@ikijs/mcp 0.37.1 → 0.38.1

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
@@ -1528,6 +1528,409 @@ interface SweepManifest {
1528
1528
  }[];
1529
1529
  }
1530
1530
 
1531
+ /**
1532
+ * One finished character picture on the layer canvas, and the raster helpers
1533
+ * an in-place cut of it is built from.
1534
+ *
1535
+ * Frame: canvas px, origin top-left, x right, y down, CANVAS wide and as tall
1536
+ * as the picture's aspect gives — the frame of the layer PNGs the cut writes,
1537
+ * so a landmark read off `view_illustration_grid` lands on the same pixel here.
1538
+ *
1539
+ * Masks are one byte per canvas pixel, row-major, 1 on and 0 off. A point
1540
+ * `[x, y]` names the pixel at column x, row y.
1541
+ */
1542
+ type Point = [number, number];
1543
+ /** `[x0, y0, x1, y1]`, both corners inside: columns x0..x1, rows y0..y1. */
1544
+ type Box = [number, number, number, number];
1545
+ /** What every helper needs to index a canvas-sized buffer. */
1546
+ interface CanvasSize {
1547
+ width: number;
1548
+ height: number;
1549
+ }
1550
+
1551
+ /**
1552
+ * `view_illustration_grid`: a picture on the layer canvas as an agent reads
1553
+ * coordinates off it — a crop at an integer zoom, nearest-neighbour so the
1554
+ * pixels stay readable, with a grid every `step` canvas px labelled along the
1555
+ * top and left edges, and optionally landmarks drawn over it.
1556
+ *
1557
+ * Frame: canvas px of the CANVAS-wide canvas `loadIllustration` produces,
1558
+ * origin top-left, x right, y down. A grid line labelled `v` sits on the left
1559
+ * (top) edge of canvas pixel `v`; a landmark coordinate `v` names that pixel,
1560
+ * so landmarks are drawn through pixel centres, half a pixel past the line.
1561
+ * The picture is shown as given, its opaque backdrop included; only real
1562
+ * transparency shows the view's own backdrop.
1563
+ *
1564
+ * Labels are drawn from a small built-in bitmap font rather than SVG text,
1565
+ * whose glyphs come from whatever fonts the host has installed: a server in
1566
+ * a container without fonts would draw a grid with no numbers on it.
1567
+ */
1568
+
1569
+ interface GridCrop {
1570
+ x: number;
1571
+ y: number;
1572
+ w: number;
1573
+ h: number;
1574
+ }
1575
+ interface ViewIllustrationGridInput {
1576
+ /** The picture (PNG, JPEG or WebP), resolved against cwd. */
1577
+ imagePath: string;
1578
+ /** A `.png` under the working directory, its folder existing. */
1579
+ outputPath: string;
1580
+ /** Canvas px; the whole canvas when omitted, clamped to it otherwise. */
1581
+ crop?: GridCrop;
1582
+ /** Integer 1..8; 1 when omitted. */
1583
+ zoom?: number;
1584
+ /** Grid spacing in canvas px, an integer of at least 5; 50 when omitted. */
1585
+ step?: number;
1586
+ /** Drawn generically by shape, each labelled with its key path. */
1587
+ landmarks?: Record<string, unknown>;
1588
+ }
1589
+ type ViewIllustrationGridResult = {
1590
+ ok: true;
1591
+ path: string;
1592
+ crop: GridCrop;
1593
+ zoom: number;
1594
+ step: number;
1595
+ canvas: {
1596
+ width: number;
1597
+ height: number;
1598
+ };
1599
+ } | {
1600
+ ok: false;
1601
+ error: string;
1602
+ };
1603
+ /**
1604
+ * Write the gridded view. Only caller-input failures (`AutoRigInputError`)
1605
+ * come back as `{ ok: false, error }`; any refusal writes nothing.
1606
+ */
1607
+ declare function viewIllustrationGrid(input: ViewIllustrationGridInput): Promise<ViewIllustrationGridResult>;
1608
+
1609
+ /**
1610
+ * The landmarks one finished picture is cut by: where its features sit, the
1611
+ * outlines that split its hair, and the points its colours and floods start
1612
+ * from, all read off `view_illustration_grid` by an agent.
1613
+ *
1614
+ * A generator input, not part of the `.iki` contract. `validateLandmarks` is
1615
+ * the authoritative check for every caller: it refuses with an
1616
+ * `AutoRigInputError` whose message starts at the offending path
1617
+ * (`landmarks.eyes.L.iris.rx ...`) and returns the landmarks with every
1618
+ * default filled in.
1619
+ *
1620
+ * Frame: canvas px, origin top-left, x right, y down; a point names a pixel.
1621
+ * `L` is the character's left, the viewer's right.
1622
+ */
1623
+
1624
+ /** Where the colour classes come from: each point reads a small patch, and a
1625
+ * pixel is hair or skin by which set it is nearer. A missing tone leaves
1626
+ * paint in it unclassed or on the wrong side. */
1627
+ interface IllustrationSamples {
1628
+ hair: {
1629
+ /** On the hair's main colour, spread over the head; a point on skin or
1630
+ * ink makes the face read as hair. */
1631
+ base: Point[];
1632
+ /** On the hair's shadowed parts; without them shaded strands can fall to
1633
+ * the skin. */
1634
+ shadow?: Point[];
1635
+ /** On the hair's sheen; without them a bright band can read as neither. */
1636
+ highlight?: Point[];
1637
+ };
1638
+ skin: {
1639
+ /** On lit skin (cheeks, forehead); a point on hair or a blush makes the
1640
+ * face and the hair swap paint. */
1641
+ base: Point[];
1642
+ /** On shaded skin (under the bangs, the neck); without them shaded skin
1643
+ * can fall to the hair. */
1644
+ shadow?: Point[];
1645
+ };
1646
+ }
1647
+ interface IllustrationEye {
1648
+ /** The whole drawn eye, lashes included; a box that clips the eye leaves
1649
+ * the clipped paint on the face. */
1650
+ box: Box;
1651
+ /** The iris disc, its centre inside `box`; an ellipse wider than the disc
1652
+ * pulls sclera or lash into the iris. */
1653
+ iris: {
1654
+ cx: number;
1655
+ cy: number;
1656
+ rx: number;
1657
+ ry: number;
1658
+ };
1659
+ }
1660
+ interface IllustrationBrow {
1661
+ /** The brow's centreline, tail first, 2 or more points; a line off the
1662
+ * brow leaves part of it on the face. */
1663
+ line: Point[];
1664
+ /** Half-width of the band around `line` the brow is cut from (8 when
1665
+ * omitted); too narrow leaves the brow's edge behind, too wide takes hair
1666
+ * or lash. */
1667
+ halfWidth: number;
1668
+ /** The band's half-width at the tail, where the brow thins (5 when
1669
+ * omitted); too wide takes the hair beside the tail. */
1670
+ tailHalfWidth: number;
1671
+ }
1672
+ /** A custom part's cut: the back hair inside a polygon. */
1673
+ interface IllustrationPolygonCut {
1674
+ /** The part's id, also its layer's file name: a plain identifier that no
1675
+ * role takes. */
1676
+ id: string;
1677
+ /** Where the part hangs from the head (a tail's knot); the part swings
1678
+ * about it, so a tie off the root tears the part away from the head as it
1679
+ * swings. */
1680
+ tie: Point;
1681
+ /** Everything of the back hair inside it goes to the part; a polygon that
1682
+ * misses a strand leaves it in the back hair, where it widens the head
1683
+ * the turn is fitted to. */
1684
+ polygon: Point[];
1685
+ }
1686
+ /** A custom part's cut: the back hair on one side of a boundary line. */
1687
+ interface IllustrationSideCut {
1688
+ /** The part's id, also its layer's file name: a plain identifier that no
1689
+ * role takes. */
1690
+ id: string;
1691
+ /** Where the part hangs from the head (a tail's knot); the part swings
1692
+ * about it, so a tie off the root tears the part away from the head as it
1693
+ * swings. */
1694
+ tie: Point;
1695
+ /** Which side of `line` the part lies on, as the viewer sees it: `left`
1696
+ * takes the hair at smaller x. The wrong side takes the head's hair. */
1697
+ side: "left" | "right";
1698
+ /** Where the part leaves the head's hair, top to bottom (y strictly
1699
+ * ascending), 2 or more points; a line inside the part leaves its root in
1700
+ * the back hair. */
1701
+ line: Point[];
1702
+ /** Under the line's last point, the part is everything on its side of the
1703
+ * column x = `below`; set it between the part and the body's hair. */
1704
+ below: number;
1705
+ /** A box around a ribbon or tie: its strongly coloured paint that is not
1706
+ * hair goes with the part instead of staying in the back hair. */
1707
+ ribbonBox?: Box;
1708
+ }
1709
+ type IllustrationCustomCut = IllustrationPolygonCut | IllustrationSideCut;
1710
+ /** The landmarks with every default applied. */
1711
+ interface IllustrationLandmarks {
1712
+ /** Colour samples for hair and skin; a sample on the wrong paint moves
1713
+ * that paint to the other class across the whole picture. */
1714
+ samples: IllustrationSamples;
1715
+ /** `L` is the character's left eye, on the viewer's right; a swapped pair
1716
+ * rigs each eye with the other side's motion. */
1717
+ eyes: {
1718
+ L: IllustrationEye;
1719
+ R: IllustrationEye;
1720
+ };
1721
+ /** Each side optional; a brow left out stays painted on the face and
1722
+ * never moves. */
1723
+ brows?: {
1724
+ L?: IllustrationBrow;
1725
+ R?: IllustrationBrow;
1726
+ };
1727
+ /** The drawn nose; left out, it stays on the face. A box that clips it
1728
+ * leaves the clipped paint on the face. */
1729
+ nose?: {
1730
+ box: Box;
1731
+ };
1732
+ mouth: {
1733
+ /** The whole drawn mouth; a box that clips it leaves paint on the face. */
1734
+ box: Box;
1735
+ /** The viewer's left end of the drawn mouth line; the lip set's corners
1736
+ * land on the two corners, so a corner off the line skews the mouth. */
1737
+ cornerL: Point;
1738
+ /** The viewer's right end of the drawn mouth line. */
1739
+ cornerR: Point;
1740
+ };
1741
+ /** Polygon, 3 or more points: the bangs and the strands beside the face.
1742
+ * Wider than the face, the turn is clamped; narrower, the bangs' edge
1743
+ * stays in the back hair. */
1744
+ frontHair: Point[];
1745
+ /** Polygons, 3 or more points each, round a lock that hangs from under
1746
+ * the bangs in front of the ear and the cheek's edge, each side optional
1747
+ * (`L` the character's left, on the viewer's right): its hair is
1748
+ * `hair_side_<side>`, drawn over the face and under `hair_front`, and
1749
+ * rigged to ride the face. Trace the lock's outline from up inside
1750
+ * `frontHair` (the two may overlap: the front hair keeps the paint both
1751
+ * claim) down round its tip. The lock's root is carried up under the
1752
+ * bangs. Under the lock, skin is filled only where it crosses the face's
1753
+ * own paint (the ear on one side and the cheek on the other) and inside
1754
+ * `skull`; the back hair is filled under it down to `shellLower`, so lower
1755
+ * `shellLower` at that side to where the hair behind the lock ends. A top
1756
+ * below the front hair leaves a strip of the lock in the back hair and
1757
+ * its root showing; a polygon reaching over the eye's outer corner puts it under
1758
+ * the lock at rest; one wider than the lock takes the back hair beside
1759
+ * it, which then rides the face. */
1760
+ sideHair?: {
1761
+ L?: Point[];
1762
+ R?: Point[];
1763
+ };
1764
+ /** Polygon, 3 or more points: the head's skin, the part hidden under the
1765
+ * hair included, the ears not; skin is filled in under the bangs and the
1766
+ * side locks inside it, so too small shows hair through the forehead on
1767
+ * a turn, and one out over an ear lays skin where hair is behind a
1768
+ * lock. */
1769
+ skull: Point[];
1770
+ /** The back hair's lower edge behind the face, left to right (x strictly
1771
+ * ascending), 2 or more points; hair is filled in behind the face down to
1772
+ * it, so too high shows a gap under the jaw on a turn. */
1773
+ shellLower: Point[];
1774
+ /** 1 or more, on the face's skin: cheeks, forehead, and one on each ear;
1775
+ * skin no seed reaches stays out of the face. */
1776
+ skinSeeds: Point[];
1777
+ /** 1 or more, on the neck and the chest; paint no seed reaches stays out
1778
+ * of the body. */
1779
+ bodySeeds: Point[];
1780
+ /** Backdrop pockets the figure encloses, which the flood from the border
1781
+ * cannot reach; a pocket without one stays painted. Pockets the hair
1782
+ * rings (gaps between strands) are keyed without one. Empty when
1783
+ * omitted. */
1784
+ backgroundSeeds: Point[];
1785
+ /** Backdrop-coloured paint the hair rings that is paint, not backdrop (a
1786
+ * pale clip between two locks): a pocket holding one is never keyed on
1787
+ * its own. Empty when omitted. */
1788
+ paintSeeds: Point[];
1789
+ /** The row the neck is carried up to behind the chin; too low shows a gap
1790
+ * under the jaw when the head turns or nods. */
1791
+ neckTopY: number;
1792
+ /** Polygons, 3 or more points each, where paint the colour samples call
1793
+ * hair belongs to the body: a dark jacket under near-black hair, a
1794
+ * hair-coloured bow on the chest. Without one such paint is cut into the
1795
+ * hair layers; one over the hair takes it out of them. Empty when
1796
+ * omitted. */
1797
+ bodyOnly: Point[][];
1798
+ /** Parts cut out of the back hair (tails, a ponytail); empty when omitted.
1799
+ * A part left in the back hair widens the head the turn is fitted to. */
1800
+ customParts: IllustrationCustomCut[];
1801
+ }
1802
+
1803
+ /**
1804
+ * What the stages of an in-place cut share: the context they cut from, a
1805
+ * layer in memory, a check, and the fills every stage builds layers with.
1806
+ */
1807
+
1808
+ /** One number an agent acts on. */
1809
+ interface CutCheck {
1810
+ id: string;
1811
+ /** `fail`: the cut is wrong and `passed` is false while it fails.
1812
+ * `warn`: worth a look; `passed` ignores it. */
1813
+ level: "fail" | "warn";
1814
+ pass: boolean;
1815
+ /** Null when there is nothing to measure (no face on the eye row). */
1816
+ value: number | null;
1817
+ /** Null for a number reported without a limit. */
1818
+ limit: number | null;
1819
+ /** Which landmark to move, and which way, when the check fails. */
1820
+ hint: string;
1821
+ /** Measured apart from `value`: on `stack`, the share of the mouth box's
1822
+ * own pixels off (the mouth is replaced later, so it does not count). */
1823
+ apart?: {
1824
+ mouthBox: number;
1825
+ };
1826
+ /** On `pockets`: the hair-rung pockets keyed as backdrop on their own, a
1827
+ * point inside each. */
1828
+ keyed?: Point[];
1829
+ }
1830
+
1831
+ /**
1832
+ * `cutLayersFromIllustration`: one finished character picture cut, in
1833
+ * place, into role layers on the canvas: the face, the front and back hair,
1834
+ * a side lock on each side given, the body and each custom part (a tail, a
1835
+ * ponytail) as its own file. Every
1836
+ * visible pixel is copied from the picture; what a layer hides when the rig
1837
+ * moves it (the forehead under the bangs, the hair behind the face, the
1838
+ * neck behind the chin, the cheek under a side lock) is filled in from the
1839
+ * paint around it.
1840
+ *
1841
+ * Driven by landmarks an agent reads off `view_illustration_grid`
1842
+ * (`illustration-landmarks.ts`), and checked: the report says, in numbers,
1843
+ * whether the layers stack back into the picture, whether each seed and
1844
+ * sample sits on the paint it should, how much of each fill was made up far
1845
+ * from any paint, and whether the front hair is wider than the face; and
1846
+ * `measure_layers`' own checks on the written directory follow.
1847
+ *
1848
+ * The drawn mouth is a closed line. Given a generated lip set (the
1849
+ * composer's keyed open mouth and interior), the composer cuts it and it is
1850
+ * placed on the drawn mouth's corners in place of that line.
1851
+ *
1852
+ * Frame: canvas px, origin top-left, x right, y down, CANVAS wide; every
1853
+ * layer is a canvas-sized PNG with the paint where the picture has it.
1854
+ */
1855
+
1856
+ interface CutLayersFromIllustrationInput {
1857
+ /** The finished picture (PNG, JPEG or WebP), resolved against cwd. */
1858
+ imagePath: string;
1859
+ /** Checked by `validateLandmarks` against the picture's canvas. */
1860
+ landmarks: unknown;
1861
+ /** An existing directory under the working directory. */
1862
+ outputDir: string;
1863
+ /** The lip set's open mouth, its inside painted flat #00FF00 (what the
1864
+ * composer reads as `mouth_keyed.png`). With `mouthInterior` the lip set
1865
+ * is written in place of the drawn mouth, its corners on
1866
+ * `landmarks.mouth`'s; one without the other is refused. */
1867
+ mouthKeyed?: string;
1868
+ /** The lip set's cavity, teeth and tongue (the composer's
1869
+ * `mouth_interior.png`); see `mouthKeyed`. */
1870
+ mouthInterior?: string;
1871
+ }
1872
+ interface CutLayer {
1873
+ role: string;
1874
+ path: string;
1875
+ /** `[x0, y0, x1, y1]` of the painted pixels, both corners inside; null
1876
+ * for a layer with none. */
1877
+ box: Box | null;
1878
+ pixels: number;
1879
+ }
1880
+ /** `measureLayers`' report on the written directory, less the checks whose
1881
+ * only remedy is re-laying-out or regenerating a generated part (see
1882
+ * `measureDir`'s `inPlace`). */
1883
+ interface CutMeasure {
1884
+ warnings: string[];
1885
+ /** The lip set's opening as the rig reads it, with a lip set. */
1886
+ lips?: LipFacts;
1887
+ }
1888
+ interface CutCustomPart {
1889
+ id: string;
1890
+ path: string;
1891
+ box: Box | null;
1892
+ pixels: number;
1893
+ /** The landmark's tie, for the custom part's rig. */
1894
+ tie: Point;
1895
+ }
1896
+ type CutLayersFromIllustrationResult = {
1897
+ ok: true;
1898
+ outputDir: string;
1899
+ canvas: CanvasSize;
1900
+ layers: CutLayer[];
1901
+ customParts: CutCustomPart[];
1902
+ previews: {
1903
+ labels: string;
1904
+ landmarks: string;
1905
+ };
1906
+ checks: CutCheck[];
1907
+ measure: CutMeasure;
1908
+ /** No fail-level check failed. */
1909
+ passed: boolean;
1910
+ } | {
1911
+ ok: false;
1912
+ error: string;
1913
+ };
1914
+
1915
+ /**
1916
+ * Cut the picture into layers in `outputDir`. Only caller-input failures
1917
+ * (`AutoRigInputError`) come back as `{ ok: false, error }`; a refusal
1918
+ * writes nothing. A write that fails part-way says the dir is now a mix:
1919
+ * the files written before it replace an earlier cut's of the same name, and
1920
+ * the rest of that cut's files (a role this cut would have removed too) are
1921
+ * still there until the cut is run again.
1922
+ */
1923
+ declare function cutLayersFromIllustration(input: CutLayersFromIllustrationInput): Promise<CutLayersFromIllustrationResult>;
1924
+ /**
1925
+ * A cut as the tool's text: the written files one per line, a `CHECK` line
1926
+ * per check (`WARN` a warn-level check that did not pass, `FAIL` a
1927
+ * fail-level one), the `MEASURE:` lines, and last `CUT pass` or `CUT FAIL:`
1928
+ * with the failed fail-level checks.
1929
+ */
1930
+ declare function formatCutReport(r: Extract<CutLayersFromIllustrationResult, {
1931
+ ok: true;
1932
+ }>): string;
1933
+
1531
1934
  declare function createIkiMcpServer(): McpServer;
1532
1935
 
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 };
1936
+ 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 CutCheck, type CutCustomPart, type CutLayer, type CutLayersFromIllustrationInput, type CutLayersFromIllustrationResult, type CutMeasure, type DeformerSummary, type DescribeResult, type GridCrop, type IkiSummary, type IllustrationBrow, type IllustrationCustomCut, type IllustrationEye, type IllustrationLandmarks, type IllustrationPolygonCut, type IllustrationSamples, type IllustrationSideCut, 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, type ViewIllustrationGridInput, type ViewIllustrationGridResult, autoRigFromLayers, checkCustomGate, checkModelFolds, checkNod, checkSweep, composeLayersFromParts, createIkiMcpServer, cutLayersFromIllustration, describeIki, describeIkiAt, describeRigPlan, failedCustomGate, formatCustomGate, formatCutReport, formatFoldReport, formatHairSideReport, formatMeasureReport, formatNodReport, formatPhysicsReport, formatRigPlanReport, formatSweepReport, formatTurnReport, listStandardParameters, measureLayers, measureTurnReference, probeRig, renderPoses, validateIki, viewIllustrationGrid };