@kvasar/google-stitch 0.1.6 → 0.1.7
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kvasar/google-stitch",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "OpenClaw plugin for Google Stitch UI generation, screen design, variants, and design systems",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -40,11 +40,12 @@
|
|
|
40
40
|
]
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
43
44
|
"@sinclair/typebox": "^0.32.0"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
|
-
"typescript": "^5.4.0",
|
|
47
47
|
"@types/node": "^22.0.0",
|
|
48
|
+
"typescript": "^5.4.0",
|
|
48
49
|
"vitest": "^1.6.0"
|
|
49
50
|
},
|
|
50
51
|
"keywords": [
|
|
@@ -1,48 +1,44 @@
|
|
|
1
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
2
|
+
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
3
|
+
|
|
1
4
|
export class StitchMCPClient {
|
|
5
|
+
private client: Client;
|
|
6
|
+
private transport: StreamableHTTPClientTransport;
|
|
7
|
+
private connected = false;
|
|
8
|
+
|
|
2
9
|
constructor(
|
|
3
10
|
private config: { apiKey: string; endpoint: string }
|
|
4
11
|
) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (!config.endpoint) {
|
|
10
|
-
throw new Error("Missing Stitch endpoint");
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
private async request(path: string, body?: unknown) {
|
|
15
|
-
const cleanPath = path.startsWith("/")
|
|
16
|
-
? path.slice(1)
|
|
17
|
-
: path;
|
|
12
|
+
this.client = new Client({
|
|
13
|
+
name: "openclaw-google-stitch",
|
|
14
|
+
version: "1.0.0",
|
|
15
|
+
});
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
this.transport = new StreamableHTTPClientTransport(
|
|
18
|
+
new URL(this.config.endpoint),
|
|
21
19
|
{
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
requestInit: {
|
|
21
|
+
headers: {
|
|
22
|
+
"X-Goog-Api-Key": this.config.apiKey,
|
|
23
|
+
},
|
|
26
24
|
},
|
|
27
|
-
body: body
|
|
28
|
-
? JSON.stringify(body)
|
|
29
|
-
: undefined,
|
|
30
25
|
}
|
|
31
26
|
);
|
|
27
|
+
}
|
|
32
28
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
);
|
|
29
|
+
async connect() {
|
|
30
|
+
if (!this.connected) {
|
|
31
|
+
await this.client.connect(this.transport);
|
|
32
|
+
this.connected = true;
|
|
38
33
|
}
|
|
39
|
-
|
|
40
|
-
return response.json();
|
|
41
34
|
}
|
|
42
35
|
|
|
43
36
|
async generateScreen(prompt: string) {
|
|
44
|
-
|
|
45
|
-
|
|
37
|
+
await this.connect();
|
|
38
|
+
|
|
39
|
+
return this.client.callTool({
|
|
40
|
+
name: "generate_screen_from_text",
|
|
41
|
+
arguments: { prompt },
|
|
46
42
|
});
|
|
47
43
|
}
|
|
48
44
|
}
|