@aprovan/stitchery 0.1.0-dev.6bd527d
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/.turbo/turbo-build.log +36 -0
- package/LICENSE +373 -0
- package/dist/cli.cjs +1400 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +1389 -0
- package/dist/cli.js.map +1 -0
- package/dist/index-DNQY1UAP.d.cts +195 -0
- package/dist/index-DNQY1UAP.d.ts +195 -0
- package/dist/index.cjs +1337 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +1308 -0
- package/dist/index.js.map +1 -0
- package/dist/server/index.cjs +1327 -0
- package/dist/server/index.cjs.map +1 -0
- package/dist/server/index.d.cts +3 -0
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.js +1304 -0
- package/dist/server/index.js.map +1 -0
- package/package.json +42 -0
- package/src/cli.ts +116 -0
- package/src/index.ts +16 -0
- package/src/prompts.ts +326 -0
- package/src/server/index.ts +365 -0
- package/src/server/local-packages.ts +91 -0
- package/src/server/routes.ts +122 -0
- package/src/server/services.ts +382 -0
- package/src/server/vfs-routes.ts +332 -0
- package/src/types.ts +59 -0
- package/tsconfig.json +13 -0
- package/tsup.config.ts +15 -0
|
@@ -0,0 +1,1327 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/server/index.ts
|
|
31
|
+
var server_exports = {};
|
|
32
|
+
__export(server_exports, {
|
|
33
|
+
createStitcheryServer: () => createStitcheryServer
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(server_exports);
|
|
36
|
+
var import_node_http = require("http");
|
|
37
|
+
var import_mcp = require("@ai-sdk/mcp");
|
|
38
|
+
var import_mcp_stdio = require("@ai-sdk/mcp/mcp-stdio");
|
|
39
|
+
var import_patchwork_utcp = require("@aprovan/patchwork-utcp");
|
|
40
|
+
var import_ai3 = require("ai");
|
|
41
|
+
|
|
42
|
+
// src/server/routes.ts
|
|
43
|
+
var import_openai_compatible = require("@ai-sdk/openai-compatible");
|
|
44
|
+
var import_ai = require("ai");
|
|
45
|
+
|
|
46
|
+
// src/prompts.ts
|
|
47
|
+
var PATCHWORK_PROMPT = `
|
|
48
|
+
You are a friendly assistant! When responding to the user, you _must_ respond with JSX files!
|
|
49
|
+
|
|
50
|
+
Look at 'patchwork.compilers' to see what specific runtime components and libraries are supported. (e.g. '['@aprovan/patchwork-image-shadcn' supports React, Tailwind, & ShadCN components). If there are no compilers, respond as you normally would. If compilers are available, ALWAYS respond with a component following [Component Generation](#component-generation).
|
|
51
|
+
|
|
52
|
+
Look at 'patchwork.services' to see what services are available for widgets to call. If services are listed, you can generate widgets that make service calls using global namespace objects.
|
|
53
|
+
|
|
54
|
+
**IMPORTANT: If you need to discover available services or get details about a specific service, use the \`search_services\` tool.**
|
|
55
|
+
|
|
56
|
+
## Component Generation
|
|
57
|
+
|
|
58
|
+
Respond with code blocks using tagged attributes on the fence line. The \`note\` attribute (optional but encouraged) provides a brief description visible in the UI. The \`path\` attribute specifies the virtual file path.
|
|
59
|
+
|
|
60
|
+
### Code Block Format
|
|
61
|
+
|
|
62
|
+
\`\`\`tsx note="Main component" path="components/weather/main.tsx"
|
|
63
|
+
export default function WeatherWidget() {
|
|
64
|
+
// component code
|
|
65
|
+
}
|
|
66
|
+
\`\`\`
|
|
67
|
+
|
|
68
|
+
### Attribute Order
|
|
69
|
+
Put \`note\` first so it's available soonest in streaming UI.
|
|
70
|
+
|
|
71
|
+
### Multi-File Generation
|
|
72
|
+
|
|
73
|
+
When generating complex widgets, you can output multiple files. Use the \`@/\` prefix for virtual file system paths. ALWAYS prefer to generate visible components before metadata.
|
|
74
|
+
|
|
75
|
+
**Example multi-file widget:**
|
|
76
|
+
|
|
77
|
+
\`\`\`json note="Widget configuration" path="components/dashboard/package.json"
|
|
78
|
+
{
|
|
79
|
+
"description": "Interactive dashboard widget",
|
|
80
|
+
"patchwork": {
|
|
81
|
+
"inputs": {
|
|
82
|
+
"type": "object",
|
|
83
|
+
"properties": {
|
|
84
|
+
"title": { "type": "string" }
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"services": {
|
|
88
|
+
"analytics": ["getMetrics", "getChartData"]
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
\`\`\`
|
|
93
|
+
|
|
94
|
+
\`\`\`tsx note="Main widget component" path="components/dashboard/main.tsx"
|
|
95
|
+
import { Card } from './Card';
|
|
96
|
+
import { Chart } from './Chart';
|
|
97
|
+
|
|
98
|
+
export default function Dashboard({ title = "Dashboard" }) {
|
|
99
|
+
return (
|
|
100
|
+
<div>
|
|
101
|
+
<h1>{title}</h1>
|
|
102
|
+
<Card />
|
|
103
|
+
<Chart />
|
|
104
|
+
</div>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
\`\`\`
|
|
108
|
+
|
|
109
|
+
\`\`\`tsx note="Card subcomponent" path="components/dashboard/Card.tsx"
|
|
110
|
+
export function Card() {
|
|
111
|
+
return <div className="p-4 rounded border">Card content</div>;
|
|
112
|
+
}
|
|
113
|
+
\`\`\`
|
|
114
|
+
|
|
115
|
+
### Requirements
|
|
116
|
+
- DO think heavily about correctness of code and syntax
|
|
117
|
+
- DO keep things simple and self-contained
|
|
118
|
+
- ALWAYS include the \`path\` attribute specifying the file location. Be generic with the name and describe the general component's use
|
|
119
|
+
- ALWAYS output the COMPLETE code block with opening \`\`\`tsx and closing \`\`\` markers
|
|
120
|
+
- Use \`note\` attribute to describe what each code block does (optional but encouraged)
|
|
121
|
+
- NEVER truncate or cut off code - finish the entire component before stopping
|
|
122
|
+
- If the component is complex, simplify it rather than leaving it incomplete
|
|
123
|
+
- Do NOT include: a heading/title
|
|
124
|
+
|
|
125
|
+
### Visual Design Guidelines
|
|
126
|
+
Create professional, polished interfaces that present information **spatially** rather than as vertical lists:
|
|
127
|
+
- Use **cards, grids, and flexbox layouts** to organize related data into visual groups
|
|
128
|
+
- Leverage **icons** (from lucide-react) alongside text to communicate meaning at a glance
|
|
129
|
+
- Apply **visual hierarchy** through typography scale, weight, and color contrast
|
|
130
|
+
- Use **whitespace strategically** to create breathing room and separation
|
|
131
|
+
- Prefer **horizontal arrangements** where data fits naturally (e.g., stats in a row, badges inline)
|
|
132
|
+
- Group related metrics into **compact visual clusters** rather than separate line items
|
|
133
|
+
- Use **subtle backgrounds, borders, and shadows** to define sections without heavy dividers
|
|
134
|
+
|
|
135
|
+
### Root Element Constraints
|
|
136
|
+
The component will be rendered inside a parent container that handles positioning. Your root element should:
|
|
137
|
+
- \u2705 Use intrinsic sizing (let content determine dimensions)
|
|
138
|
+
- \u2705 Handle internal padding (e.g., \`p-4\`, \`p-6\`)
|
|
139
|
+
- \u274C NEVER add centering utilities (\`items-center\`, \`justify-center\`) to position itself
|
|
140
|
+
- \u274C NEVER add viewport-relative sizing (\`min-h-screen\`, \`h-screen\`, \`w-screen\`)
|
|
141
|
+
- \u274C NEVER add flex/grid on root just for self-centering
|
|
142
|
+
|
|
143
|
+
### Using Services in Widgets (CRITICAL)
|
|
144
|
+
|
|
145
|
+
**MANDATORY workflow - you must follow these steps IN ORDER:**
|
|
146
|
+
|
|
147
|
+
1. **Use \`search_services\`** to discover the service schema
|
|
148
|
+
2. **STOP. Make an actual call to the service tool itself** (e.g., \`weather_get_forecast\`, \`github_get_repo\`) with real arguments. This is NOT optional. Do NOT skip this step.
|
|
149
|
+
3. **Observe the response** - verify it succeeded and note the exact data structure
|
|
150
|
+
4. **Only then generate the widget** that fetches the same data at runtime
|
|
151
|
+
|
|
152
|
+
**\`search_services\` is NOT a substitute for calling the actual service.** It only returns documentation. You MUST invoke the real service tool to validate your arguments work.
|
|
153
|
+
|
|
154
|
+
**Tool naming:** Service tools use underscores, not dots. For example: \`weather_get_forecast\`, \`github_list_repos\`.
|
|
155
|
+
|
|
156
|
+
**Example workflow for a weather widget:**
|
|
157
|
+
\`\`\`
|
|
158
|
+
Step 1: search_services({ query: "weather" })
|
|
159
|
+
\u2192 Learn that weather_get_current_conditions exists with params: { latitude, longitude }
|
|
160
|
+
|
|
161
|
+
Step 2: weather_get_current_conditions({ latitude: 29.7604, longitude: -95.3698 }) \u2190 REQUIRED!
|
|
162
|
+
\u2192 Verify it returns { temp: 72, humidity: 65, ... }
|
|
163
|
+
|
|
164
|
+
Step 3: Generate widget that calls weather.get_current_conditions at runtime
|
|
165
|
+
\`\`\`
|
|
166
|
+
|
|
167
|
+
**If you skip Step 2, you will generate broken widgets.** Arguments that look correct in the schema may fail at runtime due to validation rules, required formats, or service-specific constraints.
|
|
168
|
+
|
|
169
|
+
**NEVER embed static data directly in the component.**
|
|
170
|
+
|
|
171
|
+
\u274C **WRONG** - Embedding data directly:
|
|
172
|
+
\`\`\`tsx path="components/weather/bad-example.tsx"
|
|
173
|
+
// DON'T DO THIS - calling tool, then embedding the response as static data
|
|
174
|
+
export default function WeatherWidget() {
|
|
175
|
+
// Static data embedded at generation time - BAD!
|
|
176
|
+
const weather = { temp: 72, condition: "sunny", humidity: 45 };
|
|
177
|
+
return <div>Temperature: {weather.temp}\xB0F</div>;
|
|
178
|
+
}
|
|
179
|
+
\`\`\`
|
|
180
|
+
|
|
181
|
+
\u2705 **CORRECT** - Fetching data at runtime:
|
|
182
|
+
\`\`\`tsx note="Weather widget with runtime data" path="components/weather/main.tsx"
|
|
183
|
+
export default function WeatherWidget() {
|
|
184
|
+
const [data, setData] = useState(null);
|
|
185
|
+
const [loading, setLoading] = useState(true);
|
|
186
|
+
const [error, setError] = useState(null);
|
|
187
|
+
|
|
188
|
+
useEffect(() => {
|
|
189
|
+
// Fetch data at runtime - GOOD!
|
|
190
|
+
weather.get_forecast({ latitude: 48.8566, longitude: 2.3522 })
|
|
191
|
+
.then(setData)
|
|
192
|
+
.catch(setError)
|
|
193
|
+
.finally(() => setLoading(false));
|
|
194
|
+
}, []);
|
|
195
|
+
|
|
196
|
+
if (loading) return <Skeleton className="h-32 w-full" />;
|
|
197
|
+
if (error) return <Alert variant="destructive">{error.message}</Alert>;
|
|
198
|
+
|
|
199
|
+
return <div>Temperature: {data.temp}\xB0F</div>;
|
|
200
|
+
}
|
|
201
|
+
\`\`\`
|
|
202
|
+
|
|
203
|
+
**Why this matters:**
|
|
204
|
+
- Widgets with runtime service calls show **live data** that updates when refreshed
|
|
205
|
+
- Static embedded data becomes **stale immediately** after generation
|
|
206
|
+
- The proxy pattern allows widgets to be **reusable** across different contexts
|
|
207
|
+
- Error handling and loading states improve **user experience**
|
|
208
|
+
|
|
209
|
+
**Service call pattern:**
|
|
210
|
+
\`\`\`tsx
|
|
211
|
+
// Services are available as global namespace objects
|
|
212
|
+
// Call format: namespace.procedure_name({ ...args })
|
|
213
|
+
|
|
214
|
+
const [data, setData] = useState(null);
|
|
215
|
+
const [loading, setLoading] = useState(true);
|
|
216
|
+
const [error, setError] = useState(null);
|
|
217
|
+
|
|
218
|
+
useEffect(() => {
|
|
219
|
+
serviceName.procedure_name({ param1: value1 })
|
|
220
|
+
.then(setData)
|
|
221
|
+
.catch(setError)
|
|
222
|
+
.finally(() => setLoading(false));
|
|
223
|
+
}, [/* dependencies */]);
|
|
224
|
+
\`\`\`
|
|
225
|
+
|
|
226
|
+
**Required for service-using widgets:**
|
|
227
|
+
- Always show loading indicators (Skeleton, Loader2 spinner, etc.)
|
|
228
|
+
- Always handle errors gracefully with user-friendly messages
|
|
229
|
+
- Use appropriate React hooks (useState, useEffect) for async data
|
|
230
|
+
- Services are injected as globals - NO imports needed
|
|
231
|
+
|
|
232
|
+
### Validating Service Calls (CRITICAL - READ CAREFULLY)
|
|
233
|
+
|
|
234
|
+
**Calling \`search_services\` multiple times is NOT validation.** You must call the actual service tool.
|
|
235
|
+
|
|
236
|
+
\u274C **WRONG workflow (will produce broken widgets):**
|
|
237
|
+
\`\`\`
|
|
238
|
+
1. search_services({ query: "weather" }) \u2190 Only gets schema
|
|
239
|
+
2. search_services({ query: "location" }) \u2190 Still only schema
|
|
240
|
+
3. Generate widget \u2190 BROKEN - never tested the actual service!
|
|
241
|
+
\`\`\`
|
|
242
|
+
|
|
243
|
+
\u2705 **CORRECT workflow:**
|
|
244
|
+
\`\`\`
|
|
245
|
+
1. search_services({ query: "weather" }) \u2190 Get schema
|
|
246
|
+
2. weather_get_forecast({ latitude: 29.76, longitude: -95.37 }) \u2190 ACTUALLY CALL IT
|
|
247
|
+
3. Observe response: { temp: 72, conditions: "sunny", ... }
|
|
248
|
+
4. Generate widget that calls weather.get_forecast at runtime
|
|
249
|
+
\`\`\`
|
|
250
|
+
|
|
251
|
+
**The service tool (e.g., \`weather_get_forecast\`, \`github_list_repos\`) is a DIFFERENT tool from \`search_services\`.** You have access to both. Use both.
|
|
252
|
+
|
|
253
|
+
**Only after a successful test call to the actual service should you generate the widget.**
|
|
254
|
+
|
|
255
|
+
### Component Parameterization (IMPORTANT)
|
|
256
|
+
|
|
257
|
+
**Widgets should accept props for dynamic values instead of hardcoding:**
|
|
258
|
+
|
|
259
|
+
\u274C **WRONG** - Hardcoded values:
|
|
260
|
+
\`\`\`tsx path="components/weather/bad-example.tsx"
|
|
261
|
+
export default function WeatherWidget() {
|
|
262
|
+
// Location hardcoded - BAD!
|
|
263
|
+
const [lat, lon] = [48.8566, 2.3522]; // Paris
|
|
264
|
+
// ...
|
|
265
|
+
}
|
|
266
|
+
\`\`\`
|
|
267
|
+
|
|
268
|
+
\u2705 **CORRECT** - Parameterized with props and defaults:
|
|
269
|
+
\`\`\`tsx note="Parameterized weather widget" path="components/weather/main.tsx"
|
|
270
|
+
interface WeatherWidgetProps {
|
|
271
|
+
location?: string; // e.g., "Paris, France"
|
|
272
|
+
latitude?: number; // Direct coordinates (optional)
|
|
273
|
+
longitude?: number;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export default function WeatherWidget({
|
|
277
|
+
location = "Paris, France",
|
|
278
|
+
latitude,
|
|
279
|
+
longitude
|
|
280
|
+
}: WeatherWidgetProps) {
|
|
281
|
+
// Use provided coordinates or look up from location name
|
|
282
|
+
// ...
|
|
283
|
+
}
|
|
284
|
+
\`\`\`
|
|
285
|
+
|
|
286
|
+
**Why parameterize:**
|
|
287
|
+
- Components become **reusable** across different contexts
|
|
288
|
+
- Users can **customize behavior** without editing code
|
|
289
|
+
- Enables **composition** - parent components can pass different values
|
|
290
|
+
- Supports **testing** with various inputs
|
|
291
|
+
|
|
292
|
+
**What to parameterize:**
|
|
293
|
+
- Location names, coordinates, IDs
|
|
294
|
+
- Search queries and filters
|
|
295
|
+
- Display options (count, format, theme)
|
|
296
|
+
- API-specific identifiers (usernames, repo names, etc.)
|
|
297
|
+
|
|
298
|
+
### Anti-patterns to Avoid
|
|
299
|
+
- \u274C Bulleted or numbered lists of key-value pairs
|
|
300
|
+
- \u274C Vertical stacks where horizontal layouts would fit
|
|
301
|
+
- \u274C Plain text labels without visual treatment
|
|
302
|
+
- \u274C Uniform styling that doesn't distinguish primary from secondary information
|
|
303
|
+
- \u274C Wrapping components in centering containers (parent handles this)
|
|
304
|
+
- \u274C **Embedding API response data directly in components instead of fetching at runtime**
|
|
305
|
+
- \u274C **Calling a tool, then putting the response as static JSX/JSON in the generated code**
|
|
306
|
+
- \u274C **Hardcoding values that should be component props**
|
|
307
|
+
- \u274C **Calling \`search_services\` multiple times instead of calling the actual service tool**
|
|
308
|
+
- \u274C **Generating a widget without first making a real call to the service with your intended arguments**
|
|
309
|
+
- \u274C **Treating schema documentation as proof that a service call will work**
|
|
310
|
+
- \u274C **Omitting the \`path\` attribute on code blocks**
|
|
311
|
+
`;
|
|
312
|
+
var EDIT_PROMPT = `
|
|
313
|
+
You are editing an existing JSX component. The user will provide the current code and describe the changes they want.
|
|
314
|
+
|
|
315
|
+
## Response Format
|
|
316
|
+
|
|
317
|
+
Use code fences with tagged attributes. The \`note\` attribute (optional but encouraged) provides a brief description visible in the UI. The \`path\` attribute specifies the target file.
|
|
318
|
+
|
|
319
|
+
\`\`\`diff note="Brief description of this change" path="@/components/Button.tsx"
|
|
320
|
+
<<<<<<< SEARCH
|
|
321
|
+
exact code to find
|
|
322
|
+
=======
|
|
323
|
+
replacement code
|
|
324
|
+
>>>>>>> REPLACE
|
|
325
|
+
\`\`\`
|
|
326
|
+
|
|
327
|
+
### Attribute Order
|
|
328
|
+
Put \`note\` first so it's available soonest in streaming UI.
|
|
329
|
+
|
|
330
|
+
### Multi-File Edits
|
|
331
|
+
When editing multiple files, use the \`path\` attribute with virtual paths (\`@/\` prefix for generated files):
|
|
332
|
+
|
|
333
|
+
\`\`\`diff note="Update button handler" path="@/components/Button.tsx"
|
|
334
|
+
<<<<<<< SEARCH
|
|
335
|
+
onClick={() => {}}
|
|
336
|
+
=======
|
|
337
|
+
onClick={() => handleClick()}
|
|
338
|
+
>>>>>>> REPLACE
|
|
339
|
+
\`\`\`
|
|
340
|
+
|
|
341
|
+
\`\`\`diff note="Add utility function" path="@/lib/utils.ts"
|
|
342
|
+
<<<<<<< SEARCH
|
|
343
|
+
export const formatDate = ...
|
|
344
|
+
=======
|
|
345
|
+
export const formatDate = ...
|
|
346
|
+
|
|
347
|
+
export const handleClick = () => console.log('clicked');
|
|
348
|
+
>>>>>>> REPLACE
|
|
349
|
+
\`\`\`
|
|
350
|
+
|
|
351
|
+
## Rules
|
|
352
|
+
- SEARCH block must match the existing code EXACTLY (whitespace, indentation, everything)
|
|
353
|
+
- You can include multiple diff blocks for multiple changes
|
|
354
|
+
- Each diff block should have its own \`note\` attribute annotation
|
|
355
|
+
- Keep changes minimal and targeted
|
|
356
|
+
- Do NOT output the full file - only the diffs
|
|
357
|
+
- If clarification is needed, ask briefly before any diffs
|
|
358
|
+
|
|
359
|
+
## CRITICAL: Diff Marker Safety
|
|
360
|
+
- NEVER include the strings "<<<<<<< SEARCH", "=======", or ">>>>>>> REPLACE" inside your replacement code
|
|
361
|
+
- These are reserved markers for parsing the diff format
|
|
362
|
+
- If you need to show diff-like content, use alternative notation (e.g., "// old code" / "// new code")
|
|
363
|
+
- Malformed diff markers will cause the edit to fail
|
|
364
|
+
|
|
365
|
+
## Summary
|
|
366
|
+
After all diffs, provide a brief markdown summary of the changes made. Use formatting like:
|
|
367
|
+
- **Bold** for emphasis on key changes
|
|
368
|
+
- Bullet points for listing multiple changes
|
|
369
|
+
- Keep it concise (2-4 lines max)
|
|
370
|
+
- Do NOT include: a heading/title
|
|
371
|
+
`;
|
|
372
|
+
|
|
373
|
+
// src/server/routes.ts
|
|
374
|
+
function parseBody(req) {
|
|
375
|
+
return new Promise((resolve2, reject) => {
|
|
376
|
+
let body = "";
|
|
377
|
+
req.on("data", (chunk) => body += chunk);
|
|
378
|
+
req.on("end", () => {
|
|
379
|
+
try {
|
|
380
|
+
resolve2(JSON.parse(body));
|
|
381
|
+
} catch (err) {
|
|
382
|
+
reject(err);
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
req.on("error", reject);
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
async function handleChat(req, res, ctx) {
|
|
389
|
+
const {
|
|
390
|
+
messages,
|
|
391
|
+
metadata
|
|
392
|
+
} = await parseBody(req);
|
|
393
|
+
const normalizedMessages = messages.map((msg) => ({
|
|
394
|
+
...msg,
|
|
395
|
+
parts: msg.parts ?? [{ type: "text", text: "" }]
|
|
396
|
+
}));
|
|
397
|
+
const provider = (0, import_openai_compatible.createOpenAICompatible)({
|
|
398
|
+
name: "copilot-proxy",
|
|
399
|
+
baseURL: ctx.copilotProxyUrl
|
|
400
|
+
});
|
|
401
|
+
const result = (0, import_ai.streamText)({
|
|
402
|
+
model: provider("claude-sonnet-4"),
|
|
403
|
+
system: `---
|
|
404
|
+
patchwork:
|
|
405
|
+
compilers: ${(metadata?.patchwork?.compilers ?? []).join(",") ?? "[]"}
|
|
406
|
+
services: ${ctx.registry.getNamespaces().join(",")}
|
|
407
|
+
---
|
|
408
|
+
|
|
409
|
+
${PATCHWORK_PROMPT}
|
|
410
|
+
|
|
411
|
+
${ctx.servicesPrompt}`,
|
|
412
|
+
messages: await (0, import_ai.convertToModelMessages)(normalizedMessages),
|
|
413
|
+
stopWhen: (0, import_ai.stepCountIs)(5),
|
|
414
|
+
tools: ctx.tools
|
|
415
|
+
});
|
|
416
|
+
const response = result.toUIMessageStreamResponse();
|
|
417
|
+
response.headers.forEach(
|
|
418
|
+
(value, key) => res.setHeader(key, value)
|
|
419
|
+
);
|
|
420
|
+
if (!response.body) {
|
|
421
|
+
res.end();
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
const reader = response.body.getReader();
|
|
425
|
+
const pump = async () => {
|
|
426
|
+
const { done, value } = await reader.read();
|
|
427
|
+
if (done) {
|
|
428
|
+
res.end();
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
res.write(value);
|
|
432
|
+
await pump();
|
|
433
|
+
};
|
|
434
|
+
await pump();
|
|
435
|
+
}
|
|
436
|
+
async function handleEdit(req, res, ctx) {
|
|
437
|
+
const { code, prompt } = await parseBody(
|
|
438
|
+
req
|
|
439
|
+
);
|
|
440
|
+
const provider = (0, import_openai_compatible.createOpenAICompatible)({
|
|
441
|
+
name: "copilot-proxy",
|
|
442
|
+
baseURL: ctx.copilotProxyUrl
|
|
443
|
+
});
|
|
444
|
+
const result = (0, import_ai.streamText)({
|
|
445
|
+
model: provider("claude-opus-4.5"),
|
|
446
|
+
system: `Current component code:
|
|
447
|
+
\`\`\`tsx
|
|
448
|
+
${code}
|
|
449
|
+
\`\`\`
|
|
450
|
+
|
|
451
|
+
${EDIT_PROMPT}`,
|
|
452
|
+
messages: [{ role: "user", content: prompt }]
|
|
453
|
+
});
|
|
454
|
+
res.setHeader("Content-Type", "text/plain");
|
|
455
|
+
res.setHeader("Transfer-Encoding", "chunked");
|
|
456
|
+
res.writeHead(200);
|
|
457
|
+
for await (const chunk of result.textStream) {
|
|
458
|
+
res.write(chunk);
|
|
459
|
+
}
|
|
460
|
+
res.end();
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
// src/server/local-packages.ts
|
|
464
|
+
var import_fs = __toESM(require("fs"), 1);
|
|
465
|
+
var import_path = __toESM(require("path"), 1);
|
|
466
|
+
function handleLocalPackages(req, res, ctx) {
|
|
467
|
+
const rawUrl = req.url || "";
|
|
468
|
+
if (!rawUrl.startsWith("/_local-packages")) {
|
|
469
|
+
return false;
|
|
470
|
+
}
|
|
471
|
+
const urlWithoutPrefix = rawUrl.replace("/_local-packages", "");
|
|
472
|
+
const url = urlWithoutPrefix.split("?")[0] || "";
|
|
473
|
+
const match = url.match(/^\/@([^/]+)\/([^/@]+)(.*)$/);
|
|
474
|
+
if (!match) {
|
|
475
|
+
return false;
|
|
476
|
+
}
|
|
477
|
+
const [, scope, name, restPath] = match;
|
|
478
|
+
const packageName = `@${scope}/${name}`;
|
|
479
|
+
const localPath = ctx.localPackages[packageName];
|
|
480
|
+
if (!localPath) {
|
|
481
|
+
res.writeHead(404);
|
|
482
|
+
res.end(`Package ${packageName} not found in local overrides`);
|
|
483
|
+
return true;
|
|
484
|
+
}
|
|
485
|
+
const rest = restPath || "";
|
|
486
|
+
let filePath;
|
|
487
|
+
try {
|
|
488
|
+
if (rest === "/package.json") {
|
|
489
|
+
filePath = import_path.default.join(localPath, "package.json");
|
|
490
|
+
} else if (rest === "" || rest === "/") {
|
|
491
|
+
const pkgJson = JSON.parse(
|
|
492
|
+
import_fs.default.readFileSync(import_path.default.join(localPath, "package.json"), "utf-8")
|
|
493
|
+
);
|
|
494
|
+
const mainEntry = pkgJson.main || "dist/index.js";
|
|
495
|
+
filePath = import_path.default.join(localPath, mainEntry);
|
|
496
|
+
} else {
|
|
497
|
+
const normalizedPath = rest.startsWith("/") ? rest.slice(1) : rest;
|
|
498
|
+
const distPath = import_path.default.join(localPath, "dist", normalizedPath);
|
|
499
|
+
const rootPath = import_path.default.join(localPath, normalizedPath);
|
|
500
|
+
filePath = import_fs.default.existsSync(distPath) ? distPath : rootPath;
|
|
501
|
+
}
|
|
502
|
+
} catch (err) {
|
|
503
|
+
ctx.log("Error resolving file path:", err);
|
|
504
|
+
res.writeHead(500);
|
|
505
|
+
res.end(`Error resolving path for ${packageName}: ${err}`);
|
|
506
|
+
return true;
|
|
507
|
+
}
|
|
508
|
+
try {
|
|
509
|
+
ctx.log(`Serving ${filePath}`);
|
|
510
|
+
const content = import_fs.default.readFileSync(filePath, "utf-8");
|
|
511
|
+
const ext = import_path.default.extname(filePath);
|
|
512
|
+
const contentType = ext === ".json" ? "application/json" : ext === ".js" ? "application/javascript" : ext === ".ts" ? "application/typescript" : "text/plain";
|
|
513
|
+
res.setHeader("Content-Type", contentType);
|
|
514
|
+
res.writeHead(200);
|
|
515
|
+
res.end(content);
|
|
516
|
+
} catch (err) {
|
|
517
|
+
ctx.log("Error serving file:", filePath, err);
|
|
518
|
+
res.writeHead(404);
|
|
519
|
+
res.end(`File not found: ${filePath}`);
|
|
520
|
+
}
|
|
521
|
+
return true;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
// src/server/vfs-routes.ts
|
|
525
|
+
var import_promises = require("fs/promises");
|
|
526
|
+
var import_node_fs = require("fs");
|
|
527
|
+
var import_node_path = require("path");
|
|
528
|
+
function normalizeRelPath(path2) {
|
|
529
|
+
const decoded = decodeURIComponent(path2).replace(/\\/g, "/");
|
|
530
|
+
return decoded.replace(/^\/+|\/+$/g, "");
|
|
531
|
+
}
|
|
532
|
+
function resolvePath(rootDir, relPath) {
|
|
533
|
+
const root = (0, import_node_path.resolve)(rootDir);
|
|
534
|
+
const full = (0, import_node_path.resolve)(root, relPath);
|
|
535
|
+
if (full !== root && !full.startsWith(`${root}${import_node_path.sep}`)) {
|
|
536
|
+
throw new Error("Invalid path");
|
|
537
|
+
}
|
|
538
|
+
return full;
|
|
539
|
+
}
|
|
540
|
+
function joinRelPath(base, name) {
|
|
541
|
+
return base ? `${base}/${name}` : name;
|
|
542
|
+
}
|
|
543
|
+
async function listAllFiles(rootDir, relPath) {
|
|
544
|
+
const targetPath = resolvePath(rootDir, relPath);
|
|
545
|
+
let entries = [];
|
|
546
|
+
try {
|
|
547
|
+
entries = await (0, import_promises.readdir)(targetPath, { withFileTypes: true });
|
|
548
|
+
} catch {
|
|
549
|
+
return [];
|
|
550
|
+
}
|
|
551
|
+
const results = [];
|
|
552
|
+
for (const entry of entries) {
|
|
553
|
+
const entryRelPath = joinRelPath(relPath, entry.name);
|
|
554
|
+
if (entry.isDirectory()) {
|
|
555
|
+
results.push(...await listAllFiles(rootDir, entryRelPath));
|
|
556
|
+
} else {
|
|
557
|
+
results.push(entryRelPath);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
return results.sort((a, b) => a.localeCompare(b));
|
|
561
|
+
}
|
|
562
|
+
async function ensureDir(filePath) {
|
|
563
|
+
await (0, import_promises.mkdir)((0, import_node_path.dirname)(filePath), { recursive: true });
|
|
564
|
+
}
|
|
565
|
+
function sendJson(res, status, body) {
|
|
566
|
+
res.setHeader("Content-Type", "application/json");
|
|
567
|
+
res.writeHead(status);
|
|
568
|
+
res.end(JSON.stringify(body));
|
|
569
|
+
}
|
|
570
|
+
function handleVFS(req, res, ctx) {
|
|
571
|
+
const url = req.url || "/";
|
|
572
|
+
const method = req.method || "GET";
|
|
573
|
+
if (!url.startsWith("/vfs")) return false;
|
|
574
|
+
if (url === "/vfs/config" && method === "GET") {
|
|
575
|
+
res.setHeader("Content-Type", "application/json");
|
|
576
|
+
res.writeHead(200);
|
|
577
|
+
res.end(JSON.stringify({ usePaths: ctx.usePaths }));
|
|
578
|
+
return true;
|
|
579
|
+
}
|
|
580
|
+
const handleRequest = async () => {
|
|
581
|
+
const urlObj = new URL(url, "http://localhost");
|
|
582
|
+
const query = urlObj.searchParams;
|
|
583
|
+
const rawPath = urlObj.pathname.slice(4);
|
|
584
|
+
const relPath = normalizeRelPath(rawPath);
|
|
585
|
+
if (query.has("watch")) {
|
|
586
|
+
if (method !== "GET") {
|
|
587
|
+
res.writeHead(405);
|
|
588
|
+
res.end("Method not allowed");
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
591
|
+
const watchPath = normalizeRelPath(query.get("watch") || "");
|
|
592
|
+
const fullWatchPath = resolvePath(ctx.rootDir, watchPath);
|
|
593
|
+
let watchStats;
|
|
594
|
+
try {
|
|
595
|
+
watchStats = await (0, import_promises.stat)(fullWatchPath);
|
|
596
|
+
} catch {
|
|
597
|
+
res.writeHead(404);
|
|
598
|
+
res.end("Not found");
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
res.setHeader("Content-Type", "text/event-stream");
|
|
602
|
+
res.setHeader("Cache-Control", "no-cache");
|
|
603
|
+
res.setHeader("Connection", "keep-alive");
|
|
604
|
+
res.writeHead(200);
|
|
605
|
+
const watcher = (0, import_node_fs.watch)(
|
|
606
|
+
fullWatchPath,
|
|
607
|
+
{ recursive: watchStats.isDirectory() },
|
|
608
|
+
async (eventType, filename) => {
|
|
609
|
+
const eventPath = normalizeRelPath(
|
|
610
|
+
[watchPath, filename ? filename.toString() : ""].filter(Boolean).join("/")
|
|
611
|
+
);
|
|
612
|
+
const fullEventPath = resolvePath(ctx.rootDir, eventPath);
|
|
613
|
+
let type = "update";
|
|
614
|
+
if (eventType === "rename") {
|
|
615
|
+
try {
|
|
616
|
+
await (0, import_promises.stat)(fullEventPath);
|
|
617
|
+
type = "create";
|
|
618
|
+
} catch {
|
|
619
|
+
type = "delete";
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
res.write("event: change\n");
|
|
623
|
+
res.write(
|
|
624
|
+
`data: ${JSON.stringify({
|
|
625
|
+
type,
|
|
626
|
+
path: eventPath,
|
|
627
|
+
mtime: (/* @__PURE__ */ new Date()).toISOString()
|
|
628
|
+
})}
|
|
629
|
+
|
|
630
|
+
`
|
|
631
|
+
);
|
|
632
|
+
}
|
|
633
|
+
);
|
|
634
|
+
req.on("close", () => watcher.close());
|
|
635
|
+
return;
|
|
636
|
+
}
|
|
637
|
+
if (method === "HEAD" && !relPath) {
|
|
638
|
+
res.writeHead(200);
|
|
639
|
+
res.end();
|
|
640
|
+
return;
|
|
641
|
+
}
|
|
642
|
+
if (method === "GET" && !relPath && !query.toString()) {
|
|
643
|
+
const files = await listAllFiles(ctx.rootDir, "");
|
|
644
|
+
sendJson(res, 200, files);
|
|
645
|
+
return;
|
|
646
|
+
}
|
|
647
|
+
if (!relPath && method !== "GET" && method !== "HEAD") {
|
|
648
|
+
res.writeHead(400);
|
|
649
|
+
res.end("Invalid path");
|
|
650
|
+
return;
|
|
651
|
+
}
|
|
652
|
+
const targetPath = resolvePath(ctx.rootDir, relPath);
|
|
653
|
+
if (method === "GET" && query.get("stat") === "true") {
|
|
654
|
+
try {
|
|
655
|
+
const stats = await (0, import_promises.stat)(targetPath);
|
|
656
|
+
sendJson(res, 200, {
|
|
657
|
+
size: stats.size,
|
|
658
|
+
mtime: stats.mtime.toISOString(),
|
|
659
|
+
isFile: stats.isFile(),
|
|
660
|
+
isDirectory: stats.isDirectory()
|
|
661
|
+
});
|
|
662
|
+
} catch {
|
|
663
|
+
res.writeHead(404);
|
|
664
|
+
res.end("Not found");
|
|
665
|
+
}
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
668
|
+
if (method === "GET" && query.get("readdir") === "true") {
|
|
669
|
+
try {
|
|
670
|
+
const entries = await (0, import_promises.readdir)(targetPath, { withFileTypes: true });
|
|
671
|
+
const mapped = entries.map((entry) => ({
|
|
672
|
+
name: entry.name,
|
|
673
|
+
isDirectory: entry.isDirectory()
|
|
674
|
+
})).sort((a, b) => a.name.localeCompare(b.name));
|
|
675
|
+
sendJson(res, 200, mapped);
|
|
676
|
+
} catch (err) {
|
|
677
|
+
const code = err.code;
|
|
678
|
+
if (code === "ENOTDIR") {
|
|
679
|
+
res.writeHead(409);
|
|
680
|
+
res.end("Not a directory");
|
|
681
|
+
return;
|
|
682
|
+
}
|
|
683
|
+
res.writeHead(404);
|
|
684
|
+
res.end("Not found");
|
|
685
|
+
}
|
|
686
|
+
return;
|
|
687
|
+
}
|
|
688
|
+
if (method === "POST" && query.get("mkdir") === "true") {
|
|
689
|
+
const recursive = query.get("recursive") === "true";
|
|
690
|
+
try {
|
|
691
|
+
await (0, import_promises.mkdir)(targetPath, { recursive });
|
|
692
|
+
res.writeHead(200);
|
|
693
|
+
res.end("ok");
|
|
694
|
+
} catch {
|
|
695
|
+
res.writeHead(500);
|
|
696
|
+
res.end("Mkdir failed");
|
|
697
|
+
}
|
|
698
|
+
return;
|
|
699
|
+
}
|
|
700
|
+
switch (method) {
|
|
701
|
+
case "GET": {
|
|
702
|
+
try {
|
|
703
|
+
const content = await (0, import_promises.readFile)(targetPath, "utf-8");
|
|
704
|
+
res.setHeader("Content-Type", "text/plain");
|
|
705
|
+
res.writeHead(200);
|
|
706
|
+
res.end(content);
|
|
707
|
+
} catch {
|
|
708
|
+
res.writeHead(404);
|
|
709
|
+
res.end("Not found");
|
|
710
|
+
}
|
|
711
|
+
return;
|
|
712
|
+
}
|
|
713
|
+
case "PUT": {
|
|
714
|
+
let body = "";
|
|
715
|
+
req.on("data", (chunk) => body += chunk);
|
|
716
|
+
req.on("end", async () => {
|
|
717
|
+
try {
|
|
718
|
+
await ensureDir(targetPath);
|
|
719
|
+
await (0, import_promises.writeFile)(targetPath, body, "utf-8");
|
|
720
|
+
res.writeHead(200);
|
|
721
|
+
res.end("ok");
|
|
722
|
+
} catch (err) {
|
|
723
|
+
ctx.log("VFS PUT error:", err);
|
|
724
|
+
res.writeHead(500);
|
|
725
|
+
res.end("Write failed");
|
|
726
|
+
}
|
|
727
|
+
});
|
|
728
|
+
return;
|
|
729
|
+
}
|
|
730
|
+
case "DELETE": {
|
|
731
|
+
const recursive = query.get("recursive") === "true";
|
|
732
|
+
let stats;
|
|
733
|
+
try {
|
|
734
|
+
stats = await (0, import_promises.stat)(targetPath);
|
|
735
|
+
} catch {
|
|
736
|
+
res.writeHead(404);
|
|
737
|
+
res.end("Not found");
|
|
738
|
+
return;
|
|
739
|
+
}
|
|
740
|
+
if (stats.isDirectory()) {
|
|
741
|
+
if (!recursive) {
|
|
742
|
+
try {
|
|
743
|
+
const entries = await (0, import_promises.readdir)(targetPath);
|
|
744
|
+
if (entries.length > 0) {
|
|
745
|
+
res.writeHead(409);
|
|
746
|
+
res.end("Directory not empty");
|
|
747
|
+
return;
|
|
748
|
+
}
|
|
749
|
+
await (0, import_promises.rm)(targetPath, { recursive: false });
|
|
750
|
+
res.writeHead(200);
|
|
751
|
+
res.end("ok");
|
|
752
|
+
} catch {
|
|
753
|
+
res.writeHead(500);
|
|
754
|
+
res.end("Delete failed");
|
|
755
|
+
}
|
|
756
|
+
return;
|
|
757
|
+
}
|
|
758
|
+
try {
|
|
759
|
+
await (0, import_promises.rm)(targetPath, { recursive: true });
|
|
760
|
+
res.writeHead(200);
|
|
761
|
+
res.end("ok");
|
|
762
|
+
} catch {
|
|
763
|
+
res.writeHead(500);
|
|
764
|
+
res.end("Delete failed");
|
|
765
|
+
}
|
|
766
|
+
return;
|
|
767
|
+
}
|
|
768
|
+
try {
|
|
769
|
+
await (0, import_promises.unlink)(targetPath);
|
|
770
|
+
res.writeHead(200);
|
|
771
|
+
res.end("ok");
|
|
772
|
+
} catch {
|
|
773
|
+
res.writeHead(404);
|
|
774
|
+
res.end("Not found");
|
|
775
|
+
}
|
|
776
|
+
return;
|
|
777
|
+
}
|
|
778
|
+
case "HEAD": {
|
|
779
|
+
try {
|
|
780
|
+
await (0, import_promises.stat)(targetPath);
|
|
781
|
+
res.writeHead(200);
|
|
782
|
+
res.end();
|
|
783
|
+
} catch {
|
|
784
|
+
res.writeHead(404);
|
|
785
|
+
res.end();
|
|
786
|
+
}
|
|
787
|
+
return;
|
|
788
|
+
}
|
|
789
|
+
default:
|
|
790
|
+
res.writeHead(405);
|
|
791
|
+
res.end("Method not allowed");
|
|
792
|
+
}
|
|
793
|
+
};
|
|
794
|
+
handleRequest().catch((err) => {
|
|
795
|
+
ctx.log("VFS error:", err);
|
|
796
|
+
res.writeHead(500);
|
|
797
|
+
res.end("Internal error");
|
|
798
|
+
});
|
|
799
|
+
return true;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
// src/server/services.ts
|
|
803
|
+
var import_ai2 = require("ai");
|
|
804
|
+
var ServiceRegistry = class {
|
|
805
|
+
tools = /* @__PURE__ */ new Map();
|
|
806
|
+
toolInfo = /* @__PURE__ */ new Map();
|
|
807
|
+
backends = [];
|
|
808
|
+
/**
|
|
809
|
+
* Register tools from MCP or other sources
|
|
810
|
+
* @param tools - Record of tool name to Tool
|
|
811
|
+
* @param namespace - Optional namespace to prefix all tools (e.g., MCP server name)
|
|
812
|
+
*/
|
|
813
|
+
registerTools(tools, namespace) {
|
|
814
|
+
for (const [toolName, tool] of Object.entries(tools)) {
|
|
815
|
+
const name = namespace ? `${namespace}.${toolName}` : toolName;
|
|
816
|
+
this.tools.set(name, tool);
|
|
817
|
+
const dotIndex = name.indexOf(".");
|
|
818
|
+
const ns = dotIndex > 0 ? name.substring(0, dotIndex) : name;
|
|
819
|
+
const procedure = dotIndex > 0 ? name.substring(dotIndex + 1) : name;
|
|
820
|
+
this.toolInfo.set(name, {
|
|
821
|
+
name,
|
|
822
|
+
namespace: ns,
|
|
823
|
+
procedure,
|
|
824
|
+
description: tool.description,
|
|
825
|
+
parameters: tool.inputSchema ?? {},
|
|
826
|
+
typescriptInterface: this.generateTypeScriptInterface(name, tool)
|
|
827
|
+
});
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
/**
|
|
831
|
+
* Register a service backend (UTCP, HTTP, etc.)
|
|
832
|
+
* Creates callable Tool objects for each procedure so the LLM can invoke them directly.
|
|
833
|
+
* Backends are tried in order of registration, first success wins.
|
|
834
|
+
*/
|
|
835
|
+
registerBackend(backend, toolInfos) {
|
|
836
|
+
this.backends.push(backend);
|
|
837
|
+
if (toolInfos) {
|
|
838
|
+
for (const info of toolInfos) {
|
|
839
|
+
this.toolInfo.set(info.name, info);
|
|
840
|
+
const tool = {
|
|
841
|
+
description: info.description,
|
|
842
|
+
inputSchema: (0, import_ai2.jsonSchema)(
|
|
843
|
+
info.parameters ?? { type: "object", properties: {} }
|
|
844
|
+
),
|
|
845
|
+
execute: async (args) => {
|
|
846
|
+
return backend.call(info.namespace, info.procedure, [args]);
|
|
847
|
+
}
|
|
848
|
+
};
|
|
849
|
+
this.tools.set(info.name, tool);
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
/**
|
|
854
|
+
* Generate TypeScript interface from tool schema
|
|
855
|
+
*/
|
|
856
|
+
generateTypeScriptInterface(name, tool) {
|
|
857
|
+
const schema = tool.inputSchema;
|
|
858
|
+
const props = schema?.properties ?? {};
|
|
859
|
+
const required = schema?.required ?? [];
|
|
860
|
+
const params = Object.entries(props).map(([key, val]) => {
|
|
861
|
+
const optional = !required.includes(key) ? "?" : "";
|
|
862
|
+
const type = val.type === "number" ? "number" : val.type === "boolean" ? "boolean" : val.type === "array" ? "unknown[]" : val.type === "object" ? "Record<string, unknown>" : "string";
|
|
863
|
+
const comment = val.description ? ` // ${val.description}` : "";
|
|
864
|
+
return ` ${key}${optional}: ${type};${comment}`;
|
|
865
|
+
}).join("\n");
|
|
866
|
+
return `interface ${name.replace(
|
|
867
|
+
/[^a-zA-Z0-9]/g,
|
|
868
|
+
"_"
|
|
869
|
+
)}Args {
|
|
870
|
+
${params}
|
|
871
|
+
}`;
|
|
872
|
+
}
|
|
873
|
+
/**
|
|
874
|
+
* Convert internal tool name (namespace.procedure) to LLM-safe name (namespace_procedure)
|
|
875
|
+
* OpenAI-compatible APIs require tool names to match ^[a-zA-Z0-9_-]+$
|
|
876
|
+
*/
|
|
877
|
+
toLLMToolName(internalName) {
|
|
878
|
+
return internalName.replace(/\./g, "_");
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
* Convert LLM tool name (namespace_procedure) back to internal name (namespace.procedure)
|
|
882
|
+
* Only converts the first underscore after the namespace prefix
|
|
883
|
+
*/
|
|
884
|
+
fromLLMToolName(llmName) {
|
|
885
|
+
for (const internalName of this.tools.keys()) {
|
|
886
|
+
if (this.toLLMToolName(internalName) === llmName) {
|
|
887
|
+
return internalName;
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
const underscoreIndex = llmName.indexOf("_");
|
|
891
|
+
if (underscoreIndex > 0) {
|
|
892
|
+
return llmName.substring(0, underscoreIndex) + "." + llmName.substring(underscoreIndex + 1);
|
|
893
|
+
}
|
|
894
|
+
return llmName;
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* Get all tools for LLM usage with LLM-safe names (underscores instead of dots)
|
|
898
|
+
*/
|
|
899
|
+
getTools() {
|
|
900
|
+
const result = {};
|
|
901
|
+
for (const [name, tool] of this.tools) {
|
|
902
|
+
result[this.toLLMToolName(name)] = tool;
|
|
903
|
+
}
|
|
904
|
+
return result;
|
|
905
|
+
}
|
|
906
|
+
/**
|
|
907
|
+
* Get service metadata for prompt generation
|
|
908
|
+
*/
|
|
909
|
+
getServiceInfo() {
|
|
910
|
+
return Array.from(this.toolInfo.values());
|
|
911
|
+
}
|
|
912
|
+
/**
|
|
913
|
+
* Get unique namespaces
|
|
914
|
+
*/
|
|
915
|
+
getNamespaces() {
|
|
916
|
+
const namespaces = /* @__PURE__ */ new Set();
|
|
917
|
+
for (const info of this.toolInfo.values()) {
|
|
918
|
+
namespaces.add(info.namespace);
|
|
919
|
+
}
|
|
920
|
+
return Array.from(namespaces);
|
|
921
|
+
}
|
|
922
|
+
/**
|
|
923
|
+
* Search for services by query, namespace, or list all
|
|
924
|
+
*/
|
|
925
|
+
searchServices(options = {}) {
|
|
926
|
+
const { query, namespace, limit = 20, includeInterfaces = false } = options;
|
|
927
|
+
let results = Array.from(this.toolInfo.values());
|
|
928
|
+
if (namespace) {
|
|
929
|
+
results = results.filter((info) => info.namespace === namespace);
|
|
930
|
+
}
|
|
931
|
+
if (query) {
|
|
932
|
+
const queryLower = query.toLowerCase();
|
|
933
|
+
const keywords = queryLower.split(/\s+/).filter(Boolean);
|
|
934
|
+
results = results.map((info) => {
|
|
935
|
+
const searchText = `${info.name} ${info.namespace} ${info.procedure} ${info.description ?? ""}`.toLowerCase();
|
|
936
|
+
const matchCount = keywords.filter(
|
|
937
|
+
(kw) => searchText.includes(kw)
|
|
938
|
+
).length;
|
|
939
|
+
return { info, score: matchCount / keywords.length };
|
|
940
|
+
}).filter(({ score }) => score > 0).sort((a, b) => b.score - a.score).map(({ info }) => info);
|
|
941
|
+
}
|
|
942
|
+
results = results.slice(0, limit);
|
|
943
|
+
if (!includeInterfaces) {
|
|
944
|
+
results = results.map(({ typescriptInterface: _, ...rest }) => rest);
|
|
945
|
+
}
|
|
946
|
+
return results;
|
|
947
|
+
}
|
|
948
|
+
/**
|
|
949
|
+
* Get detailed info about a specific tool
|
|
950
|
+
*/
|
|
951
|
+
getToolInfo(toolName) {
|
|
952
|
+
return this.toolInfo.get(toolName);
|
|
953
|
+
}
|
|
954
|
+
/**
|
|
955
|
+
* List all tool names
|
|
956
|
+
*/
|
|
957
|
+
listToolNames() {
|
|
958
|
+
return Array.from(this.toolInfo.keys());
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
* Call a service procedure
|
|
962
|
+
*/
|
|
963
|
+
async call(namespace, procedure, args) {
|
|
964
|
+
for (const backend of this.backends) {
|
|
965
|
+
try {
|
|
966
|
+
return await backend.call(namespace, procedure, [args]);
|
|
967
|
+
} catch {
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
const exactKey = `${namespace}.${procedure}`;
|
|
971
|
+
let tool = this.tools.get(exactKey);
|
|
972
|
+
if (!tool) {
|
|
973
|
+
for (const [name, t] of this.tools) {
|
|
974
|
+
if (name.startsWith(`${namespace}.`) && name.endsWith(procedure)) {
|
|
975
|
+
tool = t;
|
|
976
|
+
break;
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
if (!tool) {
|
|
981
|
+
throw new Error(
|
|
982
|
+
`Service not found: ${namespace}.${procedure}. Available: ${Array.from(
|
|
983
|
+
this.tools.keys()
|
|
984
|
+
).slice(0, 10).join(", ")}`
|
|
985
|
+
);
|
|
986
|
+
}
|
|
987
|
+
if (!tool.execute) {
|
|
988
|
+
throw new Error(`Tool ${namespace}.${procedure} has no execute function`);
|
|
989
|
+
}
|
|
990
|
+
const result = await tool.execute(args, {
|
|
991
|
+
toolCallId: `${Date.now()}-${Math.random().toString(36).slice(2)}`,
|
|
992
|
+
messages: []
|
|
993
|
+
});
|
|
994
|
+
return result;
|
|
995
|
+
}
|
|
996
|
+
/**
|
|
997
|
+
* Check if a service exists
|
|
998
|
+
*/
|
|
999
|
+
has(namespace, procedure) {
|
|
1000
|
+
const key = `${namespace}.${procedure}`;
|
|
1001
|
+
return this.tools.has(key);
|
|
1002
|
+
}
|
|
1003
|
+
/**
|
|
1004
|
+
* Get count of registered tools
|
|
1005
|
+
*/
|
|
1006
|
+
get size() {
|
|
1007
|
+
return this.toolInfo.size;
|
|
1008
|
+
}
|
|
1009
|
+
};
|
|
1010
|
+
function generateServicesPrompt(registry) {
|
|
1011
|
+
const namespaces = registry.getNamespaces();
|
|
1012
|
+
if (namespaces.length === 0) return "";
|
|
1013
|
+
const services = registry.getServiceInfo();
|
|
1014
|
+
const byNamespace = /* @__PURE__ */ new Map();
|
|
1015
|
+
for (const service of services) {
|
|
1016
|
+
const existing = byNamespace.get(service.namespace) || [];
|
|
1017
|
+
existing.push(service);
|
|
1018
|
+
byNamespace.set(service.namespace, existing);
|
|
1019
|
+
}
|
|
1020
|
+
let prompt = `## Available Services
|
|
1021
|
+
|
|
1022
|
+
The following services are available for generated widgets to call:
|
|
1023
|
+
|
|
1024
|
+
`;
|
|
1025
|
+
for (const [ns, tools] of byNamespace) {
|
|
1026
|
+
prompt += `### \`${ns}\`
|
|
1027
|
+
`;
|
|
1028
|
+
for (const tool of tools) {
|
|
1029
|
+
prompt += `- \`${ns}.${tool.procedure}()\``;
|
|
1030
|
+
if (tool.description) {
|
|
1031
|
+
prompt += `: ${tool.description}`;
|
|
1032
|
+
}
|
|
1033
|
+
prompt += "\n";
|
|
1034
|
+
}
|
|
1035
|
+
prompt += "\n";
|
|
1036
|
+
}
|
|
1037
|
+
prompt += `**Usage in widgets:**
|
|
1038
|
+
\`\`\`tsx
|
|
1039
|
+
// Services are available as global namespaces
|
|
1040
|
+
const result = await ${namespaces[0] ?? "service"}.${byNamespace.get(namespaces[0] ?? "")?.[0]?.procedure ?? "example"}({ /* args */ });
|
|
1041
|
+
\`\`\`
|
|
1042
|
+
|
|
1043
|
+
Make sure to handle loading states and errors when calling services.
|
|
1044
|
+
`;
|
|
1045
|
+
return prompt;
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
// src/server/index.ts
|
|
1049
|
+
async function initMcpTools(configs, registry) {
|
|
1050
|
+
for (const config of configs) {
|
|
1051
|
+
const client = await (0, import_mcp.createMCPClient)({
|
|
1052
|
+
transport: new import_mcp_stdio.Experimental_StdioMCPTransport({
|
|
1053
|
+
command: config.command,
|
|
1054
|
+
args: config.args
|
|
1055
|
+
})
|
|
1056
|
+
});
|
|
1057
|
+
registry.registerTools(await client.tools(), config.name);
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
var searchServicesSchema = {
|
|
1061
|
+
type: "object",
|
|
1062
|
+
properties: {
|
|
1063
|
+
query: {
|
|
1064
|
+
type: "string",
|
|
1065
|
+
description: 'Natural language description of what you want to do (e.g., "get weather forecast", "list github repos")'
|
|
1066
|
+
},
|
|
1067
|
+
namespace: {
|
|
1068
|
+
type: "string",
|
|
1069
|
+
description: 'Filter results to a specific service namespace (e.g., "weather", "github")'
|
|
1070
|
+
},
|
|
1071
|
+
tool_name: {
|
|
1072
|
+
type: "string",
|
|
1073
|
+
description: "Get detailed info about a specific tool by name"
|
|
1074
|
+
},
|
|
1075
|
+
limit: {
|
|
1076
|
+
type: "number",
|
|
1077
|
+
description: "Maximum number of results to return",
|
|
1078
|
+
default: 10
|
|
1079
|
+
},
|
|
1080
|
+
include_interfaces: {
|
|
1081
|
+
type: "boolean",
|
|
1082
|
+
description: "Include TypeScript interface definitions in results",
|
|
1083
|
+
default: true
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
};
|
|
1087
|
+
function createSearchServicesTool(registry) {
|
|
1088
|
+
return {
|
|
1089
|
+
description: `Search for available services/tools. Use this to discover what APIs are available for widgets to call.
|
|
1090
|
+
|
|
1091
|
+
Returns matching services with their TypeScript interfaces. Use when:
|
|
1092
|
+
- You need to find a service to accomplish a task
|
|
1093
|
+
- You want to explore available APIs in a namespace
|
|
1094
|
+
- You need the exact interface/parameters for a service call`,
|
|
1095
|
+
inputSchema: (0, import_ai3.jsonSchema)(searchServicesSchema),
|
|
1096
|
+
execute: async (args) => {
|
|
1097
|
+
if (args.tool_name) {
|
|
1098
|
+
const info = registry.getToolInfo(args.tool_name);
|
|
1099
|
+
if (!info) {
|
|
1100
|
+
return {
|
|
1101
|
+
success: false,
|
|
1102
|
+
error: `Tool '${args.tool_name}' not found`
|
|
1103
|
+
};
|
|
1104
|
+
}
|
|
1105
|
+
return { success: true, tool: info };
|
|
1106
|
+
}
|
|
1107
|
+
const results = registry.searchServices({
|
|
1108
|
+
query: args.query,
|
|
1109
|
+
namespace: args.namespace,
|
|
1110
|
+
limit: args.limit ?? 10,
|
|
1111
|
+
includeInterfaces: args.include_interfaces ?? true
|
|
1112
|
+
});
|
|
1113
|
+
return {
|
|
1114
|
+
success: true,
|
|
1115
|
+
count: results.length,
|
|
1116
|
+
tools: results,
|
|
1117
|
+
namespaces: registry.getNamespaces()
|
|
1118
|
+
};
|
|
1119
|
+
}
|
|
1120
|
+
};
|
|
1121
|
+
}
|
|
1122
|
+
function parseBody2(req) {
|
|
1123
|
+
return new Promise((resolve2, reject) => {
|
|
1124
|
+
let body = "";
|
|
1125
|
+
req.on("data", (chunk) => body += chunk);
|
|
1126
|
+
req.on("end", () => {
|
|
1127
|
+
try {
|
|
1128
|
+
resolve2(JSON.parse(body));
|
|
1129
|
+
} catch (err) {
|
|
1130
|
+
reject(err);
|
|
1131
|
+
}
|
|
1132
|
+
});
|
|
1133
|
+
req.on("error", reject);
|
|
1134
|
+
});
|
|
1135
|
+
}
|
|
1136
|
+
async function createStitcheryServer(config = {}) {
|
|
1137
|
+
const {
|
|
1138
|
+
port = 6434,
|
|
1139
|
+
host = "127.0.0.1",
|
|
1140
|
+
copilotProxyUrl = "http://127.0.0.1:6433/v1",
|
|
1141
|
+
localPackages = {},
|
|
1142
|
+
mcpServers = [],
|
|
1143
|
+
utcp,
|
|
1144
|
+
vfsDir,
|
|
1145
|
+
vfsUsePaths = false,
|
|
1146
|
+
verbose = false
|
|
1147
|
+
} = config;
|
|
1148
|
+
const log = verbose ? (...args) => console.log("[stitchery]", ...args) : () => {
|
|
1149
|
+
};
|
|
1150
|
+
const registry = new ServiceRegistry();
|
|
1151
|
+
log("Initializing MCP tools...");
|
|
1152
|
+
await initMcpTools(mcpServers, registry);
|
|
1153
|
+
log(`Loaded ${registry.size} tools from ${mcpServers.length} MCP servers`);
|
|
1154
|
+
if (utcp) {
|
|
1155
|
+
log("Initializing UTCP backend...");
|
|
1156
|
+
log("UTCP config:", JSON.stringify(utcp, null, 2));
|
|
1157
|
+
try {
|
|
1158
|
+
const { backend, toolInfos } = await (0, import_patchwork_utcp.createUtcpBackend)(
|
|
1159
|
+
utcp,
|
|
1160
|
+
utcp.cwd
|
|
1161
|
+
);
|
|
1162
|
+
registry.registerBackend(backend, toolInfos);
|
|
1163
|
+
log(
|
|
1164
|
+
`Registered UTCP backend with ${toolInfos.length} tools:`,
|
|
1165
|
+
toolInfos.map((tool) => tool.name).join(", ")
|
|
1166
|
+
);
|
|
1167
|
+
} catch (err) {
|
|
1168
|
+
console.error("[stitchery] Failed to initialize UTCP backend:", err);
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
log("Local packages:", localPackages);
|
|
1172
|
+
const internalTools = {
|
|
1173
|
+
search_services: createSearchServicesTool(registry)
|
|
1174
|
+
};
|
|
1175
|
+
const allTools = { ...registry.getTools(), ...internalTools };
|
|
1176
|
+
const routeCtx = {
|
|
1177
|
+
copilotProxyUrl,
|
|
1178
|
+
tools: allTools,
|
|
1179
|
+
registry,
|
|
1180
|
+
servicesPrompt: generateServicesPrompt(registry),
|
|
1181
|
+
log
|
|
1182
|
+
};
|
|
1183
|
+
const localPkgCtx = { localPackages, log };
|
|
1184
|
+
const vfsCtx = vfsDir ? { rootDir: vfsDir, usePaths: vfsUsePaths, log } : null;
|
|
1185
|
+
const server = (0, import_node_http.createServer)(async (req, res) => {
|
|
1186
|
+
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
1187
|
+
res.setHeader(
|
|
1188
|
+
"Access-Control-Allow-Methods",
|
|
1189
|
+
"GET, POST, PUT, DELETE, HEAD, OPTIONS"
|
|
1190
|
+
);
|
|
1191
|
+
res.setHeader(
|
|
1192
|
+
"Access-Control-Allow-Headers",
|
|
1193
|
+
"Content-Type, Authorization"
|
|
1194
|
+
);
|
|
1195
|
+
if (req.method === "OPTIONS") {
|
|
1196
|
+
res.writeHead(204);
|
|
1197
|
+
res.end();
|
|
1198
|
+
return;
|
|
1199
|
+
}
|
|
1200
|
+
const url = req.url || "/";
|
|
1201
|
+
log(`${req.method} ${url}`);
|
|
1202
|
+
try {
|
|
1203
|
+
if (handleLocalPackages(req, res, localPkgCtx)) {
|
|
1204
|
+
return;
|
|
1205
|
+
}
|
|
1206
|
+
if (vfsCtx && handleVFS(req, res, vfsCtx)) {
|
|
1207
|
+
return;
|
|
1208
|
+
}
|
|
1209
|
+
if (url === "/api/chat" && req.method === "POST") {
|
|
1210
|
+
await handleChat(req, res, routeCtx);
|
|
1211
|
+
return;
|
|
1212
|
+
}
|
|
1213
|
+
if (url === "/api/edit" && req.method === "POST") {
|
|
1214
|
+
await handleEdit(req, res, routeCtx);
|
|
1215
|
+
return;
|
|
1216
|
+
}
|
|
1217
|
+
const proxyMatch = url.match(/^\/api\/proxy\/([^/]+)\/(.+)$/);
|
|
1218
|
+
if (proxyMatch && req.method === "POST") {
|
|
1219
|
+
const [, namespace, procedure] = proxyMatch;
|
|
1220
|
+
try {
|
|
1221
|
+
const body = await parseBody2(req);
|
|
1222
|
+
const result = await registry.call(
|
|
1223
|
+
namespace,
|
|
1224
|
+
procedure,
|
|
1225
|
+
body.args ?? {}
|
|
1226
|
+
);
|
|
1227
|
+
res.setHeader("Content-Type", "application/json");
|
|
1228
|
+
res.writeHead(200);
|
|
1229
|
+
res.end(JSON.stringify(result));
|
|
1230
|
+
} catch (err) {
|
|
1231
|
+
log("Proxy error:", err);
|
|
1232
|
+
res.setHeader("Content-Type", "application/json");
|
|
1233
|
+
res.writeHead(500);
|
|
1234
|
+
res.end(
|
|
1235
|
+
JSON.stringify({
|
|
1236
|
+
error: err instanceof Error ? err.message : "Service call failed"
|
|
1237
|
+
})
|
|
1238
|
+
);
|
|
1239
|
+
}
|
|
1240
|
+
return;
|
|
1241
|
+
}
|
|
1242
|
+
if (url === "/api/services/search" && req.method === "POST") {
|
|
1243
|
+
const body = await parseBody2(req);
|
|
1244
|
+
res.setHeader("Content-Type", "application/json");
|
|
1245
|
+
res.writeHead(200);
|
|
1246
|
+
if (body.tool_name) {
|
|
1247
|
+
const info = registry.getToolInfo(body.tool_name);
|
|
1248
|
+
if (!info) {
|
|
1249
|
+
res.end(
|
|
1250
|
+
JSON.stringify({
|
|
1251
|
+
success: false,
|
|
1252
|
+
error: `Tool '${body.tool_name}' not found`
|
|
1253
|
+
})
|
|
1254
|
+
);
|
|
1255
|
+
} else {
|
|
1256
|
+
res.end(JSON.stringify({ success: true, tool: info }));
|
|
1257
|
+
}
|
|
1258
|
+
return;
|
|
1259
|
+
}
|
|
1260
|
+
const results = registry.searchServices({
|
|
1261
|
+
query: body.query,
|
|
1262
|
+
namespace: body.namespace,
|
|
1263
|
+
limit: body.limit ?? 20,
|
|
1264
|
+
includeInterfaces: body.include_interfaces ?? false
|
|
1265
|
+
});
|
|
1266
|
+
res.end(
|
|
1267
|
+
JSON.stringify({
|
|
1268
|
+
success: true,
|
|
1269
|
+
count: results.length,
|
|
1270
|
+
tools: results,
|
|
1271
|
+
namespaces: registry.getNamespaces()
|
|
1272
|
+
})
|
|
1273
|
+
);
|
|
1274
|
+
return;
|
|
1275
|
+
}
|
|
1276
|
+
if (url === "/api/services" && req.method === "GET") {
|
|
1277
|
+
res.setHeader("Content-Type", "application/json");
|
|
1278
|
+
res.writeHead(200);
|
|
1279
|
+
res.end(
|
|
1280
|
+
JSON.stringify({
|
|
1281
|
+
namespaces: registry.getNamespaces(),
|
|
1282
|
+
services: registry.getServiceInfo()
|
|
1283
|
+
})
|
|
1284
|
+
);
|
|
1285
|
+
return;
|
|
1286
|
+
}
|
|
1287
|
+
if (url === "/health" || url === "/") {
|
|
1288
|
+
res.setHeader("Content-Type", "application/json");
|
|
1289
|
+
res.writeHead(200);
|
|
1290
|
+
res.end(JSON.stringify({ status: "ok", service: "stitchery" }));
|
|
1291
|
+
return;
|
|
1292
|
+
}
|
|
1293
|
+
res.writeHead(404);
|
|
1294
|
+
res.end(`Not found: ${url}`);
|
|
1295
|
+
} catch (err) {
|
|
1296
|
+
log("Error:", err);
|
|
1297
|
+
res.writeHead(500);
|
|
1298
|
+
res.end(err instanceof Error ? err.message : "Internal server error");
|
|
1299
|
+
}
|
|
1300
|
+
});
|
|
1301
|
+
return {
|
|
1302
|
+
server,
|
|
1303
|
+
registry,
|
|
1304
|
+
async start() {
|
|
1305
|
+
return new Promise((resolve2, reject) => {
|
|
1306
|
+
server.on("error", reject);
|
|
1307
|
+
server.listen(port, host, () => {
|
|
1308
|
+
log(`Server listening on http://${host}:${port}`);
|
|
1309
|
+
resolve2({ port, host });
|
|
1310
|
+
});
|
|
1311
|
+
});
|
|
1312
|
+
},
|
|
1313
|
+
async stop() {
|
|
1314
|
+
return new Promise((resolve2, reject) => {
|
|
1315
|
+
server.close((err) => {
|
|
1316
|
+
if (err) reject(err);
|
|
1317
|
+
else resolve2();
|
|
1318
|
+
});
|
|
1319
|
+
});
|
|
1320
|
+
}
|
|
1321
|
+
};
|
|
1322
|
+
}
|
|
1323
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1324
|
+
0 && (module.exports = {
|
|
1325
|
+
createStitcheryServer
|
|
1326
|
+
});
|
|
1327
|
+
//# sourceMappingURL=index.cjs.map
|