@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.
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
|
@@ -1,20 +1,48 @@
|
|
|
1
1
|
export class StitchMCPClient {
|
|
2
|
-
constructor(
|
|
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
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
42
|
+
|
|
43
|
+
async generateScreen(prompt: string) {
|
|
16
44
|
return this.request("generate-screen", {
|
|
17
45
|
prompt,
|
|
18
46
|
});
|
|
19
47
|
}
|
|
20
|
-
}
|
|
48
|
+
}
|