PageSourceSearch

https://berrydesk.com/assets/dashboard._workspaceId.agent-builder-Crx80a1o.js

js berrydesk.com collected 2026-10-02 00:47:41 UTC 10,169 bytes, 1 lines download raw bytes

1import{r as l,j as e}from"./react-vendor-R5HqukZ7.js";import{bk as O,u as Q,S as U,H as a,bj as T,bl as X,aL as H,I as z,bm as ee,B as $,ak as se,C as y,g as v,aZ as te,h as b,k as w,bn as h,aN as D,bo as ae,aH as K}from"./main-Ccz3IRrk.js";import{e as re,b as S,a as _}from"./convex-BevPdSW0.js";import{S as ne}from"./scroll-area-2Fobw4tZ.js";import{M as ie}from"./markdown-XSeC9ks-.js";import"./motion-Pabu1yrW.js";function le(r){const t=r.filter(c=>c.type==="set_persona");return t.length===0?null:t.reduce((c,d)=>({...c,...d.data}),{})}function ce(r){return r.filter(t=>t.type==="create_playbook").map(t=>t.data)}function oe(r){return r.filter(t=>t.type==="create_rule").map(t=>t.data)}function de(r){return r.filter(t=>t.type==="add_knowledge_url").map(t=>t.data)}const xe={role:"assistant",content:"Hi! I'm here to help you create an AI agent. Let's start — what does your business do?"};function je(){const{workspaceId:r}=O.useParams(),t=Q(),{toast:c}=U(),[d,k]=l.useState([xe]),[u,F]=l.useState([]),[p,W]=l.useState(""),[x,R]=l.useState(!1),[A,E]=l.useState(!1),g=l.useRef(null),L=l.useRef(null),P=re(S.agentBuilder.chat),G=_(S.agents.create),J=_(S.agentBuilder.applyActions),i=le(u),f=ce(u),j=oe(u),N=de(u),M=i?.name||"",C=!!i;l.useEffect(()=>{g.current&&(g.current.scrollTop=g.current.scrollHeight)},[d,x]);const B=l.useCallback(async()=>{const s=p.trim();if(!s||x)return;const n={role:"user",content:s},q=[...d,n];k(q),W(""),R(!0);try{const m=await P({workspaceId:r,message:s,conversationHistory:d.map(o=>({role:o.role,content:o.content}))}),I={role:"assistant",content:m.response};k(o=>[...o,I]),m.actions&&Array.isArray(m.actions)&&m.actions.length>0&&F(o=>[...o,...m.actions])}catch(m){console.error("Agent builder chat error:",m);const I={role:"assistant",content:"Sorry, something went wrong. Could you try rephrasing your last message?"};k(o=>[...o,I]),c({title:"Error",description:"Failed to get a response. Please try again.",variant:"destructive"})}finally{R(!1)}},[p,x,d,P,r,c]),V=s=>{s.preventDefault(),B()},Y=s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),B())},Z=async()=>{if(!(!C||A)){E(!0);try{const s=await G({workspaceId:r,name:M||"New Agent"});u.length>0&&await J({agentId:s,actions:u.map(n=>({type:n.type,data:n.data}))}),c({title:"Agent created",description:`"${M||"New Agent"}" is ready to configure.`}),t({to:"/dashboard/$workspaceId/agent/$agentId",params:{workspaceId:r,agentId:s}})}catch(s){console.error("Failed to create agent:",s),c({title:"Error",description:"Failed to create agent. Please try again.",variant:"destructive"})}finally{E(!1)}}};return e.jsxs("div",{className:"flex h-[calc(100vh-4rem)] overflow-hidden",children:[e.jsxs("div",{className:"flex w-[60%] flex-col border-r",children:[e.jsxs("div",{className:"flex items-center gap-3 border-b px-6 py-4",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-primary/10",children:e.jsx(a,{icon:T,size:18,strokeWidth:2,className:"text-primary"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:"AI Agent Builder"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Describe your business and I will configure your agent"})]})]}),e.jsxs("div",{ref:g,className:"flex-1 overflow-y-auto px-6 py-4 space-y-4",children:[d.map((s,n)=>e.jsx("div",{className:`flex ${s.role==="user"?"justify-end":"justify-start"}`,children:e.jsxs("div",{className:`flex max-w-[80%] gap-3 ${s.role==="user"?"flex-row-reverse":"flex-row"}`,children:[e.jsx("div",{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full ${s.role==="user"?"bg-primary text-primary-foreground":"bg-muted"}`,children:e.jsx(a,{icon:s.role==="user"?X:H,size:16,strokeWidth:2})}),e.jsx("div",{className:`rounded-2xl px-4 py-3 text-sm leading-relaxed ${s.role==="user"?"bg-primary text-primary-foreground":"bg-muted"}`,children:s.role==="assistant"?e.jsx(ie,{className:"prose prose-sm dark:prose-invert max-w-none [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",children:s.content}):e.jsx("span",{className:"whitespace-pre-wrap",children:s.content})})]})}
1,n)),x&&e.jsx("div",{className:"flex justify-start",children:e.jsxs("div",{className:"flex max-w-[80%] gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-muted",children:e.jsx(a,{icon:H,size:16,strokeWidth:2})}),e.jsxs("div",{className:"flex items-center gap-2 rounded-2xl bg-muted px-4 py-3 text-sm text-muted-foreground",children:[e.jsx(a,{icon:z,size:16,strokeWidth:2,className:"animate-spin"}),e.jsx("span",{children:"Thinking..."})]})]})})]}),e.jsxs("div",{className:"border-t px-6 py-4",children:[e.jsxs("form",{onSubmit:V,className:"flex items-end gap-3",children:[e.jsx(ee,{ref:L,value:p,onChange:s=>W(s.target.value),onKeyDown:Y,placeholder:"Describe your business, goals, or how you want your agent to behave...",className:"min-h-[44px] max-h-[160px] resize-none",rows:1,disabled:x}),e.jsx($,{type:"submit",size:"icon",disabled:x||!p.trim(),className:"shrink-0",children:x?e.jsx(a,{icon:z,size:18,strokeWidth:2,className:"animate-spin"}):e.jsx(a,{icon:se,size:18,strokeWidth:2})})]}),e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"Press Enter to send, Shift+Enter for a new line"})]})]}),e.jsxs("div",{className:"flex w-[40%] flex-col bg-muted/30",children:[e.jsx("div",{className:"flex items-center justify-between border-b px-6 py-4",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Agent Preview"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Configuration builds as you chat"})]})}),e.jsx(ne,{className:"flex-1",children:e.jsxs("div",{className:"space-y-4 p-6",children:[e.jsxs(y,{children:[e.jsx(v,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a,{icon:te,size:16,strokeWidth:2,className:"text-primary"}),e.jsx(b,{className:"text-sm",children:"Persona"})]})}),e.jsx(w,{children:i?e.jsxs("div",{className:"space-y-2",children:[i.name&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Name"}),e.jsx("span",{className:"text-sm font-medium",children:i.name})]}),i.role&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Role"}),e.jsx("span",{className:"text-sm",children:i.role})]}),i.goal&&e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Goal"}),e.jsx("p",{className:"mt-1 text-sm",children:i.goal})]}),i.tone&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Tone"}),e.jsx(h,{variant:"secondary",className:"text-xs",children:i.tone})]})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Not configured yet"})})]}),e.jsxs(y,{children:[e.jsx(v,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a,{icon:D,size:16,strokeWidth:2,className:"text-primary"}),e.jsx(b,{className:"text-sm",children:"Journeys"}),f.length>0&&e.jsx(h,{variant:"secondary",className:"ml-auto text-xs",children:f.length})]})}),e.jsx(w,{children:f.length>0?e.jsx("div",{className:"space-y-2",children:f.map((s,n)=>e.jsxs("div",{className:"flex items-center gap-2 rounded-md border px-3 py-2",children:[e.jsx(a,{icon:D,size:14,strokeWidth:2,className:"shrink-0 text-muted-foreground"}),e.jsx("span",{className:"text-sm",children:s.title})]},n))}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Not configured yet"})})]}),e.jsxs(y,{children:[e.jsx(v,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a,{icon:ae,size:16,strokeWidth:2,className:"text-primary"}),e.jsx(b,{className:"text-sm",children:"Rules"}),j.length>0&&e.jsx(h,{variant:"secondary",className:"ml-auto text-xs",children:j.length})]})}),e.jsx(w,{children:j.length>0?e.jsx("div",{className:"space-y-2",children:j.map((s,n)=>e.jsxs("div",{className:"rounded-md border p-3 space-y-1",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(h,{variant:"outline",className:"shrink-0 text-[10px] uppercase tracking-wider",children:"When"}),e.jsx("span",{className:"text-sm",children:s.when})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(h,{variant:"outline",className:"shrink-0 text-[10px] uppercase tracking-wider",children:"The
1n"}),e.jsx("span",{className:"text-sm",children:s.then})]})]},n))}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Not configured yet"})})]}),e.jsxs(y,{children:[e.jsx(v,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a,{icon:K,size:16,strokeWidth:2,className:"text-primary"}),e.jsx(b,{className:"text-sm",children:"Knowledge"}),N.length>0&&e.jsx(h,{variant:"secondary",className:"ml-auto text-xs",children:N.length})]})}),e.jsx(w,{children:N.length>0?e.jsx("div",{className:"space-y-2",children:N.map((s,n)=>e.jsxs("div",{className:"flex items-center gap-2 rounded-md border px-3 py-2",children:[e.jsx(a,{icon:K,size:14,strokeWidth:2,className:"shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0",children:[s.title&&e.jsx("span",{className:"block text-sm font-medium truncate",children:s.title}),e.jsx("span",{className:"block text-xs text-muted-foreground truncate",children:s.url})]})]},n))}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Not configured yet"})})]})]})}),e.jsxs("div",{className:"border-t p-6",children:[e.jsx($,{className:"w-full",size:"lg",disabled:!C||A,onClick:Z,children:A?e.jsxs(e.Fragment,{children:[e.jsx(a,{icon:z,size:16,strokeWidth:2,className:"mr-2 animate-spin"}),"Creating Agent..."]}):e.jsxs(e.Fragment,{children:[e.jsx(a,{icon:T,size:16,strokeWidth:2,className:"mr-2"}),"Create Agent"]})}),!C&&e.jsx("p",{className:"mt-2 text-center text-xs text-muted-foreground",children:"Chat with the builder to configure your agent's persona first"})]})]})]})}export{je as component};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.