@vercel/geistdocs 2.14.1 → 2.14.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/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.14.1","-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.14.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});
@@ -15,10 +15,15 @@ export type EveAgentClientContext = Record<string, unknown>;
15
15
  */
16
16
  export interface EveAgentMessageMetadata {
17
17
  session: string;
18
- /** Absolute count of NDJSON events consumed from the session stream. */
18
+ /** Absolute position of the next stored stream line to read. */
19
19
  streamIndex: number;
20
20
  }
21
21
  export interface EveAgentSession {
22
+ /**
23
+ * Delivery of the turn's message, when the agent returns one (eve 0.84+).
24
+ * The turn ends at this delivery's `delivery.settled`.
25
+ */
26
+ deliveryId?: string;
22
27
  sessionId: string;
23
28
  /** Stream index the next turn's events start at. */
24
29
  startIndex: number;
@@ -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;AAoC3E,kDAAkD;AAClD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wDAAwD;AACxD,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,gBAAgB,EAAE,CAAC;AAE1D,2EAA2E;AAC3E,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE5D;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,wEAAwE;IACxE,WAAW,EAAE,MAAM,CAAC;CACrB;AAwBD,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,oDAAoD;IACpD,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,yBAAyB;IACxC,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,kEAAkE;IAClE,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IACzB,uDAAuD;IACvD,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB;;;OAGG;IACH,aAAa,CAAC,EAAE,cAAc,EAAE,CAAC;IACjC,6EAA6E;IAC7E,OAAO,EAAE,eAAe,CAAC;IACzB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,qEAAqE;IACrE,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB;;;;OAIG;IACH,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,EAAE,eAAe,CAAC;IAClC,kEAAkE;IAClE,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IACzB,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,gEAAgE;IAChE,OAAO,EAAE,eAAe,CAAC;IACzB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,KAAG,OAAO,CAAC,eAAe,CA4D1B,CAAC;AAmOF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAU,oHAWtC,yBAAyB,kBAkE3B,CAAC"}
@@ -13,9 +13,16 @@
13
13
  * next to `message`; eve turns it into turn-scoped model context that is
14
14
  * not stored in session history.
15
15
  * - `GET {url}/eve/v1/session/:sessionId/stream?startIndex=N` streams
16
- * newline-delimited JSON events. The stream stays open after
17
- * `session.waiting`, so the client disconnects at turn boundaries and
18
- * counts consumed lines to resume from an absolute cursor.
16
+ * newline-delimited JSON. The stream stays open between turns, so the
17
+ * client disconnects at turn boundaries and counts stored lines to resume
18
+ * from an absolute cursor. Two stream versions are read:
19
+ * - v26 (eve 0.83 and older): one `{ type, data }` event per line; a turn
20
+ * ends with `session.waiting`, `session.completed`, or `session.failed`.
21
+ * - v27 (eve 0.84+): each stored line is a commit (`{ at, facts }`) or a
22
+ * progress record (`{ progress }`); `$eve` transport records are never
23
+ * counted. A turn ends with the `delivery.settled` of its message, or
24
+ * `session.ended`. A `stream.lease-ended` record ends one read, and the
25
+ * client reconnects from its cursor.
19
26
  * - `POST {url}/eve/v1/session/:sessionId/cancel` cancels the in-flight turn.
20
27
  * - In eve 0.83+, a bodyless `POST {url}/eve/v1/session/:sessionId` prepares
21
28
  * an existing session without starting a turn or replacing the session.
@@ -28,6 +35,8 @@ const SESSION_SEND_READY_TIMEOUT_MS = 20_000;
28
35
  const MAX_TRANSCRIPT_TURN_CHARS = 2000;
29
36
  const MAX_TRANSCRIPT_TOTAL_CHARS = 8000;
30
37
  const MAX_SOURCES_PER_ACTION = 5;
38
+ /** Bounds reconnects after v27 `stream.lease-ended` records within one turn. */
39
+ const MAX_STREAM_READS = 20;
31
40
  const TRAILING_SLASH_PATTERN = /\/+$/;
32
41
  const HTTP_URL_PATTERN = /^https?:\/\//;
33
42
  /** JSON body for eve's message routes; `clientContext` only when set. */
@@ -178,7 +187,10 @@ const parseSessionResponse = async (response) => {
178
187
  if (!isRecord(body) || typeof body.sessionId !== "string") {
179
188
  throw new Error("eve agent returned an invalid session response.");
180
189
  }
181
- return { sessionId: body.sessionId };
190
+ return {
191
+ deliveryId: typeof body.deliveryId === "string" ? body.deliveryId : undefined,
192
+ sessionId: body.sessionId,
193
+ };
182
194
  };
183
195
  /** Start an eve session without a turn so the first message can reuse it. */
184
196
  export const createEmptyEveAgentSession = async ({ agentUrl, fetchImpl = fetch, headers, signal, }) => {
@@ -191,7 +203,8 @@ export const createEmptyEveAgentSession = async ({ agentUrl, fetchImpl = fetch,
191
203
  if (!response.ok) {
192
204
  throw new Error(`eve agent session prewarm failed with status ${response.status}.`);
193
205
  }
194
- return await parseSessionResponse(response);
206
+ const { sessionId } = await parseSessionResponse(response);
207
+ return { sessionId };
195
208
  };
196
209
  /** Prepare an existing idle owner using eve 0.83's bodyless session POST. */
197
210
  export const prewarmExistingEveAgentSession = async ({ agentUrl, fetchImpl = fetch, headers, sessionId, signal, }) => {
@@ -206,16 +219,66 @@ export const prewarmExistingEveAgentSession = async ({ agentUrl, fetchImpl = fet
206
219
  throw new Error("eve agent returned an invalid preparation response.");
207
220
  }
208
221
  };
209
- const isTurnBoundaryEvent = (type) => type === "session.waiting" ||
210
- type === "session.completed" ||
211
- type === "session.failed";
212
- const createEveEventTranslator = (writer, { toolCitations, visibleTools }) => {
222
+ /**
223
+ * Track whether an event ends the turn. v26 ends at the session's status.
224
+ * v27 ends at the `delivery.settled` of the turn's message (any delivery
225
+ * when the agent returned no delivery ID) or at `session.ended`. A message
226
+ * that answers a paused turn's question settles `applied` while that turn
227
+ * resumes, so the boundary moves to the resumed turn settling or pausing.
228
+ */
229
+ const createTurnBoundary = (deliveryId) => {
230
+ let resumedTurn = false;
231
+ return (event) => {
232
+ switch (event.type) {
233
+ case "session.waiting":
234
+ case "session.completed":
235
+ case "session.failed":
236
+ case "session.ended":
237
+ return true;
238
+ case "delivery.settled":
239
+ if (deliveryId !== null && event.data?.deliveryId !== deliveryId) {
240
+ return false;
241
+ }
242
+ if (event.data?.outcome === "applied") {
243
+ resumedTurn = true;
244
+ return false;
245
+ }
246
+ return true;
247
+ case "turn.settled":
248
+ case "turn.paused":
249
+ return resumedTurn;
250
+ default:
251
+ return false;
252
+ }
253
+ };
254
+ };
255
+ /** Delivery outcomes after which the session can take the next message. */
256
+ const ACTIVE_DELIVERY_OUTCOMES = new Set([
257
+ "handled",
258
+ "awaiting-input",
259
+ "applied",
260
+ ]);
261
+ const getErrorMessage = (data) => {
262
+ if (typeof data?.message === "string") {
263
+ return data.message;
264
+ }
265
+ if (isRecord(data?.error) && typeof data.error.message === "string") {
266
+ return data.error.message;
267
+ }
268
+ return typeof data?.reason === "string" ? data.reason : undefined;
269
+ };
270
+ const createEveEventTranslator = (writer, { deliveryId, toolCitations, visibleTools }) => {
213
271
  let blockCounter = 0;
214
272
  let openTextId = null;
215
273
  let openReasoningId = null;
216
274
  let sessionWaiting = false;
275
+ let failureWritten = false;
217
276
  const knownToolCalls = new Map();
218
277
  const emittedSourceUrls = new Set();
278
+ /** v27 content kinds by part; only a part's first delta names its kind. */
279
+ const partKinds = new Map();
280
+ /** v27 parts whose text already streamed as deltas. */
281
+ const streamedParts = new Set();
219
282
  const closeTextBlock = () => {
220
283
  if (openTextId) {
221
284
  writer.write({ type: "text-end", id: openTextId });
@@ -255,6 +318,21 @@ const createEveEventTranslator = (writer, { toolCitations, visibleTools }) => {
255
318
  action.name ??
256
319
  action.kind ??
257
320
  "action";
321
+ const writeToolCall = (callId, toolName, input) => {
322
+ // Hidden tools never become known calls, so their results and any
323
+ // citations in them are dropped too.
324
+ if (visibleTools && !visibleTools.has(toolName)) {
325
+ return;
326
+ }
327
+ knownToolCalls.set(callId, toolName);
328
+ writer.write({
329
+ type: "tool-input-available",
330
+ toolCallId: callId,
331
+ toolName,
332
+ input: input ?? {},
333
+ dynamic: true,
334
+ });
335
+ };
258
336
  const handleActionsRequested = (data) => {
259
337
  if (!Array.isArray(data.actions)) {
260
338
  return;
@@ -265,20 +343,7 @@ const createEveEventTranslator = (writer, { toolCitations, visibleTools }) => {
265
343
  if (!isRecord(action) || typeof action.callId !== "string") {
266
344
  continue;
267
345
  }
268
- const toolName = getActionName(action);
269
- // Hidden tools never become known calls, so their results and any
270
- // citations in them are dropped too.
271
- if (visibleTools && !visibleTools.has(toolName)) {
272
- continue;
273
- }
274
- knownToolCalls.set(action.callId, toolName);
275
- writer.write({
276
- type: "tool-input-available",
277
- toolCallId: action.callId,
278
- toolName,
279
- input: action.input ?? {},
280
- dynamic: true,
281
- });
346
+ writeToolCall(action.callId, getActionName(action), action.input);
282
347
  }
283
348
  };
284
349
  const writeSourceChunks = (output) => {
@@ -295,25 +360,17 @@ const createEveEventTranslator = (writer, { toolCitations, visibleTools }) => {
295
360
  });
296
361
  }
297
362
  };
298
- const handleActionResult = (data) => {
299
- const result = data.result;
300
- if (!(isRecord(result) && typeof result.callId === "string")) {
363
+ const writeToolResult = ({ callId, error, failure, output, }) => {
364
+ if (!knownToolCalls.has(callId)) {
301
365
  return;
302
366
  }
303
- if (!knownToolCalls.has(result.callId)) {
304
- return;
305
- }
306
- const failed = data.status === "failed" ||
307
- data.status === "rejected" ||
308
- result.isError === true;
309
- if (failed) {
310
- const error = data.error;
311
- const fallbackErrorText = data.status === "rejected"
367
+ if (failure) {
368
+ const fallbackErrorText = failure === "rejected"
312
369
  ? "The action was rejected."
313
370
  : "The action failed.";
314
371
  writer.write({
315
372
  type: "tool-output-error",
316
- toolCallId: result.callId,
373
+ toolCallId: callId,
317
374
  errorText: isRecord(error) && typeof error.message === "string"
318
375
  ? error.message
319
376
  : fallbackErrorText,
@@ -323,12 +380,112 @@ const createEveEventTranslator = (writer, { toolCitations, visibleTools }) => {
323
380
  }
324
381
  writer.write({
325
382
  type: "tool-output-available",
326
- toolCallId: result.callId,
327
- output: toolCitations ? (result.output ?? null) : null,
383
+ toolCallId: callId,
384
+ output: toolCitations ? (output ?? null) : null,
328
385
  dynamic: true,
329
386
  });
330
387
  if (toolCitations) {
331
- writeSourceChunks(result.output);
388
+ writeSourceChunks(output);
389
+ }
390
+ };
391
+ const handleActionResult = (data) => {
392
+ const result = data.result;
393
+ if (!(isRecord(result) && typeof result.callId === "string")) {
394
+ return;
395
+ }
396
+ let failure = null;
397
+ if (data.status === "rejected") {
398
+ failure = "rejected";
399
+ }
400
+ else if (data.status === "failed" || result.isError === true) {
401
+ failure = "failed";
402
+ }
403
+ writeToolResult({
404
+ callId: result.callId,
405
+ error: data.error,
406
+ failure,
407
+ output: result.output,
408
+ });
409
+ };
410
+ /** v27 `call.requested`: one call, with its tool in `capability`. */
411
+ const handleCallRequested = (data) => {
412
+ const capability = data.capability;
413
+ if (typeof data.callId !== "string" ||
414
+ !isRecord(capability) ||
415
+ typeof capability.name !== "string" ||
416
+ // Task controls such as `eve__task_wait` are not user-facing tools.
417
+ capability.kind === "control") {
418
+ return;
419
+ }
420
+ closeTextBlock();
421
+ closeReasoningBlock();
422
+ writeToolCall(data.callId, capability.name, data.input);
423
+ };
424
+ /** v27 `call.settled`: `outcome` is `completed` or how the call stopped. */
425
+ const handleCallSettled = (data) => {
426
+ if (typeof data.callId !== "string") {
427
+ return;
428
+ }
429
+ let failure = null;
430
+ if (data.outcome === "rejected") {
431
+ failure = "rejected";
432
+ }
433
+ else if (data.outcome !== "completed") {
434
+ failure = "failed";
435
+ }
436
+ writeToolResult({
437
+ callId: data.callId,
438
+ error: data.error,
439
+ failure,
440
+ output: data.output,
441
+ });
442
+ };
443
+ /** v27 `content.delta` progress: text or reasoning for one part. */
444
+ const handleContentDelta = (data) => {
445
+ if (typeof data.partId !== "string" || typeof data.delta !== "string") {
446
+ return;
447
+ }
448
+ if (typeof data.kind === "string") {
449
+ partKinds.set(data.partId, data.kind);
450
+ }
451
+ const kind = partKinds.get(data.partId);
452
+ if (kind === "text") {
453
+ streamedParts.add(data.partId);
454
+ writeTextDelta(data.delta);
455
+ }
456
+ else if (kind === "reasoning") {
457
+ streamedParts.add(data.partId);
458
+ writeReasoningDelta(data.delta);
459
+ }
460
+ };
461
+ /**
462
+ * v27 `content.completed`: a finished part. Writes the whole value when
463
+ * its deltas were not read (they are optional), then closes the block.
464
+ */
465
+ const handleContentCompleted = (data) => {
466
+ if (typeof data.partId !== "string") {
467
+ return;
468
+ }
469
+ const unstreamedValue = !streamedParts.has(data.partId) && typeof data.value === "string"
470
+ ? data.value
471
+ : null;
472
+ if (data.kind === "text") {
473
+ if (unstreamedValue) {
474
+ writeTextDelta(unstreamedValue);
475
+ }
476
+ closeTextBlock();
477
+ }
478
+ else if (data.kind === "reasoning") {
479
+ if (unstreamedValue) {
480
+ writeReasoningDelta(unstreamedValue);
481
+ }
482
+ closeReasoningBlock();
483
+ }
484
+ };
485
+ /** v27 `interaction.opened`: render the question for the reader to answer. */
486
+ const handleInteractionOpened = (data) => {
487
+ if (isRecord(data.request) && typeof data.request.prompt === "string") {
488
+ writeTextDelta(`${data.request.prompt}\n`);
332
489
  }
333
490
  };
334
491
  const handleInputRequested = (data) => {
@@ -342,13 +499,16 @@ const createEveEventTranslator = (writer, { toolCitations, visibleTools }) => {
342
499
  }
343
500
  };
344
501
  const handleFailure = (data) => {
502
+ // One error per turn: v27 reports a failed session on several events.
503
+ if (failureWritten) {
504
+ return;
505
+ }
506
+ failureWritten = true;
345
507
  closeTextBlock();
346
508
  closeReasoningBlock();
347
509
  writer.write({
348
510
  type: "error",
349
- errorText: data && typeof data.message === "string"
350
- ? data.message
351
- : "The agent failed to answer.",
511
+ errorText: getErrorMessage(data) ?? "The agent failed to answer.",
352
512
  });
353
513
  };
354
514
  const eventHandlers = {
@@ -384,6 +544,54 @@ const createEveEventTranslator = (writer, { toolCitations, visibleTools }) => {
384
544
  },
385
545
  "turn.failed": handleFailure,
386
546
  "session.failed": handleFailure,
547
+ // v27 (eve 0.84+)
548
+ "content.delta": (data) => {
549
+ if (data) {
550
+ handleContentDelta(data);
551
+ }
552
+ },
553
+ "content.completed": (data) => {
554
+ if (data) {
555
+ handleContentCompleted(data);
556
+ }
557
+ },
558
+ "call.requested": (data) => {
559
+ if (data) {
560
+ handleCallRequested(data);
561
+ }
562
+ },
563
+ "call.settled": (data) => {
564
+ if (data) {
565
+ handleCallSettled(data);
566
+ }
567
+ },
568
+ "interaction.opened": (data) => {
569
+ if (data) {
570
+ handleInteractionOpened(data);
571
+ }
572
+ },
573
+ "turn.settled": (data) => {
574
+ if (data?.outcome === "failed") {
575
+ handleFailure(data);
576
+ }
577
+ },
578
+ "delivery.settled": (data) => {
579
+ if (deliveryId !== null && data?.deliveryId !== deliveryId) {
580
+ return;
581
+ }
582
+ if (ACTIVE_DELIVERY_OUTCOMES.has(data?.outcome)) {
583
+ sessionWaiting = true;
584
+ }
585
+ else if (data?.outcome === "failed" || data?.outcome === "refused") {
586
+ handleFailure(data);
587
+ }
588
+ },
589
+ "session.ended": (data) => {
590
+ sessionWaiting = false;
591
+ if (data?.outcome === "failed") {
592
+ handleFailure(data);
593
+ }
594
+ },
387
595
  };
388
596
  // Unknown event types (step.*, subagent.*, compaction.*, ...) are
389
597
  // intentionally ignored for forward compatibility.
@@ -462,7 +670,11 @@ export const startOrContinueEveAgentSession = async ({ agentUrl, clientContext,
462
670
  if (session.sessionId !== continuation.sessionId) {
463
671
  throw new Error("eve agent follow-up returned a different session id.");
464
672
  }
465
- return continuation;
673
+ return {
674
+ sessionId: continuation.sessionId,
675
+ startIndex: continuation.startIndex,
676
+ ...(session.deliveryId ? { deliveryId: session.deliveryId } : {}),
677
+ };
466
678
  }
467
679
  // Ask AI recovers from an inactive session by explicitly creating a new
468
680
  // one with the bounded transcript.
@@ -480,9 +692,61 @@ export const startOrContinueEveAgentSession = async ({ agentUrl, clientContext,
480
692
  throw new Error(`eve agent session create failed with status ${response.status}.`);
481
693
  }
482
694
  const session = await parseSessionResponse(response);
483
- return { sessionId: session.sessionId, startIndex: 0 };
695
+ return {
696
+ sessionId: session.sessionId,
697
+ startIndex: 0,
698
+ ...(session.deliveryId ? { deliveryId: session.deliveryId } : {}),
699
+ };
700
+ };
701
+ /**
702
+ * Apply a v27 `$eve` transport record. Transport records are never stored
703
+ * or counted; a position marker moves the cursor forward.
704
+ */
705
+ const readTransportRecord = (record, cursor) => {
706
+ switch (record.$eve) {
707
+ case "position":
708
+ return {
709
+ cursor: Number.isSafeInteger(record.next) && record.next > cursor
710
+ ? record.next
711
+ : cursor,
712
+ end: null,
713
+ };
714
+ case "stream.lease-ended":
715
+ return { cursor, end: { cursor, reconnect: true } };
716
+ case "stream.ended":
717
+ return { cursor, end: { cursor, reconnect: false } };
718
+ default:
719
+ return { cursor, end: null };
720
+ }
721
+ };
722
+ const handleStreamEvent = (value, onEvent) => isRecord(value) && typeof value.type === "string"
723
+ ? onEvent(value)
724
+ : false;
725
+ /**
726
+ * Hand a stored line's events to `onEvent`: every fact of a v27 commit (the
727
+ * whole line, even past a boundary), a v27 progress record, or a v26 event.
728
+ * Returns whether the line holds a turn boundary.
729
+ */
730
+ const handleStoredRecord = (record, onEvent) => {
731
+ if (isRecord(record) && Array.isArray(record.facts)) {
732
+ let boundary = false;
733
+ for (const fact of record.facts) {
734
+ if (handleStreamEvent(fact, onEvent)) {
735
+ boundary = true;
736
+ }
737
+ }
738
+ return boundary;
739
+ }
740
+ const event = isRecord(record) && isRecord(record.progress) ? record.progress : record;
741
+ return handleStreamEvent(event, onEvent);
484
742
  };
485
- const streamSessionEvents = async ({ agentUrl, fetchImpl, headers, onEvent, sessionId, signal, startIndex, }) => {
743
+ /**
744
+ * Read one stream response. v26 lines are events; v27 lines are commits
745
+ * (`facts`) or progress records, and `$eve` transport records are not
746
+ * counted. `onEvent` returns `true` at a turn boundary, which ends the read
747
+ * once the rest of its line is handled.
748
+ */
749
+ const readSessionStream = async ({ agentUrl, fetchImpl, headers, onEvent, sessionId, signal, startIndex, }) => {
486
750
  const query = startIndex > 0 ? `?startIndex=${startIndex}` : "";
487
751
  const response = await fetchImpl(`${agentUrl}${EVE_SESSION_PATH}/${encodeURIComponent(sessionId)}/stream${query}`, { headers, signal });
488
752
  if (!response.ok) {
@@ -494,25 +758,32 @@ const streamSessionEvents = async ({ agentUrl, fetchImpl, headers, onEvent, sess
494
758
  const reader = response.body.getReader();
495
759
  const decoder = new TextDecoder();
496
760
  let buffer = "";
497
- let consumed = 0;
761
+ let cursor = startIndex;
762
+ /** Returns how the read ends, or `null` to keep reading. */
498
763
  const processLine = (line) => {
499
764
  const trimmed = line.trim();
500
765
  if (!trimmed) {
501
- return false;
766
+ return null;
502
767
  }
503
- consumed += 1;
504
- let event;
768
+ let record;
505
769
  try {
506
- event = JSON.parse(trimmed);
770
+ record = JSON.parse(trimmed);
507
771
  }
508
772
  catch {
509
773
  // Skip malformed lines instead of failing the whole turn.
510
- return false;
511
- }
512
- if (!isRecord(event) || typeof event.type !== "string") {
513
- return false;
514
- }
515
- return onEvent(event);
774
+ cursor += 1;
775
+ return null;
776
+ }
777
+ // v27 transport records: never stored, never counted.
778
+ if (isRecord(record) && typeof record.$eve === "string") {
779
+ const transport = readTransportRecord(record, cursor);
780
+ cursor = transport.cursor;
781
+ return transport.end;
782
+ }
783
+ cursor += 1;
784
+ return handleStoredRecord(record, onEvent)
785
+ ? { cursor, reconnect: false }
786
+ : null;
516
787
  };
517
788
  try {
518
789
  while (true) {
@@ -522,8 +793,9 @@ const streamSessionEvents = async ({ agentUrl, fetchImpl, headers, onEvent, sess
522
793
  while (newlineIndex !== -1) {
523
794
  const line = buffer.slice(0, newlineIndex);
524
795
  buffer = buffer.slice(newlineIndex + 1);
525
- if (processLine(line)) {
526
- return consumed;
796
+ const result = processLine(line);
797
+ if (result) {
798
+ return result;
527
799
  }
528
800
  newlineIndex = buffer.indexOf("\n");
529
801
  }
@@ -531,19 +803,32 @@ const streamSessionEvents = async ({ agentUrl, fetchImpl, headers, onEvent, sess
531
803
  break;
532
804
  }
533
805
  }
534
- if (buffer.trim()) {
535
- processLine(buffer);
536
- }
537
- return consumed;
806
+ return ((buffer.trim() && processLine(buffer)) || { cursor, reconnect: false });
538
807
  }
539
808
  finally {
540
- // The eve stream stays open after `session.waiting`; release the
541
- // connection once the turn boundary is reached.
809
+ // The eve stream stays open after a turn boundary; release the
810
+ // connection once it is reached.
542
811
  await reader.cancel().catch(() => {
543
812
  // The reader may already be released or errored.
544
813
  });
545
814
  }
546
815
  };
816
+ /**
817
+ * Stream a turn's events until its boundary, reconnecting from the cursor
818
+ * when a v27 read lease ends. Resolves with the absolute position of the
819
+ * next stored line.
820
+ */
821
+ const streamSessionEvents = async (options) => {
822
+ let cursor = options.startIndex;
823
+ for (let read = 0; read < MAX_STREAM_READS; read++) {
824
+ const result = await readSessionStream({ ...options, startIndex: cursor });
825
+ cursor = result.cursor;
826
+ if (!result.reconnect) {
827
+ break;
828
+ }
829
+ }
830
+ return cursor;
831
+ };
547
832
  const cancelSession = ({ agentUrl, fetchImpl, headers, sessionId, }) => fetchImpl(`${agentUrl}${EVE_SESSION_PATH}/${encodeURIComponent(sessionId)}/cancel`, {
548
833
  method: "POST",
549
834
  body: JSON.stringify({}),
@@ -562,6 +847,7 @@ const cancelSession = ({ agentUrl, fetchImpl, headers, sessionId, }) => fetchImp
562
847
  export const streamEveAgentTurn = async ({ agentUrl, fetchImpl = fetch, headers, initialChunks = [], session, sessionTag = null, signal, toolCitations = true, visibleTools, writer, }) => {
563
848
  const normalizedUrl = normalizeAgentUrl(agentUrl);
564
849
  const { sessionId, startIndex } = session;
850
+ const deliveryId = session.deliveryId ?? null;
565
851
  // A bare `start` chunk does not flush client state; providing a message
566
852
  // id makes the assistant message render immediately, so the chat shows
567
853
  // the "Thinking..." indicator during model startup instead of a blank
@@ -571,12 +857,14 @@ export const streamEveAgentTurn = async ({ agentUrl, fetchImpl = fetch, headers,
571
857
  writer.write(chunk);
572
858
  }
573
859
  const translator = createEveEventTranslator(writer, {
860
+ deliveryId,
574
861
  toolCitations,
575
862
  visibleTools: visibleTools ? new Set(visibleTools) : null,
576
863
  });
577
- let consumed = 0;
864
+ const isTurnBoundary = createTurnBoundary(deliveryId);
865
+ let nextIndex = startIndex;
578
866
  try {
579
- consumed = await streamSessionEvents({
867
+ nextIndex = await streamSessionEvents({
580
868
  agentUrl: normalizedUrl,
581
869
  fetchImpl,
582
870
  headers,
@@ -585,7 +873,7 @@ export const streamEveAgentTurn = async ({ agentUrl, fetchImpl = fetch, headers,
585
873
  startIndex,
586
874
  onEvent: (event) => {
587
875
  translator.handleEvent(event);
588
- return isTurnBoundaryEvent(event.type);
876
+ return isTurnBoundary(event);
589
877
  },
590
878
  });
591
879
  }
@@ -608,7 +896,7 @@ export const streamEveAgentTurn = async ({ agentUrl, fetchImpl = fetch, headers,
608
896
  if (sessionTag && translator.isSessionWaiting()) {
609
897
  const eveAgent = {
610
898
  session: sessionTag,
611
- streamIndex: startIndex + consumed,
899
+ streamIndex: nextIndex,
612
900
  };
613
901
  writer.write({ type: "finish", messageMetadata: { eveAgent } });
614
902
  return;
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.14.1 so agents can understand the installed package without web access.
3
+ These docs are bundled with `@vercel/geistdocs` 2.14.2 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.14.1.
3
+ These docs are bundled with `@vercel/geistdocs` 2.14.2.
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
@@ -4281,7 +4281,7 @@ With eve 0.83 or newer, typing a follow-up also prepares the existing session ow
4281
4281
 
4282
4282
  Prewarming requires [`GEISTDOCS_CHAT_SECRET`](#keep-eve-sessions-across-turns-with-geistdocs_chat_secret). The route verifies the latest answer's session tag against the signed cookie before preparing an existing session. Preparation failures, older agents without support, and expired or mismatched cookies fall back to the normal send path. Leave prewarming disabled when typing a draft should not allocate a durable session before the reader sends a message.
4283
4283
 
4284
- 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. With `GEISTDOCS_CHAT_SECRET` set, Geistdocs continues one eve session across turns by binding it to the reader's browser with a signed, httpOnly cookie.
4284
+ 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. It reads both stream version 26 (eve 0.83 and older) and stream version 27 (eve 0.84 and newer), so the agent can upgrade across that boundary without a site change. With `GEISTDOCS_CHAT_SECRET` set, Geistdocs continues one eve session across turns by binding it to the reader's browser with a signed, httpOnly cookie.
4285
4285
 
4286
4286
  Eve agent mode keeps the platform-owned behavior from proxy mode:
4287
4287
 
@@ -467,5 +467,5 @@
467
467
  }
468
468
  ],
469
469
  "source": "apps/template/content/docs",
470
- "version": "2.14.1"
470
+ "version": "2.14.2"
471
471
  }
@@ -342,7 +342,7 @@ With eve 0.83 or newer, typing a follow-up also prepares the existing session ow
342
342
 
343
343
  Prewarming requires [`GEISTDOCS_CHAT_SECRET`](#keep-eve-sessions-across-turns-with-geistdocs_chat_secret). The route verifies the latest answer's session tag against the signed cookie before preparing an existing session. Preparation failures, older agents without support, and expired or mismatched cookies fall back to the normal send path. Leave prewarming disabled when typing a draft should not allocate a durable session before the reader sends a message.
344
344
 
345
- 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. With `GEISTDOCS_CHAT_SECRET` set, Geistdocs continues one eve session across turns by binding it to the reader's browser with a signed, httpOnly cookie.
345
+ 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. It reads both stream version 26 (eve 0.83 and older) and stream version 27 (eve 0.84 and newer), so the agent can upgrade across that boundary without a site change. With `GEISTDOCS_CHAT_SECRET` set, Geistdocs continues one eve session across turns by binding it to the reader's browser with a signed, httpOnly cookie.
346
346
 
347
347
  Eve agent mode keeps the platform-owned behavior from proxy mode:
348
348
 
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.14.1",
4
+ "version": "2.14.2",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",
@@ -340,7 +340,7 @@ With eve 0.83 or newer, typing a follow-up also prepares the existing session ow
340
340
 
341
341
  Prewarming requires [`GEISTDOCS_CHAT_SECRET`](#keep-eve-sessions-across-turns-with-geistdocs_chat_secret). The route verifies the latest answer's session tag against the signed cookie before preparing an existing session. Preparation failures, older agents without support, and expired or mismatched cookies fall back to the normal send path. Leave prewarming disabled when typing a draft should not allocate a durable session before the reader sends a message.
342
342
 
343
- 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. With `GEISTDOCS_CHAT_SECRET` set, Geistdocs continues one eve session across turns by binding it to the reader's browser with a signed, httpOnly cookie.
343
+ 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. It reads both stream version 26 (eve 0.83 and older) and stream version 27 (eve 0.84 and newer), so the agent can upgrade across that boundary without a site change. With `GEISTDOCS_CHAT_SECRET` set, Geistdocs continues one eve session across turns by binding it to the reader's browser with a signed, httpOnly cookie.
344
344
 
345
345
  Eve agent mode keeps the platform-owned behavior from proxy mode:
346
346
 
@@ -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.14.1",
20
+ "@vercel/geistdocs": "2.14.2",
21
21
  "@vercel/speed-insights": "^1.3.1",
22
22
  "ai": "^6.0.132",
23
23
  "clsx": "^2.1.1",