@ikijs/mcp 0.3.1 → 0.5.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 +25 -7
- package/dist/chunk-MDSZNVVK.mjs +1197 -0
- package/dist/chunk-MDSZNVVK.mjs.map +1 -0
- package/dist/cli.js +677 -31
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +240 -1
- package/dist/index.d.ts +240 -1
- package/dist/index.js +683 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -1
- package/package.json +2 -2
- package/dist/chunk-6LRMADRR.mjs +0 -550
- package/dist/chunk-6LRMADRR.mjs.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -28,7 +28,6 @@ var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
|
28
28
|
var import_zod = require("zod");
|
|
29
29
|
|
|
30
30
|
// src/tools.ts
|
|
31
|
-
var import_node_fs2 = __toESM(require("fs"));
|
|
32
31
|
var import_node_path2 = __toESM(require("path"));
|
|
33
32
|
var import_format = require("@ikijs/format");
|
|
34
33
|
var import_editor2 = require("@ikijs/editor");
|
|
@@ -53,15 +52,18 @@ var AutoRigInputError = class extends Error {
|
|
|
53
52
|
this.name = "AutoRigInputError";
|
|
54
53
|
}
|
|
55
54
|
};
|
|
56
|
-
function
|
|
55
|
+
function rejectEmptyOrUrl(inputPath, noun, kind) {
|
|
57
56
|
if (typeof inputPath !== "string" || inputPath.trim() === "") {
|
|
58
|
-
throw new AutoRigInputError(
|
|
57
|
+
throw new AutoRigInputError(`${noun} is empty`);
|
|
59
58
|
}
|
|
60
59
|
if (/^[a-z][a-z0-9+.-]*:\/\//i.test(inputPath)) {
|
|
61
60
|
throw new AutoRigInputError(
|
|
62
|
-
|
|
61
|
+
`${noun} must be a ${kind}, not a URL: ${inputPath}`
|
|
63
62
|
);
|
|
64
63
|
}
|
|
64
|
+
}
|
|
65
|
+
function resolveInputPath(inputPath) {
|
|
66
|
+
rejectEmptyOrUrl(inputPath, "layer path", "file path");
|
|
65
67
|
const resolved = import_node_path.default.resolve(process.cwd(), inputPath);
|
|
66
68
|
let stat;
|
|
67
69
|
try {
|
|
@@ -76,6 +78,30 @@ function resolveInputPath(inputPath) {
|
|
|
76
78
|
}
|
|
77
79
|
return resolved;
|
|
78
80
|
}
|
|
81
|
+
function resolveInputDir(dirPath) {
|
|
82
|
+
rejectEmptyOrUrl(dirPath, "layers dir", "directory path");
|
|
83
|
+
const resolved = import_node_path.default.resolve(process.cwd(), dirPath);
|
|
84
|
+
let stat;
|
|
85
|
+
try {
|
|
86
|
+
stat = import_node_fs.default.statSync(resolved);
|
|
87
|
+
} catch {
|
|
88
|
+
throw new AutoRigInputError(`layers dir not found: ${resolved}`);
|
|
89
|
+
}
|
|
90
|
+
if (!stat.isDirectory()) {
|
|
91
|
+
throw new AutoRigInputError(`layers path is not a directory: ${resolved}`);
|
|
92
|
+
}
|
|
93
|
+
return resolved;
|
|
94
|
+
}
|
|
95
|
+
function confineToWorkingDirectory(root, dir, label, original) {
|
|
96
|
+
const realRoot = import_node_fs.default.realpathSync(root);
|
|
97
|
+
const realDir = import_node_fs.default.realpathSync(dir);
|
|
98
|
+
if (realDir !== realRoot && !realDir.startsWith(realRoot + import_node_path.default.sep)) {
|
|
99
|
+
throw new AutoRigInputError(
|
|
100
|
+
`${label} escapes the working directory: ${original}`
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
return realDir;
|
|
104
|
+
}
|
|
79
105
|
function resolveOutputPath(outputPath) {
|
|
80
106
|
if (typeof outputPath !== "string" || outputPath.trim() === "") {
|
|
81
107
|
throw new AutoRigInputError("output path is empty");
|
|
@@ -95,14 +121,49 @@ function resolveOutputPath(outputPath) {
|
|
|
95
121
|
if (!stat.isDirectory()) {
|
|
96
122
|
throw new AutoRigInputError(`output parent is not a directory: ${dir}`);
|
|
97
123
|
}
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
124
|
+
const realDir = confineToWorkingDirectory(
|
|
125
|
+
root,
|
|
126
|
+
dir,
|
|
127
|
+
"output path",
|
|
128
|
+
outputPath
|
|
129
|
+
);
|
|
130
|
+
return import_node_path.default.join(realDir, import_node_path.default.basename(resolved));
|
|
131
|
+
}
|
|
132
|
+
function resolveOutputDir(dirPath) {
|
|
133
|
+
if (typeof dirPath !== "string" || dirPath.trim() === "") {
|
|
134
|
+
throw new AutoRigInputError("output dir is empty");
|
|
135
|
+
}
|
|
136
|
+
const root = process.cwd();
|
|
137
|
+
const resolved = import_node_path.default.resolve(root, dirPath);
|
|
138
|
+
let stat;
|
|
139
|
+
try {
|
|
140
|
+
stat = import_node_fs.default.statSync(resolved);
|
|
141
|
+
} catch {
|
|
142
|
+
throw new AutoRigInputError(`output dir not found: ${resolved}`);
|
|
143
|
+
}
|
|
144
|
+
if (!stat.isDirectory()) {
|
|
145
|
+
throw new AutoRigInputError(`output dir is not a directory: ${resolved}`);
|
|
146
|
+
}
|
|
147
|
+
return confineToWorkingDirectory(root, resolved, "output dir", dirPath);
|
|
148
|
+
}
|
|
149
|
+
function writeFileAtomic(outPath, data) {
|
|
150
|
+
const tmp = `${outPath}.${process.pid}.${Date.now()}.tmp`;
|
|
151
|
+
try {
|
|
152
|
+
import_node_fs.default.writeFileSync(tmp, data);
|
|
153
|
+
try {
|
|
154
|
+
import_node_fs.default.renameSync(tmp, outPath);
|
|
155
|
+
} catch (e) {
|
|
156
|
+
try {
|
|
157
|
+
import_node_fs.default.rmSync(tmp, { force: true });
|
|
158
|
+
} catch {
|
|
159
|
+
}
|
|
160
|
+
throw e;
|
|
161
|
+
}
|
|
162
|
+
} catch (e) {
|
|
101
163
|
throw new AutoRigInputError(
|
|
102
|
-
`
|
|
164
|
+
`write: ${e instanceof Error ? e.message : String(e)}`
|
|
103
165
|
);
|
|
104
166
|
}
|
|
105
|
-
return import_node_path.default.join(realDir, import_node_path.default.basename(resolved));
|
|
106
167
|
}
|
|
107
168
|
|
|
108
169
|
// src/node-images.ts
|
|
@@ -116,7 +177,12 @@ async function decodePng(filePath) {
|
|
|
116
177
|
);
|
|
117
178
|
}
|
|
118
179
|
const { data, info } = await pipeline.ensureAlpha().raw().toBuffer({ resolveWithObject: true });
|
|
119
|
-
return {
|
|
180
|
+
return {
|
|
181
|
+
width: info.width,
|
|
182
|
+
height: info.height,
|
|
183
|
+
rgba: data,
|
|
184
|
+
hasAlpha: metadata.hasAlpha ?? false
|
|
185
|
+
};
|
|
120
186
|
} catch (e) {
|
|
121
187
|
if (e instanceof AutoRigInputError) throw e;
|
|
122
188
|
const msg = e instanceof Error ? e.message : String(e);
|
|
@@ -138,15 +204,15 @@ async function renderAtlasToDataUri(crops, layout, quantizeColors) {
|
|
|
138
204
|
for (const crop of crops) byId.set(crop.id, crop);
|
|
139
205
|
const pad = layout.padding;
|
|
140
206
|
const composites = await Promise.all(
|
|
141
|
-
layout.placements.map(async (
|
|
142
|
-
const crop = byId.get(
|
|
207
|
+
layout.placements.map(async (placement2) => {
|
|
208
|
+
const crop = byId.get(placement2.id);
|
|
143
209
|
if (crop === void 0) {
|
|
144
210
|
throw new AutoRigInputError(
|
|
145
|
-
`no crop for atlas placement "${
|
|
211
|
+
`no crop for atlas placement "${placement2.id}"`
|
|
146
212
|
);
|
|
147
213
|
}
|
|
148
214
|
const input = pad > 0 ? await (0, import_sharp.default)(crop.buffer).extend({ right: pad, bottom: pad, extendWith: "copy" }).png().toBuffer() : crop.buffer;
|
|
149
|
-
return { input, left:
|
|
215
|
+
return { input, left: placement2.x, top: placement2.y };
|
|
150
216
|
})
|
|
151
217
|
);
|
|
152
218
|
const page = await (0, import_sharp.default)({
|
|
@@ -412,13 +478,13 @@ async function autoRigFromLayers(input) {
|
|
|
412
478
|
);
|
|
413
479
|
}
|
|
414
480
|
const partTextureAssignments = crops.map((crop) => {
|
|
415
|
-
const
|
|
416
|
-
if (
|
|
481
|
+
const placement2 = layout.placements.find((p) => p.id === crop.id);
|
|
482
|
+
if (placement2 === void 0) {
|
|
417
483
|
throw new Error(`auto-rig: no atlas placement for "${crop.id}"`);
|
|
418
484
|
}
|
|
419
485
|
return {
|
|
420
486
|
partId: crop.id,
|
|
421
|
-
uv: (0, import_editor2.uvRectFor)(
|
|
487
|
+
uv: (0, import_editor2.uvRectFor)(placement2, {
|
|
422
488
|
width: layout.pageWidth,
|
|
423
489
|
height: layout.pageHeight
|
|
424
490
|
})
|
|
@@ -426,19 +492,7 @@ async function autoRigFromLayers(input) {
|
|
|
426
492
|
});
|
|
427
493
|
doc.applyAtlas({ textures: [{ source: dataUri }], partTextureAssignments });
|
|
428
494
|
const finalModel = (0, import_format.parseIkiModel)(doc.getModel());
|
|
429
|
-
|
|
430
|
-
const tmp = `${outPath}.${process.pid}.${Date.now()}.tmp`;
|
|
431
|
-
import_node_fs2.default.writeFileSync(tmp, JSON.stringify(finalModel));
|
|
432
|
-
try {
|
|
433
|
-
import_node_fs2.default.renameSync(tmp, outPath);
|
|
434
|
-
} catch (e) {
|
|
435
|
-
try {
|
|
436
|
-
import_node_fs2.default.rmSync(tmp, { force: true });
|
|
437
|
-
} catch {
|
|
438
|
-
}
|
|
439
|
-
throw e;
|
|
440
|
-
}
|
|
441
|
-
});
|
|
495
|
+
writeFileAtomic(outPath, JSON.stringify(finalModel));
|
|
442
496
|
return {
|
|
443
497
|
ok: true,
|
|
444
498
|
path: outPath,
|
|
@@ -453,9 +507,531 @@ async function autoRigFromLayers(input) {
|
|
|
453
507
|
}
|
|
454
508
|
}
|
|
455
509
|
|
|
510
|
+
// src/compose.ts
|
|
511
|
+
var import_node_fs3 = __toESM(require("fs"));
|
|
512
|
+
var import_node_path4 = __toESM(require("path"));
|
|
513
|
+
var import_sharp2 = __toESM(require("sharp"));
|
|
514
|
+
|
|
515
|
+
// src/measure.ts
|
|
516
|
+
var import_node_fs2 = __toESM(require("fs"));
|
|
517
|
+
var import_node_path3 = __toESM(require("path"));
|
|
518
|
+
var IRIS_RATIO_MIN = 0.45;
|
|
519
|
+
var IRIS_RATIO_MAX = 0.72;
|
|
520
|
+
var EYE_ASPECT_MIN = 0.5;
|
|
521
|
+
var IRIS_OFFSET_MAX_X = 3;
|
|
522
|
+
var IRIS_OFFSET_MAX_Y = 10;
|
|
523
|
+
var EDGE_SOLID_MAX = 0.5;
|
|
524
|
+
var LASH_CENTRE_TOL_FRAC = 0.03;
|
|
525
|
+
var EDGE_RUN_MIN_PX = 40;
|
|
526
|
+
var FLAT_CUT_MAX_FRAC = 0.1;
|
|
527
|
+
var FLAT_CUT_MIN_PX = 40;
|
|
528
|
+
var FLAT_CUT_ALPHA_ABOVE = 120;
|
|
529
|
+
var FLAT_CUT_ALPHA_BELOW = 140;
|
|
530
|
+
async function layerStats(filePath) {
|
|
531
|
+
const { width: W, height: H, rgba } = await decodePng(filePath);
|
|
532
|
+
const alpha = (x, y) => rgba[(y * W + x) * 4 + 3];
|
|
533
|
+
let minX = W;
|
|
534
|
+
let minY = H;
|
|
535
|
+
let maxX = -1;
|
|
536
|
+
let maxY = -1;
|
|
537
|
+
let sumX = 0;
|
|
538
|
+
let sumY = 0;
|
|
539
|
+
let n = 0;
|
|
540
|
+
for (let y = 0; y < H; y++) {
|
|
541
|
+
for (let x = 0; x < W; x++) {
|
|
542
|
+
if (alpha(x, y) > 8) {
|
|
543
|
+
if (x < minX) minX = x;
|
|
544
|
+
if (x > maxX) maxX = x;
|
|
545
|
+
if (y < minY) minY = y;
|
|
546
|
+
if (y > maxY) maxY = y;
|
|
547
|
+
sumX += x;
|
|
548
|
+
sumY += y;
|
|
549
|
+
n++;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
if (maxX < 0) return null;
|
|
554
|
+
const edge = (pts) => pts.filter((v) => v > 200).length / pts.length;
|
|
555
|
+
const top = [];
|
|
556
|
+
const bottom = [];
|
|
557
|
+
const left = [];
|
|
558
|
+
const right = [];
|
|
559
|
+
for (let x = minX; x <= maxX; x++) {
|
|
560
|
+
top.push(alpha(x, minY));
|
|
561
|
+
bottom.push(alpha(x, maxY));
|
|
562
|
+
}
|
|
563
|
+
for (let y = minY; y <= maxY; y++) {
|
|
564
|
+
left.push(alpha(minX, y));
|
|
565
|
+
right.push(alpha(maxX, y));
|
|
566
|
+
}
|
|
567
|
+
let flatCutRun = 0;
|
|
568
|
+
let flatCutY = -1;
|
|
569
|
+
for (let y = minY + 1; y <= maxY; y++) {
|
|
570
|
+
let run = 0;
|
|
571
|
+
for (let x = minX; x <= maxX; x++) {
|
|
572
|
+
if (alpha(x, y - 1) < FLAT_CUT_ALPHA_ABOVE && alpha(x, y) > FLAT_CUT_ALPHA_BELOW) {
|
|
573
|
+
run++;
|
|
574
|
+
if (run > flatCutRun) {
|
|
575
|
+
flatCutRun = run;
|
|
576
|
+
flatCutY = y;
|
|
577
|
+
}
|
|
578
|
+
} else {
|
|
579
|
+
run = 0;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
return {
|
|
584
|
+
w: maxX - minX + 1,
|
|
585
|
+
h: maxY - minY + 1,
|
|
586
|
+
flatCutRun,
|
|
587
|
+
flatCutY,
|
|
588
|
+
bboxCx: (minX + maxX) / 2,
|
|
589
|
+
bboxCy: (minY + maxY) / 2,
|
|
590
|
+
massCx: sumX / n,
|
|
591
|
+
massCy: sumY / n,
|
|
592
|
+
marginTop: minY,
|
|
593
|
+
marginBottom: H - 1 - maxY,
|
|
594
|
+
marginLeft: minX,
|
|
595
|
+
marginRight: W - 1 - maxX,
|
|
596
|
+
edgeTop: edge(top),
|
|
597
|
+
edgeBottom: edge(bottom),
|
|
598
|
+
edgeLeft: edge(left),
|
|
599
|
+
edgeRight: edge(right),
|
|
600
|
+
canvasW: W,
|
|
601
|
+
canvasH: H
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
var pct = (v) => `${(v * 100).toFixed(0)}%`;
|
|
605
|
+
async function measureDir(absDir) {
|
|
606
|
+
const files = import_node_fs2.default.readdirSync(absDir).filter((f) => f.endsWith(".png") && f !== "preview.png").sort();
|
|
607
|
+
if (files.length === 0) {
|
|
608
|
+
throw new AutoRigInputError(`no role layers in ${absDir}`);
|
|
609
|
+
}
|
|
610
|
+
if (files.length > MAX_LAYERS) {
|
|
611
|
+
throw new AutoRigInputError(
|
|
612
|
+
`too many layers in ${absDir}: ${files.length} > ${MAX_LAYERS}`
|
|
613
|
+
);
|
|
614
|
+
}
|
|
615
|
+
const layers = {};
|
|
616
|
+
const empty = [];
|
|
617
|
+
for (const f of files) {
|
|
618
|
+
const role = import_node_path3.default.basename(f, ".png");
|
|
619
|
+
const m = await layerStats(import_node_path3.default.join(absDir, f));
|
|
620
|
+
if (!m) {
|
|
621
|
+
empty.push(role);
|
|
622
|
+
continue;
|
|
623
|
+
}
|
|
624
|
+
layers[role] = m;
|
|
625
|
+
}
|
|
626
|
+
const warnings = [];
|
|
627
|
+
for (const [role, m] of Object.entries(layers)) {
|
|
628
|
+
const edges = [
|
|
629
|
+
["top", m.edgeTop, m.w, m.marginTop],
|
|
630
|
+
["left", m.edgeLeft, m.h, m.marginLeft],
|
|
631
|
+
["right", m.edgeRight, m.h, m.marginRight]
|
|
632
|
+
];
|
|
633
|
+
if (role !== "body")
|
|
634
|
+
edges.push(["bottom", m.edgeBottom, m.w, m.marginBottom]);
|
|
635
|
+
for (const [side, v, span, margin] of edges) {
|
|
636
|
+
if (v > EDGE_SOLID_MAX && v * span >= EDGE_RUN_MIN_PX) {
|
|
637
|
+
const remedy = margin === 0 ? (
|
|
638
|
+
// margin 0 is consistent with a clipped placement AND with art
|
|
639
|
+
// already cropped flush that happens to sit on the boundary, and
|
|
640
|
+
// the flattened layer cannot separate them — so name the free
|
|
641
|
+
// move rather than the cause. If moving it inward leaves the
|
|
642
|
+
// edge opaque, the drawing is the one at fault.
|
|
643
|
+
`it sits flush against the canvas ${side}, which a clipped placement and already-cropped art both produce. Move it inward first \u2014 retune layout.${role}.cx/cy/w, free \u2014 and remeasure; regenerate only if the edge is still opaque with margin to spare.`
|
|
644
|
+
) : `its own drawing runs to the frame ${margin} px inside the canvas \u2014 regenerate that part with empty margin on that side. Billed.`;
|
|
645
|
+
warnings.push(
|
|
646
|
+
`${role}: ${pct(v)} of its ${side} edge is opaque \u2014 the art is cut off there, which shows as a straight seam once the head turns. Cause: ${remedy}`
|
|
647
|
+
);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
for (const [role, m] of Object.entries(layers)) {
|
|
652
|
+
if (role === "body") continue;
|
|
653
|
+
if (m.flatCutRun > FLAT_CUT_MAX_FRAC * m.w && m.flatCutRun >= FLAT_CUT_MIN_PX) {
|
|
654
|
+
warnings.push(
|
|
655
|
+
`${role}: ${m.flatCutRun}px of straight flat edge at y=${m.flatCutY} (${pct(m.flatCutRun / m.w)} of its width) \u2014 the source art is cut through there. It hides while the head faces front and opens into a seam on turn. Regenerate this part with the whole subject inside the frame.`
|
|
656
|
+
);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
for (const side of ["L", "R"]) {
|
|
660
|
+
const eye = layers[`eye_${side}`];
|
|
661
|
+
const iris = layers[`iris_${side}`];
|
|
662
|
+
const lash = layers[`lash_${side}`];
|
|
663
|
+
if (!eye) continue;
|
|
664
|
+
const aspect = eye.h / eye.w;
|
|
665
|
+
if (aspect < EYE_ASPECT_MIN) {
|
|
666
|
+
warnings.push(
|
|
667
|
+
`eye_${side}: sclera aspect h/w=${aspect.toFixed(2)} is flatter than ${EYE_ASPECT_MIN} \u2014 a round iris cannot sit inside it. Free fix first: set layout.eye_${side}.h and layout.lash_${side}.h to ${Math.ceil(eye.w * EYE_ASPECT_MIN)} (both, or the fold tears) \u2014 stretching a flat white lens is invisible. Regenerate the eyewhite taller only if that distorts the lash.`
|
|
668
|
+
);
|
|
669
|
+
}
|
|
670
|
+
if (iris) {
|
|
671
|
+
const ratio = iris.w / eye.w;
|
|
672
|
+
if (ratio < IRIS_RATIO_MIN || ratio > IRIS_RATIO_MAX) {
|
|
673
|
+
warnings.push(
|
|
674
|
+
`iris_${side}: width is ${pct(ratio)} of the sclera (target ${IRIS_RATIO_MIN}-${IRIS_RATIO_MAX}) \u2014 retune layout.iris_${side}.w (keep it a fraction of the eye width), no regeneration needed.`
|
|
675
|
+
);
|
|
676
|
+
}
|
|
677
|
+
const dx = iris.bboxCx - eye.massCx;
|
|
678
|
+
const dy = iris.bboxCy - eye.massCy;
|
|
679
|
+
if (Math.abs(dx) > IRIS_OFFSET_MAX_X || Math.abs(dy) > IRIS_OFFSET_MAX_Y) {
|
|
680
|
+
warnings.push(
|
|
681
|
+
`iris_${side}: sits (${dx.toFixed(1)}, ${dy.toFixed(1)}) px from the white's centre of mass \u2014 retune layout.iris_${side}.cx/cy. The sclera's bbox centre is NOT its visual centre when the lash flick stretches the box.`
|
|
682
|
+
);
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
if (lash) {
|
|
686
|
+
const dx = lash.bboxCx - eye.bboxCx;
|
|
687
|
+
const dTop = lash.marginTop - eye.marginTop;
|
|
688
|
+
if (Math.abs(dx) > eye.w * LASH_CENTRE_TOL_FRAC || Math.abs(dTop) > 0.5) {
|
|
689
|
+
warnings.push(
|
|
690
|
+
`lash_${side}: centre is ${dx.toFixed(1)} px and top edge ${dTop.toFixed(1)} px off eye_${side}. They are split from one source and MUST share cx/cy/w in layout, or the blink fold tears. Retune to match.`
|
|
691
|
+
);
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
for (const [role, why] of [
|
|
696
|
+
["body", "without it the character reads as a floating head on head-turn"],
|
|
697
|
+
["hair_back", "without it the silhouette is flat behind the face"]
|
|
698
|
+
]) {
|
|
699
|
+
if (layers[role] === void 0) warnings.push(`${role}: missing \u2014 ${why}.`);
|
|
700
|
+
}
|
|
701
|
+
return { layers, empty, warnings };
|
|
702
|
+
}
|
|
703
|
+
async function measureLayers(input) {
|
|
704
|
+
try {
|
|
705
|
+
const layersDir = resolveInputDir(input.layersDir);
|
|
706
|
+
const report = await measureDir(layersDir);
|
|
707
|
+
return {
|
|
708
|
+
ok: true,
|
|
709
|
+
layersDir,
|
|
710
|
+
...report,
|
|
711
|
+
passed: report.warnings.length === 0
|
|
712
|
+
};
|
|
713
|
+
} catch (err) {
|
|
714
|
+
if (err instanceof AutoRigInputError)
|
|
715
|
+
return { ok: false, error: err.message };
|
|
716
|
+
throw err;
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
function formatMeasureReport(result) {
|
|
720
|
+
const lines = [
|
|
721
|
+
`# layers (${result.layersDir})`,
|
|
722
|
+
"",
|
|
723
|
+
"role size bbox-centre mass-centre margins t/b/l/r"
|
|
724
|
+
];
|
|
725
|
+
for (const role of [...Object.keys(result.layers), ...result.empty].sort()) {
|
|
726
|
+
const m = result.layers[role];
|
|
727
|
+
if (m === void 0) {
|
|
728
|
+
lines.push(`${role.padEnd(13)} EMPTY (fully transparent)`);
|
|
729
|
+
continue;
|
|
730
|
+
}
|
|
731
|
+
lines.push(
|
|
732
|
+
`${role.padEnd(13)} ${`${m.w}x${m.h}`.padEnd(11)} ${`${m.bboxCx.toFixed(0)},${m.bboxCy.toFixed(0)}`.padEnd(14)} ${`${m.massCx.toFixed(0)},${m.massCy.toFixed(0)}`.padEnd(13)} ${m.marginTop}/${m.marginBottom}/${m.marginLeft}/${m.marginRight}`
|
|
733
|
+
);
|
|
734
|
+
}
|
|
735
|
+
lines.push("", "# checks", "");
|
|
736
|
+
if (result.warnings.length === 0) {
|
|
737
|
+
lines.push("all geometry checks passed");
|
|
738
|
+
} else {
|
|
739
|
+
for (const w of result.warnings) lines.push(`- ${w}`);
|
|
740
|
+
}
|
|
741
|
+
return lines.join("\n");
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
// src/compose.ts
|
|
745
|
+
var CANVAS = 1100;
|
|
746
|
+
var EYE_W = 128;
|
|
747
|
+
var IRIS_W = Math.round(EYE_W * 0.5625);
|
|
748
|
+
var EYEWHITE_SRC = "eyewhite.png";
|
|
749
|
+
var EYE_LASH_LUMA = 120;
|
|
750
|
+
var LASH_KEEP_FRACTION = 0.5;
|
|
751
|
+
var DEFAULT_LAYOUT = {
|
|
752
|
+
// Back hair and body sit behind the face. Both are OPTIONAL: a parts dir
|
|
753
|
+
// without them still composes (head-only character).
|
|
754
|
+
hair_back: { src: "hair_back.png", cx: 550, cy: 523, w: 800, optional: true },
|
|
755
|
+
// The torso, cut off by the canvas bottom. It rides its own `bodyDeformer`: a
|
|
756
|
+
// light share of the head turn and half its breath bob, so the character is
|
|
757
|
+
// not a floating head.
|
|
758
|
+
body: { src: "body.png", cx: 550, cy: 1017, w: 840, optional: true },
|
|
759
|
+
face: { src: "face.png", cx: 550, cy: 475, w: 400 },
|
|
760
|
+
mouth: { src: "mouth.png", cx: 550, cy: 619, w: 68 },
|
|
761
|
+
// Cross-fades with `mouth` on ParamMouthOpenY (opacity, not scaleY) once the
|
|
762
|
+
// auto-rig sees both roles. Same cx/w as `mouth` so the lip width matches;
|
|
763
|
+
// its top edge (not center) lines up with the closed mouth's top edge since
|
|
764
|
+
// the mouth opens downward from a fixed upper lip — hence the +2 cy nudge
|
|
765
|
+
// rather than sharing cy outright. Optional: composes fine without it.
|
|
766
|
+
mouth_open: {
|
|
767
|
+
src: "mouth_open.png",
|
|
768
|
+
cx: 550,
|
|
769
|
+
cy: 621,
|
|
770
|
+
w: 68,
|
|
771
|
+
optional: true
|
|
772
|
+
},
|
|
773
|
+
// eye_* (sclera) and lash_* share the eyewhite's cropped frame via noTrim (so
|
|
774
|
+
// they are NOT re-bboxed independently): the upper lash stays anchored ABOVE
|
|
775
|
+
// the sclera center, so on blink it folds DOWN over the eye like the sample
|
|
776
|
+
// model instead of the whole eye shrinking in place. Same cx/cy/w.
|
|
777
|
+
eye_L: { src: "eyewhite_sclera.png", cx: 657, cy: 475, w: EYE_W, mirror: true, noTrim: true },
|
|
778
|
+
// prettier-ignore
|
|
779
|
+
eye_R: { src: "eyewhite_sclera.png", cx: 443, cy: 475, w: EYE_W, mirror: false, noTrim: true },
|
|
780
|
+
// prettier-ignore
|
|
781
|
+
iris_L: { src: "iris.png", cx: 653, cy: 475, w: IRIS_W, mirror: false },
|
|
782
|
+
iris_R: { src: "iris.png", cx: 447, cy: 475, w: IRIS_W, mirror: false },
|
|
783
|
+
lash_L: {
|
|
784
|
+
src: "eyewhite_lash.png",
|
|
785
|
+
cx: 657,
|
|
786
|
+
cy: 475,
|
|
787
|
+
w: EYE_W,
|
|
788
|
+
mirror: true,
|
|
789
|
+
noTrim: true
|
|
790
|
+
},
|
|
791
|
+
lash_R: { src: "eyewhite_lash.png", cx: 443, cy: 475, w: EYE_W, mirror: false, noTrim: true },
|
|
792
|
+
// prettier-ignore
|
|
793
|
+
brow_L: { src: "brow.png", cx: 645, cy: 405, w: 135, mirror: false },
|
|
794
|
+
brow_R: { src: "brow.png", cx: 455, cy: 405, w: 135, mirror: true },
|
|
795
|
+
hair_front: { src: "hair_front.png", cx: 550, cy: 425, w: 660 }
|
|
796
|
+
};
|
|
797
|
+
var ORDER = [
|
|
798
|
+
"hair_back",
|
|
799
|
+
"body",
|
|
800
|
+
"face",
|
|
801
|
+
"mouth",
|
|
802
|
+
"mouth_open",
|
|
803
|
+
"eye_L",
|
|
804
|
+
"eye_R",
|
|
805
|
+
"iris_L",
|
|
806
|
+
"iris_R",
|
|
807
|
+
"lash_L",
|
|
808
|
+
"lash_R",
|
|
809
|
+
"brow_L",
|
|
810
|
+
"brow_R",
|
|
811
|
+
"hair_front"
|
|
812
|
+
];
|
|
813
|
+
function resolveLayout(overrides) {
|
|
814
|
+
const resolved = { ...DEFAULT_LAYOUT };
|
|
815
|
+
if (overrides === void 0) return resolved;
|
|
816
|
+
for (const [role, override] of Object.entries(overrides)) {
|
|
817
|
+
if (!Object.prototype.hasOwnProperty.call(DEFAULT_LAYOUT, role)) {
|
|
818
|
+
throw new AutoRigInputError(
|
|
819
|
+
`layout.${role}: unknown role \u2014 expected one of ${Object.keys(DEFAULT_LAYOUT).join(", ")}`
|
|
820
|
+
);
|
|
821
|
+
}
|
|
822
|
+
if (override === void 0) continue;
|
|
823
|
+
const next = { ...resolved[role] };
|
|
824
|
+
for (const field of ["cx", "cy"]) {
|
|
825
|
+
const value = override[field];
|
|
826
|
+
if (value === void 0) continue;
|
|
827
|
+
if (!Number.isFinite(value)) {
|
|
828
|
+
throw new AutoRigInputError(
|
|
829
|
+
`layout.${role}.${field} must be a finite number, got ${String(value)}`
|
|
830
|
+
);
|
|
831
|
+
}
|
|
832
|
+
next[field] = value;
|
|
833
|
+
}
|
|
834
|
+
for (const field of ["w", "h"]) {
|
|
835
|
+
const value = override[field];
|
|
836
|
+
if (value === void 0) continue;
|
|
837
|
+
if (!Number.isInteger(value) || value < 1 || value > CANVAS) {
|
|
838
|
+
throw new AutoRigInputError(
|
|
839
|
+
`layout.${role}.${field} must be an integer in 1..${CANVAS}, got ${String(value)}`
|
|
840
|
+
);
|
|
841
|
+
}
|
|
842
|
+
next[field] = value;
|
|
843
|
+
}
|
|
844
|
+
resolved[role] = next;
|
|
845
|
+
}
|
|
846
|
+
return resolved;
|
|
847
|
+
}
|
|
848
|
+
function keyWhiteToAlpha(rgba) {
|
|
849
|
+
const keyed = Buffer.from(rgba);
|
|
850
|
+
for (let i = 0; i < keyed.length; i += 4) {
|
|
851
|
+
if (keyed[i] > 238 && keyed[i + 1] > 238 && keyed[i + 2] > 238) {
|
|
852
|
+
keyed[i + 3] = 0;
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
return keyed;
|
|
856
|
+
}
|
|
857
|
+
async function partBuffer(role, cfg, partsDir, inMemory) {
|
|
858
|
+
let img;
|
|
859
|
+
if (inMemory !== void 0) {
|
|
860
|
+
img = (0, import_sharp2.default)(inMemory);
|
|
861
|
+
} else {
|
|
862
|
+
const srcPath = import_node_path4.default.join(partsDir, cfg.src);
|
|
863
|
+
if (!import_node_fs3.default.existsSync(srcPath)) {
|
|
864
|
+
if (cfg.optional) return null;
|
|
865
|
+
throw new AutoRigInputError(
|
|
866
|
+
`missing part source for role "${role}": ${srcPath}`
|
|
867
|
+
);
|
|
868
|
+
}
|
|
869
|
+
const png = await decodePng(srcPath);
|
|
870
|
+
img = (0, import_sharp2.default)(png.hasAlpha ? png.rgba : keyWhiteToAlpha(png.rgba), {
|
|
871
|
+
raw: { width: png.width, height: png.height, channels: 4 }
|
|
872
|
+
});
|
|
873
|
+
}
|
|
874
|
+
if (!cfg.noTrim) img = img.trim({ threshold: 12 });
|
|
875
|
+
if (cfg.mirror) img = img.flop();
|
|
876
|
+
const trimmed = await img.png().toBuffer({ resolveWithObject: true });
|
|
877
|
+
if (cfg.h === void 0) {
|
|
878
|
+
const scaledH = Math.round(
|
|
879
|
+
trimmed.info.height * cfg.w / trimmed.info.width
|
|
880
|
+
);
|
|
881
|
+
if (scaledH > CANVAS) {
|
|
882
|
+
throw new AutoRigInputError(
|
|
883
|
+
`layout.${role}.w: resized part ${cfg.w}x${scaledH} exceeds the ${CANVAS} canvas`
|
|
884
|
+
);
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
const resized = await (0, import_sharp2.default)(trimmed.data).resize(
|
|
888
|
+
cfg.h === void 0 ? { width: cfg.w } : { width: cfg.w, height: cfg.h, fit: "fill" }
|
|
889
|
+
).png().toBuffer({ resolveWithObject: true });
|
|
890
|
+
return {
|
|
891
|
+
buf: resized.data,
|
|
892
|
+
w: resized.info.width,
|
|
893
|
+
h: resized.info.height
|
|
894
|
+
};
|
|
895
|
+
}
|
|
896
|
+
function placement(role, cfg, w, h) {
|
|
897
|
+
const left = Math.round(cfg.cx - w / 2);
|
|
898
|
+
const top = Math.round(cfg.cy - h / 2);
|
|
899
|
+
if (left + w <= 0 || top + h <= 0 || left >= CANVAS || top >= CANVAS) {
|
|
900
|
+
throw new AutoRigInputError(
|
|
901
|
+
`layout.${role}.cx/cy: the placed part (${w}x${h} at ${left},${top}) falls entirely outside the ${CANVAS} canvas`
|
|
902
|
+
);
|
|
903
|
+
}
|
|
904
|
+
return { left, top };
|
|
905
|
+
}
|
|
906
|
+
function blankCanvas() {
|
|
907
|
+
return (0, import_sharp2.default)({
|
|
908
|
+
create: {
|
|
909
|
+
width: CANVAS,
|
|
910
|
+
height: CANVAS,
|
|
911
|
+
channels: 4,
|
|
912
|
+
background: { r: 0, g: 0, b: 0, alpha: 0 }
|
|
913
|
+
}
|
|
914
|
+
});
|
|
915
|
+
}
|
|
916
|
+
async function prepEyeSplit(partsDir) {
|
|
917
|
+
const srcPath = import_node_path4.default.join(partsDir, EYEWHITE_SRC);
|
|
918
|
+
if (!import_node_fs3.default.existsSync(srcPath)) {
|
|
919
|
+
throw new AutoRigInputError(`missing eyewhite source: ${srcPath}`);
|
|
920
|
+
}
|
|
921
|
+
const { width: W, height: H, rgba: data } = await decodePng(srcPath);
|
|
922
|
+
let minX = W;
|
|
923
|
+
let minY = H;
|
|
924
|
+
let maxX = -1;
|
|
925
|
+
let maxY = -1;
|
|
926
|
+
for (let y = 0; y < H; y++) {
|
|
927
|
+
for (let x = 0; x < W; x++) {
|
|
928
|
+
if (data[(y * W + x) * 4 + 3] > 8) {
|
|
929
|
+
if (x < minX) minX = x;
|
|
930
|
+
if (x > maxX) maxX = x;
|
|
931
|
+
if (y < minY) minY = y;
|
|
932
|
+
if (y > maxY) maxY = y;
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
if (maxX < 0) {
|
|
937
|
+
throw new AutoRigInputError(`eyewhite is fully transparent: ${srcPath}`);
|
|
938
|
+
}
|
|
939
|
+
const lashCutoffY = minY + LASH_KEEP_FRACTION * (maxY - minY + 1);
|
|
940
|
+
const sclera = Buffer.from(data);
|
|
941
|
+
const lash = Buffer.from(data);
|
|
942
|
+
for (let y = 0; y < H; y++) {
|
|
943
|
+
for (let x = 0; x < W; x++) {
|
|
944
|
+
const i = (y * W + x) * 4;
|
|
945
|
+
const lum = 0.299 * data[i] + 0.587 * data[i + 1] + 0.114 * data[i + 2];
|
|
946
|
+
const isDark = data[i + 3] > 0 && lum < EYE_LASH_LUMA;
|
|
947
|
+
if (isDark) sclera[i] = sclera[i + 1] = sclera[i + 2] = 255;
|
|
948
|
+
if (!(isDark && y <= lashCutoffY)) lash[i + 3] = 0;
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
const region = {
|
|
952
|
+
x: minX,
|
|
953
|
+
y: minY,
|
|
954
|
+
w: maxX - minX + 1,
|
|
955
|
+
h: maxY - minY + 1
|
|
956
|
+
};
|
|
957
|
+
return {
|
|
958
|
+
sclera: await cropToBuffer(sclera, W, H, region),
|
|
959
|
+
lash: await cropToBuffer(lash, W, H, region)
|
|
960
|
+
};
|
|
961
|
+
}
|
|
962
|
+
async function composeLayersFromParts(input) {
|
|
963
|
+
try {
|
|
964
|
+
const outDir = resolveOutputDir(input.outDir);
|
|
965
|
+
const partsDir = resolveInputDir(input.partsDir);
|
|
966
|
+
if (import_node_fs3.default.realpathSync(partsDir) === outDir) {
|
|
967
|
+
throw new AutoRigInputError(
|
|
968
|
+
`partsDir and outDir resolve to the same directory (${outDir}): composing would overwrite the source parts`
|
|
969
|
+
);
|
|
970
|
+
}
|
|
971
|
+
const layout = resolveLayout(input.layout);
|
|
972
|
+
const split = await prepEyeSplit(partsDir);
|
|
973
|
+
const splitSources = /* @__PURE__ */ new Map([
|
|
974
|
+
["eyewhite_sclera.png", split.sclera],
|
|
975
|
+
["eyewhite_lash.png", split.lash]
|
|
976
|
+
]);
|
|
977
|
+
const layers = [];
|
|
978
|
+
const skipped = [];
|
|
979
|
+
const preview = [];
|
|
980
|
+
for (const role of ORDER) {
|
|
981
|
+
const cfg = layout[role];
|
|
982
|
+
const part = await partBuffer(
|
|
983
|
+
role,
|
|
984
|
+
cfg,
|
|
985
|
+
partsDir,
|
|
986
|
+
splitSources.get(cfg.src)
|
|
987
|
+
);
|
|
988
|
+
if (part === null) {
|
|
989
|
+
skipped.push(role);
|
|
990
|
+
import_node_fs3.default.rmSync(import_node_path4.default.join(outDir, `${role}.png`), { force: true });
|
|
991
|
+
continue;
|
|
992
|
+
}
|
|
993
|
+
const { left, top } = placement(role, cfg, part.w, part.h);
|
|
994
|
+
const layer = await blankCanvas().composite([{ input: part.buf, left, top }]).png().toBuffer();
|
|
995
|
+
const outPath = import_node_path4.default.join(outDir, `${role}.png`);
|
|
996
|
+
writeFileAtomic(outPath, layer);
|
|
997
|
+
layers.push({
|
|
998
|
+
role,
|
|
999
|
+
path: outPath,
|
|
1000
|
+
width: part.w,
|
|
1001
|
+
height: part.h,
|
|
1002
|
+
left,
|
|
1003
|
+
top
|
|
1004
|
+
});
|
|
1005
|
+
preview.push({ input: part.buf, left, top });
|
|
1006
|
+
}
|
|
1007
|
+
const previewPng = await (0, import_sharp2.default)({
|
|
1008
|
+
create: {
|
|
1009
|
+
width: CANVAS,
|
|
1010
|
+
height: CANVAS,
|
|
1011
|
+
channels: 4,
|
|
1012
|
+
background: { r: 245, g: 245, b: 248, alpha: 1 }
|
|
1013
|
+
}
|
|
1014
|
+
}).composite(preview).png().toBuffer();
|
|
1015
|
+
const previewPath = import_node_path4.default.join(outDir, "preview.png");
|
|
1016
|
+
writeFileAtomic(previewPath, previewPng);
|
|
1017
|
+
return {
|
|
1018
|
+
ok: true,
|
|
1019
|
+
outDir,
|
|
1020
|
+
layers,
|
|
1021
|
+
skipped,
|
|
1022
|
+
preview: previewPath,
|
|
1023
|
+
measure: await measureDir(outDir)
|
|
1024
|
+
};
|
|
1025
|
+
} catch (err) {
|
|
1026
|
+
if (err instanceof AutoRigInputError)
|
|
1027
|
+
return { ok: false, error: err.message };
|
|
1028
|
+
throw err;
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
|
|
456
1032
|
// src/server.ts
|
|
457
1033
|
function createIkiMcpServer() {
|
|
458
|
-
const server = new import_mcp.McpServer({ name: "iki", version: "0.
|
|
1034
|
+
const server = new import_mcp.McpServer({ name: "iki", version: "0.5.0" });
|
|
459
1035
|
server.registerTool(
|
|
460
1036
|
"validate_iki",
|
|
461
1037
|
{
|
|
@@ -553,6 +1129,76 @@ function createIkiMcpServer() {
|
|
|
553
1129
|
}
|
|
554
1130
|
}
|
|
555
1131
|
);
|
|
1132
|
+
server.registerTool(
|
|
1133
|
+
"compose_layers_from_parts",
|
|
1134
|
+
{
|
|
1135
|
+
description: "Composes AI-generated part PNGs into canvas-aligned, role-named PNG layers on disk, ready for auto_rig_from_layers (the eyewhite split, alpha-trim/white-key, and placement pipeline the character-generation skill needs), with the same geometry report measure_layers returns standalone included inline. face, mouth, eyewhite, iris, brow, hair_front are required; hair_back, body, mouth_open are optional.",
|
|
1136
|
+
inputSchema: {
|
|
1137
|
+
partsDir: import_zod.z.string().describe(
|
|
1138
|
+
"Directory of the source part PNGs (resolved against cwd)."
|
|
1139
|
+
),
|
|
1140
|
+
outDir: import_zod.z.string().describe(
|
|
1141
|
+
"Existing directory to write the role layer PNGs + preview.png into (resolved against cwd; must already exist; confined to the working directory). Reused across runs: a role this run skips has its stale PNG from an earlier run deleted."
|
|
1142
|
+
),
|
|
1143
|
+
layout: import_zod.z.record(
|
|
1144
|
+
import_zod.z.string(),
|
|
1145
|
+
import_zod.z.object({
|
|
1146
|
+
cx: import_zod.z.number(),
|
|
1147
|
+
cy: import_zod.z.number(),
|
|
1148
|
+
w: import_zod.z.number(),
|
|
1149
|
+
h: import_zod.z.number()
|
|
1150
|
+
}).partial()
|
|
1151
|
+
).optional().describe(
|
|
1152
|
+
"Per-role override merged over the built-in defaults, keyed by role \u2014 hair_back, body, face, mouth, mouth_open, eye_L, eye_R, iris_L, iris_R, lash_L, lash_R, brow_L, brow_R, hair_front \u2014 e.g. `{ eye_L: { cx: 660 } }`. `w` and `h` are integers in 1..1100; omit `h` to keep the part's own aspect, set it to stretch (set it on a sclera and its lash together, or the blink fold tears)."
|
|
1153
|
+
)
|
|
1154
|
+
}
|
|
1155
|
+
},
|
|
1156
|
+
async (args) => {
|
|
1157
|
+
try {
|
|
1158
|
+
const r = await composeLayersFromParts(args);
|
|
1159
|
+
const text = r.ok ? [
|
|
1160
|
+
...r.layers.map((l) => l.path),
|
|
1161
|
+
formatMeasureReport({ ...r.measure, layersDir: r.outDir })
|
|
1162
|
+
].join("\n") : `INVALID: ${r.error}`;
|
|
1163
|
+
return { content: [{ type: "text", text }], structuredContent: r };
|
|
1164
|
+
} catch (err) {
|
|
1165
|
+
const error = err instanceof Error ? err.message : String(err);
|
|
1166
|
+
return {
|
|
1167
|
+
content: [{ type: "text", text: `Unexpected error: ${error}` }],
|
|
1168
|
+
structuredContent: { ok: false, error },
|
|
1169
|
+
isError: true
|
|
1170
|
+
};
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
);
|
|
1174
|
+
server.registerTool(
|
|
1175
|
+
"measure_layers",
|
|
1176
|
+
{
|
|
1177
|
+
description: "Reports read-only geometry checks over an already-composed layers directory \u2014 the same checks compose_layers_from_parts returns inline (iris ratio/offset, eye aspect, cropped/cut edges, missing optional roles). Use to re-check a layers dir without recomposing.",
|
|
1178
|
+
inputSchema: {
|
|
1179
|
+
layersDir: import_zod.z.string().describe(
|
|
1180
|
+
"Directory of role-named layer PNGs (resolved against cwd)."
|
|
1181
|
+
)
|
|
1182
|
+
}
|
|
1183
|
+
},
|
|
1184
|
+
async ({ layersDir }) => {
|
|
1185
|
+
try {
|
|
1186
|
+
const r = await measureLayers({ layersDir });
|
|
1187
|
+
const text = r.ok ? formatMeasureReport(r) : `INVALID: ${r.error}`;
|
|
1188
|
+
return {
|
|
1189
|
+
content: [{ type: "text", text }],
|
|
1190
|
+
structuredContent: { ...r }
|
|
1191
|
+
};
|
|
1192
|
+
} catch (err) {
|
|
1193
|
+
const error = err instanceof Error ? err.message : String(err);
|
|
1194
|
+
return {
|
|
1195
|
+
content: [{ type: "text", text: `Unexpected error: ${error}` }],
|
|
1196
|
+
structuredContent: { ok: false, error },
|
|
1197
|
+
isError: true
|
|
1198
|
+
};
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
);
|
|
556
1202
|
return server;
|
|
557
1203
|
}
|
|
558
1204
|
|