@aihu/adapter-vercel 0.1.0 → 0.1.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/README.md CHANGED
@@ -1,32 +1,93 @@
1
1
  # @aihu/adapter-vercel
2
2
 
3
- > Vercel deployment adapter for @aihu/app.
3
+ > **Aihu** agentic discovery and interaction, for human purpose.
4
4
 
5
- Part of the [aihu](https://github.com/fellwork/aihu) framework — agentic discovery and interaction, for human purpose.
5
+ Vercel deployment adapter for @aihu/app.
6
+
7
+ Part of the **meta-framework** layer of Aihu. Provides whole-app capability — file-based routing, SSR, loaders, cookies — without the boilerplate other meta-frameworks impose. See [arch-1](../../docs/roadmap/arch-1-website.md) for the meta-framework contract.
8
+
9
+ <!-- BEGIN_HANDWRITTEN: prose -->
10
+ _(Hand-written prose lives in this block. Replace this placeholder; everything below is auto-generated.)_
11
+ <!-- END_HANDWRITTEN: prose -->
6
12
 
7
13
  ## Install
8
14
 
15
+ <!-- BEGIN_AUTOGEN: install -->
16
+ <!-- regenerate: bun scripts/sync-readme.ts (also runs in pre-commit + CI) -->
17
+
9
18
  ```bash
10
19
  npm install @aihu/adapter-vercel
11
20
  # or
12
21
  bun add @aihu/adapter-vercel
13
22
  ```
14
23
 
15
- ## Usage
24
+ <sub><i>Auto-generated against `@aihu/adapter-vercel@0.1.1`.</i></sub>
16
25
 
17
- ```typescript
18
- // vite.config.ts
19
- import { defineConfig } from 'vite';
20
- import { aihu } from '@aihu/app';
21
- import vercel from '@aihu/adapter-vercel';
26
+ <!-- END_AUTOGEN: install -->
22
27
 
23
- export default defineConfig({ plugins: [aihu({ adapter: vercel() })] });
24
- ```
28
+ ## Package facts
29
+
30
+ <!-- BEGIN_AUTOGEN: stats -->
31
+ <!-- regenerate: bun scripts/sync-readme.ts (also runs in pre-commit + CI) -->
32
+
33
+ | | |
34
+ |---|---|
35
+ | **Version** | `0.1.1` |
36
+ | **Tier** | B — Meta-framework — Vercel deploy adapter |
37
+ | **Published files** | 3 entries |
38
+ | **License** | MIT |
39
+
40
+ <sub><i>Auto-generated against `@aihu/adapter-vercel@0.1.1`.</i></sub>
41
+
42
+ <!-- END_AUTOGEN: stats -->
43
+
44
+ ## Exports
45
+
46
+ <!-- BEGIN_AUTOGEN: exports -->
47
+ <!-- regenerate: bun scripts/sync-readme.ts (also runs in pre-commit + CI) -->
48
+
49
+ | Subpath | ESM | CJS |
50
+ |---|---|---|
51
+ | `.` | `./dist/index.js` | `—` |
52
+
53
+ <sub><i>Auto-generated against `@aihu/adapter-vercel@0.1.1`.</i></sub>
54
+
55
+ <!-- END_AUTOGEN: exports -->
25
56
 
26
- ## Status
57
+ ## Dependencies
27
58
 
28
- Early access (`0.1.x`). API may evolve before v1.1 GA. See the [v1.1 roadmap](https://github.com/fellwork/aihu/tree/main/docs/roadmap) for stability commitments.
59
+ <!-- BEGIN_AUTOGEN: deps -->
60
+ <!-- regenerate: bun scripts/sync-readme.ts (also runs in pre-commit + CI) -->
61
+
62
+ **Peer dependencies:**
63
+
64
+ - `@aihu/app` — `workspace:*`
65
+ - `vite` — `>=5.0.0`
66
+
67
+ <sub><i>Auto-generated against `@aihu/adapter-vercel@0.1.1`.</i></sub>
68
+
69
+ <!-- END_AUTOGEN: deps -->
70
+
71
+ ## See also
72
+
73
+ <!-- BEGIN_AUTOGEN: see-also -->
74
+ <!-- regenerate: bun scripts/sync-readme.ts (also runs in pre-commit + CI) -->
75
+
76
+ - [@aihu/app](../app)
77
+ - [@aihu/server](../server)
78
+ - [Aihu framework root](../../README.md)
79
+
80
+ <sub><i>Auto-generated against `@aihu/adapter-vercel@0.1.1`.</i></sub>
81
+
82
+ <!-- END_AUTOGEN: see-also -->
29
83
 
30
84
  ## License
31
85
 
32
- MIT see [LICENSE](https://github.com/fellwork/aihu/blob/main/LICENSE).
86
+ <!-- BEGIN_AUTOGEN: license -->
87
+ <!-- regenerate: bun scripts/sync-readme.ts (also runs in pre-commit + CI) -->
88
+
89
+ MIT — see [LICENSE](../../LICENSE).
90
+
91
+ <sub><i>Auto-generated against `@aihu/adapter-vercel@0.1.1`.</i></sub>
92
+
93
+ <!-- END_AUTOGEN: license -->
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;UAIiB,oBAAA;;AAAjB;;;;EAME,OAAA;EAKA;;;;EAAA,SAAA;EA8FoB;;;;;EAxFpB,WAAA;AAAA;;;;;;;;;;;;;;;;iBAwFc,MAAA,CAAO,OAAA,GAAU,oBAAA,GAAuB,WAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;UAIiB,oBAAA;;AAAjB;;;;EAME,OAAA;EAKA;;;;EAAA,SAAA;EAyFoB;;;;;EAnFpB,WAAA;AAAA;;;;;;;;;;;;;;;;iBAmFc,MAAA,CAAO,OAAA,GAAU,oBAAA,GAAuB,WAAA"}
package/dist/index.js CHANGED
@@ -1,9 +1,4 @@
1
- import{cp as e,mkdir as t,rm as n}from"node:fs/promises";import{join as r,resolve as i}from"node:path";function a(){return[`// AUTO-GENERATED by @aihu/adapter-vercel — do not edit`,`// Vercel Edge Function entry — SPA mode`,`//`,`// In SPA mode (V0), this function handles /api/** routes only.`,`// All page requests are served by Vercel CDN from static/index.html.`,`// For SSR mode, upgrade to @aihu/adapter-vercel with ssr: true (V1+).`,``,`export default async function handler(request) {`,` const url = new URL(request.url)`,` if (!url.pathname.startsWith('/api/')) {`,` return new Response('Not Found', { status: 404 })`,` }`,` return new Response('API route not implemented', { status: 501 })`,`}`,``,`export const config = { runtime: 'edge' }`].join(`
2
- `)+`
3
- `}function o(){return[`// AUTO-GENERATED by @aihu/adapter-vercel do not edit`,`// Vercel Serverless Function entry — SPA mode`,``,`export default async function handler(request, response) {`,` const host = request.headers.host ?? "localhost"`," const url = new URL(request.url, `https://${host}`)",` if (!url.pathname.startsWith('/api/')) {`,` response.status(404).send("Not Found")`,` return`,` }`,` response.status(501).send("API route not implemented")`,`}`].join(`
4
- `)+`
5
- `}function s(e,t){return e===`edge`?JSON.stringify({runtime:`edge`,entrypoint:`index.js`},null,2)+`
6
- `:JSON.stringify({runtime:t,handler:`index.js`,maxDuration:10},null,2)+`
7
- `}function c(){return JSON.stringify({version:3,routes:[{src:`^/assets/(.*)$`,headers:{"cache-control":`public, max-age=31536000, immutable`},continue:!0},{src:`^/api/(.*)$`,dest:`/index.func`},{src:`^/(.*)$`,dest:`/static/index.html`}]},null,2)+`
8
- `}function l(l){return{name:`vercel`,async adapt(u){let d=l?.runtime??`edge`,f=l?.nodeVersion??`nodejs18.x`,p=i(u.root,l?.outputDir??`.vercel/output`);await n(p,{recursive:!0,force:!0}),await t(p,{recursive:!0});let m=r(p,`static`);await t(m,{recursive:!0}),await e(u.outDir,m,{recursive:!0,force:!0}),console.log(`[@aihu/adapter-vercel] Copied static assets → ${m}`);let h=r(p,`functions`,`index.func`);await t(h,{recursive:!0});let g=d===`edge`?a():o();await u.writeFile(r(h,`index.js`),g);let _=s(d,f);await u.writeFile(r(h,`.vc-config.json`),_),console.log(`[@aihu/adapter-vercel] Wrote function entry (${d} runtime) → ${h}`);let v=c();await u.writeFile(r(p,`config.json`),v),console.log(`[@aihu/adapter-vercel] Build complete → ${p}`),console.log(`[@aihu/adapter-vercel] Deploy with: vercel deploy --prebuilt`)}}}export{l as vercel};
1
+ import{cp as e,mkdir as t,rm as n}from"node:fs/promises";import{join as r,resolve as i}from"node:path";function a(){return`${[`// AUTO-GENERATED by @aihu/adapter-vercel — do not edit`,`// Vercel Edge Function entry — SPA mode`,`//`,`// In SPA mode (V0), this function handles /api/** routes only.`,`// All page requests are served by Vercel CDN from static/index.html.`,`// For SSR mode, upgrade to @aihu/adapter-vercel with ssr: true (V1+).`,``,`export default async function handler(request) {`,` const url = new URL(request.url)`,` if (!url.pathname.startsWith('/api/')) {`,` return new Response('Not Found', { status: 404 })`,` }`,` return new Response('API route not implemented', { status: 501 })`,`}`,``,`export const config = { runtime: 'edge' }`].join(`
2
+ `)}\n`}function o(){return`${[`// AUTO-GENERATED by @aihu/adapter-vercel — do not edit`,`// Vercel Serverless Function entry — SPA mode`,``,`export default async function handler(request, response) {`,` const host = request.headers.host ?? "localhost"`," const url = new URL(request.url, `https://${host}`)",` if (!url.pathname.startsWith('/api/')) {`,` response.status(404).send("Not Found")`,` return`,` }`,` response.status(501).send("API route not implemented")`,`}`].join(`
3
+ `)}\n`}function s(e,t){return e===`edge`?`${JSON.stringify({runtime:`edge`,entrypoint:`index.js`},null,2)}\n`:`${JSON.stringify({runtime:t,handler:`index.js`,maxDuration:10},null,2)}\n`}function c(){return`${JSON.stringify({version:3,routes:[{src:`^/assets/(.*)$`,headers:{"cache-control":`public, max-age=31536000, immutable`},continue:!0},{src:`^/api/(.*)$`,dest:`/index.func`},{src:`^/(.*)$`,dest:`/static/index.html`}]},null,2)}\n`}function l(l){return{name:`vercel`,async adapt(u){let d=l?.runtime??`edge`,f=l?.nodeVersion??`nodejs18.x`,p=i(u.root,l?.outputDir??`.vercel/output`);await n(p,{recursive:!0,force:!0}),await t(p,{recursive:!0});let m=r(p,`static`);await t(m,{recursive:!0}),await e(u.outDir,m,{recursive:!0,force:!0}),console.log(`[@aihu/adapter-vercel] Copied static assets ${m}`);let h=r(p,`functions`,`index.func`);await t(h,{recursive:!0});let g=d===`edge`?a():o();await u.writeFile(r(h,`index.js`),g);let _=s(d,f);await u.writeFile(r(h,`.vc-config.json`),_),console.log(`[@aihu/adapter-vercel] Wrote function entry (${d} runtime) → ${h}`);let v=c();await u.writeFile(r(p,`config.json`),v),console.log(`[@aihu/adapter-vercel] Build complete → ${p}`),console.log(`[@aihu/adapter-vercel] Deploy with: vercel deploy --prebuilt`)}}}export{l as vercel};
9
4
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["resolvePath"],"sources":["../src/index.ts"],"sourcesContent":["import { cp, mkdir, rm } from 'node:fs/promises'\nimport { join, resolve as resolvePath } from 'node:path'\nimport type { AdapterContext, AihuAdapter } from '@aihu/app'\n\nexport interface VercelAdapterOptions {\n /**\n * Edge Function runtime.\n * - 'edge': Vercel Edge Runtime (V8 isolates, global deployment) — default\n * - 'serverless': Node.js serverless function (regional)\n */\n runtime?: 'edge' | 'serverless'\n /**\n * Vercel Build Output API output directory.\n * Default: '.vercel/output' (relative to project root)\n */\n outputDir?: string\n /**\n * Node.js version for serverless runtime.\n * Only used when runtime === 'serverless'.\n * Default: 'nodejs18.x'\n */\n nodeVersion?: string\n}\n\nfunction generateEdgeFunctionEntry(): string {\n return (\n [\n '// AUTO-GENERATED by @aihu/adapter-vercel — do not edit',\n '// Vercel Edge Function entry — SPA mode',\n '//',\n '// In SPA mode (V0), this function handles /api/** routes only.',\n '// All page requests are served by Vercel CDN from static/index.html.',\n '// For SSR mode, upgrade to @aihu/adapter-vercel with ssr: true (V1+).',\n '',\n 'export default async function handler(request) {',\n ' const url = new URL(request.url)',\n \" if (!url.pathname.startsWith('/api/')) {\",\n \" return new Response('Not Found', { status: 404 })\",\n ' }',\n \" return new Response('API route not implemented', { status: 501 })\",\n '}',\n '',\n \"export const config = { runtime: 'edge' }\",\n ].join('\\n') + '\\n'\n )\n}\n\nfunction generateServerlessFunctionEntry(): string {\n return (\n [\n '// AUTO-GENERATED by @aihu/adapter-vercel — do not edit',\n '// Vercel Serverless Function entry — SPA mode',\n '',\n 'export default async function handler(request, response) {',\n ' const host = request.headers.host ?? \"localhost\"',\n ' const url = new URL(request.url, `https://${host}`)',\n \" if (!url.pathname.startsWith('/api/')) {\",\n ' response.status(404).send(\"Not Found\")',\n ' return',\n ' }',\n ' response.status(501).send(\"API route not implemented\")',\n '}',\n ].join('\\n') + '\\n'\n )\n}\n\nfunction generateVcConfig(runtime: 'edge' | 'serverless', nodeVersion: string): string {\n if (runtime === 'edge') {\n return JSON.stringify({ runtime: 'edge', entrypoint: 'index.js' }, null, 2) + '\\n'\n }\n return (\n JSON.stringify({ runtime: nodeVersion, handler: 'index.js', maxDuration: 10 }, null, 2) + '\\n'\n )\n}\n\nfunction generateConfigJson(): string {\n const routes = [\n {\n src: '^/assets/(.*)$',\n headers: { 'cache-control': 'public, max-age=31536000, immutable' },\n continue: true,\n },\n {\n src: '^/api/(.*)$',\n dest: '/index.func',\n },\n {\n src: '^/(.*)$',\n dest: '/static/index.html',\n },\n ]\n return JSON.stringify({ version: 3, routes }, null, 2) + '\\n'\n}\n\n/**\n * Vercel adapter for aihu (Build Output API v3).\n *\n * Copies static assets to `.vercel/output/static/`, writes an Edge or\n * Serverless function entry, and emits the `config.json` routes manifest.\n *\n * @example\n * // aihu.config.ts\n * import { defineConfig } from '@aihu/app'\n * import { vercel } from '@aihu/adapter-vercel'\n *\n * export default defineConfig({\n * adapter: vercel(),\n * })\n */\nexport function vercel(options?: VercelAdapterOptions): AihuAdapter {\n return {\n name: 'vercel',\n\n async adapt(context: AdapterContext): Promise<void> {\n const runtime = options?.runtime ?? 'edge'\n const nodeVersion = options?.nodeVersion ?? 'nodejs18.x'\n const outputDir = resolvePath(context.root, options?.outputDir ?? '.vercel/output')\n\n // Step 1 — Clean output directory (prevents stale files from prior builds)\n await rm(outputDir, { recursive: true, force: true })\n await mkdir(outputDir, { recursive: true })\n\n // Step 2 — Copy static assets from Vite outDir → .vercel/output/static/\n const staticDir = join(outputDir, 'static')\n await mkdir(staticDir, { recursive: true })\n await cp(context.outDir, staticDir, { recursive: true, force: true })\n console.log(`[@aihu/adapter-vercel] Copied static assets → ${staticDir}`)\n\n // Step 3 — Write Edge/Serverless function entry\n const funcDir = join(outputDir, 'functions', 'index.func')\n await mkdir(funcDir, { recursive: true })\n\n const entryContent =\n runtime === 'edge' ? generateEdgeFunctionEntry() : generateServerlessFunctionEntry()\n await context.writeFile(join(funcDir, 'index.js'), entryContent)\n\n // Step 4 — Write .vc-config.json\n const vcConfig = generateVcConfig(runtime, nodeVersion)\n await context.writeFile(join(funcDir, '.vc-config.json'), vcConfig)\n console.log(`[@aihu/adapter-vercel] Wrote function entry (${runtime} runtime) → ${funcDir}`)\n\n // Step 5 — Write config.json (Build Output API v3 routes)\n const configJson = generateConfigJson()\n await context.writeFile(join(outputDir, 'config.json'), configJson)\n\n console.log(`[@aihu/adapter-vercel] Build complete → ${outputDir}`)\n console.log(`[@aihu/adapter-vercel] Deploy with: vercel deploy --prebuilt`)\n },\n }\n}\n"],"mappings":"uGAwBA,SAAS,GAAoC,CAC3C,MACE,CACE,0DACA,2CACA,KACA,kEACA,wEACA,yEACA,GACA,mDACA,qCACA,6CACA,wDACA,MACA,sEACA,IACA,GACA,4CACD,CAAC,KAAK;EAAK,CAAG;EAInB,SAAS,GAA0C,CACjD,MACE,CACE,0DACA,iDACA,GACA,6DACA,qDACA,wDACA,6CACA,6CACA,aACA,MACA,2DACA,IACD,CAAC,KAAK;EAAK,CAAG;EAInB,SAAS,EAAiB,EAAgC,EAA6B,CAIrF,OAHI,IAAY,OACP,KAAK,UAAU,CAAE,QAAS,OAAQ,WAAY,WAAY,CAAE,KAAM,EAAE,CAAG;EAG9E,KAAK,UAAU,CAAE,QAAS,EAAa,QAAS,WAAY,YAAa,GAAI,CAAE,KAAM,EAAE,CAAG;EAI9F,SAAS,GAA6B,CAgBpC,OAAO,KAAK,UAAU,CAAE,QAAS,EAAG,OAAA,CAdlC,CACE,IAAK,iBACL,QAAS,CAAE,gBAAiB,sCAAuC,CACnE,SAAU,GACX,CACD,CACE,IAAK,cACL,KAAM,cACP,CACD,CACE,IAAK,UACL,KAAM,qBACP,CAEuC,CAAE,CAAE,KAAM,EAAE,CAAG;EAkB3D,SAAgB,EAAO,EAA6C,CAClE,MAAO,CACL,KAAM,SAEN,MAAM,MAAM,EAAwC,CAClD,IAAM,EAAU,GAAS,SAAW,OAC9B,EAAc,GAAS,aAAe,aACtC,EAAYA,EAAY,EAAQ,KAAM,GAAS,WAAa,iBAAiB,CAGnF,MAAM,EAAG,EAAW,CAAE,UAAW,GAAM,MAAO,GAAM,CAAC,CACrD,MAAM,EAAM,EAAW,CAAE,UAAW,GAAM,CAAC,CAG3C,IAAM,EAAY,EAAK,EAAW,SAAS,CAC3C,MAAM,EAAM,EAAW,CAAE,UAAW,GAAM,CAAC,CAC3C,MAAM,EAAG,EAAQ,OAAQ,EAAW,CAAE,UAAW,GAAM,MAAO,GAAM,CAAC,CACrE,QAAQ,IAAI,iDAAiD,IAAY,CAGzE,IAAM,EAAU,EAAK,EAAW,YAAa,aAAa,CAC1D,MAAM,EAAM,EAAS,CAAE,UAAW,GAAM,CAAC,CAEzC,IAAM,EACJ,IAAY,OAAS,GAA2B,CAAG,GAAiC,CACtF,MAAM,EAAQ,UAAU,EAAK,EAAS,WAAW,CAAE,EAAa,CAGhE,IAAM,EAAW,EAAiB,EAAS,EAAY,CACvD,MAAM,EAAQ,UAAU,EAAK,EAAS,kBAAkB,CAAE,EAAS,CACnE,QAAQ,IAAI,gDAAgD,EAAQ,cAAc,IAAU,CAG5F,IAAM,EAAa,GAAoB,CACvC,MAAM,EAAQ,UAAU,EAAK,EAAW,cAAc,CAAE,EAAW,CAEnE,QAAQ,IAAI,2CAA2C,IAAY,CACnE,QAAQ,IAAI,+DAA+D,EAE9E"}
1
+ {"version":3,"file":"index.js","names":["resolvePath"],"sources":["../src/index.ts"],"sourcesContent":["import { cp, mkdir, rm } from 'node:fs/promises'\nimport { join, resolve as resolvePath } from 'node:path'\nimport type { AdapterContext, AihuAdapter } from '@aihu/app'\n\nexport interface VercelAdapterOptions {\n /**\n * Edge Function runtime.\n * - 'edge': Vercel Edge Runtime (V8 isolates, global deployment) — default\n * - 'serverless': Node.js serverless function (regional)\n */\n runtime?: 'edge' | 'serverless'\n /**\n * Vercel Build Output API output directory.\n * Default: '.vercel/output' (relative to project root)\n */\n outputDir?: string\n /**\n * Node.js version for serverless runtime.\n * Only used when runtime === 'serverless'.\n * Default: 'nodejs18.x'\n */\n nodeVersion?: string\n}\n\nfunction generateEdgeFunctionEntry(): string {\n return `${[\n '// AUTO-GENERATED by @aihu/adapter-vercel — do not edit',\n '// Vercel Edge Function entry — SPA mode',\n '//',\n '// In SPA mode (V0), this function handles /api/** routes only.',\n '// All page requests are served by Vercel CDN from static/index.html.',\n '// For SSR mode, upgrade to @aihu/adapter-vercel with ssr: true (V1+).',\n '',\n 'export default async function handler(request) {',\n ' const url = new URL(request.url)',\n \" if (!url.pathname.startsWith('/api/')) {\",\n \" return new Response('Not Found', { status: 404 })\",\n ' }',\n \" return new Response('API route not implemented', { status: 501 })\",\n '}',\n '',\n \"export const config = { runtime: 'edge' }\",\n ].join('\\n')}\\n`\n}\n\nfunction generateServerlessFunctionEntry(): string {\n return `${[\n '// AUTO-GENERATED by @aihu/adapter-vercel — do not edit',\n '// Vercel Serverless Function entry — SPA mode',\n '',\n 'export default async function handler(request, response) {',\n ' const host = request.headers.host ?? \"localhost\"',\n // biome-ignore lint/suspicious/noTemplateCurlyInString: template literal is intentional in generated code\n ' const url = new URL(request.url, `https://${host}`)',\n \" if (!url.pathname.startsWith('/api/')) {\",\n ' response.status(404).send(\"Not Found\")',\n ' return',\n ' }',\n ' response.status(501).send(\"API route not implemented\")',\n '}',\n ].join('\\n')}\\n`\n}\n\nfunction generateVcConfig(runtime: 'edge' | 'serverless', nodeVersion: string): string {\n if (runtime === 'edge') {\n return `${JSON.stringify({ runtime: 'edge', entrypoint: 'index.js' }, null, 2)}\\n`\n }\n return `${JSON.stringify({ runtime: nodeVersion, handler: 'index.js', maxDuration: 10 }, null, 2)}\\n`\n}\n\nfunction generateConfigJson(): string {\n const routes = [\n {\n src: '^/assets/(.*)$',\n headers: { 'cache-control': 'public, max-age=31536000, immutable' },\n continue: true,\n },\n {\n src: '^/api/(.*)$',\n dest: '/index.func',\n },\n {\n src: '^/(.*)$',\n dest: '/static/index.html',\n },\n ]\n return `${JSON.stringify({ version: 3, routes }, null, 2)}\\n`\n}\n\n/**\n * Vercel adapter for aihu (Build Output API v3).\n *\n * Copies static assets to `.vercel/output/static/`, writes an Edge or\n * Serverless function entry, and emits the `config.json` routes manifest.\n *\n * @example\n * // aihu.config.ts\n * import { defineConfig } from '@aihu/app'\n * import { vercel } from '@aihu/adapter-vercel'\n *\n * export default defineConfig({\n * adapter: vercel(),\n * })\n */\nexport function vercel(options?: VercelAdapterOptions): AihuAdapter {\n return {\n name: 'vercel',\n\n async adapt(context: AdapterContext): Promise<void> {\n const runtime = options?.runtime ?? 'edge'\n const nodeVersion = options?.nodeVersion ?? 'nodejs18.x'\n const outputDir = resolvePath(context.root, options?.outputDir ?? '.vercel/output')\n\n // Step 1 — Clean output directory (prevents stale files from prior builds)\n await rm(outputDir, { recursive: true, force: true })\n await mkdir(outputDir, { recursive: true })\n\n // Step 2 — Copy static assets from Vite outDir → .vercel/output/static/\n const staticDir = join(outputDir, 'static')\n await mkdir(staticDir, { recursive: true })\n await cp(context.outDir, staticDir, { recursive: true, force: true })\n console.log(`[@aihu/adapter-vercel] Copied static assets → ${staticDir}`)\n\n // Step 3 — Write Edge/Serverless function entry\n const funcDir = join(outputDir, 'functions', 'index.func')\n await mkdir(funcDir, { recursive: true })\n\n const entryContent =\n runtime === 'edge' ? generateEdgeFunctionEntry() : generateServerlessFunctionEntry()\n await context.writeFile(join(funcDir, 'index.js'), entryContent)\n\n // Step 4 — Write .vc-config.json\n const vcConfig = generateVcConfig(runtime, nodeVersion)\n await context.writeFile(join(funcDir, '.vc-config.json'), vcConfig)\n console.log(`[@aihu/adapter-vercel] Wrote function entry (${runtime} runtime) → ${funcDir}`)\n\n // Step 5 — Write config.json (Build Output API v3 routes)\n const configJson = generateConfigJson()\n await context.writeFile(join(outputDir, 'config.json'), configJson)\n\n console.log(`[@aihu/adapter-vercel] Build complete → ${outputDir}`)\n console.log(`[@aihu/adapter-vercel] Deploy with: vercel deploy --prebuilt`)\n },\n }\n}\n"],"mappings":"uGAwBA,SAAS,GAAoC,CAC3C,MAAO,GAAG,CACR,0DACA,2CACA,KACA,kEACA,wEACA,yEACA,GACA,mDACA,qCACA,6CACA,wDACA,MACA,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