@rubytech/create-maxy 1.0.725 → 1.0.727
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.
|
@@ -345,7 +345,7 @@ ${JSON.stringify(u.input,null,2)}
|
|
|
345
345
|
|
|
346
346
|
Result:
|
|
347
347
|
${a.output}`:`Input:
|
|
348
|
-
${JSON.stringify(u.input,null,2)}`,f=se.get(r),p=o?void 0:f??t;return(0,R.jsx)(_E,{icon:l,isPending:o,isError:c,doneClass:u.name===`Read`?`tl-done`:`tl-success`,summary:uE(u.name,u.input),detail:d,tokens:mE(n),elapsed:k(r,p),isLast:s,expanded:i===void 0?_.has(r):i,onToggle:()=>O(r),selectCheck:ee(r)},r)}if(n.type===`subagent_start`){let t=n,a=e.some(e=>e.type===`subagent_end`&&e.name===t.name),o=a?e.findIndex(e=>e.type===`subagent_end`&&e.name===t.name):void 0,c=t.background===!0,l=t.task.slice(0,60)+(t.task.length>60?`…`:``),u=t.task;if(c&&!a){let n=[...e].reverse().find(e=>e.type===`subagent_progress`&&e.name===t.name);n?.last_tool_name&&(u=`${t.task}\nLast tool: ${n.last_tool_name} (${n.tool_uses??0} calls)`)}let d=a?e.find(e=>e.type===`subagent_end`&&e.name===t.name):void 0,f=a&&d?nE.test(d.result):!1;return(0,R.jsx)(_E,{icon:a?f?(0,R.jsx)(he,{size:11}):(0,R.jsx)(xe,{size:11}):(0,R.jsx)(Ge,{size:11,className:`tl-spinner`}),isPending:!a,isError:f,summary:c?`${t.name} (background) — ${l}`:`${t.name} — ${l}`,detail:c?u:t.task,tokens:mE(n),elapsed:k(r,o),isLast:s,expanded:i===void 0?_.has(r):i,onToggle:()=>O(r),selectCheck:ee(r)},r)}if(n.type===`component`){let e=l?.has(`${u}_${r}`)??!1,i=n;return(0,R.jsxs)(`div`,{className:`tl-step`,children:[ee(r),(0,R.jsxs)(`div`,{className:`tl-col`,children:[(0,R.jsx)(`div`,{className:`tl-icon ${e?`tl-done`:`tl-pending`}`,children:(0,R.jsx)(Ze,{size:11})}),!s&&(0,R.jsx)(`div`,{className:`tl-line tl-line-grow`})]}),(0,R.jsx)(`div`,{className:`tl-body`,children:(0,R.jsx)(tE,{name:i.name,data:i.data,submitted:e,onSubmit:e=>c?.(r,e,i.name),isStreaming:t,sessionKey:g})})]},r)}if(n.type===`subagent_end`){let e=n,t=nE.test(e.result);return(0,R.jsx)(_E,{icon:t?(0,R.jsx)(he,{size:11}):(0,R.jsx)(h,{size:11}),isPending:!1,isError:t,summary:`${e.name} ${t?`failed`:`complete`}`,detail:e.result,tokens:mE(n),elapsed:k(r,se.get(r)),isLast:s,expanded:i===void 0?_.has(r):i,onToggle:()=>O(r),selectCheck:ee(r)},r)}if(n.type===`script_stream`){let e=n,t=e.line.match(/https:\/\/dash\.cloudflare\.com\/argotunnel\?[^\s]+/)?.[0],i=t?JSON.stringify({url:t,intent:`Cloudflare tunnel authorization`}):void 0;return(0,R.jsxs)(`div`,{className:`tl-script-stream`,children:[(0,R.jsxs)(`div`,{className:`tl-script-stream-line`,children:[(0,R.jsxs)(`span`,{className:`tl-script-stream-source`,children:[`[`,e.source,`]`]}),(0,R.jsx)(`span`,{className:`tl-script-stream-content`,children:e.line})]}),i&&(0,R.jsx)(x,{source:i})]},r)}return null}return(0,R.jsxs)(`div`,{className:`admin-activity`,children:[ue&&!t&&i===void 0&&(0,R.jsx)(`div`,{className:`tl-steps`,children:(0,R.jsxs)(`div`,{className:`tl-step tl-summary-row`,onClick:()=>{window.getSelection()?.toString()||b(e=>!e)},children:[(0,R.jsx)(`div`,{className:`tl-col`,children:(0,R.jsx)(`div`,{className:`tl-icon tl-done`,children:ce.hasThinking?(0,R.jsx)(He,{size:11}):(0,R.jsx)(h,{size:11})})}),(0,R.jsx)(`div`,{className:`tl-body`,children:(0,R.jsxs)(`div`,{className:`tl-row`,style:{cursor:`pointer`},children:[(0,R.jsx)(`span`,{className:`tl-summary`,children:ce.text}),ce.tokenSum>0&&(0,R.jsxs)(`span`,{className:`tl-step-tokens`,children:[(0,R.jsx)(ct,{size:9}),pE(ce.tokenSum)]}),(0,R.jsx)(`span`,{className:`tl-step-elapsed`,children:hE(n)}),(0,R.jsx)(`span`,{className:`tl-chevron`,children:y?(0,R.jsx)(Ce,{size:10}):(0,R.jsx)(p,{size:10})})]})})]})}),me.map((e,n)=>e.role===`steps`?!t&&i===void 0&&y?null:(0,R.jsx)(`div`,{className:`tl-steps`,children:e.items.map(({e:t,i:n},r)=>ye(t,n,e.items,r))},`seg-${n}`):e.items.map(({e,i:n})=>{let r=e,i=n===ve;return(0,R.jsxs)(`div`,{className:`tl-text-block`,onClick:d&&!t&&u?()=>m?.(`${u}_${n}`):void 0,style:d&&!t?{cursor:`pointer`}:void 0,children:[ee(n),(0,R.jsx)(te,{content:r.content,timestamp:!t&&i&&u?rE(u):void 0})]},n)})),t&&!de&&(0,R.jsxs)(`div`,{className:`tl-loading`,children:[(0,R.jsx)(aE,{size:13}),(0,R.jsx)(lE,{}),(0,R.jsx)(`span`,{className:`tl-elapsed`,children:hE(n)})]}),!t&&N.size>0&&(0,R.jsx)(`div`,{className:`tl-post-components`,children:e.map((e,t)=>({e,i:t})).filter(({i:e})=>N.has(e)).map(({e,i:n})=>{if(e.type!==`component`)return null;let r=l?.has(`${u}_${n}`)??!1;return(0,R.jsx)(tE,{name:e.name,data:e.data,submitted:r,onSubmit:t=>c?.(n,t,e.name),isStreaming:t,sessionKey:g},n)})}),(de||!t&&ue)&&(0,R.jsxs)(`div`,{className:`tl-footer`,children:[t&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(aE,{size:10}),(0,R.jsx)(lE,{})]}),(0,R.jsxs)(`span`,{className:`tl-footer-icon-stat`,children:[(0,R.jsx)(Ee,{size:10}),hE(n)]}),ne?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`tl-footer-sep`,children:`·`}),(0,R.jsxs)(`span`,{className:`tl-footer-icon-stat`,children:[(0,R.jsx)(ct,{size:10}),pE(ne.input_tokens+ne.cache_creation_tokens+ne.cache_read_tokens+ne.output_tokens)]})]}):t&&ce.tokenSum>0?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`tl-footer-sep`,children:`·`}),(0,R.jsxs)(`span`,{className:`tl-footer-icon-stat tl-footer-est`,children:[(0,R.jsx)(ct,{size:10}),`~`,pE(ce.tokenSum)]})]}):null,re&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`tl-footer-sep`,children:`·`}),(0,R.jsxs)(`span`,{className:`tl-footer-icon-stat tl-ctx-pct${re.budget>0&&re.tokens/re.budget>=.7?` tl-ctx-high`:re.budget>0&&re.tokens/re.budget>=.5?` tl-ctx-mid`:``}`,children:[(0,R.jsx)(Je,{size:10}),re.messages]})]}),s?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`tl-footer-sep`,children:`·`}),(0,R.jsxs)(`span`,{className:`tl-footer-icon-stat tl-ctx-compacted`,children:[(0,R.jsx)(_e,{size:10}),`compacted`]})]}):le===null?null:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`tl-footer-sep`,children:`·`}),!s&&a&&!t?(0,R.jsxs)(w,{variant:`ghost`,size:`sm`,className:`tl-footer-icon-stat tl-ctx-pct${le>=70?` tl-ctx-high`:le>=50?` tl-ctx-mid`:``}`,style:{padding:0,fontSize:`11px`},onClick:a,children:[(0,R.jsx)(_e,{size:10}),le,`%`]}):(0,R.jsxs)(`span`,{className:`tl-footer-icon-stat tl-ctx-pct${le>=70?` tl-ctx-high`:le>=50?` tl-ctx-mid`:``}`,children:[(0,R.jsx)(_e,{size:10}),le,`%`]})]}),o||t&&ie?(0,R.jsxs)(`span`,{className:`tl-footer-status`,children:[(0,R.jsx)(Ge,{size:10,className:`tl-spinner`}),ie?.message??`Compacting session...`]}):null]})]})}function yE(e){let{messages:t,isStreaming:n,elapsedSeconds:r,sessionTurnStart:i,expandAll:a,setExpandAll:o,conversationCompacted:s,isCompacting:l,setShowCompactConfirm:u,handleComponentSubmit:d,effectiveSubmitted:f,selectionMode:m,selectedItems:h,toggleSelectItem:g,sessionKey:_,setLightboxSrc:y,messageQueue:b,messageQueueRef:x,setQueue:S,sendMessage:C,appState:w,onboardingComplete:T}=e,D=(0,L.useRef)(null),O=(0,L.useRef)(null),k=(0,L.useRef)(null),A=(0,L.useRef)(!1),[j,M]=L.useState(!0);(0,L.useEffect)(()=>{if(!j){A.current=n;return}if(A.current&&!n&&k.current&&O.current){let e=k.current;if(e.offsetHeight>O.current.clientHeight){e.scrollIntoView({behavior:`smooth`,block:`start`}),A.current=n;return}}D.current?.scrollIntoView({behavior:`smooth`}),A.current=n},[t,b,j,n]),(0,L.useEffect)(()=>{if(w!==`chat`)return;let e=O.current;if(!e)return;let t=()=>{M(e.scrollHeight-e.scrollTop-e.clientHeight<80)};return e.addEventListener(`scroll`,t,{passive:!0}),t(),()=>e.removeEventListener(`scroll`,t)},[w]);let N=[...t].sort((e,t)=>(e.timestamp??0)-(t.timestamp??0)),P=N.reduce((e,t,n)=>t.role===`maxy`&&!t.hidden?n:e,-1);return(0,R.jsxs)(`div`,{className:`chat-messages-wrap`,children:[m&&(0,R.jsx)(`div`,{className:`selection-overlay-band`}),(0,R.jsxs)(`div`,{className:`chat-messages`,ref:O,children:[t.length===0&&w===`chat`&&T!==!1&&(0,R.jsxs)(`div`,{className:`idle-tips`,children:[(0,R.jsx)(`p`,{className:`idle-tips-hint`,children:`What would you like to do?`}),(0,R.jsx)(`div`,{className:`idle-tips-chips`,children:[`What needs doing?`,`Start a new task`].map(e=>(0,R.jsx)(`button`,{type:`button`,className:`idle-tip-chip`,onClick:()=>C(e),children:e},e))})]}),N.map((e,t,o)=>{if(e.hidden)return null;let p=n&&t===o.length-1,b=e.role,x=`${e.timestamp??0}_admin`,S=b===`admin`&&h.has(x),C=(t>0?o[t-1]:null)?.historical&&!e.historical;return(0,R.jsxs)(L.Fragment,{children:[C&&(0,R.jsx)(`div`,{className:`resume-divider`,children:(0,R.jsx)(`span`,{children:`Resumed conversation`})}),(0,R.jsxs)(`div`,{ref:t===P?k:void 0,className:`message ${b===`admin`?`visitor`:`maxy`}${S?` selected`:``}${e.historical?` message-historical`:``}`,children:[m&&!p&&b===`admin`&&(0,R.jsx)(`div`,{className:`message-select-check`,children:(0,R.jsx)(ge,{checked:S,onChange:()=>g(x)})}),e.role===`admin`?(0,R.jsxs)(`div`,{className:`bubble`,children:[e.content,e.attachments&&e.attachments.length>0&&(0,R.jsx)(`div`,{className:`message-attachments`,children:e.attachments.map((e,t)=>(0,R.jsxs)(`button`,{type:`button`,className:`message-attachment-chip${e.attachmentId&&_?``:` no-action`}`,onClick:()=>{if(!e.attachmentId||!_)return;let t=`/api/admin/attachment/${e.attachmentId}?session_key=${encodeURIComponent(_)}`;e.mimeType.startsWith(`image/`)?y(t):window.open(t,`_blank`)},children:[e.mimeType===`application/pdf`?(0,R.jsx)(c,{size:12}):e.mimeType.startsWith(`text/`)?(0,R.jsx)(E,{size:12}):null,(0,R.jsx)(`span`,{children:e.filename})]},t))}),(0,R.jsx)(`span`,{className:`message-timestamp`,children:v(e.timestamp)})]}):(0,R.jsx)(`div`,{className:`maxy-content-wrap`,children:(0,R.jsx)(vE,{events:e.events??[],isStreaming:p,elapsedSeconds:t===o.length-1?r:e.elapsedSeconds??0,streamStartMs:t===o.length-1?i.current??void 0:void 0,expandAll:a,onCompactNow:t===o.length-1&&!s?()=>u(!0):void 0,isCompacting:t===o.length-1?l:void 0,sessionCompacted:t===o.length-1?s:void 0,onComponentSubmit:(t,n,r)=>d(e.timestamp,t,n,r),submittedComponents:f,timestamp:e.timestamp,selectionMode:m,selectedItems:h,onToggleItem:g,sessionKey:_})})]})]},t)}),b.map((e,t)=>(0,R.jsx)(`div`,{className:`message visitor`,children:(0,R.jsxs)(`div`,{className:`bubble bubble-queued`,children:[e.text||null,e.files.length>0&&(0,R.jsx)(`div`,{className:`message-attachments`,children:e.files.map((e,t)=>(0,R.jsxs)(`span`,{className:`message-attachment-chip no-action`,children:[e.type===`application/pdf`?(0,R.jsx)(c,{size:12}):e.type.startsWith(`text/`)?(0,R.jsx)(E,{size:12}):null,(0,R.jsx)(`span`,{children:e.name})]},t))}),(0,R.jsx)(`span`,{className:`message-timestamp`,children:v(e.timestamp)}),(0,R.jsx)(`button`,{type:`button`,className:`queued-bubble-delete`,onClick:()=>S(x.current.filter((e,n)=>n!==t)),"aria-label":`Remove queued message`,children:`×`})]})},e.timestamp)),(0,R.jsx)(`div`,{ref:D})]}),!j&&(0,R.jsx)(`button`,{className:`scroll-to-bottom`,onClick:()=>D.current?.scrollIntoView({behavior:`smooth`}),"aria-label":`Scroll to bottom`,children:(0,R.jsx)(p,{size:18})}),t.some(e=>e.role===`maxy`)&&(0,R.jsx)(`button`,{className:`expand-toggle expand-toggle-${a===void 0?`default`:a?`all`:`off`}`,onClick:()=>o(e=>e===void 0?!0:e===!0?!1:void 0),"aria-label":a===void 0?`Expand all`:a?`Collapse all`:`Reset to default`,children:a===!1?(0,R.jsx)(Ve,{size:14}):(0,R.jsx)(He,{size:14})})]})}function bE({offer:e,onFreshStart:t,onContinue:n,disabled:r}){return e.active?(0,R.jsxs)(`div`,{className:`topic-change-bar`,children:[(0,R.jsx)(`div`,{className:`topic-change-bar__icon`,children:(0,R.jsx)(Le,{size:16})}),(0,R.jsxs)(`div`,{className:`topic-change-bar__actions`,children:[(0,R.jsx)(w,{variant:`primary`,size:`sm`,onClick:t,disabled:r,children:`Start fresh`}),(0,R.jsx)(w,{variant:`ghost`,size:`sm`,onClick:n,disabled:r,children:`Continue here`})]})]}):null}var xE=[{type:`stream`,label:`Stream`},{type:`error`,label:`Errors`},{type:`sse`,label:`SSE`}];function SE(e,t){return e.conversationId?`/api/admin/logs?type=${t}&conversationId=${encodeURIComponent(e.conversationId)}`:e.sessionKey?`/api/admin/logs?type=${t}&sessionKey=${encodeURIComponent(e.sessionKey)}`:`/api/admin/logs?type=${t}`}function CE(e){let{show:t,onClose:n,conversationsLoading:r,conversationsError:a,conversationsList:o,setConversationsList:s,sessionKey:l,isStreaming:u,resetConversation:d,setMessages:f,setConversationId:p}=e,[m,g]=(0,L.useState)(null),[v,y]=(0,L.useState)(null),[b,x]=(0,L.useState)(``),[S,C]=(0,L.useState)(!1),w=(0,L.useRef)(null),[T,E]=(0,L.useState)(null),[D,O]=(0,L.useState)(null),[k,A]=(0,L.useState)(null),j=(0,L.useRef)(null),M=(0,L.useRef)(null),N=(0,L.useRef)(null);(0,L.useEffect)(()=>{t||(g(null),y(null),x(``),C(!1),E(null),O(null),A(null),j.current&&=(clearTimeout(j.current),null),M.current&&=(clearTimeout(M.current),null))},[t]),(0,L.useEffect)(()=>{if(!T)return;function e(e){let t=e.target;t&&N.current?.contains(t)||t&&t.closest?.(`.conversations-logs`)||E(null)}function t(e){e.key===`Escape`&&E(null)}return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[T]),(0,L.useEffect)(()=>{v?.phase===`editing`&&(w.current?.focus(),w.current?.select())},[v]);function P(){g(null),y(null),x(``),C(!1)}async function ee(e){if(l){P(),g(e),y({phase:`loading`});try{let t=await fetch(`/api/admin/sessions/${encodeURIComponent(e)}/label?session_key=${encodeURIComponent(l)}`,{method:`POST`});if(!t.ok){y({phase:`error`,reason:(await t.json().catch(()=>({}))).error||`Request failed`});return}let n=await t.json();n.label?(y({phase:`editing`}),x(n.label)):y({phase:`error`,reason:`Not enough message content to suggest a name`})}catch(e){console.error(`[admin-modal] label suggestion failed:`,e),y({phase:`error`,reason:e instanceof Error?e.message:String(e)})}}}async function te(e){if(!(!l||!b.trim()||S)){C(!0);try{let t=await fetch(`/api/admin/sessions/${encodeURIComponent(e)}/label`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({label:b.trim(),session_key:l})});if(!t.ok){y({phase:`error`,reason:(await t.json().catch(()=>({}))).error||`Rename failed`}),C(!1);return}s(t=>t.map(t=>t.conversationId===e?{...t,name:b.trim()}:t)),P()}catch(e){console.error(`[admin-modal] label rename failed:`,e),y({phase:`error`,reason:e instanceof Error?e.message:String(e)}),C(!1)}}}function ne(e,t,n){if(T?.rowId===e){E(null);return}let r=n.getBoundingClientRect();E({rowId:e,conversationId:t.conversationId,sessionKey:t.sessionKey,top:r.bottom+4,right:Math.max(8,window.innerWidth-r.right)})}async function re(e){await ie(e)?(O(e),A(null),j.current&&clearTimeout(j.current),j.current=setTimeout(()=>O(null),1500)):(A(e),O(null),M.current&&clearTimeout(M.current),M.current=setTimeout(()=>A(null),1500))}return t?(0,R.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,R.jsxs)(`div`,{className:`claude-info-modal conversations-modal`,onClick:e=>e.stopPropagation(),children:[(0,R.jsxs)(`div`,{className:`claude-info-header`,children:[(0,R.jsx)(We,{size:12}),`Conversations`,(0,R.jsx)(`button`,{className:`claude-info-close`,onClick:n,children:`✕`})]}),(0,R.jsxs)(`div`,{className:`conversations-list`,children:[r&&(0,R.jsxs)(`div`,{className:`conversations-empty`,children:[(0,R.jsx)(oe,{size:14,className:`spin`}),` Loading…`]}),a&&(0,R.jsx)(`div`,{className:`conversations-empty conversations-error`,children:a}),!r&&!a&&o.length===0&&(0,R.jsx)(`div`,{className:`conversations-empty`,children:`No recent conversations`}),!r&&!a&&o.map(e=>{let t=e.conversationId??e.sessionKey??``,r=e.phase===`pre-flush`,a=!r&&m===e.conversationId,o=a&&v?.phase===`loading`,g=a&&v?.phase===`editing`,y=a&&v?.phase===`error`,C=e.conversationId??e.sessionKey??``;return(0,R.jsxs)(`div`,{className:`conversations-row${r?` conversations-row-pre-flush`:``}`,children:[(0,R.jsxs)(`div`,{className:`conversations-row-info`,children:[o&&(0,R.jsxs)(`span`,{className:`conversations-row-name conversations-edit-loading`,children:[(0,R.jsx)(oe,{size:12,className:`spin`}),` Generating suggestion…`]}),g&&(0,R.jsxs)(`div`,{className:`conversations-edit-inline`,children:[(0,R.jsx)(`input`,{ref:w,type:`text`,className:`conversations-edit-input`,value:b,onChange:e=>x(e.target.value),onKeyDown:t=>{t.key===`Enter`&&b.trim()&&te(e.conversationId),t.key===`Escape`&&P()},maxLength:200}),(0,R.jsx)(`button`,{type:`button`,className:`conversations-action conversations-confirm`,title:`Confirm rename`,disabled:!b.trim()||S,onClick:()=>te(e.conversationId),children:S?(0,R.jsx)(oe,{size:13,className:`spin`}):(0,R.jsx)(h,{size:13})}),(0,R.jsx)(`button`,{type:`button`,className:`conversations-action conversations-cancel`,title:`Cancel`,onClick:P,children:(0,R.jsx)(he,{size:13})})]}),y&&(0,R.jsxs)(`div`,{className:`conversations-edit-inline`,children:[(0,R.jsx)(`span`,{className:`conversations-edit-error`,children:v.reason}),(0,R.jsx)(`button`,{type:`button`,className:`conversations-action conversations-retry`,title:`Retry`,onClick:()=>ee(e.conversationId),children:(0,R.jsx)(me,{size:13})}),(0,R.jsx)(`button`,{type:`button`,className:`conversations-action conversations-cancel`,title:`Cancel`,onClick:P,children:(0,R.jsx)(he,{size:13})})]}),!a&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`span`,{className:`conversations-row-name`,children:[e.name||(r?`session ${C.slice(0,12)}…`:C.slice(0,12)+`…`),r&&(0,R.jsx)(`span`,{className:`conversations-row-phase-badge`,title:`Pre-flush — conversation not yet persisted`,children:`pre-flush`})]}),(0,R.jsxs)(`span`,{className:`conversations-row-meta`,children:[(0,R.jsx)(`button`,{type:`button`,className:`conversations-row-id${D===t?` copied`:``}${k===t?` copy-failed`:``}`,title:C,"aria-label":r?`Copy session key ${C}`:`Copy conversation id ${C}`,onClick:e=>{e.stopPropagation(),re(t)},children:D===t?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(h,{size:10}),` copied`]}):k===t?`copy failed`:C.slice(0,8)}),(0,R.jsxs)(`span`,{className:`conversations-row-time`,children:[(0,R.jsx)(Ee,{size:10}),(()=>{try{let t=new Date(e.updatedAt),n=Date.now()-t.getTime();return n<6e4?`just now`:n<36e5?`${Math.floor(n/6e4)}m ago`:n<864e5?`${Math.floor(n/36e5)}h ago`:`${Math.floor(n/864e5)}d ago`}catch{return``}})()]})]})]})]}),(0,R.jsx)(`div`,{className:`conversations-row-actions`,children:!a&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,className:`conversations-action conversations-logs`,title:r?`View pre-flush logs`:`View logs`,"aria-haspopup":`menu`,"aria-expanded":T?.rowId===t,onClick:n=>{n.stopPropagation(),ne(t,{conversationId:e.conversationId,sessionKey:e.sessionKey},n.currentTarget)},children:(0,R.jsx)(c,{size:13})}),!r&&e.conversationId&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,className:`conversations-action conversations-rename`,title:`Rename conversation`,onClick:()=>ee(e.conversationId),children:(0,R.jsx)(Qe,{size:13})}),(0,R.jsx)(`button`,{type:`button`,className:`conversations-action conversations-play`,title:`Resume conversation`,disabled:u,onClick:()=>{u||!l||(n(),d(),fetch(`/api/admin/sessions/${encodeURIComponent(e.conversationId)}/resume?session_key=${encodeURIComponent(l)}`,{method:`POST`}).then(e=>e.ok?e.json():Promise.reject(Error(`Failed to resume conversation`))).then(e=>{e.conversationId&&p(e.conversationId);let t=(e.messages??[]).map(e=>({role:e.role===`user`?`admin`:`maxy`,content:e.role===`user`?e.content:void 0,events:e.role===`assistant`?[{type:`text`,content:e.content}]:void 0,timestamp:new Date(e.createdAt).getTime()||0,historical:!0}));t.length>0&&f(t)}).catch(e=>{console.error(`[chat] conversation resume failed:`,e),f([{role:`maxy`,events:[{type:`text`,content:`Could not load conversation history.`}],timestamp:Date.now()-1,historical:!0}])}))},children:(0,R.jsx)(_,{size:13})}),(0,R.jsx)(`button`,{type:`button`,className:`conversations-action conversations-delete`,title:`Delete conversation`,onClick:()=>{s(t=>t.filter(t=>t.conversationId!==e.conversationId)),l&&fetch(`/api/admin/sessions/${encodeURIComponent(e.conversationId)}?session_key=${encodeURIComponent(l)}`,{method:`DELETE`}).catch(e=>console.error(`[chat] conversation delete failed:`,e))},children:(0,R.jsx)(i,{size:13})})]})]})})]},t)})]}),T&&(0,R.jsx)(`div`,{ref:N,className:`conversations-logs-popover`,role:`menu`,style:{top:T.top,right:T.right},children:xE.map(({type:e,label:t})=>(0,R.jsxs)(`a`,{role:`menuitem`,className:`conversations-logs-popover-item`,href:SE({conversationId:T.conversationId,sessionKey:T.sessionKey},e),target:`_blank`,rel:`noopener noreferrer`,onClick:()=>{console.debug(`[admin-modal] open-log`,{conversationId:T.conversationId,sessionKey:T.sessionKey,type:e}),E(null)},children:[(0,R.jsx)(c,{size:12}),(0,R.jsx)(`span`,{children:t})]},e))})]})}):null}function wE({src:e,onClose:t}){return e?(0,R.jsxs)(`div`,{className:`attachment-lightbox`,onClick:t,children:[(0,R.jsx)(`button`,{className:`attachment-lightbox-close`,onClick:t,"aria-label":`Close`,children:`×`}),(0,R.jsx)(`img`,{src:e,alt:`Attachment`,onClick:e=>e.stopPropagation()})]}):null}function TE({show:e,onClose:t,onConfirm:n}){return e?(0,R.jsx)(`div`,{className:`claude-info-overlay`,onClick:t,children:(0,R.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,R.jsxs)(`div`,{className:`claude-info-header`,children:[(0,R.jsx)(`span`,{children:`Compact conversation?`}),(0,R.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:`✕`})]}),(0,R.jsx)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:`Summarises the conversation history to free up context window space. The session continues with a compressed summary.`}),(0,R.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,R.jsx)(w,{variant:`secondary`,size:`sm`,style:{background:`var(--accent)`,flex:1},onClick:()=>{t(),n()},children:`Yes, compact`}),(0,R.jsx)(w,{variant:`secondary`,size:`sm`,style:{flex:1},onClick:t,children:`No`})]})]})}):null}function EE(e){let{show:t,onClose:n,claudeInfo:r,messages:i,sessionElapsed:a,conversationId:o}=e;if(!t)return null;let s=i.flatMap(e=>e.events?.filter(e=>e.type===`usage`)??[]),c=s.at(-1),l=c?.peak_request_pct==null?c?.context_window?Math.round((c.input_tokens+c.cache_creation_tokens+c.cache_read_tokens)/c.context_window*100):0:Math.round(c.peak_request_pct*100),u=s.reduce((e,t)=>e+t.input_tokens+t.cache_creation_tokens+t.cache_read_tokens+t.output_tokens,0),d=i.flatMap(e=>e.events?.filter(e=>e.type===`rate_limit`)??[]).at(-1),f=s.reduce((e,t)=>e+(t.total_cost_usd??0),0),p=r?.account?.subscriptionType,m=e=>{let t=e*1e3-Date.now();if(t<=0)return`now`;let n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4);return n>0?`${n}h ${r}m`:`${r}m`};return(0,R.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,R.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,R.jsxs)(`div`,{className:`claude-info-header`,children:[(0,R.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`claude-info-icon`}),(0,R.jsx)(`span`,{children:`Claude Code`}),(0,R.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,R.jsxs)(`div`,{className:`claude-info-section`,children:[(0,R.jsxs)(`div`,{className:`claude-info-row`,children:[(0,R.jsx)(`span`,{className:`claude-info-label`,children:`Version`}),(0,R.jsx)(`span`,{className:`claude-info-value`,children:r?r.version:`…`})]}),(0,R.jsxs)(`div`,{className:`claude-info-row`,children:[(0,R.jsx)(`span`,{className:`claude-info-label`,children:`Email`}),(0,R.jsx)(`span`,{className:`claude-info-value`,children:r?.account?.email??`…`})]})]}),(p||d||f>0)&&(0,R.jsxs)(`div`,{className:`claude-info-section`,children:[p&&(0,R.jsxs)(`div`,{className:`claude-info-row`,children:[(0,R.jsx)(`span`,{className:`claude-info-label`,children:`Plan`}),(0,R.jsx)(`span`,{className:`claude-info-value`,style:{textTransform:`capitalize`},children:p})]}),d&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`claude-info-row`,children:[(0,R.jsx)(`span`,{className:`claude-info-label`,children:`Usage`}),(0,R.jsxs)(`span`,{className:`claude-info-value`,children:[Math.round(d.utilization*100),`%`]})]}),(0,R.jsxs)(`div`,{className:`claude-info-row`,children:[(0,R.jsx)(`span`,{className:`claude-info-label`,children:`Resets in`}),(0,R.jsx)(`span`,{className:`claude-info-value`,children:m(d.resetsAt)})]}),d.isUsingOverage&&(0,R.jsxs)(`div`,{className:`claude-info-row`,children:[(0,R.jsx)(`span`,{className:`claude-info-label`,children:`Overage`}),(0,R.jsx)(`span`,{className:`claude-info-value`,children:`Active`})]})]}),f>0&&(0,R.jsxs)(`div`,{className:`claude-info-row`,children:[(0,R.jsx)(`span`,{className:`claude-info-label`,children:`Session cost`}),(0,R.jsxs)(`span`,{className:`claude-info-value`,children:[`$`,f<.01?f.toFixed(4):f.toFixed(2)]})]})]}),(0,R.jsxs)(`div`,{className:`claude-info-section`,children:[(0,R.jsxs)(`div`,{className:`claude-info-row`,children:[(0,R.jsx)(`span`,{className:`claude-info-label`,children:`Model`}),(0,R.jsx)(`span`,{className:`claude-info-value`,children:r?.model??`…`})]}),(0,R.jsxs)(`div`,{className:`claude-info-row`,children:[(0,R.jsx)(`span`,{className:`claude-info-label`,children:`Context used`}),(0,R.jsx)(`span`,{className:`claude-info-value`,children:l>0?`${l}%`:`—`})]}),(0,R.jsxs)(`div`,{className:`claude-info-row`,children:[(0,R.jsx)(`span`,{className:`claude-info-label`,children:`Tokens`}),(0,R.jsx)(`span`,{className:`claude-info-value`,children:u>0?ft(u):`—`})]}),(0,R.jsxs)(`div`,{className:`claude-info-row`,children:[(0,R.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,R.jsx)(`span`,{className:`claude-info-value`,children:dt(a)})]}),o&&(0,R.jsxs)(`div`,{className:`claude-info-row`,children:[(0,R.jsx)(`span`,{className:`claude-info-label`,children:`Conversation`}),(0,R.jsx)(`span`,{className:`claude-info-value`,style:{fontFamily:`monospace`,fontSize:10},children:o.slice(0,8)})]})]})]})})}var DE=5e3,OE={atPhase:8};function kE({show:e,onClose:t,versionInfo:n,sessionKey:r,onUpgradeComplete:i}){let[a,o]=(0,L.useState)(`prompt`),[s,c]=(0,L.useState)(``),[l,u]=(0,L.useState)(!1),[d,f]=(0,L.useState)(null),[p,m]=(0,L.useState)(null),[h,g]=(0,L.useState)(null),_=(0,L.useRef)(null),v=n?.latest??null,y=(0,L.useCallback)(()=>{_.current&&=(clearInterval(_.current),null)},[]);(0,L.useEffect)(()=>{e||(y(),o(`prompt`),c(``),u(!1),f(null),m(null),g(null))},[e,y]),(0,L.useEffect)(()=>y,[y]),(0,L.useEffect)(()=>{if(!(!e||a!==`running`||!v))return _.current=setInterval(async()=>{try{let e=await fetch(`/api/admin/version`,{cache:`no-store`});if(!e.ok)return;(await e.json()).installed===v&&(y(),o(`succeeded`),i(),setTimeout(()=>window.location.reload(),2e3))}catch{}},DE),y},[e,a,v,i,y]);let b=(0,L.useCallback)(async()=>{if(!(!v||!r||a!==`prompt`)){if(!s){f(`Enter your device password first.`);return}f(null),m(null),o(`priming`);try{let e=await fetch(`/api/admin/actions/sudo-prime?session_key=${encodeURIComponent(r)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({password:s,session_key:r})});if(e.status!==204){f((await e.json().catch(()=>({}))).error??`Password check failed (status ${e.status})`),o(`prompt`);return}}catch(e){f(e instanceof Error?e.message:`Password check network error`),o(`prompt`);return}try{let e=await fetch(`/api/admin/actions/upgrade?session_key=${encodeURIComponent(r)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sudoPassword:s,session_key:r})}),t=await e.json().catch(()=>({}));if(!e.ok||!t.actionId){m(t.error??`launch failed (status ${e.status})`),o(`launch-failed`);return}g(t.actionId),o(`running`)}catch(e){m(e instanceof Error?e.message:`launch network error`),o(`launch-failed`)}finally{c(``)}}},[s,v,r,a]);return e?(0,R.jsx)(`div`,{className:`claude-info-overlay`,onClick:()=>{(a===`prompt`||a===`succeeded`||a===`launch-failed`)&&t()},children:(0,R.jsxs)(`div`,{className:`claude-info-modal update-modal`,onClick:e=>e.stopPropagation(),children:[(0,R.jsxs)(`div`,{className:`claude-info-header`,children:[(0,R.jsx)(fe,{size:12}),`Software Update`,(0,R.jsx)(`button`,{className:`claude-info-close`,onClick:t,children:`✕`})]}),(0,R.jsxs)(`div`,{className:`update-modal-body`,children:[(0,R.jsxs)(`div`,{className:`update-modal-versions`,children:[(0,R.jsxs)(`div`,{className:`claude-info-row`,children:[(0,R.jsx)(`span`,{className:`claude-info-label`,children:`Installed`}),(0,R.jsxs)(`span`,{className:`claude-info-value`,children:[`v`,n?.installed??`…`]})]}),(0,R.jsxs)(`div`,{className:`claude-info-row`,children:[(0,R.jsx)(`span`,{className:`claude-info-label`,children:`Available`}),(0,R.jsxs)(`span`,{className:`claude-info-value update-version-new`,children:[`v`,v??`…`]})]})]}),(a===`prompt`||a===`priming`||a===`launch-failed`)&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`form-input__field`,style:{marginTop:12},children:[(0,R.jsx)(`label`,{className:`form-input__label`,htmlFor:`upgrade-sudo`,children:`Device password`}),(0,R.jsxs)(`div`,{className:`tunnel-route__row`,children:[(0,R.jsx)(`input`,{id:`upgrade-sudo`,className:`form-input__input tunnel-route__input`,type:l?`text`:`password`,autoComplete:`current-password`,value:s,onChange:e=>{c(e.target.value),f(null)},disabled:a===`priming`,onKeyDown:e=>{e.key===`Enter`&&s&&b()}}),(0,R.jsx)(`button`,{type:`button`,className:`tunnel-route__suffix`,onClick:()=>u(e=>!e),disabled:a===`priming`,style:{cursor:`pointer`,border:`none`,background:`inherit`},"aria-label":l?`Hide password`:`Show password`,children:l?`Hide`:`Show`})]}),(0,R.jsx)(`div`,{className:`form-input__field-desc`,children:`Needed once. The installer uses it to run the privileged steps; it is never saved.`}),d&&(0,R.jsx)(`div`,{className:`tunnel-route__error`,children:d}),p&&(0,R.jsx)(`div`,{className:`tunnel-route__error`,role:`alert`,children:p})]}),(0,R.jsx)(`button`,{type:`button`,className:`update-modal-btn`,onClick:b,disabled:!v||!s||a===`priming`,children:a===`priming`?`Checking password…`:a===`launch-failed`?`Try again`:`Upgrade`})]}),a===`running`&&h&&r&&(0,R.jsx)(`div`,{className:`update-modal-terminal`,style:{height:360,marginTop:10},children:(0,R.jsx)(JT,{actionId:h,sessionKey:r,selfRestart:OE})}),a===`succeeded`&&(0,R.jsxs)(`div`,{className:`update-modal-result`,children:[(0,R.jsx)(F,{size:14,className:`update-success-icon`}),(0,R.jsxs)(`span`,{children:[`Upgraded to v`,v,` — reloading…`]})]})]})]})}):null}function AE(e,t){let n=t.lastIndexOf(`_`),r=t.slice(0,n),i=t.slice(n+1),a=parseInt(r,10),o=i===`admin`?`admin`:`maxy`,s=e.find(e=>e.timestamp===a&&e.role===o);if(!s)return``;if(i===`admin`)return s.content??``;let c=parseInt(i,10),l=s.events?.[c];if(!l)return``;if(l.type===`text`||l.type===`thinking`)return l.content;if(l.type===`tool_use`){let e=l,t=`[Tool: ${e.name}]`,n=`Input:\n${JSON.stringify(e.input,null,2)}`,r=s.events??[],i=``;for(let t=c+1;t<r.length;t++){let n=r[t];if(n.type===`tool_result`&&n.name===e.name){i=`\n\nResult:\n${n.output}`;break}}return`${t}\n${n}${i}`}if(l.type===`subagent_start`){let e=l,t=s.events??[],n=``;for(let r=c+1;r<t.length;r++){let i=t[r];if(i.type===`subagent_end`&&i.name===e.name){n=`\n\nResult:\n${i.result}`;break}}return`[${e.name}: ${e.task}]${n}`}return``}function jE(e,t){let n=[...e].sort((e,t)=>(e.timestamp??0)-(t.timestamp??0)),r=[];for(let e of n)if(!e.hidden)if(e.role===`admin`)(t===`all`||t===`text`)&&r.push(`User:\n${e.content}`);else{let n=e.events??[];for(let e=0;e<n.length;e++){let i=n[e];if(i.type===`text`&&(t===`all`||t===`text`))r.push(`Maxy:\n${i.content}`);else if(i.type===`thinking`&&(t===`all`||t===`non-text`))r.push(`Maxy [thinking]:\n${i.content}`);else if(i.type===`tool_use`&&(t===`all`||t===`non-text`)){let t=i,a=``;for(let r=e+1;r<n.length;r++)if(n[r].type===`tool_result`&&n[r].name===t.name){a=`\n\nResult:\n${n[r].output}`;break}r.push(`Maxy [tool: ${t.name}]:\nInput:\n${JSON.stringify(t.input,null,2)}${a}`)}else if(i.type===`subagent_start`&&(t===`all`||t===`non-text`)){let t=i,a=``;for(let r=e+1;r<n.length;r++)if(n[r].type===`subagent_end`&&n[r].name===t.name){a=`\n\nResult:\n${n[r].result}`;break}r.push(`Maxy [agent: ${t.name}]\nTask: ${t.task}${a}`)}}}return r.join(`
|
|
348
|
+
${JSON.stringify(u.input,null,2)}`,f=se.get(r),p=o?void 0:f??t;return(0,R.jsx)(_E,{icon:l,isPending:o,isError:c,doneClass:u.name===`Read`?`tl-done`:`tl-success`,summary:uE(u.name,u.input),detail:d,tokens:mE(n),elapsed:k(r,p),isLast:s,expanded:i===void 0?_.has(r):i,onToggle:()=>O(r),selectCheck:ee(r)},r)}if(n.type===`subagent_start`){let t=n,a=e.some(e=>e.type===`subagent_end`&&e.name===t.name),o=a?e.findIndex(e=>e.type===`subagent_end`&&e.name===t.name):void 0,c=t.background===!0,l=t.task.slice(0,60)+(t.task.length>60?`…`:``),u=t.task;if(c&&!a){let n=[...e].reverse().find(e=>e.type===`subagent_progress`&&e.name===t.name);n?.last_tool_name&&(u=`${t.task}\nLast tool: ${n.last_tool_name} (${n.tool_uses??0} calls)`)}let d=a?e.find(e=>e.type===`subagent_end`&&e.name===t.name):void 0,f=a&&d?nE.test(d.result):!1;return(0,R.jsx)(_E,{icon:a?f?(0,R.jsx)(he,{size:11}):(0,R.jsx)(xe,{size:11}):(0,R.jsx)(Ge,{size:11,className:`tl-spinner`}),isPending:!a,isError:f,summary:c?`${t.name} (background) — ${l}`:`${t.name} — ${l}`,detail:c?u:t.task,tokens:mE(n),elapsed:k(r,o),isLast:s,expanded:i===void 0?_.has(r):i,onToggle:()=>O(r),selectCheck:ee(r)},r)}if(n.type===`component`){let e=l?.has(`${u}_${r}`)??!1,i=n;return(0,R.jsxs)(`div`,{className:`tl-step`,children:[ee(r),(0,R.jsxs)(`div`,{className:`tl-col`,children:[(0,R.jsx)(`div`,{className:`tl-icon ${e?`tl-done`:`tl-pending`}`,children:(0,R.jsx)(Ze,{size:11})}),!s&&(0,R.jsx)(`div`,{className:`tl-line tl-line-grow`})]}),(0,R.jsx)(`div`,{className:`tl-body`,children:(0,R.jsx)(tE,{name:i.name,data:i.data,submitted:e,onSubmit:e=>c?.(r,e,i.name),isStreaming:t,sessionKey:g})})]},r)}if(n.type===`subagent_end`){let e=n,t=nE.test(e.result);return(0,R.jsx)(_E,{icon:t?(0,R.jsx)(he,{size:11}):(0,R.jsx)(h,{size:11}),isPending:!1,isError:t,summary:`${e.name} ${t?`failed`:`complete`}`,detail:e.result,tokens:mE(n),elapsed:k(r,se.get(r)),isLast:s,expanded:i===void 0?_.has(r):i,onToggle:()=>O(r),selectCheck:ee(r)},r)}if(n.type===`script_stream`){let e=n,t=e.line.match(/https:\/\/dash\.cloudflare\.com\/argotunnel\?[^\s]+/)?.[0],i=t?JSON.stringify({url:t,intent:`Cloudflare tunnel authorization`}):void 0;return(0,R.jsxs)(`div`,{className:`tl-script-stream`,children:[(0,R.jsxs)(`div`,{className:`tl-script-stream-line`,children:[(0,R.jsxs)(`span`,{className:`tl-script-stream-source`,children:[`[`,e.source,`]`]}),(0,R.jsx)(`span`,{className:`tl-script-stream-content`,children:e.line})]}),i&&(0,R.jsx)(x,{source:i})]},r)}return null}return(0,R.jsxs)(`div`,{className:`admin-activity`,children:[ue&&!t&&i===void 0&&(0,R.jsx)(`div`,{className:`tl-steps`,children:(0,R.jsxs)(`div`,{className:`tl-step tl-summary-row`,onClick:()=>{window.getSelection()?.toString()||b(e=>!e)},children:[(0,R.jsx)(`div`,{className:`tl-col`,children:(0,R.jsx)(`div`,{className:`tl-icon tl-done`,children:ce.hasThinking?(0,R.jsx)(He,{size:11}):(0,R.jsx)(h,{size:11})})}),(0,R.jsx)(`div`,{className:`tl-body`,children:(0,R.jsxs)(`div`,{className:`tl-row`,style:{cursor:`pointer`},children:[(0,R.jsx)(`span`,{className:`tl-summary`,children:ce.text}),ce.tokenSum>0&&(0,R.jsxs)(`span`,{className:`tl-step-tokens`,children:[(0,R.jsx)(ct,{size:9}),pE(ce.tokenSum)]}),(0,R.jsx)(`span`,{className:`tl-step-elapsed`,children:hE(n)}),(0,R.jsx)(`span`,{className:`tl-chevron`,children:y?(0,R.jsx)(Ce,{size:10}):(0,R.jsx)(p,{size:10})})]})})]})}),me.map((e,n)=>e.role===`steps`?!t&&i===void 0&&y?null:(0,R.jsx)(`div`,{className:`tl-steps`,children:e.items.map(({e:t,i:n},r)=>ye(t,n,e.items,r))},`seg-${n}`):e.items.map(({e,i:n})=>{let r=e,i=n===ve;return(0,R.jsxs)(`div`,{className:`tl-text-block`,onClick:d&&!t&&u?()=>m?.(`${u}_${n}`):void 0,style:d&&!t?{cursor:`pointer`}:void 0,children:[ee(n),(0,R.jsx)(te,{content:r.content,timestamp:!t&&i&&u?rE(u):void 0})]},n)})),t&&!de&&(0,R.jsxs)(`div`,{className:`tl-loading`,children:[(0,R.jsx)(aE,{size:13}),(0,R.jsx)(lE,{}),(0,R.jsx)(`span`,{className:`tl-elapsed`,children:hE(n)})]}),!t&&N.size>0&&(0,R.jsx)(`div`,{className:`tl-post-components`,children:e.map((e,t)=>({e,i:t})).filter(({i:e})=>N.has(e)).map(({e,i:n})=>{if(e.type!==`component`)return null;let r=l?.has(`${u}_${n}`)??!1;return(0,R.jsx)(tE,{name:e.name,data:e.data,submitted:r,onSubmit:t=>c?.(n,t,e.name),isStreaming:t,sessionKey:g},n)})}),(de||!t&&ue)&&(0,R.jsxs)(`div`,{className:`tl-footer`,children:[t&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(aE,{size:10}),(0,R.jsx)(lE,{})]}),(0,R.jsxs)(`span`,{className:`tl-footer-icon-stat`,children:[(0,R.jsx)(Ee,{size:10}),hE(n)]}),ne?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`tl-footer-sep`,children:`·`}),(0,R.jsxs)(`span`,{className:`tl-footer-icon-stat`,children:[(0,R.jsx)(ct,{size:10}),pE(ne.input_tokens+ne.cache_creation_tokens+ne.cache_read_tokens+ne.output_tokens)]})]}):t&&ce.tokenSum>0?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`tl-footer-sep`,children:`·`}),(0,R.jsxs)(`span`,{className:`tl-footer-icon-stat tl-footer-est`,children:[(0,R.jsx)(ct,{size:10}),`~`,pE(ce.tokenSum)]})]}):null,re&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`tl-footer-sep`,children:`·`}),(0,R.jsxs)(`span`,{className:`tl-footer-icon-stat tl-ctx-pct${re.budget>0&&re.tokens/re.budget>=.7?` tl-ctx-high`:re.budget>0&&re.tokens/re.budget>=.5?` tl-ctx-mid`:``}`,children:[(0,R.jsx)(Je,{size:10}),re.messages]})]}),s?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`tl-footer-sep`,children:`·`}),(0,R.jsxs)(`span`,{className:`tl-footer-icon-stat tl-ctx-compacted`,children:[(0,R.jsx)(_e,{size:10}),`compacted`]})]}):le===null?null:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`tl-footer-sep`,children:`·`}),!s&&a&&!t?(0,R.jsxs)(w,{variant:`ghost`,size:`sm`,className:`tl-footer-icon-stat tl-ctx-pct${le>=70?` tl-ctx-high`:le>=50?` tl-ctx-mid`:``}`,style:{padding:0,fontSize:`11px`},onClick:a,children:[(0,R.jsx)(_e,{size:10}),le,`%`]}):(0,R.jsxs)(`span`,{className:`tl-footer-icon-stat tl-ctx-pct${le>=70?` tl-ctx-high`:le>=50?` tl-ctx-mid`:``}`,children:[(0,R.jsx)(_e,{size:10}),le,`%`]})]}),o||t&&ie?(0,R.jsxs)(`span`,{className:`tl-footer-status`,children:[(0,R.jsx)(Ge,{size:10,className:`tl-spinner`}),ie?.message??`Compacting session...`]}):null]})]})}function yE(e){let{messages:t,isStreaming:n,elapsedSeconds:r,sessionTurnStart:i,expandAll:a,setExpandAll:o,conversationCompacted:s,isCompacting:l,setShowCompactConfirm:u,handleComponentSubmit:d,effectiveSubmitted:f,selectionMode:m,selectedItems:h,toggleSelectItem:g,sessionKey:_,setLightboxSrc:y,messageQueue:b,messageQueueRef:x,setQueue:S,sendMessage:C,appState:w,onboardingComplete:T}=e,D=(0,L.useRef)(null),O=(0,L.useRef)(null),k=(0,L.useRef)(null),A=(0,L.useRef)(!1),[j,M]=L.useState(!0);(0,L.useEffect)(()=>{if(!j){A.current=n;return}if(A.current&&!n&&k.current&&O.current){let e=k.current;if(e.offsetHeight>O.current.clientHeight){e.scrollIntoView({behavior:`smooth`,block:`start`}),A.current=n;return}}D.current?.scrollIntoView({behavior:`smooth`}),A.current=n},[t,b,j,n]),(0,L.useEffect)(()=>{if(w!==`chat`)return;let e=O.current;if(!e)return;let t=()=>{M(e.scrollHeight-e.scrollTop-e.clientHeight<80)};return e.addEventListener(`scroll`,t,{passive:!0}),t(),()=>e.removeEventListener(`scroll`,t)},[w]);let N=[...t].sort((e,t)=>(e.timestamp??0)-(t.timestamp??0)),P=N.reduce((e,t,n)=>t.role===`maxy`&&!t.hidden?n:e,-1);return(0,R.jsxs)(`div`,{className:`chat-messages-wrap`,children:[m&&(0,R.jsx)(`div`,{className:`selection-overlay-band`}),(0,R.jsxs)(`div`,{className:`chat-messages`,ref:O,children:[t.length===0&&w===`chat`&&T!==!1&&(0,R.jsxs)(`div`,{className:`idle-tips`,children:[(0,R.jsx)(`p`,{className:`idle-tips-hint`,children:`What would you like to do?`}),(0,R.jsx)(`div`,{className:`idle-tips-chips`,children:[`What needs doing?`,`Start a new task`].map(e=>(0,R.jsx)(`button`,{type:`button`,className:`idle-tip-chip`,onClick:()=>C(e),children:e},e))})]}),N.map((e,t,o)=>{if(e.hidden)return null;let p=n&&t===o.length-1,b=e.role,x=`${e.timestamp??0}_admin`,S=b===`admin`&&h.has(x),C=(t>0?o[t-1]:null)?.historical&&!e.historical;return(0,R.jsxs)(L.Fragment,{children:[C&&(0,R.jsx)(`div`,{className:`resume-divider`,children:(0,R.jsx)(`span`,{children:`Resumed conversation`})}),(0,R.jsxs)(`div`,{ref:t===P?k:void 0,className:`message ${b===`admin`?`visitor`:`maxy`}${S?` selected`:``}${e.historical?` message-historical`:``}`,children:[m&&!p&&b===`admin`&&(0,R.jsx)(`div`,{className:`message-select-check`,children:(0,R.jsx)(ge,{checked:S,onChange:()=>g(x)})}),e.role===`admin`?(0,R.jsxs)(`div`,{className:`bubble`,children:[e.content,e.attachments&&e.attachments.length>0&&(0,R.jsx)(`div`,{className:`message-attachments`,children:e.attachments.map((e,t)=>(0,R.jsxs)(`button`,{type:`button`,className:`message-attachment-chip${e.attachmentId&&_?``:` no-action`}`,onClick:()=>{if(!e.attachmentId||!_)return;let t=`/api/admin/attachment/${e.attachmentId}?session_key=${encodeURIComponent(_)}`;e.mimeType.startsWith(`image/`)?y(t):window.open(t,`_blank`)},children:[e.mimeType===`application/pdf`?(0,R.jsx)(c,{size:12}):e.mimeType.startsWith(`text/`)?(0,R.jsx)(E,{size:12}):null,(0,R.jsx)(`span`,{children:e.filename})]},t))}),(0,R.jsx)(`span`,{className:`message-timestamp`,children:v(e.timestamp)})]}):(0,R.jsx)(`div`,{className:`maxy-content-wrap`,children:(0,R.jsx)(vE,{events:e.events??[],isStreaming:p,elapsedSeconds:t===o.length-1?r:e.elapsedSeconds??0,streamStartMs:t===o.length-1?i.current??void 0:void 0,expandAll:a,onCompactNow:t===o.length-1&&!s?()=>u(!0):void 0,isCompacting:t===o.length-1?l:void 0,sessionCompacted:t===o.length-1?s:void 0,onComponentSubmit:(t,n,r)=>d(e.timestamp,t,n,r),submittedComponents:f,timestamp:e.timestamp,selectionMode:m,selectedItems:h,onToggleItem:g,sessionKey:_})})]})]},t)}),b.map((e,t)=>(0,R.jsx)(`div`,{className:`message visitor`,children:(0,R.jsxs)(`div`,{className:`bubble bubble-queued`,children:[e.text||null,e.files.length>0&&(0,R.jsx)(`div`,{className:`message-attachments`,children:e.files.map((e,t)=>(0,R.jsxs)(`span`,{className:`message-attachment-chip no-action`,children:[e.type===`application/pdf`?(0,R.jsx)(c,{size:12}):e.type.startsWith(`text/`)?(0,R.jsx)(E,{size:12}):null,(0,R.jsx)(`span`,{children:e.name})]},t))}),(0,R.jsx)(`span`,{className:`message-timestamp`,children:v(e.timestamp)}),(0,R.jsx)(`button`,{type:`button`,className:`queued-bubble-delete`,onClick:()=>S(x.current.filter((e,n)=>n!==t)),"aria-label":`Remove queued message`,children:`×`})]})},e.timestamp)),(0,R.jsx)(`div`,{ref:D})]}),!j&&(0,R.jsx)(`button`,{className:`scroll-to-bottom`,onClick:()=>D.current?.scrollIntoView({behavior:`smooth`}),"aria-label":`Scroll to bottom`,children:(0,R.jsx)(p,{size:18})}),t.some(e=>e.role===`maxy`)&&(0,R.jsx)(`button`,{className:`expand-toggle expand-toggle-${a===void 0?`default`:a?`all`:`off`}`,onClick:()=>o(e=>e===void 0?!0:e===!0?!1:void 0),"aria-label":a===void 0?`Expand all`:a?`Collapse all`:`Reset to default`,children:a===!1?(0,R.jsx)(Ve,{size:14}):(0,R.jsx)(He,{size:14})})]})}function bE({offer:e,onFreshStart:t,onContinue:n,disabled:r}){return e.active?(0,R.jsxs)(`div`,{className:`topic-change-bar`,children:[(0,R.jsx)(`div`,{className:`topic-change-bar__icon`,children:(0,R.jsx)(Le,{size:16})}),(0,R.jsxs)(`div`,{className:`topic-change-bar__actions`,children:[(0,R.jsx)(w,{variant:`primary`,size:`sm`,onClick:t,disabled:r,children:`Start fresh`}),(0,R.jsx)(w,{variant:`ghost`,size:`sm`,onClick:n,disabled:r,children:`Continue here`})]})]}):null}var xE=[{type:`stream`,label:`Stream`},{type:`error`,label:`Errors`},{type:`sse`,label:`SSE`}];function SE(e,t){return e.conversationId?`/api/admin/logs?type=${t}&conversationId=${encodeURIComponent(e.conversationId)}`:e.sessionKey?`/api/admin/logs?type=${t}&sessionKey=${encodeURIComponent(e.sessionKey)}`:`/api/admin/logs?type=${t}`}function CE(e){let{show:t,onClose:n,conversationsLoading:r,conversationsError:a,conversationsList:o,setConversationsList:s,sessionKey:l,isStreaming:u,resetConversation:d,setMessages:f,setConversationId:p}=e,[m,g]=(0,L.useState)(null),[v,y]=(0,L.useState)(null),[b,x]=(0,L.useState)(``),[S,C]=(0,L.useState)(!1),w=(0,L.useRef)(null),[T,E]=(0,L.useState)(null),[D,O]=(0,L.useState)(null),[k,A]=(0,L.useState)(null),j=(0,L.useRef)(null),M=(0,L.useRef)(null),N=(0,L.useRef)(null);(0,L.useEffect)(()=>{t||(g(null),y(null),x(``),C(!1),E(null),O(null),A(null),j.current&&=(clearTimeout(j.current),null),M.current&&=(clearTimeout(M.current),null))},[t]),(0,L.useEffect)(()=>{if(!T)return;function e(e){let t=e.target;t&&N.current?.contains(t)||t&&t.closest?.(`.conversations-logs`)||E(null)}function t(e){e.key===`Escape`&&E(null)}return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[T]),(0,L.useEffect)(()=>{v?.phase===`editing`&&(w.current?.focus(),w.current?.select())},[v]);function P(){g(null),y(null),x(``),C(!1)}async function ee(e){if(l){P(),g(e),y({phase:`loading`});try{let t=await fetch(`/api/admin/sessions/${encodeURIComponent(e)}/label?session_key=${encodeURIComponent(l)}`,{method:`POST`});if(!t.ok){y({phase:`error`,reason:(await t.json().catch(()=>({}))).error||`Request failed`});return}let n=await t.json();n.label?(y({phase:`editing`}),x(n.label)):y({phase:`error`,reason:`Not enough message content to suggest a name`})}catch(e){console.error(`[admin-modal] label suggestion failed:`,e),y({phase:`error`,reason:e instanceof Error?e.message:String(e)})}}}async function te(e){if(!(!l||!b.trim()||S)){C(!0);try{let t=await fetch(`/api/admin/sessions/${encodeURIComponent(e)}/label`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({label:b.trim(),session_key:l})});if(!t.ok){y({phase:`error`,reason:(await t.json().catch(()=>({}))).error||`Rename failed`}),C(!1);return}s(t=>t.map(t=>t.conversationId===e?{...t,name:b.trim()}:t)),P()}catch(e){console.error(`[admin-modal] label rename failed:`,e),y({phase:`error`,reason:e instanceof Error?e.message:String(e)}),C(!1)}}}function ne(e,t,n){if(T?.rowId===e){E(null);return}let r=n.getBoundingClientRect();E({rowId:e,conversationId:t.conversationId,sessionKey:t.sessionKey,top:r.bottom+4,right:Math.max(8,window.innerWidth-r.right)})}async function re(e){await ie(e)?(O(e),A(null),j.current&&clearTimeout(j.current),j.current=setTimeout(()=>O(null),1500)):(A(e),O(null),M.current&&clearTimeout(M.current),M.current=setTimeout(()=>A(null),1500))}return t?(0,R.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,R.jsxs)(`div`,{className:`claude-info-modal conversations-modal`,onClick:e=>e.stopPropagation(),children:[(0,R.jsxs)(`div`,{className:`claude-info-header`,children:[(0,R.jsx)(We,{size:12}),`Conversations`,(0,R.jsx)(`button`,{className:`claude-info-close`,onClick:n,children:`✕`})]}),(0,R.jsxs)(`div`,{className:`conversations-list`,children:[r&&(0,R.jsxs)(`div`,{className:`conversations-empty`,children:[(0,R.jsx)(oe,{size:14,className:`spin`}),` Loading…`]}),a&&(0,R.jsx)(`div`,{className:`conversations-empty conversations-error`,children:a}),!r&&!a&&o.length===0&&(0,R.jsx)(`div`,{className:`conversations-empty`,children:`No recent conversations`}),!r&&!a&&o.map(e=>{let t=e.conversationId??e.sessionKey??``,r=e.phase===`pre-flush`,a=!r&&m===e.conversationId,o=a&&v?.phase===`loading`,g=a&&v?.phase===`editing`,y=a&&v?.phase===`error`,C=e.conversationId??e.sessionKey??``;return(0,R.jsxs)(`div`,{className:`conversations-row${r?` conversations-row-pre-flush`:``}`,children:[(0,R.jsxs)(`div`,{className:`conversations-row-info`,children:[o&&(0,R.jsxs)(`span`,{className:`conversations-row-name conversations-edit-loading`,children:[(0,R.jsx)(oe,{size:12,className:`spin`}),` Generating suggestion…`]}),g&&(0,R.jsxs)(`div`,{className:`conversations-edit-inline`,children:[(0,R.jsx)(`input`,{ref:w,type:`text`,className:`conversations-edit-input`,value:b,onChange:e=>x(e.target.value),onKeyDown:t=>{t.key===`Enter`&&b.trim()&&te(e.conversationId),t.key===`Escape`&&P()},maxLength:200}),(0,R.jsx)(`button`,{type:`button`,className:`conversations-action conversations-confirm`,title:`Confirm rename`,disabled:!b.trim()||S,onClick:()=>te(e.conversationId),children:S?(0,R.jsx)(oe,{size:13,className:`spin`}):(0,R.jsx)(h,{size:13})}),(0,R.jsx)(`button`,{type:`button`,className:`conversations-action conversations-cancel`,title:`Cancel`,onClick:P,children:(0,R.jsx)(he,{size:13})})]}),y&&(0,R.jsxs)(`div`,{className:`conversations-edit-inline`,children:[(0,R.jsx)(`span`,{className:`conversations-edit-error`,children:v.reason}),(0,R.jsx)(`button`,{type:`button`,className:`conversations-action conversations-retry`,title:`Retry`,onClick:()=>ee(e.conversationId),children:(0,R.jsx)(me,{size:13})}),(0,R.jsx)(`button`,{type:`button`,className:`conversations-action conversations-cancel`,title:`Cancel`,onClick:P,children:(0,R.jsx)(he,{size:13})})]}),!a&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`span`,{className:`conversations-row-name`,children:[e.name||(r?`session ${C}`:C),r&&(0,R.jsx)(`span`,{className:`conversations-row-phase-badge`,title:`Pre-flush — conversation not yet persisted`,children:`pre-flush`})]}),(0,R.jsxs)(`span`,{className:`conversations-row-meta`,children:[(0,R.jsx)(`button`,{type:`button`,className:`conversations-row-id${D===t?` copied`:``}${k===t?` copy-failed`:``}`,title:C,"aria-label":r?`Copy session key ${C}`:`Copy conversation id ${C}`,onClick:e=>{e.stopPropagation(),re(t)},children:D===t?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(h,{size:10}),` copied`]}):k===t?`copy failed`:C.slice(0,8)}),(0,R.jsxs)(`span`,{className:`conversations-row-time`,children:[(0,R.jsx)(Ee,{size:10}),(()=>{try{let t=new Date(e.updatedAt),n=Date.now()-t.getTime();return n<6e4?`just now`:n<36e5?`${Math.floor(n/6e4)}m ago`:n<864e5?`${Math.floor(n/36e5)}h ago`:`${Math.floor(n/864e5)}d ago`}catch{return``}})()]})]})]})]}),(0,R.jsx)(`div`,{className:`conversations-row-actions`,children:!a&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,className:`conversations-action conversations-logs`,title:r?`View pre-flush logs`:`View logs`,"aria-haspopup":`menu`,"aria-expanded":T?.rowId===t,onClick:n=>{n.stopPropagation(),ne(t,{conversationId:e.conversationId,sessionKey:e.sessionKey},n.currentTarget)},children:(0,R.jsx)(c,{size:13})}),!r&&e.conversationId&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,className:`conversations-action conversations-rename`,title:`Rename conversation`,onClick:()=>ee(e.conversationId),children:(0,R.jsx)(Qe,{size:13})}),(0,R.jsx)(`button`,{type:`button`,className:`conversations-action conversations-play`,title:`Resume conversation`,disabled:u,onClick:()=>{u||!l||(n(),d(),fetch(`/api/admin/sessions/${encodeURIComponent(e.conversationId)}/resume?session_key=${encodeURIComponent(l)}`,{method:`POST`}).then(e=>e.ok?e.json():Promise.reject(Error(`Failed to resume conversation`))).then(e=>{e.conversationId&&p(e.conversationId);let t=(e.messages??[]).map(e=>({role:e.role===`user`?`admin`:`maxy`,content:e.role===`user`?e.content:void 0,events:e.role===`assistant`?[{type:`text`,content:e.content}]:void 0,timestamp:new Date(e.createdAt).getTime()||0,historical:!0}));t.length>0&&f(t)}).catch(e=>{console.error(`[chat] conversation resume failed:`,e),f([{role:`maxy`,events:[{type:`text`,content:`Could not load conversation history.`}],timestamp:Date.now()-1,historical:!0}])}))},children:(0,R.jsx)(_,{size:13})}),(0,R.jsx)(`button`,{type:`button`,className:`conversations-action conversations-delete`,title:`Delete conversation`,onClick:()=>{s(t=>t.filter(t=>t.conversationId!==e.conversationId)),l&&fetch(`/api/admin/sessions/${encodeURIComponent(e.conversationId)}?session_key=${encodeURIComponent(l)}`,{method:`DELETE`}).catch(e=>console.error(`[chat] conversation delete failed:`,e))},children:(0,R.jsx)(i,{size:13})})]})]})})]},t)})]}),T&&(0,R.jsx)(`div`,{ref:N,className:`conversations-logs-popover`,role:`menu`,style:{top:T.top,right:T.right},children:xE.map(({type:e,label:t})=>(0,R.jsxs)(`a`,{role:`menuitem`,className:`conversations-logs-popover-item`,href:SE({conversationId:T.conversationId,sessionKey:T.sessionKey},e),target:`_blank`,rel:`noopener noreferrer`,onClick:()=>{console.debug(`[admin-modal] open-log`,{conversationId:T.conversationId,sessionKey:T.sessionKey,type:e}),E(null)},children:[(0,R.jsx)(c,{size:12}),(0,R.jsx)(`span`,{children:t})]},e))})]})}):null}function wE({src:e,onClose:t}){return e?(0,R.jsxs)(`div`,{className:`attachment-lightbox`,onClick:t,children:[(0,R.jsx)(`button`,{className:`attachment-lightbox-close`,onClick:t,"aria-label":`Close`,children:`×`}),(0,R.jsx)(`img`,{src:e,alt:`Attachment`,onClick:e=>e.stopPropagation()})]}):null}function TE({show:e,onClose:t,onConfirm:n}){return e?(0,R.jsx)(`div`,{className:`claude-info-overlay`,onClick:t,children:(0,R.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,R.jsxs)(`div`,{className:`claude-info-header`,children:[(0,R.jsx)(`span`,{children:`Compact conversation?`}),(0,R.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:`✕`})]}),(0,R.jsx)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:`Summarises the conversation history to free up context window space. The session continues with a compressed summary.`}),(0,R.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,R.jsx)(w,{variant:`secondary`,size:`sm`,style:{background:`var(--accent)`,flex:1},onClick:()=>{t(),n()},children:`Yes, compact`}),(0,R.jsx)(w,{variant:`secondary`,size:`sm`,style:{flex:1},onClick:t,children:`No`})]})]})}):null}function EE(e){let{show:t,onClose:n,claudeInfo:r,messages:i,sessionElapsed:a,conversationId:o}=e;if(!t)return null;let s=i.flatMap(e=>e.events?.filter(e=>e.type===`usage`)??[]),c=s.at(-1),l=c?.peak_request_pct==null?c?.context_window?Math.round((c.input_tokens+c.cache_creation_tokens+c.cache_read_tokens)/c.context_window*100):0:Math.round(c.peak_request_pct*100),u=s.reduce((e,t)=>e+t.input_tokens+t.cache_creation_tokens+t.cache_read_tokens+t.output_tokens,0),d=i.flatMap(e=>e.events?.filter(e=>e.type===`rate_limit`)??[]).at(-1),f=s.reduce((e,t)=>e+(t.total_cost_usd??0),0),p=r?.account?.subscriptionType,m=e=>{let t=e*1e3-Date.now();if(t<=0)return`now`;let n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4);return n>0?`${n}h ${r}m`:`${r}m`};return(0,R.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,R.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,R.jsxs)(`div`,{className:`claude-info-header`,children:[(0,R.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`claude-info-icon`}),(0,R.jsx)(`span`,{children:`Claude Code`}),(0,R.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,R.jsxs)(`div`,{className:`claude-info-section`,children:[(0,R.jsxs)(`div`,{className:`claude-info-row`,children:[(0,R.jsx)(`span`,{className:`claude-info-label`,children:`Version`}),(0,R.jsx)(`span`,{className:`claude-info-value`,children:r?r.version:`…`})]}),(0,R.jsxs)(`div`,{className:`claude-info-row`,children:[(0,R.jsx)(`span`,{className:`claude-info-label`,children:`Email`}),(0,R.jsx)(`span`,{className:`claude-info-value`,children:r?.account?.email??`…`})]})]}),(p||d||f>0)&&(0,R.jsxs)(`div`,{className:`claude-info-section`,children:[p&&(0,R.jsxs)(`div`,{className:`claude-info-row`,children:[(0,R.jsx)(`span`,{className:`claude-info-label`,children:`Plan`}),(0,R.jsx)(`span`,{className:`claude-info-value`,style:{textTransform:`capitalize`},children:p})]}),d&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`claude-info-row`,children:[(0,R.jsx)(`span`,{className:`claude-info-label`,children:`Usage`}),(0,R.jsxs)(`span`,{className:`claude-info-value`,children:[Math.round(d.utilization*100),`%`]})]}),(0,R.jsxs)(`div`,{className:`claude-info-row`,children:[(0,R.jsx)(`span`,{className:`claude-info-label`,children:`Resets in`}),(0,R.jsx)(`span`,{className:`claude-info-value`,children:m(d.resetsAt)})]}),d.isUsingOverage&&(0,R.jsxs)(`div`,{className:`claude-info-row`,children:[(0,R.jsx)(`span`,{className:`claude-info-label`,children:`Overage`}),(0,R.jsx)(`span`,{className:`claude-info-value`,children:`Active`})]})]}),f>0&&(0,R.jsxs)(`div`,{className:`claude-info-row`,children:[(0,R.jsx)(`span`,{className:`claude-info-label`,children:`Session cost`}),(0,R.jsxs)(`span`,{className:`claude-info-value`,children:[`$`,f<.01?f.toFixed(4):f.toFixed(2)]})]})]}),(0,R.jsxs)(`div`,{className:`claude-info-section`,children:[(0,R.jsxs)(`div`,{className:`claude-info-row`,children:[(0,R.jsx)(`span`,{className:`claude-info-label`,children:`Model`}),(0,R.jsx)(`span`,{className:`claude-info-value`,children:r?.model??`…`})]}),(0,R.jsxs)(`div`,{className:`claude-info-row`,children:[(0,R.jsx)(`span`,{className:`claude-info-label`,children:`Context used`}),(0,R.jsx)(`span`,{className:`claude-info-value`,children:l>0?`${l}%`:`—`})]}),(0,R.jsxs)(`div`,{className:`claude-info-row`,children:[(0,R.jsx)(`span`,{className:`claude-info-label`,children:`Tokens`}),(0,R.jsx)(`span`,{className:`claude-info-value`,children:u>0?ft(u):`—`})]}),(0,R.jsxs)(`div`,{className:`claude-info-row`,children:[(0,R.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,R.jsx)(`span`,{className:`claude-info-value`,children:dt(a)})]}),o&&(0,R.jsxs)(`div`,{className:`claude-info-row`,children:[(0,R.jsx)(`span`,{className:`claude-info-label`,children:`Conversation`}),(0,R.jsx)(`span`,{className:`claude-info-value`,style:{fontFamily:`monospace`,fontSize:10},children:o.slice(0,8)})]})]})]})})}var DE=5e3,OE={atPhase:8};function kE({show:e,onClose:t,versionInfo:n,sessionKey:r,onUpgradeComplete:i}){let[a,o]=(0,L.useState)(`prompt`),[s,c]=(0,L.useState)(``),[l,u]=(0,L.useState)(!1),[d,f]=(0,L.useState)(null),[p,m]=(0,L.useState)(null),[h,g]=(0,L.useState)(null),_=(0,L.useRef)(null),v=n?.latest??null,y=(0,L.useCallback)(()=>{_.current&&=(clearInterval(_.current),null)},[]);(0,L.useEffect)(()=>{e||(y(),o(`prompt`),c(``),u(!1),f(null),m(null),g(null))},[e,y]),(0,L.useEffect)(()=>y,[y]),(0,L.useEffect)(()=>{if(!(!e||a!==`running`||!v))return _.current=setInterval(async()=>{try{let e=await fetch(`/api/admin/version`,{cache:`no-store`});if(!e.ok)return;(await e.json()).installed===v&&(y(),o(`succeeded`),i(),setTimeout(()=>window.location.reload(),2e3))}catch{}},DE),y},[e,a,v,i,y]);let b=(0,L.useCallback)(async()=>{if(!(!v||!r||a!==`prompt`)){if(!s){f(`Enter your device password first.`);return}f(null),m(null),o(`priming`);try{let e=await fetch(`/api/admin/actions/sudo-prime?session_key=${encodeURIComponent(r)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({password:s,session_key:r})});if(e.status!==204){f((await e.json().catch(()=>({}))).error??`Password check failed (status ${e.status})`),o(`prompt`);return}}catch(e){f(e instanceof Error?e.message:`Password check network error`),o(`prompt`);return}try{let e=await fetch(`/api/admin/actions/upgrade?session_key=${encodeURIComponent(r)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sudoPassword:s,session_key:r})}),t=await e.json().catch(()=>({}));if(!e.ok||!t.actionId){m(t.error??`launch failed (status ${e.status})`),o(`launch-failed`);return}g(t.actionId),o(`running`)}catch(e){m(e instanceof Error?e.message:`launch network error`),o(`launch-failed`)}finally{c(``)}}},[s,v,r,a]);return e?(0,R.jsx)(`div`,{className:`claude-info-overlay`,onClick:()=>{(a===`prompt`||a===`succeeded`||a===`launch-failed`)&&t()},children:(0,R.jsxs)(`div`,{className:`claude-info-modal update-modal`,onClick:e=>e.stopPropagation(),children:[(0,R.jsxs)(`div`,{className:`claude-info-header`,children:[(0,R.jsx)(fe,{size:12}),`Software Update`,(0,R.jsx)(`button`,{className:`claude-info-close`,onClick:t,children:`✕`})]}),(0,R.jsxs)(`div`,{className:`update-modal-body`,children:[(0,R.jsxs)(`div`,{className:`update-modal-versions`,children:[(0,R.jsxs)(`div`,{className:`claude-info-row`,children:[(0,R.jsx)(`span`,{className:`claude-info-label`,children:`Installed`}),(0,R.jsxs)(`span`,{className:`claude-info-value`,children:[`v`,n?.installed??`…`]})]}),(0,R.jsxs)(`div`,{className:`claude-info-row`,children:[(0,R.jsx)(`span`,{className:`claude-info-label`,children:`Available`}),(0,R.jsxs)(`span`,{className:`claude-info-value update-version-new`,children:[`v`,v??`…`]})]})]}),(a===`prompt`||a===`priming`||a===`launch-failed`)&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`form-input__field`,style:{marginTop:12},children:[(0,R.jsx)(`label`,{className:`form-input__label`,htmlFor:`upgrade-sudo`,children:`Device password`}),(0,R.jsxs)(`div`,{className:`tunnel-route__row`,children:[(0,R.jsx)(`input`,{id:`upgrade-sudo`,className:`form-input__input tunnel-route__input`,type:l?`text`:`password`,autoComplete:`current-password`,value:s,onChange:e=>{c(e.target.value),f(null)},disabled:a===`priming`,onKeyDown:e=>{e.key===`Enter`&&s&&b()}}),(0,R.jsx)(`button`,{type:`button`,className:`tunnel-route__suffix`,onClick:()=>u(e=>!e),disabled:a===`priming`,style:{cursor:`pointer`,border:`none`,background:`inherit`},"aria-label":l?`Hide password`:`Show password`,children:l?`Hide`:`Show`})]}),(0,R.jsx)(`div`,{className:`form-input__field-desc`,children:`Needed once. The installer uses it to run the privileged steps; it is never saved.`}),d&&(0,R.jsx)(`div`,{className:`tunnel-route__error`,children:d}),p&&(0,R.jsx)(`div`,{className:`tunnel-route__error`,role:`alert`,children:p})]}),(0,R.jsx)(`button`,{type:`button`,className:`update-modal-btn`,onClick:b,disabled:!v||!s||a===`priming`,children:a===`priming`?`Checking password…`:a===`launch-failed`?`Try again`:`Upgrade`})]}),a===`running`&&h&&r&&(0,R.jsx)(`div`,{className:`update-modal-terminal`,style:{height:360,marginTop:10},children:(0,R.jsx)(JT,{actionId:h,sessionKey:r,selfRestart:OE})}),a===`succeeded`&&(0,R.jsxs)(`div`,{className:`update-modal-result`,children:[(0,R.jsx)(F,{size:14,className:`update-success-icon`}),(0,R.jsxs)(`span`,{children:[`Upgraded to v`,v,` — reloading…`]})]})]})]})}):null}function AE(e,t){let n=t.lastIndexOf(`_`),r=t.slice(0,n),i=t.slice(n+1),a=parseInt(r,10),o=i===`admin`?`admin`:`maxy`,s=e.find(e=>e.timestamp===a&&e.role===o);if(!s)return``;if(i===`admin`)return s.content??``;let c=parseInt(i,10),l=s.events?.[c];if(!l)return``;if(l.type===`text`||l.type===`thinking`)return l.content;if(l.type===`tool_use`){let e=l,t=`[Tool: ${e.name}]`,n=`Input:\n${JSON.stringify(e.input,null,2)}`,r=s.events??[],i=``;for(let t=c+1;t<r.length;t++){let n=r[t];if(n.type===`tool_result`&&n.name===e.name){i=`\n\nResult:\n${n.output}`;break}}return`${t}\n${n}${i}`}if(l.type===`subagent_start`){let e=l,t=s.events??[],n=``;for(let r=c+1;r<t.length;r++){let i=t[r];if(i.type===`subagent_end`&&i.name===e.name){n=`\n\nResult:\n${i.result}`;break}}return`[${e.name}: ${e.task}]${n}`}return``}function jE(e,t){let n=[...e].sort((e,t)=>(e.timestamp??0)-(t.timestamp??0)),r=[];for(let e of n)if(!e.hidden)if(e.role===`admin`)(t===`all`||t===`text`)&&r.push(`User:\n${e.content}`);else{let n=e.events??[];for(let e=0;e<n.length;e++){let i=n[e];if(i.type===`text`&&(t===`all`||t===`text`))r.push(`Maxy:\n${i.content}`);else if(i.type===`thinking`&&(t===`all`||t===`non-text`))r.push(`Maxy [thinking]:\n${i.content}`);else if(i.type===`tool_use`&&(t===`all`||t===`non-text`)){let t=i,a=``;for(let r=e+1;r<n.length;r++)if(n[r].type===`tool_result`&&n[r].name===t.name){a=`\n\nResult:\n${n[r].output}`;break}r.push(`Maxy [tool: ${t.name}]:\nInput:\n${JSON.stringify(t.input,null,2)}${a}`)}else if(i.type===`subagent_start`&&(t===`all`||t===`non-text`)){let t=i,a=``;for(let r=e+1;r<n.length;r++)if(n[r].type===`subagent_end`&&n[r].name===t.name){a=`\n\nResult:\n${n[r].result}`;break}r.push(`Maxy [agent: ${t.name}]\nTask: ${t.task}${a}`)}}}return r.join(`
|
|
349
349
|
|
|
350
350
|
---
|
|
351
351
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>Maxy</title>
|
|
7
7
|
<link rel="icon" href="/favicon.ico">
|
|
8
|
-
<script type="module" crossorigin src="/assets/admin-
|
|
8
|
+
<script type="module" crossorigin src="/assets/admin-BcmWF670.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/chunk-DD-I1_y5.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/jsx-runtime-BkCc5_JK.js">
|
|
11
11
|
<link rel="modulepreload" crossorigin href="/assets/preload-helper-BEFjQwLd.js">
|
package/payload/server/server.js
CHANGED
|
@@ -50,6 +50,7 @@ import {
|
|
|
50
50
|
getUserTimezone,
|
|
51
51
|
getVisitorIdForSession,
|
|
52
52
|
hashPassword,
|
|
53
|
+
interruptClient,
|
|
53
54
|
invokeAgent,
|
|
54
55
|
isActionActive,
|
|
55
56
|
isPasswordValid,
|
|
@@ -98,7 +99,7 @@ import {
|
|
|
98
99
|
vncLog,
|
|
99
100
|
waitForExit,
|
|
100
101
|
writeChromiumWrapper
|
|
101
|
-
} from "./chunk-
|
|
102
|
+
} from "./chunk-K7GQ5RMN.js";
|
|
102
103
|
|
|
103
104
|
// ../lib/graph-trash/dist/index.js
|
|
104
105
|
var require_dist = __commonJS({
|
|
@@ -8261,6 +8262,21 @@ app11.post("/", requireAdminSession, async (c) => {
|
|
|
8261
8262
|
async start(controller) {
|
|
8262
8263
|
let controllerOpen = true;
|
|
8263
8264
|
const sseEntry = { controller, conversationId: sseConvId ?? null, sessionKey: session_key };
|
|
8265
|
+
try {
|
|
8266
|
+
const reqSignal = c.req.raw?.signal;
|
|
8267
|
+
if (reqSignal) {
|
|
8268
|
+
reqSignal.addEventListener("abort", () => {
|
|
8269
|
+
const ts = (/* @__PURE__ */ new Date()).toISOString().slice(11, 23);
|
|
8270
|
+
sseLog.write(`[${ts}] [${sk}] admin: ABORT [operator-cancel] interrupting pool client
|
|
8271
|
+
`);
|
|
8272
|
+
interruptClient(session_key, sseLog).catch((err) => {
|
|
8273
|
+
sseLog.write(`[${ts}] [${sk}] admin: ABORT [interrupt-failed] ${err instanceof Error ? err.message : String(err)}
|
|
8274
|
+
`);
|
|
8275
|
+
});
|
|
8276
|
+
}, { once: true });
|
|
8277
|
+
}
|
|
8278
|
+
} catch {
|
|
8279
|
+
}
|
|
8264
8280
|
try {
|
|
8265
8281
|
registerAdminSSE(sseEntry);
|
|
8266
8282
|
if (sseConvId) {
|