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.
Files changed (161) hide show
  1. package/dist/agent-skills-config-CmZq9uWW.mjs +18 -0
  2. package/dist/agent-skills-zGLgFB6H.mjs +468 -0
  3. package/dist/cli.d.mts +1 -0
  4. package/dist/cli.mjs +656 -570
  5. package/dist/devtools/pages/ai-ready/debug.vue +9 -3
  6. package/dist/devtools/pages/ai-ready/index.vue +3 -1
  7. package/dist/devtools/pages/ai-ready/llms-txt.vue +15 -4
  8. package/dist/devtools/pages/ai-ready.vue +28 -4
  9. package/dist/module.d.mts +106 -112
  10. package/dist/module.json +3 -3
  11. package/dist/module.mjs +2732 -26
  12. package/dist/package-metadata-B1darl8W.mjs +28 -0
  13. package/dist/prerender-QMv07W4h.mjs +650 -0
  14. package/dist/runtime/app/composables/webmcp.js +90 -97
  15. package/dist/runtime/app/plugins/md-alternate.server.js +29 -26
  16. package/dist/runtime/app/plugins/md-hints.prerender.js +13 -15
  17. package/dist/runtime/app/plugins/webmcp.client.js +49 -53
  18. package/dist/runtime/app/webmcp-config.js +2 -2
  19. package/dist/runtime/cache-control.js +16 -10
  20. package/dist/runtime/i18n-url.js +6 -6
  21. package/dist/runtime/index.js +4 -12
  22. package/dist/runtime/llms-txt-directive.js +20 -13
  23. package/dist/runtime/llms-txt-files.js +188 -187
  24. package/dist/runtime/llms-txt-format.js +54 -55
  25. package/dist/runtime/llms-txt-i18n.js +22 -19
  26. package/dist/runtime/llms-txt-utils.js +140 -95
  27. package/dist/runtime/markdown-links.js +45 -39
  28. package/dist/runtime/markdown-path.js +29 -9
  29. package/dist/runtime/markdown-text.js +2 -1
  30. package/dist/runtime/mcp.js +5 -1
  31. package/dist/runtime/route-path.js +14 -8
  32. package/dist/runtime/server/db/drizzle/client.js +71 -75
  33. package/dist/runtime/server/db/drizzle/index.js +16 -28
  34. package/dist/runtime/server/db/drizzle/providers/bun.d.ts +2 -1
  35. package/dist/runtime/server/db/drizzle/providers/bun.js +10 -7
  36. package/dist/runtime/server/db/drizzle/providers/d1.js +16 -13
  37. package/dist/runtime/server/db/drizzle/providers/dbPath.js +60 -37
  38. package/dist/runtime/server/db/drizzle/providers/libsql.js +23 -11
  39. package/dist/runtime/server/db/drizzle/providers/neon.js +13 -10
  40. package/dist/runtime/server/db/drizzle/providers/node-sqlite.js +10 -7
  41. package/dist/runtime/server/db/drizzle/providers/postgres.js +13 -10
  42. package/dist/runtime/server/db/drizzle/queries.js +633 -532
  43. package/dist/runtime/server/db/drizzle/raw.js +200 -176
  44. package/dist/runtime/server/db/index.js +3 -0
  45. package/dist/runtime/server/db/queries.js +816 -607
  46. package/dist/runtime/server/db/schema/postgres.js +56 -50
  47. package/dist/runtime/server/db/schema/sqlite.js +56 -50
  48. package/dist/runtime/server/db/schema-sql.js +35 -38
  49. package/dist/runtime/server/db/seed.js +60 -45
  50. package/dist/runtime/server/db/shared.js +300 -213
  51. package/dist/runtime/server/index.js +1 -17
  52. package/dist/runtime/server/mcp/cache-key.js +5 -1
  53. package/dist/runtime/server/mcp/resources/pages.js +32 -33
  54. package/dist/runtime/server/mcp/tools/get-page-markdown.js +41 -27
  55. package/dist/runtime/server/mcp/tools/list-pages.js +40 -34
  56. package/dist/runtime/server/mcp/tools/search-pages.js +24 -16
  57. package/dist/runtime/server/middleware/markdown.d.ts +1 -1
  58. package/dist/runtime/server/middleware/markdown.js +15 -13
  59. package/dist/runtime/server/middleware/markdown.prerender.d.ts +1 -1
  60. package/dist/runtime/server/middleware/markdown.prerender.js +135 -119
  61. package/dist/runtime/server/middleware/render-markdown.d.ts +1 -1
  62. package/dist/runtime/server/middleware/render-markdown.js +164 -144
  63. package/dist/runtime/server/plugins/ai-terms.d.ts +1 -1
  64. package/dist/runtime/server/plugins/ai-terms.js +4 -8
  65. package/dist/runtime/server/plugins/content-signal-capture-nitro3.prerender.d.ts +1 -1
  66. package/dist/runtime/server/plugins/content-signal-capture-nitro3.prerender.js +7 -8
  67. package/dist/runtime/server/plugins/content-signal-capture.prerender.d.ts +1 -1
  68. package/dist/runtime/server/plugins/content-signal-capture.prerender.js +7 -7
  69. package/dist/runtime/server/plugins/db-lifecycle-nitro3.d.ts +1 -1
  70. package/dist/runtime/server/plugins/db-lifecycle-nitro3.js +13 -14
  71. package/dist/runtime/server/plugins/db-lifecycle.js +13 -11
  72. package/dist/runtime/server/plugins/html-capture.prerender.js +6 -6
  73. package/dist/runtime/server/plugins/link-header-nitro3.d.ts +1 -1
  74. package/dist/runtime/server/plugins/link-header-nitro3.js +23 -13
  75. package/dist/runtime/server/plugins/link-header.d.ts +1 -1
  76. package/dist/runtime/server/plugins/link-header.js +30 -30
  77. package/dist/runtime/server/plugins/llms-txt-directive-html.d.ts +1 -1
  78. package/dist/runtime/server/plugins/llms-txt-directive-html.js +4 -3
  79. package/dist/runtime/server/plugins/markdown-negotiation.d.ts +1 -1
  80. package/dist/runtime/server/plugins/markdown-negotiation.js +64 -45
  81. package/dist/runtime/server/plugins/sitemap-seeder.js +144 -112
  82. package/dist/runtime/server/routes/__ai-ready/cron.get.d.ts +1 -1
  83. package/dist/runtime/server/routes/__ai-ready/cron.get.js +17 -11
  84. package/dist/runtime/server/routes/__ai-ready/devtools.get.d.ts +1 -1
  85. package/dist/runtime/server/routes/__ai-ready/devtools.get.js +60 -45
  86. package/dist/runtime/server/routes/__ai-ready/pages.get.d.ts +36 -1
  87. package/dist/runtime/server/routes/__ai-ready/pages.get.js +44 -40
  88. package/dist/runtime/server/routes/__ai-ready/poll.post.d.ts +15 -1
  89. package/dist/runtime/server/routes/__ai-ready/poll.post.js +30 -30
  90. package/dist/runtime/server/routes/__ai-ready/prune.post.d.ts +13 -1
  91. package/dist/runtime/server/routes/__ai-ready/prune.post.js +29 -15
  92. package/dist/runtime/server/routes/__ai-ready/reindex.post.d.ts +22 -1
  93. package/dist/runtime/server/routes/__ai-ready/reindex.post.js +31 -21
  94. package/dist/runtime/server/routes/__ai-ready/restore.post.d.ts +4 -1
  95. package/dist/runtime/server/routes/__ai-ready/restore.post.js +28 -22
  96. package/dist/runtime/server/routes/__ai-ready/status.get.d.ts +1 -1
  97. package/dist/runtime/server/routes/__ai-ready/status.get.js +52 -53
  98. package/dist/runtime/server/routes/__ai-ready-debug.get.d.ts +83 -1
  99. package/dist/runtime/server/routes/__ai-ready-debug.get.js +209 -189
  100. package/dist/runtime/server/routes/agent-skills-artifact.d.ts +1 -1
  101. package/dist/runtime/server/routes/agent-skills-artifact.js +16 -14
  102. package/dist/runtime/server/routes/agent-skills-index.d.ts +1 -1
  103. package/dist/runtime/server/routes/agent-skills-index.js +8 -6
  104. package/dist/runtime/server/routes/ai-catalog.js +19 -19
  105. package/dist/runtime/server/routes/ai-terms.js +23 -19
  106. package/dist/runtime/server/routes/api-catalog.js +23 -23
  107. package/dist/runtime/server/routes/llms-full.txt.get.d.ts +1 -1
  108. package/dist/runtime/server/routes/llms-full.txt.get.js +42 -41
  109. package/dist/runtime/server/routes/llms.txt.get.d.ts +1 -1
  110. package/dist/runtime/server/routes/llms.txt.get.js +38 -33
  111. package/dist/runtime/server/routes/mcp-server-card.js +19 -19
  112. package/dist/runtime/server/routes/sitemap.md.get.d.ts +1 -1
  113. package/dist/runtime/server/routes/sitemap.md.get.js +38 -39
  114. package/dist/runtime/server/tasks/ai-ready-cron.d.ts +1 -1
  115. package/dist/runtime/server/tasks/ai-ready-cron.js +17 -14
  116. package/dist/runtime/server/utils/auth.js +76 -53
  117. package/dist/runtime/server/utils/batchIndex.js +72 -60
  118. package/dist/runtime/server/utils/checkStale.js +181 -134
  119. package/dist/runtime/server/utils/cloudflare-prerendered.js +23 -20
  120. package/dist/runtime/server/utils/cloudflare.js +69 -51
  121. package/dist/runtime/server/utils/content-negotiation.js +30 -18
  122. package/dist/runtime/server/utils/content.js +4 -1
  123. package/dist/runtime/server/utils/context.js +30 -19
  124. package/dist/runtime/server/utils/cron-plan.js +6 -6
  125. package/dist/runtime/server/utils/discovery-response.js +5 -6
  126. package/dist/runtime/server/utils/fetch.js +2 -1
  127. package/dist/runtime/server/utils/frontmatter.js +44 -57
  128. package/dist/runtime/server/utils/i18n.js +3 -8
  129. package/dist/runtime/server/utils/indexPage.js +152 -113
  130. package/dist/runtime/server/utils/keywords.js +278 -277
  131. package/dist/runtime/server/utils/link-header.js +67 -56
  132. package/dist/runtime/server/utils/llms-full.js +39 -49
  133. package/dist/runtime/server/utils/markdown-redirect.js +26 -14
  134. package/dist/runtime/server/utils/markdown-request.js +62 -47
  135. package/dist/runtime/server/utils/negotiation-decision.d.ts +8 -0
  136. package/dist/runtime/server/utils/negotiation-decision.js +106 -34
  137. package/dist/runtime/server/utils/negotiation-response.d.ts +1 -1
  138. package/dist/runtime/server/utils/negotiation-response.js +195 -144
  139. package/dist/runtime/server/utils/page-updated-at.js +23 -15
  140. package/dist/runtime/server/utils/prerender-html.js +31 -17
  141. package/dist/runtime/server/utils/runCron.js +263 -192
  142. package/dist/runtime/server/utils/sitemap-crawl-state.js +57 -39
  143. package/dist/runtime/server/utils/sitemap-lastmod.js +16 -14
  144. package/dist/runtime/server/utils/sitemap-md.js +39 -50
  145. package/dist/runtime/server/utils/sitemap-routes.js +7 -7
  146. package/dist/runtime/server/utils/sitemap.js +459 -414
  147. package/dist/runtime/server/utils.js +141 -122
  148. package/dist/runtime/site-tool-catalog.js +39 -43
  149. package/dist/runtime/site-tool-config.js +1 -0
  150. package/dist/runtime/sync-secret.js +11 -11
  151. package/dist/runtime/types.js +1 -0
  152. package/dist/runtime/webmcp-site-tools.js +278 -250
  153. package/dist/runtime/webmcp.js +53 -42
  154. package/dist/static-headers-G7hFL3wE.mjs +328 -0
  155. package/dist/types.d.mts +1 -9
  156. package/package.json +20 -24
  157. package/skills/nuxt-ai-ready/SKILL.md +8 -2
  158. package/dist/chunks/agent-skills.mjs +0 -383
  159. package/dist/chunks/prerender.mjs +0 -683
  160. package/dist/shared/nuxt-ai-ready.Bzx0dNWj.mjs +0 -3034
  161. 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
- "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"
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
- if (text.length > remainingBytes)
22
- return { _tag: "Skipped" };
23
- const content = text.trim();
24
- if (!content)
25
- return { _tag: "Skipped" };
26
- let value;
27
- try {
28
- value = JSON.parse(text);
29
- } catch {
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)))
34
- return { _tag: "Skipped" };
35
- const markdown = `\`\`\`json
36
- ${content.replace(RE_NBSP, "\\u00a0")}
37
- \`\`\``;
38
- const bytes = new TextEncoder().encode(markdown).byteLength + 2;
39
- if (bytes > remainingBytes)
40
- return { _tag: "Skipped" };
41
- return { _tag: "Preserved", markdown, bytes };
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
- return text.replace(RE_NBSP, " ");
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
- const extraction = {
48
- "script[type]": (el) => {
49
- if (el.attributes.type?.trim().toLowerCase() !== "application/ld+json" || meta.jsonLd.blocks.length >= JSON_LD_MAX_BLOCKS)
50
- return;
51
- const block = parseJsonLdBlock(el.textContent, JSON_LD_MAX_BYTES - meta.jsonLd.bytes);
52
- if (block._tag === "Preserved") {
53
- meta.jsonLd.blocks.push(block.markdown);
54
- meta.jsonLd.bytes += block.bytes;
55
- }
56
- },
57
- 'meta[name="keywords"]': (el) => {
58
- meta.metaKeywords = el.attributes.content || "";
59
- },
60
- "h1, h2, h3, h4, h5, h6": (el) => {
61
- const text = el.textContent?.trim();
62
- if (text)
63
- meta.headings.push({ [el.tagName.toLowerCase()]: text });
64
- },
65
- "p, li, td, th, blockquote, figcaption": (el) => {
66
- const text = el.textContent?.trim();
67
- if (text)
68
- meta.textContent.push(text);
69
- },
70
- ...extractUpdatedAt && {
71
- 'meta[property="article:modified_time"], meta[name="last-modified"], meta[name="updated"], meta[property="og:updated_time"], meta[name="lastmod"]': (el) => {
72
- if (!meta.updatedAt && el.attributes.content)
73
- meta.updatedAt = el.attributes.content;
74
- }
75
- }
76
- };
77
- const frontmatter = {
78
- additionalFields,
79
- metaFields: [...IMAGE_META_FIELDS],
80
- onExtract: (fm) => {
81
- if (fm.title)
82
- meta.title = fm.title;
83
- if (fm.description)
84
- meta.description = fm.description;
85
- }
86
- };
87
- const origin = new URL(url).origin;
88
- return {
89
- origin,
90
- ...mdreamOptions,
91
- frontmatter,
92
- extraction: { ...extraction, ...mdreamOptions?.extraction }
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 = /* @__PURE__ */ new Set([
99
- "article:modified_time",
100
- "og:updated_time",
101
- "last-modified",
102
- "lastmod",
103
- "updated"
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
- RE_META_TAG.lastIndex = 0;
107
- let m;
108
- while ((m = RE_META_TAG.exec(html)) !== null) {
109
- const tag = m[0];
110
- const key = RE_META_KEY.exec(tag)?.[1];
111
- if (!key || !UPDATED_META_KEYS.has(key))
112
- continue;
113
- const content = RE_META_CONTENT.exec(tag)?.[1];
114
- if (content)
115
- return content;
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
- const meta = { title: "", description: "", metaKeywords: "", headings: [], textContent: [], jsonLd: { blocks: [], bytes: 0 } };
121
- const options = buildMdreamOptions(url, mdreamOptions, meta, opts.extractUpdatedAt ?? false, opts.additionalFrontmatter ?? {});
122
- const nitroApp = useNitroApp();
123
- await nitroApp.hooks.callHook("ai-ready:mdreamConfig", options);
124
- const convertedMarkdown = hoistMetaDescription(htmlToMarkdown(stripLlmsTxtDirectiveHtml(html), options));
125
- const context = {
126
- html,
127
- markdown: [convertedMarkdown, ...meta.jsonLd.blocks].join("\n\n"),
128
- route: opts.hooks.route,
129
- title: meta.title,
130
- description: meta.description,
131
- isPrerender: opts.hooks.isPrerender,
132
- event: opts.hooks.event
133
- };
134
- await nitroApp.hooks.callHook("ai-ready:page:markdown", context);
135
- const markdown = context.markdown;
136
- return {
137
- markdown: normalizeWhitespace(markdown),
138
- title: normalizeWhitespace(meta.title),
139
- description: normalizeWhitespace(meta.description),
140
- headings: meta.headings,
141
- metaKeywords: meta.metaKeywords,
142
- textContent: meta.textContent.join(" "),
143
- ...meta.updatedAt && { updatedAt: meta.updatedAt }
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
- "list_pages",
3
- "search_pages",
4
- "get_page_markdown"
2
+ "list_pages",
3
+ "search_pages",
4
+ "get_page_markdown"
5
5
  ];
6
6
  export const SITE_TOOL_CATALOG = {
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: {
30
- route: "Site route to read, such as /blog/hello-world."
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
- const value = String(input ?? "").trim().replace(RE_QUERY_OR_FRAGMENT, "");
39
- if (!value || value.includes("://") || value.includes("\\"))
40
- return void 0;
41
- const route = `/${value.replace(RE_LEADING_SLASHES, "").replace(RE_MARKDOWN_SUFFIX, "")}`;
42
- const decodedRoute = (() => {
43
- try {
44
- return decodeURIComponent(route);
45
- } catch {
46
- return "";
47
- }
48
- })();
49
- if (!decodedRoute || decodedRoute.split("/").some((segment) => segment === "." || segment === ".."))
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
- if (typeof root !== "string" || root.length < 32)
6
- 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("");
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
  }
@@ -0,0 +1 @@
1
+ export {};