@vercel/geistdocs 2.14.3-canary.9417d69 → 2.14.4-canary.f3774fa
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/assets/icons/icon-share.d.ts +13 -0
- package/dist/assets/icons/icon-share.d.ts.map +1 -0
- package/dist/assets/icons/icon-share.js +12 -0
- package/dist/assets/icons/index.d.ts +1 -0
- package/dist/assets/icons/index.d.ts.map +1 -1
- package/dist/assets/icons/index.js +1 -0
- package/dist/cli/index.js +1 -1
- package/dist/config.d.ts +13 -6
- package/dist/config.d.ts.map +1 -1
- package/dist/controls.d.ts +1 -6
- package/dist/controls.d.ts.map +1 -1
- package/dist/controls.js +2 -8
- package/dist/internal/chat/message-text.d.ts +6 -0
- package/dist/internal/chat/message-text.d.ts.map +1 -1
- package/dist/internal/chat/message-text.js +6 -0
- package/dist/internal/chat/prompt-input.d.ts.map +1 -1
- package/dist/internal/chat/prompt-input.js +2 -1
- package/dist/internal/chat/share-chat.d.ts +7 -0
- package/dist/internal/chat/share-chat.d.ts.map +1 -0
- package/dist/internal/chat/share-chat.js +76 -0
- package/dist/internal/chat/sharing.d.ts +24 -0
- package/dist/internal/chat/sharing.d.ts.map +1 -0
- package/dist/internal/chat/sharing.js +115 -0
- package/dist/internal/chat/shell.d.ts.map +1 -1
- package/dist/internal/chat/shell.js +2 -1
- package/dist/internal/config-context.d.ts +0 -2
- package/dist/internal/config-context.d.ts.map +1 -1
- package/dist/internal/config-context.js +0 -2
- package/dist/internal/eve-agent.d.ts +2 -2
- package/dist/internal/eve-agent.js +2 -2
- package/dist/routes/chat.d.ts +6 -0
- package/dist/routes/chat.d.ts.map +1 -1
- package/dist/routes/chat.js +47 -6
- package/docs/agents.md +1 -1
- package/docs/llms.txt +28 -14
- package/docs/manifest.json +1 -1
- package/docs/pages/ask-ai.md +20 -0
- package/docs/pages/configuration.md +7 -13
- package/package.json +1 -1
- package/template/content/docs/ask-ai.cn.mdx +4 -0
- package/template/content/docs/ask-ai.mdx +20 -0
- package/template/content/docs/configuration.mdx +7 -13
- package/template/package.json +1 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ! THIS FILE WAS AUTO_GENERATED - DO NOT EDIT MANUALLY
|
|
3
|
+
*
|
|
4
|
+
* ▲ Part of Vercel's Geistcn Design System
|
|
5
|
+
* Generated by: pnpm icons:build
|
|
6
|
+
*
|
|
7
|
+
* @see Slack #project-geistcn for support: https://vercel.slack.com/archives/C08AW4PQHK3
|
|
8
|
+
*/
|
|
9
|
+
import type { JSX } from "react";
|
|
10
|
+
import { type IconProps } from "../_internal/components/icon/base-icon.js";
|
|
11
|
+
/** Icon component - renders as SVG */
|
|
12
|
+
export declare function IconShare(props: IconProps): JSX.Element;
|
|
13
|
+
//# sourceMappingURL=icon-share.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon-share.d.ts","sourceRoot":"","sources":["../../../src/assets/icons/icon-share.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAEL,KAAK,SAAS,EACf,MAAM,2CAA2C,CAAC;AAEnD,sCAAsC;AACtC,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,GAAG,CAAC,OAAO,CAMvD"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { BaseIcon, } from "../_internal/components/icon/base-icon.js";
|
|
3
|
+
/** Icon component - renders as SVG */
|
|
4
|
+
export function IconShare(props) {
|
|
5
|
+
return (_jsx(BaseIcon, { "$generated": GENERATED_CONFIG, ...props, children: ICON_PATHS }));
|
|
6
|
+
}
|
|
7
|
+
const GENERATED_CONFIG = {
|
|
8
|
+
height: 16,
|
|
9
|
+
aspectRatio: 1,
|
|
10
|
+
viewBox: "0 0 16 16",
|
|
11
|
+
};
|
|
12
|
+
const ICON_PATHS = (_jsx("path", { clipRule: "evenodd", d: "M7.3 1.4a1 1 0 0 1 1.4 0l3.08 3.07.53.53-1.06 1.06-.53-.53-1.97-1.97V11h-1.5V3.56L5.28 5.53l-.53.53L3.69 5l.53-.53zm6.2 7.85v4.25h-11v-5H1V14a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V8.5h-1.5z", fill: "currentColor", fillRule: "evenodd" }));
|
|
@@ -67,6 +67,7 @@ export { IconRoute } from "./icon-route";
|
|
|
67
67
|
export { IconRss } from "./icon-rss";
|
|
68
68
|
export { IconSandbox } from "./icon-sandbox";
|
|
69
69
|
export { IconShieldCheck } from "./icon-shield-check";
|
|
70
|
+
export { IconShare } from "./icon-share";
|
|
70
71
|
export { IconSlashForward } from "./icon-slash-forward";
|
|
71
72
|
export { IconSparkles } from "./icon-sparkles";
|
|
72
73
|
export { IconSpeakerOff } from "./icon-speaker-off";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/assets/icons/index.tsx"],"names":[],"mappings":"AAAA,qCAAqC;AAGrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OA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AS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -68,6 +68,7 @@ export { IconRoute } from "./icon-route";
|
|
|
68
68
|
export { IconRss } from "./icon-rss";
|
|
69
69
|
export { IconSandbox } from "./icon-sandbox";
|
|
70
70
|
export { IconShieldCheck } from "./icon-shield-check";
|
|
71
|
+
export { IconShare } from "./icon-share";
|
|
71
72
|
export { IconSlashForward } from "./icon-slash-forward";
|
|
72
73
|
export { IconSparkles } from "./icon-sparkles";
|
|
73
74
|
export { IconSpeakerOff } from "./icon-speaker-off";
|
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.3-canary.9417d69","-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.4-canary.f3774fa","-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
|
@@ -102,13 +102,18 @@ export interface GeistdocsAIHistoryConfig {
|
|
|
102
102
|
*/
|
|
103
103
|
retentionDays?: number;
|
|
104
104
|
}
|
|
105
|
-
export interface
|
|
105
|
+
export interface GeistdocsAIShareConfig {
|
|
106
106
|
/**
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
* @default "Search…"
|
|
107
|
+
* App-local POST endpoint that stores a conversation and returns
|
|
108
|
+
* `{ shareId: string }`. Geistdocs sends `{ messages, hostPath, summary? }`.
|
|
110
109
|
*/
|
|
111
|
-
|
|
110
|
+
endpoint: string;
|
|
111
|
+
/**
|
|
112
|
+
* App-local path where shared conversations are served. Geistdocs appends
|
|
113
|
+
* the returned share ID and copies the resulting URL. Geistdocs adds
|
|
114
|
+
* `basePath` automatically. @default "/ai-chat"
|
|
115
|
+
*/
|
|
116
|
+
path?: string;
|
|
112
117
|
}
|
|
113
118
|
export interface GeistdocsAIConfig extends GeistdocsFeatureConfig {
|
|
114
119
|
/**
|
|
@@ -148,6 +153,8 @@ export interface GeistdocsAIConfig extends GeistdocsFeatureConfig {
|
|
|
148
153
|
* index. Mixedbread credentials stay server-side in environment variables.
|
|
149
154
|
*/
|
|
150
155
|
retrieval?: "local" | "mixedbread";
|
|
156
|
+
/** Show a Share chat action backed by the site's own persistence endpoint. */
|
|
157
|
+
share?: GeistdocsAIShareConfig;
|
|
151
158
|
/**
|
|
152
159
|
* Suggested prompts shown before the first message. The first four
|
|
153
160
|
* distinct, non-blank suggestions are shown. Plain strings render without
|
|
@@ -284,7 +291,7 @@ export interface GeistdocsConfig {
|
|
|
284
291
|
navbarVariant?: "oss" | "standard";
|
|
285
292
|
pageActions?: GeistdocsPageActionsConfig;
|
|
286
293
|
prompt?: string;
|
|
287
|
-
search?:
|
|
294
|
+
search?: GeistdocsFeatureConfig;
|
|
288
295
|
/**
|
|
289
296
|
* Serve the site in one language without a `[lang]` route segment. App
|
|
290
297
|
* routes live directly under `app/` instead of `app/[lang]/`, the proxy
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKvC,eAAO,MAAM,iBAAiB,GAAI,UAAU,MAAM,GAAG,SAAS,WAO7D,CAAC;AAEF,+EAA+E;AAC/E,eAAO,MAAM,aAAa,GAAI,M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,qBAAqB,CAAC;CAChC;AAED,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,eAAe,EAAE,QAAQ,CAAC,KAAG,CAAW,CAAC"}
|
package/dist/controls.d.ts
CHANGED
|
@@ -8,14 +8,9 @@ export type { GeistdocsChatController, GeistdocsChatPage, } from "./internal/cha
|
|
|
8
8
|
export declare const useGeistdocsChat: () => GeistdocsChatController;
|
|
9
9
|
interface SearchButtonProps {
|
|
10
10
|
className?: string;
|
|
11
|
-
/**
|
|
12
|
-
* Button text. Defaults to `search.buttonLabel` from the config, then
|
|
13
|
-
* "Search…".
|
|
14
|
-
*/
|
|
15
|
-
label?: string;
|
|
16
11
|
onClick?: () => void;
|
|
17
12
|
}
|
|
18
|
-
export declare const SearchButton: ({ className,
|
|
13
|
+
export declare const SearchButton: ({ className, onClick }: SearchButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
19
14
|
export declare const ThemeToggle: () => import("react/jsx-runtime").JSX.Element;
|
|
20
15
|
export declare const LanguageSelector: () => import("react/jsx-runtime").JSX.Element | null;
|
|
21
16
|
interface AskAIButtonProps {
|
package/dist/controls.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controls.d.ts","sourceRoot":"","sources":["../src/controls.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAgC,MAAM,OAAO,CAAC;AAWrE,OAAO,EACL,KAAK,uBAAuB,EAE7B,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"controls.d.ts","sourceRoot":"","sources":["../src/controls.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAgC,MAAM,OAAO,CAAC;AAWrE,OAAO,EACL,KAAK,uBAAuB,EAE7B,MAAM,yBAAyB,CAAC;AAQjC,YAAY,EACV,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,yBAAyB,CAAC;AAEjC;;;GAGG;AACH,eAAO,MAAM,gBAAgB,QAAO,uBAwBnC,CAAC;AAEF,UAAU,iBAAiB;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,eAAO,MAAM,YAAY,GAAI,wBAAwB,iBAAiB,4CAqBrE,CAAC;AAEF,eAAO,MAAM,WAAW,+CA0CvB,CAAC;AAEF,eAAO,MAAM,gBAAgB,sDA+B5B,CAAC;AAEF,UAAU,gBAAgB;IACxB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,IAAI,CAAC;IACpD,OAAO,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,UAAU,CAAC;CAChD;AAED,eAAO,MAAM,WAAW,GAAI,0DAOzB,gBAAgB,mDAgClB,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,wDAAwD;IACxD,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED;;;;GAIG;AACH,eAAO,MAAM,SAAS,GAAI,qBAAqB,cAAc,SAc5D,CAAC"}
|
package/dist/controls.js
CHANGED
|
@@ -9,7 +9,6 @@ import { Kbd } from "#geistdocs-ui/components/kbd";
|
|
|
9
9
|
import { useTheme } from "#geistdocs-ui/core";
|
|
10
10
|
import { cn } from "#geistdocs-ui/utils";
|
|
11
11
|
import { useGeistdocsChatContext, } from "./internal/chat/context";
|
|
12
|
-
import { useOptionalGeistdocsConfig } from "./internal/config-context";
|
|
13
12
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "./internal/ui/dropdown-menu";
|
|
14
13
|
/**
|
|
15
14
|
* Control the Ask AI chat from custom components rendered inside
|
|
@@ -35,17 +34,12 @@ export const useGeistdocsChat = () => {
|
|
|
35
34
|
},
|
|
36
35
|
}), [ask, enabled, isOpen, openWithPage, setIsOpen]);
|
|
37
36
|
};
|
|
38
|
-
const
|
|
39
|
-
export const SearchButton = ({ className, label, onClick, }) => {
|
|
37
|
+
export const SearchButton = ({ className, onClick }) => {
|
|
40
38
|
const { setOpenSearch } = useSearchContext();
|
|
41
|
-
const config = useOptionalGeistdocsConfig();
|
|
42
|
-
const text = label?.trim() ||
|
|
43
|
-
config?.search?.buttonLabel?.trim() ||
|
|
44
|
-
DEFAULT_SEARCH_LABEL;
|
|
45
39
|
return (_jsxs("button", { className: cn("flex h-8 cursor-pointer items-center justify-between rounded-md border-0 bg-background-100 py-0 pr-1.5 pl-3.5 font-normal font-sans text-gray-1000 text-sm shadow-[0_0_0_1px_var(--ds-gray-400)] outline-none hover:bg-gray-100 focus-visible:shadow-[var(--ds-focus-ring)]", className), onClick: () => {
|
|
46
40
|
setOpenSearch(true);
|
|
47
41
|
onClick?.();
|
|
48
|
-
}, type: "button", children: [_jsx("span", { className: "pr-6", children:
|
|
42
|
+
}, type: "button", children: [_jsx("span", { className: "pr-6", children: "Search\u2026" }), _jsx(Kbd, { className: "inline-flex items-center justify-center rounded", small: true, children: "\u2318K" })] }));
|
|
49
43
|
};
|
|
50
44
|
export const ThemeToggle = () => {
|
|
51
45
|
const { resolvedTheme, setTheme } = useTheme();
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { UIMessage } from "ai";
|
|
2
|
+
/**
|
|
3
|
+
* Longest reader message Ask AI accepts, in characters. The chat input stops
|
|
4
|
+
* typing and pasting at this length, and the chat route truncates the last
|
|
5
|
+
* user message to it, since the route is publicly reachable.
|
|
6
|
+
*/
|
|
7
|
+
export declare const MAX_USER_MESSAGE_CHARS = 4000;
|
|
2
8
|
/**
|
|
3
9
|
* The Markdown a reader sees for a message: its non-blank text parts, in
|
|
4
10
|
* order, separated by blank lines. Reasoning, tool, and source parts are
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-text.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/message-text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAEpC;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAI,SAAS,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,KAAG,MAUtD,CAAC"}
|
|
1
|
+
{"version":3,"file":"message-text.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/message-text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAEpC;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAE3C;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAI,SAAS,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,KAAG,MAUtD,CAAC"}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Longest reader message Ask AI accepts, in characters. The chat input stops
|
|
3
|
+
* typing and pasting at this length, and the chat route truncates the last
|
|
4
|
+
* user message to it, since the route is publicly reachable.
|
|
5
|
+
*/
|
|
6
|
+
export const MAX_USER_MESSAGE_CHARS = 4000;
|
|
1
7
|
/**
|
|
2
8
|
* The Markdown a reader sees for a message: its non-blank text parts, in
|
|
3
9
|
* order, separated by blank lines. Reasoning, tool, and source parts are
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-input.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/prompt-input.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AACrC,OAAO,EAEL,KAAK,gBAAgB,EAErB,KAAK,SAAS,EAGf,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"prompt-input.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/prompt-input.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AACrC,OAAO,EAEL,KAAK,gBAAgB,EAErB,KAAK,SAAS,EAGf,MAAM,OAAO,CAAC;AAKf,UAAU,oBAAoB;IAC5B,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,gBAAgB,CAAC,eAAe,CAAC,CAAC;IAC5C,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,WAAW,EAAE,SAAS,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC;IACnD,KAAK,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,eAAe,GAAI,6DAO7B,oBAAoB,4CAoFtB,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useCallback, useEffect, } from "react";
|
|
4
4
|
import { IconArrowUp, IconStopCircle } from "#geistdocs-assets/icons";
|
|
5
5
|
import { Button } from "#geistdocs-ui/components/button";
|
|
6
|
+
import { MAX_USER_MESSAGE_CHARS } from "./message-text";
|
|
6
7
|
export const ChatPromptInput = ({ onChange, onStop, onSubmit, status, textareaRef, value, }) => {
|
|
7
8
|
const isGenerating = status === "submitted" || status === "streaming";
|
|
8
9
|
const isEmpty = value.trim().length === 0;
|
|
@@ -34,5 +35,5 @@ export const ChatPromptInput = ({ onChange, onStop, onSubmit, status, textareaRe
|
|
|
34
35
|
event.currentTarget.form?.requestSubmit();
|
|
35
36
|
}
|
|
36
37
|
};
|
|
37
|
-
return (_jsx("div", { className: "cursor-text rounded-[12px] border border-gray-300 border-solid pt-2 pb-2 shadow-xs transition-colors duration-250 focus-within:border-gray-500", children: _jsxs("form", { className: "flex flex-col items-center gap-2", onSubmit: onSubmit, children: [_jsx("textarea", { className: "min-h-0 w-full resize-none rounded-none border-0 bg-transparent px-4 py-2 font-sans text-copy-16 text-gray-1000 shadow-none outline-hidden ring-0 placeholder:text-gray-600 focus:outline-none focus-visible:ring-0 min-[768px]:text-copy-14", maxLength:
|
|
38
|
+
return (_jsx("div", { className: "cursor-text rounded-[12px] border border-gray-300 border-solid pt-2 pb-2 shadow-xs transition-colors duration-250 focus-within:border-gray-500", children: _jsxs("form", { className: "flex flex-col items-center gap-2", onSubmit: onSubmit, children: [_jsx("textarea", { className: "min-h-0 w-full resize-none rounded-none border-0 bg-transparent px-4 py-2 font-sans text-copy-16 text-gray-1000 shadow-none outline-hidden ring-0 placeholder:text-gray-600 focus:outline-none focus-visible:ring-0 min-[768px]:text-copy-14", maxLength: MAX_USER_MESSAGE_CHARS, name: "message", onChange: handleChange, onKeyDown: handleKeyDown, placeholder: "Ask a question...", ref: textareaRef, value: value }), _jsx("div", { className: "flex w-full items-center justify-end px-2", children: isGenerating && onStop ? (_jsx(Button, { className: "animate-fade-in-scale", onClick: onStop, prefix: _jsx(IconStopCircle, { className: "size-4" }), size: "small", typeName: "button", children: "Stop" })) : (_jsx(Button, { "aria-label": "Submit", className: "size-8 animate-fade-in-scale p-0", disabled: isEmpty, shape: "square", size: "small", svgOnly: true, typeName: "submit", children: _jsx(IconArrowUp, { className: "size-4" }) })) })] }) }));
|
|
38
39
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { UIMessage } from "ai";
|
|
2
|
+
import type { RefObject } from "react";
|
|
3
|
+
export declare const ShareChat: ({ messages, textareaRef, }: {
|
|
4
|
+
messages: UIMessage[];
|
|
5
|
+
textareaRef: RefObject<HTMLTextAreaElement | null>;
|
|
6
|
+
}) => import("react/jsx-runtime").JSX.Element | null;
|
|
7
|
+
//# sourceMappingURL=share-chat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"share-chat.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/share-chat.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAgBvC,eAAO,MAAM,SAAS,GAAI,4BAGvB;IACD,QAAQ,EAAE,SAAS,EAAE,CAAC;IACtB,WAAW,EAAE,SAAS,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC;CACpD,mDAqFA,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo, useState } from "react";
|
|
4
|
+
import { IconShare } from "#geistdocs-assets/icons";
|
|
5
|
+
import { Button } from "#geistdocs-ui/components/button";
|
|
6
|
+
import { Spinner } from "#geistdocs-ui/components/spinner";
|
|
7
|
+
import { useToasts } from "#geistdocs-ui/components/toasts";
|
|
8
|
+
import { Tooltip } from "#geistdocs-ui/components/tooltip";
|
|
9
|
+
import { useGeistdocsConfig } from "../config-context";
|
|
10
|
+
import { ChatShareError, createChatShareUrl, getChatShareErrorText, hasShareableMessages, resolveChatShareConfig, } from "./sharing";
|
|
11
|
+
export const ShareChat = ({ messages, textareaRef, }) => {
|
|
12
|
+
const config = useGeistdocsConfig();
|
|
13
|
+
const toast = useToasts();
|
|
14
|
+
const [isSharing, setIsSharing] = useState(false);
|
|
15
|
+
const canShare = useMemo(() => hasShareableMessages(messages), [messages]);
|
|
16
|
+
const share = config.ai?.share;
|
|
17
|
+
if (!share) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
const handleShare = async () => {
|
|
21
|
+
if (!canShare) {
|
|
22
|
+
toast.error({ text: "Send a message before sharing" });
|
|
23
|
+
textareaRef.current?.focus();
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
setIsSharing(true);
|
|
27
|
+
try {
|
|
28
|
+
const resolved = resolveChatShareConfig(share, config.basePath);
|
|
29
|
+
const shareUrlPromise = createChatShareUrl({
|
|
30
|
+
endpoint: resolved.endpoint,
|
|
31
|
+
hostPath: window.location.pathname,
|
|
32
|
+
messages,
|
|
33
|
+
origin: window.location.origin,
|
|
34
|
+
path: resolved.path,
|
|
35
|
+
});
|
|
36
|
+
if (typeof ClipboardItem !== "undefined" && navigator.clipboard?.write) {
|
|
37
|
+
await Promise.all([
|
|
38
|
+
navigator.clipboard.write([
|
|
39
|
+
new ClipboardItem({
|
|
40
|
+
"text/plain": shareUrlPromise.then((shareUrl) => new Blob([shareUrl], { type: "text/plain" })),
|
|
41
|
+
}),
|
|
42
|
+
]),
|
|
43
|
+
shareUrlPromise,
|
|
44
|
+
]);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
const shareUrl = await shareUrlPromise;
|
|
48
|
+
if (!navigator.clipboard?.writeText) {
|
|
49
|
+
throw new Error("Clipboard API is not available");
|
|
50
|
+
}
|
|
51
|
+
await navigator.clipboard.writeText(shareUrl);
|
|
52
|
+
}
|
|
53
|
+
toast.success({ text: "Chat link copied to clipboard!" });
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
if (error instanceof ChatShareError) {
|
|
57
|
+
if (process.env.NODE_ENV !== "production") {
|
|
58
|
+
console.debug("Failed to create chat share link", {
|
|
59
|
+
details: error.details,
|
|
60
|
+
status: error.status,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
toast.error({ text: getChatShareErrorText(error) });
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
console.error("Failed to copy chat link", error);
|
|
67
|
+
toast.error({ text: "Failed to copy chat link" });
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
finally {
|
|
71
|
+
setIsSharing(false);
|
|
72
|
+
textareaRef.current?.focus();
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
return (_jsx(Tooltip, { position: "bottom", text: "Share chat", children: _jsx(Button, { "aria-label": "Share chat", className: "text-gray-800! disabled:bg-gray-alpha-100!", disabled: !canShare || isSharing, onClick: handleShare, shape: "square", size: "small", svgOnly: true, typeName: "button", variant: "tertiary", children: isSharing ? _jsx(Spinner, { "aria-label": "Sharing" }) : _jsx(IconShare, { size: 14 }) }) }));
|
|
76
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { UIMessage } from "ai";
|
|
2
|
+
import type { GeistdocsAIShareConfig } from "../../config.js";
|
|
3
|
+
export declare class ChatShareError extends Error {
|
|
4
|
+
details?: string;
|
|
5
|
+
status?: number;
|
|
6
|
+
constructor(message: string, options?: {
|
|
7
|
+
details?: string;
|
|
8
|
+
status?: number;
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export declare const resolveChatShareConfig: (share: GeistdocsAIShareConfig, basePath: string | undefined) => {
|
|
12
|
+
endpoint: string;
|
|
13
|
+
path: string;
|
|
14
|
+
};
|
|
15
|
+
export declare const hasShareableMessages: (messages: readonly UIMessage[]) => boolean;
|
|
16
|
+
export declare const createChatShareUrl: ({ endpoint, hostPath, messages, origin, path, }: {
|
|
17
|
+
endpoint: string;
|
|
18
|
+
hostPath: string;
|
|
19
|
+
messages: readonly UIMessage[];
|
|
20
|
+
origin: string;
|
|
21
|
+
path: string;
|
|
22
|
+
}) => Promise<string>;
|
|
23
|
+
export declare const getChatShareErrorText: (error: ChatShareError) => "Too many attempts. Try again in a minute." | "Failed to create chat link. Please try again.";
|
|
24
|
+
//# sourceMappingURL=sharing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sharing.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/sharing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAEpC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAO9D,qBAAa,cAAe,SAAQ,KAAK;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;gBAGd,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAO;CAOtD;AA2BD,eAAO,MAAM,sBAAsB,GACjC,OAAO,sBAAsB,EAC7B,UAAU,MAAM,GAAG,SAAS;;;CAU5B,CAAC;AAEH,eAAO,MAAM,oBAAoB,GAAI,UAAU,SAAS,SAAS,EAAE,YAKhE,CAAC;AA4CJ,eAAO,MAAM,kBAAkB,GAAU,iDAMtC;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,SAAS,SAAS,EAAE,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd,oBA0CA,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,OAAO,cAAc,kGAGN,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { getPublicPath } from "../../config.js";
|
|
2
|
+
const DEFAULT_SHARE_PATH = "/ai-chat";
|
|
3
|
+
const INVALID_PATH_CHARACTERS = /[\s?#\\]/;
|
|
4
|
+
const MAX_ERROR_DETAILS_LENGTH = 500;
|
|
5
|
+
const MAX_SUMMARY_LENGTH = 512;
|
|
6
|
+
export class ChatShareError extends Error {
|
|
7
|
+
details;
|
|
8
|
+
status;
|
|
9
|
+
constructor(message, options = {}) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = "ChatShareError";
|
|
12
|
+
this.details = options.details;
|
|
13
|
+
this.status = options.status;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const resolveAppLocalPath = (value, option) => {
|
|
17
|
+
if (typeof value !== "string" ||
|
|
18
|
+
!value.startsWith("/") ||
|
|
19
|
+
value.startsWith("//") ||
|
|
20
|
+
value === "/" ||
|
|
21
|
+
INVALID_PATH_CHARACTERS.test(value)) {
|
|
22
|
+
throw new Error(`${option} must be a root-relative path without a query string, fragment, whitespace, or backslashes. Received ${JSON.stringify(value)}.`);
|
|
23
|
+
}
|
|
24
|
+
if (new URL(value, "https://geistdocs.local").pathname !== value ||
|
|
25
|
+
value.endsWith("/")) {
|
|
26
|
+
throw new Error(`${option} must be a normalized path without "." or ".." segments, characters that need percent-encoding, or a trailing slash. Received ${JSON.stringify(value)}.`);
|
|
27
|
+
}
|
|
28
|
+
return value;
|
|
29
|
+
};
|
|
30
|
+
export const resolveChatShareConfig = (share, basePath) => ({
|
|
31
|
+
endpoint: getPublicPath(resolveAppLocalPath(share.endpoint, "ai.share.endpoint"), basePath),
|
|
32
|
+
path: getPublicPath(resolveAppLocalPath(share.path ?? DEFAULT_SHARE_PATH, "ai.share.path"), basePath),
|
|
33
|
+
});
|
|
34
|
+
export const hasShareableMessages = (messages) => messages.some((message) => message.parts.some((part) => part.type === "text" && part.text.trim().length > 0));
|
|
35
|
+
const getShareSummary = (messages) => {
|
|
36
|
+
const firstQuestion = messages.find((message) => message.role === "user");
|
|
37
|
+
const summary = firstQuestion?.parts
|
|
38
|
+
.filter((part) => part.type === "text")
|
|
39
|
+
.map((part) => part.text)
|
|
40
|
+
.join("\n")
|
|
41
|
+
.trim();
|
|
42
|
+
return summary ? summary.slice(0, MAX_SUMMARY_LENGTH) : undefined;
|
|
43
|
+
};
|
|
44
|
+
const asRecord = (value) => value && typeof value === "object" && !Array.isArray(value)
|
|
45
|
+
? value
|
|
46
|
+
: undefined;
|
|
47
|
+
const bounded = (value) => {
|
|
48
|
+
const trimmed = value?.trim();
|
|
49
|
+
return trimmed ? trimmed.slice(0, MAX_ERROR_DETAILS_LENGTH) : undefined;
|
|
50
|
+
};
|
|
51
|
+
const responseErrorDetails = async (response) => {
|
|
52
|
+
try {
|
|
53
|
+
const contentType = response.headers.get("content-type") ?? "";
|
|
54
|
+
if (!contentType.includes("application/json")) {
|
|
55
|
+
return bounded(await response.text());
|
|
56
|
+
}
|
|
57
|
+
const body = asRecord(await response.json());
|
|
58
|
+
const error = body?.error;
|
|
59
|
+
if (typeof error === "string") {
|
|
60
|
+
return bounded(error);
|
|
61
|
+
}
|
|
62
|
+
const nested = asRecord(error);
|
|
63
|
+
if (typeof nested?.message === "string") {
|
|
64
|
+
return bounded(nested.message);
|
|
65
|
+
}
|
|
66
|
+
return typeof body?.message === "string" ? bounded(body.message) : undefined;
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
export const createChatShareUrl = async ({ endpoint, hostPath, messages, origin, path, }) => {
|
|
73
|
+
let response;
|
|
74
|
+
try {
|
|
75
|
+
response = await fetch(endpoint, {
|
|
76
|
+
body: JSON.stringify({
|
|
77
|
+
hostPath,
|
|
78
|
+
messages,
|
|
79
|
+
summary: getShareSummary(messages),
|
|
80
|
+
}),
|
|
81
|
+
headers: { "Content-Type": "application/json" },
|
|
82
|
+
method: "POST",
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
throw new ChatShareError("Share link request failed", {
|
|
87
|
+
details: error instanceof Error ? error.message : undefined,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
if (!response.ok) {
|
|
91
|
+
throw new ChatShareError("Share link request failed", {
|
|
92
|
+
details: await responseErrorDetails(response),
|
|
93
|
+
status: response.status,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
let body;
|
|
97
|
+
try {
|
|
98
|
+
body = await response.json();
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
throw new ChatShareError("Share link response was invalid", {
|
|
102
|
+
details: error instanceof Error ? error.message : undefined,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
const shareId = asRecord(body)?.shareId;
|
|
106
|
+
if (typeof shareId !== "string" || !shareId) {
|
|
107
|
+
throw new ChatShareError("Share link response did not include a share ID");
|
|
108
|
+
}
|
|
109
|
+
const url = new URL(origin);
|
|
110
|
+
url.pathname = `${path}/${encodeURIComponent(shareId)}`;
|
|
111
|
+
return url.toString();
|
|
112
|
+
};
|
|
113
|
+
export const getChatShareErrorText = (error) => error.status === 429
|
|
114
|
+
? "Too many attempts. Try again in a minute."
|
|
115
|
+
: "Failed to create chat link. Please try again.";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/shell.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/shell.tsx"],"names":[],"mappings":"AAkfA,eAAO,MAAM,kBAAkB,sDAiE9B,CAAC"}
|
|
@@ -23,6 +23,7 @@ import { MessageActions } from "./message-actions";
|
|
|
23
23
|
import { MessageMetadata } from "./message-metadata";
|
|
24
24
|
import { ChatMessagePageChip, ChatPageAttachmentCard } from "./page-attachment";
|
|
25
25
|
import { ChatPromptInput } from "./prompt-input";
|
|
26
|
+
import { ShareChat } from "./share-chat";
|
|
26
27
|
import { GeistdocsChatSessionProvider, useChatSession, } from "./session-provider";
|
|
27
28
|
import { Suggestion, Suggestions } from "./suggestion";
|
|
28
29
|
import { useChatCommands } from "./use-chat-commands";
|
|
@@ -115,7 +116,7 @@ const GeistdocsChatPanel = ({ clearConversation, expandable, session, textareaRe
|
|
|
115
116
|
});
|
|
116
117
|
}
|
|
117
118
|
};
|
|
118
|
-
return (_jsxs("aside", { "aria-label": `${chatTitle} chat`, className: "flex size-full w-full flex-col overflow-hidden whitespace-nowrap bg-background-100", children: [_jsxs("div", { className: cn("sticky top-0 z-10 flex h-16 shrink-0 items-center justify-between bg-background-100 py-2 pr-2 pl-3.5", isExpanded && EXPANDED_COLUMN), children: [_jsx("h2", { className: "font-semibold text-sm", children: chatTitle }), _jsxs("div", { className: "flex items-center gap-0.5", children: [_jsx(CopyChat, { messages: messages }), expandable ? (_jsx(Tooltip, { position: "bottom", text: expandLabel, children: _jsx(Button, { "aria-label": expandLabel, "aria-pressed": isExpanded, className: "text-gray-800! shadow-none", onClick: () => setIsExpanded(!isExpanded), shape: "square", size: "small", svgOnly: true, typeName: "button", variant: "tertiary", children: isExpanded ? (_jsx(IconFullscreenClose, { size: 14 })) : (_jsx(IconFullscreen, { size: 14 })) }) })) : null, _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 ||
|
|
119
|
+
return (_jsxs("aside", { "aria-label": `${chatTitle} chat`, className: "flex size-full w-full flex-col overflow-hidden whitespace-nowrap bg-background-100", children: [_jsxs("div", { className: cn("sticky top-0 z-10 flex h-16 shrink-0 items-center justify-between bg-background-100 py-2 pr-2 pl-3.5", isExpanded && EXPANDED_COLUMN), children: [_jsx("h2", { className: "font-semibold text-sm", children: chatTitle }), _jsxs("div", { className: "flex items-center gap-0.5", children: [_jsx(CopyChat, { messages: messages }), _jsx(ShareChat, { messages: messages, textareaRef: textareaRef }), expandable ? (_jsx(Tooltip, { position: "bottom", text: expandLabel, children: _jsx(Button, { "aria-label": expandLabel, "aria-pressed": isExpanded, className: "text-gray-800! shadow-none", onClick: () => setIsExpanded(!isExpanded), shape: "square", size: "small", svgOnly: true, typeName: "button", variant: "tertiary", children: isExpanded ? (_jsx(IconFullscreenClose, { size: 14 })) : (_jsx(IconFullscreen, { size: 14 })) }) })) : null, _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 ||
|
|
119
120
|
status === "streaming" ||
|
|
120
121
|
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, { className: cn(isExpanded && EXPANDED_COLUMN), children: [messages.map((message, index) => {
|
|
121
122
|
const inProgress = isActiveAssistantMessage({
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import type { GeistdocsConfig } from "../config";
|
|
3
3
|
export declare const useGeistdocsConfig: () => GeistdocsConfig;
|
|
4
|
-
/** Like `useGeistdocsConfig`, but returns null outside a GeistdocsProvider. */
|
|
5
|
-
export declare const useOptionalGeistdocsConfig: () => GeistdocsConfig | null;
|
|
6
4
|
interface GeistdocsConfigProviderProps {
|
|
7
5
|
children: ReactNode;
|
|
8
6
|
config: GeistdocsConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-context.d.ts","sourceRoot":"","sources":["../../src/internal/config-context.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,SAAS,EAAuB,MAAM,OAAO,CAAC;AAC3E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAIjD,eAAO,MAAM,kBAAkB,QAAO,eAUrC,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"config-context.d.ts","sourceRoot":"","sources":["../../src/internal/config-context.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,SAAS,EAAuB,MAAM,OAAO,CAAC;AAC3E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAIjD,eAAO,MAAM,kBAAkB,QAAO,eAUrC,CAAC;AAEF,UAAU,4BAA4B;IACpC,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,EAAE,eAAe,CAAC;CACzB;AAED,eAAO,MAAM,uBAAuB,GAAI,uBAGrC,4BAA4B,4CAQ9B,CAAC"}
|
|
@@ -9,8 +9,6 @@ export const useGeistdocsConfig = () => {
|
|
|
9
9
|
}
|
|
10
10
|
return context;
|
|
11
11
|
};
|
|
12
|
-
/** Like `useGeistdocsConfig`, but returns null outside a GeistdocsProvider. */
|
|
13
|
-
export const useOptionalGeistdocsConfig = () => useContext(GeistdocsConfigContext);
|
|
14
12
|
export const GeistdocsConfigProvider = ({ children, config, }) => {
|
|
15
13
|
const value = useMemo(() => config, [config]);
|
|
16
14
|
return (_jsx(GeistdocsConfigContext.Provider, { value: value, children: children }));
|
|
@@ -87,8 +87,8 @@ export declare const resolveEveAgentUrl: ({ configUrl, hasProxy, optionUrl, }: {
|
|
|
87
87
|
}) => string | null;
|
|
88
88
|
/**
|
|
89
89
|
* Cap the text of the trailing user message. The chat client limits input
|
|
90
|
-
* to
|
|
91
|
-
* forward arbitrarily large payloads to the
|
|
90
|
+
* to the same length, but the route is publicly reachable and must not
|
|
91
|
+
* forward arbitrarily large payloads to the model.
|
|
92
92
|
*/
|
|
93
93
|
export declare const capLastUserMessageText: (messages: UIMessage[], limit: number) => UIMessage[];
|
|
94
94
|
/**
|
|
@@ -91,8 +91,8 @@ export const resolveEveAgentUrl = ({ configUrl, hasProxy, optionUrl, }) => {
|
|
|
91
91
|
};
|
|
92
92
|
/**
|
|
93
93
|
* Cap the text of the trailing user message. The chat client limits input
|
|
94
|
-
* to
|
|
95
|
-
* forward arbitrarily large payloads to the
|
|
94
|
+
* to the same length, but the route is publicly reachable and must not
|
|
95
|
+
* forward arbitrarily large payloads to the model.
|
|
96
96
|
*/
|
|
97
97
|
export const capLastUserMessageText = (messages, limit) => {
|
|
98
98
|
const lastMessage = messages.at(-1);
|
package/dist/routes/chat.d.ts
CHANGED
|
@@ -82,6 +82,12 @@ interface ChatEveAgentOptions {
|
|
|
82
82
|
visibleTools?: string[];
|
|
83
83
|
}
|
|
84
84
|
interface ChatRequestLimits {
|
|
85
|
+
/**
|
|
86
|
+
* Most message parts accepted in one request, counted across all
|
|
87
|
+
* messages. Larger requests receive 400.
|
|
88
|
+
* @default 2000
|
|
89
|
+
*/
|
|
90
|
+
maxMessageParts?: number;
|
|
85
91
|
/**
|
|
86
92
|
* Most messages accepted in one request. Larger requests receive 400.
|
|
87
93
|
* @default 200
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/routes/chat.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,aAAa,EAQnB,MAAM,IAAI,CAAC;AAGZ,OAAO,EAAE,KAAK,eAAe,EAAiB,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/routes/chat.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,aAAa,EAQnB,MAAM,IAAI,CAAC;AAGZ,OAAO,EAAE,KAAK,eAAe,EAAiB,MAAM,WAAW,CAAC;AAMhE,OAAO,EAEL,KAAK,qBAAqB,EAG3B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAIL,KAAK,qBAAqB,EAU3B,MAAM,uBAAuB,CAAC;AAW/B,OAAO,EACL,KAAK,mBAAmB,EAEzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAEvD,KAAK,YAAY,GAAG,qBAAqB,CAAC;AA4B1C;;;GAGG;AACH,KAAK,mBAAmB,GACpB,WAAW,GACX,CAAC,CAAC,OAAO,EAAE,OAAO,KAAK,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;AAE/D,UAAU,eAAe;IACvB,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;GAOG;AACH,KAAK,oBAAoB,GAAG,MAAM,GAAG,WAAW,CAAC;AAEjD,+EAA+E;AAC/E,UAAU,uBAAuB;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;CACb;AAED,2EAA2E;AAC3E,KAAK,iCAAiC,GAAG,CAAC,OAAO,EAAE;IACjD,WAA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,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;CAC1B;AAquDD,eAAO,MAAM,eAAe,GAAI,wGAW7B,sBAAsB;gBAqBE,OAAO;;CAkMjC,CAAC"}
|
package/dist/routes/chat.js
CHANGED
|
@@ -3,6 +3,7 @@ import { convertToModelMessages, createUIMessageStream, createUIMessageStreamRes
|
|
|
3
3
|
import { initAdvancedSearch } from "fumadocs-core/search/server";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { getPublicPath } from "../config";
|
|
6
|
+
import { MAX_USER_MESSAGE_CHARS } from "../internal/chat/message-text";
|
|
6
7
|
import { createSourceChunk, createSourceChunks, } from "../internal/chat/source-chunks";
|
|
7
8
|
import { createChatDocumentSearch, } from "../internal/chat-retrieval";
|
|
8
9
|
import { buildEveAgentTranscript, capLastUserMessageText, createEmptyEveAgentSession, getEveAgentMessageMetadata, hasPriorEveAgentTurn, normalizeAgentUrl, prewarmExistingEveAgentSession, resolveEveAgentUrl, startOrContinueEveAgentSession, streamEveAgentTurn, } from "../internal/eve-agent";
|
|
@@ -11,7 +12,9 @@ import { isPageVisibleForSurface, } from "../page-visibility";
|
|
|
11
12
|
const DEFAULT_CHAT_MODEL = "openai/gpt-5.6-sol";
|
|
12
13
|
const DEFAULT_MAX_REQUEST_BYTES = 1_000_000;
|
|
13
14
|
const DEFAULT_MAX_MESSAGES = 200;
|
|
15
|
+
const DEFAULT_MAX_MESSAGE_PARTS = 2000;
|
|
14
16
|
const DEFAULT_MAX_PAGE_CONTEXT_CHARS = 200_000;
|
|
17
|
+
const MAX_TOOL_CALL_ID_CHARS = 256;
|
|
15
18
|
const MAX_PAGE_CONTEXT_URL_CHARS = 2048;
|
|
16
19
|
const MAX_CLIENT_CONTEXT_TITLE_CHARS = 256;
|
|
17
20
|
const CONTEXT_INJECTION_MODES = [
|
|
@@ -19,7 +22,6 @@ const CONTEXT_INJECTION_MODES = [
|
|
|
19
22
|
"page-only",
|
|
20
23
|
];
|
|
21
24
|
const MAX_CONTEXT_CHARS = 1500;
|
|
22
|
-
const MAX_EVE_AGENT_MESSAGE_CHARS = 4000;
|
|
23
25
|
const MAX_PROXY_RELATED_PAGES = 5;
|
|
24
26
|
const MAX_TOOL_RESULTS = 8;
|
|
25
27
|
const TRAILING_SLASH_PATTERN = /\/$/;
|
|
@@ -676,6 +678,7 @@ const createChatErrorResponse = (error, status) => new Response(JSON.stringify({
|
|
|
676
678
|
});
|
|
677
679
|
const resolveLimits = (limits) => {
|
|
678
680
|
const resolved = {
|
|
681
|
+
maxMessageParts: limits?.maxMessageParts ?? DEFAULT_MAX_MESSAGE_PARTS,
|
|
679
682
|
maxMessages: limits?.maxMessages ?? DEFAULT_MAX_MESSAGES,
|
|
680
683
|
maxPageContextChars: limits?.maxPageContextChars ?? DEFAULT_MAX_PAGE_CONTEXT_CHARS,
|
|
681
684
|
maxRequestBytes: limits?.maxRequestBytes ?? DEFAULT_MAX_REQUEST_BYTES,
|
|
@@ -785,6 +788,39 @@ const createEveAgentPrewarmResponse = async ({ agentUrl, body, enabled, eveAgent
|
|
|
785
788
|
},
|
|
786
789
|
});
|
|
787
790
|
};
|
|
791
|
+
const isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
792
|
+
const isToolPartType = (type) => type === "dynamic-tool" || type.startsWith("tool-");
|
|
793
|
+
/**
|
|
794
|
+
* Checks the shape of client-sent message history before any conversion.
|
|
795
|
+
* The AI SDK converts every part of every message, so malformed tool parts
|
|
796
|
+
* (for example, a non-string `toolCallId`) or an unbounded number of parts
|
|
797
|
+
* would otherwise cost CPU and memory on the shared server process before
|
|
798
|
+
* the request is rejected.
|
|
799
|
+
*/
|
|
800
|
+
const validateMessageParts = (messages, limits) => {
|
|
801
|
+
let partCount = 0;
|
|
802
|
+
for (const message of messages) {
|
|
803
|
+
if (!(isPlainObject(message) && Array.isArray(message.parts))) {
|
|
804
|
+
return "each message must be an object with a parts array.";
|
|
805
|
+
}
|
|
806
|
+
partCount += message.parts.length;
|
|
807
|
+
if (partCount > limits.maxMessageParts) {
|
|
808
|
+
return `at most ${limits.maxMessageParts} message parts are allowed.`;
|
|
809
|
+
}
|
|
810
|
+
for (const part of message.parts) {
|
|
811
|
+
if (!(isPlainObject(part) && typeof part.type === "string")) {
|
|
812
|
+
return "each message part must be an object with a string type.";
|
|
813
|
+
}
|
|
814
|
+
if (isToolPartType(part.type) &&
|
|
815
|
+
!(typeof part.toolCallId === "string" &&
|
|
816
|
+
part.toolCallId.length > 0 &&
|
|
817
|
+
part.toolCallId.length <= MAX_TOOL_CALL_ID_CHARS)) {
|
|
818
|
+
return `toolCallId must be a non-empty string of at most ${MAX_TOOL_CALL_ID_CHARS} characters.`;
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
return null;
|
|
823
|
+
};
|
|
788
824
|
const parsePageContext = (value, limits) => {
|
|
789
825
|
if (value === undefined || value === null) {
|
|
790
826
|
return { value: undefined };
|
|
@@ -850,6 +886,12 @@ const resolveChatRequestBody = async ({ eveAgent, eveAgentUrl, limits, prewarmEn
|
|
|
850
886
|
response: createChatErrorResponse(`Invalid chat request: at most ${limits.maxMessages} messages are allowed.`, 400),
|
|
851
887
|
};
|
|
852
888
|
}
|
|
889
|
+
const messagesError = validateMessageParts(body.messages, limits);
|
|
890
|
+
if (messagesError) {
|
|
891
|
+
return {
|
|
892
|
+
response: createChatErrorResponse(`Invalid chat request: ${messagesError}`, 400),
|
|
893
|
+
};
|
|
894
|
+
}
|
|
853
895
|
const pageContext = parsePageContext(body.pageContext, limits);
|
|
854
896
|
if ("error" in pageContext) {
|
|
855
897
|
return {
|
|
@@ -925,13 +967,12 @@ const createEveAgentErrorStreamResponse = ({ error, messages, signal, }) => {
|
|
|
925
967
|
return createUIMessageStreamResponse({ stream });
|
|
926
968
|
};
|
|
927
969
|
const createEveAgentResponse = async ({ actualMessages, agentUrl, config, contextInjection, currentRoute, defaultLanguage, eveAgent, filterPage, languages, limits, messages, pageContext, req, routeSources, searchDocuments, sessionCodec, }) => {
|
|
928
|
-
const cappedMessages = capLastUserMessageText(actualMessages, MAX_EVE_AGENT_MESSAGE_CHARS);
|
|
929
970
|
const baseUrl = getSiteBaseUrl(config.siteUrl, req);
|
|
930
971
|
const pageOnly = contextInjection === "page-only";
|
|
931
972
|
const { messages: contextMessages, sourceDocs } = pageOnly
|
|
932
|
-
? { messages:
|
|
973
|
+
? { messages: actualMessages, sourceDocs: [] }
|
|
933
974
|
: await buildProxyMessages({
|
|
934
|
-
actualMessages
|
|
975
|
+
actualMessages,
|
|
935
976
|
config,
|
|
936
977
|
currentRoute,
|
|
937
978
|
defaultLanguage,
|
|
@@ -947,7 +988,7 @@ const createEveAgentResponse = async ({ actualMessages, agentUrl, config, contex
|
|
|
947
988
|
}
|
|
948
989
|
const lastMessageText = getMessageText(lastMessage);
|
|
949
990
|
const { continuation, prewarmed } = resolveEveAgentContinuation({
|
|
950
|
-
messages:
|
|
991
|
+
messages: actualMessages,
|
|
951
992
|
req,
|
|
952
993
|
sessionCodec,
|
|
953
994
|
});
|
|
@@ -1097,7 +1138,7 @@ export const createChatRoute = ({ config, contextInjection = "auto", eveAgent, f
|
|
|
1097
1138
|
return resolvedRequest.response;
|
|
1098
1139
|
}
|
|
1099
1140
|
const { currentRoute, messages, pageContext } = resolvedRequest.body;
|
|
1100
|
-
const actualMessages = messages.filter((message) => !isPageContextMessage(message));
|
|
1141
|
+
const actualMessages = capLastUserMessageText(messages.filter((message) => !isPageContextMessage(message)), MAX_USER_MESSAGE_CHARS);
|
|
1101
1142
|
if (eveAgentUrl) {
|
|
1102
1143
|
return await createEveAgentResponse({
|
|
1103
1144
|
actualMessages,
|
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.
|
|
3
|
+
These docs are bundled with `@vercel/geistdocs` 2.14.4-canary.f3774fa 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.
|
|
3
|
+
These docs are bundled with `@vercel/geistdocs` 2.14.4-canary.f3774fa.
|
|
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
|
|
@@ -1281,19 +1281,6 @@ export const nav = [
|
|
|
1281
1281
|
|
|
1282
1282
|
On desktop, the group opens as a full-width panel below the navbar, following the vercel.com header pattern and matching the OSS products flyout. `section` values become column headings, preserving first-seen order; items without a `section` group into a column headed by the dropdown's own label. In the mobile menu, the group renders as a collapsible section. External URLs open in a new tab and show an external-link arrow.
|
|
1283
1283
|
|
|
1284
|
-
### Rename the search button
|
|
1285
|
-
|
|
1286
|
-
Set `search.buttonLabel` in `defineConfig` to change the text of the search buttons in the navbar, the mobile menu, and the mobile docs sidebar:
|
|
1287
|
-
|
|
1288
|
-
```tsx title="lib/geistdocs/config.tsx"
|
|
1289
|
-
export const config = defineConfig({
|
|
1290
|
-
// ...
|
|
1291
|
-
search: { buttonLabel: "search…" },
|
|
1292
|
-
});
|
|
1293
|
-
```
|
|
1294
|
-
|
|
1295
|
-
Blank values keep the default, "Search…". A `SearchButton` you render yourself takes a `label` prop that overrides the config.
|
|
1296
|
-
|
|
1297
1284
|
## `defineConfig`
|
|
1298
1285
|
|
|
1299
1286
|
`lib/geistdocs/config.tsx` converts your root exports into a package config. Most projects only need the generated defaults:
|
|
@@ -1383,6 +1370,7 @@ The `ai` config also controls the chat panel and its route:
|
|
|
1383
1370
|
| `suggestions` | `(string \| { text: string; icon?: ReactNode })[]` | `[]` | Suggested prompts. The first four distinct prompts are shown, and strings render without an icon. |
|
|
1384
1371
|
| `history.retentionDays` | `number` | `30` | Days a stored conversation is kept after its most recent message. `0` stores no history, and `Infinity` never expires it. |
|
|
1385
1372
|
| `messageFeedback` | `boolean` | `false` | Show thumbs up and thumbs down buttons on finished answers and send votes to the Geistdocs feedback service. |
|
|
1373
|
+
| `share` | `GeistdocsAIShareConfig` | `undefined` | Show a Share chat action backed by your persistence endpoint and public shared-conversation route. |
|
|
1386
1374
|
| `toolLabels` | `Record<string, string>` | `{}` | Activity label shown while a named tool runs, such as `{ web_search: "Searching..." }`. Other tools show `Running <tool name>...`. |
|
|
1387
1375
|
|
|
1388
1376
|
```tsx title="geistdocs.tsx"
|
|
@@ -1391,9 +1379,15 @@ export const ai = {
|
|
|
1391
1379
|
title: "Ask Acme AI",
|
|
1392
1380
|
history: { retentionDays: 7 },
|
|
1393
1381
|
messageFeedback: true,
|
|
1382
|
+
share: {
|
|
1383
|
+
endpoint: "/api/ai-chat/share",
|
|
1384
|
+
path: "/ai-chat",
|
|
1385
|
+
},
|
|
1394
1386
|
};
|
|
1395
1387
|
```
|
|
1396
1388
|
|
|
1389
|
+
The endpoint receives `{ messages, hostPath, summary? }` and must return `{ shareId }`. The public route at `path/<shareId>` must display the saved conversation. Both paths are app-local; Geistdocs adds `basePath` automatically. See [Share a conversation](/docs/ask-ai#share-a-conversation) for the full contract.
|
|
1390
|
+
|
|
1397
1391
|
See [Ask AI](/docs/ask-ai) for the full eve agent mode behavior, including authentication, for moving the chat route adapter when you set `endpoint`, for what a `messageFeedback` vote sends, and for matching a production Vertex or eve setup with `toolLabels` and the server-only `createChatRoute` options. Read [Improve Ask AI answers with Mixedbread](/docs/mixedbread-retrieval) before enabling semantic retrieval.
|
|
1398
1392
|
|
|
1399
1393
|
Use [Versioned docs](/docs/versioned-docs) for versioned source setup and [Proxy and markdown routes](/docs/proxy) for route mappings.
|
|
@@ -4017,9 +4011,25 @@ Once open, users can:
|
|
|
4017
4011
|
- Ask questions about any part of your documentation
|
|
4018
4012
|
- View the documentation pages used as sources for each answer
|
|
4019
4013
|
- Copy an answer as Markdown
|
|
4014
|
+
- Share a conversation with a public link when the site configures chat sharing
|
|
4020
4015
|
- Expand the desktop panel to fill the viewport
|
|
4021
4016
|
- Get step-by-step guidance on complex topics
|
|
4022
4017
|
|
|
4018
|
+
### Share a conversation
|
|
4019
|
+
|
|
4020
|
+
To show **Share chat** in the chat header, set `ai.share` to an app-local POST endpoint and the public route that displays shared conversations:
|
|
4021
|
+
|
|
4022
|
+
```tsx title="geistdocs.tsx"
|
|
4023
|
+
export const ai = {
|
|
4024
|
+
share: {
|
|
4025
|
+
endpoint: "/api/ai-chat/share",
|
|
4026
|
+
path: "/ai-chat",
|
|
4027
|
+
},
|
|
4028
|
+
};
|
|
4029
|
+
```
|
|
4030
|
+
|
|
4031
|
+
Geistdocs sends the endpoint a JSON body with `messages`, `hostPath`, and an optional `summary` containing the first user message. The endpoint must persist the conversation and return `{ "shareId": "..." }`. Geistdocs copies a link to `<path>/<shareId>`; your app must serve that public route and load the saved conversation. The endpoint and path are app-local, and Geistdocs adds `basePath` when needed. Chat sharing is disabled when `ai.share` is unset.
|
|
4032
|
+
|
|
4023
4033
|
## Control Ask AI from your own components
|
|
4024
4034
|
|
|
4025
4035
|
`useGeistdocsChat` from `@vercel/geistdocs/controls` opens, closes, and sends messages to the Ask AI chat from your own client components. Call it from any component rendered inside `GeistdocsProvider`, such as a custom header, a callout, or an MDX component.
|
|
@@ -4607,10 +4617,13 @@ The Vertex route forwards `{ messages, platform: "vercel" }` with the `x-client-
|
|
|
4607
4617
|
| --------------------- | ---------------------------- | ---------------------- |
|
|
4608
4618
|
| `maxRequestBytes` | `1_000_000` bytes (1 MB) | `413` |
|
|
4609
4619
|
| `maxMessages` | `200` messages | `400` |
|
|
4620
|
+
| `maxMessageParts` | `2_000` parts, all messages | `400` |
|
|
4610
4621
|
| `maxPageContextChars` | `200_000` characters | `400` |
|
|
4611
4622
|
|
|
4612
4623
|
Rejected requests receive a JSON body in the form `{ "error": "..." }`. The route reads the request body as a stream and stops as soon as it passes `maxRequestBytes`, and rejects a request whose `Content-Length` header is over the cap without reading the body. An oversized `pageContext.content` is rejected, not truncated.
|
|
4613
4624
|
|
|
4625
|
+
The route also checks the shape of the message history before converting it for the model. Each message needs a `parts` array, each part needs a string `type`, and each tool part (`tool-*` or `dynamic-tool`) needs a `toolCallId` that is a non-empty string of at most 256 characters. Other requests receive `400`.
|
|
4626
|
+
|
|
4614
4627
|
`maxPageContextChars` only rejects `pageContext.content` that API callers send with the page text. The Ask AI client sends `pageContext: { url }` without content, and the route reads that page from the site's own sources; with `contextInjection: "page-only"`, that page's Markdown is truncated to `maxPageContextChars` before it is forwarded. `pageContext.url` must be a non-empty string of at most 2,048 characters in both shapes; other values receive `400`.
|
|
4615
4628
|
|
|
4616
4629
|
Change the limits with the `limits` option:
|
|
@@ -4622,6 +4635,7 @@ export const { POST, maxDuration } = createChatRoute({
|
|
|
4622
4635
|
limits: {
|
|
4623
4636
|
maxRequestBytes: 500_000,
|
|
4624
4637
|
maxMessages: 100,
|
|
4638
|
+
maxMessageParts: 1_000,
|
|
4625
4639
|
maxPageContextChars: 100_000,
|
|
4626
4640
|
},
|
|
4627
4641
|
});
|
package/docs/manifest.json
CHANGED
package/docs/pages/ask-ai.md
CHANGED
|
@@ -52,9 +52,25 @@ Once open, users can:
|
|
|
52
52
|
- Ask questions about any part of your documentation
|
|
53
53
|
- View the documentation pages used as sources for each answer
|
|
54
54
|
- Copy an answer as Markdown
|
|
55
|
+
- Share a conversation with a public link when the site configures chat sharing
|
|
55
56
|
- Expand the desktop panel to fill the viewport
|
|
56
57
|
- Get step-by-step guidance on complex topics
|
|
57
58
|
|
|
59
|
+
### Share a conversation
|
|
60
|
+
|
|
61
|
+
To show **Share chat** in the chat header, set `ai.share` to an app-local POST endpoint and the public route that displays shared conversations:
|
|
62
|
+
|
|
63
|
+
```tsx title="geistdocs.tsx"
|
|
64
|
+
export const ai = {
|
|
65
|
+
share: {
|
|
66
|
+
endpoint: "/api/ai-chat/share",
|
|
67
|
+
path: "/ai-chat",
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Geistdocs sends the endpoint a JSON body with `messages`, `hostPath`, and an optional `summary` containing the first user message. The endpoint must persist the conversation and return `{ "shareId": "..." }`. Geistdocs copies a link to `<path>/<shareId>`; your app must serve that public route and load the saved conversation. The endpoint and path are app-local, and Geistdocs adds `basePath` when needed. Chat sharing is disabled when `ai.share` is unset.
|
|
73
|
+
|
|
58
74
|
## Control Ask AI from your own components
|
|
59
75
|
|
|
60
76
|
`useGeistdocsChat` from `@vercel/geistdocs/controls` opens, closes, and sends messages to the Ask AI chat from your own client components. Call it from any component rendered inside `GeistdocsProvider`, such as a custom header, a callout, or an MDX component.
|
|
@@ -642,10 +658,13 @@ The Vertex route forwards `{ messages, platform: "vercel" }` with the `x-client-
|
|
|
642
658
|
| --------------------- | ---------------------------- | ---------------------- |
|
|
643
659
|
| `maxRequestBytes` | `1_000_000` bytes (1 MB) | `413` |
|
|
644
660
|
| `maxMessages` | `200` messages | `400` |
|
|
661
|
+
| `maxMessageParts` | `2_000` parts, all messages | `400` |
|
|
645
662
|
| `maxPageContextChars` | `200_000` characters | `400` |
|
|
646
663
|
|
|
647
664
|
Rejected requests receive a JSON body in the form `{ "error": "..." }`. The route reads the request body as a stream and stops as soon as it passes `maxRequestBytes`, and rejects a request whose `Content-Length` header is over the cap without reading the body. An oversized `pageContext.content` is rejected, not truncated.
|
|
648
665
|
|
|
666
|
+
The route also checks the shape of the message history before converting it for the model. Each message needs a `parts` array, each part needs a string `type`, and each tool part (`tool-*` or `dynamic-tool`) needs a `toolCallId` that is a non-empty string of at most 256 characters. Other requests receive `400`.
|
|
667
|
+
|
|
649
668
|
`maxPageContextChars` only rejects `pageContext.content` that API callers send with the page text. The Ask AI client sends `pageContext: { url }` without content, and the route reads that page from the site's own sources; with `contextInjection: "page-only"`, that page's Markdown is truncated to `maxPageContextChars` before it is forwarded. `pageContext.url` must be a non-empty string of at most 2,048 characters in both shapes; other values receive `400`.
|
|
650
669
|
|
|
651
670
|
Change the limits with the `limits` option:
|
|
@@ -657,6 +676,7 @@ export const { POST, maxDuration } = createChatRoute({
|
|
|
657
676
|
limits: {
|
|
658
677
|
maxRequestBytes: 500_000,
|
|
659
678
|
maxMessages: 100,
|
|
679
|
+
maxMessageParts: 1_000,
|
|
660
680
|
maxPageContextChars: 100_000,
|
|
661
681
|
},
|
|
662
682
|
});
|
|
@@ -142,19 +142,6 @@ export const nav = [
|
|
|
142
142
|
|
|
143
143
|
On desktop, the group opens as a full-width panel below the navbar, following the vercel.com header pattern and matching the OSS products flyout. `section` values become column headings, preserving first-seen order; items without a `section` group into a column headed by the dropdown's own label. In the mobile menu, the group renders as a collapsible section. External URLs open in a new tab and show an external-link arrow.
|
|
144
144
|
|
|
145
|
-
### Rename the search button
|
|
146
|
-
|
|
147
|
-
Set `search.buttonLabel` in `defineConfig` to change the text of the search buttons in the navbar, the mobile menu, and the mobile docs sidebar:
|
|
148
|
-
|
|
149
|
-
```tsx title="lib/geistdocs/config.tsx"
|
|
150
|
-
export const config = defineConfig({
|
|
151
|
-
// ...
|
|
152
|
-
search: { buttonLabel: "search…" },
|
|
153
|
-
});
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
Blank values keep the default, "Search…". A `SearchButton` you render yourself takes a `label` prop that overrides the config.
|
|
157
|
-
|
|
158
145
|
## `defineConfig`
|
|
159
146
|
|
|
160
147
|
`lib/geistdocs/config.tsx` converts your root exports into a package config. Most projects only need the generated defaults:
|
|
@@ -244,6 +231,7 @@ The `ai` config also controls the chat panel and its route:
|
|
|
244
231
|
| `suggestions` | `(string \| { text: string; icon?: ReactNode })[]` | `[]` | Suggested prompts. The first four distinct prompts are shown, and strings render without an icon. |
|
|
245
232
|
| `history.retentionDays` | `number` | `30` | Days a stored conversation is kept after its most recent message. `0` stores no history, and `Infinity` never expires it. |
|
|
246
233
|
| `messageFeedback` | `boolean` | `false` | Show thumbs up and thumbs down buttons on finished answers and send votes to the Geistdocs feedback service. |
|
|
234
|
+
| `share` | `GeistdocsAIShareConfig` | `undefined` | Show a Share chat action backed by your persistence endpoint and public shared-conversation route. |
|
|
247
235
|
| `toolLabels` | `Record<string, string>` | `{}` | Activity label shown while a named tool runs, such as `{ web_search: "Searching..." }`. Other tools show `Running <tool name>...`. |
|
|
248
236
|
|
|
249
237
|
```tsx title="geistdocs.tsx"
|
|
@@ -252,9 +240,15 @@ export const ai = {
|
|
|
252
240
|
title: "Ask Acme AI",
|
|
253
241
|
history: { retentionDays: 7 },
|
|
254
242
|
messageFeedback: true,
|
|
243
|
+
share: {
|
|
244
|
+
endpoint: "/api/ai-chat/share",
|
|
245
|
+
path: "/ai-chat",
|
|
246
|
+
},
|
|
255
247
|
};
|
|
256
248
|
```
|
|
257
249
|
|
|
250
|
+
The endpoint receives `{ messages, hostPath, summary? }` and must return `{ shareId }`. The public route at `path/<shareId>` must display the saved conversation. Both paths are app-local; Geistdocs adds `basePath` automatically. See [Share a conversation](/docs/ask-ai#share-a-conversation) for the full contract.
|
|
251
|
+
|
|
258
252
|
See [Ask AI](/docs/ask-ai) for the full eve agent mode behavior, including authentication, for moving the chat route adapter when you set `endpoint`, for what a `messageFeedback` vote sends, and for matching a production Vertex or eve setup with `toolLabels` and the server-only `createChatRoute` options. Read [Improve Ask AI answers with Mixedbread](/docs/mixedbread-retrieval) before enabling semantic retrieval.
|
|
259
253
|
|
|
260
254
|
Use [Versioned docs](/docs/versioned-docs) for versioned source setup and [Proxy and markdown routes](/docs/proxy) for route mappings.
|
package/package.json
CHANGED
|
@@ -499,10 +499,13 @@ export const ai = {
|
|
|
499
499
|
| --------------------- | ------------------------ | ------------ |
|
|
500
500
|
| `maxRequestBytes` | `1_000_000` 字节(1 MB) | `413` |
|
|
501
501
|
| `maxMessages` | `200` 条消息 | `400` |
|
|
502
|
+
| `maxMessageParts` | 所有消息共 `2_000` 个部分 | `400` |
|
|
502
503
|
| `maxPageContextChars` | `200_000` 个字符 | `400` |
|
|
503
504
|
|
|
504
505
|
被拒绝的请求会收到 `{ "error": "..." }` 格式的 JSON 响应。过长的 `pageContext.content` 会被拒绝,而不是被截断。
|
|
505
506
|
|
|
507
|
+
路由还会在为模型转换消息历史之前检查其结构。每条消息都必须包含 `parts` 数组,每个部分都必须有字符串类型的 `type`,每个工具部分(`tool-*` 或 `dynamic-tool`)的 `toolCallId` 都必须是最多 256 个字符的非空字符串,否则返回 `400`。
|
|
508
|
+
|
|
506
509
|
`maxPageContextChars` 只会拒绝 API 调用方随页面文本一起发送的 `pageContext.content`。Ask AI 客户端发送不含内容的 `pageContext: { url }`,路由会从站点自身的来源读取该页面;使用 `contextInjection: "page-only"` 时,该页面的 Markdown 会在转发前截断到 `maxPageContextChars`。两种形式中的 `pageContext.url` 都必须是最多 2,048 个字符的非空字符串,否则返回 `400`。
|
|
507
510
|
|
|
508
511
|
使用 `limits` 选项修改这些限制:
|
|
@@ -514,6 +517,7 @@ export const { POST, maxDuration } = createChatRoute({
|
|
|
514
517
|
limits: {
|
|
515
518
|
maxRequestBytes: 500_000,
|
|
516
519
|
maxMessages: 100,
|
|
520
|
+
maxMessageParts: 1_000,
|
|
517
521
|
maxPageContextChars: 100_000,
|
|
518
522
|
},
|
|
519
523
|
});
|
|
@@ -50,9 +50,25 @@ Once open, users can:
|
|
|
50
50
|
- Ask questions about any part of your documentation
|
|
51
51
|
- View the documentation pages used as sources for each answer
|
|
52
52
|
- Copy an answer as Markdown
|
|
53
|
+
- Share a conversation with a public link when the site configures chat sharing
|
|
53
54
|
- Expand the desktop panel to fill the viewport
|
|
54
55
|
- Get step-by-step guidance on complex topics
|
|
55
56
|
|
|
57
|
+
### Share a conversation
|
|
58
|
+
|
|
59
|
+
To show **Share chat** in the chat header, set `ai.share` to an app-local POST endpoint and the public route that displays shared conversations:
|
|
60
|
+
|
|
61
|
+
```tsx title="geistdocs.tsx"
|
|
62
|
+
export const ai = {
|
|
63
|
+
share: {
|
|
64
|
+
endpoint: "/api/ai-chat/share",
|
|
65
|
+
path: "/ai-chat",
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Geistdocs sends the endpoint a JSON body with `messages`, `hostPath`, and an optional `summary` containing the first user message. The endpoint must persist the conversation and return `{ "shareId": "..." }`. Geistdocs copies a link to `<path>/<shareId>`; your app must serve that public route and load the saved conversation. The endpoint and path are app-local, and Geistdocs adds `basePath` when needed. Chat sharing is disabled when `ai.share` is unset.
|
|
71
|
+
|
|
56
72
|
## Control Ask AI from your own components
|
|
57
73
|
|
|
58
74
|
`useGeistdocsChat` from `@vercel/geistdocs/controls` opens, closes, and sends messages to the Ask AI chat from your own client components. Call it from any component rendered inside `GeistdocsProvider`, such as a custom header, a callout, or an MDX component.
|
|
@@ -640,10 +656,13 @@ The Vertex route forwards `{ messages, platform: "vercel" }` with the `x-client-
|
|
|
640
656
|
| --------------------- | ---------------------------- | ---------------------- |
|
|
641
657
|
| `maxRequestBytes` | `1_000_000` bytes (1 MB) | `413` |
|
|
642
658
|
| `maxMessages` | `200` messages | `400` |
|
|
659
|
+
| `maxMessageParts` | `2_000` parts, all messages | `400` |
|
|
643
660
|
| `maxPageContextChars` | `200_000` characters | `400` |
|
|
644
661
|
|
|
645
662
|
Rejected requests receive a JSON body in the form `{ "error": "..." }`. The route reads the request body as a stream and stops as soon as it passes `maxRequestBytes`, and rejects a request whose `Content-Length` header is over the cap without reading the body. An oversized `pageContext.content` is rejected, not truncated.
|
|
646
663
|
|
|
664
|
+
The route also checks the shape of the message history before converting it for the model. Each message needs a `parts` array, each part needs a string `type`, and each tool part (`tool-*` or `dynamic-tool`) needs a `toolCallId` that is a non-empty string of at most 256 characters. Other requests receive `400`.
|
|
665
|
+
|
|
647
666
|
`maxPageContextChars` only rejects `pageContext.content` that API callers send with the page text. The Ask AI client sends `pageContext: { url }` without content, and the route reads that page from the site's own sources; with `contextInjection: "page-only"`, that page's Markdown is truncated to `maxPageContextChars` before it is forwarded. `pageContext.url` must be a non-empty string of at most 2,048 characters in both shapes; other values receive `400`.
|
|
648
667
|
|
|
649
668
|
Change the limits with the `limits` option:
|
|
@@ -655,6 +674,7 @@ export const { POST, maxDuration } = createChatRoute({
|
|
|
655
674
|
limits: {
|
|
656
675
|
maxRequestBytes: 500_000,
|
|
657
676
|
maxMessages: 100,
|
|
677
|
+
maxMessageParts: 1_000,
|
|
658
678
|
maxPageContextChars: 100_000,
|
|
659
679
|
},
|
|
660
680
|
});
|
|
@@ -140,19 +140,6 @@ export const nav = [
|
|
|
140
140
|
|
|
141
141
|
On desktop, the group opens as a full-width panel below the navbar, following the vercel.com header pattern and matching the OSS products flyout. `section` values become column headings, preserving first-seen order; items without a `section` group into a column headed by the dropdown's own label. In the mobile menu, the group renders as a collapsible section. External URLs open in a new tab and show an external-link arrow.
|
|
142
142
|
|
|
143
|
-
### Rename the search button
|
|
144
|
-
|
|
145
|
-
Set `search.buttonLabel` in `defineConfig` to change the text of the search buttons in the navbar, the mobile menu, and the mobile docs sidebar:
|
|
146
|
-
|
|
147
|
-
```tsx title="lib/geistdocs/config.tsx"
|
|
148
|
-
export const config = defineConfig({
|
|
149
|
-
// ...
|
|
150
|
-
search: { buttonLabel: "search…" },
|
|
151
|
-
});
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
Blank values keep the default, "Search…". A `SearchButton` you render yourself takes a `label` prop that overrides the config.
|
|
155
|
-
|
|
156
143
|
## `defineConfig`
|
|
157
144
|
|
|
158
145
|
`lib/geistdocs/config.tsx` converts your root exports into a package config. Most projects only need the generated defaults:
|
|
@@ -242,6 +229,7 @@ The `ai` config also controls the chat panel and its route:
|
|
|
242
229
|
| `suggestions` | `(string \| { text: string; icon?: ReactNode })[]` | `[]` | Suggested prompts. The first four distinct prompts are shown, and strings render without an icon. |
|
|
243
230
|
| `history.retentionDays` | `number` | `30` | Days a stored conversation is kept after its most recent message. `0` stores no history, and `Infinity` never expires it. |
|
|
244
231
|
| `messageFeedback` | `boolean` | `false` | Show thumbs up and thumbs down buttons on finished answers and send votes to the Geistdocs feedback service. |
|
|
232
|
+
| `share` | `GeistdocsAIShareConfig` | `undefined` | Show a Share chat action backed by your persistence endpoint and public shared-conversation route. |
|
|
245
233
|
| `toolLabels` | `Record<string, string>` | `{}` | Activity label shown while a named tool runs, such as `{ web_search: "Searching..." }`. Other tools show `Running <tool name>...`. |
|
|
246
234
|
|
|
247
235
|
```tsx title="geistdocs.tsx"
|
|
@@ -250,9 +238,15 @@ export const ai = {
|
|
|
250
238
|
title: "Ask Acme AI",
|
|
251
239
|
history: { retentionDays: 7 },
|
|
252
240
|
messageFeedback: true,
|
|
241
|
+
share: {
|
|
242
|
+
endpoint: "/api/ai-chat/share",
|
|
243
|
+
path: "/ai-chat",
|
|
244
|
+
},
|
|
253
245
|
};
|
|
254
246
|
```
|
|
255
247
|
|
|
248
|
+
The endpoint receives `{ messages, hostPath, summary? }` and must return `{ shareId }`. The public route at `path/<shareId>` must display the saved conversation. Both paths are app-local; Geistdocs adds `basePath` automatically. See [Share a conversation](/docs/ask-ai#share-a-conversation) for the full contract.
|
|
249
|
+
|
|
256
250
|
See [Ask AI](/docs/ask-ai) for the full eve agent mode behavior, including authentication, for moving the chat route adapter when you set `endpoint`, for what a `messageFeedback` vote sends, and for matching a production Vertex or eve setup with `toolLabels` and the server-only `createChatRoute` options. Read [Improve Ask AI answers with Mixedbread](/docs/mixedbread-retrieval) before enabling semantic retrieval.
|
|
257
251
|
|
|
258
252
|
Use [Versioned docs](/docs/versioned-docs) for versioned source setup and [Proxy and markdown routes](/docs/proxy) for route mappings.
|
package/template/package.json
CHANGED
|
@@ -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.
|
|
20
|
+
"@vercel/geistdocs": "2.14.4-canary.f3774fa",
|
|
21
21
|
"@vercel/speed-insights": "^1.3.1",
|
|
22
22
|
"ai": "^6.0.132",
|
|
23
23
|
"clsx": "^2.1.1",
|