khoj 1.36.6.dev5__py3-none-any.whl → 1.36.6.dev8__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. khoj/app/settings.py +3 -2
  2. khoj/interface/compiled/404/index.html +2 -2
  3. khoj/interface/compiled/_next/static/chunks/{2327-36d17f2483e80f60.js → 2327-02e86a50c65e575a.js} +1 -1
  4. khoj/interface/compiled/_next/static/chunks/{5477-8c08e1b401f43d23.js → 5477-7417eeee06ac7e61.js} +1 -1
  5. khoj/interface/compiled/_next/static/chunks/{8155-87b4d2ea2cf725cc.js → 8155-ad130153ddcc930f.js} +1 -1
  6. khoj/interface/compiled/_next/static/chunks/app/agents/{page-fbe2c1c661cd14ac.js → page-2f55f9d0da49bf31.js} +1 -1
  7. khoj/interface/compiled/_next/static/chunks/app/automations/{page-ad620b194fd508fe.js → page-d0a630a2b4ecc41d.js} +1 -1
  8. khoj/interface/compiled/_next/static/chunks/app/chat/{page-4108f46796c1c606.js → page-53ba9f1424043383.js} +1 -1
  9. khoj/interface/compiled/_next/static/chunks/app/{page-f91e6a6a849baf5e.js → page-642bd02fc4f16606.js} +1 -1
  10. khoj/interface/compiled/_next/static/chunks/app/search/{layout-ab5dbb69fb914900.js → layout-ff081947c70ea9b7.js} +1 -1
  11. khoj/interface/compiled/_next/static/chunks/app/search/{page-30e231665f1f3796.js → page-7c80e369ee1cdfad.js} +1 -1
  12. khoj/interface/compiled/_next/static/chunks/app/settings/{page-924a7308250ed0eb.js → page-9939a20613b25901.js} +1 -1
  13. khoj/interface/compiled/_next/static/chunks/app/share/chat/{layout-2ce0cb95b1219d97.js → layout-94a33aa0eae034fc.js} +1 -1
  14. khoj/interface/compiled/_next/static/chunks/app/share/chat/{page-ffcb3ce5c6af9988.js → page-6253896a84300e9b.js} +1 -1
  15. khoj/interface/compiled/_next/static/chunks/{webpack-79b7e98c584222f7.js → webpack-d605f0467a332031.js} +1 -1
  16. khoj/interface/compiled/_next/static/css/55d4a822f8d94b67.css +1 -0
  17. khoj/interface/compiled/_next/static/css/{8051073dc55b92b3.css → 804ceddd6c935d4a.css} +1 -1
  18. khoj/interface/compiled/agents/index.html +2 -2
  19. khoj/interface/compiled/agents/index.txt +2 -2
  20. khoj/interface/compiled/automations/index.html +2 -2
  21. khoj/interface/compiled/automations/index.txt +2 -2
  22. khoj/interface/compiled/chat/index.html +2 -2
  23. khoj/interface/compiled/chat/index.txt +2 -2
  24. khoj/interface/compiled/index.html +2 -2
  25. khoj/interface/compiled/index.txt +2 -2
  26. khoj/interface/compiled/search/index.html +2 -2
  27. khoj/interface/compiled/search/index.txt +3 -3
  28. khoj/interface/compiled/settings/index.html +2 -2
  29. khoj/interface/compiled/settings/index.txt +2 -2
  30. khoj/interface/compiled/share/chat/index.html +2 -2
  31. khoj/interface/compiled/share/chat/index.txt +3 -3
  32. khoj/routers/helpers.py +4 -0
  33. khoj/routers/research.py +5 -0
  34. {khoj-1.36.6.dev5.dist-info → khoj-1.36.6.dev8.dist-info}/METADATA +1 -1
  35. {khoj-1.36.6.dev5.dist-info → khoj-1.36.6.dev8.dist-info}/RECORD +40 -40
  36. khoj/interface/compiled/_next/static/css/f29752d6e1be7624.css +0 -1
  37. /khoj/interface/compiled/_next/static/{mj3LRaTV49NoToQFKNZbZ → BY2zqRvbb80d6NZZlApxn}/_buildManifest.js +0 -0
  38. /khoj/interface/compiled/_next/static/{mj3LRaTV49NoToQFKNZbZ → BY2zqRvbb80d6NZZlApxn}/_ssgManifest.js +0 -0
  39. {khoj-1.36.6.dev5.dist-info → khoj-1.36.6.dev8.dist-info}/WHEEL +0 -0
  40. {khoj-1.36.6.dev5.dist-info → khoj-1.36.6.dev8.dist-info}/entry_points.txt +0 -0
  41. {khoj-1.36.6.dev5.dist-info → khoj-1.36.6.dev8.dist-info}/licenses/LICENSE +0 -0
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5477],{5477:function(e,t,a){"use strict";a.d(t,{$:function(){return r},a:function(){return O}});var s,r,n=a(57437),l=a(26442),o=a.n(l),i=a(2265),c=a(18848);a(2446);var d=a(12144),u=a(10107),h=a(19715),f=a(35849),g=a(4203),x=a(51549),m=a(62340),p=a(23518),j=a(37099),b=a(62869),v=a(32759),w=a(57054),y=a(27312),N=a(76818),k=a(81103),C=a(84671),E=a(33494),D=a(14308),S=a(42225),M=a(59199),R=a(7436),T=a(26110),z=a(19378);(s=r||(r={})).MESSAGE="message",s.FILE="file",s.RESEARCH="research";let O=(0,i.forwardRef)((e,t)=>{let[a,s]=(0,i.useState)(""),r=(0,i.useRef)(null),l=(0,i.useRef)(null),O=(0,i.useRef)(null),[A,I]=(0,i.useState)(null),[L,_]=(0,i.useState)(null),[P,F]=(0,i.useState)(!1),[W,U]=(0,i.useState)(null),[$,H]=(0,i.useState)(!1),[J,B]=(0,i.useState)(!1),[K,Y]=(0,i.useState)([]),[Z,X]=(0,i.useState)([]),[q,G]=(0,i.useState)(null),[V,Q]=(0,i.useState)([]),[ee,et]=(0,i.useState)(!1),[ea,es]=(0,i.useState)(null),[er,en]=(0,i.useState)(0),[el,eo]=(0,i.useState)(!1),[ei,ec]=(0,i.useState)(!1),[ed,eu]=(0,i.useState)(e.isResearchModeEnabled||!1);function eh(){if(J&&(B(!1),Y([]),Z.forEach(t=>e.sendImage(t))),!a.trim())return;if(!e.isLoggedIn){U("Hey there, you need to be signed in to send messages to Khoj AI"),H(!0);return}let t=a.trim(),r=e.chatOptionsData&&Object.keys(e.chatOptionsData).some(e=>t.startsWith("/".concat(e)));ed&&!r&&(t="/research ".concat(t)),e.sendMessage(t),G(null),Q([]),s("")}function ef(a){var s,r;if(!e.isLoggedIn){U("Please login to chat with your files"),H(!0);return}let n=["jpg","jpeg","png","webp"],l=[];for(let e=0;e<a.length;e++){let t=a[e],s=t.name.split(".").pop();n.includes(s||"")&&l.push(c.Z.sanitize(URL.createObjectURL(t)))}l.length>0&&(B(!0),Y(e=>[...e,...l]),null==t||null===(r=t.current)||void 0===r||r.focus());let o=Array.from(a).filter(e=>!n.includes(e.name.split(".").pop()||"")),i=o?Array.from(o).concat(Array.from(q||[])):Array.from(q||[]);if(i.length>0){for(let e=0;e<i.length;e++)if(i[e].size>10485760){I("File ".concat(i[e].name," is too large. Please upload files smaller than 10 MB."));return}let t=new DataTransfer;i.forEach(e=>t.items.add(e)),eg(t.files).then(a=>{e.setUploadedFiles(a),G(t.files),Q(a)})}null==t||null===(s=t.current)||void 0===s||s.focus()}async function eg(e){let t=await (0,M.M1)(e);F(!0);try{let e=await fetch("/api/content/convert",{method:"POST",body:t});if(F(!1),!e.ok)throw Error("HTTP error! status: ".concat(e.status));return await e.json()}catch(e){return _("Error converting files. "+e+". Please try again, or contact team@khoj.dev if the issue persists."),console.error("Error converting files:",e),[]}}async function ex(){try{let e=await navigator.mediaDevices.getUserMedia({audio:!0}),t=new MediaRecorder(e,{mimeType:"audio/webm"}),a=[];t.ondataavailable=async e=>{a.push(e.data);let t=new Blob(a,{type:"audio/webm"}),r=new FormData;r.append("file",t);try{let e=await fetch("/api/transcribe",{method:"POST",body:r});if(!e.ok)throw Error("Network response was not ok");let t=await e.json();s(t.text.trim())}catch(e){console.error("Error sending audio to server:",e)}},t.start(1500),t.onstop=async()=>{let e=new Blob(a,{type:"audio/webm"}),r=new FormData;r.append("file",e);try{let e=await fetch("/api/transcribe",{method:"POST",body:r});if(!e.ok)throw Error("Network response was not ok");let a=await e.json();t.stream.getTracks().forEach(e=>e.stop()),es(null),s(a.text.trim())}catch(e){console.error("Error sending audio to server:",e)}},es(t)}catch(e){console.error("Error getting microphone",e)}}return(0,i.useEffect)(()=>{if(P||en(0),P){let e=setInterval(()=>{en(e=>{let t=e+(Math.floor(5*Math.random())+1);return t<100?t:100})},800);return()=>clearInterval(e)}},[P]),(0,i.useEffect)(()=>{var a;void 0!==e.prefillMessage&&(s(e.prefillMessage),null==t||null===(a=t.current)||void 0===a||a.focus())},[e.prefillMessage]),(0,i.useEffect)(()=>{var a,s,r;"message"===e.focus?null==t||null===(a=t.current)||void 0===a||a.focus():"file"===e.focus?null===(s=l.current)||void 0===s||s.focus():"research"===e.focus&&(null===(r=O.current)||void 0===r||r.focus())},[e.focus]),(0,i.useEffect)(()=>{async function e(){K.length>0&&X(await Promise.all(K.map(async e=>{let t=await fetch(e),a=await t.blob();return new Promise(e=>{let t=new FileReader;t.onload=()=>e(t.result),t.readAsDataURL(a)})}))),F(!1)}F(!0),e()},[K]),(0,i.useEffect)(()=>{e.isResearchModeEnabled&&eu(e.isResearchModeEnabled)},[e.isResearchModeEnabled]),(0,i.useEffect)(()=>{!ee&&ea&&ea.stop(),ee&&!ea&&ex()},[ee,ea]),(0,i.useEffect)(()=>{(null==t?void 0:t.current)&&(t.current.style.height="auto",t.current.style.height=Math.max(t.current.scrollHeight-24,64)+"px",a.startsWith("/")&&1===a.split(" ").length?ec(!0):ec(!1))},[a]),(0,n.jsxs)(n.Fragment,{children:[$&&W&&(0,n.jsx)(E.Z,{onOpenChange:H,isMobileWidth:e.isMobileWidth}),P&&(0,n.jsx)(j.aR,{open:P,children:(0,n.jsxs)(j._T,{children:[(0,n.jsx)(j.fY,{children:(0,n.jsx)(j.f$,{children:"Uploading data. Please wait."})}),(0,n.jsx)(j.yT,{children:(0,n.jsx)(v.E,{indicatorColor:"bg-slate-500",className:"w-full h-2 rounded-full",value:er})}),(0,n.jsx)(j.OL,{className:"bg-slate-400 hover:bg-slate-500",onClick:()=>F(!1),children:"Dismiss"})]})}),A&&(0,n.jsx)(j.aR,{open:null!==A,children:(0,n.jsxs)(j._T,{children:[(0,n.jsx)(j.fY,{children:(0,n.jsx)(j.f$,{children:"Data Upload Warning"})}),(0,n.jsx)(j.yT,{children:A}),(0,n.jsx)(j.OL,{className:"bg-slate-400 hover:bg-slate-500",onClick:()=>I(null),children:"Close"})]})}),L&&(0,n.jsx)(j.aR,{open:null!==L,children:(0,n.jsxs)(j._T,{children:[(0,n.jsxs)(j.fY,{children:[(0,n.jsx)(j.f$,{children:"Oh no!"}),(0,n.jsx)(j.yT,{children:"Something went wrong while uploading your data"})]}),(0,n.jsx)(j.yT,{children:L}),(0,n.jsx)(j.OL,{className:"bg-slate-400 hover:bg-slate-500",onClick:()=>_(null),children:"Close"})]})}),ei&&(0,n.jsx)("div",{className:"flex justify-center text-center",children:(0,n.jsxs)(w.J2,{open:ei,onOpenChange:ec,children:[(0,n.jsx)(y.xo,{className:"flex justify-center text-center"}),(0,n.jsx)(w.yk,{onOpenAutoFocus:e=>e.preventDefault(),className:"".concat(e.isMobileWidth?"w-[100vw]":"w-full"," rounded-md"),side:"bottom",align:"center",sideOffset:e.conversationId?0:80,alignOffset:0,children:(0,n.jsxs)(p.mY,{className:"max-w-full",children:[(0,n.jsx)(p.sZ,{placeholder:"Type a command or search...",value:a,className:"hidden"}),(0,n.jsxs)(p.e8,{children:[(0,n.jsx)(p.rb,{children:"No matching commands."}),(0,n.jsx)(p.fu,{heading:"Agent Tools",children:e.chatOptionsData&&Object.entries(e.chatOptionsData).map(e=>{let[t,a]=e;return(0,n.jsx)(p.di,{className:"text-md",onSelect:()=>{s("/".concat(t," "))},children:(0,n.jsxs)("div",{className:"grid grid-cols-1 gap-1",children:[(0,n.jsxs)("div",{className:"font-bold flex items-center",children:[(0,S.vH)(t,"h-4 w-4 mr-2"),"/",t]}),(0,n.jsx)("div",{children:a})]})},t)})}),(0,n.jsx)(p.zz,{})]})]})})]})}),(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 overflow-x-auto",children:[J&&K.map((e,t)=>(0,n.jsxs)("div",{className:"relative flex-shrink-0 pb-3 pt-2 group",children:[(0,n.jsx)("img",{src:e,alt:"img-".concat(t),className:"w-auto h-16 object-cover rounded-xl"}),(0,n.jsx)(b.z,{variant:"ghost",size:"icon",className:"absolute -top-0 -right-2 h-5 w-5 rounded-full bg-neutral-200 dark:bg-neutral-600 hover:bg-neutral-300 dark:hover:bg-neutral-500 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{Y(e=>e.filter((e,a)=>a!==t)),X(e=>e.filter((e,a)=>a!==t)),1===K.length&&B(!1)},children:(0,n.jsx)(d.X,{className:"h-3 w-3"})})]},t)),V&&Array.from(V).map((t,a)=>(0,n.jsxs)(T.Vq,{children:[(0,n.jsx)(T.hg,{asChild:!0,children:(0,n.jsxs)("div",{className:"relative flex-shrink-0 p-2 group",children:[(0,n.jsx)("div",{className:"w-auto h-16 object-cover rounded-xl ".concat(e.agentColor?(0,C.tp)(e.agentColor):"bg-orange-300 hover:bg-orange-500"," bg-opacity-15"),children:(0,n.jsxs)("div",{className:"flex p-2 flex-col justify-start items-start h-full",children:[(0,n.jsx)("span",{className:"text-sm font-bold text-neutral-500 dark:text-neutral-400 text-ellipsis truncate max-w-[200px] break-words",children:t.name}),(0,n.jsxs)("span",{className:"flex items-center gap-1",children:[(0,S.Le)(t.file_type),(0,n.jsx)("span",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:(0,R.xq)(t.size)})]})]})}),(0,n.jsx)(b.z,{variant:"ghost",size:"icon",className:"absolute -top-0 -right-2 h-5 w-5 rounded-full bg-neutral-200 dark:bg-neutral-600 hover:bg-neutral-300 dark:hover:bg-neutral-500 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{G(a=>{let s=t.name;if(!a)return null;let r=Array.from(a).filter(e=>e.name!==s),n=new DataTransfer;r.forEach(e=>n.items.add(e));let l=V.filter(e=>e.name!==s);return e.setUploadedFiles(l),Q(l),n.files})},children:(0,n.jsx)(d.X,{className:"h-3 w-3"})})]},a)}),(0,n.jsxs)(T.cZ,{children:[(0,n.jsx)(T.fK,{children:(0,n.jsx)(T.$N,{children:t.name})}),(0,n.jsx)(T.Be,{children:(0,n.jsx)(z.x,{className:"h-72 w-full rounded-md",children:t.content})})]})]},a))]}),(0,n.jsxs)("div",{className:"".concat(o().actualInputArea," justify-between dark:bg-neutral-700 relative ").concat(el&&"animate-pulse"),onDragOver:function(e){e.preventDefault(),eo(!0)},onDragLeave:function(e){e.preventDefault(),eo(!1)},onDrop:function(e){e.preventDefault(),eo(!1),e.dataTransfer.files&&ef(e.dataTransfer.files)},children:[(0,n.jsx)("input",{type:"file",accept:".pdf,.doc,.docx,.txt,.md,.org,.jpg,.jpeg,.png,.webp",multiple:!0,ref:r,onChange:function(e){e.target.files&&ef(e.target.files)},style:{display:"none"}}),(0,n.jsx)("div",{className:"flex items-center",children:(0,n.jsx)(k.pn,{children:(0,n.jsxs)(k.u,{children:[(0,n.jsx)(k.aJ,{asChild:!0,children:(0,n.jsx)(b.z,{variant:"ghost",className:"!bg-none p-0 m-2 h-auto text-3xl rounded-full text-gray-300 hover:text-gray-500",disabled:e.sendDisabled||!e.isLoggedIn,onClick:function(){r.current&&r.current.click()},ref:l,children:(0,n.jsx)(u.p,{className:"w-8 h-8"})})}),(0,n.jsx)(k._v,{children:"Attach a PDF, plain text file, or image"})]})})}),(0,n.jsx)("div",{className:"flex-grow flex flex-col w-full gap-1.5 relative",children:(0,n.jsx)(N.g,{ref:t,className:"border-none focus:border-none\n focus:outline-none focus-visible:ring-transparent\n w-full h-16 min-h-16 max-h-[128px] md:py-4 rounded-lg resize-none dark:bg-neutral-700\n ".concat(e.isMobileWidth?"text-md":"text-lg"),placeholder:"Type / to see a list of commands",id:"message",autoFocus:!0,value:a,onKeyDown:t=>{"Enter"!==t.key||t.shiftKey||e.isMobileWidth||(B(!1),Y([]),t.preventDefault(),eh())},onChange:e=>s(e.target.value),disabled:e.sendDisabled||ee})}),(0,n.jsxs)("div",{className:"flex items-end pb-2",children:[ee?(0,n.jsx)(k.pn,{children:(0,n.jsxs)(k.u,{children:[(0,n.jsx)(k.aJ,{asChild:!0,children:(0,n.jsx)(b.z,{variant:"default",className:"".concat(!ee&&"hidden"," ").concat(e.agentColor?(0,C.tp)(e.agentColor):"bg-orange-300 hover:bg-orange-500"," rounded-full p-1 m-2 h-auto text-3xl transition transform md:hover:-translate-y-1"),onClick:()=>{et(!ee)},disabled:e.sendDisabled||!e.isLoggedIn,children:(0,n.jsx)(h.d,{weight:"fill",className:"w-6 h-6"})})}),(0,n.jsx)(k._v,{children:"Click to stop recording and transcribe your voice."})]})}):ea?(0,n.jsx)(D.l,{}):(0,n.jsx)(k.pn,{children:(0,n.jsxs)(k.u,{children:[(0,n.jsx)(k.aJ,{asChild:!0,children:e.sendDisabled?(0,n.jsx)(b.z,{variant:"default",className:"".concat(e.agentColor?(0,C.tp)(e.agentColor):"bg-orange-300 hover:bg-orange-500"," rounded-full p-1 m-2 h-auto text-3xl transition transform md:hover:-translate-y-1"),onClick:()=>{e.setTriggeredAbort(!0)},children:(0,n.jsx)(h.d,{weight:"fill",className:"w-6 h-6"})}):(0,n.jsx)(b.z,{variant:"default",className:"".concat(!a||ee||"hidden"," ").concat(e.agentColor?(0,C.tp)(e.agentColor):"bg-orange-300 hover:bg-orange-500"," rounded-full p-1 m-2 h-auto text-3xl transition transform md:hover:-translate-y-1"),disabled:e.sendDisabled||!e.isLoggedIn,onClick:()=>{s("Listening..."),et(!ee)},children:(0,n.jsx)(f.P,{weight:"fill",className:"w-6 h-6"})})}),(0,n.jsx)(k._v,{children:e.sendDisabled?"Click here to stop the streaming.":"Click to transcribe your message with voice."})]})}),(0,n.jsx)(b.z,{className:"".concat((!a||ee)&&"hidden"," ").concat(e.agentColor?(0,C.tp)(e.agentColor):"bg-orange-300 hover:bg-orange-500"," rounded-full p-1 m-2 h-auto text-3xl transition transform md:hover:-translate-y-1"),disabled:e.sendDisabled||!e.isLoggedIn,onClick:eh,children:(0,n.jsx)(g.a,{className:"w-6 h-6",weight:"bold"})})]})]}),(0,n.jsx)(k.pn,{children:(0,n.jsxs)(k.u,{children:[(0,n.jsx)(k.aJ,{asChild:!0,children:(0,n.jsxs)(b.z,{variant:"ghost",className:"float-right justify-center gap-1 flex items-center p-1.5 mr-2 h-fit",disabled:e.sendDisabled||!e.isLoggedIn,ref:O,onClick:()=>{var e;eu(!ed),null==t||null===(e=t.current)||void 0===e||e.focus()},children:[(0,n.jsx)("span",{className:"text-muted-foreground text-sm",children:"Research Mode"}),ed?(0,n.jsx)(x.W,{weight:"fill",className:"w-6 h-6 inline-block ".concat(e.agentColor?(0,C.oz)(e.agentColor):(0,C.oz)("orange")," rounded-full")}):(0,n.jsx)(m.$,{weight:"fill",className:"w-6 h-6 inline-block ".concat((0,C.oz)("gray")," rounded-full")})]})}),(0,n.jsx)(k._v,{className:"text-xs",children:"(Experimental) Research Mode allows you to get more deeply researched, detailed responses. Response times may be longer."})]})})]})]})});O.displayName="ChatInputArea"},32759:function(e,t,a){"use strict";a.d(t,{E:function(){return o}});var s=a(57437),r=a(2265),n=a(60610),l=a(94508);let o=r.forwardRef((e,t)=>{let{className:a,value:r,indicatorColor:o,...i}=e;return(0,s.jsx)(n.fC,{ref:t,className:(0,l.cn)("relative h-4 w-full overflow-hidden rounded-full bg-secondary",a),...i,children:(0,s.jsx)(n.z$,{className:"h-full w-full flex-1 bg-primary transition-all ".concat(o),style:{transform:"translateX(-".concat(100-(r||0),"%)")}})})});o.displayName=n.fC.displayName},76818:function(e,t,a){"use strict";a.d(t,{g:function(){return l}});var s=a(57437),r=a(2265),n=a(94508);let l=r.forwardRef((e,t)=>{let{className:a,...r}=e;return(0,s.jsx)("textarea",{className:(0,n.cn)("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",a),ref:t,...r})});l.displayName="Textarea"},26442:function(e){e.exports={actualInputArea:"chatInputArea_actualInputArea__Ha6cN"}}}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5477],{5477:function(e,t,a){"use strict";a.d(t,{$:function(){return r},a:function(){return O}});var s,r,n=a(57437),l=a(26442),o=a.n(l),i=a(2265),c=a(18848);a(2446);var d=a(12144),u=a(10107),h=a(19715),f=a(35849),g=a(4203),x=a(51549),m=a(62340),p=a(23518),j=a(37099),b=a(62869),v=a(32759),w=a(57054),y=a(27312),N=a(76818),k=a(81103),C=a(84671),E=a(33494),D=a(14308),S=a(42225),M=a(59199),R=a(7436),T=a(26110),z=a(19378);(s=r||(r={})).MESSAGE="message",s.FILE="file",s.RESEARCH="research";let O=(0,i.forwardRef)((e,t)=>{let[a,s]=(0,i.useState)(""),r=(0,i.useRef)(null),l=(0,i.useRef)(null),O=(0,i.useRef)(null),[A,I]=(0,i.useState)(null),[L,_]=(0,i.useState)(null),[P,F]=(0,i.useState)(!1),[W,U]=(0,i.useState)(null),[$,H]=(0,i.useState)(!1),[J,B]=(0,i.useState)(!1),[K,Y]=(0,i.useState)([]),[Z,X]=(0,i.useState)([]),[q,G]=(0,i.useState)(null),[V,Q]=(0,i.useState)([]),[ee,et]=(0,i.useState)(!1),[ea,es]=(0,i.useState)(null),[er,en]=(0,i.useState)(0),[el,eo]=(0,i.useState)(!1),[ei,ec]=(0,i.useState)(!1),[ed,eu]=(0,i.useState)(e.isResearchModeEnabled||!1);function eh(){if(J&&(B(!1),Y([]),Z.forEach(t=>e.sendImage(t))),!a.trim())return;if(!e.isLoggedIn){U("Hey there, you need to be signed in to send messages to Khoj AI"),H(!0);return}let t=a.trim(),r=e.chatOptionsData&&Object.keys(e.chatOptionsData).some(e=>t.startsWith("/".concat(e)));ed&&!r&&(t="/research ".concat(t)),e.sendMessage(t),G(null),Q([]),s("")}function ef(a){var s,r;if(!e.isLoggedIn){U("Please login to chat with your files"),H(!0);return}let n=["jpg","jpeg","png","webp"],l=[];for(let e=0;e<a.length;e++){let t=a[e],s=t.name.split(".").pop();n.includes(s||"")&&l.push(c.Z.sanitize(URL.createObjectURL(t)))}l.length>0&&(B(!0),Y(e=>[...e,...l]),null==t||null===(r=t.current)||void 0===r||r.focus());let o=Array.from(a).filter(e=>!n.includes(e.name.split(".").pop()||"")),i=o?Array.from(o).concat(Array.from(q||[])):Array.from(q||[]);if(i.length>0){for(let e=0;e<i.length;e++)if(i[e].size>10485760){I("File ".concat(i[e].name," is too large. Please upload files smaller than 10 MB."));return}let t=new DataTransfer;i.forEach(e=>t.items.add(e)),eg(t.files).then(a=>{e.setUploadedFiles(a),G(t.files),Q(a)})}null==t||null===(s=t.current)||void 0===s||s.focus()}async function eg(e){let t=await (0,M.M1)(e);F(!0);try{let e=await fetch("/api/content/convert",{method:"POST",body:t});if(F(!1),!e.ok)throw Error("HTTP error! status: ".concat(e.status));return await e.json()}catch(e){return _("Error converting files. "+e+". Please try again, or contact team@khoj.dev if the issue persists."),console.error("Error converting files:",e),[]}}async function ex(){try{let e=await navigator.mediaDevices.getUserMedia({audio:!0}),t=new MediaRecorder(e,{mimeType:"audio/webm"}),a=[];t.ondataavailable=async e=>{a.push(e.data);let t=new Blob(a,{type:"audio/webm"}),r=new FormData;r.append("file",t);try{let e=await fetch("/api/transcribe",{method:"POST",body:r});if(!e.ok)throw Error("Network response was not ok");let t=await e.json();s(t.text.trim())}catch(e){console.error("Error sending audio to server:",e)}},t.start(1500),t.onstop=async()=>{let e=new Blob(a,{type:"audio/webm"}),r=new FormData;r.append("file",e);try{let e=await fetch("/api/transcribe",{method:"POST",body:r});if(!e.ok)throw Error("Network response was not ok");let a=await e.json();t.stream.getTracks().forEach(e=>e.stop()),es(null),s(a.text.trim())}catch(e){console.error("Error sending audio to server:",e)}},es(t)}catch(e){console.error("Error getting microphone",e)}}return(0,i.useEffect)(()=>{if(P||en(0),P){let e=setInterval(()=>{en(e=>{let t=e+(Math.floor(5*Math.random())+1);return t<100?t:100})},800);return()=>clearInterval(e)}},[P]),(0,i.useEffect)(()=>{var a;void 0!==e.prefillMessage&&(s(e.prefillMessage),null==t||null===(a=t.current)||void 0===a||a.focus())},[e.prefillMessage]),(0,i.useEffect)(()=>{var a,s,r;"message"===e.focus?null==t||null===(a=t.current)||void 0===a||a.focus():"file"===e.focus?null===(s=l.current)||void 0===s||s.focus():"research"===e.focus&&(null===(r=O.current)||void 0===r||r.focus())},[e.focus]),(0,i.useEffect)(()=>{async function e(){K.length>0&&X(await Promise.all(K.map(async e=>{let t=await fetch(e),a=await t.blob();return new Promise(e=>{let t=new FileReader;t.onload=()=>e(t.result),t.readAsDataURL(a)})}))),F(!1)}F(!0),e()},[K]),(0,i.useEffect)(()=>{e.isResearchModeEnabled&&eu(e.isResearchModeEnabled)},[e.isResearchModeEnabled]),(0,i.useEffect)(()=>{!ee&&ea&&ea.stop(),ee&&!ea&&ex()},[ee,ea]),(0,i.useEffect)(()=>{(null==t?void 0:t.current)&&(t.current.style.height="auto",t.current.style.height=Math.max(t.current.scrollHeight-24,64)+"px",a.startsWith("/")&&1===a.split(" ").length?ec(!0):ec(!1))},[a]),(0,n.jsxs)(n.Fragment,{children:[$&&W&&(0,n.jsx)(E.Z,{onOpenChange:H,isMobileWidth:e.isMobileWidth}),P&&(0,n.jsx)(j.aR,{open:P,children:(0,n.jsxs)(j._T,{children:[(0,n.jsx)(j.fY,{children:(0,n.jsx)(j.f$,{children:"Uploading data. Please wait."})}),(0,n.jsx)(j.yT,{children:(0,n.jsx)(v.E,{indicatorColor:"bg-slate-500",className:"w-full h-2 rounded-full",value:er})}),(0,n.jsx)(j.OL,{className:"bg-slate-400 hover:bg-slate-500",onClick:()=>F(!1),children:"Dismiss"})]})}),A&&(0,n.jsx)(j.aR,{open:null!==A,children:(0,n.jsxs)(j._T,{children:[(0,n.jsx)(j.fY,{children:(0,n.jsx)(j.f$,{children:"Data Upload Warning"})}),(0,n.jsx)(j.yT,{children:A}),(0,n.jsx)(j.OL,{className:"bg-slate-400 hover:bg-slate-500",onClick:()=>I(null),children:"Close"})]})}),L&&(0,n.jsx)(j.aR,{open:null!==L,children:(0,n.jsxs)(j._T,{children:[(0,n.jsxs)(j.fY,{children:[(0,n.jsx)(j.f$,{children:"Oh no!"}),(0,n.jsx)(j.yT,{children:"Something went wrong while uploading your data"})]}),(0,n.jsx)(j.yT,{children:L}),(0,n.jsx)(j.OL,{className:"bg-slate-400 hover:bg-slate-500",onClick:()=>_(null),children:"Close"})]})}),ei&&(0,n.jsx)("div",{className:"flex justify-center text-center",children:(0,n.jsxs)(w.J2,{open:ei,onOpenChange:ec,children:[(0,n.jsx)(y.xo,{className:"flex justify-center text-center"}),(0,n.jsx)(w.yk,{onOpenAutoFocus:e=>e.preventDefault(),className:"".concat(e.isMobileWidth?"w-[100vw]":"w-full"," rounded-md"),side:"bottom",align:"center",sideOffset:e.conversationId?0:80,alignOffset:0,children:(0,n.jsxs)(p.mY,{className:"max-w-full",children:[(0,n.jsx)(p.sZ,{placeholder:"Type a command or search...",value:a,className:"hidden"}),(0,n.jsxs)(p.e8,{children:[(0,n.jsx)(p.rb,{children:"No matching commands."}),(0,n.jsx)(p.fu,{heading:"Agent Tools",children:e.chatOptionsData&&Object.entries(e.chatOptionsData).map(e=>{let[t,a]=e;return(0,n.jsx)(p.di,{className:"text-md",onSelect:()=>{s("/".concat(t," "))},children:(0,n.jsxs)("div",{className:"grid grid-cols-1 gap-1",children:[(0,n.jsxs)("div",{className:"font-bold flex items-center",children:[(0,S.vH)(t,"h-4 w-4 mr-2"),"/",t]}),(0,n.jsx)("div",{children:a})]})},t)})}),(0,n.jsx)(p.zz,{})]})]})})]})}),(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 overflow-x-auto",children:[J&&K.map((e,t)=>(0,n.jsxs)("div",{className:"relative flex-shrink-0 pb-3 pt-2 group",children:[(0,n.jsx)("img",{src:e,alt:"img-".concat(t),className:"w-auto h-16 object-cover rounded-xl"}),(0,n.jsx)(b.z,{variant:"ghost",size:"icon",className:"absolute -top-0 -right-2 h-5 w-5 rounded-full bg-neutral-200 dark:bg-neutral-600 hover:bg-neutral-300 dark:hover:bg-neutral-500 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{Y(e=>e.filter((e,a)=>a!==t)),X(e=>e.filter((e,a)=>a!==t)),1===K.length&&B(!1)},children:(0,n.jsx)(d.X,{className:"h-3 w-3"})})]},t)),V&&Array.from(V).map((t,a)=>(0,n.jsxs)(T.Vq,{children:[(0,n.jsx)(T.hg,{asChild:!0,children:(0,n.jsxs)("div",{className:"relative flex-shrink-0 p-2 group",children:[(0,n.jsx)("div",{className:"w-auto h-16 object-cover rounded-xl ".concat(e.agentColor?(0,C.tp)(e.agentColor):"bg-orange-300 hover:bg-orange-500"," bg-opacity-15"),children:(0,n.jsxs)("div",{className:"flex p-2 flex-col justify-start items-start h-full",children:[(0,n.jsx)("span",{className:"text-sm font-bold text-neutral-500 dark:text-neutral-400 text-ellipsis truncate max-w-[200px] break-words",children:t.name}),(0,n.jsxs)("span",{className:"flex items-center gap-1",children:[(0,S.Le)(t.file_type),(0,n.jsx)("span",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:(0,R.xq)(t.size)})]})]})}),(0,n.jsx)(b.z,{variant:"ghost",size:"icon",className:"absolute -top-0 -right-2 h-5 w-5 rounded-full bg-neutral-200 dark:bg-neutral-600 hover:bg-neutral-300 dark:hover:bg-neutral-500 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{G(a=>{let s=t.name;if(!a)return null;let r=Array.from(a).filter(e=>e.name!==s),n=new DataTransfer;r.forEach(e=>n.items.add(e));let l=V.filter(e=>e.name!==s);return e.setUploadedFiles(l),Q(l),n.files})},children:(0,n.jsx)(d.X,{className:"h-3 w-3"})})]},a)}),(0,n.jsxs)(T.cZ,{children:[(0,n.jsx)(T.fK,{children:(0,n.jsx)(T.$N,{children:t.name})}),(0,n.jsx)(T.Be,{children:(0,n.jsx)(z.x,{className:"h-72 w-full rounded-md",children:t.content})})]})]},a))]}),(0,n.jsxs)("div",{className:"".concat(o().actualInputArea," justify-between dark:bg-neutral-700 relative ").concat(el&&"animate-pulse"),onDragOver:function(e){e.preventDefault(),eo(!0)},onDragLeave:function(e){e.preventDefault(),eo(!1)},onDrop:function(e){e.preventDefault(),eo(!1),e.dataTransfer.files&&ef(e.dataTransfer.files)},children:[(0,n.jsx)("input",{type:"file",accept:".pdf,.doc,.docx,.txt,.md,.org,.jpg,.jpeg,.png,.webp",multiple:!0,ref:r,onChange:function(e){e.target.files&&ef(e.target.files)},style:{display:"none"}}),(0,n.jsx)("div",{className:"flex items-center",children:(0,n.jsx)(k.pn,{children:(0,n.jsxs)(k.u,{children:[(0,n.jsx)(k.aJ,{asChild:!0,children:(0,n.jsx)(b.z,{variant:"ghost",className:"!bg-none p-0 m-2 h-auto text-3xl rounded-full text-gray-300 hover:text-gray-500",disabled:e.sendDisabled||!e.isLoggedIn,onClick:function(){r.current&&r.current.click()},ref:l,children:(0,n.jsx)(u.p,{className:"w-8 h-8"})})}),(0,n.jsx)(k._v,{children:"Attach a PDF, plain text file, or image"})]})})}),(0,n.jsx)("div",{className:"flex-grow flex flex-col w-full gap-1.5 relative",children:(0,n.jsx)(N.g,{ref:t,className:"border-none focus:border-none\n focus:outline-none focus-visible:ring-transparent\n w-full h-16 min-h-16 max-h-[128px] md:py-4 rounded-lg resize-none dark:bg-neutral-700\n ".concat(e.isMobileWidth?"text-md":"text-lg"),placeholder:"Type / to see a list of commands",id:"message",autoFocus:!0,value:a,onKeyDown:t=>{"Enter"!==t.key||t.shiftKey||e.isMobileWidth||(B(!1),Y([]),t.preventDefault(),eh())},onChange:e=>s(e.target.value),disabled:e.sendDisabled||ee})}),(0,n.jsxs)("div",{className:"flex items-end pb-2",children:[ee?(0,n.jsx)(k.pn,{children:(0,n.jsxs)(k.u,{children:[(0,n.jsx)(k.aJ,{asChild:!0,children:(0,n.jsx)(b.z,{variant:"default",className:"".concat(!ee&&"hidden"," ").concat(e.agentColor?(0,C.tp)(e.agentColor):"bg-orange-300 hover:bg-orange-500"," rounded-full p-1 m-2 h-auto text-3xl transition transform md:hover:-translate-y-1"),onClick:()=>{et(!ee)},disabled:e.sendDisabled||!e.isLoggedIn,children:(0,n.jsx)(h.d,{weight:"fill",className:"w-6 h-6"})})}),(0,n.jsx)(k._v,{children:"Click to stop recording and transcribe your voice."})]})}):ea?(0,n.jsx)(D.l,{}):(0,n.jsx)(k.pn,{children:(0,n.jsxs)(k.u,{children:[(0,n.jsx)(k.aJ,{asChild:!0,children:e.sendDisabled?(0,n.jsx)(b.z,{variant:"default",className:"".concat(e.agentColor?(0,C.tp)(e.agentColor):"bg-orange-300 hover:bg-orange-500"," rounded-full p-1 m-2 h-auto text-3xl transition transform md:hover:-translate-y-1"),onClick:()=>{e.setTriggeredAbort(!0)},children:(0,n.jsx)(h.d,{weight:"fill",className:"w-6 h-6"})}):(0,n.jsx)(b.z,{variant:"default",className:"".concat(!a||ee||"hidden"," ").concat(e.agentColor?(0,C.tp)(e.agentColor):"bg-orange-300 hover:bg-orange-500"," rounded-full p-1 m-2 h-auto text-3xl transition transform md:hover:-translate-y-1"),disabled:e.sendDisabled||!e.isLoggedIn,onClick:()=>{s("Listening..."),et(!ee)},children:(0,n.jsx)(f.P,{weight:"fill",className:"w-6 h-6"})})}),(0,n.jsx)(k._v,{children:e.sendDisabled?"Click here to stop the streaming.":"Click to transcribe your message with voice."})]})}),(0,n.jsx)(b.z,{className:"".concat((!a||ee)&&"hidden"," ").concat(e.agentColor?(0,C.tp)(e.agentColor):"bg-orange-300 hover:bg-orange-500"," rounded-full p-1 m-2 h-auto text-3xl transition transform md:hover:-translate-y-1"),disabled:e.sendDisabled||!e.isLoggedIn,onClick:eh,children:(0,n.jsx)(g.a,{className:"w-6 h-6",weight:"bold"})})]})]}),(0,n.jsx)(k.pn,{children:(0,n.jsxs)(k.u,{children:[(0,n.jsx)(k.aJ,{asChild:!0,children:(0,n.jsxs)(b.z,{variant:"ghost",className:"float-right justify-center gap-1 flex items-center p-1.5 mr-2 h-fit",disabled:e.sendDisabled||!e.isLoggedIn,ref:O,onClick:()=>{var e;eu(!ed),null==t||null===(e=t.current)||void 0===e||e.focus()},children:[(0,n.jsx)("span",{className:"text-muted-foreground text-sm",children:"Research Mode"}),ed?(0,n.jsx)(x.W,{weight:"fill",className:"w-6 h-6 inline-block ".concat(e.agentColor?(0,C.oz)(e.agentColor):(0,C.oz)("orange")," rounded-full")}):(0,n.jsx)(m.$,{weight:"fill",className:"w-6 h-6 inline-block ".concat((0,C.oz)("gray")," rounded-full")})]})}),(0,n.jsx)(k._v,{className:"text-xs",children:"Research Mode allows you to get more deeply researched, detailed responses. Response times may be longer."})]})})]})]})});O.displayName="ChatInputArea"},32759:function(e,t,a){"use strict";a.d(t,{E:function(){return o}});var s=a(57437),r=a(2265),n=a(60610),l=a(94508);let o=r.forwardRef((e,t)=>{let{className:a,value:r,indicatorColor:o,...i}=e;return(0,s.jsx)(n.fC,{ref:t,className:(0,l.cn)("relative h-4 w-full overflow-hidden rounded-full bg-secondary",a),...i,children:(0,s.jsx)(n.z$,{className:"h-full w-full flex-1 bg-primary transition-all ".concat(o),style:{transform:"translateX(-".concat(100-(r||0),"%)")}})})});o.displayName=n.fC.displayName},76818:function(e,t,a){"use strict";a.d(t,{g:function(){return l}});var s=a(57437),r=a(2265),n=a(94508);let l=r.forwardRef((e,t)=>{let{className:a,...r}=e;return(0,s.jsx)("textarea",{className:(0,n.cn)("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",a),ref:t,...r})});l.displayName="Textarea"},26442:function(e){e.exports={actualInputArea:"chatInputArea_actualInputArea__Ha6cN"}}}]);