nuxt-ai-ready 3.6.1 → 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 +18 -22
- 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
|
@@ -6,140 +6,159 @@ const RE_NBSP = /\u00A0/g;
|
|
|
6
6
|
const JSON_LD_MAX_BYTES = 65536;
|
|
7
7
|
const JSON_LD_MAX_BLOCKS = 16;
|
|
8
8
|
const IMAGE_META_FIELDS = [
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
"og:image",
|
|
10
|
+
"og:image:url",
|
|
11
|
+
"og:image:secure_url",
|
|
12
|
+
"og:image:type",
|
|
13
|
+
"og:image:width",
|
|
14
|
+
"og:image:height",
|
|
15
|
+
"og:image:alt",
|
|
16
|
+
"twitter:image",
|
|
17
|
+
"twitter:image:src",
|
|
18
|
+
"twitter:image:alt"
|
|
19
19
|
];
|
|
20
20
|
function parseJsonLdBlock(text, remainingBytes) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
21
|
+
// Reject large input before parsing. UTF-8 uses at least one byte per character.
|
|
22
|
+
if (text.length > remainingBytes) return { _tag: "Skipped" };
|
|
23
|
+
const content = text.trim();
|
|
24
|
+
if (!content) return { _tag: "Skipped" };
|
|
25
|
+
let value;
|
|
26
|
+
try {
|
|
27
|
+
value = JSON.parse(text);
|
|
28
|
+
} catch {
|
|
29
|
+
// Malformed optional metadata must not prevent serving the page's Markdown.
|
|
30
|
+
return { _tag: "Skipped" };
|
|
31
|
+
}
|
|
32
|
+
const isObject = (item) => typeof item === "object" && item !== null && !Array.isArray(item);
|
|
33
|
+
if (!isObject(value) && !(Array.isArray(value) && value.every(isObject))) return { _tag: "Skipped" };
|
|
34
|
+
// Preserve numbers without reserialization. Escape NBSP before prose normalization.
|
|
35
|
+
const markdown = `\`\`\`json\n${content.replace(RE_NBSP, "\\u00a0")}\n\`\`\``;
|
|
36
|
+
const bytes = new TextEncoder().encode(markdown).byteLength + 2;
|
|
37
|
+
if (bytes > remainingBytes) return { _tag: "Skipped" };
|
|
38
|
+
return {
|
|
39
|
+
_tag: "Preserved",
|
|
40
|
+
markdown,
|
|
41
|
+
bytes
|
|
42
|
+
};
|
|
42
43
|
}
|
|
44
|
+
// Replace NBSP (U+00A0) with regular spaces to avoid encoding display issues
|
|
43
45
|
function normalizeWhitespace(text) {
|
|
44
|
-
|
|
46
|
+
return text.replace(RE_NBSP, " ");
|
|
45
47
|
}
|
|
48
|
+
// Build mdream options with extraction plugin
|
|
46
49
|
function buildMdreamOptions(url, mdreamOptions, meta, extractUpdatedAt, additionalFields) {
|
|
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
|
-
|
|
50
|
+
// title and description come from mdream's frontmatter callback below; the
|
|
51
|
+
// extraction selectors below sometimes fire with empty textContent and would
|
|
52
|
+
// clobber the values, so we don't register them here.
|
|
53
|
+
const extraction = {
|
|
54
|
+
"script[type]": (el) => {
|
|
55
|
+
if (el.attributes.type?.trim().toLowerCase() !== "application/ld+json" || meta.jsonLd.blocks.length >= JSON_LD_MAX_BLOCKS) return;
|
|
56
|
+
const block = parseJsonLdBlock(el.textContent, JSON_LD_MAX_BYTES - meta.jsonLd.bytes);
|
|
57
|
+
if (block._tag === "Preserved") {
|
|
58
|
+
meta.jsonLd.blocks.push(block.markdown);
|
|
59
|
+
meta.jsonLd.bytes += block.bytes;
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"meta[name=\"keywords\"]": (el) => {
|
|
63
|
+
meta.metaKeywords = el.attributes.content || "";
|
|
64
|
+
},
|
|
65
|
+
"h1, h2, h3, h4, h5, h6": (el) => {
|
|
66
|
+
const text = el.textContent?.trim();
|
|
67
|
+
if (text) meta.headings.push({ [el.tagName.toLowerCase()]: text });
|
|
68
|
+
},
|
|
69
|
+
"p, li, td, th, blockquote, figcaption": (el) => {
|
|
70
|
+
const text = el.textContent?.trim();
|
|
71
|
+
if (text) meta.textContent.push(text);
|
|
72
|
+
},
|
|
73
|
+
...extractUpdatedAt && { "meta[property=\"article:modified_time\"], meta[name=\"last-modified\"], meta[name=\"updated\"], meta[property=\"og:updated_time\"], meta[name=\"lastmod\"]": (el) => {
|
|
74
|
+
if (!meta.updatedAt && el.attributes.content) meta.updatedAt = el.attributes.content;
|
|
75
|
+
} }
|
|
76
|
+
};
|
|
77
|
+
// Pair mdream's `additionalFields` with `onExtract` so the engine owns the
|
|
78
|
+
// YAML emission while still surfacing extracted data back to us. The
|
|
79
|
+
// additional fields land at the root of the frontmatter, where Vercel's
|
|
80
|
+
// agent-readability audit looks for canonical_url and last_updated.
|
|
81
|
+
const frontmatter = {
|
|
82
|
+
additionalFields,
|
|
83
|
+
metaFields: [...IMAGE_META_FIELDS],
|
|
84
|
+
onExtract: (fm) => {
|
|
85
|
+
if (fm.title) meta.title = fm.title;
|
|
86
|
+
if (fm.description) meta.description = fm.description;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
// Use just the origin (not full URL) so absolute paths like /docs/foo resolve correctly
|
|
90
|
+
const origin = new URL(url).origin;
|
|
91
|
+
return {
|
|
92
|
+
origin,
|
|
93
|
+
...mdreamOptions,
|
|
94
|
+
frontmatter,
|
|
95
|
+
extraction: {
|
|
96
|
+
...extraction,
|
|
97
|
+
...mdreamOptions?.extraction
|
|
98
|
+
}
|
|
99
|
+
};
|
|
94
100
|
}
|
|
101
|
+
// Pull the most recent `last_updated` candidate from the HTML head. Used to
|
|
102
|
+
// populate mdream's `additionalFields` before conversion (mdream's extraction
|
|
103
|
+
// callbacks fire mid-conversion, too late to feed back into additionalFields).
|
|
95
104
|
const RE_META_TAG = /<meta\b[^>]*>/gi;
|
|
96
105
|
const RE_META_KEY = /(?:property|name)=["']([^"']+)["']/i;
|
|
97
106
|
const RE_META_CONTENT = /content=["']([^"']*)["']/i;
|
|
98
|
-
const UPDATED_META_KEYS =
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
107
|
+
const UPDATED_META_KEYS = new Set([
|
|
108
|
+
"article:modified_time",
|
|
109
|
+
"og:updated_time",
|
|
110
|
+
"last-modified",
|
|
111
|
+
"lastmod",
|
|
112
|
+
"updated"
|
|
104
113
|
]);
|
|
105
114
|
export function extractLastUpdated(html) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
return void 0;
|
|
115
|
+
RE_META_TAG.lastIndex = 0;
|
|
116
|
+
let m;
|
|
117
|
+
// eslint-disable-next-line no-cond-assign
|
|
118
|
+
while ((m = RE_META_TAG.exec(html)) !== null) {
|
|
119
|
+
const tag = m[0];
|
|
120
|
+
const key = RE_META_KEY.exec(tag)?.[1];
|
|
121
|
+
if (!key || !UPDATED_META_KEYS.has(key)) continue;
|
|
122
|
+
const content = RE_META_CONTENT.exec(tag)?.[1];
|
|
123
|
+
if (content) return content;
|
|
124
|
+
}
|
|
125
|
+
return undefined;
|
|
118
126
|
}
|
|
127
|
+
// Convert HTML to Markdown through the Nitro conversion hooks
|
|
119
128
|
export async function convertHtmlToMarkdown(html, url, mdreamOptions, opts) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
129
|
+
const meta = {
|
|
130
|
+
title: "",
|
|
131
|
+
description: "",
|
|
132
|
+
metaKeywords: "",
|
|
133
|
+
headings: [],
|
|
134
|
+
textContent: [],
|
|
135
|
+
jsonLd: {
|
|
136
|
+
blocks: [],
|
|
137
|
+
bytes: 0
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
const options = buildMdreamOptions(url, mdreamOptions, meta, opts.extractUpdatedAt ?? false, opts.additionalFrontmatter ?? {});
|
|
141
|
+
const nitroApp = useNitroApp();
|
|
142
|
+
await nitroApp.hooks.callHook("ai-ready:mdreamConfig", options);
|
|
143
|
+
const convertedMarkdown = hoistMetaDescription(htmlToMarkdown(stripLlmsTxtDirectiveHtml(html), options));
|
|
144
|
+
const context = {
|
|
145
|
+
html,
|
|
146
|
+
markdown: [convertedMarkdown, ...meta.jsonLd.blocks].join("\n\n"),
|
|
147
|
+
route: opts.hooks.route,
|
|
148
|
+
title: meta.title,
|
|
149
|
+
description: meta.description,
|
|
150
|
+
isPrerender: opts.hooks.isPrerender,
|
|
151
|
+
event: opts.hooks.event
|
|
152
|
+
};
|
|
153
|
+
await nitroApp.hooks.callHook("ai-ready:page:markdown", context);
|
|
154
|
+
const markdown = context.markdown;
|
|
155
|
+
return {
|
|
156
|
+
markdown: normalizeWhitespace(markdown),
|
|
157
|
+
title: normalizeWhitespace(meta.title),
|
|
158
|
+
description: normalizeWhitespace(meta.description),
|
|
159
|
+
headings: meta.headings,
|
|
160
|
+
metaKeywords: meta.metaKeywords,
|
|
161
|
+
textContent: meta.textContent.join(" "),
|
|
162
|
+
...meta.updatedAt && { updatedAt: meta.updatedAt }
|
|
163
|
+
};
|
|
145
164
|
}
|
|
@@ -1,52 +1,48 @@
|
|
|
1
1
|
export const SITE_TOOL_NAMES = [
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
"list_pages",
|
|
3
|
+
"search_pages",
|
|
4
|
+
"get_page_markdown"
|
|
5
5
|
];
|
|
6
6
|
export const SITE_TOOL_CATALOG = {
|
|
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
|
-
}
|
|
7
|
+
list_pages: {
|
|
8
|
+
name: "list_pages",
|
|
9
|
+
title: "List pages",
|
|
10
|
+
description: "Lists pages on this site with their route, title and description. Use it to see what the site covers before reading a page.",
|
|
11
|
+
parameters: {
|
|
12
|
+
limit: "How many pages to return.",
|
|
13
|
+
offset: "How many pages to skip, for paging through long sites."
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
search_pages: {
|
|
17
|
+
name: "search_pages",
|
|
18
|
+
title: "Search pages",
|
|
19
|
+
description: "Searches the full content of this site and returns the best matching pages with their route, title and description. Takes a plain language query.",
|
|
20
|
+
parameters: {
|
|
21
|
+
query: "Words or a phrase to search for, such as \"refund policy\".",
|
|
22
|
+
limit: "How many results to return."
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
get_page_markdown: {
|
|
26
|
+
name: "get_page_markdown",
|
|
27
|
+
title: "Read page",
|
|
28
|
+
description: "Reads a page of this site as markdown. Pass a route returned by list_pages or search_pages, such as /about.",
|
|
29
|
+
parameters: { route: "Site route to read, such as /blog/hello-world." }
|
|
30
|
+
}
|
|
33
31
|
};
|
|
34
32
|
const RE_LEADING_SLASHES = /^\/+/;
|
|
35
33
|
const RE_MARKDOWN_SUFFIX = /\.md$/;
|
|
36
34
|
const RE_QUERY_OR_FRAGMENT = /[?#].*$/;
|
|
37
35
|
export function normalizeSiteRoute(input) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return void 0;
|
|
51
|
-
return route;
|
|
36
|
+
const value = String(input ?? "").trim().replace(RE_QUERY_OR_FRAGMENT, "");
|
|
37
|
+
if (!value || value.includes("://") || value.includes("\\")) return undefined;
|
|
38
|
+
const route = `/${value.replace(RE_LEADING_SLASHES, "").replace(RE_MARKDOWN_SUFFIX, "")}`;
|
|
39
|
+
const decodedRoute = (() => {
|
|
40
|
+
try {
|
|
41
|
+
return decodeURIComponent(route);
|
|
42
|
+
} catch {
|
|
43
|
+
return "";
|
|
44
|
+
}
|
|
45
|
+
})();
|
|
46
|
+
if (!decodedRoute || decodedRoute.split("/").some((segment) => segment === "." || segment === "..")) return undefined;
|
|
47
|
+
return route;
|
|
52
48
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export const RUNTIME_SYNC_SECRET_PURPOSE = "nuxt-ai-ready:runtime-sync";
|
|
2
2
|
export const APPLICATION_SECRET_ERROR = "Set NUXT_APP_SECRET to a string with at least 32 characters. Generate one with openssl rand -base64 32.";
|
|
3
3
|
export const LEGACY_RUNTIME_SYNC_SECRET_WARNING = "runtimeSyncSecret and NUXT_AI_READY_RUNTIME_SYNC_SECRET are deprecated. Set NUXT_APP_SECRET. Refresh scheduler tokens with `nuxt-ai-ready token`.";
|
|
4
|
+
/** Nuxt deriveSecret's HKDF, for the CLI and event-bound Worker secrets. */
|
|
4
5
|
export async function deriveRuntimeSyncSecret(root) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return Array.from(new Uint8Array(bits), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
6
|
+
if (typeof root !== "string" || root.length < 32) throw new Error(APPLICATION_SECRET_ERROR);
|
|
7
|
+
const encoder = new TextEncoder();
|
|
8
|
+
const key = await crypto.subtle.importKey("raw", encoder.encode(root), "HKDF", false, ["deriveBits"]);
|
|
9
|
+
const bits = await crypto.subtle.deriveBits({
|
|
10
|
+
name: "HKDF",
|
|
11
|
+
hash: "SHA-256",
|
|
12
|
+
salt: encoder.encode("nuxt"),
|
|
13
|
+
info: encoder.encode(RUNTIME_SYNC_SECRET_PURPOSE)
|
|
14
|
+
}, key, 256);
|
|
15
|
+
return Array.from(new Uint8Array(bits), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
16
16
|
}
|
package/dist/runtime/types.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|