@lovable.dev/mcp-js 3.1.0 → 3.2.0
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 +43 -0
- package/dist/{authorize-Dt7ll7Ur.d.ts → authorize-DUEaDXjU.d.ts} +1 -1
- package/dist/{authorize-BS_In2AW.d.cts → authorize-bDiUiJco.d.cts} +1 -1
- package/dist/{base-B7D0KqaY.d.ts → base-CLO7XsxC.d.ts} +1 -1
- package/dist/{base-D3TT1Wup.d.cts → base-D2d7lJY5.d.cts} +1 -1
- package/dist/cli/extract-manifest.cjs +1 -1
- package/dist/cli/extract-manifest.js +1 -1
- package/dist/{cors-YjwGFsid.cjs → cors-Dk0jvKYK.cjs} +1 -1
- package/dist/{cors-Df2tqbzV.js → cors-tLp9UO0k.js} +1 -1
- package/dist/{errors-CWxgUZH3.cjs → errors-CLfxIB-l.cjs} +3 -2
- package/dist/{errors-ZmYYVYKN.js → errors-CljrUVby.js} +3 -2
- package/dist/format-DDzvc92Z.cjs +41 -0
- package/dist/format-DKEuO8Tn.js +30 -0
- package/dist/hooks-BOdDe251.js +353 -0
- package/dist/hooks-xQl3EkDa.cjs +382 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/{io-BvogiiQ1.d.ts → io-CFyHLyvs.d.ts} +1 -1
- package/dist/{io-Bn0ErYbG.d.cts → io-DfUvQ-SV.d.cts} +1 -1
- package/dist/{io-BoS6dhC0.js → io-U3Nv7y0k.js} +3 -2
- package/dist/{io-D_DKGquD.cjs → io-tWj7qb9q.cjs} +7 -6
- package/dist/{mcp-aNWgpVIF.cjs → mcp-BMNeCc_-.cjs} +160 -8
- package/dist/{mcp-Bm89K_uU.js → mcp-BYSubCtv.js} +161 -9
- package/dist/{package-Cl7NhnV4.cjs → package-B4OsCEhG.cjs} +1 -1
- package/dist/{package-C6IcwY5Z.js → package-DXBX-HJu.js} +1 -1
- package/dist/protocols/mcp/index.cjs +1 -1
- package/dist/protocols/mcp/index.d.cts +3 -3
- package/dist/protocols/mcp/index.d.ts +3 -3
- package/dist/protocols/mcp/index.js +1 -1
- package/dist/protocols/oauth-metadata.cjs +1 -1
- package/dist/protocols/oauth-metadata.d.cts +3 -3
- package/dist/protocols/oauth-metadata.d.ts +3 -3
- package/dist/protocols/oauth-metadata.js +1 -1
- package/dist/stacks/supabase/index.cjs +2 -2
- package/dist/stacks/supabase/index.d.cts +1 -1
- package/dist/stacks/supabase/index.d.ts +1 -1
- package/dist/stacks/supabase/index.js +2 -2
- package/dist/stacks/supabase/vite.cjs +40 -18
- package/dist/stacks/supabase/vite.d.cts +1 -1
- package/dist/stacks/supabase/vite.d.ts +1 -1
- package/dist/stacks/supabase/vite.js +34 -12
- package/dist/stacks/tanstack/index.cjs +2 -2
- package/dist/stacks/tanstack/index.d.cts +2 -2
- package/dist/stacks/tanstack/index.d.ts +2 -2
- package/dist/stacks/tanstack/index.js +2 -2
- package/dist/stacks/tanstack/vite.cjs +33 -24
- package/dist/stacks/tanstack/vite.d.cts +1 -1
- package/dist/stacks/tanstack/vite.d.ts +1 -1
- package/dist/stacks/tanstack/vite.js +26 -17
- package/dist/testing/index.d.cts +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/{types-BX8RawmT.d.ts → types-CAFCH0yK.d.cts} +7 -1
- package/dist/{types-BX8RawmT.d.cts → types-CAFCH0yK.d.ts} +7 -1
- package/package.json +16 -4
- package/skill-imports.d.cts +1 -0
- package/skill-imports.d.ts +9 -0
- package/dist/supabase-config-DITfH_bn.js +0 -30
- package/dist/supabase-config-Dz13d9ze.cjs +0 -41
|
@@ -2,8 +2,8 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
-
const require_package = require("../../package-
|
|
6
|
-
const
|
|
5
|
+
const require_package = require("../../package-B4OsCEhG.cjs");
|
|
6
|
+
const require_hooks = require("../../hooks-xQl3EkDa.cjs");
|
|
7
7
|
const require_paths = require("../../paths-OP318a6c.cjs");
|
|
8
8
|
let node_fs = require("node:fs");
|
|
9
9
|
let node_path = require("node:path");
|
|
@@ -16,7 +16,7 @@ function fileExists(path) {
|
|
|
16
16
|
(0, node_fs.lstatSync)(path);
|
|
17
17
|
return true;
|
|
18
18
|
} catch (err) {
|
|
19
|
-
if (
|
|
19
|
+
if (require_hooks.isFileMissing(err)) return false;
|
|
20
20
|
throw err;
|
|
21
21
|
}
|
|
22
22
|
}
|
|
@@ -36,7 +36,7 @@ function writeIfChanged(file, content, ownershipCheck) {
|
|
|
36
36
|
try {
|
|
37
37
|
existing = (0, node_fs.readFileSync)(file, "utf8");
|
|
38
38
|
} catch (err) {
|
|
39
|
-
if (!
|
|
39
|
+
if (!require_hooks.isFileMissing(err)) throw err;
|
|
40
40
|
}
|
|
41
41
|
if (existing !== void 0) {
|
|
42
42
|
if (!ownershipCheck(existing)) throw new Error(`@lovable.dev/mcp-js: refusing to overwrite user-authored file at ${file}. Delete it or move it first.`);
|
|
@@ -145,11 +145,15 @@ function importMetaEnvDefines(inlineEnv) {
|
|
|
145
145
|
for (const [key, value] of Object.entries(env)) if (/^[A-Za-z_$][\w$]*$/.test(key)) defines[`import.meta.env.${key}`] = JSON.stringify(value);
|
|
146
146
|
return defines;
|
|
147
147
|
}
|
|
148
|
-
async function bundleFunctionEntry(projectRoot, mcpEntryAbs, functionName,
|
|
148
|
+
async function bundleFunctionEntry(projectRoot, mcpEntryAbs, functionName, options) {
|
|
149
149
|
const versions = readProjectDependencyVersions(projectRoot);
|
|
150
|
+
const aliases = options.aliases ?? [];
|
|
151
|
+
const wrapper = `import mcp from ${JSON.stringify(mcpEntryAbs)};\nimport { createSupabaseHandler } from "@lovable.dev/mcp-js/stacks/supabase";\nDeno.serve(createSupabaseHandler(mcp, { functionName: ${JSON.stringify(functionName)} }));\n`;
|
|
152
|
+
const skillFiles = [];
|
|
153
|
+
const skillDirs = [];
|
|
150
154
|
const result = await (0, esbuild.build)({
|
|
151
155
|
stdin: {
|
|
152
|
-
contents:
|
|
156
|
+
contents: wrapper,
|
|
153
157
|
resolveDir: projectRoot,
|
|
154
158
|
sourcefile: "lovable-mcp-supabase-entry.ts",
|
|
155
159
|
loader: "ts"
|
|
@@ -162,18 +166,24 @@ async function bundleFunctionEntry(projectRoot, mcpEntryAbs, functionName, inlin
|
|
|
162
166
|
target: "esnext",
|
|
163
167
|
absWorkingDir: projectRoot,
|
|
164
168
|
logLevel: "silent",
|
|
165
|
-
define: importMetaEnvDefines(inlineEnv),
|
|
169
|
+
define: importMetaEnvDefines(options.inlineEnv),
|
|
166
170
|
plugins: [
|
|
171
|
+
require_hooks.skillImportEsbuildPlugin((compilation) => {
|
|
172
|
+
skillFiles.push(...compilation.watchFiles);
|
|
173
|
+
skillDirs.push(...compilation.watchDirs);
|
|
174
|
+
console.info(compilation.report);
|
|
175
|
+
}, options.onSkillDirectory),
|
|
167
176
|
...aliases.length > 0 ? [resolveViteAliases(aliases)] : [],
|
|
168
177
|
rejectFrontendImages(projectRoot),
|
|
169
178
|
externalizeBareAsNpm(versions)
|
|
170
179
|
]
|
|
171
180
|
});
|
|
172
181
|
const out = result.outputFiles[0]?.text ?? "";
|
|
173
|
-
const inputs = Object.keys(result.metafile?.inputs ?? {}).filter((p) => !p.startsWith("<") && !p.startsWith("npm:")).map((p) => (0, node_path.resolve)(projectRoot, p));
|
|
182
|
+
const inputs = Object.keys(result.metafile?.inputs ?? {}).filter((p) => !p.startsWith("<") && !p.startsWith("npm:") && !require_hooks.isSkillImportInput(p)).map((p) => (0, node_path.resolve)(projectRoot, p)).concat(skillFiles);
|
|
174
183
|
return {
|
|
175
184
|
code: `${GENERATED_BANNER}\n// supabase function: ${functionName}\n// Bundled from ${(0, node_path.relative)(projectRoot, mcpEntryAbs).split(node_path.sep).join("/")} by @lovable.dev/mcp-js.\n` + out,
|
|
176
|
-
inputs
|
|
185
|
+
inputs,
|
|
186
|
+
skillDirs
|
|
177
187
|
};
|
|
178
188
|
}
|
|
179
189
|
function resolvePaths(options) {
|
|
@@ -212,13 +222,14 @@ async function syncSupabaseFunction(options) {
|
|
|
212
222
|
inputs: []
|
|
213
223
|
};
|
|
214
224
|
}
|
|
215
|
-
const { code, inputs } = await bundleFunctionEntry(projectRoot, paths.mcpEntryAbs, functionName, options
|
|
225
|
+
const { code, inputs, skillDirs } = await bundleFunctionEntry(projectRoot, paths.mcpEntryAbs, functionName, options);
|
|
216
226
|
if (writeIfChanged(paths.functionEntry, code, hasGeneratedBanner)) written.push(paths.functionEntry);
|
|
217
227
|
cleanupOrphans(paths.functionDir, /* @__PURE__ */ new Set([paths.functionEntry]), removed);
|
|
218
228
|
return {
|
|
219
229
|
written,
|
|
220
230
|
removed,
|
|
221
|
-
inputs
|
|
231
|
+
inputs,
|
|
232
|
+
skillDirs
|
|
222
233
|
};
|
|
223
234
|
}
|
|
224
235
|
function cleanupOrphans(functionDir, expected, removed) {
|
|
@@ -226,7 +237,7 @@ function cleanupOrphans(functionDir, expected, removed) {
|
|
|
226
237
|
try {
|
|
227
238
|
entries = (0, node_fs.readdirSync)(functionDir);
|
|
228
239
|
} catch (err) {
|
|
229
|
-
if (
|
|
240
|
+
if (require_hooks.isFileMissing(err)) return;
|
|
230
241
|
throw err;
|
|
231
242
|
}
|
|
232
243
|
for (const entry of entries) {
|
|
@@ -236,14 +247,14 @@ function cleanupOrphans(functionDir, expected, removed) {
|
|
|
236
247
|
try {
|
|
237
248
|
content = (0, node_fs.readFileSync)(full, "utf8");
|
|
238
249
|
} catch (err) {
|
|
239
|
-
if (
|
|
250
|
+
if (require_hooks.isFileMissing(err) || err.code === "EISDIR") continue;
|
|
240
251
|
throw err;
|
|
241
252
|
}
|
|
242
253
|
if (hasGeneratedBanner(content) || hasGeneratedJsonMarker(content)) try {
|
|
243
254
|
(0, node_fs.unlinkSync)(full);
|
|
244
255
|
removed.push(full);
|
|
245
256
|
} catch (err) {
|
|
246
|
-
if (!
|
|
257
|
+
if (!require_hooks.isFileMissing(err)) throw err;
|
|
247
258
|
}
|
|
248
259
|
}
|
|
249
260
|
}
|
|
@@ -262,7 +273,7 @@ function productionImportMetaEnv(config) {
|
|
|
262
273
|
SSR: false
|
|
263
274
|
};
|
|
264
275
|
if (!env.VITE_SUPABASE_PROJECT_ID) {
|
|
265
|
-
const ref =
|
|
276
|
+
const ref = require_hooks.readSupabaseProjectRef(config.root);
|
|
266
277
|
if (ref) env.VITE_SUPABASE_PROJECT_ID = ref;
|
|
267
278
|
}
|
|
268
279
|
return env;
|
|
@@ -300,16 +311,24 @@ function mcpPlugin(options = {}) {
|
|
|
300
311
|
let inlineEnv = {};
|
|
301
312
|
let aliases = [];
|
|
302
313
|
let watchedInputs = /* @__PURE__ */ new Set();
|
|
314
|
+
let watchedSkillDirs = [];
|
|
315
|
+
let devServer;
|
|
303
316
|
const regenerate = async () => {
|
|
304
|
-
const { inputs } = await syncSupabaseFunction({
|
|
317
|
+
const { inputs, skillDirs } = await syncSupabaseFunction({
|
|
305
318
|
projectRoot,
|
|
306
319
|
mcpEntry: mcpEntryOption,
|
|
307
320
|
functionsDir: functionsDirOption,
|
|
308
321
|
functionName,
|
|
309
322
|
inlineEnv,
|
|
310
|
-
aliases
|
|
323
|
+
aliases,
|
|
324
|
+
onSkillDirectory(directory) {
|
|
325
|
+
const normalized = normalizePath(directory);
|
|
326
|
+
if (!watchedSkillDirs.includes(normalized)) watchedSkillDirs.push(normalized);
|
|
327
|
+
devServer?.watcher.add(directory);
|
|
328
|
+
}
|
|
311
329
|
});
|
|
312
330
|
watchedInputs = new Set(inputs.map(normalizePath));
|
|
331
|
+
watchedSkillDirs = (skillDirs ?? []).map(normalizePath);
|
|
313
332
|
};
|
|
314
333
|
return {
|
|
315
334
|
name: "@lovable.dev/mcp-js/supabase",
|
|
@@ -330,9 +349,12 @@ function mcpPlugin(options = {}) {
|
|
|
330
349
|
await regenerate();
|
|
331
350
|
},
|
|
332
351
|
configureServer(server) {
|
|
352
|
+
devServer = server;
|
|
353
|
+
server.watcher.add(watchedSkillDirs);
|
|
333
354
|
const onChange = (file) => {
|
|
334
355
|
const norm = normalizePath(file);
|
|
335
|
-
|
|
356
|
+
const inSkillDir = watchedSkillDirs.some((dir) => norm.startsWith(`${dir}/`));
|
|
357
|
+
if (norm !== normalizePath(mcpEntryAbs) && !watchedInputs.has(norm) && !inSkillDir) return;
|
|
336
358
|
regenerate().catch((err) => {
|
|
337
359
|
const message = `[@lovable.dev/mcp-js] failed to regenerate the Supabase function: ${err instanceof Error ? err.message : String(err)}`;
|
|
338
360
|
if (server.config?.logger?.error) server.config.logger.error(message);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as version } from "../../package-
|
|
2
|
-
import {
|
|
1
|
+
import { t as version } from "../../package-DXBX-HJu.js";
|
|
2
|
+
import { a as isFileMissing, i as readSupabaseProjectRef, n as skillImportEsbuildPlugin, t as isSkillImportInput } from "../../hooks-BOdDe251.js";
|
|
3
3
|
import { n as assertFunctionName, t as FUNCTIONS_MOUNT_PREFIX } from "../../paths-IS65L6TA.js";
|
|
4
4
|
import { lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, unlinkSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { dirname, join, relative, resolve, sep } from "node:path";
|
|
@@ -141,11 +141,15 @@ function importMetaEnvDefines(inlineEnv) {
|
|
|
141
141
|
for (const [key, value] of Object.entries(env)) if (/^[A-Za-z_$][\w$]*$/.test(key)) defines[`import.meta.env.${key}`] = JSON.stringify(value);
|
|
142
142
|
return defines;
|
|
143
143
|
}
|
|
144
|
-
async function bundleFunctionEntry(projectRoot, mcpEntryAbs, functionName,
|
|
144
|
+
async function bundleFunctionEntry(projectRoot, mcpEntryAbs, functionName, options) {
|
|
145
145
|
const versions = readProjectDependencyVersions(projectRoot);
|
|
146
|
+
const aliases = options.aliases ?? [];
|
|
147
|
+
const wrapper = `import mcp from ${JSON.stringify(mcpEntryAbs)};\nimport { createSupabaseHandler } from "@lovable.dev/mcp-js/stacks/supabase";\nDeno.serve(createSupabaseHandler(mcp, { functionName: ${JSON.stringify(functionName)} }));\n`;
|
|
148
|
+
const skillFiles = [];
|
|
149
|
+
const skillDirs = [];
|
|
146
150
|
const result = await build({
|
|
147
151
|
stdin: {
|
|
148
|
-
contents:
|
|
152
|
+
contents: wrapper,
|
|
149
153
|
resolveDir: projectRoot,
|
|
150
154
|
sourcefile: "lovable-mcp-supabase-entry.ts",
|
|
151
155
|
loader: "ts"
|
|
@@ -158,18 +162,24 @@ async function bundleFunctionEntry(projectRoot, mcpEntryAbs, functionName, inlin
|
|
|
158
162
|
target: "esnext",
|
|
159
163
|
absWorkingDir: projectRoot,
|
|
160
164
|
logLevel: "silent",
|
|
161
|
-
define: importMetaEnvDefines(inlineEnv),
|
|
165
|
+
define: importMetaEnvDefines(options.inlineEnv),
|
|
162
166
|
plugins: [
|
|
167
|
+
skillImportEsbuildPlugin((compilation) => {
|
|
168
|
+
skillFiles.push(...compilation.watchFiles);
|
|
169
|
+
skillDirs.push(...compilation.watchDirs);
|
|
170
|
+
console.info(compilation.report);
|
|
171
|
+
}, options.onSkillDirectory),
|
|
163
172
|
...aliases.length > 0 ? [resolveViteAliases(aliases)] : [],
|
|
164
173
|
rejectFrontendImages(projectRoot),
|
|
165
174
|
externalizeBareAsNpm(versions)
|
|
166
175
|
]
|
|
167
176
|
});
|
|
168
177
|
const out = result.outputFiles[0]?.text ?? "";
|
|
169
|
-
const inputs = Object.keys(result.metafile?.inputs ?? {}).filter((p) => !p.startsWith("<") && !p.startsWith("npm:")).map((p) => resolve(projectRoot, p));
|
|
178
|
+
const inputs = Object.keys(result.metafile?.inputs ?? {}).filter((p) => !p.startsWith("<") && !p.startsWith("npm:") && !isSkillImportInput(p)).map((p) => resolve(projectRoot, p)).concat(skillFiles);
|
|
170
179
|
return {
|
|
171
180
|
code: `${GENERATED_BANNER}\n// supabase function: ${functionName}\n// Bundled from ${relative(projectRoot, mcpEntryAbs).split(sep).join("/")} by @lovable.dev/mcp-js.\n` + out,
|
|
172
|
-
inputs
|
|
181
|
+
inputs,
|
|
182
|
+
skillDirs
|
|
173
183
|
};
|
|
174
184
|
}
|
|
175
185
|
function resolvePaths(options) {
|
|
@@ -208,13 +218,14 @@ async function syncSupabaseFunction(options) {
|
|
|
208
218
|
inputs: []
|
|
209
219
|
};
|
|
210
220
|
}
|
|
211
|
-
const { code, inputs } = await bundleFunctionEntry(projectRoot, paths.mcpEntryAbs, functionName, options
|
|
221
|
+
const { code, inputs, skillDirs } = await bundleFunctionEntry(projectRoot, paths.mcpEntryAbs, functionName, options);
|
|
212
222
|
if (writeIfChanged(paths.functionEntry, code, hasGeneratedBanner)) written.push(paths.functionEntry);
|
|
213
223
|
cleanupOrphans(paths.functionDir, /* @__PURE__ */ new Set([paths.functionEntry]), removed);
|
|
214
224
|
return {
|
|
215
225
|
written,
|
|
216
226
|
removed,
|
|
217
|
-
inputs
|
|
227
|
+
inputs,
|
|
228
|
+
skillDirs
|
|
218
229
|
};
|
|
219
230
|
}
|
|
220
231
|
function cleanupOrphans(functionDir, expected, removed) {
|
|
@@ -296,16 +307,24 @@ function mcpPlugin(options = {}) {
|
|
|
296
307
|
let inlineEnv = {};
|
|
297
308
|
let aliases = [];
|
|
298
309
|
let watchedInputs = /* @__PURE__ */ new Set();
|
|
310
|
+
let watchedSkillDirs = [];
|
|
311
|
+
let devServer;
|
|
299
312
|
const regenerate = async () => {
|
|
300
|
-
const { inputs } = await syncSupabaseFunction({
|
|
313
|
+
const { inputs, skillDirs } = await syncSupabaseFunction({
|
|
301
314
|
projectRoot,
|
|
302
315
|
mcpEntry: mcpEntryOption,
|
|
303
316
|
functionsDir: functionsDirOption,
|
|
304
317
|
functionName,
|
|
305
318
|
inlineEnv,
|
|
306
|
-
aliases
|
|
319
|
+
aliases,
|
|
320
|
+
onSkillDirectory(directory) {
|
|
321
|
+
const normalized = normalizePath(directory);
|
|
322
|
+
if (!watchedSkillDirs.includes(normalized)) watchedSkillDirs.push(normalized);
|
|
323
|
+
devServer?.watcher.add(directory);
|
|
324
|
+
}
|
|
307
325
|
});
|
|
308
326
|
watchedInputs = new Set(inputs.map(normalizePath));
|
|
327
|
+
watchedSkillDirs = (skillDirs ?? []).map(normalizePath);
|
|
309
328
|
};
|
|
310
329
|
return {
|
|
311
330
|
name: "@lovable.dev/mcp-js/supabase",
|
|
@@ -326,9 +345,12 @@ function mcpPlugin(options = {}) {
|
|
|
326
345
|
await regenerate();
|
|
327
346
|
},
|
|
328
347
|
configureServer(server) {
|
|
348
|
+
devServer = server;
|
|
349
|
+
server.watcher.add(watchedSkillDirs);
|
|
329
350
|
const onChange = (file) => {
|
|
330
351
|
const norm = normalizePath(file);
|
|
331
|
-
|
|
352
|
+
const inSkillDir = watchedSkillDirs.some((dir) => norm.startsWith(`${dir}/`));
|
|
353
|
+
if (norm !== normalizePath(mcpEntryAbs) && !watchedInputs.has(norm) && !inSkillDir) return;
|
|
332
354
|
regenerate().catch((err) => {
|
|
333
355
|
const message = `[@lovable.dev/mcp-js] failed to regenerate the Supabase function: ${err instanceof Error ? err.message : String(err)}`;
|
|
334
356
|
if (server.config?.logger?.error) server.config.logger.error(message);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_cors = require("../../cors-
|
|
3
|
-
const require_mcp = require("../../mcp-
|
|
2
|
+
const require_cors = require("../../cors-Dk0jvKYK.cjs");
|
|
3
|
+
const require_mcp = require("../../mcp-BMNeCc_-.cjs");
|
|
4
4
|
const require_protocols_oauth_metadata = require("../../protocols/oauth-metadata.cjs");
|
|
5
5
|
const require_forwarded = require("../../forwarded-B37IdmMX.cjs");
|
|
6
6
|
//#region src/stacks/tanstack/handlers.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { m as McpDefinition } from "../../types-
|
|
2
|
-
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-
|
|
1
|
+
import { m as McpDefinition } from "../../types-CAFCH0yK.cjs";
|
|
2
|
+
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-bDiUiJco.cjs";
|
|
3
3
|
//#region src/stacks/tanstack/handlers.d.ts
|
|
4
4
|
interface TanStackRequest extends Request {
|
|
5
5
|
waitUntil?: ScheduleBackground;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { m as McpDefinition } from "../../types-
|
|
2
|
-
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-
|
|
1
|
+
import { m as McpDefinition } from "../../types-CAFCH0yK.js";
|
|
2
|
+
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-DUEaDXjU.js";
|
|
3
3
|
//#region src/stacks/tanstack/handlers.d.ts
|
|
4
4
|
interface TanStackRequest extends Request {
|
|
5
5
|
waitUntil?: ScheduleBackground;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as createRecorderForRuntime } from "../../cors-
|
|
2
|
-
import { t as createMcpProtocolHandler } from "../../mcp-
|
|
1
|
+
import { c as createRecorderForRuntime } from "../../cors-tLp9UO0k.js";
|
|
2
|
+
import { t as createMcpProtocolHandler } from "../../mcp-BYSubCtv.js";
|
|
3
3
|
import { createOAuthProtectedResourceMetadataHandler } from "../../protocols/oauth-metadata.js";
|
|
4
4
|
import { t as applyForwardedOrigin } from "../../forwarded-BBXvFeh6.js";
|
|
5
5
|
//#region src/stacks/tanstack/handlers.ts
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
require("../../metadata-path-zd7NSNoa.cjs");
|
|
6
|
-
const
|
|
6
|
+
const require_hooks = require("../../hooks-xQl3EkDa.cjs");
|
|
7
7
|
let node_fs = require("node:fs");
|
|
8
8
|
let node_path = require("node:path");
|
|
9
9
|
let vite = require("vite");
|
|
@@ -63,7 +63,7 @@ function relativeImportSpecifier(routeFile, target) {
|
|
|
63
63
|
const withoutExt = normalizePath((0, node_path.relative)((0, node_path.dirname)(routeFile), target)).replace(/\.ts$/, "");
|
|
64
64
|
return withoutExt.startsWith(".") ? withoutExt : `./${withoutExt}`;
|
|
65
65
|
}
|
|
66
|
-
function buildRouteSource(route, resourcePath, metadataPath, trustForwardedHost, trustForwardedProto, mcpEntry, projectRoot) {
|
|
66
|
+
function buildRouteSource(route, resourcePath, metadataPath, trustForwardedHost, trustForwardedProto, mcpEntry, projectRoot, hasSitemapInventory) {
|
|
67
67
|
const mcpImport = relativeImportSpecifier(route.file, mcpEntry);
|
|
68
68
|
const routeRel = normalizePath((0, node_path.relative)(projectRoot, route.file));
|
|
69
69
|
const optionEntries = [`resourcePath: "${resourcePath}"`];
|
|
@@ -87,7 +87,7 @@ import { ${route.handlerFactory} } from "@lovable.dev/mcp-js/stacks/tanstack";
|
|
|
87
87
|
import mcp from "${mcpImport}";
|
|
88
88
|
|
|
89
89
|
${routeOpen}
|
|
90
|
-
server: {
|
|
90
|
+
${hasSitemapInventory ? " staticData: { sitemap: false },\n" : ""} server: {
|
|
91
91
|
handlers: {
|
|
92
92
|
ANY: ${route.handlerFactory}(mcp, ${optionsObject}),
|
|
93
93
|
},
|
|
@@ -107,7 +107,7 @@ function writeIfChanged(file, content) {
|
|
|
107
107
|
try {
|
|
108
108
|
existing = (0, node_fs.readFileSync)(file, "utf8");
|
|
109
109
|
} catch (err) {
|
|
110
|
-
if (!
|
|
110
|
+
if (!require_hooks.isFileMissing(err)) throw err;
|
|
111
111
|
}
|
|
112
112
|
if (existing !== void 0) {
|
|
113
113
|
if (!hasGeneratedBanner(existing)) throw new Error(`@lovable.dev/mcp-js: refusing to overwrite user-authored route at ${file}. Delete it or move it first.`);
|
|
@@ -121,7 +121,7 @@ function fileStartsWithBanner(file) {
|
|
|
121
121
|
try {
|
|
122
122
|
return hasGeneratedBanner((0, node_fs.readFileSync)(file, "utf8"));
|
|
123
123
|
} catch (err) {
|
|
124
|
-
if (
|
|
124
|
+
if (require_hooks.isFileMissing(err)) return false;
|
|
125
125
|
throw err;
|
|
126
126
|
}
|
|
127
127
|
}
|
|
@@ -132,7 +132,7 @@ function findAdoptedFiles(routesDir) {
|
|
|
132
132
|
try {
|
|
133
133
|
entries = (0, node_fs.readdirSync)(dir);
|
|
134
134
|
} catch (err) {
|
|
135
|
-
if (
|
|
135
|
+
if (require_hooks.isFileMissing(err)) return;
|
|
136
136
|
throw err;
|
|
137
137
|
}
|
|
138
138
|
for (const entry of entries) {
|
|
@@ -141,7 +141,7 @@ function findAdoptedFiles(routesDir) {
|
|
|
141
141
|
try {
|
|
142
142
|
stat = (0, node_fs.lstatSync)(full);
|
|
143
143
|
} catch (err) {
|
|
144
|
-
if (
|
|
144
|
+
if (require_hooks.isFileMissing(err)) continue;
|
|
145
145
|
throw err;
|
|
146
146
|
}
|
|
147
147
|
if (stat.isDirectory()) visit(full);
|
|
@@ -181,17 +181,25 @@ function mcpPlugin(options = {}) {
|
|
|
181
181
|
const trustForwardedProto = options.trustForwardedProto !== false;
|
|
182
182
|
let projectRoot = process.cwd();
|
|
183
183
|
let mcpEntry = (0, node_path.resolve)(projectRoot, mcpEntryOption);
|
|
184
|
+
let sitemapFile = (0, node_path.resolve)(projectRoot, "src/lib/sitemap.ts");
|
|
184
185
|
let { routesDir, mcpRouteFile, metadataRouteFile } = resolveAllRoutes(projectRoot, routesDirOption, routeFileName, metadataUrlPath);
|
|
185
186
|
const regenerate = () => {
|
|
186
187
|
let mcpEntryExists = true;
|
|
187
188
|
try {
|
|
188
189
|
(0, node_fs.lstatSync)(mcpEntry);
|
|
189
190
|
} catch (err) {
|
|
190
|
-
if (!
|
|
191
|
+
if (!require_hooks.isFileMissing(err)) throw err;
|
|
191
192
|
mcpEntryExists = false;
|
|
192
193
|
}
|
|
193
194
|
const expected = /* @__PURE__ */ new Set();
|
|
194
195
|
if (mcpEntryExists) {
|
|
196
|
+
let sitemapSource = "";
|
|
197
|
+
try {
|
|
198
|
+
sitemapSource = (0, node_fs.readFileSync)(sitemapFile, "utf8");
|
|
199
|
+
} catch (err) {
|
|
200
|
+
if (!require_hooks.isFileMissing(err)) throw err;
|
|
201
|
+
}
|
|
202
|
+
const hasSitemapInventory = /^\s*export\s+const\s+sitemapRouteInventoryVersion\s*=\s*1\s*(?:;|$)/m.test(sitemapSource);
|
|
195
203
|
const routes = [{
|
|
196
204
|
file: mcpRouteFile,
|
|
197
205
|
routeLiteral: urlPath,
|
|
@@ -205,16 +213,29 @@ function mcpPlugin(options = {}) {
|
|
|
205
213
|
});
|
|
206
214
|
for (const route of routes) {
|
|
207
215
|
expected.add(route.file);
|
|
208
|
-
writeIfChanged(route.file, buildRouteSource(route, urlPath, injectedMetadataPath, trustForwardedHost, trustForwardedProto, mcpEntry, projectRoot));
|
|
216
|
+
writeIfChanged(route.file, buildRouteSource(route, urlPath, injectedMetadataPath, trustForwardedHost, trustForwardedProto, mcpEntry, projectRoot, hasSitemapInventory));
|
|
209
217
|
}
|
|
210
218
|
}
|
|
211
219
|
for (const file of findAdoptedFiles(routesDir)) if (!expected.has(file)) try {
|
|
212
220
|
(0, node_fs.unlinkSync)(file);
|
|
213
221
|
} catch (err) {
|
|
214
|
-
if (!
|
|
222
|
+
if (!require_hooks.isFileMissing(err)) throw err;
|
|
215
223
|
}
|
|
216
224
|
};
|
|
217
225
|
return {
|
|
226
|
+
...require_hooks.skillImportVitePlugin({ onServer(server) {
|
|
227
|
+
const onChange = (file) => {
|
|
228
|
+
if (normalizePath(file) === normalizePath(mcpEntry) || normalizePath(file) === normalizePath(sitemapFile)) regenerate();
|
|
229
|
+
};
|
|
230
|
+
server.watcher.on("add", onChange);
|
|
231
|
+
server.watcher.on("change", onChange);
|
|
232
|
+
server.watcher.on("unlink", onChange);
|
|
233
|
+
server.watcher.once("close", () => {
|
|
234
|
+
server.watcher.off("add", onChange);
|
|
235
|
+
server.watcher.off("change", onChange);
|
|
236
|
+
server.watcher.off("unlink", onChange);
|
|
237
|
+
});
|
|
238
|
+
} }),
|
|
218
239
|
name: "@lovable.dev/mcp-js",
|
|
219
240
|
api: {
|
|
220
241
|
get mcpEntry() {
|
|
@@ -227,29 +248,17 @@ function mcpPlugin(options = {}) {
|
|
|
227
248
|
config(userConfig, { mode }) {
|
|
228
249
|
const root = userConfig.root ? (0, node_path.resolve)(userConfig.root) : process.cwd();
|
|
229
250
|
if ((0, vite.loadEnv)(mode, typeof userConfig.envDir === "string" ? (0, node_path.resolve)(root, userConfig.envDir) : root, userConfig.envPrefix ?? "VITE_")[SUPABASE_PROJECT_REF_ENV]) return;
|
|
230
|
-
const ref =
|
|
251
|
+
const ref = require_hooks.readSupabaseProjectRef(root);
|
|
231
252
|
if (!ref) return;
|
|
232
253
|
return { define: { [`import.meta.env.${SUPABASE_PROJECT_REF_ENV}`]: JSON.stringify(ref) } };
|
|
233
254
|
},
|
|
234
255
|
configResolved(config) {
|
|
235
256
|
projectRoot = config.root;
|
|
236
257
|
mcpEntry = (0, node_path.resolve)(projectRoot, mcpEntryOption);
|
|
258
|
+
sitemapFile = (0, node_path.resolve)(projectRoot, "src/lib/sitemap.ts");
|
|
237
259
|
({routesDir, mcpRouteFile, metadataRouteFile} = resolveAllRoutes(projectRoot, routesDirOption, routeFileName, metadataUrlPath));
|
|
238
260
|
regenerate();
|
|
239
261
|
},
|
|
240
|
-
configureServer(server) {
|
|
241
|
-
const onChange = (file) => {
|
|
242
|
-
if (normalizePath(file) === normalizePath(mcpEntry)) regenerate();
|
|
243
|
-
};
|
|
244
|
-
server.watcher.on("add", onChange);
|
|
245
|
-
server.watcher.on("change", onChange);
|
|
246
|
-
server.watcher.on("unlink", onChange);
|
|
247
|
-
server.watcher.once("close", () => {
|
|
248
|
-
server.watcher.off("add", onChange);
|
|
249
|
-
server.watcher.off("change", onChange);
|
|
250
|
-
server.watcher.off("unlink", onChange);
|
|
251
|
-
});
|
|
252
|
-
},
|
|
253
262
|
buildStart() {
|
|
254
263
|
regenerate();
|
|
255
264
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "../../metadata-path-CAkNcfyY.js";
|
|
2
|
-
import {
|
|
2
|
+
import { a as isFileMissing, i as readSupabaseProjectRef, r as skillImportVitePlugin } from "../../hooks-BOdDe251.js";
|
|
3
3
|
import { lstatSync, mkdirSync, readFileSync, readdirSync, unlinkSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { dirname, join, relative, resolve, sep } from "node:path";
|
|
5
5
|
import { loadEnv } from "vite";
|
|
@@ -59,7 +59,7 @@ function relativeImportSpecifier(routeFile, target) {
|
|
|
59
59
|
const withoutExt = normalizePath(relative(dirname(routeFile), target)).replace(/\.ts$/, "");
|
|
60
60
|
return withoutExt.startsWith(".") ? withoutExt : `./${withoutExt}`;
|
|
61
61
|
}
|
|
62
|
-
function buildRouteSource(route, resourcePath, metadataPath, trustForwardedHost, trustForwardedProto, mcpEntry, projectRoot) {
|
|
62
|
+
function buildRouteSource(route, resourcePath, metadataPath, trustForwardedHost, trustForwardedProto, mcpEntry, projectRoot, hasSitemapInventory) {
|
|
63
63
|
const mcpImport = relativeImportSpecifier(route.file, mcpEntry);
|
|
64
64
|
const routeRel = normalizePath(relative(projectRoot, route.file));
|
|
65
65
|
const optionEntries = [`resourcePath: "${resourcePath}"`];
|
|
@@ -83,7 +83,7 @@ import { ${route.handlerFactory} } from "@lovable.dev/mcp-js/stacks/tanstack";
|
|
|
83
83
|
import mcp from "${mcpImport}";
|
|
84
84
|
|
|
85
85
|
${routeOpen}
|
|
86
|
-
server: {
|
|
86
|
+
${hasSitemapInventory ? " staticData: { sitemap: false },\n" : ""} server: {
|
|
87
87
|
handlers: {
|
|
88
88
|
ANY: ${route.handlerFactory}(mcp, ${optionsObject}),
|
|
89
89
|
},
|
|
@@ -177,6 +177,7 @@ function mcpPlugin(options = {}) {
|
|
|
177
177
|
const trustForwardedProto = options.trustForwardedProto !== false;
|
|
178
178
|
let projectRoot = process.cwd();
|
|
179
179
|
let mcpEntry = resolve(projectRoot, mcpEntryOption);
|
|
180
|
+
let sitemapFile = resolve(projectRoot, "src/lib/sitemap.ts");
|
|
180
181
|
let { routesDir, mcpRouteFile, metadataRouteFile } = resolveAllRoutes(projectRoot, routesDirOption, routeFileName, metadataUrlPath);
|
|
181
182
|
const regenerate = () => {
|
|
182
183
|
let mcpEntryExists = true;
|
|
@@ -188,6 +189,13 @@ function mcpPlugin(options = {}) {
|
|
|
188
189
|
}
|
|
189
190
|
const expected = /* @__PURE__ */ new Set();
|
|
190
191
|
if (mcpEntryExists) {
|
|
192
|
+
let sitemapSource = "";
|
|
193
|
+
try {
|
|
194
|
+
sitemapSource = readFileSync(sitemapFile, "utf8");
|
|
195
|
+
} catch (err) {
|
|
196
|
+
if (!isFileMissing(err)) throw err;
|
|
197
|
+
}
|
|
198
|
+
const hasSitemapInventory = /^\s*export\s+const\s+sitemapRouteInventoryVersion\s*=\s*1\s*(?:;|$)/m.test(sitemapSource);
|
|
191
199
|
const routes = [{
|
|
192
200
|
file: mcpRouteFile,
|
|
193
201
|
routeLiteral: urlPath,
|
|
@@ -201,7 +209,7 @@ function mcpPlugin(options = {}) {
|
|
|
201
209
|
});
|
|
202
210
|
for (const route of routes) {
|
|
203
211
|
expected.add(route.file);
|
|
204
|
-
writeIfChanged(route.file, buildRouteSource(route, urlPath, injectedMetadataPath, trustForwardedHost, trustForwardedProto, mcpEntry, projectRoot));
|
|
212
|
+
writeIfChanged(route.file, buildRouteSource(route, urlPath, injectedMetadataPath, trustForwardedHost, trustForwardedProto, mcpEntry, projectRoot, hasSitemapInventory));
|
|
205
213
|
}
|
|
206
214
|
}
|
|
207
215
|
for (const file of findAdoptedFiles(routesDir)) if (!expected.has(file)) try {
|
|
@@ -211,6 +219,19 @@ function mcpPlugin(options = {}) {
|
|
|
211
219
|
}
|
|
212
220
|
};
|
|
213
221
|
return {
|
|
222
|
+
...skillImportVitePlugin({ onServer(server) {
|
|
223
|
+
const onChange = (file) => {
|
|
224
|
+
if (normalizePath(file) === normalizePath(mcpEntry) || normalizePath(file) === normalizePath(sitemapFile)) regenerate();
|
|
225
|
+
};
|
|
226
|
+
server.watcher.on("add", onChange);
|
|
227
|
+
server.watcher.on("change", onChange);
|
|
228
|
+
server.watcher.on("unlink", onChange);
|
|
229
|
+
server.watcher.once("close", () => {
|
|
230
|
+
server.watcher.off("add", onChange);
|
|
231
|
+
server.watcher.off("change", onChange);
|
|
232
|
+
server.watcher.off("unlink", onChange);
|
|
233
|
+
});
|
|
234
|
+
} }),
|
|
214
235
|
name: "@lovable.dev/mcp-js",
|
|
215
236
|
api: {
|
|
216
237
|
get mcpEntry() {
|
|
@@ -230,22 +251,10 @@ function mcpPlugin(options = {}) {
|
|
|
230
251
|
configResolved(config) {
|
|
231
252
|
projectRoot = config.root;
|
|
232
253
|
mcpEntry = resolve(projectRoot, mcpEntryOption);
|
|
254
|
+
sitemapFile = resolve(projectRoot, "src/lib/sitemap.ts");
|
|
233
255
|
({routesDir, mcpRouteFile, metadataRouteFile} = resolveAllRoutes(projectRoot, routesDirOption, routeFileName, metadataUrlPath));
|
|
234
256
|
regenerate();
|
|
235
257
|
},
|
|
236
|
-
configureServer(server) {
|
|
237
|
-
const onChange = (file) => {
|
|
238
|
-
if (normalizePath(file) === normalizePath(mcpEntry)) regenerate();
|
|
239
|
-
};
|
|
240
|
-
server.watcher.on("add", onChange);
|
|
241
|
-
server.watcher.on("change", onChange);
|
|
242
|
-
server.watcher.on("unlink", onChange);
|
|
243
|
-
server.watcher.once("close", () => {
|
|
244
|
-
server.watcher.off("add", onChange);
|
|
245
|
-
server.watcher.off("change", onChange);
|
|
246
|
-
server.watcher.off("unlink", onChange);
|
|
247
|
-
});
|
|
248
|
-
},
|
|
249
258
|
buildStart() {
|
|
250
259
|
regenerate();
|
|
251
260
|
}
|
package/dist/testing/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { w as ZodOutputSchema } from "../types-
|
|
1
|
+
import { w as ZodOutputSchema } from "../types-CAFCH0yK.cjs";
|
|
2
2
|
import { n as McpCheckError, t as Diagnostic } from "../diagnostic-DRKjgCsW.cjs";
|
|
3
3
|
//#region src/testing/result.d.ts
|
|
4
4
|
interface ToolResultExpectation {
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { w as ZodOutputSchema } from "../types-
|
|
1
|
+
import { w as ZodOutputSchema } from "../types-CAFCH0yK.js";
|
|
2
2
|
import { n as McpCheckError, t as Diagnostic } from "../diagnostic-DRKjgCsW.js";
|
|
3
3
|
//#region src/testing/result.d.ts
|
|
4
4
|
interface ToolResultExpectation {
|
|
@@ -180,6 +180,11 @@ interface MetricsOptions {
|
|
|
180
180
|
/** Either the bare on/off toggle or the full options object. */
|
|
181
181
|
type MetricsConfig = boolean | MetricsOptions;
|
|
182
182
|
//#endregion
|
|
183
|
+
//#region src/skills/format.d.ts
|
|
184
|
+
interface Skill {
|
|
185
|
+
readonly __skill: never;
|
|
186
|
+
}
|
|
187
|
+
//#endregion
|
|
183
188
|
//#region src/core/types.d.ts
|
|
184
189
|
/**
|
|
185
190
|
* Any zod schema. Aliased to zod's `ZodType` (no generics) — non-deprecated
|
|
@@ -396,6 +401,7 @@ type McpDefinitionInput<TAppContext = undefined> = {
|
|
|
396
401
|
*/
|
|
397
402
|
readonly instructions: string;
|
|
398
403
|
readonly tools: readonly (AnyAppContextToolDefinition<TAppContext> | StaticToolDefinition)[];
|
|
404
|
+
readonly skills?: readonly Skill[];
|
|
399
405
|
/**
|
|
400
406
|
* Usage-metrics emission (runtime telemetry), on by default. `false` opts out;
|
|
401
407
|
* `{ endpoint, headers }` sends to your own OTLP collector. Self-disables at
|
|
@@ -410,4 +416,4 @@ type McpDefinition<TAppContext = unknown> = Omit<McpDefinitionInput<TAppContext>
|
|
|
410
416
|
readonly [McpDefinitionBrand]: never;
|
|
411
417
|
};
|
|
412
418
|
//#endregion
|
|
413
|
-
export {
|
|
419
|
+
export { AuthContext as A, ToolVisibilityContext as C, Skill as D, ZodSchema as E, JwtClaims as F, McpAuthConfig as I, McpProtocolEra as M, ProgressUpdate as N, MetricsConfig as O, ToolContext as P, ToolHandlerResult as S, ZodRawShape$1 as T, ResourceLinkIcon as _, ContentBlock as a, ToolContent as b, EmbeddedResource as c, JsonValue as d, JsonValueInput as f, ResourceLink as g, McpDefinitionInput as h, ContentAnnotations as i, McpClientInfo as j, MetricsOptions as k, EmbeddedTextResource as l, McpDefinition as m, AppContextToolDefinitionInput as n, CreateAppContextInput as o, McpAllowedOrigins as p, AudioContent as r, EmbeddedBlobResource as s, AppContextToolDefinition as t, ImageContent as u, TextContent as v, ZodOutputSchema as w, ToolDefinition as x, ToolAnnotations as y };
|