@ikijs/mcp 0.23.2 → 0.25.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.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  createIkiMcpServer
4
- } from "./chunk-SXLILLB6.mjs";
4
+ } from "./chunk-JIVXQW4L.mjs";
5
5
 
6
6
  // src/cli.ts
7
7
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
@@ -9,6 +9,9 @@ async function main() {
9
9
  const server = createIkiMcpServer();
10
10
  await server.connect(new StdioServerTransport());
11
11
  }
12
+ for (const signal of ["SIGINT", "SIGTERM", "SIGHUP"]) {
13
+ process.on(signal, () => process.exit(0));
14
+ }
12
15
  main().catch((err) => {
13
16
  console.error(err);
14
17
  process.exit(1);
package/dist/cli.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { createIkiMcpServer } from \"./server\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\n\nasync function main() {\n const server = createIkiMcpServer();\n await server.connect(new StdioServerTransport());\n}\n\nmain().catch((err) => {\n console.error(err);\n process.exit(1);\n});\n"],"mappings":";;;;;;AAEA,SAAS,4BAA4B;AAErC,eAAe,OAAO;AACpB,QAAM,SAAS,mBAAmB;AAClC,QAAM,OAAO,QAAQ,IAAI,qBAAqB,CAAC;AACjD;AAEA,KAAK,EAAE,MAAM,CAAC,QAAQ;AACpB,UAAQ,MAAM,GAAG;AACjB,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":[]}
1
+ {"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { createIkiMcpServer } from \"./server\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\n\nasync function main() {\n const server = createIkiMcpServer();\n await server.connect(new StdioServerTransport());\n}\n\n// Turn signals into a normal exit so 'exit' handlers (a render's browser\n// cleanup) run; the default action would skip them.\nfor (const signal of [\"SIGINT\", \"SIGTERM\", \"SIGHUP\"] as const) {\n process.on(signal, () => process.exit(0));\n}\n\nmain().catch((err) => {\n console.error(err);\n process.exit(1);\n});\n"],"mappings":";;;;;;AAEA,SAAS,4BAA4B;AAErC,eAAe,OAAO;AACpB,QAAM,SAAS,mBAAmB;AAClC,QAAM,OAAO,QAAQ,IAAI,qBAAqB,CAAC;AACjD;AAIA,WAAW,UAAU,CAAC,UAAU,WAAW,QAAQ,GAAY;AAC7D,UAAQ,GAAG,QAAQ,MAAM,QAAQ,KAAK,CAAC,CAAC;AAC1C;AAEA,KAAK,EAAE,MAAM,CAAC,QAAQ;AACpB,UAAQ,MAAM,GAAG;AACjB,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":[]}
package/dist/index.d.mts CHANGED
@@ -1,7 +1,57 @@
1
1
  import { TurnTargets, RigStyle, IrisStrand, TurnSolveReport } from '@ikijs/editor';
2
2
  export { TurnSolveReport } from '@ikijs/editor';
3
+ import { IkiModel } from '@ikijs/format';
3
4
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
4
5
 
6
+ /** A parameter setting to check the rig at; every other parameter rests at its default. */
7
+ interface FoldPose {
8
+ /** Its sorted `id=value` pairs joined by one space; `rest` when empty. */
9
+ name: string;
10
+ values: Record<string, number>;
11
+ }
12
+ /** Where and when a target comes nearest to folding over one class of poses. */
13
+ interface FoldHit {
14
+ /** Doubled signed area at the pose over the same at rest. */
15
+ ratio: number;
16
+ /** The warp grid's cell, or the part mesh's triangle (its index into `mesh.indices` / 3). */
17
+ where: {
18
+ col: number;
19
+ row: number;
20
+ } | {
21
+ triangle: number;
22
+ };
23
+ pose: FoldPose;
24
+ /** Where it sits at rest, model space, through the static matrix chain. */
25
+ rest: {
26
+ x: number;
27
+ y: number;
28
+ };
29
+ }
30
+ interface FoldTarget {
31
+ target: {
32
+ kind: "deformer" | "part";
33
+ id: string;
34
+ };
35
+ /** Read off `worst` alone; `ok` when it is absent. */
36
+ kind: "flip" | "collapse" | "ok";
37
+ /** Least ratio over the poses `expected` rejects (every pose without it). */
38
+ worst?: FoldHit;
39
+ /** Least ratio over the poses `expected` accepts. */
40
+ expected?: FoldHit;
41
+ }
42
+ interface FoldReport {
43
+ /** How many poses were checked. */
44
+ poses: number;
45
+ thresholds: {
46
+ flip: 0;
47
+ collapse: 0.1;
48
+ };
49
+ /** One per warp deformer, then one per mesh part, each in model order. */
50
+ targets: FoldTarget[];
51
+ /** The targets that are not `ok`, worst first. */
52
+ offenders: FoldTarget[];
53
+ }
54
+
5
55
  type ValidateResult = {
6
56
  ok: true;
7
57
  } | {
@@ -162,6 +212,10 @@ type AutoRigResult = {
162
212
  * (`strandOverlap`). Absent for a layer set with no nose, which solves
163
213
  * no turn at all. */
164
214
  turn?: TurnSolveReport;
215
+ /** The written model's folds over the engine's pose set, its eyes and
216
+ * mouth shutting on purpose set apart as `expected`. Report-only: a
217
+ * fold never refuses the rig. */
218
+ folds: FoldReport;
165
219
  } | {
166
220
  ok: false;
167
221
  error: string;
@@ -572,6 +626,27 @@ type ComposeResult = {
572
626
  */
573
627
  declare function composeLayersFromParts(input: ComposeInput): Promise<ComposeResult>;
574
628
 
629
+ /**
630
+ * The fold check `auto_rig_from_layers` and `render_poses` report: the
631
+ * engine's `checkFolds` with the auto-rig's by-design closures set apart, and
632
+ * the text lines both tools print it as.
633
+ */
634
+
635
+ /** `checkFolds` over `foldPoses(model)`, the closures above kept out of `worst`. */
636
+ declare function checkModelFolds(model: IkiModel): FoldReport;
637
+ /**
638
+ * `report` as text lines: one `FOLD` line per offender, worst first, or
639
+ * `FOLDS: none over N poses`; then, when a by-design closure folds, one
640
+ * `FOLDS expected:` line naming each such part, its ratio and the parameter
641
+ * that shuts it. A `FOLD` line gives its rest point in model space and in
642
+ * model px from the top-left of the model's `canvas` — the layer PNGs' own
643
+ * pixels, the frame `RenderPlan.mouth` is in, not a render's.
644
+ */
645
+ declare function formatFoldReport(report: FoldReport, canvas: {
646
+ width: number;
647
+ height: number;
648
+ }): string[];
649
+
575
650
  /**
576
651
  * Measure the head-turn cues in a PAIR of images of the same character — one
577
652
  * facing front, one turned — and report them as three ratios. It is how a
@@ -689,6 +764,81 @@ declare function measureTurnReference(input: MeasureTurnInput): Promise<MeasureT
689
764
  * behind each, then one block per image. */
690
765
  declare function formatTurnReport(result: TurnMeasurement): string;
691
766
 
767
+ /**
768
+ * The pose plan `render_poses` captures: the canvas framing, the crops and the
769
+ * pose list, all decided from the model. It is the iki-character-loop's
770
+ * render recipe, minus the page that ran it.
771
+ */
772
+
773
+ interface RenderCrop {
774
+ sx: number;
775
+ sy: number;
776
+ sw: number;
777
+ sh: number;
778
+ dw: number;
779
+ dh: number;
780
+ }
781
+ interface RenderPose {
782
+ name: string;
783
+ values: Record<string, number>;
784
+ /** Canvas px source and output size; absent = the whole canvas. */
785
+ crop?: RenderCrop;
786
+ }
787
+ interface RenderPlan {
788
+ canvas: {
789
+ width: number;
790
+ height: number;
791
+ };
792
+ /** The player's view; absent = the model's own canvas. */
793
+ view?: {
794
+ x: number;
795
+ y: number;
796
+ width: number;
797
+ height: number;
798
+ };
799
+ fullBody: boolean;
800
+ /** The mouth's centre in model px from the top-left. */
801
+ mouth?: {
802
+ cx: number;
803
+ cy: number;
804
+ };
805
+ poses: RenderPose[];
806
+ }
807
+ interface RenderPosesInput {
808
+ /** The rigged `.iki` to render (resolved against cwd). */
809
+ modelPath: string;
810
+ /** Existing directory under cwd the pose PNGs are written into. */
811
+ outDir: string;
812
+ }
813
+ type RenderPosesResult = {
814
+ ok: true;
815
+ outDir: string;
816
+ canvas: RenderPlan["canvas"];
817
+ fullBody: boolean;
818
+ mouth?: RenderPlan["mouth"];
819
+ /** Texture indices the engine could not load; the renders lack them. */
820
+ failedTextures: number[];
821
+ poses: {
822
+ name: string;
823
+ path: string;
824
+ }[];
825
+ /** The model's own canvas, which `folds`' rest points are placed on in
826
+ * the text (`canvas` is the render's). */
827
+ modelCanvas: IkiModel["canvas"];
828
+ /** The model's folds, as `auto_rig_from_layers` reports them.
829
+ * Report-only: a fold never fails the render. */
830
+ folds: FoldReport;
831
+ } | {
832
+ ok: false;
833
+ error: string;
834
+ };
835
+ /**
836
+ * Render the model's pose set into `outDir`. Only caller-input failures
837
+ * (`AutoRigInputError`, `IkiFormatError`, and no installed browser) come back as
838
+ * `{ ok: false, error }`; a browser or page failure throws.
839
+ */
840
+ declare function renderPoses(input: RenderPosesInput): Promise<RenderPosesResult>;
841
+
692
842
  declare function createIkiMcpServer(): McpServer;
693
843
 
694
- 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 StandardParameterInfo, type TurnImageMeasure, type TurnMeasurement, type ValidateResult, autoRigFromLayers, composeLayersFromParts, createIkiMcpServer, describeIki, formatMeasureReport, formatTurnReport, listStandardParameters, measureLayers, measureTurnReference, validateIki };
844
+ 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 RenderPosesInput, type RenderPosesResult, type StandardParameterInfo, type TurnImageMeasure, type TurnMeasurement, type ValidateResult, autoRigFromLayers, checkModelFolds, composeLayersFromParts, createIkiMcpServer, describeIki, formatFoldReport, formatMeasureReport, formatTurnReport, listStandardParameters, measureLayers, measureTurnReference, renderPoses, validateIki };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,57 @@
1
1
  import { TurnTargets, RigStyle, IrisStrand, TurnSolveReport } from '@ikijs/editor';
2
2
  export { TurnSolveReport } from '@ikijs/editor';
3
+ import { IkiModel } from '@ikijs/format';
3
4
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
4
5
 
6
+ /** A parameter setting to check the rig at; every other parameter rests at its default. */
7
+ interface FoldPose {
8
+ /** Its sorted `id=value` pairs joined by one space; `rest` when empty. */
9
+ name: string;
10
+ values: Record<string, number>;
11
+ }
12
+ /** Where and when a target comes nearest to folding over one class of poses. */
13
+ interface FoldHit {
14
+ /** Doubled signed area at the pose over the same at rest. */
15
+ ratio: number;
16
+ /** The warp grid's cell, or the part mesh's triangle (its index into `mesh.indices` / 3). */
17
+ where: {
18
+ col: number;
19
+ row: number;
20
+ } | {
21
+ triangle: number;
22
+ };
23
+ pose: FoldPose;
24
+ /** Where it sits at rest, model space, through the static matrix chain. */
25
+ rest: {
26
+ x: number;
27
+ y: number;
28
+ };
29
+ }
30
+ interface FoldTarget {
31
+ target: {
32
+ kind: "deformer" | "part";
33
+ id: string;
34
+ };
35
+ /** Read off `worst` alone; `ok` when it is absent. */
36
+ kind: "flip" | "collapse" | "ok";
37
+ /** Least ratio over the poses `expected` rejects (every pose without it). */
38
+ worst?: FoldHit;
39
+ /** Least ratio over the poses `expected` accepts. */
40
+ expected?: FoldHit;
41
+ }
42
+ interface FoldReport {
43
+ /** How many poses were checked. */
44
+ poses: number;
45
+ thresholds: {
46
+ flip: 0;
47
+ collapse: 0.1;
48
+ };
49
+ /** One per warp deformer, then one per mesh part, each in model order. */
50
+ targets: FoldTarget[];
51
+ /** The targets that are not `ok`, worst first. */
52
+ offenders: FoldTarget[];
53
+ }
54
+
5
55
  type ValidateResult = {
6
56
  ok: true;
7
57
  } | {
@@ -162,6 +212,10 @@ type AutoRigResult = {
162
212
  * (`strandOverlap`). Absent for a layer set with no nose, which solves
163
213
  * no turn at all. */
164
214
  turn?: TurnSolveReport;
215
+ /** The written model's folds over the engine's pose set, its eyes and
216
+ * mouth shutting on purpose set apart as `expected`. Report-only: a
217
+ * fold never refuses the rig. */
218
+ folds: FoldReport;
165
219
  } | {
166
220
  ok: false;
167
221
  error: string;
@@ -572,6 +626,27 @@ type ComposeResult = {
572
626
  */
573
627
  declare function composeLayersFromParts(input: ComposeInput): Promise<ComposeResult>;
574
628
 
629
+ /**
630
+ * The fold check `auto_rig_from_layers` and `render_poses` report: the
631
+ * engine's `checkFolds` with the auto-rig's by-design closures set apart, and
632
+ * the text lines both tools print it as.
633
+ */
634
+
635
+ /** `checkFolds` over `foldPoses(model)`, the closures above kept out of `worst`. */
636
+ declare function checkModelFolds(model: IkiModel): FoldReport;
637
+ /**
638
+ * `report` as text lines: one `FOLD` line per offender, worst first, or
639
+ * `FOLDS: none over N poses`; then, when a by-design closure folds, one
640
+ * `FOLDS expected:` line naming each such part, its ratio and the parameter
641
+ * that shuts it. A `FOLD` line gives its rest point in model space and in
642
+ * model px from the top-left of the model's `canvas` — the layer PNGs' own
643
+ * pixels, the frame `RenderPlan.mouth` is in, not a render's.
644
+ */
645
+ declare function formatFoldReport(report: FoldReport, canvas: {
646
+ width: number;
647
+ height: number;
648
+ }): string[];
649
+
575
650
  /**
576
651
  * Measure the head-turn cues in a PAIR of images of the same character — one
577
652
  * facing front, one turned — and report them as three ratios. It is how a
@@ -689,6 +764,81 @@ declare function measureTurnReference(input: MeasureTurnInput): Promise<MeasureT
689
764
  * behind each, then one block per image. */
690
765
  declare function formatTurnReport(result: TurnMeasurement): string;
691
766
 
767
+ /**
768
+ * The pose plan `render_poses` captures: the canvas framing, the crops and the
769
+ * pose list, all decided from the model. It is the iki-character-loop's
770
+ * render recipe, minus the page that ran it.
771
+ */
772
+
773
+ interface RenderCrop {
774
+ sx: number;
775
+ sy: number;
776
+ sw: number;
777
+ sh: number;
778
+ dw: number;
779
+ dh: number;
780
+ }
781
+ interface RenderPose {
782
+ name: string;
783
+ values: Record<string, number>;
784
+ /** Canvas px source and output size; absent = the whole canvas. */
785
+ crop?: RenderCrop;
786
+ }
787
+ interface RenderPlan {
788
+ canvas: {
789
+ width: number;
790
+ height: number;
791
+ };
792
+ /** The player's view; absent = the model's own canvas. */
793
+ view?: {
794
+ x: number;
795
+ y: number;
796
+ width: number;
797
+ height: number;
798
+ };
799
+ fullBody: boolean;
800
+ /** The mouth's centre in model px from the top-left. */
801
+ mouth?: {
802
+ cx: number;
803
+ cy: number;
804
+ };
805
+ poses: RenderPose[];
806
+ }
807
+ interface RenderPosesInput {
808
+ /** The rigged `.iki` to render (resolved against cwd). */
809
+ modelPath: string;
810
+ /** Existing directory under cwd the pose PNGs are written into. */
811
+ outDir: string;
812
+ }
813
+ type RenderPosesResult = {
814
+ ok: true;
815
+ outDir: string;
816
+ canvas: RenderPlan["canvas"];
817
+ fullBody: boolean;
818
+ mouth?: RenderPlan["mouth"];
819
+ /** Texture indices the engine could not load; the renders lack them. */
820
+ failedTextures: number[];
821
+ poses: {
822
+ name: string;
823
+ path: string;
824
+ }[];
825
+ /** The model's own canvas, which `folds`' rest points are placed on in
826
+ * the text (`canvas` is the render's). */
827
+ modelCanvas: IkiModel["canvas"];
828
+ /** The model's folds, as `auto_rig_from_layers` reports them.
829
+ * Report-only: a fold never fails the render. */
830
+ folds: FoldReport;
831
+ } | {
832
+ ok: false;
833
+ error: string;
834
+ };
835
+ /**
836
+ * Render the model's pose set into `outDir`. Only caller-input failures
837
+ * (`AutoRigInputError`, `IkiFormatError`, and no installed browser) come back as
838
+ * `{ ok: false, error }`; a browser or page failure throws.
839
+ */
840
+ declare function renderPoses(input: RenderPosesInput): Promise<RenderPosesResult>;
841
+
692
842
  declare function createIkiMcpServer(): McpServer;
693
843
 
694
- 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 StandardParameterInfo, type TurnImageMeasure, type TurnMeasurement, type ValidateResult, autoRigFromLayers, composeLayersFromParts, createIkiMcpServer, describeIki, formatMeasureReport, formatTurnReport, listStandardParameters, measureLayers, measureTurnReference, validateIki };
844
+ 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 RenderPosesInput, type RenderPosesResult, type StandardParameterInfo, type TurnImageMeasure, type TurnMeasurement, type ValidateResult, autoRigFromLayers, checkModelFolds, composeLayersFromParts, createIkiMcpServer, describeIki, formatFoldReport, formatMeasureReport, formatTurnReport, listStandardParameters, measureLayers, measureTurnReference, renderPoses, validateIki };