nuxt-ai-ready 3.6.0 → 3.6.2
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/dist/agent-skills-config-CmZq9uWW.mjs +18 -0
- package/dist/agent-skills-zGLgFB6H.mjs +468 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +656 -570
- package/dist/devtools/pages/ai-ready/debug.vue +9 -3
- package/dist/devtools/pages/ai-ready/index.vue +3 -1
- package/dist/devtools/pages/ai-ready/llms-txt.vue +15 -4
- package/dist/devtools/pages/ai-ready.vue +28 -4
- package/dist/module.d.mts +106 -112
- package/dist/module.json +3 -3
- package/dist/module.mjs +2732 -26
- package/dist/package-metadata-B1darl8W.mjs +28 -0
- package/dist/prerender-QMv07W4h.mjs +650 -0
- package/dist/runtime/app/composables/webmcp.js +90 -97
- package/dist/runtime/app/plugins/md-alternate.server.js +29 -26
- package/dist/runtime/app/plugins/md-hints.prerender.js +13 -15
- package/dist/runtime/app/plugins/webmcp.client.js +49 -53
- package/dist/runtime/app/webmcp-config.js +2 -2
- package/dist/runtime/cache-control.js +16 -10
- package/dist/runtime/i18n-url.js +6 -6
- package/dist/runtime/index.js +4 -12
- package/dist/runtime/llms-txt-directive.js +20 -13
- package/dist/runtime/llms-txt-files.js +188 -187
- package/dist/runtime/llms-txt-format.js +54 -55
- package/dist/runtime/llms-txt-i18n.js +22 -19
- package/dist/runtime/llms-txt-utils.js +140 -95
- package/dist/runtime/markdown-links.js +45 -39
- package/dist/runtime/markdown-path.js +29 -9
- package/dist/runtime/markdown-text.js +2 -1
- package/dist/runtime/mcp.js +5 -1
- package/dist/runtime/route-path.js +14 -8
- package/dist/runtime/server/db/drizzle/client.js +71 -75
- package/dist/runtime/server/db/drizzle/index.js +16 -28
- package/dist/runtime/server/db/drizzle/providers/bun.d.ts +2 -1
- package/dist/runtime/server/db/drizzle/providers/bun.js +10 -7
- package/dist/runtime/server/db/drizzle/providers/d1.js +16 -13
- package/dist/runtime/server/db/drizzle/providers/dbPath.js +60 -37
- package/dist/runtime/server/db/drizzle/providers/libsql.js +23 -11
- package/dist/runtime/server/db/drizzle/providers/neon.js +13 -10
- package/dist/runtime/server/db/drizzle/providers/node-sqlite.js +10 -7
- package/dist/runtime/server/db/drizzle/providers/postgres.js +13 -10
- package/dist/runtime/server/db/drizzle/queries.js +633 -532
- package/dist/runtime/server/db/drizzle/raw.js +200 -176
- package/dist/runtime/server/db/index.js +3 -0
- package/dist/runtime/server/db/queries.js +816 -607
- package/dist/runtime/server/db/schema/postgres.js +56 -50
- package/dist/runtime/server/db/schema/sqlite.js +56 -50
- package/dist/runtime/server/db/schema-sql.js +35 -38
- package/dist/runtime/server/db/seed.js +60 -45
- package/dist/runtime/server/db/shared.js +300 -213
- package/dist/runtime/server/index.js +1 -17
- package/dist/runtime/server/mcp/cache-key.js +5 -1
- package/dist/runtime/server/mcp/resources/pages.js +32 -33
- package/dist/runtime/server/mcp/tools/get-page-markdown.js +41 -27
- package/dist/runtime/server/mcp/tools/list-pages.js +40 -34
- package/dist/runtime/server/mcp/tools/search-pages.js +24 -16
- package/dist/runtime/server/middleware/markdown.d.ts +1 -1
- package/dist/runtime/server/middleware/markdown.js +15 -13
- package/dist/runtime/server/middleware/markdown.prerender.d.ts +1 -1
- package/dist/runtime/server/middleware/markdown.prerender.js +135 -119
- package/dist/runtime/server/middleware/render-markdown.d.ts +1 -1
- package/dist/runtime/server/middleware/render-markdown.js +164 -144
- package/dist/runtime/server/plugins/ai-terms.d.ts +1 -1
- package/dist/runtime/server/plugins/ai-terms.js +4 -8
- package/dist/runtime/server/plugins/content-signal-capture-nitro3.prerender.d.ts +1 -1
- package/dist/runtime/server/plugins/content-signal-capture-nitro3.prerender.js +7 -8
- package/dist/runtime/server/plugins/content-signal-capture.prerender.d.ts +1 -1
- package/dist/runtime/server/plugins/content-signal-capture.prerender.js +7 -7
- package/dist/runtime/server/plugins/db-lifecycle-nitro3.d.ts +1 -1
- package/dist/runtime/server/plugins/db-lifecycle-nitro3.js +13 -14
- package/dist/runtime/server/plugins/db-lifecycle.js +13 -11
- package/dist/runtime/server/plugins/html-capture.prerender.js +6 -6
- package/dist/runtime/server/plugins/link-header-nitro3.d.ts +1 -1
- package/dist/runtime/server/plugins/link-header-nitro3.js +23 -13
- package/dist/runtime/server/plugins/link-header.d.ts +1 -1
- package/dist/runtime/server/plugins/link-header.js +30 -30
- package/dist/runtime/server/plugins/llms-txt-directive-html.d.ts +1 -1
- package/dist/runtime/server/plugins/llms-txt-directive-html.js +4 -3
- package/dist/runtime/server/plugins/markdown-negotiation.d.ts +1 -1
- package/dist/runtime/server/plugins/markdown-negotiation.js +64 -45
- package/dist/runtime/server/plugins/sitemap-seeder.js +144 -112
- package/dist/runtime/server/routes/__ai-ready/cron.get.d.ts +1 -1
- package/dist/runtime/server/routes/__ai-ready/cron.get.js +17 -11
- package/dist/runtime/server/routes/__ai-ready/devtools.get.d.ts +1 -1
- package/dist/runtime/server/routes/__ai-ready/devtools.get.js +60 -45
- package/dist/runtime/server/routes/__ai-ready/pages.get.d.ts +36 -1
- package/dist/runtime/server/routes/__ai-ready/pages.get.js +44 -40
- package/dist/runtime/server/routes/__ai-ready/poll.post.d.ts +15 -1
- package/dist/runtime/server/routes/__ai-ready/poll.post.js +30 -30
- package/dist/runtime/server/routes/__ai-ready/prune.post.d.ts +13 -1
- package/dist/runtime/server/routes/__ai-ready/prune.post.js +29 -15
- package/dist/runtime/server/routes/__ai-ready/reindex.post.d.ts +22 -1
- package/dist/runtime/server/routes/__ai-ready/reindex.post.js +31 -21
- package/dist/runtime/server/routes/__ai-ready/restore.post.d.ts +4 -1
- package/dist/runtime/server/routes/__ai-ready/restore.post.js +28 -22
- package/dist/runtime/server/routes/__ai-ready/status.get.d.ts +1 -1
- package/dist/runtime/server/routes/__ai-ready/status.get.js +52 -53
- package/dist/runtime/server/routes/__ai-ready-debug.get.d.ts +83 -1
- package/dist/runtime/server/routes/__ai-ready-debug.get.js +209 -189
- package/dist/runtime/server/routes/agent-skills-artifact.d.ts +1 -1
- package/dist/runtime/server/routes/agent-skills-artifact.js +16 -14
- package/dist/runtime/server/routes/agent-skills-index.d.ts +1 -1
- package/dist/runtime/server/routes/agent-skills-index.js +8 -6
- package/dist/runtime/server/routes/ai-catalog.js +19 -19
- package/dist/runtime/server/routes/ai-terms.js +23 -19
- package/dist/runtime/server/routes/api-catalog.js +23 -23
- package/dist/runtime/server/routes/llms-full.txt.get.d.ts +1 -1
- package/dist/runtime/server/routes/llms-full.txt.get.js +42 -41
- package/dist/runtime/server/routes/llms.txt.get.d.ts +1 -1
- package/dist/runtime/server/routes/llms.txt.get.js +38 -33
- package/dist/runtime/server/routes/mcp-server-card.js +19 -19
- package/dist/runtime/server/routes/sitemap.md.get.d.ts +1 -1
- package/dist/runtime/server/routes/sitemap.md.get.js +38 -39
- package/dist/runtime/server/tasks/ai-ready-cron.d.ts +1 -1
- package/dist/runtime/server/tasks/ai-ready-cron.js +17 -14
- package/dist/runtime/server/utils/auth.js +76 -53
- package/dist/runtime/server/utils/batchIndex.js +72 -60
- package/dist/runtime/server/utils/checkStale.js +181 -134
- package/dist/runtime/server/utils/cloudflare-prerendered.js +23 -20
- package/dist/runtime/server/utils/cloudflare.js +69 -51
- package/dist/runtime/server/utils/content-negotiation.js +30 -18
- package/dist/runtime/server/utils/content.js +4 -1
- package/dist/runtime/server/utils/context.js +30 -19
- package/dist/runtime/server/utils/cron-plan.js +6 -6
- package/dist/runtime/server/utils/discovery-response.js +5 -6
- package/dist/runtime/server/utils/fetch.js +2 -1
- package/dist/runtime/server/utils/frontmatter.js +44 -57
- package/dist/runtime/server/utils/i18n.js +3 -8
- package/dist/runtime/server/utils/indexPage.js +152 -113
- package/dist/runtime/server/utils/keywords.js +278 -277
- package/dist/runtime/server/utils/link-header.js +67 -56
- package/dist/runtime/server/utils/llms-full.js +39 -49
- package/dist/runtime/server/utils/markdown-redirect.js +26 -14
- package/dist/runtime/server/utils/markdown-request.js +62 -47
- package/dist/runtime/server/utils/negotiation-decision.d.ts +8 -0
- package/dist/runtime/server/utils/negotiation-decision.js +106 -34
- package/dist/runtime/server/utils/negotiation-response.d.ts +1 -1
- package/dist/runtime/server/utils/negotiation-response.js +195 -144
- package/dist/runtime/server/utils/page-updated-at.js +23 -15
- package/dist/runtime/server/utils/prerender-html.js +31 -17
- package/dist/runtime/server/utils/runCron.js +263 -192
- package/dist/runtime/server/utils/sitemap-crawl-state.js +57 -39
- package/dist/runtime/server/utils/sitemap-lastmod.js +16 -14
- package/dist/runtime/server/utils/sitemap-md.js +39 -50
- package/dist/runtime/server/utils/sitemap-routes.js +7 -7
- package/dist/runtime/server/utils/sitemap.js +459 -414
- package/dist/runtime/server/utils.js +141 -122
- package/dist/runtime/site-tool-catalog.js +39 -43
- package/dist/runtime/site-tool-config.js +1 -0
- package/dist/runtime/sync-secret.js +11 -11
- package/dist/runtime/types.js +1 -0
- package/dist/runtime/webmcp-site-tools.js +278 -250
- package/dist/runtime/webmcp.js +53 -42
- package/dist/static-headers-G7hFL3wE.mjs +328 -0
- package/dist/types.d.mts +1 -9
- package/package.json +20 -24
- package/skills/nuxt-ai-ready/SKILL.md +8 -2
- package/dist/chunks/agent-skills.mjs +0 -383
- package/dist/chunks/prerender.mjs +0 -683
- package/dist/shared/nuxt-ai-ready.Bzx0dNWj.mjs +0 -3034
- package/dist/shared/nuxt-ai-ready.DCd-1s1G.mjs +0 -29
|
@@ -1,103 +1,96 @@
|
|
|
1
|
-
import {
|
|
2
|
-
computed,
|
|
3
|
-
getCurrentInstance,
|
|
4
|
-
onActivated,
|
|
5
|
-
onDeactivated,
|
|
6
|
-
onMounted,
|
|
7
|
-
onScopeDispose,
|
|
8
|
-
ref,
|
|
9
|
-
shallowRef,
|
|
10
|
-
toValue,
|
|
11
|
-
watch
|
|
12
|
-
} from "vue";
|
|
1
|
+
import { computed, getCurrentInstance, onActivated, onDeactivated, onMounted, onScopeDispose, ref, shallowRef, toValue, watch } from "vue";
|
|
13
2
|
import { checkToolBudget, getModelContext, registerTool } from "../../webmcp.js";
|
|
14
3
|
import { getWebMcpDefaults } from "../webmcp-config.js";
|
|
4
|
+
/**
|
|
5
|
+
* Hydration-safe WebMCP support. It stays false through SSR and the first client
|
|
6
|
+
* render, then updates after mount.
|
|
7
|
+
*/
|
|
15
8
|
export function useWebMcpSupported() {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return computed(() => mounted.value && !!getModelContext());
|
|
9
|
+
const inComponent = !!getCurrentInstance();
|
|
10
|
+
const mounted = ref(!inComponent);
|
|
11
|
+
if (inComponent) onMounted(() => mounted.value = true);
|
|
12
|
+
return computed(() => mounted.value && !!getModelContext());
|
|
21
13
|
}
|
|
22
14
|
export function useWebMcpTool(tool, options = {}) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
15
|
+
const inComponent = !!getCurrentInstance();
|
|
16
|
+
const state = shallowRef({ _tag: "Unsupported" });
|
|
17
|
+
const supported = computed(() => state.value._tag !== "Unsupported");
|
|
18
|
+
const defaultExposedTo = getWebMcpDefaults().exposedTo;
|
|
19
|
+
let mounted = !inComponent;
|
|
20
|
+
let active = true;
|
|
21
|
+
let permanentlyDisabled = options.signal?.aborted === true;
|
|
22
|
+
let controller;
|
|
23
|
+
const stopRegistration = () => {
|
|
24
|
+
const current = controller;
|
|
25
|
+
controller = undefined;
|
|
26
|
+
current?.abort();
|
|
27
|
+
state.value = getModelContext() ? { _tag: "Inactive" } : { _tag: "Unsupported" };
|
|
28
|
+
};
|
|
29
|
+
const syncRegistration = () => {
|
|
30
|
+
if (!mounted) return;
|
|
31
|
+
const modelContext = getModelContext();
|
|
32
|
+
if (!modelContext) {
|
|
33
|
+
stopRegistration();
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (!active || permanentlyDisabled || !toValue(options.enabled ?? true)) {
|
|
37
|
+
stopRegistration();
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (controller) return;
|
|
41
|
+
if (import.meta.dev) {
|
|
42
|
+
for (const warning of checkToolBudget(tool)) console.warn(`[nuxt-ai-ready] ${warning}`);
|
|
43
|
+
}
|
|
44
|
+
const current = new AbortController();
|
|
45
|
+
controller = current;
|
|
46
|
+
state.value = { _tag: "Registering" };
|
|
47
|
+
const registerOptions = { signal: current.signal };
|
|
48
|
+
const exposedTo = options.exposedTo ?? defaultExposedTo;
|
|
49
|
+
if (exposedTo?.length) registerOptions.exposedTo = exposedTo;
|
|
50
|
+
void registerTool(modelContext, tool, registerOptions).then((result) => {
|
|
51
|
+
if (controller !== current || current.signal.aborted) return;
|
|
52
|
+
if (result._tag === "Registered") {
|
|
53
|
+
state.value = result;
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
controller = undefined;
|
|
57
|
+
state.value = {
|
|
58
|
+
_tag: "Failed",
|
|
59
|
+
error: result.error
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
const unregister = () => {
|
|
64
|
+
permanentlyDisabled = true;
|
|
65
|
+
stopRegistration();
|
|
66
|
+
};
|
|
67
|
+
const callerSignal = options.signal;
|
|
68
|
+
const abortFromCaller = () => unregister();
|
|
69
|
+
if (callerSignal && !callerSignal.aborted) callerSignal.addEventListener("abort", abortFromCaller, { once: true });
|
|
70
|
+
watch(() => toValue(options.enabled ?? true), syncRegistration);
|
|
71
|
+
if (inComponent) {
|
|
72
|
+
onMounted(() => {
|
|
73
|
+
mounted = true;
|
|
74
|
+
syncRegistration();
|
|
75
|
+
});
|
|
76
|
+
onActivated(() => {
|
|
77
|
+
active = true;
|
|
78
|
+
syncRegistration();
|
|
79
|
+
});
|
|
80
|
+
onDeactivated(() => {
|
|
81
|
+
active = false;
|
|
82
|
+
stopRegistration();
|
|
83
|
+
});
|
|
84
|
+
} else {
|
|
85
|
+
syncRegistration();
|
|
86
|
+
}
|
|
87
|
+
onScopeDispose(() => {
|
|
88
|
+
callerSignal?.removeEventListener("abort", abortFromCaller);
|
|
89
|
+
stopRegistration();
|
|
90
|
+
}, true);
|
|
91
|
+
return {
|
|
92
|
+
supported,
|
|
93
|
+
state,
|
|
94
|
+
unregister
|
|
95
|
+
};
|
|
103
96
|
}
|
|
@@ -1,28 +1,31 @@
|
|
|
1
|
-
import { defineNuxtPlugin, useHead, useRequestEvent, useRequestURL, useRuntimeConfig } from "nuxt/app";
|
|
1
|
+
import { defineNuxtPlugin, useError, useHead, useRequestEvent, useRequestURL, useRuntimeConfig } from "nuxt/app";
|
|
2
2
|
import { joinURL } from "ufo";
|
|
3
3
|
import { markdownAlternatePath } from "../../markdown-path.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
4
|
+
import { toDeployedRoute, toLogicalRoute } from "../../route-path.js";
|
|
5
|
+
export default defineNuxtPlugin({ setup() {
|
|
6
|
+
const error = useError();
|
|
7
|
+
if (error.value) return;
|
|
8
|
+
const url = useRequestURL();
|
|
9
|
+
const runtimeConfig = useRuntimeConfig();
|
|
10
|
+
const baseURL = runtimeConfig.app.baseURL;
|
|
11
|
+
// Skip anything the markdown handler declines: a reserved namespace
|
|
12
|
+
// (including `/__nuxt_error`), or a route that already carries an extension.
|
|
13
|
+
const markdownLogicalPath = markdownAlternatePath(toLogicalRoute(url.pathname, baseURL));
|
|
14
|
+
if (!markdownLogicalPath) return;
|
|
15
|
+
const markdownPath = toDeployedRoute(markdownLogicalPath, baseURL);
|
|
16
|
+
const config = runtimeConfig["nuxt-ai-ready"];
|
|
17
|
+
const describedby = config?.describedby !== false;
|
|
18
|
+
const markdownAvailable = useRequestEvent()?.context.aiReadyMarkdownAvailable !== false;
|
|
19
|
+
const markdownLink = {
|
|
20
|
+
rel: "alternate",
|
|
21
|
+
type: "text/markdown",
|
|
22
|
+
href: markdownPath,
|
|
23
|
+
...import.meta.prerender && config?.zeroRuntimeMarkdown && { "data-ai-ready-markdown": "" }
|
|
24
|
+
};
|
|
25
|
+
const links = [...markdownAvailable ? [markdownLink] : [], ...describedby ? [{
|
|
26
|
+
rel: "describedby",
|
|
27
|
+
href: joinURL(baseURL, "llms.txt")
|
|
28
|
+
}] : []];
|
|
29
|
+
if (!links.length) return;
|
|
30
|
+
useHead(() => error.value ? {} : { link: links });
|
|
31
|
+
} });
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import { defineNuxtPlugin, prerenderRoutes } from "nuxt/app";
|
|
2
2
|
import { markdownAlternatePath } from "../../markdown-path.js";
|
|
3
|
-
export default defineNuxtPlugin({
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
});
|
|
3
|
+
export default defineNuxtPlugin({ setup(nuxtApp) {
|
|
4
|
+
if (!import.meta.prerender) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
nuxtApp.hooks.hook("app:rendered", (ctx) => {
|
|
8
|
+
const url = ctx.ssrContext?.url || "";
|
|
9
|
+
const markdownPath = markdownAlternatePath(url);
|
|
10
|
+
if (!markdownPath || ctx.ssrContext?.error || ctx.ssrContext?.noSSR) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
prerenderRoutes(markdownPath);
|
|
14
|
+
});
|
|
15
|
+
} });
|
|
@@ -3,57 +3,53 @@ import { checkToolBudget, getModelContext, registerTool } from "../../webmcp.js"
|
|
|
3
3
|
import { createSiteTools } from "../../webmcp-site-tools.js";
|
|
4
4
|
import { setWebMcpDefaults } from "../webmcp-config.js";
|
|
5
5
|
export default defineNuxtPlugin({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
console.error(`[nuxt-ai-ready] Failed to register WebMCP tool "${tool.name}".`, result.error);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}
|
|
6
|
+
name: "nuxt-ai-ready:webmcp",
|
|
7
|
+
setup(nuxtApp) {
|
|
8
|
+
const runtimeConfig = useRuntimeConfig();
|
|
9
|
+
const { webmcp } = runtimeConfig.public["nuxt-ai-ready"];
|
|
10
|
+
setWebMcpDefaults(webmcp);
|
|
11
|
+
nuxtApp.hook("app:created", async () => {
|
|
12
|
+
const modelContext = getModelContext();
|
|
13
|
+
if (!modelContext) return;
|
|
14
|
+
const registerOptions = {};
|
|
15
|
+
if (webmcp.exposedTo?.length) registerOptions.exposedTo = webmcp.exposedTo;
|
|
16
|
+
const toolRegisterOptions = {};
|
|
17
|
+
const setExposedTo = (name, exposedTo) => {
|
|
18
|
+
if (exposedTo !== undefined) toolRegisterOptions[name] = { exposedTo };
|
|
19
|
+
};
|
|
20
|
+
setExposedTo("list_pages", webmcp.tools.listPages?.exposedTo);
|
|
21
|
+
setExposedTo("search_pages", webmcp.tools.searchPages?.exposedTo);
|
|
22
|
+
setExposedTo("get_page_markdown", webmcp.tools.getPageMarkdown?.exposedTo);
|
|
23
|
+
const context = {
|
|
24
|
+
tools: createSiteTools({
|
|
25
|
+
baseURL: runtimeConfig.app.baseURL,
|
|
26
|
+
tools: {
|
|
27
|
+
listPages: webmcp.tools.listPages ? {
|
|
28
|
+
defaultLimit: webmcp.tools.listPages.defaultLimit,
|
|
29
|
+
maxOutputChars: webmcp.tools.listPages.maxOutputChars
|
|
30
|
+
} : { enabled: false },
|
|
31
|
+
searchPages: webmcp.tools.searchPages ? {
|
|
32
|
+
defaultLimit: webmcp.tools.searchPages.defaultLimit,
|
|
33
|
+
maxOutputChars: webmcp.tools.searchPages.maxOutputChars
|
|
34
|
+
} : { enabled: false },
|
|
35
|
+
getPageMarkdown: webmcp.tools.getPageMarkdown ? { maxOutputChars: webmcp.tools.getPageMarkdown.maxOutputChars } : { enabled: false }
|
|
36
|
+
}
|
|
37
|
+
}),
|
|
38
|
+
registerOptions,
|
|
39
|
+
toolRegisterOptions
|
|
40
|
+
};
|
|
41
|
+
// Consumer types are generated by the module when WebMCP is enabled.
|
|
42
|
+
await nuxtApp.callHook("ai-ready:webmcp:tools", context);
|
|
43
|
+
for (const tool of context.tools) {
|
|
44
|
+
if (import.meta.dev) {
|
|
45
|
+
for (const warning of checkToolBudget(tool)) console.warn(`[nuxt-ai-ready] ${warning}`);
|
|
46
|
+
}
|
|
47
|
+
const result = await registerTool(modelContext, tool, {
|
|
48
|
+
...context.registerOptions,
|
|
49
|
+
...context.toolRegisterOptions[tool.name]
|
|
50
|
+
});
|
|
51
|
+
if (result._tag === "Error") console.error(`[nuxt-ai-ready] Failed to register WebMCP tool "${tool.name}".`, result.error);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
59
55
|
});
|
|
@@ -1,14 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared `Cache-Control` for public AI-ready endpoints.
|
|
3
|
+
*
|
|
4
|
+
* Freshness goes in `max-age` only. Cloudflare disables stale serving when
|
|
5
|
+
* `s-maxage` is present, so `stale-while-revalidate` would never apply at
|
|
6
|
+
* the edge.
|
|
7
|
+
*/
|
|
1
8
|
export function publicCacheControl(maxAgeSeconds, staleSeconds) {
|
|
2
|
-
|
|
9
|
+
return staleSeconds > 0 ? `public, max-age=${maxAgeSeconds}, stale-while-revalidate=${staleSeconds}` : `public, max-age=${maxAgeSeconds}`;
|
|
3
10
|
}
|
|
11
|
+
/** Merge Vary tokens without removing cache dimensions or duplicating names. */
|
|
4
12
|
export function mergeVaryHeader(current, added) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
return [...unique.values()].join(", ");
|
|
13
|
+
const tokens = [...(current || "").split(","), ...added.split(",")].map((token) => token.trim()).filter(Boolean);
|
|
14
|
+
if (tokens.includes("*")) return "*";
|
|
15
|
+
const unique = new Map();
|
|
16
|
+
for (const token of tokens) {
|
|
17
|
+
if (!unique.has(token.toLowerCase())) unique.set(token.toLowerCase(), token);
|
|
18
|
+
}
|
|
19
|
+
return [...unique.values()].join(", ");
|
|
14
20
|
}
|
package/dist/runtime/i18n-url.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
/** Resolve a locale alternate against its configured domain or the current site. */
|
|
1
2
|
export function resolveLocaleAlternateUrl(alternate, resolveUrl) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return new URL(`${deployed.pathname}${deployed.search}${deployed.hash}`, origin).href;
|
|
3
|
+
const resolved = resolveUrl(alternate.path);
|
|
4
|
+
if (!alternate.domain) return resolved;
|
|
5
|
+
const origin = /^[a-z][a-z\d+.-]*:\/\//i.test(alternate.domain) ? alternate.domain : `https://${alternate.domain}`;
|
|
6
|
+
const deployed = new URL(resolved, "http://nuxtseo.local");
|
|
7
|
+
return new URL(`${deployed.pathname}${deployed.search}${deployed.hash}`, origin).href;
|
|
8
8
|
}
|
package/dist/runtime/index.js
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
|
+
// Database access - Drizzle
|
|
1
2
|
export { closeDrizzle, useDrizzle, useRawDb } from "./server/db/index.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
getStaleRoutes,
|
|
6
|
-
isPageFresh,
|
|
7
|
-
pruneStaleRoutes,
|
|
8
|
-
queryPages,
|
|
9
|
-
searchPages,
|
|
10
|
-
seedRoutes,
|
|
11
|
-
streamPages,
|
|
12
|
-
upsertPage
|
|
13
|
-
} from "./server/db/queries.js";
|
|
3
|
+
// Queries from the full queries module (uses raw SQL internally)
|
|
4
|
+
export { countPages, getPageLastmods, getStaleRoutes, isPageFresh, pruneStaleRoutes, queryPages, searchPages, seedRoutes, streamPages, upsertPage } from "./server/db/queries.js";
|
|
5
|
+
// Server utils - only available in Nitro context
|
|
14
6
|
export { indexPage, indexPageByRoute } from "./server/utils/indexPage.js";
|
|
@@ -1,23 +1,30 @@
|
|
|
1
1
|
const RE_FRONTMATTER = /^\uFEFF?---[\t ]*\r?\n(?:[\s\S]*?\r?\n)?---[\t ]*(?:\r?\n|$)/;
|
|
2
|
+
/** The line that points a reader of one page at the whole site's index. */
|
|
2
3
|
export function llmsTxtDirective(llmsTxtUrl) {
|
|
3
|
-
|
|
4
|
+
return `> Index of every page on this site: [llms.txt](${llmsTxtUrl})`;
|
|
4
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* Add the llms.txt directive near the top of a page's Markdown, after any
|
|
8
|
+
* frontmatter so YAML parsers still find it first. An agent that lands on one
|
|
9
|
+
* page then knows where the full index is.
|
|
10
|
+
*/
|
|
5
11
|
export function insertLlmsTxtDirective(markdown, llmsTxtUrl) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
`))
|
|
12
|
-
return markdown;
|
|
13
|
-
return `${frontmatter}${frontmatter ? "\n" : ""}${directive}
|
|
14
|
-
|
|
15
|
-
${body}`;
|
|
12
|
+
const directive = llmsTxtDirective(llmsTxtUrl);
|
|
13
|
+
const frontmatter = markdown.match(RE_FRONTMATTER)?.[0] ?? "";
|
|
14
|
+
const body = markdown.slice(frontmatter.length).replace(/^(?:\r?\n)+/, "");
|
|
15
|
+
if (body === directive || body.startsWith(`${directive}\n`) || body.startsWith(`${directive}\r\n`)) return markdown;
|
|
16
|
+
return `${frontmatter}${frontmatter ? "\n" : ""}${directive}\n\n${body}`;
|
|
16
17
|
}
|
|
18
|
+
/** Marks the injected HTML link so Markdown conversion can drop it again. */
|
|
17
19
|
const RE_DIRECTIVE_HTML = /<a [^>]*data-llms-txt-directive[^>]*>[^<]*<\/a>/g;
|
|
20
|
+
/**
|
|
21
|
+
* The HTML equivalent: a link at the top of the body, hidden visually but
|
|
22
|
+
* kept for screen readers and agents that read the raw HTML.
|
|
23
|
+
*/
|
|
18
24
|
export function llmsTxtDirectiveHtml(llmsTxtPath) {
|
|
19
|
-
|
|
25
|
+
return `<a href="${llmsTxtPath}" tabindex="-1" style="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0" data-llms-txt-directive>Index of every page on this site: llms.txt</a>`;
|
|
20
26
|
}
|
|
27
|
+
/** Remove the injected HTML link, so a page's Markdown carries the directive once. */
|
|
21
28
|
export function stripLlmsTxtDirectiveHtml(html) {
|
|
22
|
-
|
|
29
|
+
return html.replace(RE_DIRECTIVE_HTML, "");
|
|
23
30
|
}
|