@google/stitch-sdk 0.0.1
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 +271 -0
- package/dist/generated/src/index.d.ts +13 -0
- package/dist/generated/src/index.d.ts.map +1 -0
- package/dist/generated/src/index.js +13 -0
- package/dist/generated/src/index.js.map +1 -0
- package/dist/generated/src/project.d.ts +35 -0
- package/dist/generated/src/project.d.ts.map +1 -0
- package/dist/generated/src/project.js +62 -0
- package/dist/generated/src/project.js.map +1 -0
- package/dist/generated/src/screen.d.ts +40 -0
- package/dist/generated/src/screen.d.ts.map +1 -0
- package/dist/generated/src/screen.js +82 -0
- package/dist/generated/src/screen.js.map +1 -0
- package/dist/generated/src/stitch.d.ts +23 -0
- package/dist/generated/src/stitch.d.ts.map +1 -0
- package/dist/generated/src/stitch.js +27 -0
- package/dist/generated/src/stitch.js.map +1 -0
- package/dist/generated/src/tool-definitions.d.ts +20 -0
- package/dist/generated/src/tool-definitions.d.ts.map +1 -0
- package/dist/generated/src/tool-definitions.js +333 -0
- package/dist/generated/src/tool-definitions.js.map +1 -0
- package/dist/src/ai.d.ts +17 -0
- package/dist/src/ai.d.ts.map +1 -0
- package/dist/src/ai.js +30 -0
- package/dist/src/ai.js.map +1 -0
- package/dist/src/client.d.ts +77 -0
- package/dist/src/client.d.ts.map +1 -0
- package/dist/src/client.js +135 -0
- package/dist/src/client.js.map +1 -0
- package/dist/src/constants.d.ts +2 -0
- package/dist/src/constants.d.ts.map +1 -0
- package/dist/src/constants.js +15 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/index.d.ts +10 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +25 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/proxy/client.d.ts +22 -0
- package/dist/src/proxy/client.d.ts.map +1 -0
- package/dist/src/proxy/client.js +87 -0
- package/dist/src/proxy/client.js.map +1 -0
- package/dist/src/proxy/core.d.ts +16 -0
- package/dist/src/proxy/core.d.ts.map +1 -0
- package/dist/src/proxy/core.js +68 -0
- package/dist/src/proxy/core.js.map +1 -0
- package/dist/src/proxy/handlers/callTool.d.ts +7 -0
- package/dist/src/proxy/handlers/callTool.d.ts.map +1 -0
- package/dist/src/proxy/handlers/callTool.js +40 -0
- package/dist/src/proxy/handlers/callTool.js.map +1 -0
- package/dist/src/proxy/handlers/listTools.d.ts +7 -0
- package/dist/src/proxy/handlers/listTools.d.ts.map +1 -0
- package/dist/src/proxy/handlers/listTools.js +36 -0
- package/dist/src/proxy/handlers/listTools.js.map +1 -0
- package/dist/src/proxy/index.d.ts +4 -0
- package/dist/src/proxy/index.d.ts.map +1 -0
- package/dist/src/proxy/index.js +17 -0
- package/dist/src/proxy/index.js.map +1 -0
- package/dist/src/singleton.d.ts +25 -0
- package/dist/src/singleton.d.ts.map +1 -0
- package/dist/src/singleton.js +76 -0
- package/dist/src/singleton.js.map +1 -0
- package/dist/src/spec/client.d.ts +52 -0
- package/dist/src/spec/client.d.ts.map +1 -0
- package/dist/src/spec/client.js +52 -0
- package/dist/src/spec/client.js.map +1 -0
- package/dist/src/spec/errors.d.ts +39 -0
- package/dist/src/spec/errors.d.ts.map +1 -0
- package/dist/src/spec/errors.js +56 -0
- package/dist/src/spec/errors.js.map +1 -0
- package/dist/src/spec/proxy.d.ts +22 -0
- package/dist/src/spec/proxy.d.ts.map +1 -0
- package/dist/src/spec/proxy.js +31 -0
- package/dist/src/spec/proxy.js.map +1 -0
- package/dist/src/tools-adapter.d.ts +27 -0
- package/dist/src/tools-adapter.d.ts.map +1 -0
- package/dist/src/tools-adapter.js +66 -0
- package/dist/src/tools-adapter.js.map +1 -0
- package/dist/src/types.d.ts +38 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +15 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/version.d.ts +2 -0
- package/dist/src/version.d.ts.map +1 -0
- package/dist/src/version.js +3 -0
- package/dist/src/version.js.map +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
/** All tools available on the Stitch MCP server, generated from tools-manifest.json. */
|
|
2
|
+
export const toolDefinitions = [
|
|
3
|
+
{
|
|
4
|
+
"name": "create_project",
|
|
5
|
+
"description": "Creates a new Stitch project. A project is a container for UI designs and frontend code.\n",
|
|
6
|
+
"inputSchema": {
|
|
7
|
+
"description": "Request message for CreateProject.",
|
|
8
|
+
"properties": {
|
|
9
|
+
"title": {
|
|
10
|
+
"description": "Optional. The title of the project.",
|
|
11
|
+
"type": "string"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"type": "object"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"name": "get_project",
|
|
19
|
+
"description": "Retrieves the details of a specific Stitch project using its project name.\n",
|
|
20
|
+
"inputSchema": {
|
|
21
|
+
"description": "Request message for GetProject.",
|
|
22
|
+
"properties": {
|
|
23
|
+
"name": {
|
|
24
|
+
"description": "Required. Identifier. The resource name of the project to retrieve. Format: `projects/{project}` Example: `projects/4044680601076201931`",
|
|
25
|
+
"type": "string",
|
|
26
|
+
"x-google-identifier": true
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"required": [
|
|
30
|
+
"name"
|
|
31
|
+
],
|
|
32
|
+
"type": "object"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"name": "list_projects",
|
|
37
|
+
"description": "Lists all Stitch projects accessible to the user. By default, it lists projects owned by the user.\n",
|
|
38
|
+
"inputSchema": {
|
|
39
|
+
"description": "Request message for ListProjects.",
|
|
40
|
+
"properties": {
|
|
41
|
+
"filter": {
|
|
42
|
+
"description": "Optional. A filter to apply to the list of projects, following a subset of AIP-160. This service supports filtering on the `view` field. Supported filters: * `view=owned`: Lists only projects owned by the user. This is the default behavior if no filter is specified. * `view=shared`: Lists only projects shared with the user. Example: `view=owned`",
|
|
43
|
+
"type": "string"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"type": "object"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"name": "list_screens",
|
|
51
|
+
"description": "Lists all screens within a given Stitch project.\n",
|
|
52
|
+
"inputSchema": {
|
|
53
|
+
"description": "Request message for ListScreens.",
|
|
54
|
+
"properties": {
|
|
55
|
+
"projectId": {
|
|
56
|
+
"description": "Required. Identifier. The project ID to list screens for, example: '4044680601076201931', without the `projects/` prefix.",
|
|
57
|
+
"type": "string",
|
|
58
|
+
"x-google-identifier": true
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"required": [
|
|
62
|
+
"projectId"
|
|
63
|
+
],
|
|
64
|
+
"type": "object"
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"name": "get_screen",
|
|
69
|
+
"description": "Retrieves the details of a specific screen within a project.\n",
|
|
70
|
+
"inputSchema": {
|
|
71
|
+
"description": "Request message for GetScreen.",
|
|
72
|
+
"properties": {
|
|
73
|
+
"name": {
|
|
74
|
+
"description": "Required. Identifier. The resource name of the screen to retrieve. Format: `projects/{project}/screens/{screen}` Example: `projects/4044680601076201931/screens/98b50e2ddc9943efb387052637738f61`",
|
|
75
|
+
"type": "string",
|
|
76
|
+
"x-google-identifier": true
|
|
77
|
+
},
|
|
78
|
+
"projectId": {
|
|
79
|
+
"deprecated": true,
|
|
80
|
+
"description": "Required. The project ID of screen to retrieve. Example: `4044680601076201931`, without the `projects/` prefix.",
|
|
81
|
+
"type": "string"
|
|
82
|
+
},
|
|
83
|
+
"screenId": {
|
|
84
|
+
"deprecated": true,
|
|
85
|
+
"description": "Required. The screen ID of screen to retrieve. Example: `98b50e2ddc9943efb387052637738f61`, without the `screens/` prefix.",
|
|
86
|
+
"type": "string"
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
"required": [
|
|
90
|
+
"name",
|
|
91
|
+
"projectId",
|
|
92
|
+
"screenId"
|
|
93
|
+
],
|
|
94
|
+
"type": "object"
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"name": "generate_screen_from_text",
|
|
99
|
+
"description": "Generates a new screen within a project from a text prompt.\n\n**Instructions for Tool Call:**\n* This action can take a few minutes to complete. Please be patient. DO NOT RETRY.\n* If the tool call fails due to connection error, the generation process may still succeed. Please try to get the screen with `get_screen` method later.\n\n**Output:**\n* **`output_components`**: If `output_components` contains text, return it to the user. If `output_components` contains suggestions (e.g. \"Yes, make them all\"), present these suggestions to the user. If the user accepts one of the suggestions, call `generate_screen_from_text` again with `prompt` set to the accepted suggestion.\n",
|
|
100
|
+
"inputSchema": {
|
|
101
|
+
"description": "Request message for GenerateScreenFromText.",
|
|
102
|
+
"properties": {
|
|
103
|
+
"deviceType": {
|
|
104
|
+
"description": "The type of device that captured the screenshot, e.g., mobile or desktop.",
|
|
105
|
+
"enum": [
|
|
106
|
+
"DEVICE_TYPE_UNSPECIFIED",
|
|
107
|
+
"MOBILE",
|
|
108
|
+
"DESKTOP",
|
|
109
|
+
"TABLET",
|
|
110
|
+
"AGNOSTIC"
|
|
111
|
+
],
|
|
112
|
+
"type": "string",
|
|
113
|
+
"x-google-enum-descriptions": [
|
|
114
|
+
"Unspecified device type.",
|
|
115
|
+
"A design for a mobile device.",
|
|
116
|
+
"A design for a desktop device.",
|
|
117
|
+
"A design for a tablet device.",
|
|
118
|
+
"A design that is not tied to a specific device."
|
|
119
|
+
]
|
|
120
|
+
},
|
|
121
|
+
"modelId": {
|
|
122
|
+
"description": "Optional. The model to use for generation.",
|
|
123
|
+
"enum": [
|
|
124
|
+
"MODEL_ID_UNSPECIFIED",
|
|
125
|
+
"GEMINI_3_PRO",
|
|
126
|
+
"GEMINI_3_FLASH"
|
|
127
|
+
],
|
|
128
|
+
"type": "string",
|
|
129
|
+
"x-google-enum-descriptions": [
|
|
130
|
+
"Unspecified model.",
|
|
131
|
+
"Gemini 3 Pro.",
|
|
132
|
+
"Gemini 3 Flash."
|
|
133
|
+
]
|
|
134
|
+
},
|
|
135
|
+
"projectId": {
|
|
136
|
+
"description": "Required. The project ID to generate the screen for, example: '4044680601076201931', without the `projects/` prefix.",
|
|
137
|
+
"type": "string"
|
|
138
|
+
},
|
|
139
|
+
"prompt": {
|
|
140
|
+
"description": "Required. The input text to generate the screen from.",
|
|
141
|
+
"type": "string"
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
"required": [
|
|
145
|
+
"projectId",
|
|
146
|
+
"prompt"
|
|
147
|
+
],
|
|
148
|
+
"type": "object"
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"name": "edit_screens",
|
|
153
|
+
"description": "Edits existing screens within a project using a text prompt.\n\n**Instructions for Tool Call:**\n* This action can take a few minutes to complete. Please be patient. DO NOT RETRY.\n* If the tool call fails due to connection error, the process may still succeed.\n",
|
|
154
|
+
"inputSchema": {
|
|
155
|
+
"description": "Request message for EditScreens.",
|
|
156
|
+
"properties": {
|
|
157
|
+
"deviceType": {
|
|
158
|
+
"description": "Optional. The type of device that captured the screenshot, e.g., mobile or desktop.",
|
|
159
|
+
"enum": [
|
|
160
|
+
"DEVICE_TYPE_UNSPECIFIED",
|
|
161
|
+
"MOBILE",
|
|
162
|
+
"DESKTOP",
|
|
163
|
+
"TABLET",
|
|
164
|
+
"AGNOSTIC"
|
|
165
|
+
],
|
|
166
|
+
"type": "string",
|
|
167
|
+
"x-google-enum-descriptions": [
|
|
168
|
+
"Unspecified device type.",
|
|
169
|
+
"A design for a mobile device.",
|
|
170
|
+
"A design for a desktop device.",
|
|
171
|
+
"A design for a tablet device.",
|
|
172
|
+
"A design that is not tied to a specific device."
|
|
173
|
+
]
|
|
174
|
+
},
|
|
175
|
+
"modelId": {
|
|
176
|
+
"description": "Optional. The model to use for generation.",
|
|
177
|
+
"enum": [
|
|
178
|
+
"MODEL_ID_UNSPECIFIED",
|
|
179
|
+
"GEMINI_3_PRO",
|
|
180
|
+
"GEMINI_3_FLASH"
|
|
181
|
+
],
|
|
182
|
+
"type": "string",
|
|
183
|
+
"x-google-enum-descriptions": [
|
|
184
|
+
"Unspecified model.",
|
|
185
|
+
"Gemini 3 Pro.",
|
|
186
|
+
"Gemini 3 Flash."
|
|
187
|
+
]
|
|
188
|
+
},
|
|
189
|
+
"projectId": {
|
|
190
|
+
"description": "Required. The project ID of screens to edit, example: '4044680601076201931', without the `projects/` prefix.",
|
|
191
|
+
"type": "string"
|
|
192
|
+
},
|
|
193
|
+
"prompt": {
|
|
194
|
+
"description": "Required. The input text to generate the screen from.",
|
|
195
|
+
"type": "string"
|
|
196
|
+
},
|
|
197
|
+
"selectedScreenIds": {
|
|
198
|
+
"description": "Required. The screen IDs of screens to edit, example: ['98b50e2ddc9943efb387052637738f61', '98b50e2ddc9943efb387052637738f62'], without the `screens/` prefix.",
|
|
199
|
+
"items": {
|
|
200
|
+
"type": "string"
|
|
201
|
+
},
|
|
202
|
+
"type": "array"
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
"required": [
|
|
206
|
+
"projectId",
|
|
207
|
+
"selectedScreenIds",
|
|
208
|
+
"prompt"
|
|
209
|
+
],
|
|
210
|
+
"type": "object"
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
"name": "generate_variants",
|
|
215
|
+
"description": "Generates variants of existing screens within a project using a text prompt.\n",
|
|
216
|
+
"inputSchema": {
|
|
217
|
+
"$defs": {
|
|
218
|
+
"VariantOptions": {
|
|
219
|
+
"description": "Configuration options for design variant generation. This message captures all parameters used to generate variants, allowing the configuration to be stored, replayed, or analyzed.",
|
|
220
|
+
"properties": {
|
|
221
|
+
"aspects": {
|
|
222
|
+
"description": "Optional. Specific aspects to focus on. If empty, all aspects may be varied.",
|
|
223
|
+
"items": {
|
|
224
|
+
"enum": [
|
|
225
|
+
"VARIANT_ASPECT_UNSPECIFIED",
|
|
226
|
+
"LAYOUT",
|
|
227
|
+
"COLOR_SCHEME",
|
|
228
|
+
"IMAGES",
|
|
229
|
+
"TEXT_FONT",
|
|
230
|
+
"TEXT_CONTENT"
|
|
231
|
+
],
|
|
232
|
+
"type": "string",
|
|
233
|
+
"x-google-enum-descriptions": [
|
|
234
|
+
"Unspecified aspect.",
|
|
235
|
+
"Layout: Arrangement of elements on the screen.",
|
|
236
|
+
"Color scheme: Colors used on the screen.",
|
|
237
|
+
"Images: Images used on the screen.",
|
|
238
|
+
"Text font: Fonts used for text on the screen.",
|
|
239
|
+
"Text content: Text content on the screen."
|
|
240
|
+
]
|
|
241
|
+
},
|
|
242
|
+
"type": "array"
|
|
243
|
+
},
|
|
244
|
+
"creativeRange": {
|
|
245
|
+
"description": "Optional. Creative range for variations. Default: EXPLORE",
|
|
246
|
+
"enum": [
|
|
247
|
+
"CREATIVE_RANGE_UNSPECIFIED",
|
|
248
|
+
"REFINE",
|
|
249
|
+
"EXPLORE",
|
|
250
|
+
"REIMAGINE"
|
|
251
|
+
],
|
|
252
|
+
"type": "string",
|
|
253
|
+
"x-google-enum-descriptions": [
|
|
254
|
+
"Unspecified creative range.",
|
|
255
|
+
"Subtle refinements, closely adhering to original.",
|
|
256
|
+
"Balanced exploration. Default.",
|
|
257
|
+
"Radical explorations, fundamentally challenging the original."
|
|
258
|
+
]
|
|
259
|
+
},
|
|
260
|
+
"variantCount": {
|
|
261
|
+
"description": "Optional. Number of variants to generate (1-5). Default: 3",
|
|
262
|
+
"format": "int32",
|
|
263
|
+
"type": "integer"
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
"type": "object"
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
"description": "Request message for GenerateVariants.",
|
|
270
|
+
"properties": {
|
|
271
|
+
"deviceType": {
|
|
272
|
+
"description": "Optional. The type of device that captured the screenshot, e.g., mobile or desktop.",
|
|
273
|
+
"enum": [
|
|
274
|
+
"DEVICE_TYPE_UNSPECIFIED",
|
|
275
|
+
"MOBILE",
|
|
276
|
+
"DESKTOP",
|
|
277
|
+
"TABLET",
|
|
278
|
+
"AGNOSTIC"
|
|
279
|
+
],
|
|
280
|
+
"type": "string",
|
|
281
|
+
"x-google-enum-descriptions": [
|
|
282
|
+
"Unspecified device type.",
|
|
283
|
+
"A design for a mobile device.",
|
|
284
|
+
"A design for a desktop device.",
|
|
285
|
+
"A design for a tablet device.",
|
|
286
|
+
"A design that is not tied to a specific device."
|
|
287
|
+
]
|
|
288
|
+
},
|
|
289
|
+
"modelId": {
|
|
290
|
+
"description": "Optional. The model to use for generation.",
|
|
291
|
+
"enum": [
|
|
292
|
+
"MODEL_ID_UNSPECIFIED",
|
|
293
|
+
"GEMINI_3_PRO",
|
|
294
|
+
"GEMINI_3_FLASH"
|
|
295
|
+
],
|
|
296
|
+
"type": "string",
|
|
297
|
+
"x-google-enum-descriptions": [
|
|
298
|
+
"Unspecified model.",
|
|
299
|
+
"Gemini 3 Pro.",
|
|
300
|
+
"Gemini 3 Flash."
|
|
301
|
+
]
|
|
302
|
+
},
|
|
303
|
+
"projectId": {
|
|
304
|
+
"description": "Required. The project ID of screens to generate variants for, example: '4044680601076201931', without the `projects/` prefix.",
|
|
305
|
+
"type": "string"
|
|
306
|
+
},
|
|
307
|
+
"prompt": {
|
|
308
|
+
"description": "Required. The input text used to generate the variants.",
|
|
309
|
+
"type": "string"
|
|
310
|
+
},
|
|
311
|
+
"selectedScreenIds": {
|
|
312
|
+
"description": "Required. The screen ids of screen to generate variants for, example: ['98b50e2ddc9943efb387052637738f61', '98b50e2ddc9943efb387052637738f62'], without the `screens/` prefix.",
|
|
313
|
+
"items": {
|
|
314
|
+
"type": "string"
|
|
315
|
+
},
|
|
316
|
+
"type": "array"
|
|
317
|
+
},
|
|
318
|
+
"variantOptions": {
|
|
319
|
+
"$ref": "#/$defs/VariantOptions",
|
|
320
|
+
"description": "Required. The variant options for generation, including the number of variants, creative range, and aspects to focus on."
|
|
321
|
+
}
|
|
322
|
+
},
|
|
323
|
+
"required": [
|
|
324
|
+
"projectId",
|
|
325
|
+
"selectedScreenIds",
|
|
326
|
+
"prompt",
|
|
327
|
+
"variantOptions"
|
|
328
|
+
],
|
|
329
|
+
"type": "object"
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
];
|
|
333
|
+
//# sourceMappingURL=tool-definitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-definitions.js","sourceRoot":"","sources":["../../../generated/src/tool-definitions.ts"],"names":[],"mappings":"AAkBA,wFAAwF;AACxF,MAAM,CAAC,MAAM,eAAe,GAAqB;IAC/C;QACE,MAAM,EAAE,gBAAgB;QACxB,aAAa,EAAE,4FAA4F;QAC3G,aAAa,EAAE;YACb,aAAa,EAAE,oCAAoC;YACnD,YAAY,EAAE;gBACZ,OAAO,EAAE;oBACP,aAAa,EAAE,qCAAqC;oBACpD,MAAM,EAAE,QAAQ;iBACjB;aACF;YACD,MAAM,EAAE,QAAQ;SACjB;KACF;IACD;QACE,MAAM,EAAE,aAAa;QACrB,aAAa,EAAE,8EAA8E;QAC7F,aAAa,EAAE;YACb,aAAa,EAAE,iCAAiC;YAChD,YAAY,EAAE;gBACZ,MAAM,EAAE;oBACN,aAAa,EAAE,0IAA0I;oBACzJ,MAAM,EAAE,QAAQ;oBAChB,qBAAqB,EAAE,IAAI;iBAC5B;aACF;YACD,UAAU,EAAE;gBACV,MAAM;aACP;YACD,MAAM,EAAE,QAAQ;SACjB;KACF;IACD;QACE,MAAM,EAAE,eAAe;QACvB,aAAa,EAAE,sGAAsG;QACrH,aAAa,EAAE;YACb,aAAa,EAAE,mCAAmC;YAClD,YAAY,EAAE;gBACZ,QAAQ,EAAE;oBACR,aAAa,EAAE,6VAA6V;oBAC5W,MAAM,EAAE,QAAQ;iBACjB;aACF;YACD,MAAM,EAAE,QAAQ;SACjB;KACF;IACD;QACE,MAAM,EAAE,cAAc;QACtB,aAAa,EAAE,oDAAoD;QACnE,aAAa,EAAE;YACb,aAAa,EAAE,kCAAkC;YACjD,YAAY,EAAE;gBACZ,WAAW,EAA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AAE,QAAQ;oBAChB,4BAA4B,EAAE;wBAC5B,0BAA0B;wBAC1B,+BAA+B;wBAC/B,gCAAgC;wBAChC,+BAA+B;wBAC/B,iDAAiD;qBAClD;iBACF;gBACD,SAAS,EAAE;oBACT,aAAa,EAAE,4CAA4C;oBAC3D,MAAM,EAAE;wBACN,sBAAsB;wBACtB,cAAc;wBACd,gBAAgB;qBACjB;oBACD,MAAM,EAAE,QAAQ;oBAChB,4BAA4B,EAAE;wBAC5B,oBAAoB;wBACpB,eAAe;wBACf,iBAAiB;qBAClB;iBACF;gBACD,WAAW,EAAE;oBACX,aAAa,EAAE,+HAA+H;oBAC9I,MAAM,EAAE,QAAQ;iBACjB;gBACD,QAAQ,EAAE;oBACR,aAAa,EAAE,yDAAyD;oBACxE,MAAM,EAAE,QAAQ;iBACjB;gBACD,mBAAmB,EAAE;oBACnB,aAAa,EAAE,gLAAgL;oBAC/L,OAAO,EAAE;wBACP,MAAM,EAAE,QAAQ;qBACjB;oBACD,MAAM,EAAE,OAAO;iBAChB;gBACD,gBAAgB,EAAE;oBAChB,MAAM,EAAE,wBAAwB;oBAChC,aAAa,EAAE,0HAA0H;iBAC1I;aACF;YACD,UAAU,EAAE;gBACV,WAAW;gBACX,mBAAmB;gBACnB,QAAQ;gBACR,gBAAgB;aACjB;YACD,MAAM,EAAE,QAAQ;SACjB;KACF;CACF,CAAC"}
|
package/dist/src/ai.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI SDK adapter entry point.
|
|
3
|
+
*
|
|
4
|
+
* Import from `@google/stitch-sdk/ai` to use Stitch tools with the Vercel AI SDK.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* import { stitchTools } from "@google/stitch-sdk/ai";
|
|
8
|
+
* import { generateText } from "ai";
|
|
9
|
+
*
|
|
10
|
+
* const { text } = await generateText({
|
|
11
|
+
* model,
|
|
12
|
+
* tools: stitchTools(),
|
|
13
|
+
* prompt: "Create a login page",
|
|
14
|
+
* });
|
|
15
|
+
*/
|
|
16
|
+
export { stitchTools } from "./tools-adapter.js";
|
|
17
|
+
//# sourceMappingURL=ai.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../../src/ai.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/src/ai.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Copyright 2026 Google LLC
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
/**
|
|
15
|
+
* AI SDK adapter entry point.
|
|
16
|
+
*
|
|
17
|
+
* Import from `@google/stitch-sdk/ai` to use Stitch tools with the Vercel AI SDK.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* import { stitchTools } from "@google/stitch-sdk/ai";
|
|
21
|
+
* import { generateText } from "ai";
|
|
22
|
+
*
|
|
23
|
+
* const { text } = await generateText({
|
|
24
|
+
* model,
|
|
25
|
+
* tools: stitchTools(),
|
|
26
|
+
* prompt: "Create a login page",
|
|
27
|
+
* });
|
|
28
|
+
*/
|
|
29
|
+
export { stitchTools } from "./tools-adapter.js";
|
|
30
|
+
//# sourceMappingURL=ai.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai.js","sourceRoot":"","sources":["../../src/ai.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,kDAAkD;AAClD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { StitchConfig, StitchToolClientSpec } from './spec/client.js';
|
|
2
|
+
/**
|
|
3
|
+
* Authenticated tool pipe for the Stitch MCP Server.
|
|
4
|
+
*
|
|
5
|
+
* Designed for agents and orchestration scripts that forward JSON payloads
|
|
6
|
+
* to MCP tools. Handles auth injection via the transport layer (not global fetch).
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* const client = new StitchToolClient(); // reads STITCH_API_KEY from env
|
|
10
|
+
* const result = await client.callTool("generate_screen_from_text", { ... });
|
|
11
|
+
*/
|
|
12
|
+
export declare class StitchToolClient implements StitchToolClientSpec {
|
|
13
|
+
name: 'stitch-tool-client';
|
|
14
|
+
description: 'Authenticated tool pipe for Stitch MCP Server';
|
|
15
|
+
private client;
|
|
16
|
+
private transport;
|
|
17
|
+
private config;
|
|
18
|
+
private isConnected;
|
|
19
|
+
constructor(inputConfig?: Partial<StitchConfig>);
|
|
20
|
+
/**
|
|
21
|
+
* Build auth headers based on config (API key or OAuth).
|
|
22
|
+
*/
|
|
23
|
+
private buildAuthHeaders;
|
|
24
|
+
private parseToolResponse;
|
|
25
|
+
connect(): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Generic tool caller with type support and error parsing.
|
|
28
|
+
*/
|
|
29
|
+
callTool<T>(name: string, args: Record<string, any>): Promise<T>;
|
|
30
|
+
listTools(): Promise<{
|
|
31
|
+
[x: string]: unknown;
|
|
32
|
+
tools: {
|
|
33
|
+
inputSchema: {
|
|
34
|
+
[x: string]: unknown;
|
|
35
|
+
type: "object";
|
|
36
|
+
properties?: Record<string, object> | undefined;
|
|
37
|
+
required?: string[] | undefined;
|
|
38
|
+
};
|
|
39
|
+
name: string;
|
|
40
|
+
description?: string | undefined;
|
|
41
|
+
outputSchema?: {
|
|
42
|
+
[x: string]: unknown;
|
|
43
|
+
type: "object";
|
|
44
|
+
properties?: Record<string, object> | undefined;
|
|
45
|
+
required?: string[] | undefined;
|
|
46
|
+
} | undefined;
|
|
47
|
+
annotations?: {
|
|
48
|
+
title?: string | undefined;
|
|
49
|
+
readOnlyHint?: boolean | undefined;
|
|
50
|
+
destructiveHint?: boolean | undefined;
|
|
51
|
+
idempotentHint?: boolean | undefined;
|
|
52
|
+
openWorldHint?: boolean | undefined;
|
|
53
|
+
} | undefined;
|
|
54
|
+
execution?: {
|
|
55
|
+
taskSupport?: "optional" | "required" | "forbidden" | undefined;
|
|
56
|
+
} | undefined;
|
|
57
|
+
_meta?: Record<string, unknown> | undefined;
|
|
58
|
+
icons?: {
|
|
59
|
+
src: string;
|
|
60
|
+
mimeType?: string | undefined;
|
|
61
|
+
sizes?: string[] | undefined;
|
|
62
|
+
theme?: "light" | "dark" | undefined;
|
|
63
|
+
}[] | undefined;
|
|
64
|
+
title?: string | undefined;
|
|
65
|
+
}[];
|
|
66
|
+
_meta?: {
|
|
67
|
+
[x: string]: unknown;
|
|
68
|
+
progressToken?: string | number | undefined;
|
|
69
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
70
|
+
taskId: string;
|
|
71
|
+
} | undefined;
|
|
72
|
+
} | undefined;
|
|
73
|
+
nextCursor?: string | undefined;
|
|
74
|
+
}>;
|
|
75
|
+
close(): Promise<void>;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAsB,YAAY,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAI1F;;;;;;;;;GASG;AACH,qBAAa,gBAAiB,YAAW,oBAAoB;IAC3D,IAAI,EAAE,oBAAoB,CAAwB;IAClD,WAAW,EAAE,+CAA+C,CAAmD;IAE/G,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAA8C;IAC/D,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,WAAW,CAAkB;gBAEzB,WAAW,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC;IAgB/C;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAexB,OAAO,CAAC,iBAAiB;IAsCnB,OAAO;IAsBb;;OAEG;IACG,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAYhE,SAAS;;;;;;0BAY0/e,CAAC;wBAA8D,CAAC;;;uBAAwF,CAAC;wBAA8C,CAAC;;;0BAAoG,CAAC;wBAA8D,CAAC;;uBAA0E,CAAC;qBAAyB,CAAC;4BAAkD,CAAC;+BAAsD,CAAC;8BAAqD,CAAC;6BAAoD,CAAC;;qBAAuE,CAAC;2BAA+B,CAAC;;iBAAiG,CAAC;iBAAwD,CAAC;;wBAAyD,CAAC;qBAA2C,CAAC;qBAA6C,CAAC;;iBAA8E,CAAC;;;;yBAAgH,CAAC;kDAAiF,CAAC;;;;;;IAPl1hB,KAAK;CAMZ"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// Copyright 2026 Google LLC
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
15
|
+
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
16
|
+
import { StitchConfigSchema } from './spec/client.js';
|
|
17
|
+
import { StitchError } from './spec/errors.js';
|
|
18
|
+
import { SDK_VERSION } from './version.js';
|
|
19
|
+
/**
|
|
20
|
+
* Authenticated tool pipe for the Stitch MCP Server.
|
|
21
|
+
*
|
|
22
|
+
* Designed for agents and orchestration scripts that forward JSON payloads
|
|
23
|
+
* to MCP tools. Handles auth injection via the transport layer (not global fetch).
|
|
24
|
+
*
|
|
25
|
+
* Usage:
|
|
26
|
+
* const client = new StitchToolClient(); // reads STITCH_API_KEY from env
|
|
27
|
+
* const result = await client.callTool("generate_screen_from_text", { ... });
|
|
28
|
+
*/
|
|
29
|
+
export class StitchToolClient {
|
|
30
|
+
name = 'stitch-tool-client';
|
|
31
|
+
description = 'Authenticated tool pipe for Stitch MCP Server';
|
|
32
|
+
client;
|
|
33
|
+
transport = null;
|
|
34
|
+
config;
|
|
35
|
+
isConnected = false;
|
|
36
|
+
constructor(inputConfig) {
|
|
37
|
+
const rawConfig = {
|
|
38
|
+
accessToken: inputConfig?.accessToken || process.env.STITCH_ACCESS_TOKEN,
|
|
39
|
+
apiKey: inputConfig?.apiKey || process.env.STITCH_API_KEY,
|
|
40
|
+
projectId: inputConfig?.projectId || process.env.GOOGLE_CLOUD_PROJECT,
|
|
41
|
+
baseUrl: inputConfig?.baseUrl,
|
|
42
|
+
timeout: inputConfig?.timeout,
|
|
43
|
+
};
|
|
44
|
+
this.config = StitchConfigSchema.parse(rawConfig);
|
|
45
|
+
this.client = new Client({ name: "stitch-core-client", version: SDK_VERSION }, { capabilities: {} });
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Build auth headers based on config (API key or OAuth).
|
|
49
|
+
*/
|
|
50
|
+
buildAuthHeaders() {
|
|
51
|
+
const headers = {
|
|
52
|
+
'Accept': 'application/json, text/event-stream',
|
|
53
|
+
};
|
|
54
|
+
if (this.config.apiKey) {
|
|
55
|
+
headers['X-Goog-Api-Key'] = this.config.apiKey;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
headers['Authorization'] = `Bearer ${this.config.accessToken}`;
|
|
59
|
+
headers['X-Goog-User-Project'] = this.config.projectId;
|
|
60
|
+
}
|
|
61
|
+
return headers;
|
|
62
|
+
}
|
|
63
|
+
parseToolResponse(result, name) {
|
|
64
|
+
if (result.isError) {
|
|
65
|
+
const errorText = result.content.map((c) => (c.type === 'text' ? c.text : '')).join('');
|
|
66
|
+
let code = 'UNKNOWN_ERROR';
|
|
67
|
+
const lowerErrorText = errorText.toLowerCase();
|
|
68
|
+
if (lowerErrorText.includes('rate limit') || lowerErrorText.includes('429')) {
|
|
69
|
+
code = 'RATE_LIMITED';
|
|
70
|
+
}
|
|
71
|
+
else if (lowerErrorText.includes('not found') || lowerErrorText.includes('404')) {
|
|
72
|
+
code = 'NOT_FOUND';
|
|
73
|
+
}
|
|
74
|
+
else if (lowerErrorText.includes('permission') || lowerErrorText.includes('403')) {
|
|
75
|
+
code = 'PERMISSION_DENIED';
|
|
76
|
+
}
|
|
77
|
+
throw new StitchError({
|
|
78
|
+
code,
|
|
79
|
+
message: `Tool Call Failed [${name}]: ${errorText}`,
|
|
80
|
+
recoverable: code === 'RATE_LIMITED',
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
// Stitch specific parsing: Check structuredContent first, then JSON in text
|
|
84
|
+
const anyResult = result;
|
|
85
|
+
if (anyResult.structuredContent)
|
|
86
|
+
return anyResult.structuredContent;
|
|
87
|
+
const textContent = result.content.find((c) => c.type === 'text');
|
|
88
|
+
if (textContent && textContent.type === 'text') {
|
|
89
|
+
try {
|
|
90
|
+
return JSON.parse(textContent.text);
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
return textContent.text;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return anyResult;
|
|
97
|
+
}
|
|
98
|
+
async connect() {
|
|
99
|
+
if (this.isConnected)
|
|
100
|
+
return;
|
|
101
|
+
// Create transport with auth headers injected per-instance (no global fetch mutation)
|
|
102
|
+
this.transport = new StreamableHTTPClientTransport(new URL(this.config.baseUrl), {
|
|
103
|
+
requestInit: {
|
|
104
|
+
headers: this.buildAuthHeaders(),
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
this.transport.onerror = (err) => {
|
|
108
|
+
console.error("Stitch Transport Error:", err);
|
|
109
|
+
this.isConnected = false;
|
|
110
|
+
};
|
|
111
|
+
await this.client.connect(this.transport);
|
|
112
|
+
this.isConnected = true;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Generic tool caller with type support and error parsing.
|
|
116
|
+
*/
|
|
117
|
+
async callTool(name, args) {
|
|
118
|
+
if (!this.isConnected)
|
|
119
|
+
await this.connect();
|
|
120
|
+
const result = await this.client.callTool({ name, arguments: args }, undefined, { timeout: this.config.timeout });
|
|
121
|
+
return this.parseToolResponse(result, name);
|
|
122
|
+
}
|
|
123
|
+
async listTools() {
|
|
124
|
+
if (!this.isConnected)
|
|
125
|
+
await this.connect();
|
|
126
|
+
return this.client.listTools();
|
|
127
|
+
}
|
|
128
|
+
async close() {
|
|
129
|
+
if (this.transport) {
|
|
130
|
+
await this.transport.close();
|
|
131
|
+
this.isConnected = false;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"A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;QAC3B,CAAC,CAAC;QAEF,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC1C,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,QAAQ,CAAI,IAAY,EAAE,IAAyB;QACvD,IAAI,CAAC,IAAI,CAAC,WAAW;YAAE,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QAE5C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CACvC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,EACzB,SAAS,EACT,EAAE,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CACjC,CAAC;QAEF,OAAO,IAAI,CAAC,iBAAiB,CAAI,MAAM,EAAE,IAAI,CAAC,CAAC;IACjD,CAAC;IAED,KAAK,CAAC,SAAS;QACb,IAAI,CAAC,IAAI,CAAC,WAAW;YAAE,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QAC5C,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;YAC7B,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;QAC3B,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,sBAAsB,sCAAsC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright 2026 Google LLC
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
export const DEFAULT_STITCH_API_URL = 'https://stitch.googleapis.com/mcp';
|
|
15
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,kDAAkD;AAClD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,MAAM,CAAC,MAAM,sBAAsB,GAAG,mCAAmC,CAAC"}
|