nuxt-ai-ready 2.5.3 → 3.0.1
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 +13 -12
- package/dist/chunks/agent-skills.mjs +35 -12
- package/dist/chunks/prerender.mjs +35 -24
- package/dist/cli.mjs +5 -2
- package/dist/module.d.mts +4 -0
- package/dist/module.json +2 -2
- package/dist/module.mjs +8 -4
- package/dist/runtime/app/index.d.ts +3 -0
- package/dist/runtime/app/index.js +2 -0
- package/dist/runtime/cache-control.d.ts +2 -0
- package/dist/runtime/cache-control.js +11 -0
- package/dist/runtime/llms-txt-utils.js +1 -1
- package/dist/runtime/server/db/context.d.ts +13 -0
- package/dist/runtime/server/db/drizzle/client.d.ts +6 -7
- package/dist/runtime/server/db/drizzle/client.js +13 -2
- package/dist/runtime/server/db/drizzle/providers/bun.d.ts +2 -2
- package/dist/runtime/server/db/drizzle/providers/bun.js +2 -2
- package/dist/runtime/server/db/drizzle/providers/d1.d.ts +2 -2
- package/dist/runtime/server/db/drizzle/providers/d1.js +3 -2
- package/dist/runtime/server/db/drizzle/providers/libsql.d.ts +2 -2
- package/dist/runtime/server/db/drizzle/providers/libsql.js +2 -2
- package/dist/runtime/server/db/drizzle/providers/neon.d.ts +2 -2
- package/dist/runtime/server/db/drizzle/providers/neon.js +2 -2
- package/dist/runtime/server/db/drizzle/providers/node-sqlite.d.ts +2 -2
- package/dist/runtime/server/db/drizzle/providers/node-sqlite.js +2 -2
- package/dist/runtime/server/db/drizzle/providers/postgres.d.ts +2 -2
- package/dist/runtime/server/db/drizzle/providers/postgres.js +2 -2
- package/dist/runtime/server/db/drizzle/queries.d.ts +27 -27
- package/dist/runtime/server/db/drizzle/queries.js +6 -5
- package/dist/runtime/server/db/drizzle/raw.d.ts +2 -6
- package/dist/runtime/server/db/index.d.ts +1 -1
- package/dist/runtime/server/db/index.js +1 -1
- package/dist/runtime/server/db/queries.d.ts +36 -36
- package/dist/runtime/server/db/queries.js +8 -9
- package/dist/runtime/server/db/seed.d.ts +2 -2
- package/dist/runtime/server/db/seed.js +4 -3
- package/dist/runtime/server/db/shared.d.ts +8 -0
- package/dist/runtime/server/db/shared.js +8 -2
- package/dist/runtime/server/index.d.ts +2 -0
- package/dist/runtime/server/index.js +17 -0
- package/dist/runtime/server/mcp/cache-key.js +4 -0
- package/dist/runtime/server/mcp/tools/get-page-markdown.js +3 -2
- package/dist/runtime/server/mcp/tools/list-pages.js +3 -2
- package/dist/runtime/server/mcp/tools/search-pages.js +3 -2
- package/dist/runtime/server/middleware/markdown.prerender.js +1 -1
- package/dist/runtime/server/plugins/db-lifecycle-nitro3.d.ts +2 -0
- package/dist/runtime/server/plugins/db-lifecycle-nitro3.js +16 -0
- package/dist/runtime/server/plugins/html-capture.prerender.js +6 -4
- package/dist/runtime/server/plugins/link-header-nitro3.d.ts +2 -0
- package/dist/runtime/server/plugins/link-header-nitro3.js +20 -0
- package/dist/runtime/server/plugins/link-header.d.ts +6 -0
- package/dist/runtime/server/plugins/link-header.js +7 -11
- package/dist/runtime/server/plugins/markdown-negotiation.js +8 -1
- package/dist/runtime/server/plugins/sitemap-seeder.js +3 -3
- package/dist/runtime/server/routes/agent-skills-artifact.d.ts +1 -1
- package/dist/runtime/server/routes/agent-skills-artifact.js +10 -10
- package/dist/runtime/server/routes/agent-skills-index.d.ts +1 -1
- package/dist/runtime/server/routes/agent-skills-index.js +7 -6
- package/dist/runtime/server/routes/ai-catalog.d.ts +2 -1
- package/dist/runtime/server/routes/ai-catalog.js +7 -8
- package/dist/runtime/server/routes/api-catalog.d.ts +3 -1
- package/dist/runtime/server/routes/api-catalog.js +12 -12
- package/dist/runtime/server/routes/llms-full.txt.get.js +1 -1
- package/dist/runtime/server/routes/mcp-server-card.d.ts +1 -1
- package/dist/runtime/server/routes/mcp-server-card.js +7 -8
- package/dist/runtime/server/utils/checkStale.d.ts +2 -2
- package/dist/runtime/server/utils/cloudflare-prerendered.d.ts +3 -0
- package/dist/runtime/server/utils/cloudflare-prerendered.js +23 -0
- package/dist/runtime/server/utils/cloudflare.d.ts +5 -5
- package/dist/runtime/server/utils/cloudflare.js +31 -7
- package/dist/runtime/server/utils/content-negotiation.d.ts +5 -3
- package/dist/runtime/server/utils/content-negotiation.js +8 -7
- package/dist/runtime/server/utils/context.d.ts +3 -3
- package/dist/runtime/server/utils/context.js +1 -1
- package/dist/runtime/server/utils/discovery-response.d.ts +2 -0
- package/dist/runtime/server/utils/link-header.d.ts +5 -3
- package/dist/runtime/server/utils/link-header.js +26 -2
- package/dist/runtime/server/utils/markdown-request.d.ts +4 -3
- package/dist/runtime/server/utils/markdown-request.js +15 -13
- package/dist/runtime/server/utils/negotiation-decision.d.ts +4 -0
- package/dist/runtime/server/utils/negotiation-decision.js +6 -5
- package/dist/runtime/server/utils/negotiation-response.js +47 -22
- package/dist/runtime/server/utils/prerender-html.d.ts +2 -1
- package/dist/runtime/server/utils/prerender-html.js +3 -1
- package/dist/runtime/types.d.ts +15 -7
- package/dist/shared/nuxt-ai-ready.B3hAuOLQ.mjs +29 -0
- package/dist/shared/{nuxt-ai-ready.CLSWou20.mjs → nuxt-ai-ready.C34F0LJo.mjs} +560 -219
- package/package.json +86 -20
- package/skills/nuxt-ai-ready/SKILL.md +26 -12
- package/skills/nuxt-ai-ready/references/runtime-indexing.md +7 -6
- package/dist/runtime/server/db/drizzle/providers/sqlite.d.ts +0 -8
- package/dist/runtime/server/db/drizzle/providers/sqlite.js +0 -15
- package/node_modules/@mdream/js/LICENSE.md +0 -9
- package/node_modules/@mdream/js/README.md +0 -792
- package/node_modules/@mdream/js/bin/mdream.mjs +0 -2
- package/node_modules/@mdream/js/dist/_chunks/const.mjs +0 -134
- package/node_modules/@mdream/js/dist/_chunks/index.d.mts +0 -9
- package/node_modules/@mdream/js/dist/_chunks/markdown-processor.mjs +0 -1968
- package/node_modules/@mdream/js/dist/_chunks/minimal.d.mts +0 -6
- package/node_modules/@mdream/js/dist/_chunks/parse.mjs +0 -2756
- package/node_modules/@mdream/js/dist/_chunks/plugins.mjs +0 -725
- package/node_modules/@mdream/js/dist/_chunks/resolve-plugins.mjs +0 -44
- package/node_modules/@mdream/js/dist/_chunks/stream.mjs +0 -37
- package/node_modules/@mdream/js/dist/_chunks/types.d.mts +0 -473
- package/node_modules/@mdream/js/dist/cli.d.mts +0 -1
- package/node_modules/@mdream/js/dist/cli.mjs +0 -32
- package/node_modules/@mdream/js/dist/core.d.mts +0 -15
- package/node_modules/@mdream/js/dist/core.mjs +0 -28
- package/node_modules/@mdream/js/dist/index.d.mts +0 -4
- package/node_modules/@mdream/js/dist/index.mjs +0 -58
- package/node_modules/@mdream/js/dist/llms-txt.d.mts +0 -86
- package/node_modules/@mdream/js/dist/llms-txt.mjs +0 -308
- package/node_modules/@mdream/js/dist/negotiate.d.mts +0 -35
- package/node_modules/@mdream/js/dist/negotiate.mjs +0 -121
- package/node_modules/@mdream/js/dist/parse.d.mts +0 -90
- package/node_modules/@mdream/js/dist/parse.mjs +0 -2
- package/node_modules/@mdream/js/dist/plugins.d.mts +0 -85
- package/node_modules/@mdream/js/dist/plugins.mjs +0 -2
- package/node_modules/@mdream/js/dist/preset/minimal.d.mts +0 -2
- package/node_modules/@mdream/js/dist/preset/minimal.mjs +0 -33
- package/node_modules/@mdream/js/dist/splitter.d.mts +0 -18
- package/node_modules/@mdream/js/dist/splitter.mjs +0 -194
- package/node_modules/@mdream/js/package.json +0 -103
- package/node_modules/cac/LICENSE +0 -21
- package/node_modules/cac/README.md +0 -492
- package/node_modules/cac/dist/index.d.ts +0 -196
- package/node_modules/cac/dist/index.js +0 -638
- package/node_modules/cac/package.json +0 -72
- package/node_modules/mdream/LICENSE.md +0 -9
- package/node_modules/mdream/README.md +0 -1091
- package/node_modules/mdream/bin/mdream.mjs +0 -46
- package/node_modules/mdream/dist/browser.d.mts +0 -105
- package/node_modules/mdream/dist/browser.mjs +0 -262
- package/node_modules/mdream/dist/edge.d.mts +0 -100
- package/node_modules/mdream/dist/edge.mjs +0 -250
- package/node_modules/mdream/dist/iife.js +0 -605
- package/node_modules/mdream/dist/index.d.mts +0 -89
- package/node_modules/mdream/dist/index.mjs +0 -184
- package/node_modules/mdream/dist/wasm.d.mts +0 -100
- package/node_modules/mdream/dist/wasm.mjs +0 -140
- package/node_modules/mdream/dist/worker.d.mts +0 -101
- package/node_modules/mdream/dist/worker.mjs +0 -217
- package/node_modules/mdream/napi/index.d.mts +0 -127
- package/node_modules/mdream/napi/index.d.ts +0 -127
- package/node_modules/mdream/napi/index.mjs +0 -725
- package/node_modules/mdream/napi/rust.android-arm-eabi.node +0 -0
- package/node_modules/mdream/napi/rust.android-arm64.node +0 -0
- package/node_modules/mdream/napi/rust.darwin-arm64.node +0 -0
- package/node_modules/mdream/napi/rust.darwin-x64.node +0 -0
- package/node_modules/mdream/napi/rust.freebsd-x64.node +0 -0
- package/node_modules/mdream/napi/rust.linux-arm-gnueabihf.node +0 -0
- package/node_modules/mdream/napi/rust.linux-arm64-gnu.node +0 -0
- package/node_modules/mdream/napi/rust.linux-arm64-musl.node +0 -0
- package/node_modules/mdream/napi/rust.linux-x64-gnu.node +0 -0
- package/node_modules/mdream/napi/rust.linux-x64-musl.node +0 -0
- package/node_modules/mdream/napi/rust.wasi.cjs +0 -2144
- package/node_modules/mdream/napi/rust.wasm32-wasi.wasm +0 -0
- package/node_modules/mdream/napi/rust.win32-arm64-msvc.node +0 -0
- package/node_modules/mdream/napi/rust.win32-x64-msvc.node +0 -0
- package/node_modules/mdream/node_modules/@emnapi/core/LICENSE +0 -21
- package/node_modules/mdream/node_modules/@emnapi/core/README.md +0 -1
- package/node_modules/mdream/node_modules/@emnapi/core/dist/emnapi-core.d.ts +0 -392
- package/node_modules/mdream/node_modules/@emnapi/core/dist/emnapi-core.full.d.ts +0 -392
- package/node_modules/mdream/node_modules/@emnapi/core/dist/emnapi-core.full.js +0 -8351
- package/node_modules/mdream/node_modules/@emnapi/core/dist/emnapi-core.js +0 -7268
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/async-work.d.ts +0 -5
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/async-work.js +0 -843
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/index.d.ts +0 -4
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/index.js +0 -3
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/threadsafe-function.d.ts +0 -5
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/threadsafe-function.js +0 -1010
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/v8.d.ts +0 -5
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/v8.js +0 -1446
- package/node_modules/mdream/node_modules/@emnapi/core/node_modules/@emnapi/wasi-threads/LICENSE +0 -21
- package/node_modules/mdream/node_modules/@emnapi/core/node_modules/@emnapi/wasi-threads/README.md +0 -203
- package/node_modules/mdream/node_modules/@emnapi/core/node_modules/@emnapi/wasi-threads/dist/wasi-threads.d.ts +0 -236
- package/node_modules/mdream/node_modules/@emnapi/core/node_modules/@emnapi/wasi-threads/dist/wasi-threads.js +0 -1086
- package/node_modules/mdream/node_modules/@emnapi/core/node_modules/@emnapi/wasi-threads/package.json +0 -35
- package/node_modules/mdream/node_modules/@emnapi/core/node_modules/@emnapi/wasi-threads/rollup.config.js +0 -6
- package/node_modules/mdream/node_modules/@emnapi/core/package.json +0 -39
- package/node_modules/mdream/node_modules/@emnapi/core/rollup.config.js +0 -60
- package/node_modules/mdream/node_modules/@emnapi/runtime/LICENSE +0 -21
- package/node_modules/mdream/node_modules/@emnapi/runtime/README.md +0 -1
- package/node_modules/mdream/node_modules/@emnapi/runtime/dist/emnapi.d.ts +0 -833
- package/node_modules/mdream/node_modules/@emnapi/runtime/dist/emnapi.js +0 -2306
- package/node_modules/mdream/node_modules/@emnapi/runtime/dist/emnapi.js.map +0 -1
- package/node_modules/mdream/node_modules/@emnapi/runtime/index.cjs +0 -63
- package/node_modules/mdream/node_modules/@emnapi/runtime/package.json +0 -39
- package/node_modules/mdream/node_modules/@emnapi/runtime/rollup.config.js +0 -25
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/LICENSE +0 -21
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/README.md +0 -203
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/dist/wasi-threads.d.ts +0 -240
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/dist/wasi-threads.js +0 -1118
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/package.json +0 -35
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/rollup.config.js +0 -6
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/dist/emnapi-plugins.cjs +0 -1472
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/dist/emnapi-plugins.js +0 -1470
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/dist/fs-proxy.cjs +0 -237
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/dist/fs.js +0 -17578
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/fs-proxy.js +0 -317
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/package.json +0 -67
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/runtime.cjs +0 -39
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/runtime.js +0 -36
- package/node_modules/mdream/node_modules/@tybys/wasm-util/LICENSE +0 -21
- package/node_modules/mdream/node_modules/@tybys/wasm-util/README.md +0 -193
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/tsdoc-metadata.json +0 -11
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.d.ts +0 -423
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.esm-bundler.js +0 -2932
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.esm.js +0 -2932
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.esm.min.js +0 -1
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.js +0 -2954
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.min.js +0 -1
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/asyncify.js +0 -158
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/index.js +0 -13
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/jspi.js +0 -46
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/load.js +0 -97
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/memory.js +0 -35
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/error.js +0 -103
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/fd.js +0 -268
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/fs.js +0 -3
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/index.js +0 -192
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/path.js +0 -316
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/preview1.js +0 -1599
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/rights.js +0 -141
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/types.js +0 -220
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/util.js +0 -128
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/webassembly.js +0 -13
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/asyncify.mjs +0 -153
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/index.mjs +0 -9
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/jspi.mjs +0 -39
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/load.mjs +0 -89
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/memory.mjs +0 -28
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/error.mjs +0 -97
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/fd.mjs +0 -256
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/fs.mjs +0 -1
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/index.mjs +0 -186
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/path.mjs +0 -310
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/preview1.mjs +0 -1593
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/rights.mjs +0 -135
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/types.mjs +0 -216
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/util.mjs +0 -113
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/webassembly.mjs +0 -9
- package/node_modules/mdream/node_modules/@tybys/wasm-util/package.json +0 -58
- package/node_modules/mdream/node_modules/tslib/CopyrightNotice.txt +0 -15
- package/node_modules/mdream/node_modules/tslib/LICENSE.txt +0 -12
- package/node_modules/mdream/node_modules/tslib/README.md +0 -164
- package/node_modules/mdream/node_modules/tslib/SECURITY.md +0 -41
- package/node_modules/mdream/node_modules/tslib/modules/index.d.ts +0 -38
- package/node_modules/mdream/node_modules/tslib/modules/index.js +0 -70
- package/node_modules/mdream/node_modules/tslib/modules/package.json +0 -3
- package/node_modules/mdream/node_modules/tslib/package.json +0 -47
- package/node_modules/mdream/node_modules/tslib/tslib.d.ts +0 -460
- package/node_modules/mdream/node_modules/tslib/tslib.es6.html +0 -1
- package/node_modules/mdream/node_modules/tslib/tslib.es6.js +0 -402
- package/node_modules/mdream/node_modules/tslib/tslib.es6.mjs +0 -401
- package/node_modules/mdream/node_modules/tslib/tslib.html +0 -1
- package/node_modules/mdream/node_modules/tslib/tslib.js +0 -484
- package/node_modules/mdream/package.json +0 -110
- package/node_modules/mdream/skills/mdream/SKILL.md +0 -124
- package/node_modules/mdream/skills/mdream/references/runtimes.md +0 -49
- package/node_modules/mdream/wasm/mdream_edge.d.ts +0 -90
- package/node_modules/mdream/wasm/mdream_edge.js +0 -517
- package/node_modules/mdream/wasm/mdream_edge_bg.wasm +0 -0
- package/node_modules/mdream/wasm/mdream_edge_bg.wasm.d.ts +0 -20
- package/node_modules/mdream/wasm/package.json +0 -17
- package/node_modules/mdream/wasm-bundler/mdream_edge.d.ts +0 -45
- package/node_modules/mdream/wasm-bundler/mdream_edge.js +0 -13
- package/node_modules/mdream/wasm-bundler/mdream_edge_bg.js +0 -413
- package/node_modules/mdream/wasm-bundler/mdream_edge_bg.wasm +0 -0
- package/node_modules/mdream/wasm-bundler/mdream_edge_bg.wasm.d.ts +0 -20
- package/node_modules/mdream/wasm-bundler/package.json +0 -19
- package/node_modules/pathe/LICENSE +0 -70
- package/node_modules/pathe/README.md +0 -73
- package/node_modules/pathe/dist/index.cjs +0 -39
- package/node_modules/pathe/dist/index.d.cts +0 -47
- package/node_modules/pathe/dist/index.d.mts +0 -47
- package/node_modules/pathe/dist/index.d.ts +0 -47
- package/node_modules/pathe/dist/index.mjs +0 -19
- package/node_modules/pathe/dist/shared/pathe.BSlhyZSM.cjs +0 -266
- package/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs +0 -249
- package/node_modules/pathe/dist/utils.cjs +0 -82
- package/node_modules/pathe/dist/utils.d.cts +0 -32
- package/node_modules/pathe/dist/utils.d.mts +0 -32
- package/node_modules/pathe/dist/utils.d.ts +0 -32
- package/node_modules/pathe/dist/utils.mjs +0 -77
- package/node_modules/pathe/package.json +0 -61
- package/node_modules/pathe/utils.d.ts +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export function getContentNegotiationVary(botNegotiation = false) {
|
|
2
|
+
return botNegotiation ? "Accept, Sec-Fetch-Dest, User-Agent" : "Accept";
|
|
3
|
+
}
|
|
4
|
+
function cachesWithoutNegotiationVariation(cache, botNegotiation) {
|
|
4
5
|
if (!cache)
|
|
5
6
|
return false;
|
|
6
7
|
if (typeof cache !== "object")
|
|
@@ -8,16 +9,16 @@ function cachesWithoutNegotiationVariation(cache) {
|
|
|
8
9
|
if (cache.headersOnly)
|
|
9
10
|
return false;
|
|
10
11
|
const varies = new Set(cache.varies?.map((header) => header.toLowerCase()));
|
|
11
|
-
return
|
|
12
|
+
return getContentNegotiationVary(botNegotiation).split(",").some((header) => !varies.has(header.trim().toLowerCase()));
|
|
12
13
|
}
|
|
13
14
|
export function resolveContentNegotiation(input) {
|
|
14
15
|
if (input.policy === "enabled")
|
|
15
|
-
return { _tag: "enabled", source: "explicit" };
|
|
16
|
+
return { _tag: "enabled", source: "explicit", vary: getContentNegotiationVary(input.botNegotiation) };
|
|
16
17
|
if (input.policy === "disabled")
|
|
17
18
|
return { _tag: "disabled", source: "explicit" };
|
|
18
19
|
if (input.routeRule.isr)
|
|
19
20
|
return { _tag: "disabled", source: "isr" };
|
|
20
|
-
if (cachesWithoutNegotiationVariation(input.routeRule.cache))
|
|
21
|
+
if (cachesWithoutNegotiationVariation(input.routeRule.cache, input.botNegotiation === true))
|
|
21
22
|
return { _tag: "disabled", source: "route-cache" };
|
|
22
|
-
return { _tag: "enabled", source: "default" };
|
|
23
|
+
return { _tag: "enabled", source: "default", vary: getContentNegotiationVary(input.botNegotiation) };
|
|
23
24
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AiReadyDatabaseEvent } from '../db/context.js';
|
|
2
2
|
export interface UniversalContext {
|
|
3
3
|
/** Site URL from nuxt-site-config */
|
|
4
4
|
siteUrl: string | undefined;
|
|
@@ -10,8 +10,8 @@ export interface UniversalContext {
|
|
|
10
10
|
* In request context: uses H3Event and nuxt-site-config middleware
|
|
11
11
|
* In scheduled task: rebuilds from build-time site-config stack
|
|
12
12
|
*/
|
|
13
|
-
export declare function createUniversalContext(event:
|
|
13
|
+
export declare function createUniversalContext(event: AiReadyDatabaseEvent | undefined): UniversalContext;
|
|
14
14
|
/**
|
|
15
15
|
* Get site URL from context, throwing if not configured
|
|
16
16
|
*/
|
|
17
|
-
export declare function requireSiteUrl(event:
|
|
17
|
+
export declare function requireSiteUrl(event: AiReadyDatabaseEvent | undefined): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createSiteConfigStack } from "site-config-stack";
|
|
2
2
|
import { useRuntimeConfig } from "#nuxtseo/nitro";
|
|
3
3
|
export function createUniversalContext(event) {
|
|
4
|
-
const runtimeConfig = useRuntimeConfig(
|
|
4
|
+
const runtimeConfig = useRuntimeConfig();
|
|
5
5
|
let siteUrl = runtimeConfig.site?.url || runtimeConfig.public?.site?.url;
|
|
6
6
|
if (!siteUrl) {
|
|
7
7
|
const siteConfigRuntime = runtimeConfig["nuxt-site-config"];
|
|
@@ -16,8 +16,10 @@ interface LinkHeaderConfig {
|
|
|
16
16
|
describedby?: boolean;
|
|
17
17
|
i18n?: RuntimeI18nConfig | null;
|
|
18
18
|
}
|
|
19
|
-
/**
|
|
20
|
-
* Build a comma-joined Link header value with the standard alternates plus i18n hreflang variants.
|
|
21
|
-
*/
|
|
22
19
|
export declare function buildLinkHeader(path: string, variant: 'html' | 'markdown', config: LinkHeaderConfig, resolveUrl?: LinkUrlResolver, routeContext?: RuntimeRouteContext): string;
|
|
20
|
+
/** Resolve request-specific URLs once for both success and error responses. */
|
|
21
|
+
export declare function buildStatusAwareLinkHeaders(path: string, variant: 'html' | 'markdown', config: LinkHeaderConfig, resolveUrl?: LinkUrlResolver, routeContext?: RuntimeRouteContext): {
|
|
22
|
+
error: string;
|
|
23
|
+
success: string;
|
|
24
|
+
};
|
|
23
25
|
export {};
|
|
@@ -14,7 +14,7 @@ function resolveHeaderUrl(path, resolveUrl) {
|
|
|
14
14
|
return path;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
function buildBaseParts(path, variant, config, resolveUrl) {
|
|
18
18
|
const parts = [];
|
|
19
19
|
if (variant === "html") {
|
|
20
20
|
const href = resolveHeaderUrl(toMarkdownPath(path), resolveUrl);
|
|
@@ -28,6 +28,9 @@ export function buildLinkHeader(path, variant, config, resolveUrl, routeContext
|
|
|
28
28
|
const href = resolveHeaderUrl(LLMS_TXT_PATH, resolveUrl);
|
|
29
29
|
parts.push(`<${encodePathForHeader(href)}>; rel="describedby"`);
|
|
30
30
|
}
|
|
31
|
+
return parts;
|
|
32
|
+
}
|
|
33
|
+
function appendLocaleParts(parts, path, variant, config, resolveUrl, routeContext) {
|
|
31
34
|
if (config.i18n) {
|
|
32
35
|
const alternates = computeLocaleAlternates(path, config.i18n, routeContext);
|
|
33
36
|
for (const alt of alternates) {
|
|
@@ -39,8 +42,29 @@ export function buildLinkHeader(path, variant, config, resolveUrl, routeContext
|
|
|
39
42
|
parts.push(`<${encodePathForHeader(href)}>; rel="alternate"; hreflang="${alt.hreflang}"`);
|
|
40
43
|
}
|
|
41
44
|
}
|
|
45
|
+
}
|
|
46
|
+
function appendCatalogPart(parts, config) {
|
|
42
47
|
if (config.apiCatalog) {
|
|
43
|
-
|
|
48
|
+
const catalog = `<${encodePathForHeader(config.apiCatalog.href)}>; rel="api-catalog"`;
|
|
49
|
+
parts.push(catalog);
|
|
50
|
+
return catalog;
|
|
44
51
|
}
|
|
52
|
+
}
|
|
53
|
+
export function buildLinkHeader(path, variant, config, resolveUrl, routeContext = {}) {
|
|
54
|
+
const parts = buildBaseParts(path, variant, config, resolveUrl);
|
|
55
|
+
appendLocaleParts(parts, path, variant, config, resolveUrl, routeContext);
|
|
56
|
+
appendCatalogPart(parts, config);
|
|
45
57
|
return parts.join(", ");
|
|
46
58
|
}
|
|
59
|
+
export function buildStatusAwareLinkHeaders(path, variant, config, resolveUrl, routeContext = {}) {
|
|
60
|
+
const parts = buildBaseParts(path, variant, config, resolveUrl);
|
|
61
|
+
const safeParts = parts.slice();
|
|
62
|
+
const catalog = appendCatalogPart(safeParts, config);
|
|
63
|
+
const error = safeParts.join(", ");
|
|
64
|
+
if (!config.i18n)
|
|
65
|
+
return { error, success: error };
|
|
66
|
+
appendLocaleParts(parts, path, variant, config, resolveUrl, routeContext);
|
|
67
|
+
if (catalog)
|
|
68
|
+
parts.push(catalog);
|
|
69
|
+
return { error, success: parts.join(", ") };
|
|
70
|
+
}
|
|
@@ -13,11 +13,12 @@ export interface MarkdownRequest {
|
|
|
13
13
|
isPrerender: boolean;
|
|
14
14
|
}
|
|
15
15
|
export declare function toMarkdownRequest(event: H3Event, isPrerender?: boolean): MarkdownRequest;
|
|
16
|
-
export declare function negotiateRequestRepresentation(request: MarkdownRequest): ContentNegotiationResult;
|
|
17
|
-
export declare function negotiateRepresentation(event: H3Event): ContentNegotiationResult;
|
|
16
|
+
export declare function negotiateRequestRepresentation(request: MarkdownRequest, botNegotiation?: boolean): ContentNegotiationResult;
|
|
17
|
+
export declare function negotiateRepresentation(event: H3Event, botNegotiation?: boolean): ContentNegotiationResult;
|
|
18
18
|
export type MarkdownRequestMode = {
|
|
19
19
|
_tag: 'runtime';
|
|
20
20
|
contentNegotiation: boolean;
|
|
21
|
+
botNegotiation?: boolean;
|
|
21
22
|
} | {
|
|
22
23
|
_tag: 'prerender';
|
|
23
24
|
};
|
|
@@ -30,4 +31,4 @@ export type MarkdownRenderInfo = {
|
|
|
30
31
|
} | null;
|
|
31
32
|
export declare function getRequestRenderInfo(request: MarkdownRequest, mode?: MarkdownRequestMode): MarkdownRenderInfo;
|
|
32
33
|
export declare function getMarkdownRenderInfo(event: H3Event, mode?: MarkdownRequestMode): MarkdownRenderInfo;
|
|
33
|
-
export declare function clientPrefersMarkdown(event: H3Event): boolean;
|
|
34
|
+
export declare function clientPrefersMarkdown(event: H3Event, botNegotiation?: boolean): boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { negotiateContent } from "@mdream/js/negotiate";
|
|
1
|
+
import { negotiateContent, parseAcceptHeader } from "@mdream/js/negotiate";
|
|
2
2
|
import { getBotInfo } from "@nuxtjs/robots/util";
|
|
3
3
|
import { getHeaders } from "#nuxtseo/h3";
|
|
4
4
|
import { isReservedPath } from "../../markdown-path.js";
|
|
@@ -6,22 +6,24 @@ const RE_MD_EXT = /\.md$/;
|
|
|
6
6
|
export function toMarkdownRequest(event, isPrerender = !!import.meta.prerender) {
|
|
7
7
|
return { path: event.path, headers: getHeaders(event), isPrerender };
|
|
8
8
|
}
|
|
9
|
-
export function negotiateRequestRepresentation(request) {
|
|
9
|
+
export function negotiateRequestRepresentation(request, botNegotiation = false) {
|
|
10
10
|
if (request.isPrerender || request.headers["x-nitro-prerender"])
|
|
11
11
|
return "html";
|
|
12
12
|
const accept = request.headers.accept;
|
|
13
|
-
const
|
|
14
|
-
if (
|
|
15
|
-
return
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
const preference = negotiateContent(accept);
|
|
14
|
+
if (!botNegotiation || preference !== "html" || request.headers["sec-fetch-dest"] === "document")
|
|
15
|
+
return preference;
|
|
16
|
+
const entries = parseAcceptHeader(accept?.toLowerCase() || "");
|
|
17
|
+
const matching = ["text/markdown", "text/*", "*/*"].map((type) => entries.filter((entry) => entry.type === type)).find((group) => group.length > 0);
|
|
18
|
+
if (matching && matching.every((entry) => entry.q === 0))
|
|
19
|
+
return preference;
|
|
18
20
|
const botInfo = getBotInfo(request.headers);
|
|
19
21
|
if (botInfo?.category === "ai")
|
|
20
22
|
return "markdown";
|
|
21
|
-
return
|
|
23
|
+
return preference;
|
|
22
24
|
}
|
|
23
|
-
export function negotiateRepresentation(event) {
|
|
24
|
-
return negotiateRequestRepresentation(toMarkdownRequest(event));
|
|
25
|
+
export function negotiateRepresentation(event, botNegotiation = false) {
|
|
26
|
+
return negotiateRequestRepresentation(toMarkdownRequest(event), botNegotiation);
|
|
25
27
|
}
|
|
26
28
|
export function getRequestRenderInfo(request, mode = { _tag: "runtime", contentNegotiation: true }) {
|
|
27
29
|
const queryIndex = request.path.indexOf("?");
|
|
@@ -41,7 +43,7 @@ export function getRequestRenderInfo(request, mode = { _tag: "runtime", contentN
|
|
|
41
43
|
const extension = hasExtension ? lastSegment.substring(lastSegment.lastIndexOf(".")) : "";
|
|
42
44
|
if (hasExtension && extension !== ".md")
|
|
43
45
|
return null;
|
|
44
|
-
const negotiation = isPrerender ? "markdown" : mode.contentNegotiation ? negotiateRequestRepresentation(request) : "html";
|
|
46
|
+
const negotiation = isPrerender ? "markdown" : mode.contentNegotiation ? negotiateRequestRepresentation(request, mode.botNegotiation) : "html";
|
|
45
47
|
if (isExplicit) {
|
|
46
48
|
const path = normalizePath(originalPath.slice(0, -3));
|
|
47
49
|
return { path, isExplicit: true, negotiation: "markdown" };
|
|
@@ -58,6 +60,6 @@ function normalizePath(path) {
|
|
|
58
60
|
return path.slice(0, -5) || "/";
|
|
59
61
|
return path;
|
|
60
62
|
}
|
|
61
|
-
export function clientPrefersMarkdown(event) {
|
|
62
|
-
return negotiateRepresentation(event) === "markdown";
|
|
63
|
+
export function clientPrefersMarkdown(event, botNegotiation = false) {
|
|
64
|
+
return negotiateRepresentation(event, botNegotiation) === "markdown";
|
|
63
65
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ContentNegotiationPolicy } from '../../types.js';
|
|
2
2
|
import type { ContentNegotiationResolution, NegotiationRouteRule } from './content-negotiation.js';
|
|
3
3
|
import type { MarkdownRequest } from './markdown-request.js';
|
|
4
|
+
import { getContentNegotiationVary } from './content-negotiation.js';
|
|
4
5
|
/** Marks an internal HTML fetch that must bypass content negotiation. */
|
|
5
6
|
export declare const INTERNAL_HEADER = "x-ai-ready-internal";
|
|
6
7
|
/**
|
|
@@ -13,6 +14,7 @@ export interface NegotiationInput {
|
|
|
13
14
|
request: MarkdownRequest;
|
|
14
15
|
routeRule: NegotiationRouteRule;
|
|
15
16
|
policy: ContentNegotiationPolicy;
|
|
17
|
+
botNegotiation?: boolean;
|
|
16
18
|
/**
|
|
17
19
|
* Routes that already serve a Markdown file verbatim, such as an agent skill
|
|
18
20
|
* alias. They are answered by their own handler, never rendered.
|
|
@@ -24,6 +26,7 @@ export type NegotiationDecision = {
|
|
|
24
26
|
reason: 'well-known' | 'internal' | 'artifact' | 'not-a-page' | 'deferred';
|
|
25
27
|
} | {
|
|
26
28
|
_tag: 'not-acceptable';
|
|
29
|
+
vary: ReturnType<typeof getContentNegotiationVary>;
|
|
27
30
|
} | {
|
|
28
31
|
_tag: 'html';
|
|
29
32
|
path: string;
|
|
@@ -31,6 +34,7 @@ export type NegotiationDecision = {
|
|
|
31
34
|
} | {
|
|
32
35
|
_tag: 'redirect';
|
|
33
36
|
path: string;
|
|
37
|
+
vary: ReturnType<typeof getContentNegotiationVary>;
|
|
34
38
|
} | {
|
|
35
39
|
_tag: 'render';
|
|
36
40
|
path: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { resolveContentNegotiation } from "./content-negotiation.js";
|
|
1
|
+
import { getContentNegotiationVary, resolveContentNegotiation } from "./content-negotiation.js";
|
|
2
2
|
import { getRequestRenderInfo } from "./markdown-request.js";
|
|
3
3
|
export const INTERNAL_HEADER = "x-ai-ready-internal";
|
|
4
4
|
export function resolveNegotiationDecision(input) {
|
|
@@ -10,20 +10,21 @@ export function resolveNegotiationDecision(input) {
|
|
|
10
10
|
return { _tag: "skip", reason: "artifact" };
|
|
11
11
|
if (request.headers[INTERNAL_HEADER])
|
|
12
12
|
return { _tag: "skip", reason: "internal" };
|
|
13
|
-
const negotiation = resolveContentNegotiation({ policy: input.policy, routeRule: input.routeRule });
|
|
13
|
+
const negotiation = resolveContentNegotiation({ policy: input.policy, routeRule: input.routeRule, botNegotiation: input.botNegotiation });
|
|
14
14
|
const renderInfo = getRequestRenderInfo(request, {
|
|
15
15
|
_tag: "runtime",
|
|
16
|
-
contentNegotiation: negotiation._tag === "enabled"
|
|
16
|
+
contentNegotiation: negotiation._tag === "enabled",
|
|
17
|
+
botNegotiation: input.botNegotiation
|
|
17
18
|
});
|
|
18
19
|
if (!renderInfo)
|
|
19
20
|
return { _tag: "skip", reason: "not-a-page" };
|
|
20
21
|
if ("notAcceptable" in renderInfo)
|
|
21
|
-
return { _tag: "not-acceptable" };
|
|
22
|
+
return { _tag: "not-acceptable", vary: getContentNegotiationVary(input.botNegotiation) };
|
|
22
23
|
if (renderInfo.isExplicit) {
|
|
23
24
|
return stage === "early" ? { _tag: "skip", reason: "deferred" } : { _tag: "render", path: renderInfo.path };
|
|
24
25
|
}
|
|
25
26
|
if (renderInfo.negotiation === "markdown")
|
|
26
|
-
return { _tag: "redirect", path: renderInfo.path };
|
|
27
|
+
return { _tag: "redirect", path: renderInfo.path, vary: getContentNegotiationVary(input.botNegotiation) };
|
|
27
28
|
return { _tag: "html", path: renderInfo.path, negotiation };
|
|
28
29
|
}
|
|
29
30
|
function withoutQuery(path) {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { createNitroRouteRuleMatcher } from "nuxtseo-shared/server";
|
|
2
2
|
import { localAgentSkillArtifacts } from "#ai-ready-virtual/agent-skills.mjs";
|
|
3
|
-
import { appendHeader, createError, getHeader, getRequestHost, getResponseHeader, sendRedirect, setHeader } from "#nuxtseo/h3";
|
|
3
|
+
import { appendHeader, createError, getHeader, getRequestHost, getRequestURL, getResponseHeader, sendRedirect, setHeader } from "#nuxtseo/h3";
|
|
4
4
|
import { useRuntimeConfig } from "#nuxtseo/nitro";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import * as siteConfigUtils from "#site-config/server/composables/utils";
|
|
6
|
+
import { initRequestSiteConfig } from "#site-config/server/init";
|
|
7
|
+
import { mergeVaryHeader } from "../../cache-control.js";
|
|
7
8
|
import { toMarkdownPath } from "../../markdown-path.js";
|
|
8
9
|
import { toDeployedRoute } from "../../route-path.js";
|
|
9
10
|
import { setStatusAwareLinkHeader } from "../plugins/link-header.js";
|
|
10
|
-
import {
|
|
11
|
-
import { buildLinkHeader } from "./link-header.js";
|
|
11
|
+
import { buildLinkHeader, buildStatusAwareLinkHeaders } from "./link-header.js";
|
|
12
12
|
import { toMarkdownRequest } from "./markdown-request.js";
|
|
13
13
|
import { resolveNegotiationDecision } from "./negotiation-decision.js";
|
|
14
14
|
const APPLIED_KEY = "nuxt-ai-ready:negotiation-applied";
|
|
@@ -17,17 +17,25 @@ export function agentSkillArtifactPaths() {
|
|
|
17
17
|
artifactPaths ??= new Set(Object.keys(localAgentSkillArtifacts));
|
|
18
18
|
return artifactPaths;
|
|
19
19
|
}
|
|
20
|
+
function createHeaderUrlResolver(event, ctx) {
|
|
21
|
+
if (!siteConfigUtils.createSitePathResolver)
|
|
22
|
+
return ctx.resolveUrl;
|
|
23
|
+
let resolveUrl;
|
|
24
|
+
return (path) => {
|
|
25
|
+
resolveUrl ??= siteConfigUtils.createSitePathResolver(event, { absolute: true, withBase: true });
|
|
26
|
+
return resolveUrl(ctx.resolvePath(path));
|
|
27
|
+
};
|
|
28
|
+
}
|
|
20
29
|
export function setLinkHeader(event, ctx, variant) {
|
|
21
|
-
setHeader(event, "link", buildLinkHeader(ctx.path, variant, ctx.config, ctx
|
|
30
|
+
setHeader(event, "link", buildLinkHeader(ctx.path, variant, ctx.config, createHeaderUrlResolver(event, ctx), ctx.routeContext));
|
|
22
31
|
}
|
|
23
32
|
export function setStatusAwareHeader(event, ctx, variant) {
|
|
24
|
-
const successHeader = buildLinkHeader(ctx.path, variant, ctx.config, ctx.resolveUrl, ctx.routeContext);
|
|
25
33
|
if (!ctx.config.i18n) {
|
|
26
|
-
|
|
34
|
+
setLinkHeader(event, ctx, variant);
|
|
27
35
|
return;
|
|
28
36
|
}
|
|
29
|
-
const
|
|
30
|
-
setStatusAwareLinkHeader(event,
|
|
37
|
+
const headers = buildStatusAwareLinkHeaders(ctx.path, variant, ctx.config, createHeaderUrlResolver(event, ctx), ctx.routeContext);
|
|
38
|
+
setStatusAwareLinkHeader(event, headers.error, headers.success);
|
|
31
39
|
}
|
|
32
40
|
export function setUncacheableHeaders(event) {
|
|
33
41
|
setHeader(event, "cache-control", "private, no-store");
|
|
@@ -44,6 +52,8 @@ export function setUncacheableHeaders(event) {
|
|
|
44
52
|
}
|
|
45
53
|
export function setMarkdownHeaders(event, ctx, sourceHeaders) {
|
|
46
54
|
setHeader(event, "content-type", "text/markdown; charset=utf-8");
|
|
55
|
+
const vary = [getResponseHeader(event, "vary"), sourceHeaders?.get("vary")].filter(Boolean).join(", ");
|
|
56
|
+
setHeader(event, "vary", mergeVaryHeader(vary, "Accept"));
|
|
47
57
|
setLinkHeader(event, ctx, "markdown");
|
|
48
58
|
const privateResponse = [
|
|
49
59
|
"cache-control",
|
|
@@ -68,7 +78,7 @@ export function setMarkdownHeaders(event, ctx, sourceHeaders) {
|
|
|
68
78
|
}
|
|
69
79
|
export async function ensureSiteConfig(event) {
|
|
70
80
|
if (!event.context._initedSiteConfig)
|
|
71
|
-
await
|
|
81
|
+
await initRequestSiteConfig(event, getRequestURL(event, { xForwardedHost: true, xForwardedProto: true }).origin, createNitroRouteRuleMatcher(useRuntimeConfig(event))(event.path));
|
|
72
82
|
}
|
|
73
83
|
export function buildNegotiationContext(event, path) {
|
|
74
84
|
const runtimeConfig = useRuntimeConfig(event);
|
|
@@ -78,10 +88,11 @@ export function buildNegotiationContext(event, path) {
|
|
|
78
88
|
config: runtimeConfig["nuxt-ai-ready"],
|
|
79
89
|
path,
|
|
80
90
|
resolvePath,
|
|
81
|
-
resolveUrl: (target) => withSiteUrl(event, resolvePath(target)),
|
|
91
|
+
resolveUrl: (target) => siteConfigUtils.withSiteUrl(event, resolvePath(target), { withBase: true }),
|
|
82
92
|
routeContext: { host: getRequestHost(event, { xForwardedHost: true }) }
|
|
83
93
|
};
|
|
84
94
|
}
|
|
95
|
+
const REQUEST_DECISION = Symbol("nuxt-ai-ready:negotiation");
|
|
85
96
|
let matcherCache;
|
|
86
97
|
function getRouteRuleMatcher(runtimeConfig) {
|
|
87
98
|
if (matcherCache?.config !== runtimeConfig)
|
|
@@ -91,13 +102,27 @@ function getRouteRuleMatcher(runtimeConfig) {
|
|
|
91
102
|
export function decideNegotiation(event, stage) {
|
|
92
103
|
const runtimeConfig = useRuntimeConfig(event);
|
|
93
104
|
const config = runtimeConfig["nuxt-ai-ready"];
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
105
|
+
const context = event.context;
|
|
106
|
+
const owner = event.node?.req ?? event.req ?? event;
|
|
107
|
+
let cached = context[REQUEST_DECISION];
|
|
108
|
+
if (!cached || cached.owner !== owner || cached.path !== event.path || cached.policy !== config.contentNegotiation || cached.botNegotiation !== config.botNegotiation) {
|
|
109
|
+
cached = {
|
|
110
|
+
owner,
|
|
111
|
+
path: event.path,
|
|
112
|
+
policy: config.contentNegotiation,
|
|
113
|
+
botNegotiation: config.botNegotiation,
|
|
114
|
+
decision: resolveNegotiationDecision({
|
|
115
|
+
stage: "middleware",
|
|
116
|
+
request: toMarkdownRequest(event),
|
|
117
|
+
routeRule: getRouteRuleMatcher(runtimeConfig)(event.path),
|
|
118
|
+
policy: config.contentNegotiation,
|
|
119
|
+
botNegotiation: config.botNegotiation,
|
|
120
|
+
artifactPaths: agentSkillArtifactPaths()
|
|
121
|
+
})
|
|
122
|
+
};
|
|
123
|
+
context[REQUEST_DECISION] = cached;
|
|
124
|
+
}
|
|
125
|
+
return stage === "early" && cached.decision._tag === "render" ? { _tag: "skip", reason: "deferred" } : cached.decision;
|
|
101
126
|
}
|
|
102
127
|
export async function applyNegotiation(event, decision) {
|
|
103
128
|
if (decision._tag === "skip" || decision._tag === "render")
|
|
@@ -107,7 +132,7 @@ export async function applyNegotiation(event, decision) {
|
|
|
107
132
|
return;
|
|
108
133
|
context[APPLIED_KEY] = true;
|
|
109
134
|
if (decision._tag === "not-acceptable") {
|
|
110
|
-
appendHeader(event, "vary",
|
|
135
|
+
appendHeader(event, "vary", decision.vary);
|
|
111
136
|
setUncacheableHeaders(event);
|
|
112
137
|
throw createError({
|
|
113
138
|
statusCode: 406,
|
|
@@ -119,11 +144,11 @@ export async function applyNegotiation(event, decision) {
|
|
|
119
144
|
const ctx = buildNegotiationContext(event, decision.path);
|
|
120
145
|
if (decision._tag === "html") {
|
|
121
146
|
if (decision.negotiation._tag === "enabled")
|
|
122
|
-
appendHeader(event, "vary",
|
|
147
|
+
appendHeader(event, "vary", decision.negotiation.vary);
|
|
123
148
|
setStatusAwareHeader(event, ctx, "html");
|
|
124
149
|
return;
|
|
125
150
|
}
|
|
126
|
-
appendHeader(event, "vary",
|
|
151
|
+
appendHeader(event, "vary", decision.vary);
|
|
127
152
|
setLinkHeader(event, ctx, "html");
|
|
128
153
|
setUncacheableHeaders(event);
|
|
129
154
|
return sendRedirect(event, ctx.resolvePath(toMarkdownPath(decision.path)), 307);
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import type { NuxtRenderHTMLContext } from 'nuxt/app';
|
|
2
|
+
export declare function storePrerenderedHtml(path: string, html: string | NuxtRenderHTMLContext): void;
|
|
2
3
|
export declare function consumePrerenderedHtml(path: string): string | undefined;
|
|
@@ -9,5 +9,7 @@ export function consumePrerenderedHtml(path) {
|
|
|
9
9
|
const key = normalizeHtmlCachePath(path);
|
|
10
10
|
const html = htmlByPath.get(key);
|
|
11
11
|
htmlByPath.delete(key);
|
|
12
|
-
|
|
12
|
+
if (!html || typeof html === "string")
|
|
13
|
+
return html;
|
|
14
|
+
return `<!DOCTYPE html><html ${html.htmlAttrs.join(" ")}><head>${html.head.join("")}</head><body ${html.bodyAttrs.join(" ")}>${html.bodyPrepend.join("")}${html.body.join("")}${html.bodyAppend.join("")}</body></html>`;
|
|
13
15
|
}
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -76,11 +76,10 @@ export interface AgentSkillsConfig {
|
|
|
76
76
|
*/
|
|
77
77
|
skills?: AgentSkillConfig[];
|
|
78
78
|
/**
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
* at
|
|
82
|
-
*
|
|
83
|
-
* @default 'skills'
|
|
79
|
+
* Explicit directory scanned for `<name>/SKILL.md` in the project root and its layers.
|
|
80
|
+
* By default, only `skills/<name>/SKILL.md` inside their resolved public directories is discovered.
|
|
81
|
+
* Public skills are also served at `/skills/<name>/SKILL.md`.
|
|
82
|
+
* An explicit directory uses `/<dir>/<name>/SKILL.md`. `false` disables discovery.
|
|
84
83
|
*/
|
|
85
84
|
dir?: string | false;
|
|
86
85
|
/**
|
|
@@ -129,12 +128,21 @@ export interface ModuleOptions {
|
|
|
129
128
|
*/
|
|
130
129
|
debug?: boolean;
|
|
131
130
|
/**
|
|
132
|
-
* Negotiate Markdown on HTML routes through Accept
|
|
131
|
+
* Negotiate Markdown on HTML routes through Accept headers.
|
|
133
132
|
* Disable when a deployment cache cannot vary responses by request headers.
|
|
134
133
|
* Explicit .md routes remain available.
|
|
134
|
+
* On Cloudflare Workers, true also routes prerendered HTML through the Worker.
|
|
135
|
+
* Automatic negotiation preserves the existing Cloudflare asset routing.
|
|
135
136
|
* @default Automatic per route
|
|
136
137
|
*/
|
|
137
138
|
contentNegotiation?: boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Offer Markdown to AI bots even when their Accept header prefers HTML.
|
|
141
|
+
* Requires cache variation on Accept, Sec-Fetch-Dest, and User-Agent.
|
|
142
|
+
* Disable to avoid fragmenting caches by raw User-Agent strings.
|
|
143
|
+
* @default false
|
|
144
|
+
*/
|
|
145
|
+
botNegotiation?: boolean;
|
|
138
146
|
/**
|
|
139
147
|
* Publish an RFC 9727 API Catalog at `/.well-known/api-catalog`.
|
|
140
148
|
* Relative entry URLs resolve against the configured site URL and app base URL.
|
|
@@ -286,7 +294,7 @@ export interface ModuleOptions {
|
|
|
286
294
|
/**
|
|
287
295
|
* Database type - auto-detected if not specified
|
|
288
296
|
* - 'none': No database. Build time generation only.
|
|
289
|
-
* - 'sqlite': Local SQLite via node:sqlite
|
|
297
|
+
* - 'sqlite': Local SQLite via node:sqlite (default for Node.js)
|
|
290
298
|
* - 'd1': Cloudflare D1 (auto-detected on Cloudflare)
|
|
291
299
|
* - 'bun': Bun SQLite via bun:sqlite (auto-detected on Bun) [experimental]
|
|
292
300
|
* - 'libsql': Turso/LibSQL [experimental]
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import { findPackageJSON } from 'node:module';
|
|
4
|
+
import { isAbsolute, join } from 'node:path';
|
|
5
|
+
import { pathToFileURL } from 'node:url';
|
|
6
|
+
|
|
7
|
+
function resolvePackageMetadataPath(specifier, base, options) {
|
|
8
|
+
if (options) {
|
|
9
|
+
const candidate = join(options.searchDirectory, specifier, "package.json");
|
|
10
|
+
if (existsSync(candidate))
|
|
11
|
+
return candidate;
|
|
12
|
+
}
|
|
13
|
+
const input = isAbsolute(specifier) ? pathToFileURL(specifier) : specifier;
|
|
14
|
+
const path = findPackageJSON(input, base && pathToFileURL(join(base, "package.json")));
|
|
15
|
+
if (!path)
|
|
16
|
+
throw new Error(`Could not find package metadata for ${specifier}.`);
|
|
17
|
+
return path;
|
|
18
|
+
}
|
|
19
|
+
async function readPackageMetadata(specifier, base, options) {
|
|
20
|
+
const metadata = JSON.parse(await readFile(resolvePackageMetadataPath(specifier, base, options), "utf8"));
|
|
21
|
+
if (typeof metadata !== "object" || metadata === null)
|
|
22
|
+
throw new Error(`Invalid package metadata for ${specifier}.`);
|
|
23
|
+
const version = "version" in metadata ? metadata.version : void 0;
|
|
24
|
+
const peers = "peerDependencies" in metadata ? metadata.peerDependencies : void 0;
|
|
25
|
+
const peerDependencies = typeof peers === "object" && peers !== null ? Object.fromEntries(Object.entries(peers).filter((entry) => typeof entry[1] === "string")) : {};
|
|
26
|
+
return typeof version === "string" ? { version, peerDependencies } : { peerDependencies };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { resolvePackageMetadataPath as a, readPackageMetadata as r };
|