@kvasar/google-stitch 0.1.4 → 0.1.5

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "openclaw-google-stitch",
3
3
  "name": "Google Stitch MCP",
4
- "version": "0.1.4",
4
+ "version": "0.1.5",
5
5
  "description": "Integrates Google Stitch MCP services into OpenClaw",
6
6
  "skills": ["skills"],
7
7
  "configSchema": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kvasar/google-stitch",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
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",
@@ -1,20 +1,48 @@
1
1
  export class StitchMCPClient {
2
- constructor(private config: { apiKey: string; endpoint: string }) {}
2
+ constructor(
3
+ private config: { apiKey: string; endpoint: string }
4
+ ) {
5
+ if (!config.apiKey) {
6
+ throw new Error("Missing Stitch apiKey");
7
+ }
8
+
9
+ if (!config.endpoint) {
10
+ throw new Error("Missing Stitch endpoint");
11
+ }
12
+ }
13
+
3
14
  private async request(path: string, body?: unknown) {
4
- const response = await fetch(`${this.config.endpoint}/${path}`, {
5
- method: "POST",
6
- headers: {
7
- "Content-Type": "application/json",
8
- Authorization: `Bearer ${this.config.apiKey}`,
9
- },
10
- body: body ? JSON.stringify(body) : undefined,
11
- });
12
- if (!response.ok) throw new Error(`Stitch API error: ${response.status}`);
15
+ const cleanPath = path.startsWith("/")
16
+ ? path.slice(1)
17
+ : path;
18
+
19
+ const response = await fetch(
20
+ `${this.config.endpoint}/${cleanPath}`,
21
+ {
22
+ method: "POST",
23
+ headers: {
24
+ "Content-Type": "application/json",
25
+ "X-Goog-Api-Key": this.config.apiKey,
26
+ },
27
+ body: body
28
+ ? JSON.stringify(body)
29
+ : undefined,
30
+ }
31
+ );
32
+
33
+ if (!response.ok) {
34
+ const errorText = await response.text();
35
+ throw new Error(
36
+ `Stitch API error: ${response.status} - ${errorText}`
37
+ );
38
+ }
39
+
13
40
  return response.json();
14
41
  }
15
- async generateScreen(prompt: string) {
42
+
43
+ async generateScreen(prompt: string) {
16
44
  return this.request("generate-screen", {
17
45
  prompt,
18
46
  });
19
47
  }
20
- }
48
+ }