@ufira/vibma 0.3.2 → 1.0.0-rc1
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 +3 -1
- package/dist/mcp.cjs +2455 -1159
- package/dist/mcp.cjs.map +1 -1
- package/dist/mcp.js +2457 -1161
- package/dist/mcp.js.map +1 -1
- package/dist/tools/endpoint.cjs +10 -1
- package/dist/tools/endpoint.cjs.map +1 -1
- package/dist/tools/endpoint.js +10 -1
- package/dist/tools/endpoint.js.map +1 -1
- package/dist/tools/generated/guards.cjs +786 -0
- package/dist/tools/generated/guards.cjs.map +1 -0
- package/dist/tools/generated/guards.d.cts +92 -0
- package/dist/tools/generated/guards.d.ts +92 -0
- package/dist/tools/generated/guards.js +718 -0
- package/dist/tools/generated/guards.js.map +1 -0
- package/dist/tools/registry.cjs +946 -2
- package/dist/tools/registry.cjs.map +1 -1
- package/dist/tools/registry.js +948 -2
- package/dist/tools/registry.js.map +1 -1
- package/dist/tools/schemas.cjs +43 -6
- package/dist/tools/schemas.cjs.map +1 -1
- package/dist/tools/schemas.d.cts +38 -6
- package/dist/tools/schemas.d.ts +38 -6
- package/dist/tools/schemas.js +38 -6
- package/dist/tools/schemas.js.map +1 -1
- package/dist/tools/types.cjs.map +1 -1
- package/dist/tools/types.d.cts +5 -1
- package/dist/tools/types.d.ts +5 -1
- package/dist/tools/types.js.map +1 -1
- package/package.json +6 -2
package/dist/tools/schemas.d.ts
CHANGED
|
@@ -18,13 +18,45 @@ declare const depth: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
|
18
18
|
declare const xPos: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
19
19
|
/** Y position for creation tools */
|
|
20
20
|
declare const yPos: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
21
|
-
/** RGBA color — accepts {r,g,b,a?} object (0-1)
|
|
22
|
-
declare const colorRgba: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodObject<{
|
|
21
|
+
/** RGBA color — accepts {r,g,b,a?} object (0-1), hex string (#RGB, #RRGGBB, #RRGGBBAA), or style/variable name string */
|
|
22
|
+
declare const colorRgba: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodUnion<readonly [z.ZodObject<{
|
|
23
23
|
r: z.ZodCoercedNumber<unknown>;
|
|
24
24
|
g: z.ZodCoercedNumber<unknown>;
|
|
25
25
|
b: z.ZodCoercedNumber<unknown>;
|
|
26
26
|
a: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
27
|
-
}, z.core.$strip>>;
|
|
27
|
+
}, z.core.$strip>, z.ZodString]>>;
|
|
28
|
+
/** Variable value — color (hex or RGBA), number, boolean, string, or alias */
|
|
29
|
+
declare const variableValue: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodUnion<readonly [z.ZodNumber, z.ZodBoolean, z.ZodString, z.ZodObject<{
|
|
30
|
+
r: z.ZodNumber;
|
|
31
|
+
g: z.ZodNumber;
|
|
32
|
+
b: z.ZodNumber;
|
|
33
|
+
a: z.ZodOptional<z.ZodNumber>;
|
|
34
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
35
|
+
type: z.ZodLiteral<"VARIABLE_ALIAS">;
|
|
36
|
+
name: z.ZodString;
|
|
37
|
+
}, z.core.$strip>]>>;
|
|
38
|
+
/** Line height — number (px) or {value, unit} */
|
|
39
|
+
declare const lineHeight: z.ZodUnion<readonly [z.ZodCoercedNumber<unknown>, z.ZodObject<{
|
|
40
|
+
value: z.ZodCoercedNumber<unknown>;
|
|
41
|
+
unit: z.ZodEnum<{
|
|
42
|
+
PIXELS: "PIXELS";
|
|
43
|
+
PERCENT: "PERCENT";
|
|
44
|
+
AUTO: "AUTO";
|
|
45
|
+
}>;
|
|
46
|
+
}, z.core.$strip>]>;
|
|
47
|
+
/** Letter spacing — number (px) or {value, unit} */
|
|
48
|
+
declare const letterSpacing: z.ZodUnion<readonly [z.ZodCoercedNumber<unknown>, z.ZodObject<{
|
|
49
|
+
value: z.ZodCoercedNumber<unknown>;
|
|
50
|
+
unit: z.ZodEnum<{
|
|
51
|
+
PIXELS: "PIXELS";
|
|
52
|
+
PERCENT: "PERCENT";
|
|
53
|
+
}>;
|
|
54
|
+
}, z.core.$strip>]>;
|
|
55
|
+
/** String or boolean — for component property defaults */
|
|
56
|
+
declare const stringOrBoolean: z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>;
|
|
57
|
+
/** Design token — accepts a string that is either a numeric value ("8") or a variable name/ID ("Radii/Medium").
|
|
58
|
+
* Numeric strings are parsed to numbers in the handler; non-numeric strings are variable references. */
|
|
59
|
+
declare const token: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodString>;
|
|
28
60
|
/** Single effect entry — shared by set_effects and styles create */
|
|
29
61
|
declare const effectEntry: z.ZodObject<{
|
|
30
62
|
type: z.ZodEnum<{
|
|
@@ -33,12 +65,12 @@ declare const effectEntry: z.ZodObject<{
|
|
|
33
65
|
LAYER_BLUR: "LAYER_BLUR";
|
|
34
66
|
BACKGROUND_BLUR: "BACKGROUND_BLUR";
|
|
35
67
|
}>;
|
|
36
|
-
color: z.ZodOptional<z.ZodPipe<z.ZodTransform<any, unknown>, z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodObject<{
|
|
68
|
+
color: z.ZodOptional<z.ZodPipe<z.ZodTransform<any, unknown>, z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodUnion<readonly [z.ZodObject<{
|
|
37
69
|
r: z.ZodCoercedNumber<unknown>;
|
|
38
70
|
g: z.ZodCoercedNumber<unknown>;
|
|
39
71
|
b: z.ZodCoercedNumber<unknown>;
|
|
40
72
|
a: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
41
|
-
}, z.core.$strip>>>>;
|
|
73
|
+
}, z.core.$strip>, z.ZodString]>>>>;
|
|
42
74
|
offset: z.ZodOptional<z.ZodPipe<z.ZodTransform<any, unknown>, z.ZodObject<{
|
|
43
75
|
x: z.ZodCoercedNumber<unknown>;
|
|
44
76
|
y: z.ZodCoercedNumber<unknown>;
|
|
@@ -49,4 +81,4 @@ declare const effectEntry: z.ZodObject<{
|
|
|
49
81
|
blendMode: z.ZodOptional<z.ZodString>;
|
|
50
82
|
}, z.core.$strip>;
|
|
51
83
|
|
|
52
|
-
export { colorRgba, depth, effectEntry, nodeId, nodeIds, parentId, xPos, yPos };
|
|
84
|
+
export { colorRgba, depth, effectEntry, letterSpacing, lineHeight, nodeId, nodeIds, parentId, stringOrBoolean, token, variableValue, xPos, yPos };
|
package/dist/tools/schemas.js
CHANGED
|
@@ -42,12 +42,39 @@ function parseHex(hex) {
|
|
|
42
42
|
var colorRgba = z2.preprocess((v) => {
|
|
43
43
|
if (typeof v === "string") return parseHex(v) ?? v;
|
|
44
44
|
return v;
|
|
45
|
-
}, z2.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
}, z2.union([
|
|
46
|
+
z2.object({
|
|
47
|
+
r: z2.coerce.number().min(0).max(1),
|
|
48
|
+
g: z2.coerce.number().min(0).max(1),
|
|
49
|
+
b: z2.coerce.number().min(0).max(1),
|
|
50
|
+
a: z2.coerce.number().min(0).max(1).optional()
|
|
51
|
+
}),
|
|
52
|
+
z2.string()
|
|
53
|
+
// Non-hex strings pass through for handler-level style/variable resolution
|
|
54
|
+
])).describe('Hex "#FF0000", {r,g,b,a?} 0-1, or style/variable name.');
|
|
55
|
+
var variableValue = z2.preprocess((v) => {
|
|
56
|
+
if (typeof v === "string") return parseHex(v) ?? v;
|
|
57
|
+
return v;
|
|
58
|
+
}, z2.union([
|
|
59
|
+
z2.number(),
|
|
60
|
+
z2.boolean(),
|
|
61
|
+
z2.string(),
|
|
62
|
+
z2.object({ r: z2.number(), g: z2.number(), b: z2.number(), a: z2.number().optional() }),
|
|
63
|
+
z2.object({ type: z2.literal("VARIABLE_ALIAS"), name: z2.string() })
|
|
64
|
+
])).describe('number, boolean, string, hex "#FF0000", {r,g,b,a?}, or {type:"VARIABLE_ALIAS",name:"other/variable"}');
|
|
65
|
+
var lineHeight = z2.union([
|
|
66
|
+
z2.coerce.number(),
|
|
67
|
+
z2.object({ value: z2.coerce.number(), unit: z2.enum(["PIXELS", "PERCENT", "AUTO"]) })
|
|
68
|
+
]).describe('number (px) or {value, unit: "PIXELS"|"PERCENT"|"AUTO"}');
|
|
69
|
+
var letterSpacing = z2.union([
|
|
70
|
+
z2.coerce.number(),
|
|
71
|
+
z2.object({ value: z2.coerce.number(), unit: z2.enum(["PIXELS", "PERCENT"]) })
|
|
72
|
+
]).describe('number (px) or {value, unit: "PIXELS"|"PERCENT"}');
|
|
73
|
+
var stringOrBoolean = z2.union([z2.string(), z2.boolean()]);
|
|
74
|
+
var token = z2.preprocess((v) => {
|
|
75
|
+
if (typeof v === "number") return String(v);
|
|
76
|
+
return v;
|
|
77
|
+
}, z2.string()).describe('number as string ("8") or variable name ("Radii/Medium")');
|
|
51
78
|
var effectEntry = z2.object({
|
|
52
79
|
type: z2.enum(["DROP_SHADOW", "INNER_SHADOW", "LAYER_BLUR", "BACKGROUND_BLUR"]),
|
|
53
80
|
color: flexJson(colorRgba).optional(),
|
|
@@ -61,9 +88,14 @@ export {
|
|
|
61
88
|
colorRgba,
|
|
62
89
|
depth,
|
|
63
90
|
effectEntry,
|
|
91
|
+
letterSpacing,
|
|
92
|
+
lineHeight,
|
|
64
93
|
nodeId,
|
|
65
94
|
nodeIds,
|
|
66
95
|
parentId,
|
|
96
|
+
stringOrBoolean,
|
|
97
|
+
token,
|
|
98
|
+
variableValue,
|
|
67
99
|
xPos,
|
|
68
100
|
yPos
|
|
69
101
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/tools/schemas.ts","../../src/utils/coercion.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { flexJson, flexBool } from \"../utils/coercion\";\n\n// ─── Shared Zod Schema Fragments ────────────────────────────────\n// Import as: import * as S from \"./schemas\";\n\n/** Single node ID */\nexport const nodeId = z.string().describe(\"Node ID\");\n\n/** Array of node IDs */\nexport const nodeIds = flexJson(z.array(z.string())).describe(\"Array of node IDs\");\n\n/** Optional parent reference for creation tools */\nexport const parentId = z.string().optional()\n .describe(\"Parent node ID. Omit to place on current page.\");\n\n/**\n * Response depth — controls how much node detail is returned after an operation.\n * Omit for minimal response (id + name only).\n * 0 = node with full properties, children as stubs.\n * N = recurse N levels of children with full properties.\n * -1 = unlimited recursion.\n */\nexport const depth = z.coerce.number().optional()\n .describe(\"Response detail: omit for id+name only. 0=properties + child stubs. N=recurse N levels. -1=unlimited.\");\n\n/** X position for creation tools */\nexport const xPos = z.coerce.number().optional().describe(\"X position (default: 0)\");\n\n/** Y position for creation tools */\nexport const yPos = z.coerce.number().optional().describe(\"Y position (default: 0)\");\n\n/** Parse hex color string (#RGB, #RRGGBB, #RRGGBBAA) to {r,g,b,a} 0-1 */\nfunction parseHex(hex: string): { r: number; g: number; b: number; a?: number } | null {\n const m = hex.match(/^#?([0-9a-f]{3,8})$/i);\n if (!m) return null;\n let h = m[1];\n if (h.length === 3) h = h[0]+h[0]+h[1]+h[1]+h[2]+h[2];\n if (h.length === 4) h = h[0]+h[0]+h[1]+h[1]+h[2]+h[2]+h[3]+h[3];\n if (h.length !== 6 && h.length !== 8) return null;\n const r = parseInt(h.slice(0, 2), 16) / 255;\n const g = parseInt(h.slice(2, 4), 16) / 255;\n const b = parseInt(h.slice(4, 6), 16) / 255;\n if (h.length === 8) return { r, g, b, a: parseInt(h.slice(6, 8), 16) / 255 };\n return { r, g, b };\n}\n\n/** RGBA color — accepts {r,g,b,a?} object (0-1)
|
|
1
|
+
{"version":3,"sources":["../../src/tools/schemas.ts","../../src/utils/coercion.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { flexJson, flexBool } from \"../utils/coercion\";\n\n// ─── Shared Zod Schema Fragments ────────────────────────────────\n// Import as: import * as S from \"./schemas\";\n\n/** Single node ID */\nexport const nodeId = z.string().describe(\"Node ID\");\n\n/** Array of node IDs */\nexport const nodeIds = flexJson(z.array(z.string())).describe(\"Array of node IDs\");\n\n/** Optional parent reference for creation tools */\nexport const parentId = z.string().optional()\n .describe(\"Parent node ID. Omit to place on current page.\");\n\n/**\n * Response depth — controls how much node detail is returned after an operation.\n * Omit for minimal response (id + name only).\n * 0 = node with full properties, children as stubs.\n * N = recurse N levels of children with full properties.\n * -1 = unlimited recursion.\n */\nexport const depth = z.coerce.number().optional()\n .describe(\"Response detail: omit for id+name only. 0=properties + child stubs. N=recurse N levels. -1=unlimited.\");\n\n/** X position for creation tools */\nexport const xPos = z.coerce.number().optional().describe(\"X position (default: 0)\");\n\n/** Y position for creation tools */\nexport const yPos = z.coerce.number().optional().describe(\"Y position (default: 0)\");\n\n/** Parse hex color string (#RGB, #RRGGBB, #RRGGBBAA) to {r,g,b,a} 0-1 */\nfunction parseHex(hex: string): { r: number; g: number; b: number; a?: number } | null {\n const m = hex.match(/^#?([0-9a-f]{3,8})$/i);\n if (!m) return null;\n let h = m[1];\n if (h.length === 3) h = h[0]+h[0]+h[1]+h[1]+h[2]+h[2];\n if (h.length === 4) h = h[0]+h[0]+h[1]+h[1]+h[2]+h[2]+h[3]+h[3];\n if (h.length !== 6 && h.length !== 8) return null;\n const r = parseInt(h.slice(0, 2), 16) / 255;\n const g = parseInt(h.slice(2, 4), 16) / 255;\n const b = parseInt(h.slice(4, 6), 16) / 255;\n if (h.length === 8) return { r, g, b, a: parseInt(h.slice(6, 8), 16) / 255 };\n return { r, g, b };\n}\n\n/** RGBA color — accepts {r,g,b,a?} object (0-1), hex string (#RGB, #RRGGBB, #RRGGBBAA), or style/variable name string */\nexport const colorRgba = z.preprocess((v) => {\n if (typeof v === \"string\") return parseHex(v) ?? v;\n return v;\n}, z.union([\n z.object({\n r: z.coerce.number().min(0).max(1),\n g: z.coerce.number().min(0).max(1),\n b: z.coerce.number().min(0).max(1),\n a: z.coerce.number().min(0).max(1).optional(),\n }),\n z.string(), // Non-hex strings pass through for handler-level style/variable resolution\n])).describe('Hex \"#FF0000\", {r,g,b,a?} 0-1, or style/variable name.');\n\n/** Variable value — color (hex or RGBA), number, boolean, string, or alias */\nexport const variableValue = z.preprocess((v) => {\n if (typeof v === \"string\") return parseHex(v) ?? v;\n return v;\n}, z.union([\n z.number(),\n z.boolean(),\n z.string(),\n z.object({ r: z.number(), g: z.number(), b: z.number(), a: z.number().optional() }),\n z.object({ type: z.literal(\"VARIABLE_ALIAS\"), name: z.string() }),\n])).describe('number, boolean, string, hex \"#FF0000\", {r,g,b,a?}, or {type:\"VARIABLE_ALIAS\",name:\"other/variable\"}');\n\n/** Line height — number (px) or {value, unit} */\nexport const lineHeight = z.union([\n z.coerce.number(),\n z.object({ value: z.coerce.number(), unit: z.enum([\"PIXELS\", \"PERCENT\", \"AUTO\"]) }),\n]).describe('number (px) or {value, unit: \"PIXELS\"|\"PERCENT\"|\"AUTO\"}');\n\n/** Letter spacing — number (px) or {value, unit} */\nexport const letterSpacing = z.union([\n z.coerce.number(),\n z.object({ value: z.coerce.number(), unit: z.enum([\"PIXELS\", \"PERCENT\"]) }),\n]).describe('number (px) or {value, unit: \"PIXELS\"|\"PERCENT\"}');\n\n/** String or boolean — for component property defaults */\nexport const stringOrBoolean = z.union([z.string(), z.boolean()]);\n\n/** Design token — accepts a string that is either a numeric value (\"8\") or a variable name/ID (\"Radii/Medium\").\n * Numeric strings are parsed to numbers in the handler; non-numeric strings are variable references. */\nexport const token = z.preprocess((v) => {\n // Accept raw numbers from agents that pass them correctly\n if (typeof v === \"number\") return String(v);\n return v;\n}, z.string()).describe('number as string (\"8\") or variable name (\"Radii/Medium\")');\n\n/** Single effect entry — shared by set_effects and styles create */\nexport const effectEntry = z.object({\n type: z.enum([\"DROP_SHADOW\", \"INNER_SHADOW\", \"LAYER_BLUR\", \"BACKGROUND_BLUR\"]),\n color: flexJson(colorRgba).optional(),\n offset: flexJson(z.object({ x: z.coerce.number(), y: z.coerce.number() })).optional(),\n radius: z.coerce.number(),\n spread: z.coerce.number().optional(),\n visible: flexBool(z.boolean()).optional(),\n blendMode: z.string().optional(),\n});\n","import { z } from \"zod\";\n\n// AI agents (Claude, GPT, etc.) frequently pass numbers as strings\n// (\"10\" instead of 10), booleans as strings (\"true\" instead of true),\n// and objects/arrays as JSON strings. These helpers add resilient\n// coercion so tools don't fail on valid-but-mistyped input.\n\n/** Coerce \"true\"/\"false\"/\"1\"/\"0\" strings to boolean */\nexport const flexBool = <T extends z.ZodTypeAny>(inner: T) =>\n z.preprocess((v) => {\n if (v === \"true\" || v === \"1\") return true;\n if (v === \"false\" || v === \"0\") return false;\n return v;\n }, inner);\n\n/** Coerce JSON strings to parsed values (for objects/arrays that agents may stringify) */\nexport const flexJson = <T extends z.ZodTypeAny>(inner: T) =>\n z.preprocess((v) => {\n if (typeof v === \"string\") {\n try {\n return JSON.parse(v);\n } catch {\n return v;\n }\n }\n return v;\n }, inner);\n\n/** Coerce numeric strings only when they're valid numbers (safe for use inside unions) */\nexport const flexNum = <T extends z.ZodTypeAny>(inner: T) =>\n z.preprocess((v) => {\n if (typeof v === \"string\") {\n const n = Number(v);\n if (!isNaN(n) && v.trim() !== \"\") return n;\n }\n return v;\n }, inner);\n"],"mappings":";AAAA,SAAS,KAAAA,UAAS;;;ACAlB,SAAS,SAAS;AAQX,IAAM,WAAW,CAAyB,UAC/C,EAAE,WAAW,CAAC,MAAM;AAClB,MAAI,MAAM,UAAU,MAAM,IAAK,QAAO;AACtC,MAAI,MAAM,WAAW,MAAM,IAAK,QAAO;AACvC,SAAO;AACT,GAAG,KAAK;AAGH,IAAM,WAAW,CAAyB,UAC/C,EAAE,WAAW,CAAC,MAAM;AAClB,MAAI,OAAO,MAAM,UAAU;AACzB,QAAI;AACF,aAAO,KAAK,MAAM,CAAC;AAAA,IACrB,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT,GAAG,KAAK;;;ADnBH,IAAM,SAASC,GAAE,OAAO,EAAE,SAAS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CAAC,EAAE,SAAS,yDAAyD;AAG9D,IAAM,gBAAgBA,GAAE,MAAM;AAAA,EACnCA,GAAE,OAAO,OAAO;AAAA,EAChBA,GAAE,OAAO,EAAE,OAAOA,GAAE,OAAO,OAAO,GAAG,MAAMA,GAAE,KAAK,CAAC,UAAU,SAAS,CAAC,EAAE,CAAC;AAC5E,CAAC,EAAE,SAAS,kDAAkD;AAGvD,IAAM,kBAAkBA,GAAE,MAAM,CAACA,GAAE,OAAO,GAAGA,GAAE,QAAQ,CAAC,CAAC;AAIzD,IAAM,QAAQA,GAAE,WAAW,CAAC,MAAM;AAEvC,MAAI,OAAO,MAAM,SAAU,QAAO,OAAO,CAAC;AAC1C,SAAO;AACT,GAAGA,GAAE,OAAO,CAAC,EAAE,SAAS,0DAA0D;AAG3E,IAAM,cAAcA,GAAE,OAAO;AAAA,EAClC,MAAMA,GAAE,KAAK,CAAC,eAAe,gBAAgB,cAAc,iBAAiB,CAAC;AAAA,EAC7E,OAAO,SAAS,SAAS,EAAE,SAAS;AAAA,EACpC,QAAQ,SAASA,GAAE,OAAO,EAAE,GAAGA,GAAE,OAAO,OAAO,GAAG,GAAGA,GAAE,OAAO,OAAO,EAAE,CAAC,CAAC,EAAE,SAAS;AAAA,EACpF,QAAQA,GAAE,OAAO,OAAO;AAAA,EACxB,QAAQA,GAAE,OAAO,OAAO,EAAE,SAAS;AAAA,EACnC,SAAS,SAASA,GAAE,QAAQ,CAAC,EAAE,SAAS;AAAA,EACxC,WAAWA,GAAE,OAAO,EAAE,SAAS;AACjC,CAAC;","names":["z","z"]}
|
package/dist/tools/types.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/tools/types.ts"],"sourcesContent":["import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport type { z } from \"zod\";\n\n/** Function signature for sending commands to Figma via WebSocket */\nexport type SendCommandFn = (command: string, params?: unknown, timeoutMs?: number) => Promise<unknown>;\n\n/** Re-export McpServer type for tool files */\nexport type { McpServer };\n\n// ─── Tool Registry Types ────────────────────────────────────────\n\n/** Access tier for a tool */\nexport type ToolTier = \"read\" | \"create\" | \"edit\";\n\n/** Which tiers are enabled for this MCP session */\nexport interface Capabilities { create: boolean; edit: boolean }\n\n/** Declarative tool definition — replaces imperative registerMcpTools() */\nexport interface ToolDef {\n name: string;\n description: string;\n schema: Record<string, z.ZodTypeAny>\n | ((caps: Capabilities) => Record<string, z.ZodTypeAny>);\n tier: ToolTier;\n /** Figma command name. Defaults to name. */\n command?: string;\n /** sendCommand timeout in ms (default: 30 000) */\n timeout?: number;\n /** Pre-send validation (e.g. per-method item parsing for endpoints) */\n validate?: (params: any) => void;\n /** Custom response formatter. Default: mcpJson */\n formatResponse?: (result: unknown) => any;\n}\n\n/** Standard batch result from Figma handlers */\nexport interface BatchResult<T = unknown> {\n results: Array<T | \"ok\" | { error: string }>;\n warnings?: string[];\n /** Set when some items were deferred (e.g. font loading cap exceeded) */\n deferred?: string;\n}\n\n/** Max response size in characters (~12K tokens). Prevents LLM client-side truncation that corrupts JSON. */\nconst MAX_RESPONSE_CHARS = 50_000;\n\n/** Format a successful MCP response (JSON). Returns a clean error if response exceeds safe size. */\nexport function mcpJson(data: unknown) {\n const text = JSON.stringify(data);\n if (text.length <= MAX_RESPONSE_CHARS) {\n return { content: [{ type: \"text\" as const, text }] };\n }\n return {\n content: [{\n type: \"text\" as const,\n text: JSON.stringify({\n _error: \"response_too_large\",\n _sizeKB: Math.round(text.length / 1024),\n warning: \"Response exceeds safe size. Use 'depth', 'fields', 'limit', or 'summaryOnly' parameters to reduce response size.\",\n }),\n }],\n };\n}\n\n/** Format an error MCP response */\nexport function mcpError(prefix: string, error: unknown) {\n const msg = error instanceof Error ? error.message : String(error);\n return { content: [{ type: \"text\" as const, text: `${prefix}: ${msg}` }] };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"sources":["../../src/tools/types.ts"],"sourcesContent":["import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport type { z } from \"zod\";\n\n/** Function signature for sending commands to Figma via WebSocket */\nexport type SendCommandFn = (command: string, params?: unknown, timeoutMs?: number) => Promise<unknown>;\n\n/** Re-export McpServer type for tool files */\nexport type { McpServer };\n\n// ─── Tool Registry Types ────────────────────────────────────────\n\n/** Access tier for a tool */\nexport type ToolTier = \"read\" | \"create\" | \"edit\";\n\n/** Which tiers are enabled for this MCP session */\nexport interface Capabilities { create: boolean; edit: boolean }\n\n/** Declarative tool definition — replaces imperative registerMcpTools() */\nexport interface ToolDef {\n name: string;\n description: string;\n schema: Record<string, z.ZodTypeAny>\n | ((caps: Capabilities) => Record<string, z.ZodTypeAny>);\n tier: ToolTier;\n /** Figma command name. Defaults to name. For legacy standalone tools. */\n command?: string;\n /** Method → Figma command dispatch map. For endpoint tools (generated by schema compiler). */\n commandMap?: Record<string, string>;\n /** sendCommand timeout in ms (default: 30 000) */\n timeout?: number;\n /** Pre-send validation (e.g. per-method item parsing for endpoints) */\n validate?: (params: any) => void;\n /** Custom response formatter. Default: mcpJson */\n formatResponse?: (result: unknown) => any;\n /** Per-method response formatters. Overrides formatResponse for specific methods. */\n methodFormatters?: Record<string, (result: unknown) => any>;\n}\n\n/** Standard batch result from Figma handlers */\nexport interface BatchResult<T = unknown> {\n results: Array<T | \"ok\" | { error: string }>;\n warnings?: string[];\n /** Set when some items were deferred (e.g. font loading cap exceeded) */\n deferred?: string;\n}\n\n/** Max response size in characters (~12K tokens). Prevents LLM client-side truncation that corrupts JSON. */\nconst MAX_RESPONSE_CHARS = 50_000;\n\n/** Format a successful MCP response (JSON). Returns a clean error if response exceeds safe size. */\nexport function mcpJson(data: unknown) {\n const text = JSON.stringify(data);\n if (text.length <= MAX_RESPONSE_CHARS) {\n return { content: [{ type: \"text\" as const, text }] };\n }\n return {\n content: [{\n type: \"text\" as const,\n text: JSON.stringify({\n _error: \"response_too_large\",\n _sizeKB: Math.round(text.length / 1024),\n warning: \"Response exceeds safe size. Use 'depth', 'fields', 'limit', or 'summaryOnly' parameters to reduce response size.\",\n }),\n }],\n };\n}\n\n/** Format an error MCP response */\nexport function mcpError(prefix: string, error: unknown) {\n const msg = error instanceof Error ? error.message : String(error);\n return { content: [{ type: \"text\" as const, text: `${prefix}: ${msg}` }] };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA+CA,IAAM,qBAAqB;AAGpB,SAAS,QAAQ,MAAe;AACrC,QAAM,OAAO,KAAK,UAAU,IAAI;AAChC,MAAI,KAAK,UAAU,oBAAoB;AACrC,WAAO,EAAE,SAAS,CAAC,EAAE,MAAM,QAAiB,KAAK,CAAC,EAAE;AAAA,EACtD;AACA,SAAO;AAAA,IACL,SAAS,CAAC;AAAA,MACR,MAAM;AAAA,MACN,MAAM,KAAK,UAAU;AAAA,QACnB,QAAQ;AAAA,QACR,SAAS,KAAK,MAAM,KAAK,SAAS,IAAI;AAAA,QACtC,SAAS;AAAA,MACX,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AACF;AAGO,SAAS,SAAS,QAAgB,OAAgB;AACvD,QAAM,MAAM,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AACjE,SAAO,EAAE,SAAS,CAAC,EAAE,MAAM,QAAiB,MAAM,GAAG,MAAM,KAAK,GAAG,GAAG,CAAC,EAAE;AAC3E;","names":[]}
|
package/dist/tools/types.d.cts
CHANGED
|
@@ -17,14 +17,18 @@ interface ToolDef {
|
|
|
17
17
|
description: string;
|
|
18
18
|
schema: Record<string, z.ZodTypeAny> | ((caps: Capabilities) => Record<string, z.ZodTypeAny>);
|
|
19
19
|
tier: ToolTier;
|
|
20
|
-
/** Figma command name. Defaults to name. */
|
|
20
|
+
/** Figma command name. Defaults to name. For legacy standalone tools. */
|
|
21
21
|
command?: string;
|
|
22
|
+
/** Method → Figma command dispatch map. For endpoint tools (generated by schema compiler). */
|
|
23
|
+
commandMap?: Record<string, string>;
|
|
22
24
|
/** sendCommand timeout in ms (default: 30 000) */
|
|
23
25
|
timeout?: number;
|
|
24
26
|
/** Pre-send validation (e.g. per-method item parsing for endpoints) */
|
|
25
27
|
validate?: (params: any) => void;
|
|
26
28
|
/** Custom response formatter. Default: mcpJson */
|
|
27
29
|
formatResponse?: (result: unknown) => any;
|
|
30
|
+
/** Per-method response formatters. Overrides formatResponse for specific methods. */
|
|
31
|
+
methodFormatters?: Record<string, (result: unknown) => any>;
|
|
28
32
|
}
|
|
29
33
|
/** Standard batch result from Figma handlers */
|
|
30
34
|
interface BatchResult<T = unknown> {
|
package/dist/tools/types.d.ts
CHANGED
|
@@ -17,14 +17,18 @@ interface ToolDef {
|
|
|
17
17
|
description: string;
|
|
18
18
|
schema: Record<string, z.ZodTypeAny> | ((caps: Capabilities) => Record<string, z.ZodTypeAny>);
|
|
19
19
|
tier: ToolTier;
|
|
20
|
-
/** Figma command name. Defaults to name. */
|
|
20
|
+
/** Figma command name. Defaults to name. For legacy standalone tools. */
|
|
21
21
|
command?: string;
|
|
22
|
+
/** Method → Figma command dispatch map. For endpoint tools (generated by schema compiler). */
|
|
23
|
+
commandMap?: Record<string, string>;
|
|
22
24
|
/** sendCommand timeout in ms (default: 30 000) */
|
|
23
25
|
timeout?: number;
|
|
24
26
|
/** Pre-send validation (e.g. per-method item parsing for endpoints) */
|
|
25
27
|
validate?: (params: any) => void;
|
|
26
28
|
/** Custom response formatter. Default: mcpJson */
|
|
27
29
|
formatResponse?: (result: unknown) => any;
|
|
30
|
+
/** Per-method response formatters. Overrides formatResponse for specific methods. */
|
|
31
|
+
methodFormatters?: Record<string, (result: unknown) => any>;
|
|
28
32
|
}
|
|
29
33
|
/** Standard batch result from Figma handlers */
|
|
30
34
|
interface BatchResult<T = unknown> {
|
package/dist/tools/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/tools/types.ts"],"sourcesContent":["import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport type { z } from \"zod\";\n\n/** Function signature for sending commands to Figma via WebSocket */\nexport type SendCommandFn = (command: string, params?: unknown, timeoutMs?: number) => Promise<unknown>;\n\n/** Re-export McpServer type for tool files */\nexport type { McpServer };\n\n// ─── Tool Registry Types ────────────────────────────────────────\n\n/** Access tier for a tool */\nexport type ToolTier = \"read\" | \"create\" | \"edit\";\n\n/** Which tiers are enabled for this MCP session */\nexport interface Capabilities { create: boolean; edit: boolean }\n\n/** Declarative tool definition — replaces imperative registerMcpTools() */\nexport interface ToolDef {\n name: string;\n description: string;\n schema: Record<string, z.ZodTypeAny>\n | ((caps: Capabilities) => Record<string, z.ZodTypeAny>);\n tier: ToolTier;\n /** Figma command name. Defaults to name. */\n command?: string;\n /** sendCommand timeout in ms (default: 30 000) */\n timeout?: number;\n /** Pre-send validation (e.g. per-method item parsing for endpoints) */\n validate?: (params: any) => void;\n /** Custom response formatter. Default: mcpJson */\n formatResponse?: (result: unknown) => any;\n}\n\n/** Standard batch result from Figma handlers */\nexport interface BatchResult<T = unknown> {\n results: Array<T | \"ok\" | { error: string }>;\n warnings?: string[];\n /** Set when some items were deferred (e.g. font loading cap exceeded) */\n deferred?: string;\n}\n\n/** Max response size in characters (~12K tokens). Prevents LLM client-side truncation that corrupts JSON. */\nconst MAX_RESPONSE_CHARS = 50_000;\n\n/** Format a successful MCP response (JSON). Returns a clean error if response exceeds safe size. */\nexport function mcpJson(data: unknown) {\n const text = JSON.stringify(data);\n if (text.length <= MAX_RESPONSE_CHARS) {\n return { content: [{ type: \"text\" as const, text }] };\n }\n return {\n content: [{\n type: \"text\" as const,\n text: JSON.stringify({\n _error: \"response_too_large\",\n _sizeKB: Math.round(text.length / 1024),\n warning: \"Response exceeds safe size. Use 'depth', 'fields', 'limit', or 'summaryOnly' parameters to reduce response size.\",\n }),\n }],\n };\n}\n\n/** Format an error MCP response */\nexport function mcpError(prefix: string, error: unknown) {\n const msg = error instanceof Error ? error.message : String(error);\n return { content: [{ type: \"text\" as const, text: `${prefix}: ${msg}` }] };\n}\n"],"mappings":";
|
|
1
|
+
{"version":3,"sources":["../../src/tools/types.ts"],"sourcesContent":["import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport type { z } from \"zod\";\n\n/** Function signature for sending commands to Figma via WebSocket */\nexport type SendCommandFn = (command: string, params?: unknown, timeoutMs?: number) => Promise<unknown>;\n\n/** Re-export McpServer type for tool files */\nexport type { McpServer };\n\n// ─── Tool Registry Types ────────────────────────────────────────\n\n/** Access tier for a tool */\nexport type ToolTier = \"read\" | \"create\" | \"edit\";\n\n/** Which tiers are enabled for this MCP session */\nexport interface Capabilities { create: boolean; edit: boolean }\n\n/** Declarative tool definition — replaces imperative registerMcpTools() */\nexport interface ToolDef {\n name: string;\n description: string;\n schema: Record<string, z.ZodTypeAny>\n | ((caps: Capabilities) => Record<string, z.ZodTypeAny>);\n tier: ToolTier;\n /** Figma command name. Defaults to name. For legacy standalone tools. */\n command?: string;\n /** Method → Figma command dispatch map. For endpoint tools (generated by schema compiler). */\n commandMap?: Record<string, string>;\n /** sendCommand timeout in ms (default: 30 000) */\n timeout?: number;\n /** Pre-send validation (e.g. per-method item parsing for endpoints) */\n validate?: (params: any) => void;\n /** Custom response formatter. Default: mcpJson */\n formatResponse?: (result: unknown) => any;\n /** Per-method response formatters. Overrides formatResponse for specific methods. */\n methodFormatters?: Record<string, (result: unknown) => any>;\n}\n\n/** Standard batch result from Figma handlers */\nexport interface BatchResult<T = unknown> {\n results: Array<T | \"ok\" | { error: string }>;\n warnings?: string[];\n /** Set when some items were deferred (e.g. font loading cap exceeded) */\n deferred?: string;\n}\n\n/** Max response size in characters (~12K tokens). Prevents LLM client-side truncation that corrupts JSON. */\nconst MAX_RESPONSE_CHARS = 50_000;\n\n/** Format a successful MCP response (JSON). Returns a clean error if response exceeds safe size. */\nexport function mcpJson(data: unknown) {\n const text = JSON.stringify(data);\n if (text.length <= MAX_RESPONSE_CHARS) {\n return { content: [{ type: \"text\" as const, text }] };\n }\n return {\n content: [{\n type: \"text\" as const,\n text: JSON.stringify({\n _error: \"response_too_large\",\n _sizeKB: Math.round(text.length / 1024),\n warning: \"Response exceeds safe size. Use 'depth', 'fields', 'limit', or 'summaryOnly' parameters to reduce response size.\",\n }),\n }],\n };\n}\n\n/** Format an error MCP response */\nexport function mcpError(prefix: string, error: unknown) {\n const msg = error instanceof Error ? error.message : String(error);\n return { content: [{ type: \"text\" as const, text: `${prefix}: ${msg}` }] };\n}\n"],"mappings":";AA+CA,IAAM,qBAAqB;AAGpB,SAAS,QAAQ,MAAe;AACrC,QAAM,OAAO,KAAK,UAAU,IAAI;AAChC,MAAI,KAAK,UAAU,oBAAoB;AACrC,WAAO,EAAE,SAAS,CAAC,EAAE,MAAM,QAAiB,KAAK,CAAC,EAAE;AAAA,EACtD;AACA,SAAO;AAAA,IACL,SAAS,CAAC;AAAA,MACR,MAAM;AAAA,MACN,MAAM,KAAK,UAAU;AAAA,QACnB,QAAQ;AAAA,QACR,SAAS,KAAK,MAAM,KAAK,SAAS,IAAI;AAAA,QACtC,SAAS;AAAA,MACX,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AACF;AAGO,SAAS,SAAS,QAAgB,OAAgB;AACvD,QAAM,MAAM,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AACjE,SAAO,EAAE,SAAS,CAAC,EAAE,MAAM,QAAiB,MAAM,GAAG,MAAM,KAAK,GAAG,GAAG,CAAC,EAAE;AAC3E;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ufira/vibma",
|
|
3
3
|
"description": "Vibma — Vibe Design meets Figma. AI-powered MCP bridge for designing in Figma.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "1.0.0-rc1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "ufira <https://github.com/ufira-ai>",
|
|
7
7
|
"homepage": "https://github.com/ufira-ai/vibma",
|
|
@@ -44,6 +44,10 @@
|
|
|
44
44
|
"import": "./dist/tools/registry.js",
|
|
45
45
|
"require": "./dist/tools/registry.cjs"
|
|
46
46
|
},
|
|
47
|
+
"./guards": {
|
|
48
|
+
"import": "./dist/tools/generated/guards.js",
|
|
49
|
+
"require": "./dist/tools/generated/guards.cjs"
|
|
50
|
+
},
|
|
47
51
|
"./utils/color": {
|
|
48
52
|
"import": "./dist/utils/color.js",
|
|
49
53
|
"require": "./dist/utils/color.cjs"
|
|
@@ -75,7 +79,7 @@
|
|
|
75
79
|
"zod": "4.3.6"
|
|
76
80
|
},
|
|
77
81
|
"devDependencies": {
|
|
78
|
-
"@types/node": "^25.
|
|
82
|
+
"@types/node": "^25.4.0",
|
|
79
83
|
"@types/ws": "^8.18.1",
|
|
80
84
|
"tsup": "^8.5.1",
|
|
81
85
|
"typescript": "^5.9.3"
|