@vercel/geistdocs 2.4.2 → 2.5.0

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 (35) hide show
  1. package/dist/cli/index.js +1 -1
  2. package/dist/config.d.ts +5 -0
  3. package/dist/config.d.ts.map +1 -1
  4. package/dist/internal/chat/context.d.ts +1 -0
  5. package/dist/internal/chat/context.d.ts.map +1 -1
  6. package/dist/internal/chat/context.js +1 -0
  7. package/dist/internal/chat/shell.d.ts.map +1 -1
  8. package/dist/internal/chat/shell.js +32 -10
  9. package/dist/internal/eve-agent-session.d.ts +12 -0
  10. package/dist/internal/eve-agent-session.d.ts.map +1 -0
  11. package/dist/internal/eve-agent-session.js +26 -0
  12. package/dist/internal/eve-agent.d.ts +9 -5
  13. package/dist/internal/eve-agent.d.ts.map +1 -1
  14. package/dist/internal/eve-agent.js +63 -15
  15. package/dist/internal/mdx-to-markdown.d.ts.map +1 -1
  16. package/dist/internal/mdx-to-markdown.js +68 -1
  17. package/dist/internal/provider-client.d.ts +13 -1
  18. package/dist/internal/provider-client.d.ts.map +1 -1
  19. package/dist/internal/search.d.ts +23 -1
  20. package/dist/internal/search.d.ts.map +1 -1
  21. package/dist/internal/search.js +19 -4
  22. package/dist/routes/chat.d.ts.map +1 -1
  23. package/dist/routes/chat.js +51 -13
  24. package/docs/agents.md +1 -1
  25. package/docs/llms.txt +36 -3
  26. package/docs/manifest.json +1 -1
  27. package/docs/pages/ask-ai.md +6 -1
  28. package/docs/pages/configuration.md +6 -1
  29. package/docs/pages/provider.md +23 -0
  30. package/package.json +1 -1
  31. package/template/AGENTS.md +1 -1
  32. package/template/content/docs/ask-ai.mdx +6 -1
  33. package/template/content/docs/configuration.mdx +6 -1
  34. package/template/content/docs/provider.mdx +23 -0
  35. package/template/package.json +1 -1
package/dist/cli/index.js CHANGED
@@ -4,4 +4,4 @@ import{Option as Rn,program as A}from"commander";import{access as Ke,copyFile as
4
4
  `);throw new AggregateError(i,`Mixedbread search sync did not complete:
5
5
  ${a}`)}return r},Ft=async({client:e,file:t,pollIntervalMs:n,pollTimeoutMs:r,sleep:i})=>{let s=t,o=Date.now()+r;for(;s.status==="pending"||s.status==="in_progress";){if(Date.now()>=o)throw new Error(`Mixedbread timed out while indexing file ${t.id}.`);await i(n),s=await e.retrieveStoreFile(t.id)}if(s.status!=="completed")throw new Error(`Mixedbread failed to index file ${t.id} (${s.status}).`);return s},Dt=async({client:e,desired:t,pollIntervalMs:n,pollTimeoutMs:r,sleep:i})=>{let s=await e.uploadFile({content:t.document.content,filename:`${U(t.document.id).slice(0,32)}.md`}),o;try{o=await e.createStoreFile({externalId:t.externalId,fileId:s,metadata:{...t.metadata,[g.rawFileId]:s}})}catch(a){try{await e.deleteFile(s)}catch(d){throw new AggregateError([a,d],`Mixedbread failed to attach and clean up raw file ${s}.`)}throw a}return Ft({client:e,file:o,pollIntervalMs:n,pollTimeoutMs:r,sleep:i})},Ie=async({client:e,concurrency:t=St,manifest:n,pollIntervalMs:r=_t,pollTimeoutMs:i=Tt,revision:s,revisionAncestors:o=[],revisionTimestamp:a,sleep:d=Rt})=>{let c=_e(n);if(c.provider!=="mixedbread")return{deleted:0,skipped:c.documents.length,uploaded:0};let u=c.siteId?.trim();if(!u)throw new Error("Mixedbread retrieval requires a non-empty siteId in geistdocs.tsx.");if(c.documents.length===0)throw new Error("The Geistdocs search export is empty. Refusing to remove indexed documents.");let l=c.documents.map(p=>At(p,u,s,o,a)),m=new Map(l.map(p=>[p.document.id,p])),h=(await be(e)).flatMap(p=>{let y=q(p.metadata);return y?.siteId===u?[{file:p,metadata:y}]:[]}),x=new Map,P=new Set;for(let p of h){W(p.metadata,s,a)&&P.add(p.metadata.documentId);let y=m.get(p.metadata.documentId);y&&p.metadata.contentHash===y.hash&&p.file.status==="completed"&&!x.has(p.metadata.documentId)&&x.set(p.metadata.documentId,p)}let _=l.filter(p=>!(x.has(p.document.id)||P.has(p.document.id)));await Ee(_,t,p=>Dt({client:e,desired:p,pollIntervalMs:r,pollTimeoutMs:i,sleep:d}));let b=(await be(e)).flatMap(p=>{let y=q(p.metadata);return y?.siteId===u?[{file:p,metadata:y}]:[]}),D=new Set(b.filter(({metadata:p})=>W(p,s,a)).map(({metadata:p})=>p.documentId)),ie=new Set;for(let p of l){if(D.has(p.document.id))continue;let ae=b.filter(({file:V,metadata:k})=>V.status==="completed"&&k.documentId===p.document.id&&k.contentHash===p.hash).sort((V,k)=>V.file.id.localeCompare(k.file.id))[0];ae&&ie.add(ae.file.id)}let oe=b.filter(({file:p,metadata:y})=>p.status!=="pending"&&p.status!=="in_progress"&&!W(y,s,a)&&Mt({currentRevision:s,currentRevisionAncestors:o,currentRevisionTimestamp:a,desired:m.get(y.documentId),metadata:y})&&!ie.has(p.id));return await Ee(oe,t,async({file:p,metadata:y})=>{await e.deleteFile(y.rawFileId??p.id),await e.deleteStoreFile(p.id)}),{deleted:oe.length,skipped:l.length-_.length,uploaded:_.length}};var Ot=50,$t=e=>`vercel integration add mixedbread --name docs-${e||"your-site-id"} --environment production`,ve=(e,t)=>kt("git",t,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim(),Nt=e=>{let t=process.env.VERCEL_GIT_COMMIT_SHA?.trim(),n=[];try{n=ve(e,["rev-list",`--max-count=${Ot+1}`,t||"HEAD"]).split(`
6
6
  `).filter(Boolean)}catch{n=[]}let r=t||n[0],i;for(let s of Array.from(new Set([r,"HEAD"].filter(Boolean))))try{let o=Number(ve(e,["show","-s","--format=%ct",s]));if(Number.isFinite(o)){i=o;break}}catch{}return{revision:r,revisionAncestors:n.filter(s=>s!==r),revisionTimestamp:i}},Pe=async({allowNonProduction:e=!1,dir:t=".next"}={})=>{let n=process.cwd();Ct.loadEnvConfig(n,!1);let r=process.env.MXBAI_API_KEY?.trim(),i=process.env.MXBAI_STORE_ID?.trim();if(process.env.VERCEL_ENV!=="production"&&!e){console.log("Geistdocs search sync skipped: this is not a production Vercel build.");return}if(!!r!=!!i)throw new Error("Mixedbread is partially configured. Set both MXBAI_API_KEY and MXBAI_STORE_ID.");let s;try{s=await Te({cwd:n,outputDirectory:t})}catch(a){if(!(r||i)){console.log("Geistdocs search sync skipped: no Mixedbread credentials or static search export were found.");return}throw a}if(s.provider!=="mixedbread"){console.log("Geistdocs search sync skipped: Ask AI uses local retrieval.");return}if(!(r&&i))throw new Error(["Mixedbread retrieval is enabled, but MXBAI_API_KEY or MXBAI_STORE_ID is missing.","From the root of this site's repository, linked to the correct Vercel project, run:",$t(s.siteId)].join(`
7
- `));let o=await Ie({client:we({apiBaseUrl:process.env.MXBAI_BASE_URL,apiKey:r,storeId:i}),manifest:s,...Nt(n)});console.log(`Geistdocs search sync complete: ${o.uploaded} uploaded, ${o.deleted} deleted, ${o.skipped} unchanged.`)};import{readFileSync as Gt,writeFileSync as Ut}from"fs";import{mkdir as Lt,readFile as Z,writeFile as jt}from"fs/promises";import{dirname as Bt,extname as Vt,relative as Fe,resolve as j}from"path";import{intro as Jt,isCancel as Ht,log as I,multiselect as Xt,outro as L,spinner as Kt}from"@clack/prompts";import{glob as Yt}from"glob";import{Node as F,Project as qt,SyntaxKind as zt}from"ts-morph";var Wt="geistdocs.tsx",Qt="content/docs/**/*.mdx",ee=".translation-cache.json",Q=8,Ae=()=>({version:1,entries:{}}),Zt=async e=>{let t=await Z(e),{createHash:n}=await import("crypto");return n("sha256").update(t).digest("hex")},en=e=>{let t=j(process.cwd(),e);return Gt(t,"utf8")},Me=e=>F.isObjectLiteralExpression(e)?e.getProperties().flatMap(t=>{if(F.isPropertyAssignment(t)){let n=t.getNameNode();if(F.isIdentifier(n)||F.isStringLiteral(n))return[n.getText().replaceAll(/['"]/g,"")]}return[]}).filter(Boolean):[],tn=e=>{try{let t=new qt({compilerOptions:{allowJs:!0,jsx:4,module:99,target:10},skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!0}),n=en(e),s=t.createSourceFile(e,n,{overwrite:!0}).getVariableDeclarations().find(a=>a.getName()==="translations")?.getInitializer();if(!s)return[];if(F.isObjectLiteralExpression(s))return Me(s);let o=s.getFirstDescendantByKind(zt.ObjectLiteralExpression);return o?Me(o):[]}catch(t){let n=t instanceof Error?t.message:`${t}`;return I.warn(`Failed to read locales from ${e}: ${n}`),[]}},nn=async()=>{let e=await Xt({message:"Which locales should be translated?",options:[{value:"cn",label:"Chinese (cn)"},{value:"jp",label:"Japanese (jp)"},{value:"es",label:"Spanish (es)"},{value:"fr",label:"French (fr)"},{value:"de",label:"German (de)"}],required:!0});return Ht(e)&&(L("Translation cancelled"),process.exit(0)),e},rn=async e=>(await Yt(e,{cwd:process.cwd(),absolute:!0,nodir:!0})).sort(),sn=async()=>{let e=j(process.cwd(),ee);try{let t=await Z(e,"utf8"),n=JSON.parse(t);return n.version!==1||!n.entries?Ae():{version:1,entries:n.entries}}catch{return Ae()}},Re=e=>{let t=j(process.cwd(),ee),n=JSON.stringify(e,null,2);Ut(t,n,"utf8")},on=async e=>{let t=await Promise.all(e.map(async n=>[n,await Zt(n)]));return Object.fromEntries(t)},an=(e,t)=>{let n=Vt(e);return`${e.slice(0,-n.length)}.${t}${n}`},De=(e,t)=>`${Fe(process.cwd(),e)}::${t}`,cn=(e,t,n,r,i=!1)=>{let s=[],o=0;for(let a of t){let d=n[a];for(let c of e){let u=an(a,c),l=De(a,c),m=r.entries[l];if(!i&&m?.hash===d){o+=1;continue}s.push({locale:c,sourceFile:a,sourceHash:d,targetFile:u})}}return{tasks:s,skippedCount:o}},dn=async e=>{await Lt(Bt(e),{recursive:!0})},ln=async(e,t,n)=>{let r=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t,locale:n})});if(!r.ok){let s=await r.text();throw new Error(`API request failed (${r.status}): ${s}`)}let i=await r.json();if(!i.translation)throw new Error("API response did not include a translation");return i.translation},pn=async(e,t,n)=>{let r=await Z(e.sourceFile,"utf8"),i=await ln(t,r,e.locale);await dn(e.targetFile),await jt(e.targetFile,i,"utf8"),n.entries[De(e.sourceFile,e.locale)]={hash:e.sourceHash,updatedAt:new Date().toISOString()}},ke=async(e,t)=>{Jt("Translate MDX content");let n=e??Qt,r=t.url||process.env.GEISTDOCS_TRANSLATE_URL||"https://geistdocs.com/translate",i=tn(t.config??Wt),s=await rn(n);s.length===0&&(I.error(`No MDX files found matching pattern: ${n}`),L("Translation cancelled"),process.exit(1)),I.info(`Found ${s.length} MDX file(s) matching pattern`),i.length===0&&(i=await nn());let o=j(process.cwd(),ee),a=await sn();await Re(a),I.info(`Using cache: ${o}`);let d=await on(s),{tasks:c,skippedCount:u}=cn(i,s,d,a,t.force);if(c.length===0){I.success("All translations are up to date!"),L(`Skipped ${u} file(s) (unchanged)`);return}let l=[];for(let h=0;h<c.length;h+=Q)l.push(c.slice(h,h+Q));I.info(`Processing ${c.length} translation(s) in ${l.length} batch(es) of up to ${Q}`),u>0&&I.info(`Skipped ${u} translation(s) (unchanged)`);let m=Kt();m.start("Translating content...");let f=0;for(let h of l)await Promise.all(h.map(async x=>{await pn(x,r,a),f+=1,m.message(`Translated ${f}/${c.length}: ${Fe(process.cwd(),x.targetFile)}`)})),await Re(a);m.stop("Translation complete!"),L(`Created/updated ${c.length} file(s)`)};import{access as un,copyFile as gn,mkdir as Ne,rm as re}from"fs/promises";import{dirname as mn,join as v}from"path";import{intro as fn,log as w,outro as B,spinner as Ge}from"@clack/prompts";import{glob as hn}from"glob";var wn=["**/*"],yn=["content/docs/**"],te=".geistdocs-tmp",xn=async(e,t)=>{let n=v(e,t);await re(n,{recursive:!0,force:!0}),await Ne(n,{recursive:!0})},ne=async e=>await re(e,{recursive:!0,force:!0}),Ce=async(e,t,n)=>(await hn(e,{cwd:n,nodir:!0,dot:!0,ignore:[".git/**",...t]})).sort(),bn=async e=>{try{return await un(e),!0}catch{return!1}},En=async(e,t,n)=>{let r=v(t,e),i=v(n,e);return await bn(r)?(await gn(r,i),{success:!0}):{success:!1,error:`Source file not found: ${r}`}},Sn=async(e,t)=>{let n=v(t,e);return await re(n,{force:!0}),{success:!0}},Oe=20,$e=async(e,t,n)=>{let r=[];for(let i=0;i<e.length;i+=n){let s=e.slice(i,i+n),o=await Promise.all(s.map(t));r.push(...o)}return r},_n=async(e,t,n,r,i)=>{let s={success:[],deleted:[],failed:[]},o=[...new Set(e.map(d=>mn(v(r,d))))];i.message(`Creating ${o.length} directories...`),await Promise.all(o.map(d=>Ne(d,{recursive:!0}))),i.message(`Updating ${e.length} files...`);let a=await $e(e,async d=>{let c=await En(d,n,r);return{file:d,...c}},Oe);for(let{file:d,success:c,error:u}of a)c?s.success.push(d):s.failed.push({file:d,error:u??"Unknown error"});if(t.length>0){i.message(`Deleting ${t.length} files...`);let d=await $e(t,async c=>{try{return await Sn(c,r),{file:c,success:!0}}catch(u){let l=u instanceof Error?u.message:`${u}`;return{file:c,success:!1,error:l}}},Oe);for(let c of d)c.success?s.deleted.push(c.file):s.failed.push({file:c.file,error:c.error})}return s},Tn=e=>{if(e.success.length>0){w.success(`Successfully updated ${e.success.length} files:`);for(let t of e.success)w.info(` \u2713 ${t}`)}if(e.deleted.length>0){w.success(`Deleted ${e.deleted.length} files:`);for(let t of e.deleted)w.info(` \u{1F5D1} ${t}`)}if(e.failed.length>0){w.warn(`Failed to update ${e.failed.length} files:`);for(let{file:t,error:n}of e.failed)w.error(` \u2717 ${t}: ${n}`)}},In=e=>e.includes("canary")?"canary":"latest",vn=async e=>{let t=await fetch(`https://registry.npmjs.org/${encodeURIComponent(S)}`);if(!t.ok)throw new Error(`Failed to resolve ${S}@${e}`);let r=(await t.json())["dist-tags"]?.[e];if(!r)throw new Error(`Could not find dist-tag ${e} for ${S}`);return r},Pn=async e=>{let t=await M(e),n=J(t,S);if(!n)return{currentVersion:n,nextVersion:void 0,updated:!1};let r=In(n),i=await vn(r);return n===i?{currentVersion:n,nextVersion:i,updateTag:r,updated:!1}:($(t,S,i),await O(e,t),{currentVersion:n,nextVersion:i,updateTag:r,updated:!0})},An=async(e,t,n)=>{let r=await M(e);if(!le(r,S))return!1;t&&t.length>0&&w.warn("Ignoring file patterns for a package-based site. This update will bump the package version instead."),n?.sync&&w.warn("Ignoring --sync for a package-based site. Runtime updates now come from the package version.");let{currentVersion:i,nextVersion:s,updateTag:o,updated:a}=await Pn(e);if(!a)return w.success(i?`@vercel/geistdocs is already at ${s} (${o}).`:"No package version update was needed."),B("Package-based site is already up to date."),!0;w.info(`Bumping ${S} from ${i} to ${s} (${o})`);let d=Ge();return d.start("Installing updated package version..."),await T("pnpm",["install"],{cwd:e}),d.stop("Package update complete!"),B("Please review and test the upgraded package version."),!0},Mn=async(e,t,n,r,i)=>{let s=v(e,te),o=Ge(),a=i?.sync?s:t;o.start("Preparing template snapshot..."),i?.sync&&(await xn(e,te),await N(s)),o.message("Scanning for files...");let d=await Ce(n,r,a),c=[];if(i?.sync){o.message("Comparing with local files...");let l=await Ce(n,r,e),m=new Set(d);c=l.filter(f=>!m.has(f))}if(o.stop(`Found ${d.length} files to update`),d.length===0&&c.length===0){w.warn("No files matched the patterns. Nothing to update."),i?.sync&&await ne(s),B("Update cancelled.");return}w.info(`Patterns: ${n.length}`),w.info(`Files to update: ${d.length}`),i?.sync&&w.info(`Files to delete: ${c.length}`),o.start("Updating files...");let u=await _n(d,c,a,e,o);i?.sync&&(o.message("Cleaning up..."),await ne(s)),o.stop("Update complete!"),Tn(u),B("Please review and test the changes carefully.")},Ue=async(e,t)=>{let n=process.cwd(),r=H(),i=e&&e.length>0?e:wn,s=e&&e.length>0?[]:yn;try{if(fn("Let's update your Geistdocs project!"),await An(n,e,t))return;w.info("Template source: bundled package snapshot"),e&&e.length>0&&w.info(`Updating specific files: ${e.join(", ")}`),t?.sync&&w.info("Sync mode enabled: will delete files removed from template"),await Mn(n,r,i,s,t)}catch(o){let a=o instanceof Error?o.message:`${o}`;try{await ne(v(n,te))}catch{}w.error(`Failed to update project: ${a}`),process.exit(1)}};A.name("geistdocs").description("CLI for Geistdocs projects").version("2.4.2","-v, --version","Output the current version");A.command("init").description("Initialize a new Geistdocs project").option("--name <name>","Name of the project").addOption(new Rn("--brand <brand>","Navbar brand").choices(["vercel","labs"]).default("vercel")).option("--disable-git","Disable git initialization").action(he);A.command("update [files...]").description("Update a Geistdocs project (optionally specify files/patterns to update)").option("--sync","Delete local files that no longer exist in the template").action(Ue);A.command("translate [pattern]").description("Translate MDX file(s) to one or more locales (default: content/docs/**/*.mdx)").option("--config <path>","Path to config file to load locales from (defaults to geistdocs.tsx)").option("--url <url>","Custom translation API URL (defaults to GEISTDOCS_TRANSLATE_URL or https://geistdocs.com/translate)").option("--force","Force re-translation of all files, ignoring cache").action(ke);var Fn=A.command("search").description("Manage the external search index used by Ask AI");Fn.command("sync").description("Sync the latest static docs export to Mixedbread").option("--dir <path>","Next.js output directory",".next").option("--allow-non-production","Run outside a production Vercel build").action(Pe);await A.parseAsync(process.argv).catch(e=>{console.error(e instanceof Error?e.message:e),process.exitCode=1});
7
+ `));let o=await Ie({client:we({apiBaseUrl:process.env.MXBAI_BASE_URL,apiKey:r,storeId:i}),manifest:s,...Nt(n)});console.log(`Geistdocs search sync complete: ${o.uploaded} uploaded, ${o.deleted} deleted, ${o.skipped} unchanged.`)};import{readFileSync as Gt,writeFileSync as Ut}from"fs";import{mkdir as Lt,readFile as Z,writeFile as jt}from"fs/promises";import{dirname as Bt,extname as Vt,relative as Fe,resolve as j}from"path";import{intro as Jt,isCancel as Ht,log as I,multiselect as Xt,outro as L,spinner as Kt}from"@clack/prompts";import{glob as Yt}from"glob";import{Node as F,Project as qt,SyntaxKind as zt}from"ts-morph";var Wt="geistdocs.tsx",Qt="content/docs/**/*.mdx",ee=".translation-cache.json",Q=8,Ae=()=>({version:1,entries:{}}),Zt=async e=>{let t=await Z(e),{createHash:n}=await import("crypto");return n("sha256").update(t).digest("hex")},en=e=>{let t=j(process.cwd(),e);return Gt(t,"utf8")},Me=e=>F.isObjectLiteralExpression(e)?e.getProperties().flatMap(t=>{if(F.isPropertyAssignment(t)){let n=t.getNameNode();if(F.isIdentifier(n)||F.isStringLiteral(n))return[n.getText().replaceAll(/['"]/g,"")]}return[]}).filter(Boolean):[],tn=e=>{try{let t=new qt({compilerOptions:{allowJs:!0,jsx:4,module:99,target:10},skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!0}),n=en(e),s=t.createSourceFile(e,n,{overwrite:!0}).getVariableDeclarations().find(a=>a.getName()==="translations")?.getInitializer();if(!s)return[];if(F.isObjectLiteralExpression(s))return Me(s);let o=s.getFirstDescendantByKind(zt.ObjectLiteralExpression);return o?Me(o):[]}catch(t){let n=t instanceof Error?t.message:`${t}`;return I.warn(`Failed to read locales from ${e}: ${n}`),[]}},nn=async()=>{let e=await Xt({message:"Which locales should be translated?",options:[{value:"cn",label:"Chinese (cn)"},{value:"jp",label:"Japanese (jp)"},{value:"es",label:"Spanish (es)"},{value:"fr",label:"French (fr)"},{value:"de",label:"German (de)"}],required:!0});return Ht(e)&&(L("Translation cancelled"),process.exit(0)),e},rn=async e=>(await Yt(e,{cwd:process.cwd(),absolute:!0,nodir:!0})).sort(),sn=async()=>{let e=j(process.cwd(),ee);try{let t=await Z(e,"utf8"),n=JSON.parse(t);return n.version!==1||!n.entries?Ae():{version:1,entries:n.entries}}catch{return Ae()}},Re=e=>{let t=j(process.cwd(),ee),n=JSON.stringify(e,null,2);Ut(t,n,"utf8")},on=async e=>{let t=await Promise.all(e.map(async n=>[n,await Zt(n)]));return Object.fromEntries(t)},an=(e,t)=>{let n=Vt(e);return`${e.slice(0,-n.length)}.${t}${n}`},De=(e,t)=>`${Fe(process.cwd(),e)}::${t}`,cn=(e,t,n,r,i=!1)=>{let s=[],o=0;for(let a of t){let d=n[a];for(let c of e){let u=an(a,c),l=De(a,c),m=r.entries[l];if(!i&&m?.hash===d){o+=1;continue}s.push({locale:c,sourceFile:a,sourceHash:d,targetFile:u})}}return{tasks:s,skippedCount:o}},dn=async e=>{await Lt(Bt(e),{recursive:!0})},ln=async(e,t,n)=>{let r=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t,locale:n})});if(!r.ok){let s=await r.text();throw new Error(`API request failed (${r.status}): ${s}`)}let i=await r.json();if(!i.translation)throw new Error("API response did not include a translation");return i.translation},pn=async(e,t,n)=>{let r=await Z(e.sourceFile,"utf8"),i=await ln(t,r,e.locale);await dn(e.targetFile),await jt(e.targetFile,i,"utf8"),n.entries[De(e.sourceFile,e.locale)]={hash:e.sourceHash,updatedAt:new Date().toISOString()}},ke=async(e,t)=>{Jt("Translate MDX content");let n=e??Qt,r=t.url||process.env.GEISTDOCS_TRANSLATE_URL||"https://geistdocs.com/translate",i=tn(t.config??Wt),s=await rn(n);s.length===0&&(I.error(`No MDX files found matching pattern: ${n}`),L("Translation cancelled"),process.exit(1)),I.info(`Found ${s.length} MDX file(s) matching pattern`),i.length===0&&(i=await nn());let o=j(process.cwd(),ee),a=await sn();await Re(a),I.info(`Using cache: ${o}`);let d=await on(s),{tasks:c,skippedCount:u}=cn(i,s,d,a,t.force);if(c.length===0){I.success("All translations are up to date!"),L(`Skipped ${u} file(s) (unchanged)`);return}let l=[];for(let h=0;h<c.length;h+=Q)l.push(c.slice(h,h+Q));I.info(`Processing ${c.length} translation(s) in ${l.length} batch(es) of up to ${Q}`),u>0&&I.info(`Skipped ${u} translation(s) (unchanged)`);let m=Kt();m.start("Translating content...");let f=0;for(let h of l)await Promise.all(h.map(async x=>{await pn(x,r,a),f+=1,m.message(`Translated ${f}/${c.length}: ${Fe(process.cwd(),x.targetFile)}`)})),await Re(a);m.stop("Translation complete!"),L(`Created/updated ${c.length} file(s)`)};import{access as un,copyFile as gn,mkdir as Ne,rm as re}from"fs/promises";import{dirname as mn,join as v}from"path";import{intro as fn,log as w,outro as B,spinner as Ge}from"@clack/prompts";import{glob as hn}from"glob";var wn=["**/*"],yn=["content/docs/**"],te=".geistdocs-tmp",xn=async(e,t)=>{let n=v(e,t);await re(n,{recursive:!0,force:!0}),await Ne(n,{recursive:!0})},ne=async e=>await re(e,{recursive:!0,force:!0}),Ce=async(e,t,n)=>(await hn(e,{cwd:n,nodir:!0,dot:!0,ignore:[".git/**",...t]})).sort(),bn=async e=>{try{return await un(e),!0}catch{return!1}},En=async(e,t,n)=>{let r=v(t,e),i=v(n,e);return await bn(r)?(await gn(r,i),{success:!0}):{success:!1,error:`Source file not found: ${r}`}},Sn=async(e,t)=>{let n=v(t,e);return await re(n,{force:!0}),{success:!0}},Oe=20,$e=async(e,t,n)=>{let r=[];for(let i=0;i<e.length;i+=n){let s=e.slice(i,i+n),o=await Promise.all(s.map(t));r.push(...o)}return r},_n=async(e,t,n,r,i)=>{let s={success:[],deleted:[],failed:[]},o=[...new Set(e.map(d=>mn(v(r,d))))];i.message(`Creating ${o.length} directories...`),await Promise.all(o.map(d=>Ne(d,{recursive:!0}))),i.message(`Updating ${e.length} files...`);let a=await $e(e,async d=>{let c=await En(d,n,r);return{file:d,...c}},Oe);for(let{file:d,success:c,error:u}of a)c?s.success.push(d):s.failed.push({file:d,error:u??"Unknown error"});if(t.length>0){i.message(`Deleting ${t.length} files...`);let d=await $e(t,async c=>{try{return await Sn(c,r),{file:c,success:!0}}catch(u){let l=u instanceof Error?u.message:`${u}`;return{file:c,success:!1,error:l}}},Oe);for(let c of d)c.success?s.deleted.push(c.file):s.failed.push({file:c.file,error:c.error})}return s},Tn=e=>{if(e.success.length>0){w.success(`Successfully updated ${e.success.length} files:`);for(let t of e.success)w.info(` \u2713 ${t}`)}if(e.deleted.length>0){w.success(`Deleted ${e.deleted.length} files:`);for(let t of e.deleted)w.info(` \u{1F5D1} ${t}`)}if(e.failed.length>0){w.warn(`Failed to update ${e.failed.length} files:`);for(let{file:t,error:n}of e.failed)w.error(` \u2717 ${t}: ${n}`)}},In=e=>e.includes("canary")?"canary":"latest",vn=async e=>{let t=await fetch(`https://registry.npmjs.org/${encodeURIComponent(S)}`);if(!t.ok)throw new Error(`Failed to resolve ${S}@${e}`);let r=(await t.json())["dist-tags"]?.[e];if(!r)throw new Error(`Could not find dist-tag ${e} for ${S}`);return r},Pn=async e=>{let t=await M(e),n=J(t,S);if(!n)return{currentVersion:n,nextVersion:void 0,updated:!1};let r=In(n),i=await vn(r);return n===i?{currentVersion:n,nextVersion:i,updateTag:r,updated:!1}:($(t,S,i),await O(e,t),{currentVersion:n,nextVersion:i,updateTag:r,updated:!0})},An=async(e,t,n)=>{let r=await M(e);if(!le(r,S))return!1;t&&t.length>0&&w.warn("Ignoring file patterns for a package-based site. This update will bump the package version instead."),n?.sync&&w.warn("Ignoring --sync for a package-based site. Runtime updates now come from the package version.");let{currentVersion:i,nextVersion:s,updateTag:o,updated:a}=await Pn(e);if(!a)return w.success(i?`@vercel/geistdocs is already at ${s} (${o}).`:"No package version update was needed."),B("Package-based site is already up to date."),!0;w.info(`Bumping ${S} from ${i} to ${s} (${o})`);let d=Ge();return d.start("Installing updated package version..."),await T("pnpm",["install"],{cwd:e}),d.stop("Package update complete!"),B("Please review and test the upgraded package version."),!0},Mn=async(e,t,n,r,i)=>{let s=v(e,te),o=Ge(),a=i?.sync?s:t;o.start("Preparing template snapshot..."),i?.sync&&(await xn(e,te),await N(s)),o.message("Scanning for files...");let d=await Ce(n,r,a),c=[];if(i?.sync){o.message("Comparing with local files...");let l=await Ce(n,r,e),m=new Set(d);c=l.filter(f=>!m.has(f))}if(o.stop(`Found ${d.length} files to update`),d.length===0&&c.length===0){w.warn("No files matched the patterns. Nothing to update."),i?.sync&&await ne(s),B("Update cancelled.");return}w.info(`Patterns: ${n.length}`),w.info(`Files to update: ${d.length}`),i?.sync&&w.info(`Files to delete: ${c.length}`),o.start("Updating files...");let u=await _n(d,c,a,e,o);i?.sync&&(o.message("Cleaning up..."),await ne(s)),o.stop("Update complete!"),Tn(u),B("Please review and test the changes carefully.")},Ue=async(e,t)=>{let n=process.cwd(),r=H(),i=e&&e.length>0?e:wn,s=e&&e.length>0?[]:yn;try{if(fn("Let's update your Geistdocs project!"),await An(n,e,t))return;w.info("Template source: bundled package snapshot"),e&&e.length>0&&w.info(`Updating specific files: ${e.join(", ")}`),t?.sync&&w.info("Sync mode enabled: will delete files removed from template"),await Mn(n,r,i,s,t)}catch(o){let a=o instanceof Error?o.message:`${o}`;try{await ne(v(n,te))}catch{}w.error(`Failed to update project: ${a}`),process.exit(1)}};A.name("geistdocs").description("CLI for Geistdocs projects").version("2.5.0","-v, --version","Output the current version");A.command("init").description("Initialize a new Geistdocs project").option("--name <name>","Name of the project").addOption(new Rn("--brand <brand>","Navbar brand").choices(["vercel","labs"]).default("vercel")).option("--disable-git","Disable git initialization").action(he);A.command("update [files...]").description("Update a Geistdocs project (optionally specify files/patterns to update)").option("--sync","Delete local files that no longer exist in the template").action(Ue);A.command("translate [pattern]").description("Translate MDX file(s) to one or more locales (default: content/docs/**/*.mdx)").option("--config <path>","Path to config file to load locales from (defaults to geistdocs.tsx)").option("--url <url>","Custom translation API URL (defaults to GEISTDOCS_TRANSLATE_URL or https://geistdocs.com/translate)").option("--force","Force re-translation of all files, ignoring cache").action(ke);var Fn=A.command("search").description("Manage the external search index used by Ask AI");Fn.command("sync").description("Sync the latest static docs export to Mixedbread").option("--dir <path>","Next.js output directory",".next").option("--allow-non-production","Run outside a production Vercel build").action(Pe);await A.parseAsync(process.argv).catch(e=>{console.error(e instanceof Error?e.message:e),process.exitCode=1});
package/dist/config.d.ts CHANGED
@@ -58,6 +58,11 @@ export interface GeistdocsFeatureConfig {
58
58
  enabled?: boolean;
59
59
  }
60
60
  export interface GeistdocsEveAgentConfig {
61
+ /**
62
+ * Start an empty eve session when Ask AI loads so the first message can skip
63
+ * workflow startup latency. Requires eve 0.59 or newer. @default false
64
+ */
65
+ prewarm?: boolean;
61
66
  /**
62
67
  * Base URL of a deployed eve framework agent, such as
63
68
  * `"https://help-eve.vercel.app"`. When set, Ask AI requests are answered
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAA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;IAClC,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACzB,yCAAyC;IACzC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,WAAW,CAAC,EAAE,oBAAoB,CAAC;IACnC;;;OAGG;IACH,YAAY,CAAC,EAAE,sBAAsB,CAAC;IACtC,iBAAiB,CAAC,EAAE,yBAAyB,EAAE,CAAC;IAChD,aAAa,CAAC,EAAE,KAAK,GAAG,UAAU,CAAC;IACnC,WAAW,CAAC,EAAE,0BAA0B,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,sBAAsB,CAAC;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2EAA2E;IAC3E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,KAAK,CAAC,EAAE,sBAAsB,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,qBAAqB,CAAC;IACrC,QAAQ,CAAC,EAAE,uBAAuB,CAAC;IACnC,MAAM,CAAC,EAAE,sBAAsB,CAAC;CACjC;AAED,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,eAAe,EAAE,QAAQ,CAAC,KAAG,CAAW,CAAC"}
@@ -6,6 +6,7 @@ interface GeistdocsChatContextValue {
6
6
  hasBeenOpened: boolean;
7
7
  isOpen: boolean;
8
8
  preloadChat: () => void;
9
+ prewarmEveAgent: boolean;
9
10
  prompt: string;
10
11
  setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;
11
12
  setPrompt: React.Dispatch<React.SetStateAction<string>>;
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/context.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,eAAe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f,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IACzD,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;IACxD,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;CACf;AAMD,eAAO,MAAM,gBAAgB,iCAQ5B,CAAC;AAEF,UAAU,0BAA0B;IAClC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,IAAI,GAAG,UAAU,GAAG,OAAO,CAAC,CAAC;CAC5D;AAED,eAAO,MAAM,qBAAqB,GAAI,uBAGnC,0BAA0B,4CA0D5B,CAAC"}
@@ -40,6 +40,7 @@ export const GeistdocsChatProvider = ({ children, config, }) => {
40
40
  hasBeenOpened,
41
41
  isOpen,
42
42
  preloadChat,
43
+ prewarmEveAgent: config.ai?.eveAgent?.prewarm === true,
43
44
  prompt,
44
45
  setIsOpen,
45
46
  setPrompt,
@@ -1 +1 @@
1
- {"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/shell.tsx"],"names":[],"mappings":"AAwYA,eAAO,MAAM,kBAAkB,sDAsD9B,CAAC"}
1
+ {"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/shell.tsx"],"names":[],"mappings":"AA8aA,eAAO,MAAM,kBAAkB,sDAsD9B,CAAC"}
@@ -17,6 +17,7 @@ import { useToasts } from "#geistdocs-ui/components/toasts";
17
17
  import { Tooltip } from "#geistdocs-ui/components/tooltip";
18
18
  import { cn } from "#geistdocs-ui/utils";
19
19
  import { getPublicPath } from "../../config";
20
+ import { requestEveAgentPrewarm } from "../eve-agent-session.js";
20
21
  import { useIsMobile } from "../use-mobile";
21
22
  import { isActiveAssistantMessage, shouldShowPendingActivity, } from "./activity";
22
23
  import { useGeistdocsChat } from "./context";
@@ -80,6 +81,10 @@ const useChatPersistence = (title) => {
80
81
  }, [db]);
81
82
  const clearMessages = useCallback(async () => {
82
83
  try {
84
+ if (saveTimeoutRef.current) {
85
+ clearTimeout(saveTimeoutRef.current);
86
+ saveTimeoutRef.current = undefined;
87
+ }
83
88
  await db.messages.clear();
84
89
  }
85
90
  catch (error) {
@@ -102,21 +107,28 @@ const GeistdocsChatInner = ({ isOpen }) => {
102
107
  const id = useId();
103
108
  const pathname = usePathname();
104
109
  const textareaRef = useRef(null);
110
+ const prewarmPromiseRef = useRef(null);
105
111
  const [isInitialized, setIsInitialized] = useState(false);
106
112
  const toast = useToasts();
107
- const { prompt, setPrompt, setIsOpen, title, basePath, footer, suggestions } = useGeistdocsChat();
113
+ const { prompt, setPrompt, setIsOpen, title, basePath, footer, prewarmEveAgent, suggestions, } = useGeistdocsChat();
108
114
  const { initialMessages, isLoading, saveMessages, clearMessages } = useChatPersistence(title);
115
+ const chatApi = getPublicPath("/api/chat", basePath);
109
116
  const { messages, sendMessage, status, setMessages, stop } = useChat({
110
117
  id,
111
118
  transport: new DefaultChatTransport({
112
- api: getPublicPath("/api/chat", basePath),
113
- prepareSendMessagesRequest: ({ body, messages }) => ({
114
- body: {
115
- ...body,
116
- messages,
117
- currentRoute: pathname,
118
- },
119
- }),
119
+ api: chatApi,
120
+ prepareSendMessagesRequest: async ({ body, messages }) => {
121
+ const prewarmedSession = await prewarmPromiseRef.current;
122
+ prewarmPromiseRef.current = null;
123
+ return {
124
+ body: {
125
+ ...body,
126
+ messages,
127
+ currentRoute: pathname,
128
+ eveAgentSession: prewarmedSession ?? undefined,
129
+ },
130
+ };
131
+ },
120
132
  }),
121
133
  onError: (error) => {
122
134
  toast.error({ text: error.message });
@@ -131,6 +143,14 @@ const GeistdocsChatInner = ({ isOpen }) => {
131
143
  setIsInitialized(true);
132
144
  }
133
145
  }, [initialMessages, isInitialized, isLoading, setMessages]);
146
+ useEffect(() => {
147
+ if (prewarmEveAgent &&
148
+ isInitialized &&
149
+ messages.length === 0 &&
150
+ prewarmPromiseRef.current === null) {
151
+ prewarmPromiseRef.current = requestEveAgentPrewarm({ apiUrl: chatApi });
152
+ }
153
+ }, [chatApi, isInitialized, messages.length, prewarmEveAgent]);
134
154
  useEffect(() => {
135
155
  if (isInitialized && messages.length > 0) {
136
156
  saveMessages(messages);
@@ -176,7 +196,9 @@ const GeistdocsChatInner = ({ isOpen }) => {
176
196
  if (isLoading) {
177
197
  return (_jsx("div", { className: "flex size-full w-full flex-col items-center justify-center overflow-hidden whitespace-nowrap rounded-xl xl:max-w-md xl:border xl:bg-background-100", children: _jsx(Spinner, {}) }));
178
198
  }
179
- return (_jsxs("aside", { "aria-label": "Ask AI chat", className: "flex size-full w-full flex-col overflow-hidden whitespace-nowrap bg-background-100", children: [_jsxs("div", { className: "sticky top-0 z-10 flex h-16 items-center justify-between bg-background-100 py-2 pr-2 pl-3.5", children: [_jsx("h2", { className: "font-semibold text-sm", children: "Ask AI" }), _jsxs("div", { className: "flex items-center gap-0.5", children: [_jsx(CopyChat, { messages: messages }), _jsx(Tooltip, { position: "bottom", text: "Delete chat", children: _jsx(Button, { "aria-label": "Delete chat", className: "text-gray-800! disabled:bg-gray-alpha-100!", disabled: messages.length === 0, onClick: handleClearChat, shape: "square", size: "small", svgOnly: true, typeName: "button", variant: "tertiary", children: _jsx(IconTrash, { size: 14 }) }) }), _jsx(Tooltip, { position: "bottom", text: "Close chat", children: _jsx(Button, { "aria-label": "Close chat", className: "text-gray-800! shadow-none", onClick: () => setIsOpen(false), shape: "square", size: "small", svgOnly: true, typeName: "button", variant: "tertiary", children: _jsx(IconChevronDoubleRight, { size: 14 }) }) })] })] }), _jsxs(Conversation, { children: [_jsxs(ConversationContent, { children: [messages.map((message, index) => (_jsxs(Message, { from: message.role, children: [_jsx(MessageMetadata, { inProgress: isActiveAssistantMessage({
199
+ return (_jsxs("aside", { "aria-label": "Ask AI chat", className: "flex size-full w-full flex-col overflow-hidden whitespace-nowrap bg-background-100", children: [_jsxs("div", { className: "sticky top-0 z-10 flex h-16 items-center justify-between bg-background-100 py-2 pr-2 pl-3.5", children: [_jsx("h2", { className: "font-semibold text-sm", children: "Ask AI" }), _jsxs("div", { className: "flex items-center gap-0.5", children: [_jsx(CopyChat, { messages: messages }), _jsx(Tooltip, { position: "bottom", text: "Delete chat", children: _jsx(Button, { "aria-label": "Delete chat", className: "text-gray-800! disabled:bg-gray-alpha-100!", disabled: messages.length === 0 ||
200
+ status === "streaming" ||
201
+ status === "submitted", onClick: handleClearChat, shape: "square", size: "small", svgOnly: true, typeName: "button", variant: "tertiary", children: _jsx(IconTrash, { size: 14 }) }) }), _jsx(Tooltip, { position: "bottom", text: "Close chat", children: _jsx(Button, { "aria-label": "Close chat", className: "text-gray-800! shadow-none", onClick: () => setIsOpen(false), shape: "square", size: "small", svgOnly: true, typeName: "button", variant: "tertiary", children: _jsx(IconChevronDoubleRight, { size: 14 }) }) })] })] }), _jsxs(Conversation, { children: [_jsxs(ConversationContent, { children: [messages.map((message, index) => (_jsxs(Message, { from: message.role, children: [_jsx(MessageMetadata, { inProgress: isActiveAssistantMessage({
180
202
  index,
181
203
  messages,
182
204
  status,
@@ -0,0 +1,12 @@
1
+ export interface EveAgentSessionHandle {
2
+ sessionId: string;
3
+ /** Absolute count of NDJSON events consumed from the session stream. */
4
+ streamIndex: number;
5
+ }
6
+ export declare const isEveAgentSessionHandle: (value: unknown) => value is EveAgentSessionHandle;
7
+ export declare const requestEveAgentPrewarm: ({ apiUrl, fetchImpl, timeoutMs, }: {
8
+ apiUrl: string;
9
+ fetchImpl?: typeof fetch;
10
+ timeoutMs?: number;
11
+ }) => Promise<EveAgentSessionHandle | null>;
12
+ //# sourceMappingURL=eve-agent-session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eve-agent-session.d.ts","sourceRoot":"","sources":["../../src/internal/eve-agent-session.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,wEAAwE;IACxE,WAAW,EAAE,MAAM,CAAC;CACrB;AAKD,eAAO,MAAM,uBAAuB,GAClC,OAAO,OAAO,KACb,KAAK,IAAI,qBAMY,CAAC;AAEzB,eAAO,MAAM,sBAAsB,GAAU,mCAI1C;IACD,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,KAAG,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAkBvC,CAAC"}
@@ -0,0 +1,26 @@
1
+ const PREWARM_TIMEOUT_MS = 20_000;
2
+ const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
3
+ export const isEveAgentSessionHandle = (value) => isRecord(value) &&
4
+ typeof value.sessionId === "string" &&
5
+ value.sessionId.length > 0 &&
6
+ typeof value.streamIndex === "number" &&
7
+ Number.isInteger(value.streamIndex) &&
8
+ value.streamIndex >= 0;
9
+ export const requestEveAgentPrewarm = async ({ apiUrl, fetchImpl = fetch, timeoutMs = PREWARM_TIMEOUT_MS, }) => {
10
+ try {
11
+ const response = await fetchImpl(apiUrl, {
12
+ method: "POST",
13
+ body: JSON.stringify({ prewarm: true }),
14
+ headers: { "Content-Type": "application/json" },
15
+ signal: AbortSignal.timeout(timeoutMs),
16
+ });
17
+ if (!response.ok) {
18
+ return null;
19
+ }
20
+ const body = await response.json();
21
+ return isEveAgentSessionHandle(body) ? body : null;
22
+ }
23
+ catch {
24
+ return null;
25
+ }
26
+ };
@@ -1,9 +1,6 @@
1
1
  import type { UIMessage, UIMessageChunk, UIMessageStreamWriter } from "ai";
2
- export interface EveAgentSessionHandle {
3
- sessionId: string;
4
- /** Absolute count of NDJSON events consumed from the session stream. */
5
- streamIndex: number;
6
- }
2
+ import { type EveAgentSessionHandle } from "./eve-agent-session.js";
3
+ export type { EveAgentSessionHandle } from "./eve-agent-session.js";
7
4
  export interface RunEveAgentTurnOptions {
8
5
  /** Base URL of the deployed eve agent. */
9
6
  agentUrl: string;
@@ -67,6 +64,13 @@ export declare const extractSourceUrls: (value: unknown, limit?: number) => {
67
64
  title?: string;
68
65
  url: string;
69
66
  }[];
67
+ /** Start an eve session without a turn so the first message can reuse it. */
68
+ export declare const prewarmEveAgentSession: ({ agentUrl, fetchImpl, headers, signal, }: {
69
+ agentUrl: string;
70
+ fetchImpl?: typeof fetch;
71
+ headers?: HeadersInit;
72
+ signal?: AbortSignal;
73
+ }) => Promise<EveAgentSessionHandle>;
70
74
  /**
71
75
  * Run a single Ask AI turn against a hosted eve agent, writing AI SDK UI
72
76
  * message chunks to the provided writer.
@@ -1 +1 @@
1
- {"version":3,"file":"eve-agent.d.ts","sourceRoot":"","sources":["../../src/internal/eve-agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,IAAI,CAAC;AA2B3E,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,wEAAwE;IACxE,WAAW,EAAE,MAAM,CAAC;CACrB;AA4BD,MAAM,WAAW,sBAAsB;IACrC,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,kEAAkE;IAClE,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IACzB,mDAAmD;IACnD,MAAM,CAAC,EAAE,qBAAqB,GAAG,IAAI,CAAC;IACtC,uDAAuD;IACvD,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB;;;OAGG;IACH,aAAa,CAAC,EAAE,cAAc,EAAE,CAAC;IACjC,gEAAgE;IAChE,OAAO,EAAE,MAAM,CAAC;IAChB,qEAAqE;IACrE,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,MAAM,EAAE,qBAAqB,CAAC;CAC/B;AAsBD;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,GACnC,UAAU,SAA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1
+ import { isEveAgentSessionHandle, } from "./eve-agent-session.js";
1
2
  /**
2
3
  * Client for the eve framework's session HTTP API, translating eve's NDJSON
3
4
  * event stream into AI SDK UI message chunks.
@@ -16,6 +17,9 @@
16
17
  */
17
18
  const EVE_SESSION_PATH = "/eve/v1/session";
18
19
  const CANCEL_TIMEOUT_MS = 5000;
20
+ const SESSION_SEND_RETRY_BASE_DELAY_MS = 250;
21
+ const SESSION_SEND_RETRY_MAX_DELAY_MS = 2000;
22
+ const SESSION_SEND_READY_TIMEOUT_MS = 20_000;
19
23
  const MAX_TRANSCRIPT_TURN_CHARS = 2000;
20
24
  const MAX_TRANSCRIPT_TOTAL_CHARS = 8000;
21
25
  const MAX_SOURCES_PER_ACTION = 5;
@@ -27,12 +31,6 @@ const getMessageText = (message) => message.parts
27
31
  .filter((part) => part.type === "text")
28
32
  .map((part) => part.text)
29
33
  .join("\n");
30
- const isSessionHandle = (value) => isRecord(value) &&
31
- typeof value.sessionId === "string" &&
32
- value.sessionId.length > 0 &&
33
- typeof value.streamIndex === "number" &&
34
- Number.isInteger(value.streamIndex) &&
35
- value.streamIndex >= 0;
36
34
  /**
37
35
  * Read the eve session handle persisted on the most recent assistant
38
36
  * message. The handle round-trips through the client: it is written to
@@ -47,7 +45,7 @@ export const getEveAgentSessionHandle = (messages) => {
47
45
  }
48
46
  const handle = message.metadata
49
47
  ?.eveAgent;
50
- return isSessionHandle(handle) ? handle : null;
48
+ return isEveAgentSessionHandle(handle) ? handle : null;
51
49
  }
52
50
  return null;
53
51
  };
@@ -164,6 +162,20 @@ const parseSessionResponse = async (response) => {
164
162
  }
165
163
  return { sessionId: body.sessionId };
166
164
  };
165
+ /** Start an eve session without a turn so the first message can reuse it. */
166
+ export const prewarmEveAgentSession = async ({ agentUrl, fetchImpl = fetch, headers, signal, }) => {
167
+ const response = await fetchImpl(`${normalizeAgentUrl(agentUrl)}${EVE_SESSION_PATH}`, {
168
+ method: "POST",
169
+ body: JSON.stringify({}),
170
+ headers,
171
+ signal,
172
+ });
173
+ if (!response.ok) {
174
+ throw new Error(`eve agent session prewarm failed with status ${response.status}.`);
175
+ }
176
+ const session = await parseSessionResponse(response);
177
+ return { sessionId: session.sessionId, streamIndex: 0 };
178
+ };
167
179
  const isTurnBoundaryEvent = (type) => type === "session.waiting" ||
168
180
  type === "session.completed" ||
169
181
  type === "session.failed";
@@ -350,14 +362,55 @@ const createEveEventTranslator = (writer) => {
350
362
  isSessionWaiting: () => sessionWaiting,
351
363
  };
352
364
  };
353
- const startOrContinueSession = async ({ agentUrl, fallbackMessage, fetchImpl, handle, headers, message, signal, }) => {
354
- if (handle) {
365
+ const waitForRetry = (delayMs, signal) => new Promise((resolve, reject) => {
366
+ const onAbort = () => {
367
+ clearTimeout(timeout);
368
+ reject(signal?.reason ??
369
+ new DOMException("The operation was aborted.", "AbortError"));
370
+ };
371
+ const timeout = setTimeout(() => {
372
+ signal?.removeEventListener("abort", onAbort);
373
+ resolve();
374
+ }, delayMs);
375
+ if (signal?.aborted) {
376
+ onAbort();
377
+ return;
378
+ }
379
+ signal?.addEventListener("abort", onAbort, { once: true });
380
+ });
381
+ const postSessionMessage = async ({ agentUrl, fetchImpl, handle, headers, message, signal, }) => {
382
+ const readyDeadline = Date.now() + SESSION_SEND_READY_TIMEOUT_MS;
383
+ let retryDelayMs = SESSION_SEND_RETRY_BASE_DELAY_MS;
384
+ for (;;) {
355
385
  const response = await fetchImpl(`${agentUrl}${EVE_SESSION_PATH}/${encodeURIComponent(handle.sessionId)}`, {
356
386
  method: "POST",
357
387
  body: JSON.stringify({ message }),
358
388
  headers,
359
389
  signal,
360
390
  });
391
+ if (response.ok || response.status !== 409) {
392
+ return { response };
393
+ }
394
+ const body = await response.json().catch(() => null);
395
+ const code = isRecord(body) && typeof body.code === "string" ? body.code : undefined;
396
+ if (code !== "session_not_ready" || Date.now() >= readyDeadline) {
397
+ return { code, response };
398
+ }
399
+ const remainingMs = readyDeadline - Date.now();
400
+ await waitForRetry(Math.min(retryDelayMs, remainingMs), signal);
401
+ retryDelayMs = Math.min(retryDelayMs * 2, SESSION_SEND_RETRY_MAX_DELAY_MS);
402
+ }
403
+ };
404
+ const startOrContinueSession = async ({ agentUrl, fallbackMessage, fetchImpl, handle, headers, message, signal, }) => {
405
+ if (handle) {
406
+ const { code, response } = await postSessionMessage({
407
+ agentUrl,
408
+ fetchImpl,
409
+ handle,
410
+ headers,
411
+ message,
412
+ signal,
413
+ });
361
414
  if (response.ok) {
362
415
  const session = await parseSessionResponse(response);
363
416
  if (session.sessionId !== handle.sessionId) {
@@ -367,12 +420,7 @@ const startOrContinueSession = async ({ agentUrl, fallbackMessage, fetchImpl, ha
367
420
  }
368
421
  // Ask AI recovers from an inactive session by explicitly creating a new
369
422
  // one with the bounded transcript.
370
- let inactive = false;
371
- if (response.status === 409) {
372
- const body = await response.json().catch(() => null);
373
- inactive = isRecord(body) && body.code === "session_not_active";
374
- }
375
- if (!inactive) {
423
+ if (code !== "session_not_active") {
376
424
  throw new Error(`eve agent follow-up failed with status ${response.status}.`);
377
425
  }
378
426
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mdx-to-markdown.d.ts","sourceRoot":"","sources":["../../src/internal/mdx-to-markdown.ts"],"names":[],"mappings":"AA+SA,yEAAyE;AACzE,eAAO,MAAM,aAAa,GAAU,QAAQ,MAAM,oBACF,CAAC"}
1
+ {"version":3,"file":"mdx-to-markdown.d.ts","sourceRoot":"","sources":["../../src/internal/mdx-to-markdown.ts"],"names":[],"mappings":"AAkYA,yEAAyE;AACzE,eAAO,MAAM,aAAa,GAAU,QAAQ,MAAM,oBAcjD,CAAC"}
@@ -231,5 +231,72 @@ const processor = unified()
231
231
  bullet: "-",
232
232
  fences: true,
233
233
  });
234
+ // Fumadocs' processed text decodes HTML entities, so authored `&lt;` can come
235
+ // back as a literal `<` that is no longer valid MDX (`Record<string, string>`,
236
+ // `Promise<void>`). Escaping the offending `<` restores the author's intent:
237
+ // the sequence is text, not a tag.
238
+ const escapeTagAt = (source, line, column) => {
239
+ const lines = source.split("\n");
240
+ const text = lines[line - 1];
241
+ if (text?.[column - 1] !== "<") {
242
+ return undefined;
243
+ }
244
+ lines[line - 1] = `${text.slice(0, column - 1)}&lt;${text.slice(column)}`;
245
+ return lines.join("\n");
246
+ };
247
+ // Walk back from the offending character over a JSX name to its `<`.
248
+ const escapeTagBefore = (source, line, column) => {
249
+ const lines = source.split("\n");
250
+ const text = lines[line - 1];
251
+ if (!text) {
252
+ return undefined;
253
+ }
254
+ for (const start of [column - 1, column - 2]) {
255
+ let index = Math.min(start, text.length - 1);
256
+ while (index >= 0 && NAME_CHARACTER.test(text[index])) {
257
+ index -= 1;
258
+ }
259
+ if (text[index] === "<") {
260
+ lines[line - 1] = `${text.slice(0, index)}&lt;${text.slice(index + 1)}`;
261
+ return lines.join("\n");
262
+ }
263
+ }
264
+ return undefined;
265
+ };
266
+ const NAME_CHARACTER = /[\w$.-]/;
267
+ const UNCLOSED_TAG_PATTERN = /expected corresponding closing tag for `<[^`]+>` \((\d+):(\d+)-/;
268
+ const escapeOffendingText = (source, error) => {
269
+ if (error.source !== "micromark-extension-mdx-jsx" &&
270
+ error.source !== "mdast-util-mdx-jsx") {
271
+ return undefined;
272
+ }
273
+ const unclosed = UNCLOSED_TAG_PATTERN.exec(error.message);
274
+ if (unclosed) {
275
+ return escapeTagAt(source, Number(unclosed[1]), Number(unclosed[2]));
276
+ }
277
+ if (error.ruleId === "unexpected-character" && error.place) {
278
+ const { line, column } = error.place;
279
+ if (line && column) {
280
+ return escapeTagBefore(source, line, column);
281
+ }
282
+ }
283
+ return undefined;
284
+ };
285
+ const MAX_ESCAPES = 100;
234
286
  /** Convert authored MDX into component-free, agent-readable Markdown. */
235
- export const mdxToMarkdown = async (source) => String(await processor.process(source)).trim();
287
+ export const mdxToMarkdown = async (source) => {
288
+ let input = source;
289
+ for (let attempt = 0; attempt <= MAX_ESCAPES; attempt += 1) {
290
+ try {
291
+ return String(await processor.process(input)).trim();
292
+ }
293
+ catch (error) {
294
+ const escaped = escapeOffendingText(input, error);
295
+ if (!escaped || escaped === input || attempt === MAX_ESCAPES) {
296
+ throw error;
297
+ }
298
+ input = escaped;
299
+ }
300
+ }
301
+ return "";
302
+ };
@@ -1,9 +1,21 @@
1
1
  import { RootProvider } from "fumadocs-ui/provider/next";
2
2
  import { type ComponentProps } from "react";
3
3
  import type { GeistdocsConfig } from "../config";
4
- export interface GeistdocsProviderProps extends ComponentProps<typeof RootProvider> {
4
+ import { GeistdocsSearchDialog } from "./search";
5
+ type RootProviderSearch = NonNullable<ComponentProps<typeof RootProvider>["search"]>;
6
+ export interface GeistdocsProviderProps extends Omit<ComponentProps<typeof RootProvider>, "search"> {
5
7
  config: GeistdocsConfig;
6
8
  lang?: string;
9
+ /**
10
+ * fumadocs types `search.options` against its own default dialog, which this
11
+ * provider replaces. Typed here against the dialog actually rendered, so
12
+ * props it accepts — `tag` — can be passed, and props only the default
13
+ * dialog reads cannot be passed and silently ignored.
14
+ */
15
+ search?: Omit<RootProviderSearch, "options"> & {
16
+ options?: Partial<ComponentProps<typeof GeistdocsSearchDialog>>;
17
+ };
7
18
  }
8
19
  export declare const GeistdocsProvider: (props: GeistdocsProviderProps) => import("react/jsx-runtime").JSX.Element;
20
+ export {};
9
21
  //# sourceMappingURL=provider-client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"provider-client.d.ts","sourceRoot":"","sources":["../../src/internal/provider-client.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EACL,KAAK,cAAc,EAKpB,MAAM,OAAO,CAAC;AAIf,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAejD,MAAM,WAAW,sBACf,SAAQ,cAAc,CAAC,OAAO,YAAY,CAAC;IAC3C,MAAM,EAAE,eAAe,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAmFD,eAAO,MAAM,iBAAiB,GAAI,OAAO,sBAAsB,4CAQ9D,CAAC"}
1
+ {"version":3,"file":"provider-client.d.ts","sourceRoot":"","sources":["../../src/internal/provider-client.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EACL,KAAK,cAAc,EAKpB,MAAM,OAAO,CAAC;AAIf,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAKjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAUjD,KAAK,kBAAkB,GAAG,WAAW,CACnC,cAAc,CAAC,OAAO,YAAY,CAAC,CAAC,QAAQ,CAAC,CAC9C,CAAC;AAEF,MAAM,WAAW,sBACf,SAAQ,IAAI,CAAC,cAAc,CAAC,OAAO,YAAY,CAAC,EAAE,QAAQ,CAAC;IAC3D,MAAM,EAAE,eAAe,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;OAKG;IACH,MAAM,CAAC,EAAE,IAAI,CAAC,kBAAkB,EAAE,SAAS,CAAC,GAAG;QAC7C,OAAO,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,OAAO,qBAAqB,CAAC,CAAC,CAAC;KACjE,CAAC;CACH;AAmFD,eAAO,MAAM,iBAAiB,GAAI,OAAO,sBAAsB,4CAQ9D,CAAC"}
@@ -1,6 +1,19 @@
1
1
  import { type SharedProps } from "fumadocs-ui/components/dialog/search";
2
- export declare const GeistdocsSearchDialog: ({ basePath, tag, ...props }: SharedProps & {
2
+ import type { TagItem } from "fumadocs-ui/contexts/search";
3
+ export declare const GeistdocsSearchDialog: ({ allowClear, basePath, onTagChange, tag, tags, ...props }: SharedProps & {
4
+ /**
5
+ * Let a reader clear the selected scope and search everything. Only meaningful
6
+ * alongside `tags`.
7
+ *
8
+ * @defaultValue false
9
+ */
10
+ allowClear?: boolean;
3
11
  basePath?: string;
12
+ /**
13
+ * Called when a reader picks a scope, for consumers that persist the choice
14
+ * across sessions. The dialog holds the selection either way.
15
+ */
16
+ onTagChange?: (tag: string | undefined) => void;
4
17
  /**
5
18
  * Scope passed through to the search route as fumadocs' `tag` query
6
19
  * parameter, for sites whose index is partitioned (by version, section, or
@@ -16,5 +29,14 @@ export declare const GeistdocsSearchDialog: ({ basePath, tag, ...props }: Shared
16
29
  * entry, and the second would be served the first's results.
17
30
  */
18
31
  tag?: string | string[];
32
+ /**
33
+ * Scopes a reader can switch between, rendered as a row of pills under the
34
+ * results. Without them the scope is whatever `tag` says and the reader
35
+ * cannot change it; with them `tag` is the initial selection.
36
+ *
37
+ * Pills carry a single scope each, so `tag` should be a string when they are
38
+ * used. An array scope stays in force but selects no pill.
39
+ */
40
+ tags?: TagItem[];
19
41
  }) => import("react/jsx-runtime").JSX.Element;
20
42
  //# sourceMappingURL=search.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/internal/search.tsx"],"names":[],"mappings":"AAGA,OAAO,EAUL,KAAK,WAAW,EACjB,MAAM,sCAAsC,CAAC;AAI9C,eAAO,MAAM,qBAAqB,GAAI,6BAInC,WAAW,GAAG;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;;;;;;;;;OAaG;IACH,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACzB,4CAyCA,CAAC"}
1
+ {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/internal/search.tsx"],"names":[],"mappings":"AAIA,OAAO,EAWL,KAAK,WAAW,EAGjB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAI3D,eAAO,MAAM,qBAAqB,GAAI,4DAOnC,WAAW,GAAG;IACf;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAChD;;;;;;;;;;;;;OAaG;IACH,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC;CAClB,4CAuEA,CAAC"}
@@ -1,16 +1,31 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useDocsSearch } from "fumadocs-core/search/client";
4
- import { SearchDialog as FumadocsSearchDialog, SearchDialogClose, SearchDialogContent, SearchDialogHeader, SearchDialogIcon, SearchDialogInput, SearchDialogList, SearchDialogListItem, SearchDialogOverlay, } from "fumadocs-ui/components/dialog/search";
4
+ import { useOnChange } from "fumadocs-core/utils/use-on-change";
5
+ import { SearchDialog as FumadocsSearchDialog, SearchDialogClose, SearchDialogContent, SearchDialogFooter, SearchDialogHeader, SearchDialogIcon, SearchDialogInput, SearchDialogList, SearchDialogListItem, SearchDialogOverlay, TagsList, TagsListItem, } from "fumadocs-ui/components/dialog/search";
5
6
  import { useI18n } from "fumadocs-ui/contexts/i18n";
7
+ import { useState } from "react";
6
8
  import { getPublicPath } from "../config";
7
- export const GeistdocsSearchDialog = ({ basePath, tag, ...props }) => {
9
+ export const GeistdocsSearchDialog = ({ allowClear = false, basePath, onTagChange, tag, tags, ...props }) => {
8
10
  const { locale } = useI18n();
11
+ const hasTags = tags !== undefined && tags.length > 0;
12
+ // Holds whatever scope is in force, which is not always a pill: an array scope
13
+ // has no single pill to select, and it stays in force until a reader picks
14
+ // one. Narrowing it to a string here would silently drop it.
15
+ const [selected, setSelected] = useState(tag);
16
+ // Follow the incoming scope: a consumer that derives it from the current page
17
+ // changes it on navigation, and the selection should move with it.
18
+ useOnChange(tag, (value) => {
19
+ setSelected(value);
20
+ });
9
21
  const { search, setSearch, query } = useDocsSearch({
10
22
  type: "fetch",
11
23
  locale,
12
- tag,
24
+ tag: hasTags ? selected : tag,
13
25
  api: getPublicPath("/api/search", basePath),
14
26
  });
15
- return (_jsxs(FumadocsSearchDialog, { isLoading: query.isLoading, onSearchChange: setSearch, search: search, ...props, children: [_jsx(SearchDialogOverlay, { className: "bg-background-100/80 backdrop-blur-none" }), _jsxs(SearchDialogContent, { className: "w-[640px] max-w-[calc(100vw-1rem)] border-none shadow-[var(--ds-shadow-modal)]", "data-geistdocs-command-modal": true, onEscapeKeyDown: () => props.onOpenChange(false), children: [_jsxs(SearchDialogHeader, { children: [_jsx(SearchDialogIcon, {}), _jsx(SearchDialogInput, {}), _jsx(SearchDialogClose, {})] }), _jsx(SearchDialogList, { "aria-label": "Search results", Item: (itemProps) => (_jsx(SearchDialogListItem, { ...itemProps, role: "option" })), items: query.data === "empty" ? null : query.data, role: "listbox" })] })] }));
27
+ return (_jsxs(FumadocsSearchDialog, { isLoading: query.isLoading, onSearchChange: setSearch, search: search, ...props, children: [_jsx(SearchDialogOverlay, { className: "bg-background-100/80 backdrop-blur-none" }), _jsxs(SearchDialogContent, { className: "w-[640px] max-w-[calc(100vw-1rem)] border-none shadow-[var(--ds-shadow-modal)]", "data-geistdocs-command-modal": true, onEscapeKeyDown: () => props.onOpenChange(false), children: [_jsxs(SearchDialogHeader, { children: [_jsx(SearchDialogIcon, {}), _jsx(SearchDialogInput, {}), _jsx(SearchDialogClose, {})] }), _jsx(SearchDialogList, { "aria-label": "Search results", Item: (itemProps) => (_jsx(SearchDialogListItem, { ...itemProps, role: "option" })), items: query.data === "empty" ? null : query.data, role: "listbox" }), hasTags ? (_jsx(SearchDialogFooter, { children: _jsx(TagsList, { allowClear: allowClear, onTagChange: (value) => {
28
+ setSelected(value);
29
+ onTagChange?.(value);
30
+ }, tag: typeof selected === "string" ? selected : undefined, children: tags.map((item) => (_jsx(TagsListItem, { value: item.value, children: item.name }, item.value))) }) })) : null] })] }));
16
31
  };
@@ -1 +1 @@
1
- {"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/routes/chat.ts"],"names":[],"mappings":"AACA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BAeE,OAAO;;CAqLjC,CAAC"}
@@ -5,7 +5,8 @@ import { z } from "zod";
5
5
  import { getPublicPath } from "../config";
6
6
  import { createSourceChunk, createSourceChunks, } from "../internal/chat/source-chunks";
7
7
  import { createChatDocumentSearch, } from "../internal/chat-retrieval";
8
- import { buildEveAgentTranscript, capLastUserMessageText, getEveAgentSessionHandle, resolveEveAgentUrl, runEveAgentTurn, } from "../internal/eve-agent";
8
+ import { buildEveAgentTranscript, capLastUserMessageText, getEveAgentSessionHandle, prewarmEveAgentSession, resolveEveAgentUrl, runEveAgentTurn, } from "../internal/eve-agent";
9
+ import { isEveAgentSessionHandle } from "../internal/eve-agent-session.js";
9
10
  import { isPageVisibleForSurface, } from "../page-visibility";
10
11
  const DEFAULT_CHAT_MODEL = "openai/gpt-5.6-sol";
11
12
  const MAX_CONTEXT_CHARS = 1500;
@@ -77,6 +78,9 @@ const isPageContextMessage = (message) => message.metadata?.isPageContext;
77
78
  const isChatRequestBody = (value) => typeof value === "object" &&
78
79
  value !== null &&
79
80
  Array.isArray(value.messages);
81
+ const isEveAgentPrewarmRequestBody = (value) => typeof value === "object" &&
82
+ value !== null &&
83
+ value.prewarm === true;
80
84
  const getPageData = (page) => page.data;
81
85
  const getStructuredContent = (page) => JSON.stringify(getPageData(page).structuredData?.contents ?? "");
82
86
  const isChatPageVisible = (page, lang, source, filterPage) => isPageVisibleForSurface(page, "chat") &&
@@ -535,7 +539,38 @@ const createChatErrorResponse = (error, status) => new Response(JSON.stringify({
535
539
  status,
536
540
  headers: { "Content-Type": "application/json" },
537
541
  });
538
- const createEveAgentResponse = async ({ actualMessages, agentUrl, config, currentRoute, defaultLanguage, eveAgent, filterPage, languages, messages, pageContext, req, routeSources, searchDocuments, }) => {
542
+ const createEveAgentPrewarmResponse = async ({ agentUrl, enabled, eveAgent, req, }) => {
543
+ if (!(agentUrl && enabled)) {
544
+ return createChatErrorResponse("Invalid chat request: eve agent prewarming is not enabled.", 400);
545
+ }
546
+ const headers = await getEveAgentRequestHeaders({ eveAgent, req });
547
+ const session = await prewarmEveAgentSession({
548
+ agentUrl,
549
+ headers,
550
+ signal: req.signal,
551
+ });
552
+ return Response.json(session, { status: 202 });
553
+ };
554
+ const resolveChatRequestBody = async ({ eveAgent, eveAgentUrl, prewarmEnabled, req, }) => {
555
+ const body = await req.json();
556
+ if (isEveAgentPrewarmRequestBody(body)) {
557
+ return {
558
+ response: await createEveAgentPrewarmResponse({
559
+ agentUrl: eveAgentUrl,
560
+ enabled: prewarmEnabled,
561
+ eveAgent,
562
+ req,
563
+ }),
564
+ };
565
+ }
566
+ if (!isChatRequestBody(body)) {
567
+ return {
568
+ response: createChatErrorResponse("Invalid chat request: messages must be an array.", 400),
569
+ };
570
+ }
571
+ return { body };
572
+ };
573
+ const createEveAgentResponse = async ({ actualMessages, agentUrl, config, currentRoute, defaultLanguage, eveAgent, filterPage, languages, messages, pageContext, prewarmedHandle, req, routeSources, searchDocuments, }) => {
539
574
  const cappedMessages = capLastUserMessageText(actualMessages, MAX_EVE_AGENT_MESSAGE_CHARS);
540
575
  const { messages: contextMessages, sourceDocs } = await buildProxyMessages({
541
576
  actualMessages: cappedMessages,
@@ -553,12 +588,14 @@ const createEveAgentResponse = async ({ actualMessages, agentUrl, config, curren
553
588
  return createChatErrorResponse("Invalid chat request: expected a user message.", 400);
554
589
  }
555
590
  const lastMessageText = getMessageText(lastMessage);
556
- const handle = getEveAgentSessionHandle(cappedMessages);
591
+ const persistedHandle = getEveAgentSessionHandle(cappedMessages);
592
+ const handle = persistedHandle ??
593
+ (isEveAgentSessionHandle(prewarmedHandle) ? prewarmedHandle : null);
557
594
  // A fresh eve session (no handle, or the handle turned out to be
558
595
  // unusable) receives the prior turns inlined so it still sees the
559
596
  // conversation so far.
560
597
  const transcriptMessage = buildEveAgentTranscript(contextMessages, lastMessageText);
561
- const outboundMessage = handle ? lastMessageText : transcriptMessage;
598
+ const outboundMessage = persistedHandle ? lastMessageText : transcriptMessage;
562
599
  if (!outboundMessage.trim()) {
563
600
  return createChatErrorResponse("Invalid chat request: message must not be empty.", 400);
564
601
  }
@@ -604,16 +641,16 @@ export const createChatRoute = ({ config, eveAgent, filterPage, mixedbread, mode
604
641
  });
605
642
  const POST = async (req) => {
606
643
  try {
607
- const requestBody = await req.json();
608
- if (!isChatRequestBody(requestBody)) {
609
- return new Response(JSON.stringify({
610
- error: "Invalid chat request: messages must be an array.",
611
- }), {
612
- status: 400,
613
- headers: { "Content-Type": "application/json" },
614
- });
644
+ const resolvedRequest = await resolveChatRequestBody({
645
+ eveAgent,
646
+ eveAgentUrl,
647
+ prewarmEnabled: config.ai?.eveAgent?.prewarm === true,
648
+ req,
649
+ });
650
+ if ("response" in resolvedRequest) {
651
+ return resolvedRequest.response;
615
652
  }
616
- const { messages, currentRoute, pageContext } = requestBody;
653
+ const { currentRoute, eveAgentSession, messages, pageContext } = resolvedRequest.body;
617
654
  const actualMessages = messages.filter((message) => !isPageContextMessage(message));
618
655
  if (eveAgentUrl) {
619
656
  return await createEveAgentResponse({
@@ -627,6 +664,7 @@ export const createChatRoute = ({ config, eveAgent, filterPage, mixedbread, mode
627
664
  languages,
628
665
  messages,
629
666
  pageContext,
667
+ prewarmedHandle: eveAgentSession,
630
668
  req,
631
669
  routeSources,
632
670
  searchDocuments,
package/docs/agents.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Geistdocs Package Docs
2
2
 
3
- These docs are bundled with `@vercel/geistdocs` 2.4.2 so agents can understand the installed package without web access.
3
+ These docs are bundled with `@vercel/geistdocs` 2.5.0 so agents can understand the installed package without web access.
4
4
  They are generated from `apps/template/content/docs` during the package build.
5
5
 
6
6
  ## How to use these files
package/docs/llms.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  # Geistdocs Package Documentation
2
2
 
3
- These docs are bundled with `@vercel/geistdocs` 2.4.2.
3
+ These docs are bundled with `@vercel/geistdocs` 2.5.0.
4
4
  They describe how to build package-backed Geistdocs sites and how to use the package APIs from generated project adapters.
5
5
 
6
6
  ## Documentation Index
@@ -1289,10 +1289,15 @@ The `ai` config accepts `retrieval: "mixedbread"` to use semantic documentation
1289
1289
  ```tsx title="geistdocs.tsx"
1290
1290
  export const ai = {
1291
1291
  retrieval: "mixedbread",
1292
- eveAgent: { url: "https://help-eve.example.dev" },
1292
+ eveAgent: {
1293
+ url: "https://help-eve.example.dev",
1294
+ prewarm: true,
1295
+ },
1293
1296
  };
1294
1297
  ```
1295
1298
 
1299
+ Set `eveAgent.prewarm` only when the agent runs eve 0.59 or newer and allocating an empty durable session as Ask AI loads is appropriate for the site.
1300
+
1296
1301
  See [Ask AI](/docs/ask-ai) for the full eve agent mode behavior, including authentication. Read [Improve Ask AI answers with Mixedbread](/docs/mixedbread-retrieval) before enabling semantic retrieval.
1297
1302
 
1298
1303
  Use [Versioned docs](/docs/versioned-docs) for versioned source setup and [Proxy and markdown routes](/docs/proxy) for route mappings.
@@ -2378,6 +2383,29 @@ Pass the scope here rather than reading a header or a cookie in the route. The s
2378
2383
  > Note:
2379
2384
  `createSearchRoute` indexes pages without a `tag` field, and tagged queries match with `containsAll`, so a tag passed to the built-in route matches nothing.
2380
2385
 
2386
+ ### Let readers change the scope
2387
+
2388
+ `tag` alone fixes the scope: it follows the page and a reader cannot override it. Pass `tags` as well to render the alternatives as pills under the results:
2389
+
2390
+ ```tsx title="app/layout.tsx"
2391
+ <GeistdocsProvider
2392
+ config={config}
2393
+ search={{
2394
+ options: {
2395
+ tag: "v5",
2396
+ tags: [
2397
+ { name: "v4", value: "v4" },
2398
+ { name: "v5", value: "v5" },
2399
+ ],
2400
+ allowClear: true,
2401
+ onTagChange: (value) => persist(value),
2402
+ },
2403
+ }}
2404
+ >
2405
+ ```
2406
+
2407
+ The selection starts at `tag` and follows it when the page changes, so navigating still re-scopes the dialog. `allowClear` adds a pill that searches everything, and `onTagChange` reports each pick for sites that remember it across sessions.
2408
+
2381
2409
  ## AI Sidebar
2382
2410
 
2383
2411
  When users open the AI chat on desktop, the provider automatically adds padding to prevent content from being hidden behind the sidebar. On mobile, the chat opens as a drawer instead, so no padding is needed.
@@ -3796,10 +3824,15 @@ Use eve agent mode when a hosted [eve framework](https://eve.dev) agent should a
3796
3824
 
3797
3825
  ```tsx title="geistdocs.tsx"
3798
3826
  export const ai = {
3799
- eveAgent: { url: "https://help-eve.example.dev" },
3827
+ eveAgent: {
3828
+ url: "https://help-eve.example.dev",
3829
+ prewarm: true,
3830
+ },
3800
3831
  };
3801
3832
  ```
3802
3833
 
3834
+ Set `prewarm: true` to start an empty session when the Ask AI client loads, including when a reader hovers or focuses the Ask AI control. The first message waits for that request and reuses the accepted session, avoiding workflow startup latency. Prewarming requires eve 0.59 or newer and falls back to normal session creation if the early request fails. Leave it disabled when opening the chat should not allocate a durable session before the reader sends a message.
3835
+
3803
3836
  The URL flows to `createChatRoute` through the config object you already pass in `app/api/chat/route.ts` — no route changes are required. Geistdocs speaks eve's session API directly: it starts or resumes a durable eve session, streams the agent's NDJSON events, and translates them into the same UI message stream the chat panel already renders. Conversation continuity is handled automatically by round-tripping the eve session handle through message metadata.
3804
3837
 
3805
3838
  Eve agent mode keeps the platform-owned behavior from proxy mode:
@@ -242,5 +242,5 @@
242
242
  }
243
243
  ],
244
244
  "source": "apps/template/content/docs",
245
- "version": "2.4.2"
245
+ "version": "2.5.0"
246
246
  }
@@ -134,10 +134,15 @@ Use eve agent mode when a hosted [eve framework](https://eve.dev) agent should a
134
134
 
135
135
  ```tsx title="geistdocs.tsx"
136
136
  export const ai = {
137
- eveAgent: { url: "https://help-eve.example.dev" },
137
+ eveAgent: {
138
+ url: "https://help-eve.example.dev",
139
+ prewarm: true,
140
+ },
138
141
  };
139
142
  ```
140
143
 
144
+ Set `prewarm: true` to start an empty session when the Ask AI client loads, including when a reader hovers or focuses the Ask AI control. The first message waits for that request and reuses the accepted session, avoiding workflow startup latency. Prewarming requires eve 0.59 or newer and falls back to normal session creation if the early request fails. Leave it disabled when opening the chat should not allocate a durable session before the reader sends a message.
145
+
141
146
  The URL flows to `createChatRoute` through the config object you already pass in `app/api/chat/route.ts` — no route changes are required. Geistdocs speaks eve's session API directly: it starts or resumes a durable eve session, streams the agent's NDJSON events, and translates them into the same UI message stream the chat panel already renders. Conversation continuity is handled automatically by round-tripping the eve session handle through message metadata.
142
147
 
143
148
  Eve agent mode keeps the platform-owned behavior from proxy mode:
@@ -199,10 +199,15 @@ The `ai` config accepts `retrieval: "mixedbread"` to use semantic documentation
199
199
  ```tsx title="geistdocs.tsx"
200
200
  export const ai = {
201
201
  retrieval: "mixedbread",
202
- eveAgent: { url: "https://help-eve.example.dev" },
202
+ eveAgent: {
203
+ url: "https://help-eve.example.dev",
204
+ prewarm: true,
205
+ },
203
206
  };
204
207
  ```
205
208
 
209
+ Set `eveAgent.prewarm` only when the agent runs eve 0.59 or newer and allocating an empty durable session as Ask AI loads is appropriate for the site.
210
+
206
211
  See [Ask AI](/docs/ask-ai) for the full eve agent mode behavior, including authentication. Read [Improve Ask AI answers with Mixedbread](/docs/mixedbread-retrieval) before enabling semantic retrieval.
207
212
 
208
213
  Use [Versioned docs](/docs/versioned-docs) for versioned source setup and [Proxy and markdown routes](/docs/proxy) for route mappings.
@@ -62,6 +62,29 @@ Pass the scope here rather than reading a header or a cookie in the route. The s
62
62
  > Note:
63
63
  `createSearchRoute` indexes pages without a `tag` field, and tagged queries match with `containsAll`, so a tag passed to the built-in route matches nothing.
64
64
 
65
+ ### Let readers change the scope
66
+
67
+ `tag` alone fixes the scope: it follows the page and a reader cannot override it. Pass `tags` as well to render the alternatives as pills under the results:
68
+
69
+ ```tsx title="app/layout.tsx"
70
+ <GeistdocsProvider
71
+ config={config}
72
+ search={{
73
+ options: {
74
+ tag: "v5",
75
+ tags: [
76
+ { name: "v4", value: "v4" },
77
+ { name: "v5", value: "v5" },
78
+ ],
79
+ allowClear: true,
80
+ onTagChange: (value) => persist(value),
81
+ },
82
+ }}
83
+ >
84
+ ```
85
+
86
+ The selection starts at `tag` and follows it when the page changes, so navigating still re-scopes the dialog. `allowClear` adds a pill that searches everything, and `onTagChange` reports each pick for sites that remember it across sessions.
87
+
65
88
  ## AI Sidebar
66
89
 
67
90
  When users open the AI chat on desktop, the provider automatically adds padding to prevent content from being hidden behind the sidebar. On mobile, the chat opens as a drawer instead, so no padding is needed.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vercel/geistdocs",
3
3
  "description": "Runtime and CLI for Geistdocs projects.",
4
- "version": "2.4.2",
4
+ "version": "2.5.0",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",
@@ -75,7 +75,7 @@ Use these instructions when an AI coding agent edits this project.
75
75
  - Keep `MXBAI_API_KEY` and `MXBAI_STORE_ID` in environment variables. Never put them in `geistdocs.tsx`, because config is available to client components.
76
76
  - Keep `app/api/search/export/route.ts` and the `next build && geistdocs search sync` build script when Mixedbread retrieval is enabled. Production builds incrementally sync chat-visible Markdown; local and preview builds skip remote sync unless `--allow-non-production` is passed.
77
77
  - Mixedbread failures fall back to local Orama retrieval. Keep the local source definitions and `excludeFrom: [chat]` visibility behavior intact.
78
- - Set `ai.eveAgent: { url }` in `geistdocs.tsx` to answer Ask AI with a hosted eve framework agent instead. The URL flows through the config object; the route file needs no changes. Requests authenticate with a per-request Vercel OIDC bearer token by default; pass server-only headers through the `eveAgent` option on `createChatRoute` for custom auth. Never put auth material in `geistdocs.tsx`. Configuring both `proxy` and an eve agent throws at route creation.
78
+ - Set `ai.eveAgent: { url }` in `geistdocs.tsx` to answer Ask AI with a hosted eve framework agent instead. The URL flows through the config object; the route file needs no changes. Set `prewarm: true` for eve 0.59+ responders when the site should prepare an empty durable session as the chat client loads. Requests authenticate with a per-request Vercel OIDC bearer token by default; pass server-only headers through the `eveAgent` option on `createChatRoute` for custom auth. Never put auth material in `geistdocs.tsx`. Configuring both `proxy` and an eve agent throws at route creation.
79
79
  - Geistdocs Ask AI targets AI SDK v6: `ai` v6 and `@ai-sdk/react` v3. Keep those dependencies on the generated package versions unless a `@vercel/geistdocs` release changes them.
80
80
  - If the app uses `ai` or `@ai-sdk/react` for product code outside Geistdocs, migrate that app code separately or let the package manager install separate versions. Do not downgrade Geistdocs Ask AI to match unrelated app code.
81
81
  - Set `GEISTDOCS_CHAT_PROXY_URL` only when Ask AI should route through the central Vertex-backed proxy. The value must include the `/vertex` route, such as `https://<geistdocs-platform-deployment>/vertex`.
@@ -132,10 +132,15 @@ Use eve agent mode when a hosted [eve framework](https://eve.dev) agent should a
132
132
 
133
133
  ```tsx title="geistdocs.tsx"
134
134
  export const ai = {
135
- eveAgent: { url: "https://help-eve.example.dev" },
135
+ eveAgent: {
136
+ url: "https://help-eve.example.dev",
137
+ prewarm: true,
138
+ },
136
139
  };
137
140
  ```
138
141
 
142
+ Set `prewarm: true` to start an empty session when the Ask AI client loads, including when a reader hovers or focuses the Ask AI control. The first message waits for that request and reuses the accepted session, avoiding workflow startup latency. Prewarming requires eve 0.59 or newer and falls back to normal session creation if the early request fails. Leave it disabled when opening the chat should not allocate a durable session before the reader sends a message.
143
+
139
144
  The URL flows to `createChatRoute` through the config object you already pass in `app/api/chat/route.ts` — no route changes are required. Geistdocs speaks eve's session API directly: it starts or resumes a durable eve session, streams the agent's NDJSON events, and translates them into the same UI message stream the chat panel already renders. Conversation continuity is handled automatically by round-tripping the eve session handle through message metadata.
140
145
 
141
146
  Eve agent mode keeps the platform-owned behavior from proxy mode:
@@ -197,10 +197,15 @@ The `ai` config accepts `retrieval: "mixedbread"` to use semantic documentation
197
197
  ```tsx title="geistdocs.tsx"
198
198
  export const ai = {
199
199
  retrieval: "mixedbread",
200
- eveAgent: { url: "https://help-eve.example.dev" },
200
+ eveAgent: {
201
+ url: "https://help-eve.example.dev",
202
+ prewarm: true,
203
+ },
201
204
  };
202
205
  ```
203
206
 
207
+ Set `eveAgent.prewarm` only when the agent runs eve 0.59 or newer and allocating an empty durable session as Ask AI loads is appropriate for the site.
208
+
204
209
  See [Ask AI](/docs/ask-ai) for the full eve agent mode behavior, including authentication. Read [Improve Ask AI answers with Mixedbread](/docs/mixedbread-retrieval) before enabling semantic retrieval.
205
210
 
206
211
  Use [Versioned docs](/docs/versioned-docs) for versioned source setup and [Proxy and markdown routes](/docs/proxy) for route mappings.
@@ -61,6 +61,29 @@ Pass the scope here rather than reading a header or a cookie in the route. The s
61
61
  `createSearchRoute` indexes pages without a `tag` field, and tagged queries match with `containsAll`, so a tag passed to the built-in route matches nothing.
62
62
  </Callout>
63
63
 
64
+ ### Let readers change the scope
65
+
66
+ `tag` alone fixes the scope: it follows the page and a reader cannot override it. Pass `tags` as well to render the alternatives as pills under the results:
67
+
68
+ ```tsx title="app/layout.tsx"
69
+ <GeistdocsProvider
70
+ config={config}
71
+ search={{
72
+ options: {
73
+ tag: "v5",
74
+ tags: [
75
+ { name: "v4", value: "v4" },
76
+ { name: "v5", value: "v5" },
77
+ ],
78
+ allowClear: true,
79
+ onTagChange: (value) => persist(value),
80
+ },
81
+ }}
82
+ >
83
+ ```
84
+
85
+ The selection starts at `tag` and follows it when the page changes, so navigating still re-scopes the dialog. `allowClear` adds a pill that searches everything, and `onTagChange` reports each pick for sites that remember it across sessions.
86
+
64
87
  ## AI Sidebar
65
88
 
66
89
  When users open the AI chat on desktop, the provider automatically adds padding to prevent content from being hidden behind the sidebar. On mobile, the chat opens as a drawer instead, so no padding is needed.
@@ -17,7 +17,7 @@
17
17
  "@streamdown/code": "^1.0.1",
18
18
  "@vercel/agent-readability": "^0.7.0",
19
19
  "@vercel/analytics": "^1.6.1",
20
- "@vercel/geistdocs": "2.4.2",
20
+ "@vercel/geistdocs": "2.5.0",
21
21
  "@vercel/speed-insights": "^1.3.1",
22
22
  "ai": "^6.0.132",
23
23
  "clsx": "^2.1.1",