@rizom/brain 0.2.0-alpha.844 → 0.2.0-alpha.846

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 (39) hide show
  1. package/dist/brain.js +5 -5
  2. package/dist/chunks/app-yee5z9c3.js +5 -0
  3. package/dist/chunks/{index-pkjvv0ay.js → index-40apbj19.js} +2 -2
  4. package/dist/chunks/{index-590f2jt0.js → index-92ts47kk.js} +3 -3
  5. package/dist/chunks/{index-590f2jt0.js.map → index-92ts47kk.js.map} +3 -3
  6. package/dist/chunks/{index-ekpvmbwd.js → index-bcgnyz6w.js} +2 -2
  7. package/dist/chunks/{index-ygeeaab7.js → index-bpa9kb2d.js} +2 -2
  8. package/dist/chunks/{index-24r1t300.js → index-n9qf67bx.js} +2 -2
  9. package/dist/chunks/{index-6t12x5me.js → index-xa1emqjd.js} +3 -3
  10. package/dist/chunks/{index-6t12x5me.js.map → index-xa1emqjd.js.map} +1 -1
  11. package/dist/chunks/{package-96xwdrgf.js → package-wstdmpan.js} +3 -3
  12. package/dist/chunks/{package-96xwdrgf.js.map → package-wstdmpan.js.map} +1 -1
  13. package/dist/entities.js +1 -1
  14. package/dist/index.js +1 -1
  15. package/dist/interfaces.js +1 -1
  16. package/dist/model.js +4 -4
  17. package/dist/model.js.map +1 -1
  18. package/dist/services.js +1 -1
  19. package/dist/testing.js +1 -1
  20. package/dist/ui/{studio-app-sybdqvxs.js → studio-app-njac86mm.js} +79 -79
  21. package/dist/ui/{studio-app-sybdqvxs.js.map → studio-app-njac86mm.js.map} +5 -4
  22. package/dist/ui/studio-asset-manifest.json +11 -11
  23. package/dist/ui/studio-chunks/{account-view-5hn8fnzw.js → account-view-vd7r4j1h.js} +1 -1
  24. package/dist/ui/studio-chunks/{main-zxr0aqw3.js → main-172x0me8.js} +2 -2
  25. package/dist/ui/studio-chunks/{main-zxr0aqw3.js.map → main-172x0me8.js.map} +3 -3
  26. package/dist/ui/studio-chunks/main-98w8qkfj.js +4 -0
  27. package/dist/ui/studio-chunks/{main-px4xemnw.js.map → main-98w8qkfj.js.map} +3 -3
  28. package/dist/ui/studio-chunks/main-qzww64vy.js.map +1 -1
  29. package/dist/ui/studio-chunks/{studio-chat-workspace-rfr7egmk.js → studio-chat-workspace-rdge6t6n.js} +1 -1
  30. package/package.json +1 -1
  31. package/dist/chunks/app-kgqkeyte.js +0 -5
  32. package/dist/ui/studio-chunks/main-px4xemnw.js +0 -4
  33. /package/dist/chunks/{app-kgqkeyte.js.map → app-yee5z9c3.js.map} +0 -0
  34. /package/dist/chunks/{index-pkjvv0ay.js.map → index-40apbj19.js.map} +0 -0
  35. /package/dist/chunks/{index-ekpvmbwd.js.map → index-bcgnyz6w.js.map} +0 -0
  36. /package/dist/chunks/{index-ygeeaab7.js.map → index-bpa9kb2d.js.map} +0 -0
  37. /package/dist/chunks/{index-24r1t300.js.map → index-n9qf67bx.js.map} +0 -0
  38. /package/dist/ui/studio-chunks/{account-view-5hn8fnzw.js.map → account-view-vd7r4j1h.js.map} +0 -0
  39. /package/dist/ui/studio-chunks/{studio-chat-workspace-rfr7egmk.js.map → studio-chat-workspace-rdge6t6n.js.map} +0 -0
@@ -1,3 +1,3 @@
1
- import{R as it,S as at,T as ne,U as ue,V as rt,W as lt,da as ct,p as st,q as Je,r as ze}from"./main-zxr0aqw3.js";import{ga as n,ha as i,ia as Le,ja as q,ka as ut,la as mt,ma as ft,na as ht,oa as pt,pa as vt,qa as _,ra as gt,sa as yt}from"./main-wkp4g23f.js";import{Ca as et,Fa as Ke,Kb as dt,La as Oe,Oa as de,Qa as Fe,ob as Ve}from"./main-jyhbh07e.js";import"./main-wyzt8zma.js";import{ic as X}from"./main-px4xemnw.js";import{$c as Ne,Fd as z,Oc as tt,Pc as nt,_c as Ae,bd as xe,pc as H,rc as D,sc as Ee,tc as Ge,wc as Be,xc as He,zc as qe}from"./main-qzww64vy.js";import{pf as ot}from"./main-dfmjnvb5.js";import{qf as L}from"./main-nbfatnag.js";import{Yf as w}from"./main-1ad1b2wa.js";var Q=w(L(),1);var O=w(H(),1),qt={stopped:"Stopped",disconnected:"Connection lost",failed:"Response failed"};function ke(e){let{interrupted:t}=e;return O.jsxDEV("section",{className:i("studio-chat-interruption",n.empty),role:t.kind==="stopped"?"status":"alert","aria-atomic":"true",children:[O.jsxDEV("strong",{children:qt[t.kind]},void 0,!1,void 0,this),O.jsxDEV("p",{children:"Any received text is kept here. Stopping the response does not undo completed actions; the server may still be working."},void 0,!1,void 0,this),t.detail&&O.jsxDEV("p",{children:t.detail},void 0,!1,void 0,this),t.retry&&O.jsxDEV(O.Fragment,{children:[O.jsxDEV("p",{children:"Sending again may repeat completed actions. Review the request before sending."},void 0,!1,void 0,this),O.jsxDEV(D,{type:"button",variant:"ghost",disabled:e.restoreBlocked||e.draftPending,onClick:()=>{if(!t.retry||e.draftPending)return;e.onRestore(t.retry)},children:"Review retry in composer"},void 0,!1,void 0,this),e.draftPending&&O.jsxDEV("p",{children:"Your composer draft is unchanged. Send or clear it before restoring this request."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var Z=w(L(),1);var N=w(H(),1);function we(e){return N.jsxDEV("aside",{className:i("studio-chat-context",n.contextBody),tabIndex:0,"aria-label":"Conversation sources and attachments",children:N.jsxDEV("div",{className:i("studio-chat-context-list",n.cards),children:[e.session?.contextHandoff?N.jsxDEV("section",{className:i("studio-chat-context-card",n.contextItem),children:[N.jsxDEV("span",{className:i("studio-chat-context-kicker",n.kicker),children:"Linked context"},void 0,!1,void 0,this),N.jsxDEV("h3",{className:i("studio-chat-context-card-title",n.cardHeading,z.section),children:e.session.contextHandoff.titleSeed},void 0,!1,void 0,this),N.jsxDEV("p",{className:i("studio-chat-context-card-text",n.cardText),children:[e.session.contextHandoff.sourceId," ·"," ",e.session.contextHandoff.itemId]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):null,e.cards.length===0&&e.progress.length===0?N.jsxDEV("p",{className:i("studio-chat-empty",n.empty),children:"No sources or attachments in this conversation yet."},void 0,!1,void 0,this):null,e.cards.map((t,o)=>N.jsxDEV("section",{className:i("studio-chat-context-card",n.contextItem),children:[N.jsxDEV("span",{className:i("studio-chat-context-kicker",n.kicker),children:t.kind==="sources"?"Sources":"Artifact"},void 0,!1,void 0,this),N.jsxDEV("h3",{className:i("studio-chat-context-card-title",n.cardHeading,z.section),children:t.kind==="sources"?t.title??`${t.sources.length} consulted`:t.kind==="attachment"?t.title:"Conversation context"},void 0,!1,void 0,this),t.kind==="sources"?N.jsxDEV(N.Fragment,{children:[N.jsxDEV("ul",{children:t.sources.slice(0,5).map((s)=>N.jsxDEV("li",{children:s.title??s.source},s.id,!1,void 0,this))},void 0,!1,void 0,this),t.sources.length>5?N.jsxDEV("p",{className:i("studio-chat-context-card-text",n.cardText),children:[t.sources.length-5," more sources in the conversation."]},void 0,!0,void 0,this):null]},void 0,!0,void 0,this):t.kind==="attachment"&&t.description?N.jsxDEV("p",{className:i("studio-chat-context-card-text",n.cardText),children:t.description},void 0,!1,void 0,this):null]},`${t.kind}-${t.id}-${o}`,!0,void 0,this)),e.progress.map((t,o)=>N.jsxDEV("section",{className:i("studio-chat-context-card",n.contextItem),children:[N.jsxDEV("span",{className:i("studio-chat-context-kicker",n.kicker),children:"Durable job"},void 0,!1,void 0,this),N.jsxDEV("h3",{className:i("studio-chat-context-card-title",n.cardHeading,z.section),children:t.operationTarget??t.operationType},void 0,!1,void 0,this),N.jsxDEV("p",{className:i("studio-chat-context-card-text",n.cardText),children:t.message??t.status},void 0,!1,void 0,this)]},`${t.type}-${o}`,!0,void 0,this))]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}var Ot=86400000;function Ie(e,t){return new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit"}).format(e)}function Lt(e,t){return Math.round((Date.parse(t)-Date.parse(e))/Ot)}function De(e,t,o){let s=Lt(Ie(e,o),Ie(t,o));if(s<=0)return"Today";if(s===1)return"Yesterday";if(s<7)return"This week";return"Earlier"}function Re(e,t,o){let s=[...e].sort((r,a)=>a.lastActiveAt.localeCompare(r.lastActiveAt));return["Today","Yesterday","This week","Earlier"].map((r)=>({label:r,sessions:s.filter((a)=>De(Date.parse(a.lastActiveAt),t,o)===r)})).filter((r)=>r.sessions.length>0)}function le(e){let t=e.contextHandoff;if(t?.sourceId!==Ne)return null;let o=xe(t.itemId);return o?{...o,title:t.titleSeed}:null}function Te(e,t,o){let s=le(e);if(s)return{kind:"entry",text:s.title};let r=Date.parse(e.lastActiveAt);if(Number.isNaN(r))return{kind:"time",text:""};let a=Math.floor((t-r)/60000),l=De(r,t,o);if(l==="Today"){if(a<1)return{kind:"time",text:"Just now"};if(a<60)return{kind:"time",text:`${a} ${a===1?"minute":"minutes"} ago`};let f=Math.floor(a/60);return{kind:"time",text:`${f} ${f===1?"hour":"hours"} ago`}}if(l==="Yesterday")return{kind:"time",text:"Yesterday"};if(l==="This week")return{kind:"time",text:new Intl.DateTimeFormat("en-GB",{weekday:"long",timeZone:o}).format(r)};return{kind:"time",text:new Intl.DateTimeFormat("en-GB",{day:"numeric",month:"short",timeZone:o}).format(r)}}var P=w(L(),1);var A=w(H(),1);function Pe(e){let[t,o]=P.useState(!1),[s,r]=P.useState(e.title),[a,l]=P.useState(!1),[f,d]=P.useState(null),m=P.useRef(!1),p=P.useRef(!1),b=P.useRef(null);P.useEffect(()=>{if(t)b.current?.focus()},[t]);let g=P.useRef(null);P.useEffect(()=>(m.current=!0,()=>{m.current=!1}),[]);let I=()=>{o(!1),d(null),requestAnimationFrame(()=>g.current?.querySelector("button")?.focus())},y=async()=>{if(p.current||!s.trim())return;p.current=!0,l(!0),d(null);try{if(await e.onRename(s.trim()),m.current)I()}catch(c){if(m.current)d(Ae(c,"Rename failed. Your proposed title is kept.")||"Rename failed. Your proposed title is kept.")}finally{if(p.current=!1,m.current)l(!1)}};return A.jsxDEV(A.Fragment,{children:[A.jsxDEV("span",{ref:g,children:A.jsxDEV(D,{type:"button",variant:"ghost","aria-expanded":t,disabled:t,onClick:()=>{r(e.title),o(!0)},children:"Rename"},void 0,!1,void 0,this)},void 0,!1,void 0,this),t&&A.jsxDEV("form",{className:i("studio-chat-rename",n.sessionControls),onSubmit:(c)=>{c.preventDefault(),y()},children:[A.jsxDEV("label",{children:["Conversation title",A.jsxDEV(Ee,{ref:b,xstyle:n.sessionFilterSelect,value:s,onChange:(c)=>r(c.target.value),required:!0,maxLength:48,disabled:a},void 0,!1,void 0,this)]},void 0,!0,void 0,this),A.jsxDEV("div",{className:i("",n.actions),children:[A.jsxDEV(D,{type:"submit",disabled:a||!s.trim(),children:a?"Renaming…":"Save title"},void 0,!1,void 0,this),A.jsxDEV(D,{type:"button",variant:"ghost",disabled:a,onClick:I,children:"Cancel"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),f&&A.jsxDEV("p",{role:"alert",children:f},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var u=w(H(),1);function Ue(e){let{currentSession:t,archivedSession:o,setConversationsOpen:s,detailsOpen:r,setDetailsOpen:a,renameCurrent:l}=e.sessions,f=Z.useRef(null),d=t?le(t):null,m=d?.title??t?.contextHandoff?.titleSeed??void 0,p=d?e.entryHref(d.entityType,d.entityId):void 0,b=t?.title??(e.sessionId?"Conversation":"New conversation"),g=(c)=>p!==void 0?u.jsxDEV("a",{href:p,className:i("studio-chat-open-entry",n.openEntry,c&&n.openEntryIcon),"aria-label":c?"Open entry":void 0,onClick:(S)=>{if(!Oe(S))return;S.preventDefault(),e.onOpenEntry(p)},children:c?u.jsxDEV("span",{"aria-hidden":"true",children:"↗"},void 0,!1,void 0,this):"Open entry ↗"},void 0,!1,void 0,this):null,I=u.jsxDEV(D,{type:"button",variant:"ghost",xstyle:n.toolbarButton,"aria-label":"Conversation details and options","aria-haspopup":"dialog","aria-expanded":r,onClick:()=>a(!0),children:"•••"},void 0,!1,void 0,this),[y]=Z.useState(()=>Symbol("chat thread"));return X(y,e.phoneShown?{title:b,back:{label:"Conversations",onBack:()=>s(!0)},action:u.jsxDEV(u.Fragment,{children:[g(!0),I]},void 0,!0,void 0,this)}:null),u.jsxDEV(u.Fragment,{children:[u.jsxDEV("header",{className:i("studio-chat-thread-head",n.threadHead,n.phoneGoneFlex),children:[u.jsxDEV("h1",{className:i("studio-chat-session-heading",n.title),title:t?.title,children:b},void 0,!1,void 0,this),m&&u.jsxDEV("span",{className:i("studio-chat-about",n.about),"data-studio-chat-about":"",children:["About: ",m]},void 0,!0,void 0,this),u.jsxDEV("div",{className:i("studio-chat-head-actions",n.toolbar),children:[g(!1),u.jsxDEV("span",{ref:f,children:I},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),u.jsxDEV(Be,{open:r,onOpenChange:(c)=>{if(a(c),!c)e.deletion.cancelDelete()},children:u.jsxDEV(He,{"aria-describedby":void 0,onCloseAutoFocus:(c)=>{c.preventDefault(),([...document.querySelectorAll('[aria-label="Conversation details and options"]')].find((k)=>k.offsetParent!==null)??f.current?.querySelector("button"))?.focus()},children:[u.jsxDEV(qe,{children:"Conversation details"},void 0,!1,void 0,this),u.jsxDEV("div",{className:i("studio-chat-details",n.details),children:[u.jsxDEV("p",{children:t?.title??"New conversation"},void 0,!1,void 0,this),u.jsxDEV("div",{className:i("studio-chat-session-actions",n.actions),children:[t&&u.jsxDEV(Pe,{title:t.title,onRename:l},t.id,!1,void 0,this),o&&u.jsxDEV("p",{role:"status",children:"Archived conversation. New messages here remain archived."},void 0,!1,void 0,this),e.sessionId&&!o?u.jsxDEV(D,{className:"studio-chat-header-action",variant:"ghost",type:"button",onClick:e.onArchive,disabled:e.archiveBlocked,title:e.draftPending?"Send or clear the draft before archiving":void 0,children:e.archiving?"Archiving…":"Archive"},void 0,!1,void 0,this):null,e.sessionId&&(e.deletion.confirming?u.jsxDEV("section",{role:"group","aria-label":"Confirm conversation deletion",children:[u.jsxDEV("p",{children:"Delete this conversation permanently? This cannot be undone."},void 0,!1,void 0,this),u.jsxDEV("p",{children:"Deleting history does not undo completed actions or guarantee that remote work has stopped."},void 0,!1,void 0,this),e.deletion.deleteError&&u.jsxDEV("p",{role:"alert",children:e.deletion.deleteError},void 0,!1,void 0,this),u.jsxDEV(D,{type:"button",variant:"ghost",autoFocus:!0,"aria-label":"Cancel conversation deletion",disabled:e.deletion.deleting,onClick:e.deletion.cancelDelete,children:"Cancel"},void 0,!1,void 0,this),u.jsxDEV(D,{type:"button",variant:"ghost","aria-label":"Permanently delete conversation",disabled:e.archiveBlocked,onClick:()=>void e.deletion.confirmDelete(),children:e.deletion.deleting?"Deleting…":"Delete permanently"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):u.jsxDEV(D,{type:"button",variant:"ghost","aria-label":"Delete conversation",disabled:e.archiveBlocked,title:e.draftPending?"Send or clear the draft before deleting":void 0,onClick:e.deletion.requestDelete,children:"Delete conversation"},void 0,!1,void 0,this))]},void 0,!0,void 0,this),u.jsxDEV("details",{children:[u.jsxDEV("summary",{children:"Sources and attachments"},void 0,!1,void 0,this),u.jsxDEV(we,{cards:e.contextCards,progress:e.progress,session:t},void 0,!1,void 0,this)]},void 0,!0,void 0,this),u.jsxDEV("details",{children:[u.jsxDEV("summary",{children:"File types and limits"},void 0,!1,void 0,this),u.jsxDEV("p",{id:"studio-chat-upload-guidance",children:Le},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var U=w(L(),1);var Ut=250;function Me(e){let{chatClient:t,queryClient:o,sessionId:s,studioBasePath:r,navigate:a}=e,[l,f]=U.useState(s===null),[d,m]=U.useState(!1),[p,b]=U.useState(""),[g,I]=U.useState({query:"",archived:!1,offset:0});U.useEffect(()=>{let E=window.setTimeout(()=>I((T)=>T.query===p.trim()?T:{...T,query:p.trim(),offset:0}),Ut);return()=>window.clearTimeout(E)},[p]);let y=Ke({queryKey:[...q.sessions,g],queryFn:()=>t.listSessions(g)}),c=y.data??[],S=c.find((E)=>E.id===s)??o.getQueriesData({queryKey:q.sessions}).flatMap(([,E])=>E??[]).find((E)=>E.id===s),k=U.useCallback(()=>{m(!1)},[]),x=U.useCallback((E,T=!1)=>{a(Fe(r,E),{preserveWork:T}),f(!1),k()},[a,r,k]),R=async(E)=>{if(!S)return;let T=await t.renameSession(S.id,E);if(!T.renamed)throw Error("The conversation could not be renamed.");o.setQueriesData({queryKey:q.sessions},(V)=>V?.map((W)=>W.id===S.id?{...W,title:T.title}:W)),o.invalidateQueries({queryKey:q.sessions})};return{sessions:c,currentSession:S,archivedSession:S?.archived===!0,sessionControls:{search:p,view:g,error:y.error?"Sessions could not be loaded.":null,onRetry:()=>{y.refetch()},onSearch:b,onView:I},sessionsLoading:y.isPending,navigateToSession:x,conversationsOpen:l,setConversationsOpen:f,detailsOpen:d,setDetailsOpen:m,closeDisclosures:k,renameCurrent:R}}var K=w(L(),1);function Qe(e){let{chatClient:t,draftKey:o,currentDraftKey:s,setUploads:r}=e,[a,l]=K.useState(!1),[f,d]=K.useState([]),m=K.useRef(null),p=K.useCallback(async(y)=>{if(m.current||y.length===0)return;let c=Symbol();if(m.current=c,l(!0),d((S)=>[...S.filter((k)=>!y.some((x)=>x.id===k.id)),...y.map((k)=>({id:k.id,file:k.file,status:"uploading"}))]),await Promise.all(y.map(async(S)=>{try{let k=await t.upload(S.file,S.file.name);if(m.current!==c||s.current!==o)return;r((x)=>[...x,k]),d((x)=>x.filter((R)=>R.id!==S.id))}catch(k){if(m.current!==c||s.current!==o)return;d((x)=>x.map((R)=>R.id===S.id?{...R,status:"failed",error:_(k,"Upload failed")}:R))}})),m.current===c)m.current=null,l(!1)},[t,o,s,r]),b=K.useCallback(async(y)=>{let c=Array.from(y.target.files??[]);y.target.value="",await p(c.map((S)=>({id:crypto.randomUUID(),file:S,status:"uploading"})))},[p]),g=K.useCallback((y)=>{d((c)=>c.filter((S)=>S.id!==y))},[]),I=K.useCallback(()=>{m.current=null,l(!1),d([])},[]);return{uploading:a,uploadAttempts:f,runUploads:p,uploadFiles:b,dismissAttempt:g,reset:I}}var j=w(L(),1);function We(e){let{chatClient:t,queryClient:o,sessionId:s,draftKey:r,currentDraftKey:a,mountedRef:l,blocked:f,setSending:d,setError:m,navigateToSession:p}=e,[b,g]=j.useState(!1),I=j.useCallback(async()=>{if(!s||f)return;d(!0),g(!0);try{if(await t.archiveSession(s),await o.invalidateQueries({queryKey:q.sessions}),l.current&&a.current===r)p(void 0,!0)}catch(c){if(l.current&&a.current===r)m(_(c,"Conversation could not be archived"))}finally{if(l.current&&a.current===r)d(!1),g(!1)}},[t,o,s,r,a,l,f,d,m,p]),y=j.useCallback(()=>g(!1),[]);return{archiving:b,archiveCurrent:I,reset:y}}var M=w(L(),1);function $e(e){let{chatClient:t,queryClient:o,sessionId:s,draftKey:r,currentDraftKey:a,mountedRef:l,blocked:f,setSending:d,navigateToSession:m}=e,[p,b]=M.useState(null),[g,I]=M.useState(!1),[y,c]=M.useState(null),S=M.useRef(0),k=M.useRef(!1),x=p===r,R=M.useCallback(()=>{S.current++,k.current=!1,b(null),I(!1),c(null)},[]);return{confirming:x,deleting:g,deleteError:y,requestDelete:()=>{if(!s||f||k.current)return;c(null),b(r)},cancelDelete:()=>{if(!k.current)b(null)},confirmDelete:async()=>{if(!s||!x||f||k.current)return;let W=S.current,B=()=>l.current&&a.current===r&&S.current===W;k.current=!0,I(!0),d(!0),c(null);try{if(!(await t.deleteSession(s)).deleted)throw Error("Deletion was not acknowledged");if(await o.cancelQueries({queryKey:q.messages(s)}),o.removeQueries({queryKey:q.messages(s)}),o.setQueriesData({queryKey:q.sessions},(G)=>G?.filter((J)=>J.id!==s)),o.invalidateQueries({queryKey:q.sessions}),B())b(null),m(void 0,!0)}catch{if(B())c("Deletion could not be confirmed. The conversation may already be deleted. Check history before trying again.")}finally{if(B())k.current=!1,I(!1),d(!1)}},reset:R}}var ee=w(L(),1);function _e(e){let{chatClient:t,handoff:o,sessionId:s,apiPath:r,draftStore:a,draftKey:l,currentDraftKey:f,mountedRef:d,setDraft:m,setError:p,navigateToSession:b}=e,g=ee.useRef(null);ee.useEffect(()=>{if(!o||s)return;let I=`${o.sourceId}\x00${o.itemId}`;if(g.current===I)return;g.current=I,m(o.prompt),p(null);let y=()=>d.current===!0&&f.current===l&&g.current===I;t.openContextSession({version:1,sourceId:o.sourceId,itemId:o.itemId,titleSeed:o.label}).then(({conversationId:c})=>{if(!y())return;a.adopt(l,Ve(r,c)),b(c,!0)}).catch((c)=>{if(!y())return;g.current=null,p(_(c,"Context could not be attached"))})},[t,o,s,r,a,l,f,d,m,p,b])}var te=w(L(),1);function Ye(e){let{question:t,sessionId:o,setDraft:s}=e,r=te.useRef(null);te.useEffect(()=>{if(!t||o)return;if(r.current===t)return;r.current=t,s(t)},[t,o,s])}var ce=w(L(),1);function je(e){let{onChange:t,draft:o,uploadCount:s,uploadAttemptCount:r,sending:a,uploading:l}=e;ce.useEffect(()=>{t?.({hasDraft:Boolean(o||s||r),busy:a||l})},[o,s,r,a,l,t]),ce.useEffect(()=>()=>t?.({hasDraft:!1,busy:!1}),[t])}var Xe=w(L(),1);var C=w(H(),1);function Ze(e){let t=Date.now(),o=e.sessions.length>0||e.search!==""||e.view.query!==""||e.view.archived||e.view.offset>0,s=C.jsxDEV(D,{className:"studio-chat-new",type:"button",size:"sm","aria-label":"New conversation",onClick:e.onNew,children:"New"},void 0,!1,void 0,this),[r]=Xe.useState(()=>Symbol("conversations"));return X(r,e.phoneHidden===!0?null:{title:"Conversations",action:s}),C.jsxDEV("aside",{className:i("studio-chat-session-picker",n.conversations,e.phoneHidden===!0&&n.conversationsHidden),"aria-label":"Conversations",children:[C.jsxDEV("div",{className:i("studio-chat-session-controls",n.sessionControls),children:[C.jsxDEV("div",{className:i("",n.railHead,n.phoneGoneFlex),children:[C.jsxDEV("h2",{className:i("",n.railTitle),children:"Conversations"},void 0,!1,void 0,this),C.jsxDEV(D,{className:"studio-chat-new",type:"button",variant:"secondary",size:"sm","aria-label":"New conversation",onClick:e.onNew,children:"New"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),o&&C.jsxDEV(Je,{label:"Conversation search and filters",searchLabel:"Search conversations",search:e.search,onSearch:e.onSearch,filterLabel:"Filter",filterCount:e.view.archived?1:0,filtered:Boolean(e.view.query)||e.view.archived,onClear:()=>{e.onSearch(""),e.onView({...e.view,query:"",archived:!1,offset:0})},children:C.jsxDEV(Ge,{"aria-label":"Show conversations",value:e.view.archived?"archived":"active",onChange:(a)=>e.onView({...e.view,archived:a.target.value==="archived",offset:0}),children:[C.jsxDEV("option",{value:"active",children:"Active conversations"},void 0,!1,void 0,this),C.jsxDEV("option",{value:"archived",children:"Archived conversations"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),e.error&&C.jsxDEV("p",{role:"alert",children:[e.error," ",C.jsxDEV(D,{type:"button",variant:"ghost",onClick:e.onRetry,children:"Retry sessions"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),C.jsxDEV("div",{className:i("studio-chat-session-list",n.sessionList),children:[e.loading?C.jsxDEV("p",{className:i("studio-chat-empty",n.railEmpty),children:"Loading conversations…"},void 0,!1,void 0,this):null,!e.loading&&!e.error&&e.sessions.length===0?C.jsxDEV("p",{className:i("studio-chat-empty",n.railEmpty),children:e.view.query?"No conversations match this search.":e.view.offset>0?"No more conversations.":e.view.archived?"No archived conversations.":"No conversations yet."},void 0,!1,void 0,this):null,Re(e.sessions,t).map((a)=>C.jsxDEV("section",{"aria-label":a.label,children:[C.jsxDEV("h3",{className:i("",n.dayLabel),children:a.label},void 0,!1,void 0,this),a.sessions.map((l)=>{let f=l.id===e.activeSessionId,d=Te(l,t);return C.jsxDEV("button",{className:i("studio-chat-session",n.session,f&&n.activeSession),"data-active":f?"true":"false","aria-current":f?"true":void 0,type:"button",onClick:()=>e.onSelect(l.id),children:[C.jsxDEV("strong",{className:i("studio-chat-session-title",n.sessionTitle),children:l.title},void 0,!1,void 0,this),C.jsxDEV("small",{className:i("studio-chat-session-note",n.sessionNote),"data-note":d.kind,children:d.kind==="entry"?C.jsxDEV(C.Fragment,{children:[C.jsxDEV("span",{"aria-hidden":"true",className:i("",n.brainMark)},void 0,!1,void 0,this),d.text]},void 0,!0,void 0,this):C.jsxDEV("time",{dateTime:l.lastActiveAt,title:l.lastActiveAt,children:d.text},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},l.id,!0,void 0,this)})]},a.label,!0,void 0,this)),(e.view.offset>0||e.sessions.length>=25)&&C.jsxDEV(ze,{label:"Conversation pages",offset:e.view.offset,count:e.sessions.length,loading:e.loading,hasNext:e.sessions.length>=25,onPrevious:()=>e.onView({...e.view,offset:Math.max(0,e.view.offset-25)}),onNext:()=>e.onView({...e.view,offset:e.view.offset+25})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var h=w(H(),1);function Kt(e,t,o){return`${e==="/"?"":e.replace(/\/+$/,"")}/entities/${encodeURIComponent(t)}/${encodeURIComponent(o)}`}function io(e){let t=et(),o=tt(),s=Q.useMemo(()=>ot({apiPath:e.apiPath,fetch:o}),[e.apiPath,o]),{draftStore:r,draftKey:a,currentDraftKey:l,draft:f,uploads:d,setDraft:m,setUploads:p}=vt({draftStore:e.draftStore,apiPath:e.apiPath,sessionId:e.sessionId}),{uploading:b,uploadAttempts:g,runUploads:I,uploadFiles:y,dismissAttempt:c,reset:S}=Qe({chatClient:s,draftKey:a,currentDraftKey:l,setUploads:p}),k=at(),x=Me({chatClient:s,queryClient:t,sessionId:e.sessionId,studioBasePath:e.studioBasePath,navigate:e.navigate}),{navigateToSession:R,closeDisclosures:E}=x,T=Q.useRef(!1),V=Q.useRef(null),{pendingMessages:W,stream:B,sending:F,error:G,interrupted:J,setSending:me,setError:fe,submitPrompt:Ct,respondToApproval:he,runSuggestedAction:St,hasActiveStream:bt,stopActiveStream:kt,abortActiveStream:pe,reset:wt}=gt({chatClient:s,queryClient:t,sessionId:e.sessionId,apiPath:e.apiPath,draftStore:r,draftKey:a,currentDraftKey:l,mountedRef:T,adoptedSessionRef:V,uploads:d,uploading:b,uploadAttemptCount:g.length,navigateToSession:R});_e({chatClient:s,handoff:e.handoff,sessionId:e.sessionId,apiPath:e.apiPath,draftStore:r,draftKey:a,currentDraftKey:l,mountedRef:T,setDraft:m,setError:fe,navigateToSession:R}),Ye({question:e.question,sessionId:e.sessionId,setDraft:m});let ve=Boolean(f)||d.length>0,ge=ve||g.length>0,oe=F||b||ge,{archiving:ye,archiveCurrent:It,reset:Nt}=We({chatClient:s,queryClient:t,sessionId:e.sessionId,draftKey:a,currentDraftKey:l,mountedRef:T,blocked:oe,setSending:me,setError:fe,navigateToSession:R}),se=$e({chatClient:s,queryClient:t,sessionId:e.sessionId,draftKey:a,currentDraftKey:l,mountedRef:T,blocked:oe,setSending:me,navigateToSession:R});Q.useEffect(()=>(T.current=!0,()=>{T.current=!1,pe()}),[pe]),je({onChange:e.onNavigationStateChange,draft:f,uploadCount:d.length,uploadAttemptCount:g.length,sending:F,uploading:b});let{visibleMessages:Y,contextCards:xt,historyFailed:ie,historyOpening:ae,historyReading:Dt,hasStoredHistory:Rt,retryHistory:Tt}=yt({chatClient:s,sessionId:e.sessionId,sending:F,pendingMessages:W,stream:B}),{ref:Ce,onScroll:Et,awayFromLatest:At,jumpToLatest:Pt}=nt({resetKey:e.sessionId,contentKey:`${Y.length}:${B?.text.length??-1}`});Q.useEffect(()=>{if(E(),e.sessionId&&V.current===e.sessionId){V.current=null;return}wt(),S(),Nt(),se.reset()},[e.sessionId]);let Bt=(v)=>{v.preventDefault(),Ct(f)},Se=ct(e.workspaces),be=!ie&&(!e.sessionId||!ae)&&Y.length===0?mt({types:e.types.map((v)=>v.entityType),workspaces:e.workspaces.map((v)=>v.id)}):[];return h.jsxDEV(dt,{value:(v)=>e.navigate(v),children:h.jsxDEV("div",{className:i("studio",st.frame,n.root,it.space),"data-view":"chat","data-studio-shell":"",children:[h.jsxDEV(lt,{contextLabel:"Chat",navigation:{types:e.types,workspaces:e.workspaces,activeEntityType:null,activeWorkspaceId:de,workspaceBadges:Se,selectEntityType:e.selectEntityType,selectWorkspace:e.selectWorkspace}},void 0,!1,void 0,this),h.jsxDEV("div",{className:ue("studio-chat-shell",n.shell,ne.shell,k&&ne.shellCollapsed),children:[h.jsxDEV("aside",{className:ue("rail studio-chat-studio-rail",ne.rail),children:h.jsxDEV(rt,{renderMode:"desktop",types:e.types,active:null,onSelect:e.selectEntityType,workspaces:e.workspaces,activeWorkspace:de,workspaceBadges:Se,onSelectWorkspace:e.selectWorkspace},void 0,!1,void 0,this)},void 0,!1,void 0,this),h.jsxDEV("main",{className:i("studio-chat-workspace",n.frame),children:h.jsxDEV("div",{className:i("studio-chat-room",n.room),children:[h.jsxDEV(Ze,{...x.sessionControls,activeSessionId:e.sessionId,loading:x.sessionsLoading,sessions:x.sessions,onNew:()=>R(),onSelect:R,phoneHidden:!x.conversationsOpen},void 0,!1,void 0,this),h.jsxDEV("section",{className:i("studio-chat-thread",n.thread,x.conversationsOpen&&n.threadHidden),"aria-label":"Conversation",children:[h.jsxDEV(Ue,{sessionId:e.sessionId,sessions:x,archiving:ye,archiveBlocked:oe,draftPending:ge,onArchive:()=>void It(),deletion:se,contextCards:xt,progress:B?.progress??[],entryHref:(v,re)=>Kt(e.studioBasePath,v,re),onOpenEntry:(v)=>e.navigate(v),phoneShown:!x.conversationsOpen},void 0,!1,void 0,this),h.jsxDEV("div",{ref:Ce,tabIndex:0,role:"region","aria-label":"Conversation messages",onScroll:Et,className:i("studio-chat-thread-scroll",n.threadScroll),children:h.jsxDEV("div",{className:i("studio-chat-manuscript",n.manuscript),children:[ie&&h.jsxDEV("section",{role:"alert",children:[h.jsxDEV("p",{children:[Rt?"Showing previously loaded messages. ":"","Conversation could not be loaded."]},void 0,!0,void 0,this),h.jsxDEV(D,{type:"button",variant:"ghost",disabled:Dt,onClick:Tt,children:"Retry conversation"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ae&&e.sessionId&&Y.length===0?h.jsxDEV("p",{className:i("studio-chat-empty",n.empty),children:"Opening conversation…"},void 0,!1,void 0,this):null,!ie&&(!e.sessionId||!ae)&&Y.length===0?h.jsxDEV(ft,{},void 0,!1,void 0,this):null,Y.map((v)=>h.jsxDEV(ht,{message:v,client:s,disabled:F,speaker:"Your brain",reading:"manuscript",onAction:St,onApproval:he},v.id,!1,void 0,this)),B?.approvals.map((v)=>h.jsxDEV(pt,{approval:v,disabled:F,onDecision:he},v.approvalId,!1,void 0,this)),B&&B.progress.length>0&&h.jsxDEV("details",{className:i("studio-chat-progress",n.card),children:[h.jsxDEV("summary",{children:["Activity · ",B.progress.length," updates"]},void 0,!0,void 0,this),h.jsxDEV("pre",{className:i("",n.source),children:JSON.stringify(B.progress,null,2)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),F?h.jsxDEV("p",{className:i("studio-chat-stream-status",n.empty),role:"status",children:"Responding…"},void 0,!1,void 0,this):null,J&&h.jsxDEV(ke,{interrupted:J,draftPending:ve,restoreBlocked:F||b,onRestore:(v)=>{m(v.text),p([...v.uploads]),Ce.current?.closest(".studio-chat-thread")?.querySelector("textarea")?.focus()}},void 0,!1,void 0,this),G?h.jsxDEV("p",{className:i("studio-chat-error",n.empty,n.error),role:"alert",children:G},void 0,!1,void 0,this):null,h.jsxDEV("div",{},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),h.jsxDEV(ut,{above:be.length>0?h.jsxDEV("div",{"data-studio-chat-starters":"",className:i("studio-chat-starters",n.starters),"aria-label":"Ways to start",children:be.map((v)=>h.jsxDEV("button",{type:"button",className:i("",n.starter),onClick:()=>m(v),children:v},v,!1,void 0,this))},void 0,!1,void 0,this):void 0,onJumpToLatest:At?Pt:void 0,draft:f,sending:F,uploading:b,uploads:d,uploadAttempts:g,onRetryUpload:(v)=>void I([v]),onDismissUpload:c,onDraft:m,locked:ye||se.deleting,onRemoveUpload:(v)=>p((re)=>re.filter((Ht)=>Ht.id!==v)),onFiles:y,onSubmit:Bt,onStop:bt()?kt:void 0},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}export{io as StudioChatWorkspace};
1
+ import{R as it,S as at,T as ne,U as ue,V as rt,W as lt,da as ct,p as st,q as Je,r as ze}from"./main-172x0me8.js";import{ga as n,ha as i,ia as Le,ja as q,ka as ut,la as mt,ma as ft,na as ht,oa as pt,pa as vt,qa as _,ra as gt,sa as yt}from"./main-wkp4g23f.js";import{Ca as et,Fa as Ke,Kb as dt,La as Oe,Oa as de,Qa as Fe,ob as Ve}from"./main-jyhbh07e.js";import"./main-wyzt8zma.js";import{ic as X}from"./main-98w8qkfj.js";import{$c as Ne,Fd as z,Oc as tt,Pc as nt,_c as Ae,bd as xe,pc as H,rc as D,sc as Ee,tc as Ge,wc as Be,xc as He,zc as qe}from"./main-qzww64vy.js";import{pf as ot}from"./main-dfmjnvb5.js";import{qf as L}from"./main-nbfatnag.js";import{Yf as w}from"./main-1ad1b2wa.js";var Q=w(L(),1);var O=w(H(),1),qt={stopped:"Stopped",disconnected:"Connection lost",failed:"Response failed"};function ke(e){let{interrupted:t}=e;return O.jsxDEV("section",{className:i("studio-chat-interruption",n.empty),role:t.kind==="stopped"?"status":"alert","aria-atomic":"true",children:[O.jsxDEV("strong",{children:qt[t.kind]},void 0,!1,void 0,this),O.jsxDEV("p",{children:"Any received text is kept here. Stopping the response does not undo completed actions; the server may still be working."},void 0,!1,void 0,this),t.detail&&O.jsxDEV("p",{children:t.detail},void 0,!1,void 0,this),t.retry&&O.jsxDEV(O.Fragment,{children:[O.jsxDEV("p",{children:"Sending again may repeat completed actions. Review the request before sending."},void 0,!1,void 0,this),O.jsxDEV(D,{type:"button",variant:"ghost",disabled:e.restoreBlocked||e.draftPending,onClick:()=>{if(!t.retry||e.draftPending)return;e.onRestore(t.retry)},children:"Review retry in composer"},void 0,!1,void 0,this),e.draftPending&&O.jsxDEV("p",{children:"Your composer draft is unchanged. Send or clear it before restoring this request."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var Z=w(L(),1);var N=w(H(),1);function we(e){return N.jsxDEV("aside",{className:i("studio-chat-context",n.contextBody),tabIndex:0,"aria-label":"Conversation sources and attachments",children:N.jsxDEV("div",{className:i("studio-chat-context-list",n.cards),children:[e.session?.contextHandoff?N.jsxDEV("section",{className:i("studio-chat-context-card",n.contextItem),children:[N.jsxDEV("span",{className:i("studio-chat-context-kicker",n.kicker),children:"Linked context"},void 0,!1,void 0,this),N.jsxDEV("h3",{className:i("studio-chat-context-card-title",n.cardHeading,z.section),children:e.session.contextHandoff.titleSeed},void 0,!1,void 0,this),N.jsxDEV("p",{className:i("studio-chat-context-card-text",n.cardText),children:[e.session.contextHandoff.sourceId," ·"," ",e.session.contextHandoff.itemId]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):null,e.cards.length===0&&e.progress.length===0?N.jsxDEV("p",{className:i("studio-chat-empty",n.empty),children:"No sources or attachments in this conversation yet."},void 0,!1,void 0,this):null,e.cards.map((t,o)=>N.jsxDEV("section",{className:i("studio-chat-context-card",n.contextItem),children:[N.jsxDEV("span",{className:i("studio-chat-context-kicker",n.kicker),children:t.kind==="sources"?"Sources":"Artifact"},void 0,!1,void 0,this),N.jsxDEV("h3",{className:i("studio-chat-context-card-title",n.cardHeading,z.section),children:t.kind==="sources"?t.title??`${t.sources.length} consulted`:t.kind==="attachment"?t.title:"Conversation context"},void 0,!1,void 0,this),t.kind==="sources"?N.jsxDEV(N.Fragment,{children:[N.jsxDEV("ul",{children:t.sources.slice(0,5).map((s)=>N.jsxDEV("li",{children:s.title??s.source},s.id,!1,void 0,this))},void 0,!1,void 0,this),t.sources.length>5?N.jsxDEV("p",{className:i("studio-chat-context-card-text",n.cardText),children:[t.sources.length-5," more sources in the conversation."]},void 0,!0,void 0,this):null]},void 0,!0,void 0,this):t.kind==="attachment"&&t.description?N.jsxDEV("p",{className:i("studio-chat-context-card-text",n.cardText),children:t.description},void 0,!1,void 0,this):null]},`${t.kind}-${t.id}-${o}`,!0,void 0,this)),e.progress.map((t,o)=>N.jsxDEV("section",{className:i("studio-chat-context-card",n.contextItem),children:[N.jsxDEV("span",{className:i("studio-chat-context-kicker",n.kicker),children:"Durable job"},void 0,!1,void 0,this),N.jsxDEV("h3",{className:i("studio-chat-context-card-title",n.cardHeading,z.section),children:t.operationTarget??t.operationType},void 0,!1,void 0,this),N.jsxDEV("p",{className:i("studio-chat-context-card-text",n.cardText),children:t.message??t.status},void 0,!1,void 0,this)]},`${t.type}-${o}`,!0,void 0,this))]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}var Ot=86400000;function Ie(e,t){return new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit"}).format(e)}function Lt(e,t){return Math.round((Date.parse(t)-Date.parse(e))/Ot)}function De(e,t,o){let s=Lt(Ie(e,o),Ie(t,o));if(s<=0)return"Today";if(s===1)return"Yesterday";if(s<7)return"This week";return"Earlier"}function Re(e,t,o){let s=[...e].sort((r,a)=>a.lastActiveAt.localeCompare(r.lastActiveAt));return["Today","Yesterday","This week","Earlier"].map((r)=>({label:r,sessions:s.filter((a)=>De(Date.parse(a.lastActiveAt),t,o)===r)})).filter((r)=>r.sessions.length>0)}function le(e){let t=e.contextHandoff;if(t?.sourceId!==Ne)return null;let o=xe(t.itemId);return o?{...o,title:t.titleSeed}:null}function Te(e,t,o){let s=le(e);if(s)return{kind:"entry",text:s.title};let r=Date.parse(e.lastActiveAt);if(Number.isNaN(r))return{kind:"time",text:""};let a=Math.floor((t-r)/60000),l=De(r,t,o);if(l==="Today"){if(a<1)return{kind:"time",text:"Just now"};if(a<60)return{kind:"time",text:`${a} ${a===1?"minute":"minutes"} ago`};let f=Math.floor(a/60);return{kind:"time",text:`${f} ${f===1?"hour":"hours"} ago`}}if(l==="Yesterday")return{kind:"time",text:"Yesterday"};if(l==="This week")return{kind:"time",text:new Intl.DateTimeFormat("en-GB",{weekday:"long",timeZone:o}).format(r)};return{kind:"time",text:new Intl.DateTimeFormat("en-GB",{day:"numeric",month:"short",timeZone:o}).format(r)}}var P=w(L(),1);var A=w(H(),1);function Pe(e){let[t,o]=P.useState(!1),[s,r]=P.useState(e.title),[a,l]=P.useState(!1),[f,d]=P.useState(null),m=P.useRef(!1),p=P.useRef(!1),b=P.useRef(null);P.useEffect(()=>{if(t)b.current?.focus()},[t]);let g=P.useRef(null);P.useEffect(()=>(m.current=!0,()=>{m.current=!1}),[]);let I=()=>{o(!1),d(null),requestAnimationFrame(()=>g.current?.querySelector("button")?.focus())},y=async()=>{if(p.current||!s.trim())return;p.current=!0,l(!0),d(null);try{if(await e.onRename(s.trim()),m.current)I()}catch(c){if(m.current)d(Ae(c,"Rename failed. Your proposed title is kept.")||"Rename failed. Your proposed title is kept.")}finally{if(p.current=!1,m.current)l(!1)}};return A.jsxDEV(A.Fragment,{children:[A.jsxDEV("span",{ref:g,children:A.jsxDEV(D,{type:"button",variant:"ghost","aria-expanded":t,disabled:t,onClick:()=>{r(e.title),o(!0)},children:"Rename"},void 0,!1,void 0,this)},void 0,!1,void 0,this),t&&A.jsxDEV("form",{className:i("studio-chat-rename",n.sessionControls),onSubmit:(c)=>{c.preventDefault(),y()},children:[A.jsxDEV("label",{children:["Conversation title",A.jsxDEV(Ee,{ref:b,xstyle:n.sessionFilterSelect,value:s,onChange:(c)=>r(c.target.value),required:!0,maxLength:48,disabled:a},void 0,!1,void 0,this)]},void 0,!0,void 0,this),A.jsxDEV("div",{className:i("",n.actions),children:[A.jsxDEV(D,{type:"submit",disabled:a||!s.trim(),children:a?"Renaming…":"Save title"},void 0,!1,void 0,this),A.jsxDEV(D,{type:"button",variant:"ghost",disabled:a,onClick:I,children:"Cancel"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),f&&A.jsxDEV("p",{role:"alert",children:f},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var u=w(H(),1);function Ue(e){let{currentSession:t,archivedSession:o,setConversationsOpen:s,detailsOpen:r,setDetailsOpen:a,renameCurrent:l}=e.sessions,f=Z.useRef(null),d=t?le(t):null,m=d?.title??t?.contextHandoff?.titleSeed??void 0,p=d?e.entryHref(d.entityType,d.entityId):void 0,b=t?.title??(e.sessionId?"Conversation":"New conversation"),g=(c)=>p!==void 0?u.jsxDEV("a",{href:p,className:i("studio-chat-open-entry",n.openEntry,c&&n.openEntryIcon),"aria-label":c?"Open entry":void 0,onClick:(S)=>{if(!Oe(S))return;S.preventDefault(),e.onOpenEntry(p)},children:c?u.jsxDEV("span",{"aria-hidden":"true",children:"↗"},void 0,!1,void 0,this):"Open entry ↗"},void 0,!1,void 0,this):null,I=u.jsxDEV(D,{type:"button",variant:"ghost",xstyle:n.toolbarButton,"aria-label":"Conversation details and options","aria-haspopup":"dialog","aria-expanded":r,onClick:()=>a(!0),children:"•••"},void 0,!1,void 0,this),[y]=Z.useState(()=>Symbol("chat thread"));return X(y,e.phoneShown?{title:b,back:{label:"Conversations",onBack:()=>s(!0)},action:u.jsxDEV(u.Fragment,{children:[g(!0),I]},void 0,!0,void 0,this)}:null),u.jsxDEV(u.Fragment,{children:[u.jsxDEV("header",{className:i("studio-chat-thread-head",n.threadHead,n.phoneGoneFlex),children:[u.jsxDEV("h1",{className:i("studio-chat-session-heading",n.title),title:t?.title,children:b},void 0,!1,void 0,this),m&&u.jsxDEV("span",{className:i("studio-chat-about",n.about),"data-studio-chat-about":"",children:["About: ",m]},void 0,!0,void 0,this),u.jsxDEV("div",{className:i("studio-chat-head-actions",n.toolbar),children:[g(!1),u.jsxDEV("span",{ref:f,children:I},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),u.jsxDEV(Be,{open:r,onOpenChange:(c)=>{if(a(c),!c)e.deletion.cancelDelete()},children:u.jsxDEV(He,{"aria-describedby":void 0,onCloseAutoFocus:(c)=>{c.preventDefault(),([...document.querySelectorAll('[aria-label="Conversation details and options"]')].find((k)=>k.offsetParent!==null)??f.current?.querySelector("button"))?.focus()},children:[u.jsxDEV(qe,{children:"Conversation details"},void 0,!1,void 0,this),u.jsxDEV("div",{className:i("studio-chat-details",n.details),children:[u.jsxDEV("p",{children:t?.title??"New conversation"},void 0,!1,void 0,this),u.jsxDEV("div",{className:i("studio-chat-session-actions",n.actions),children:[t&&u.jsxDEV(Pe,{title:t.title,onRename:l},t.id,!1,void 0,this),o&&u.jsxDEV("p",{role:"status",children:"Archived conversation. New messages here remain archived."},void 0,!1,void 0,this),e.sessionId&&!o?u.jsxDEV(D,{className:"studio-chat-header-action",variant:"ghost",type:"button",onClick:e.onArchive,disabled:e.archiveBlocked,title:e.draftPending?"Send or clear the draft before archiving":void 0,children:e.archiving?"Archiving…":"Archive"},void 0,!1,void 0,this):null,e.sessionId&&(e.deletion.confirming?u.jsxDEV("section",{role:"group","aria-label":"Confirm conversation deletion",children:[u.jsxDEV("p",{children:"Delete this conversation permanently? This cannot be undone."},void 0,!1,void 0,this),u.jsxDEV("p",{children:"Deleting history does not undo completed actions or guarantee that remote work has stopped."},void 0,!1,void 0,this),e.deletion.deleteError&&u.jsxDEV("p",{role:"alert",children:e.deletion.deleteError},void 0,!1,void 0,this),u.jsxDEV(D,{type:"button",variant:"ghost",autoFocus:!0,"aria-label":"Cancel conversation deletion",disabled:e.deletion.deleting,onClick:e.deletion.cancelDelete,children:"Cancel"},void 0,!1,void 0,this),u.jsxDEV(D,{type:"button",variant:"ghost","aria-label":"Permanently delete conversation",disabled:e.archiveBlocked,onClick:()=>void e.deletion.confirmDelete(),children:e.deletion.deleting?"Deleting…":"Delete permanently"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):u.jsxDEV(D,{type:"button",variant:"ghost","aria-label":"Delete conversation",disabled:e.archiveBlocked,title:e.draftPending?"Send or clear the draft before deleting":void 0,onClick:e.deletion.requestDelete,children:"Delete conversation"},void 0,!1,void 0,this))]},void 0,!0,void 0,this),u.jsxDEV("details",{children:[u.jsxDEV("summary",{children:"Sources and attachments"},void 0,!1,void 0,this),u.jsxDEV(we,{cards:e.contextCards,progress:e.progress,session:t},void 0,!1,void 0,this)]},void 0,!0,void 0,this),u.jsxDEV("details",{children:[u.jsxDEV("summary",{children:"File types and limits"},void 0,!1,void 0,this),u.jsxDEV("p",{id:"studio-chat-upload-guidance",children:Le},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var U=w(L(),1);var Ut=250;function Me(e){let{chatClient:t,queryClient:o,sessionId:s,studioBasePath:r,navigate:a}=e,[l,f]=U.useState(s===null),[d,m]=U.useState(!1),[p,b]=U.useState(""),[g,I]=U.useState({query:"",archived:!1,offset:0});U.useEffect(()=>{let E=window.setTimeout(()=>I((T)=>T.query===p.trim()?T:{...T,query:p.trim(),offset:0}),Ut);return()=>window.clearTimeout(E)},[p]);let y=Ke({queryKey:[...q.sessions,g],queryFn:()=>t.listSessions(g)}),c=y.data??[],S=c.find((E)=>E.id===s)??o.getQueriesData({queryKey:q.sessions}).flatMap(([,E])=>E??[]).find((E)=>E.id===s),k=U.useCallback(()=>{m(!1)},[]),x=U.useCallback((E,T=!1)=>{a(Fe(r,E),{preserveWork:T}),f(!1),k()},[a,r,k]),R=async(E)=>{if(!S)return;let T=await t.renameSession(S.id,E);if(!T.renamed)throw Error("The conversation could not be renamed.");o.setQueriesData({queryKey:q.sessions},(V)=>V?.map((W)=>W.id===S.id?{...W,title:T.title}:W)),o.invalidateQueries({queryKey:q.sessions})};return{sessions:c,currentSession:S,archivedSession:S?.archived===!0,sessionControls:{search:p,view:g,error:y.error?"Sessions could not be loaded.":null,onRetry:()=>{y.refetch()},onSearch:b,onView:I},sessionsLoading:y.isPending,navigateToSession:x,conversationsOpen:l,setConversationsOpen:f,detailsOpen:d,setDetailsOpen:m,closeDisclosures:k,renameCurrent:R}}var K=w(L(),1);function Qe(e){let{chatClient:t,draftKey:o,currentDraftKey:s,setUploads:r}=e,[a,l]=K.useState(!1),[f,d]=K.useState([]),m=K.useRef(null),p=K.useCallback(async(y)=>{if(m.current||y.length===0)return;let c=Symbol();if(m.current=c,l(!0),d((S)=>[...S.filter((k)=>!y.some((x)=>x.id===k.id)),...y.map((k)=>({id:k.id,file:k.file,status:"uploading"}))]),await Promise.all(y.map(async(S)=>{try{let k=await t.upload(S.file,S.file.name);if(m.current!==c||s.current!==o)return;r((x)=>[...x,k]),d((x)=>x.filter((R)=>R.id!==S.id))}catch(k){if(m.current!==c||s.current!==o)return;d((x)=>x.map((R)=>R.id===S.id?{...R,status:"failed",error:_(k,"Upload failed")}:R))}})),m.current===c)m.current=null,l(!1)},[t,o,s,r]),b=K.useCallback(async(y)=>{let c=Array.from(y.target.files??[]);y.target.value="",await p(c.map((S)=>({id:crypto.randomUUID(),file:S,status:"uploading"})))},[p]),g=K.useCallback((y)=>{d((c)=>c.filter((S)=>S.id!==y))},[]),I=K.useCallback(()=>{m.current=null,l(!1),d([])},[]);return{uploading:a,uploadAttempts:f,runUploads:p,uploadFiles:b,dismissAttempt:g,reset:I}}var j=w(L(),1);function We(e){let{chatClient:t,queryClient:o,sessionId:s,draftKey:r,currentDraftKey:a,mountedRef:l,blocked:f,setSending:d,setError:m,navigateToSession:p}=e,[b,g]=j.useState(!1),I=j.useCallback(async()=>{if(!s||f)return;d(!0),g(!0);try{if(await t.archiveSession(s),await o.invalidateQueries({queryKey:q.sessions}),l.current&&a.current===r)p(void 0,!0)}catch(c){if(l.current&&a.current===r)m(_(c,"Conversation could not be archived"))}finally{if(l.current&&a.current===r)d(!1),g(!1)}},[t,o,s,r,a,l,f,d,m,p]),y=j.useCallback(()=>g(!1),[]);return{archiving:b,archiveCurrent:I,reset:y}}var M=w(L(),1);function $e(e){let{chatClient:t,queryClient:o,sessionId:s,draftKey:r,currentDraftKey:a,mountedRef:l,blocked:f,setSending:d,navigateToSession:m}=e,[p,b]=M.useState(null),[g,I]=M.useState(!1),[y,c]=M.useState(null),S=M.useRef(0),k=M.useRef(!1),x=p===r,R=M.useCallback(()=>{S.current++,k.current=!1,b(null),I(!1),c(null)},[]);return{confirming:x,deleting:g,deleteError:y,requestDelete:()=>{if(!s||f||k.current)return;c(null),b(r)},cancelDelete:()=>{if(!k.current)b(null)},confirmDelete:async()=>{if(!s||!x||f||k.current)return;let W=S.current,B=()=>l.current&&a.current===r&&S.current===W;k.current=!0,I(!0),d(!0),c(null);try{if(!(await t.deleteSession(s)).deleted)throw Error("Deletion was not acknowledged");if(await o.cancelQueries({queryKey:q.messages(s)}),o.removeQueries({queryKey:q.messages(s)}),o.setQueriesData({queryKey:q.sessions},(G)=>G?.filter((J)=>J.id!==s)),o.invalidateQueries({queryKey:q.sessions}),B())b(null),m(void 0,!0)}catch{if(B())c("Deletion could not be confirmed. The conversation may already be deleted. Check history before trying again.")}finally{if(B())k.current=!1,I(!1),d(!1)}},reset:R}}var ee=w(L(),1);function _e(e){let{chatClient:t,handoff:o,sessionId:s,apiPath:r,draftStore:a,draftKey:l,currentDraftKey:f,mountedRef:d,setDraft:m,setError:p,navigateToSession:b}=e,g=ee.useRef(null);ee.useEffect(()=>{if(!o||s)return;let I=`${o.sourceId}\x00${o.itemId}`;if(g.current===I)return;g.current=I,m(o.prompt),p(null);let y=()=>d.current===!0&&f.current===l&&g.current===I;t.openContextSession({version:1,sourceId:o.sourceId,itemId:o.itemId,titleSeed:o.label}).then(({conversationId:c})=>{if(!y())return;a.adopt(l,Ve(r,c)),b(c,!0)}).catch((c)=>{if(!y())return;g.current=null,p(_(c,"Context could not be attached"))})},[t,o,s,r,a,l,f,d,m,p,b])}var te=w(L(),1);function Ye(e){let{question:t,sessionId:o,setDraft:s}=e,r=te.useRef(null);te.useEffect(()=>{if(!t||o)return;if(r.current===t)return;r.current=t,s(t)},[t,o,s])}var ce=w(L(),1);function je(e){let{onChange:t,draft:o,uploadCount:s,uploadAttemptCount:r,sending:a,uploading:l}=e;ce.useEffect(()=>{t?.({hasDraft:Boolean(o||s||r),busy:a||l})},[o,s,r,a,l,t]),ce.useEffect(()=>()=>t?.({hasDraft:!1,busy:!1}),[t])}var Xe=w(L(),1);var C=w(H(),1);function Ze(e){let t=Date.now(),o=e.sessions.length>0||e.search!==""||e.view.query!==""||e.view.archived||e.view.offset>0,s=C.jsxDEV(D,{className:"studio-chat-new",type:"button",size:"sm","aria-label":"New conversation",onClick:e.onNew,children:"New"},void 0,!1,void 0,this),[r]=Xe.useState(()=>Symbol("conversations"));return X(r,e.phoneHidden===!0?null:{title:"Conversations",action:s}),C.jsxDEV("aside",{className:i("studio-chat-session-picker",n.conversations,e.phoneHidden===!0&&n.conversationsHidden),"aria-label":"Conversations",children:[C.jsxDEV("div",{className:i("studio-chat-session-controls",n.sessionControls),children:[C.jsxDEV("div",{className:i("",n.railHead,n.phoneGoneFlex),children:[C.jsxDEV("h2",{className:i("",n.railTitle),children:"Conversations"},void 0,!1,void 0,this),C.jsxDEV(D,{className:"studio-chat-new",type:"button",variant:"secondary",size:"sm","aria-label":"New conversation",onClick:e.onNew,children:"New"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),o&&C.jsxDEV(Je,{label:"Conversation search and filters",searchLabel:"Search conversations",search:e.search,onSearch:e.onSearch,filterLabel:"Filter",filterCount:e.view.archived?1:0,filtered:Boolean(e.view.query)||e.view.archived,onClear:()=>{e.onSearch(""),e.onView({...e.view,query:"",archived:!1,offset:0})},children:C.jsxDEV(Ge,{"aria-label":"Show conversations",value:e.view.archived?"archived":"active",onChange:(a)=>e.onView({...e.view,archived:a.target.value==="archived",offset:0}),children:[C.jsxDEV("option",{value:"active",children:"Active conversations"},void 0,!1,void 0,this),C.jsxDEV("option",{value:"archived",children:"Archived conversations"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),e.error&&C.jsxDEV("p",{role:"alert",children:[e.error," ",C.jsxDEV(D,{type:"button",variant:"ghost",onClick:e.onRetry,children:"Retry sessions"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),C.jsxDEV("div",{className:i("studio-chat-session-list",n.sessionList),children:[e.loading?C.jsxDEV("p",{className:i("studio-chat-empty",n.railEmpty),children:"Loading conversations…"},void 0,!1,void 0,this):null,!e.loading&&!e.error&&e.sessions.length===0?C.jsxDEV("p",{className:i("studio-chat-empty",n.railEmpty),children:e.view.query?"No conversations match this search.":e.view.offset>0?"No more conversations.":e.view.archived?"No archived conversations.":"No conversations yet."},void 0,!1,void 0,this):null,Re(e.sessions,t).map((a)=>C.jsxDEV("section",{"aria-label":a.label,children:[C.jsxDEV("h3",{className:i("",n.dayLabel),children:a.label},void 0,!1,void 0,this),a.sessions.map((l)=>{let f=l.id===e.activeSessionId,d=Te(l,t);return C.jsxDEV("button",{className:i("studio-chat-session",n.session,f&&n.activeSession),"data-active":f?"true":"false","aria-current":f?"true":void 0,type:"button",onClick:()=>e.onSelect(l.id),children:[C.jsxDEV("strong",{className:i("studio-chat-session-title",n.sessionTitle),children:l.title},void 0,!1,void 0,this),C.jsxDEV("small",{className:i("studio-chat-session-note",n.sessionNote),"data-note":d.kind,children:d.kind==="entry"?C.jsxDEV(C.Fragment,{children:[C.jsxDEV("span",{"aria-hidden":"true",className:i("",n.brainMark)},void 0,!1,void 0,this),d.text]},void 0,!0,void 0,this):C.jsxDEV("time",{dateTime:l.lastActiveAt,title:l.lastActiveAt,children:d.text},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},l.id,!0,void 0,this)})]},a.label,!0,void 0,this)),(e.view.offset>0||e.sessions.length>=25)&&C.jsxDEV(ze,{label:"Conversation pages",offset:e.view.offset,count:e.sessions.length,loading:e.loading,hasNext:e.sessions.length>=25,onPrevious:()=>e.onView({...e.view,offset:Math.max(0,e.view.offset-25)}),onNext:()=>e.onView({...e.view,offset:e.view.offset+25})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var h=w(H(),1);function Kt(e,t,o){return`${e==="/"?"":e.replace(/\/+$/,"")}/entities/${encodeURIComponent(t)}/${encodeURIComponent(o)}`}function io(e){let t=et(),o=tt(),s=Q.useMemo(()=>ot({apiPath:e.apiPath,fetch:o}),[e.apiPath,o]),{draftStore:r,draftKey:a,currentDraftKey:l,draft:f,uploads:d,setDraft:m,setUploads:p}=vt({draftStore:e.draftStore,apiPath:e.apiPath,sessionId:e.sessionId}),{uploading:b,uploadAttempts:g,runUploads:I,uploadFiles:y,dismissAttempt:c,reset:S}=Qe({chatClient:s,draftKey:a,currentDraftKey:l,setUploads:p}),k=at(),x=Me({chatClient:s,queryClient:t,sessionId:e.sessionId,studioBasePath:e.studioBasePath,navigate:e.navigate}),{navigateToSession:R,closeDisclosures:E}=x,T=Q.useRef(!1),V=Q.useRef(null),{pendingMessages:W,stream:B,sending:F,error:G,interrupted:J,setSending:me,setError:fe,submitPrompt:Ct,respondToApproval:he,runSuggestedAction:St,hasActiveStream:bt,stopActiveStream:kt,abortActiveStream:pe,reset:wt}=gt({chatClient:s,queryClient:t,sessionId:e.sessionId,apiPath:e.apiPath,draftStore:r,draftKey:a,currentDraftKey:l,mountedRef:T,adoptedSessionRef:V,uploads:d,uploading:b,uploadAttemptCount:g.length,navigateToSession:R});_e({chatClient:s,handoff:e.handoff,sessionId:e.sessionId,apiPath:e.apiPath,draftStore:r,draftKey:a,currentDraftKey:l,mountedRef:T,setDraft:m,setError:fe,navigateToSession:R}),Ye({question:e.question,sessionId:e.sessionId,setDraft:m});let ve=Boolean(f)||d.length>0,ge=ve||g.length>0,oe=F||b||ge,{archiving:ye,archiveCurrent:It,reset:Nt}=We({chatClient:s,queryClient:t,sessionId:e.sessionId,draftKey:a,currentDraftKey:l,mountedRef:T,blocked:oe,setSending:me,setError:fe,navigateToSession:R}),se=$e({chatClient:s,queryClient:t,sessionId:e.sessionId,draftKey:a,currentDraftKey:l,mountedRef:T,blocked:oe,setSending:me,navigateToSession:R});Q.useEffect(()=>(T.current=!0,()=>{T.current=!1,pe()}),[pe]),je({onChange:e.onNavigationStateChange,draft:f,uploadCount:d.length,uploadAttemptCount:g.length,sending:F,uploading:b});let{visibleMessages:Y,contextCards:xt,historyFailed:ie,historyOpening:ae,historyReading:Dt,hasStoredHistory:Rt,retryHistory:Tt}=yt({chatClient:s,sessionId:e.sessionId,sending:F,pendingMessages:W,stream:B}),{ref:Ce,onScroll:Et,awayFromLatest:At,jumpToLatest:Pt}=nt({resetKey:e.sessionId,contentKey:`${Y.length}:${B?.text.length??-1}`});Q.useEffect(()=>{if(E(),e.sessionId&&V.current===e.sessionId){V.current=null;return}wt(),S(),Nt(),se.reset()},[e.sessionId]);let Bt=(v)=>{v.preventDefault(),Ct(f)},Se=ct(e.workspaces),be=!ie&&(!e.sessionId||!ae)&&Y.length===0?mt({types:e.types.map((v)=>v.entityType),workspaces:e.workspaces.map((v)=>v.id)}):[];return h.jsxDEV(dt,{value:(v)=>e.navigate(v),children:h.jsxDEV("div",{className:i("studio",st.frame,n.root,it.space),"data-view":"chat","data-studio-shell":"",children:[h.jsxDEV(lt,{contextLabel:"Chat",navigation:{types:e.types,workspaces:e.workspaces,activeEntityType:null,activeWorkspaceId:de,workspaceBadges:Se,selectEntityType:e.selectEntityType,selectWorkspace:e.selectWorkspace}},void 0,!1,void 0,this),h.jsxDEV("div",{className:ue("studio-chat-shell",n.shell,ne.shell,k&&ne.shellCollapsed),children:[h.jsxDEV("aside",{className:ue("rail studio-chat-studio-rail",ne.rail),children:h.jsxDEV(rt,{renderMode:"desktop",types:e.types,active:null,onSelect:e.selectEntityType,workspaces:e.workspaces,activeWorkspace:de,workspaceBadges:Se,onSelectWorkspace:e.selectWorkspace},void 0,!1,void 0,this)},void 0,!1,void 0,this),h.jsxDEV("main",{className:i("studio-chat-workspace",n.frame),children:h.jsxDEV("div",{className:i("studio-chat-room",n.room),children:[h.jsxDEV(Ze,{...x.sessionControls,activeSessionId:e.sessionId,loading:x.sessionsLoading,sessions:x.sessions,onNew:()=>R(),onSelect:R,phoneHidden:!x.conversationsOpen},void 0,!1,void 0,this),h.jsxDEV("section",{className:i("studio-chat-thread",n.thread,x.conversationsOpen&&n.threadHidden),"aria-label":"Conversation",children:[h.jsxDEV(Ue,{sessionId:e.sessionId,sessions:x,archiving:ye,archiveBlocked:oe,draftPending:ge,onArchive:()=>void It(),deletion:se,contextCards:xt,progress:B?.progress??[],entryHref:(v,re)=>Kt(e.studioBasePath,v,re),onOpenEntry:(v)=>e.navigate(v),phoneShown:!x.conversationsOpen},void 0,!1,void 0,this),h.jsxDEV("div",{ref:Ce,tabIndex:0,role:"region","aria-label":"Conversation messages",onScroll:Et,className:i("studio-chat-thread-scroll",n.threadScroll),children:h.jsxDEV("div",{className:i("studio-chat-manuscript",n.manuscript),children:[ie&&h.jsxDEV("section",{role:"alert",children:[h.jsxDEV("p",{children:[Rt?"Showing previously loaded messages. ":"","Conversation could not be loaded."]},void 0,!0,void 0,this),h.jsxDEV(D,{type:"button",variant:"ghost",disabled:Dt,onClick:Tt,children:"Retry conversation"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ae&&e.sessionId&&Y.length===0?h.jsxDEV("p",{className:i("studio-chat-empty",n.empty),children:"Opening conversation…"},void 0,!1,void 0,this):null,!ie&&(!e.sessionId||!ae)&&Y.length===0?h.jsxDEV(ft,{},void 0,!1,void 0,this):null,Y.map((v)=>h.jsxDEV(ht,{message:v,client:s,disabled:F,speaker:"Your brain",reading:"manuscript",onAction:St,onApproval:he},v.id,!1,void 0,this)),B?.approvals.map((v)=>h.jsxDEV(pt,{approval:v,disabled:F,onDecision:he},v.approvalId,!1,void 0,this)),B&&B.progress.length>0&&h.jsxDEV("details",{className:i("studio-chat-progress",n.card),children:[h.jsxDEV("summary",{children:["Activity · ",B.progress.length," updates"]},void 0,!0,void 0,this),h.jsxDEV("pre",{className:i("",n.source),children:JSON.stringify(B.progress,null,2)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),F?h.jsxDEV("p",{className:i("studio-chat-stream-status",n.empty),role:"status",children:"Responding…"},void 0,!1,void 0,this):null,J&&h.jsxDEV(ke,{interrupted:J,draftPending:ve,restoreBlocked:F||b,onRestore:(v)=>{m(v.text),p([...v.uploads]),Ce.current?.closest(".studio-chat-thread")?.querySelector("textarea")?.focus()}},void 0,!1,void 0,this),G?h.jsxDEV("p",{className:i("studio-chat-error",n.empty,n.error),role:"alert",children:G},void 0,!1,void 0,this):null,h.jsxDEV("div",{},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),h.jsxDEV(ut,{above:be.length>0?h.jsxDEV("div",{"data-studio-chat-starters":"",className:i("studio-chat-starters",n.starters),"aria-label":"Ways to start",children:be.map((v)=>h.jsxDEV("button",{type:"button",className:i("",n.starter),onClick:()=>m(v),children:v},v,!1,void 0,this))},void 0,!1,void 0,this):void 0,onJumpToLatest:At?Pt:void 0,draft:f,sending:F,uploading:b,uploads:d,uploadAttempts:g,onRetryUpload:(v)=>void I([v]),onDismissUpload:c,onDraft:m,locked:ye||se.deleting,onRemoveUpload:(v)=>p((re)=>re.filter((Ht)=>Ht.id!==v)),onFiles:y,onSubmit:Bt,onStop:bt()?kt:void 0},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}export{io as StudioChatWorkspace};
2
2
 
3
3
  //# debugId=DDA31B743D948B5B64756E2164756E21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rizom/brain",
3
- "version": "0.2.0-alpha.844",
3
+ "version": "0.2.0-alpha.846",
4
4
  "description": "Brain runtime + CLI — scaffold, run, and manage AI brain instances",
5
5
  "keywords": [
6
6
  "brain",
@@ -1,5 +0,0 @@
1
- // @bun
2
- import{B as a}from"./index-pkjvv0ay.js";import"./index-e0qz6mam.js";import"./index-ygeeaab7.js";import"./index-dv4tqrbw.js";import"./index-590f2jt0.js";import"./index-s7mrb3rq.js";import"./index-0va9v6ve.js";import"./index-ky8tsadx.js";import"./index-gb5500kt.js";import"./index-r8mzr1hv.js";import"./index-cmk5se4p.js";export{a as App};
3
-
4
- //# debugId=B0224EA8233B0C3764756E2164756E21
5
- //# sourceMappingURL=app-kgqkeyte.js.map
@@ -1,4 +0,0 @@
1
- import{Qc as u,Wc as v,Xc as x,mc as s,pc as h}from"./main-qzww64vy.js";import{qf as y}from"./main-nbfatnag.js";import{Yf as i}from"./main-1ad1b2wa.js";var e={inset:{kLKAdn:"xijc0j3",kg3NbH:"x1tcxzho",k3VDzK:"xvl5zoi",kr1LIo:"xn3xmfv",$$css:!0},documentInset:{keoZOQ:"xseo6mj",kUOVxO:"x1i847zn",kcJqd2:"xg0897w",kLZkdG:"xhl984y",$$css:!0},root:{k1xSpc:"xrvj5dj",kOIVth:"x167g77z",kogj98:"x1ghz6dp",kGO01o:"x1hhzuzn",kt9PQ7:"xlxy82",kfdmCh:"x1q0q8m5",kL6WhQ:"x1594w68",kh9fTk:"xzuy7g3",$$css:!0},navigation:{kBCFzs:"x1osaytk",$$css:!0},hasAction:{kumcoG:"xju1xpo",$$css:!0},control:{kSGwAc:"xamitd3",kFhvOy:"x1qab1bc",k7Eaqz:"xeuugli",kCrP1I:"x1yagzmq",kV7FkP:"x1re7oy7",$$css:!0},row:{k1xSpc:"xrvj5dj",kumcoG:"x1mkdm3x",kGNEyG:"x1pha0wt",kOIVth:"x1v2ro7d",k7Eaqz:"xeuugli",kAzted:"x1gg8mnh",$$css:!0},copy:{k1xSpc:"x78zum5",kwnvtZ:"x1a02dak",kGNEyG:"x1pha0wt",kOIVth:"x1v2ro7d",k7Eaqz:"xeuugli",$$css:!0},titleGrow:{k1xSpc:"xrvj5dj",k5JduY:"x68pbbn",kVb13B:"x1snja1x",kMEsQN:"xx0cqyw",kduyaJ:"xajgrl3",kcTWDK:"xvikt2r",$$css:!0},titleInput:{k1xSpc:"x1lliihq",kJuA4N:"x1b1wf8y",kzqmXN:"xh8yej3",k7Eaqz:"xeuugli",kVQacm:"xb3r6kr",kHenm0:"xtt52l0",kHjlTd:"xj0a0fe",kogj98:"x1ghz6dp",kmVPX3:"x1717udv",kMzoRj:"xc342km",kaIpWk:"x12oqio5",kWkggS:"xjbqb8w",kMwMTN:"x1heor9g",kVVagm:"xln7xf2",ka26j:"xkyhvkk",kb6lSQ:"x4gjf66",kLWn49:"x15bjb6t",k8Qsv1:"x1wku8z5",kMeerF:"x784prv xcpyg62",k3XXqK:"x9v5kkp x19ahsqg",kjBf7l:"xxh1od1 x1iau5pp",kInvED:"x1hl8ikr",$$css:!0},titleIssue:{k1xSpc:"x1lliihq",keoZOQ:"x1k70j0n",kMwMTN:"x1mel2pz",kMv6JI:"x5ddh9m",kGuDYH:"x4z9k3i",k63SB2:"xo1l8bm",kb6lSQ:"x12oo3zp",$$css:!0},title:{k7Eaqz:"xeuugli",ks0D6T:"x193iq5w",kogj98:"x1ghz6dp",kMwMTN:"xqvuw85",kMv6JI:"xssy22x",kGuDYH:"xqozcyj",ka26j:"x17owtcr",k63SB2:"x1s688f",kb6lSQ:"x1w69ole",kLWn49:"x1159mfc",kHjlTd:"xj0a0fe",kr4CYY:"x13i2va0",kFKdQ1:"xc3hpf1",kHdLCk:"x5dg28r",kOqvnJ:"xmi8g4k",kN0ZIM:"x5ih01h",keaIxW:"xhmgfki",$$css:!0},metadata:{k1xSpc:"x78zum5",kwnvtZ:"x1a02dak",kGNEyG:"x6s0dn4",kOIVth:"x17d4w8g",kMwMTN:"x1ar3pfp",kGuDYH:"x1qt5hsa",kr4CYY:"xxgfmko",$$css:!0},phoneHidden:{k7Eaqz:"xeuugli",kHdLCk:"xkaaz9w",$$css:!0},phoneBarred:{kt9PQ7:"xlxy82 xg3gpzv",kGO01o:"x1hhzuzn xlw6zc2",$$css:!0},statusDetail:{kMwMTN:"x1ar3pfp",kMv6JI:"x5ddh9m",kGuDYH:"x1j6dyjg",kLWn49:"x1evy7pa",$$css:!0},facts:{k1xSpc:"x78zum5",kwnvtZ:"x1a02dak",kOIVth:"xhypsl1",kogj98:"x1ghz6dp",kmVPX3:"x1717udv",kB88ic:"xe8uvvx",kMwMTN:"x1ar3pfp",kMv6JI:"x5ddh9m",kGuDYH:"xif65rj",kr4CYY:"x1yzm3l3",$$css:!0},fact:{k1xSpc:"x3nfvp2",kGNEyG:"x6s0dn4",kOIVth:"x167g77z",$$css:!0},factMark:{kzqmXN:"x1xc55vz",kZKoxP:"xdk7pt",kmuXW:"x2lah0s",kaIpWk:"x16rqkct",kWkggS:"xtwfq29",$$css:!0},totals:{k1xSpc:"x78zum5",kwnvtZ:"x1a02dak",kOIVth:"x1v2ro7d",kogj98:"x1ghz6dp",$$css:!0},total:{k1xSpc:"x3nfvp2",kGNEyG:"x1pha0wt",kOIVth:"x1nejdyq",$$css:!0},totalLabel:{kMwMTN:"x1ar3pfp",kMv6JI:"x5ddh9m",kGuDYH:"x1j6dyjg",$$css:!0},totalValue:{kogj98:"x1ghz6dp",kMwMTN:"xqvuw85",kMv6JI:"xa9opjo",kGuDYH:"xfifm61",k63SB2:"x1s688f",$$css:!0},action:{kVAEAm:"x1n2onr6",kY2c9j:"xoegz02",koQZXg:"x8x9d4c",ks0D6T:"x193iq5w",kmuXW:"x2lah0s",kKwN1N:"x1pyp8la",kKq9zD:"xfl54mv",kRugJJ:"x13bo2ae",kpC6i:"xb8kata",kfD2x5:"xoco0x4",ku5HWf:"xlpsox",kfX6GZ:"x170sw7g",kp4SAw:"x1ynha1y",$$css:!0}};var m={body:{kUk6DE:"x98rzlu",kAzted:"x2lwn1j",k1xSpc:"xrvj5dj",kGNEyG:"x1qjc9v5",k9llMU:"x5o4joa",kRnz6y:"x13me3c",k9pwkU:"xch1w8t x8mpkbv",kSQbcb:"x1mgqk5d",keaIxW:"x7zq708 x1sqw5yv",$$css:!0},editor:{k1xSpc:"xrvj5dj",kumcoG:"x1q0n783 x1l1zzp x1efj4vi x4jmfmw",k9llMU:"xxq7klm",kAzted:"x2lwn1j",k7Eaqz:"xeuugli",k9pwkU:"x1y6iwit",keaIxW:"xhmgfki",$$css:!0},head:{kBCFzs:"x1osaytk",kbNqZ1:"x1ms6mhf",$$css:!0},colophon:{kBCFzs:"x1npkx4u x1gw0dv9",kbNqZ1:"x7sv70a",kAzted:"x2lwn1j",k7Eaqz:"xeuugli",kORKVm:"x1odjw0f",kZ1KPB:"xe0pwq",k4WBpm:"x19ypqd9",kaZRDh:"xlsyykk",k1xSpc:"x1tugbw3 x1idufoc",kWkggS:"xbslqsl",kmVPX3:"xga4tv",kubnTK:"x1llo3lq",kOLLwu:"x4pt66b",kU6wY8:"xnoo4qv",kRugJJ:"x1pvtvnk",kq8Ghq:"x171z6dy",$$css:!0},detailsSheet:{kVAEAm:"x12u6v07",kbCHJM:"x172uiah",kCIrl2:"x106zgql",krVfgx:"x1imafyg",kY2c9j:"x1u2u1qb",kskxy:"x13cfglm",kORKVm:"x1odjw0f xscgqpg",kZeWKH:"xg0x1tt",kIxVMA:"x126vn7o",ksF3WI:"x1abwb35",kLKAdn:"x9desvi x1vy0343",kGO01o:"xefzj8c xw27878",kGVxlE:"x12br0k5",$$css:!0},fullWidthProperties:{kBCFzs:"x1osaytk",kZ1KPB:"xyj58a3",$$css:!0},fields:{kMzoRj:"xc342km",kogj98:"x1ghz6dp",kmVPX3:"x1717udv",k7Eaqz:"xeuugli",$$css:!0},manuscript:{k1xSpc:"x78zum5",kXwgrk:"xdt5ytf",kBCFzs:"xgkxs2y",kbNqZ1:"x7sv70a",kAzted:"x2lwn1j",k7Eaqz:"xeuugli",k9g6sI:"x12h1iku",kWkggS:"x18s3upu",kRnz6y:"x13me3c",kCrP1I:"x1gw0dv9",kU6wY8:"xnoo4qv",kKq9zD:"xscgqpg",kHdLCk:"x1ux6vrq",$$css:!0},colophonHidden:{k1xSpc:"x1s85apg",$$css:!0},inspectorToggle:{k1xSpc:"xkaaz9w",$$css:!0},pipeline:{kBCFzs:"x1osaytk",kbNqZ1:"xz51j44",kVAEAm:"x1n2onr6",k1xSpc:"x78zum5",kGNEyG:"x6s0dn4",kOIVth:"x1v2ro7d",kwnvtZ:"x1a02dak",kmVPX3:"xxmtint",kAzted:"xvkrg5o",kEmTf6:"x1anjdel",kBoZxP:"xj3o16p",kCrP1I:"x1gw0dv9",kU6wY8:"x1dhnagk",kHdLCk:"x10acg2q",k1JLwA:"x1lk34zc",kLyoy9:"x1d3ddqg",kTWfjk:"xiyjfb3",kRugJJ:"x11btecl",kLZC3w:"xvg7k2t",kWkggS:"x18s3upu x1r2i3kv",$$css:!0},detailsToggle:{k1xSpc:"x1s85apg x13v5x0x",kAzted:"x1gg8mnh",$$css:!0},saveState:{k1xSpc:"x78zum5",kwnvtZ:"x1a02dak",kGNEyG:"x1pha0wt",k1C7PZ:"x1amjocr",khm7nJ:"x1dbijih",$$css:!0},compactStatus:{k1xSpc:"x1s85apg xdsa2pc xfsj286 xbuh8fq",k7Eaqz:"xeuugli",kVQacm:"xb3r6kr",kMwMTN:"xulty9s x15g7g0v",kMv6JI:"xa9opjo",kGuDYH:"xdzlmae",kb6lSQ:"x2ujxvm",kLWn49:"x1xfvgam",kg5iWk:"xlyipyv",khDVqt:"xuxw1ft",$$css:!0},compactValue:{k1xSpc:"x1lliihq",kVQacm:"xb3r6kr",kMwMTN:"x19k5i5u",kGuDYH:"xvwhms9",kg5iWk:"xlyipyv",$$css:!0}};var f=i(y(),1);var r=i(y(),1),k=null,c=new Set;function p(){for(let t of c)t()}function w(t){return c.add(t),()=>{c.delete(t)}}function I(){return r.useSyncExternalStore(w,()=>k?.content??null,()=>null)}function g(t,o){r.useLayoutEffect(()=>{if(!o)return;return k={owner:t,content:o},p(),()=>{if(k?.owner!==t)return;k=null,p()}})}var a=i(h(),1);function q(t){switch(t){case"public":return{kind:"session",label:"Signed in"};case"trusted":return{kind:"permission",label:"Trusted"};case"admin":return{kind:"permission",label:"Admin only"}}}function R(t){let o=t.model.metadata?.slice(0,4)??[],l=t.model.totals.slice(0,4),[S]=f.useState(()=>Symbol("page head")),b=t.appearance!=="document";g(S,b?{title:t.model.title,...t.back?{back:t.back}:{},...t.action?{action:t.action}:{}}:null);let z=o.length===0&&!t.model.status&&l.length===0&&!t.model.facts?.length&&!t.control;if(t.appearance==="document")return a.jsxDEV("header",{className:x("studio-page-head",e.root,e.row,Boolean(t.action)&&e.hasAction,e.documentInset,m.head,!t.titleEditor&&e.phoneHidden),"data-studio-page-head":"true","data-has-status":"false","data-has-totals":"false",children:[t.navigation?a.jsxDEV("nav",{"aria-label":"Collection navigation",...s(e.navigation,e.phoneHidden),children:t.navigation},void 0,!1,void 0,this):null,a.jsxDEV("div",{...s(e.copy),children:a.jsxDEV("h1",{className:x("",e.title),children:t.titleEditor??t.model.title},void 0,!1,void 0,this)},void 0,!1,void 0,this),t.action?a.jsxDEV("div",{className:x("studio-page-head-action",e.action,e.phoneHidden),children:t.action},void 0,!1,void 0,this):null]},void 0,!0,void 0,this);return a.jsxDEV("header",{className:x("studio-page-head",e.root,e.phoneBarred,z&&e.phoneHidden),"aria-description":t.model.description,"data-studio-page-head":"true","data-studio-head-barred":"","data-has-status":t.model.status?"true":"false","data-has-totals":l.length>0?"true":"false",children:[t.navigation?a.jsxDEV("nav",{"aria-label":"Collection navigation",...s(e.navigation),children:t.navigation},void 0,!1,void 0,this):null,a.jsxDEV("div",{className:x("studio-page-head-title-row",e.row,Boolean(t.action??t.control)&&e.hasAction),children:[a.jsxDEV("div",{...s(e.copy),children:[a.jsxDEV("h1",{...s(e.title,e.phoneHidden),children:t.titleEditor??t.model.title},void 0,!1,void 0,this),o.length>0&&a.jsxDEV("div",{className:x("studio-page-head-metadata",e.metadata),children:o.map((n,d)=>a.jsxDEV("span",{...s(d>0&&e.phoneHidden),children:[d>0&&a.jsxDEV("span",{"aria-hidden":"true",children:"· "},void 0,!1,void 0,this),n]},`${n}:${d}`,!0,void 0,this))},void 0,!1,void 0,this),t.model.status&&a.jsxDEV("span",{className:x("studio-head-status",v.status,u(t.model.status.tone),l.length>0&&e.phoneHidden),"data-tone":t.model.status.tone??"neutral",children:[t.model.status.label,t.model.status.detail&&a.jsxDEV("small",{...s(e.statusDetail),children:t.model.status.detail},void 0,!1,void 0,this)]},void 0,!0,void 0,this),l.length>0&&a.jsxDEV("dl",{className:x("studio-page-head-totals",e.totals),children:l.map((n,d)=>a.jsxDEV("div",{"data-tone":n.tone??"neutral",...s(e.total,d>0&&n.tone!=="warn"&&n.tone!=="error"&&e.phoneHidden),children:[a.jsxDEV("dt",{...s(e.totalLabel),children:n.label},void 0,!1,void 0,this),a.jsxDEV("dd",{...s(e.totalValue,u(n.tone)),children:n.value},void 0,!1,void 0,this)]},`${n.label}:${d}`,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t.control&&a.jsxDEV("div",{...s(e.control),"data-studio-head-control":"",children:t.control},void 0,!1,void 0,this),t.action&&a.jsxDEV("div",{className:x("studio-page-head-action",e.action,e.phoneHidden),"data-studio-primary-action":"true","data-operator-action-popover":"",children:t.action},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t.model.facts&&t.model.facts.length>0&&a.jsxDEV("ul",{"aria-label":"Status",...s(e.facts),children:t.model.facts.map((n,d)=>a.jsxDEV("li",{"data-tone":n.tone??"neutral",...s(e.fact),children:[a.jsxDEV("span",{"aria-hidden":"true",...s(e.factMark,u(n.tone))},void 0,!1,void 0,this),n.label]},`${n.label}:${d}`,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function O(t,o){return{...o.kicker?{kicker:o.kicker}:{},access:q(t.permission),title:o.title??t.label,...o.description?{description:o.description}:{},...o.status?{status:o.status}:{},...o.facts?.length?{facts:o.facts}:{},totals:[],...o.primaryAction?{primaryAction:o.primaryAction}:{}}}
2
- export{e as fc,m as gc,I as hc,g as ic,q as jc,R as kc,O as lc};
3
-
4
- //# debugId=D68A38F24A67D2EA64756E2164756E21