@kvasar/google-stitch 0.1.19 → 0.1.21
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/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@ import { Type } from "@sinclair/typebox";
|
|
|
7
7
|
import { StitchMCPClient } from "../services/stitch-mcp-client.js";
|
|
8
8
|
|
|
9
9
|
export interface CreateProjectParams {
|
|
10
|
-
|
|
10
|
+
title: string;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export function createProjectTool(client: StitchMCPClient) {
|
|
@@ -20,7 +20,7 @@ export function createProjectTool(client: StitchMCPClient) {
|
|
|
20
20
|
),
|
|
21
21
|
}),
|
|
22
22
|
async execute(_id: string, params: CreateProjectParams) {
|
|
23
|
-
const result = await client.createProject(params.
|
|
23
|
+
const result = await client.createProject(params.title);
|
|
24
24
|
return {
|
|
25
25
|
content: [{ type: "text" as const, text: JSON.stringify(result, null, 2) }],
|
|
26
26
|
};
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { StitchMCPClient } from "../services/stitch-mcp-client.js";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
|
|
6
|
+
type StitchFile = {
|
|
7
|
+
name?: string;
|
|
8
|
+
downloadUrl?: string;
|
|
9
|
+
mimeType?: string;
|
|
10
|
+
fileContentBase64?: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
type Screen = {
|
|
14
|
+
name?: string;
|
|
15
|
+
id?: string;
|
|
16
|
+
title?: string;
|
|
17
|
+
prompt?: string;
|
|
18
|
+
screenshot?: StitchFile;
|
|
19
|
+
htmlCode?: StitchFile;
|
|
20
|
+
figmaExport?: StitchFile;
|
|
21
|
+
deviceType?: string;
|
|
22
|
+
width?: string;
|
|
23
|
+
height?: string;
|
|
24
|
+
groupId?: string;
|
|
25
|
+
groupName?: string;
|
|
26
|
+
generatedBy?: string;
|
|
27
|
+
isCreatedByClient?: boolean;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
type GetScreenParams = {
|
|
31
|
+
name: string;
|
|
32
|
+
projectId: string;
|
|
33
|
+
screenId: string;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
type ContentItem = {
|
|
37
|
+
type: string;
|
|
38
|
+
[key: string]: any;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const getScreenTool = (client: StitchMCPClient) => ({
|
|
42
|
+
name: "get_screen",
|
|
43
|
+
description:
|
|
44
|
+
"Retrieves and visually renders a specific screen within a Stitch project.",
|
|
45
|
+
|
|
46
|
+
parameters: {
|
|
47
|
+
type: "object",
|
|
48
|
+
properties: {
|
|
49
|
+
name: {
|
|
50
|
+
type: "string",
|
|
51
|
+
description:
|
|
52
|
+
"Required. Resource name. Format: projects/{project}/screens/{screen}"
|
|
53
|
+
},
|
|
54
|
+
projectId: {
|
|
55
|
+
type: "string",
|
|
56
|
+
description:
|
|
57
|
+
"Required (deprecated). Project ID without prefix."
|
|
58
|
+
},
|
|
59
|
+
screenId: {
|
|
60
|
+
type: "string",
|
|
61
|
+
description:
|
|
62
|
+
"Required (deprecated). Screen ID without prefix."
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
required: ["name", "projectId", "screenId"]
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
async execute(
|
|
69
|
+
_: string,
|
|
70
|
+
params: GetScreenParams
|
|
71
|
+
) {
|
|
72
|
+
const { name, projectId, screenId } = params;
|
|
73
|
+
|
|
74
|
+
if (!name || !projectId || !screenId) {
|
|
75
|
+
throw new Error(
|
|
76
|
+
"name, projectId and screenId are required"
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const screen = (await client.request("get_screen", {
|
|
81
|
+
name,
|
|
82
|
+
projectId,
|
|
83
|
+
screenId
|
|
84
|
+
})) as Screen;
|
|
85
|
+
|
|
86
|
+
const content: ContentItem[] = [];
|
|
87
|
+
|
|
88
|
+
content.push({
|
|
89
|
+
type: "text",
|
|
90
|
+
text: `## ${screen.title || "Untitled screen"}
|
|
91
|
+
Prompt: ${screen.prompt || "-"}
|
|
92
|
+
Device: ${screen.deviceType || "-"}
|
|
93
|
+
Size: ${screen.width || "?"} × ${screen.height || "?"}`
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// Prefer embedded image
|
|
97
|
+
if (screen.screenshot?.fileContentBase64) {
|
|
98
|
+
const tempFilePath = path.join(
|
|
99
|
+
os.tmpdir(),
|
|
100
|
+
`stitch-screen-${Date.now()}.png`
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
fs.writeFileSync(
|
|
104
|
+
tempFilePath,
|
|
105
|
+
Buffer.from(
|
|
106
|
+
screen.screenshot.fileContentBase64,
|
|
107
|
+
"base64"
|
|
108
|
+
)
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
content.push({
|
|
112
|
+
type: "image",
|
|
113
|
+
path: tempFilePath,
|
|
114
|
+
caption: screen.title || "Generated screen"
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
return { content };
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Fallback remote image
|
|
121
|
+
if (screen.screenshot?.downloadUrl) {
|
|
122
|
+
content.push({
|
|
123
|
+
type: "image",
|
|
124
|
+
url: screen.screenshot.downloadUrl,
|
|
125
|
+
caption: screen.title || "Generated screen"
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
return { content };
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// HTML fallback
|
|
132
|
+
if (screen.htmlCode?.fileContentBase64) {
|
|
133
|
+
const html = Buffer.from(
|
|
134
|
+
screen.htmlCode.fileContentBase64,
|
|
135
|
+
"base64"
|
|
136
|
+
).toString("utf-8");
|
|
137
|
+
|
|
138
|
+
content.push({
|
|
139
|
+
type: "html",
|
|
140
|
+
html
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
return { content };
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (screen.htmlCode?.downloadUrl) {
|
|
147
|
+
content.push({
|
|
148
|
+
type: "html",
|
|
149
|
+
html: `<iframe
|
|
150
|
+
src="${screen.htmlCode.downloadUrl}"
|
|
151
|
+
style="width:100%;height:600px;border:none;"
|
|
152
|
+
></iframe>`
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
return { content };
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
content.push({
|
|
159
|
+
type: "text",
|
|
160
|
+
text: "No visual preview available for this screen."
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
return { content };
|
|
164
|
+
}
|
|
165
|
+
});
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
+
import { Type, Static } from "@sinclair/typebox";
|
|
2
|
+
|
|
3
|
+
const ListDesignSystemsSchema = Type.Object({
|
|
4
|
+
projectId: Type.Optional(Type.String({ description: "Optional. Project ID. If empty, lists global design systems." })),
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
type ListDesignSystemsParams = Static<typeof ListDesignSystemsSchema>;
|
|
8
|
+
|
|
1
9
|
export const listDesignSystemsTool = (client:any) => ({
|
|
2
10
|
name: "list_design_systems",
|
|
3
|
-
description: "
|
|
4
|
-
|
|
11
|
+
description: "Lists design systems accessible to the user, optionally filtered by project",
|
|
12
|
+
parameters: ListDesignSystemsSchema,
|
|
13
|
+
async execute(_: string, params: ListDesignSystemsParams) {
|
|
5
14
|
return await client.request?.("list_design_systems", params);
|
|
6
15
|
},
|
|
7
16
|
});
|
|
@@ -2,6 +2,7 @@ import { StitchMCPClient } from "../services/stitch-mcp-client.js";
|
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import os from "node:os";
|
|
4
4
|
import path from "node:path";
|
|
5
|
+
import { Type } from "@sinclair/typebox";
|
|
5
6
|
|
|
6
7
|
interface ListScreensParams {
|
|
7
8
|
projectId: string;
|
|
@@ -34,6 +35,10 @@ type Screen = {
|
|
|
34
35
|
export const listScreensTool = (client: StitchMCPClient) => ({
|
|
35
36
|
name: "list_screens",
|
|
36
37
|
description: "Lists all screens within a given Stitch project",
|
|
38
|
+
parameters: Type.Object({
|
|
39
|
+
projectId: Type.String({
|
|
40
|
+
description: "Required. Project ID (e.g., '4044680601076201931'), without `projects/` prefix."
|
|
41
|
+
})}),
|
|
37
42
|
|
|
38
43
|
async execute(_: string, params: ListScreensParams) {
|
|
39
44
|
if (!params?.projectId) {
|