@seqyuan/annovibe 0.8.134 → 0.8.135

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 (85) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +15 -15
  3. package/.next/build-manifest.json +2 -2
  4. package/.next/prerender-manifest.json +3 -3
  5. package/.next/required-server-files.js +1 -1
  6. package/.next/required-server-files.json +1 -1
  7. package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  8. package/.next/server/app/_global-error.html +1 -1
  9. package/.next/server/app/_global-error.rsc +1 -1
  10. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  11. package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  12. package/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  13. package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  14. package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  15. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  16. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  17. package/.next/server/app/_not-found.html +1 -1
  18. package/.next/server/app/_not-found.rsc +2 -2
  19. package/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  20. package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  21. package/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
  22. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  23. package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  24. package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  25. package/.next/server/app/api/agent/runtime/route.js +1 -1
  26. package/.next/server/app/api/file-tree/write/route.js +1 -1
  27. package/.next/server/app/api/internal/runtime/route.js +1 -1
  28. package/.next/server/app/api/sessions/[id]/route.js +1 -1
  29. package/.next/server/app/api/version/route.js +1 -1
  30. package/.next/server/app/index.html +1 -1
  31. package/.next/server/app/index.rsc +3 -3
  32. package/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  33. package/.next/server/app/index.segments/_full.segment.rsc +3 -3
  34. package/.next/server/app/index.segments/_head.segment.rsc +1 -1
  35. package/.next/server/app/index.segments/_index.segment.rsc +2 -2
  36. package/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  37. package/.next/server/app/login/page_client-reference-manifest.js +1 -1
  38. package/.next/server/app/login.html +1 -1
  39. package/.next/server/app/login.rsc +2 -2
  40. package/.next/server/app/login.segments/_full.segment.rsc +2 -2
  41. package/.next/server/app/login.segments/_head.segment.rsc +1 -1
  42. package/.next/server/app/login.segments/_index.segment.rsc +2 -2
  43. package/.next/server/app/login.segments/_tree.segment.rsc +2 -2
  44. package/.next/server/app/login.segments/login/__PAGE__.segment.rsc +1 -1
  45. package/.next/server/app/login.segments/login.segment.rsc +1 -1
  46. package/.next/server/app/page.js +17 -17
  47. package/.next/server/app/page_client-reference-manifest.js +1 -1
  48. package/.next/server/app/smoke/page_client-reference-manifest.js +1 -1
  49. package/.next/server/app/smoke/session-stream/page_client-reference-manifest.js +1 -1
  50. package/.next/server/app/smoke/session-stream.html +1 -1
  51. package/.next/server/app/smoke/session-stream.rsc +3 -3
  52. package/.next/server/app/smoke/session-stream.segments/_full.segment.rsc +3 -3
  53. package/.next/server/app/smoke/session-stream.segments/_head.segment.rsc +1 -1
  54. package/.next/server/app/smoke/session-stream.segments/_index.segment.rsc +2 -2
  55. package/.next/server/app/smoke/session-stream.segments/_tree.segment.rsc +2 -2
  56. package/.next/server/app/smoke/session-stream.segments/smoke/session-stream/__PAGE__.segment.rsc +2 -2
  57. package/.next/server/app/smoke/session-stream.segments/smoke/session-stream.segment.rsc +1 -1
  58. package/.next/server/app/smoke/session-stream.segments/smoke.segment.rsc +1 -1
  59. package/.next/server/app/smoke.html +2 -2
  60. package/.next/server/app/smoke.rsc +3 -3
  61. package/.next/server/app/smoke.segments/_full.segment.rsc +3 -3
  62. package/.next/server/app/smoke.segments/_head.segment.rsc +1 -1
  63. package/.next/server/app/smoke.segments/_index.segment.rsc +2 -2
  64. package/.next/server/app/smoke.segments/_tree.segment.rsc +2 -2
  65. package/.next/server/app/smoke.segments/smoke/__PAGE__.segment.rsc +2 -2
  66. package/.next/server/app/smoke.segments/smoke.segment.rsc +1 -1
  67. package/.next/server/app-paths-manifest.json +15 -15
  68. package/.next/server/chunks/4584.js +1 -1
  69. package/.next/server/chunks/6429.js +4 -4
  70. package/.next/server/chunks/9230.js +5 -5
  71. package/.next/server/middleware-build-manifest.js +1 -1
  72. package/.next/server/pages/404.html +1 -1
  73. package/.next/server/pages/500.html +1 -1
  74. package/.next/server/server-reference-manifest.json +1 -1
  75. package/.next/static/chunks/{4456-91f92907e8ef1f89.js → 4456-646debea1b5bbec7.js} +3 -3
  76. package/.next/static/chunks/9544-46c74a307e919fcb.js +22 -0
  77. package/.next/static/chunks/app/page-765bc8a2e911eb4c.js +44 -0
  78. package/.next/static/css/{fdfd4d4bcfae3c6a.css → 4a3f6b9aa8eed19f.css} +1 -1
  79. package/bin/annovibe-im-gateway.js +0 -4
  80. package/bin/pi-web.js +0 -12
  81. package/package.json +1 -1
  82. package/.next/static/chunks/9544-5e2696923ae4f6b5.js +0 -22
  83. package/.next/static/chunks/app/page-959c2935e21471e4.js +0 -44
  84. /package/.next/static/{2gyhgfAo_GNB2lRPOJwF9 → WmuL2h-UefYxq-xz32JzM}/_buildManifest.js +0 -0
  85. /package/.next/static/{2gyhgfAo_GNB2lRPOJwF9 → WmuL2h-UefYxq-xz32JzM}/_ssgManifest.js +0 -0
@@ -255,6 +255,6 @@ ${a}
255
255
  </body>
256
256
  </html>`}},8033:(a,b,c)=>{"use strict";c.d(b,{Dm:()=>p});var d=c(48249),e=c(67484),f=c(54097),g=c(57703),h=c(1453),i=c(129);function j({model:a,background:b="transparent",maxHeight:c=280}){return 0===a.resultImages.length&&0===a.collapsedPreviewPaths.length?null:(0,d.jsxs)("div",{style:{padding:"0 10px 10px",background:b},children:[a.resultImages.length>0&&(0,d.jsx)(i.O7,{images:a.resultImages,maxHeight:c}),a.collapsedPreviewPaths.length>0&&(0,d.jsx)(i.eR,{imagePaths:a.collapsedPreviewPaths,maxHeight:c})]})}function k({model:a,inputMaxHeight:b=280,inputBackground:c="var(--bg-subtle)",inputTextColor:e="var(--text-muted)",showBorderTop:f=!1}){let g=(0,d.jsx)(h.m,{text:a.inputText,maxHeight:b,collapsible:!0,textColor:e,background:c});return f?(0,d.jsx)("div",{style:{borderTop:"1px solid var(--border)"},children:g}):g}function l({model:a,result:b,showUnavailableWhenMissing:c=!1,unavailableLabel:e="Result not available"}){return b?(0,d.jsx)(i.qb,{text:a.displayResultText??"",isEmpty:a.resultIsEmpty,isError:b.isError??!1,images:a.resultImages,imagePaths:a.mergedImagePaths,toolDetails:b.details??null}):c?(0,d.jsx)("div",{style:{padding:"8px 10px",borderTop:"1px solid var(--border)",color:"var(--text-dim)",fontSize:12,fontStyle:"italic"},children:e}):null}var m=c(80251);function n({expanded:a,onToggle:b,tool:c,status:e,durationLabel:f,title:h,summary:i,titleTooltip:j,summaryTooltip:k,leading:l,titleStyle:o,buttonStyle:p}){return(0,d.jsx)(g.V,{expanded:a,onToggle:b,status:e,title:h??c.toolName,summary:i??(0,m.Wm)(c.input),durationLabel:f,leading:l,titleTooltip:j,summaryTooltip:k,buttonStyle:p,titleStyle:o})}function o({expanded:a,model:b,result:c,collapsedPreviewBackground:e="transparent",showCollapsedPreview:f=!0,showUnavailableWhenMissing:g=!1,unavailableLabel:h="Result not available",showInputBorderTop:i=!1}){return a?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(k,{model:b,showBorderTop:i}),(0,d.jsx)(l,{model:b,result:c,showUnavailableWhenMissing:g,unavailableLabel:h})]}):f?(0,d.jsx)(j,{model:b,background:e}):null}function p({tool:a,result:b,status:c,durationLabel:g,cwd:h,title:j,summary:m,titleTooltip:q,summaryTooltip:r,leading:s,collapsedPreviewBackground:t="transparent",showCollapsedPreview:u=!0,showUnavailableWhenMissing:v=!1,unavailableLabel:w="Result not available",showInputBorderTop:x=!1,titleStyle:y,buttonStyle:z,containerStyle:A,notebookStyle:B=!1}){let[C,D]=(0,e.useState)(!1),E=(0,e.useMemo)(()=>(function({input:a,result:b,cwd:c}){let d=JSON.stringify(a??{},null,2),e=b?b.content.filter(a=>"text"===a.type).map(a=>a.text).join("\n"):null,f=b?b.content.filter(a=>"image"===a.type):[],g=(0,i.Ln)(e,f.length>0),h=null!==g&&("(no output)"===g.trim()||""===g.trim()),j=(0,i.qn)(d,c),k=(0,i.qn)(g,c),l=(0,i.Xz)([...k,...j]),m=k.length>0?k:j;return{inputText:d,displayResultText:g,resultImages:f,resultIsEmpty:h,inputImagePaths:j,resultImagePaths:k,mergedImagePaths:l,collapsedPreviewPaths:m}})({input:a.input,result:b,cwd:h}),[h,b,a.input]);if(B){let c={...E,inputText:function(a){if(a&&"object"==typeof a){for(let b of["command","cmd","script"])if("string"==typeof a[b])return a[b]}return"string"==typeof a?a:JSON.stringify(a??{},null,2)}(a.input)};return(0,d.jsxs)(f.t,{kind:"tool-call",style:{fontSize:12,minWidth:0,marginTop:2,marginBottom:6,...A},children:[(0,d.jsxs)("div",{style:{padding:"3px 10px",background:"var(--bg-panel)",borderBottom:"1px solid var(--border)",fontSize:11,color:"var(--text-dim)",display:"flex",alignItems:"center",gap:6},children:[(0,d.jsx)("span",{style:{fontWeight:500},children:a.toolName}),g&&(0,d.jsx)("span",{style:{opacity:.6},children:g})]}),(0,d.jsx)(k,{model:c,showBorderTop:!1,inputMaxHeight:260,inputBackground:"var(--bg)"}),b&&(0,d.jsx)(l,{model:E,result:b,showUnavailableWhenMissing:!1})]})}return(0,d.jsxs)(f.t,{kind:"tool-call",style:{fontSize:12,minWidth:0,...A},children:[(0,d.jsx)(n,{expanded:C,onToggle:()=>D(a=>!a),tool:a,status:c,durationLabel:g,title:j,summary:m,titleTooltip:q,summaryTooltip:r,leading:s,titleStyle:y,buttonStyle:z}),(0,d.jsx)(o,{expanded:C,model:E,result:b,collapsedPreviewBackground:t,showCollapsedPreview:u,showUnavailableWhenMissing:v,unavailableLabel:w,showInputBorderTop:x})]})}},11642:(a,b,c)=>{Promise.resolve().then(c.t.bind(c,95547,23))},19581:(a,b,c)=>{"use strict";c.d(b,{NG:()=>g,oG:()=>i,iO:()=>h,Mi:()=>j});var d=c(48249),e=c(67484);function f({children:a,totalLines:b,className:c,collapsedMaxHeight:g="15.5rem",expandedMaxHeight:h,overlayBackground:i="var(--bg)",footerBackground:j="var(--bg-panel)"}){let[k,l]=(0,e.useState)(!1);return b<=20?(0,d.jsx)(d.Fragment,{children:a}):(0,d.jsxs)("div",{className:c,children:[(0,d.jsxs)("div",{style:{position:"relative",...k?{maxHeight:h,overflowY:h?"auto":"visible",overflowX:"hidden"}:{maxHeight:g,overflow:"hidden"}},children:[a,!k&&(0,d.jsx)("div",{style:{position:"absolute",insetInline:0,bottom:0,height:"3.5rem",background:`linear-gradient(to top, ${i} 0%, transparent 100%)`,pointerEvents:"none"}})]}),(0,d.jsx)("button",{type:"button",onClick:()=>l(a=>!a),"aria-expanded":k,style:{display:"flex",alignItems:"center",gap:4,width:"100%",minHeight:28,padding:"4px 8px",justifyContent:"center",background:j,border:"none",borderTop:"1px solid var(--border)",color:"var(--text-dim)",cursor:"pointer",fontSize:11},children:k?"Collapse":`Show all ${b} lines`})]})}function g({children:a,className:b,style:c}){return(0,d.jsx)("div",{className:b,style:{borderRadius:6,overflow:"hidden",border:"1px solid var(--border)",...c},children:a})}function h({title:a,actions:b,style:c}){return(0,d.jsxs)("div",{style:{padding:"3px 10px",background:"var(--bg-panel)",borderBottom:"1px solid var(--border)",fontSize:11,color:"var(--text-dim)",display:"flex",justifyContent:"space-between",alignItems:"center",gap:8,...c},children:[(0,d.jsx)("span",{children:a}),b?(0,d.jsx)("div",{style:{display:"flex",gap:8,alignItems:"center"},children:b}):null]})}function i({children:a,totalLines:b,expandedMaxHeight:c,overlayBackground:e,footerBackground:g}){return(0,d.jsx)(f,{totalLines:b,expandedMaxHeight:c,overlayBackground:e,footerBackground:g,children:a})}function j({onClick:a,label:b,activeLabel:c,active:e=!1,title:f,ariaLabel:g}){return(0,d.jsx)("button",{type:"button",onClick:a,title:f,"aria-label":g,style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:11},children:e&&c?c:b})}},27563:(a,b,c)=>{"use strict";c.d(b,{kD:()=>z,Ld:()=>l,pR:()=>u,y0:()=>k,q:()=>s,cP:()=>t,o0:()=>v});var d=c(48249),e=c(67484),f=c(41044),g=c(54097),h=c(73383),i=c(57703),j=c(8033);function k({children:a,style:b,...c}){return(0,d.jsx)("div",{...c,style:{borderLeft:"2px solid var(--border)",paddingLeft:8,minWidth:0,...b},children:a})}function l({children:a,style:b,...c}){return(0,d.jsx)("div",{...c,style:{display:"flex",flexDirection:"column",gap:4,paddingTop:6,...b},children:a})}function m({name:a}){let b={width:13,height:13,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0};return"terminal"===a?(0,d.jsxs)("svg",{...b,children:[(0,d.jsx)("polyline",{points:"4 7 10 12 4 17"}),(0,d.jsx)("line",{x1:"12",y1:"17",x2:"20",y2:"17"})]}):"edit"===a?(0,d.jsxs)("svg",{...b,children:[(0,d.jsx)("path",{d:"M12 20h9"}),(0,d.jsx)("path",{d:"M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z"})]}):"read"===a?(0,d.jsxs)("svg",{...b,children:[(0,d.jsx)("path",{d:"M4 19.5V5a2 2 0 0 1 2-2h11.5a1.5 1.5 0 0 1 0 3H6"}),(0,d.jsx)("path",{d:"M6 6v15h12"})]}):"search"===a?(0,d.jsxs)("svg",{...b,children:[(0,d.jsx)("circle",{cx:"11",cy:"11",r:"7"}),(0,d.jsx)("path",{d:"m20 20-4-4"})]}):"agent"===a?(0,d.jsxs)("svg",{...b,children:[(0,d.jsx)("path",{d:"M12 8V4"}),(0,d.jsx)("rect",{x:"5",y:"8",width:"14",height:"11",rx:"3"}),(0,d.jsx)("path",{d:"M9 13h.01"}),(0,d.jsx)("path",{d:"M15 13h.01"}),(0,d.jsx)("path",{d:"M10 17h4"})]}):"thinking"===a?(0,d.jsxs)("svg",{...b,children:[(0,d.jsx)("path",{d:"M9 18h6"}),(0,d.jsx)("path",{d:"M10 22h4"}),(0,d.jsx)("path",{d:"M8.5 14.5a6 6 0 1 1 7 0c-.8.6-1.5 1.6-1.5 2.5h-4c0-.9-.7-1.9-1.5-2.5Z"})]}):"success"===a?(0,d.jsx)("svg",{...b,children:(0,d.jsx)("polyline",{points:"20 6 9 17 4 12"})}):"error"===a?(0,d.jsxs)("svg",{...b,children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,d.jsx)("path",{d:"m15 9-6 6"}),(0,d.jsx)("path",{d:"m9 9 6 6"})]}):"unknown"===a?(0,d.jsxs)("svg",{...b,children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,d.jsx)("path",{d:"M9.5 9a2.8 2.8 0 0 1 5 1.8c0 1.8-2.5 2.1-2.5 3.7"}),(0,d.jsx)("path",{d:"M12 18h.01"})]}):"chevron"===a?(0,d.jsx)("svg",{...b,children:(0,d.jsx)("polyline",{points:"8 10 12 14 16 10"})}):"running"===a?(0,d.jsxs)("svg",{...b,style:{animation:"spin 0.8s linear infinite"},children:[(0,d.jsx)("path",{d:"M21 12a9 9 0 0 1-9 9"}),(0,d.jsx)("path",{d:"M3 12a9 9 0 0 1 9-9"})]}):(0,d.jsxs)("svg",{...b,children:[(0,d.jsx)("path",{d:"M12 3v18"}),(0,d.jsx)("path",{d:"M3 12h18"}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"3"})]})}function n(a){if(void 0===a)return null;if(a<60)return`~${a}s`;let b=Math.floor(a/60),c=a%60;return`~${b}m${c?` ${c}s`:""}`}function o({expanded:a,total:b,summary:c,runningDescription:e,onToggle:f}){return(0,d.jsxs)("button",{type:"button",onClick:f,"aria-expanded":a,title:a?"Collapse process":"Expand process",style:{width:"100%",minHeight:30,display:"flex",alignItems:"center",gap:8,border:"1px solid var(--border)",borderRadius:6,background:a?"var(--bg-panel)":"transparent",color:"var(--text-muted)",padding:"5px 8px",cursor:"pointer",textAlign:"left",minWidth:0},children:[(0,d.jsx)("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",minWidth:22,height:18,borderRadius:5,background:"var(--bg-selected)",color:"var(--text-muted)",fontSize:11,fontFamily:"var(--font-mono)",flexShrink:0},children:b}),(0,d.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,fontSize:12,flex:1},children:c}),e&&(0,d.jsx)("span",{title:e,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:220,minWidth:0,fontSize:11,flexShrink:1},children:e}),(0,d.jsx)("span",{style:{display:"inline-flex",color:"var(--text-dim)",flexShrink:0,transform:a?"rotate(180deg)":"none",transition:"transform 0.15s"},children:(0,d.jsx)(m,{name:"chevron"})})]})}function p({item:a,isStreaming:b=!1}){let c=n(a.duration);return(0,d.jsx)(h.pm,{content:a.content,durationLabel:c,isStreaming:b,leading:(0,d.jsx)("span",{style:{display:"inline-flex",color:"var(--text-dim)",flexShrink:0},children:(0,d.jsx)(m,{name:"thinking"})}),buttonStyle:{minHeight:28,padding:"5px 8px"}})}function q({item:a,cwd:b}){let[c,h]=(0,e.useState)(!1),j=a.tools.some(a=>"running"===a.status),k=a.tools.some(a=>"error"===a.status),l=a.tools.every(a=>"unknown"===a.status),n=j?"running":k?"error":l?"unknown":"success";return(0,d.jsxs)(g.t,{kind:"context-group",children:[(0,d.jsx)(i.V,{expanded:c,onToggle:()=>h(a=>!a),status:n,title:`${j?"Gathering context":"Gathered context"} (${a.tools.length})`,leading:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{style:{display:"inline-flex",color:(0,f.Gb)(n),flexShrink:0},children:(0,d.jsx)(m,{name:n})}),(0,d.jsx)("span",{style:{display:"inline-flex",color:"var(--text-dim)",flexShrink:0},children:(0,d.jsx)(m,{name:"read"})})]}),buttonStyle:{width:"100%",minHeight:28,display:"flex",alignItems:"center",gap:7,padding:"5px 8px",border:"none",background:"transparent",color:"var(--text-muted)",cursor:"pointer",textAlign:"left",minWidth:0},titleStyle:{fontFamily:"inherit",fontWeight:400,fontSize:12}}),c&&(0,d.jsx)(g.p,{children:(0,d.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4,padding:"4px 6px 6px"},children:a.tools.map(a=>(0,d.jsx)(r,{item:a,cwd:b,nested:!0},a.tool.toolCallId))})})]})}function r({item:a,cwd:b,nested:c}){let e=n(a.duration);return(0,d.jsx)(j.Dm,{tool:a.tool,result:a.result,status:a.status,durationLabel:e,cwd:b,title:a.meta.label,summary:a.meta.summary,titleTooltip:a.tool.toolName,summaryTooltip:a.meta.summary,leading:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{style:{display:"inline-flex",color:(0,f.Gb)(a.status),flexShrink:0},children:(0,d.jsx)(m,{name:a.status})}),(0,d.jsx)("span",{style:{display:"inline-flex",color:"var(--text-dim)",flexShrink:0},children:(0,d.jsx)(m,{name:a.meta.kind})})]}),showCollapsedPreview:!1,showUnavailableWhenMissing:"unknown"===a.status,showInputBorderTop:!0,buttonStyle:{width:"100%",minHeight:28,display:"flex",alignItems:"center",gap:7,padding:"5px 8px",border:"none",background:"transparent",color:"var(--text-muted)",cursor:"pointer",textAlign:"left",minWidth:0},titleStyle:{color:"error"===a.status?"#f87171":"var(--text-muted)",maxWidth:120},containerStyle:{border:c?"1px solid color-mix(in srgb, var(--border) 70%, transparent)":"1px solid var(--border)",background:c?"var(--bg)":"var(--bg-panel)"}})}let s=o,t=p,u=q,v=r;var w=c(80251);let x=new Set(["read","read_file","readfile","search","grep","glob","find","find_files","ls","list","list_files"]),y=[];function z({tools:a,results:b,durations:c,thinkingBlocks:g=y,isStreaming:h,cwd:i}){let j,m,n,s,t=function(a=768){let[b,c]=(0,e.useState)(!1);return b}(),u=(0,e.useMemo)(()=>{let d=[];return g.forEach((a,b)=>{d.push({type:"thinking",key:`thinking-${b}`,content:a.content,duration:a.duration})}),a.forEach(a=>{let e,g=b?.get(a.toolCallId);d.push({type:"tool",tool:a,result:g,status:(0,f.s2)(g,h),duration:c?.get(a.toolCallId),meta:{label:(e=(0,w.wS)(a)).label,summary:e.summary,kind:e.kind}})}),d},[c,h,b,g,a]),v=(0,e.useMemo)(()=>(function(a,b){let c=[],d=[],e=()=>{d.length>=3?c.push({type:"contextGroup",key:d.map(a=>a.tool.toolCallId).join(":"),tools:d}):c.push(...d),d=[]};for(let g of a){var f;if("tool"===g.type&&(f=g.tool,x.has((0,w.WI)(f.toolName)))&&(!b||"running"!==g.status)){d.push(g);continue}e(),c.push(g)}return e(),c})(u,h),[h,u]),A=u.filter(a=>"tool"===a.type),B=A.filter(a=>"running"===a.status),C=B.length>0,[D,E]=(0,e.useState)(null),F=!t&&(!!h||C),G=D??F,H=A.length+g.length,I=B[B.length-1]?.meta.summary;if(0===H)return null;let J=(j=A.filter(a=>"running"===a.status),m=A.filter(a=>"success"===a.status).length,n=A.filter(a=>"error"===a.status).length,s=A.filter(a=>"unknown"===a.status).length,[A.length>0?`${A.length} ${1===A.length?"tool":"tools"}`:null,g.length>0?`${g.length} ${1===g.length?"thought":"thoughts"}`:null,j.length>0?`${j.length} running`:null,m>0?`${m} completed`:null,n>0?`${n} failed`:null,s>0?`${s} unknown`:null].filter(Boolean));return(0,d.jsxs)(k,{children:[(0,d.jsx)(o,{expanded:G,total:H,summary:J.join(" \xb7 "),runningDescription:I,onToggle:()=>E(a=>!(a??F))}),G&&(0,d.jsx)(l,{children:v.map(a=>"thinking"===a.type?(0,d.jsx)(p,{item:a,isStreaming:!!h},a.key):"contextGroup"===a.type?(0,d.jsx)(q,{item:a,cwd:i},a.key):(0,d.jsx)(r,{item:a,cwd:i},a.tool.toolCallId))})]})}},31218:(a,b,c)=>{"use strict";c.d(b,{u:()=>u});var d=c(48249),e=c(67484),f=c(2857),g=c(7952);let h=["--bg","--bg-panel","--bg-hover","--bg-selected","--border","--text","--text-muted","--text-dim","--accent","--accent-hover"];async function i(a){if(navigator.clipboard?.writeText)return void await navigator.clipboard.writeText(a);let b=document.createElement("textarea");b.value=a,b.style.position="fixed",b.style.inset="0",b.style.opacity="0",document.body.appendChild(b),b.focus(),b.select();let c=document.execCommand("copy");if(document.body.removeChild(b),!c)throw Error("Clipboard copy failed.")}async function j(a){let b=await k(a.code);if(b)return b;if(a.capture)return function(a){if(!a.html)throw Error("The widget did not provide capturable HTML.");let b=n({width:a.bodyWidth||640,height:a.bodyHeight||360}),c=function(a){let b=document.createElement("template");b.innerHTML=(0,g.L$)(a.html||"");let c=document.createElement("div");for(let d of(c.appendChild(b.content.cloneNode(!0)),Array.from(c.querySelectorAll("img[data-canvas-export]")))){let b=Number(d.getAttribute("data-canvas-export")),c=Number.isFinite(b)?a.canvases?.[b]:null;if(!c?.dataUrl){d.remove();continue}d.setAttribute("src",c.dataUrl),d.setAttribute("width",String(c.width)),d.setAttribute("height",String(c.height)),d.setAttribute("style",function(a,b){let c=new Map;for(let b of(a||"").split(";")){let[a,...d]=b.split(":");a?.trim()&&d.length>0&&c.set(a.trim(),d.join(":").trim())}for(let[a,d]of Object.entries(b))c.set(a,d);return Array.from(c.entries()).map(([a,b])=>a+":"+b).join(";")}(d.getAttribute("style"),{width:c.width+"px",height:c.height+"px",display:"block"}))}return l(c),Array.from(c.childNodes).map(a=>new XMLSerializer().serializeToString(a)).join("")}(a);if(!c.trim())throw Error("The widget capture was empty.");let d=[a.styles||"","#__widget_export_root{"+function(){if("u"<typeof document)return"";let a=getComputedStyle(document.documentElement);return h.map(b=>{let c=a.getPropertyValue(b).trim();return c?b+":"+c+";":""}).join("")}()+'font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",system-ui,sans-serif;font-size:14px;line-height:1.6;color:var(--text,#1a1a1a);background:transparent;}',"#__widget_export_root *{box-sizing:border-box;}\n#__widget_export_root svg{max-width:100%;height:auto;display:block;}"].join("\n");return p(q('<svg xmlns="http://www.w3.org/2000/svg" width="'+b.width+'" height="'+b.height+'" viewBox="0 0 '+b.width+" "+b.height+'"><defs><style><![CDATA['+d.replace(/\]\]>/g,"]]]]><![CDATA[>")+']]></style></defs><foreignObject x="0" y="0" width="100%" height="100%">'+('<div xmlns="http://www.w3.org/1999/xhtml" id="__widget_export_root" style="width:'+b.width+"px;min-height:")+b.height+'px;overflow:visible;">'+c+"</div></foreignObject></svg>"),b.width,b.height)}(a.capture);throw Error("PNG export needs a rendered widget capture.")}async function k(a){var b;let c,d,e,f,h=function(a){let b=(0,g.L$)(a).trim();if(!/^<\s*(style|svg)\b/i.test(b))return null;let c=new DOMParser().parseFromString(b,"text/html"),d=Array.from(c.body.children),e=d.filter(a=>"svg"===a.tagName.toLowerCase()),f=d.filter(a=>"style"!==a.tagName.toLowerCase());if(1!==e.length||1!==f.length)return null;let h=e[0].cloneNode(!0),i=Array.from(c.body.querySelectorAll("style")).map(a=>a.textContent||"").join("\n").trim();if(i){let a=document.createElementNS("http://www.w3.org/2000/svg","style");a.textContent=i,h.insertBefore(a,h.firstChild)}return h}(a);if(!h)return null;l(h),h.setAttribute("xmlns","http://www.w3.org/2000/svg");let i=n((c=function(a){if(!a)return null;let b=a.trim().split(/[\s,]+/).map(Number);return 4!==b.length||b.some(a=>!Number.isFinite(a))||b[2]<=0||b[3]<=0?null:{width:b[2],height:b[3]}}((b=h).getAttribute("viewBox")),d=m(b.getAttribute("width"))??c?.width??640,e=c?c.height/c.width:.5625,f=m(b.getAttribute("height"))??c?.height??d*e,{width:d,height:f}));return h.setAttribute("width",String(i.width)),h.setAttribute("height",String(i.height)),h.getAttribute("viewBox")||h.setAttribute("viewBox","0 0 "+i.width+" "+i.height),p(q(new XMLSerializer().serializeToString(h)),i.width,i.height)}function l(a){for(let b of Array.from(a.querySelectorAll("script, iframe, object, embed, meta, link, base, form")))b.remove();for(let b of[a,...Array.from(a.querySelectorAll("*"))])for(let a of Array.from(b.attributes)){let c=a.name.toLowerCase(),d=a.value.trim();if(c.startsWith("on")){b.removeAttribute(a.name);continue}("href"===c||"src"===c||c.endsWith(":href"))&&/^\s*(javascript|data:text\/html)/i.test(d)&&b.removeAttribute(a.name)}}function m(a){if(!a||a.includes("%"))return null;let b=Number.parseFloat(a);return Number.isFinite(b)&&b>0?b:null}function n(a){let b=o(Math.ceil(a.width||640),240,2e3),c=o(Math.ceil(a.height||360),80,4e3),d=b*c;if(d>8e6){let a=Math.sqrt(8e6/d);b=Math.max(240,Math.floor(b*a)),c=Math.max(80,Math.floor(c*a))}return{width:b,height:c}}function o(a,b,c){return Math.min(Math.max(a,b),c)}function p(a,b,c){return new Promise((d,e)=>{let f=new Image,g=URL.createObjectURL(new Blob([a],{type:"image/svg+xml;charset=utf-8"}));f.onload=()=>{URL.revokeObjectURL(g);try{let a=document.createElement("canvas"),g=Math.min(window.devicePixelRatio||1,2);a.width=Math.ceil(b*g),a.height=Math.ceil(c*g),a.style.width=b+"px",a.style.height=c+"px";let h=a.getContext("2d");if(!h)throw Error("Canvas is not available.");h.scale(g,g),h.drawImage(f,0,0,b,c),a.toBlob(a=>{a?d(a):e(Error("Canvas export returned no image."))},"image/png")}catch(a){e(a instanceof Error?a:Error("PNG export failed."))}},f.onerror=()=>{URL.revokeObjectURL(g),e(Error("The browser could not render this widget as PNG."))},f.src=g})}function q(a){if("u"<typeof document)return a;let b=getComputedStyle(document.documentElement);return a.replace(/var\(\s*(--[a-zA-Z0-9_-]+)(?:\s*,\s*([^)]+))?\)/g,(a,c,d)=>b.getPropertyValue(c).trim()||d?.trim()||"#000")}let r=/cdnjs\.cloudflare\.com|cdn\.jsdelivr\.net|unpkg\.com|esm\.sh/,s=new Map;function t(a){return a.slice(0,200)}function u({code:a,isStreaming:b,title:c,showOverlay:h,onSendMessage:k}){let{isDark:l}=(0,f.D)(),m=(0,e.useRef)(null);(0,e.useRef)(null);let n=(0,e.useRef)(null),o=(0,e.useRef)(new Map),p=(0,e.useRef)(""),[q,v]=(0,e.useState)(!1),[w,x]=(0,e.useState)(()=>s.get(t(a))??0),[y,z]=(0,e.useState)(!1),[A,B]=(0,e.useState)(!1),[C,D]=(0,e.useState)(null),[E,F]=(0,e.useState)(!1),[G,H]=(0,e.useState)(!1),[I,J]=(0,e.useState)(null);(0,e.useRef)("");let K=(0,e.useRef)((s.get(t(a))??0)>0);(0,e.useRef)(!1);let L=(0,e.useRef)(l),[M,N]=(0,e.useState)(()=>(0,g.sM)((0,g.f7)({}),L.current)),O=(0,e.useCallback)(a=>{n.current&&clearTimeout(n.current),D(a),n.current=setTimeout(()=>D(null),1800)},[]),P=(0,e.useMemo)(()=>r.test(a),[a]);(0,e.useCallback)(a=>{let b=m.current;b?.contentWindow&&a!==p.current&&(p.current=a,b.contentWindow.postMessage({type:"widget:update",html:a},"*"))},[]);let Q=(0,e.useCallback)(()=>{let a=m.current?.contentWindow;return a?new Promise((b,c)=>{let d=`${Date.now()}-${Math.random().toString(36).slice(2)}`,e=setTimeout(()=>{o.current.delete(d),c(Error("Timed out waiting for widget capture."))},2500);o.current.set(d,{resolve:b,reject:c,timeout:e}),a.postMessage({type:"widget:capture",requestId:d},"*")}):Promise.reject(Error("Widget iframe is not ready."))},[]),R=(0,e.useCallback)(async()=>{try{let b;await i((b={widget_code:a},c?.trim()&&(b.title=c.trim()),"```show-widget\n"+JSON.stringify(b,null,2)+"\n```")),O("Copied source")}catch{O("Copy failed")}},[a,c,O]),S=(0,e.useCallback)(async()=>{try{await i(a),O("Copied HTML/SVG")}catch{O("Copy failed")}},[a,O]),T=(0,e.useCallback)(async()=>{if(!b&&!E){F(!0),O("Exporting PNG...");try{var d,e;let b,f,g;try{b=await j({code:a})}catch{let c=await Q();b=await j({code:a,capture:c})}d=b,e=`${((c||"widget").trim()||"widget").replace(/[^a-zA-Z0-9._-]+/g,"_").replace(/^_+|_+$/g,"")||"widget"}.png`,f=URL.createObjectURL(d),(g=document.createElement("a")).href=f,g.download=e,document.body.appendChild(g),g.click(),document.body.removeChild(g),URL.revokeObjectURL(f),O("Downloaded PNG")}catch(a){console.warn("[WidgetRenderer] PNG export failed:",a),O("PNG export unavailable")}finally{F(!1)}}},[a,c,b,E,Q,O]),U=h||P&&!b&&q&&!G,V={width:24,height:22,padding:0,background:"var(--bg-hover)",color:"var(--text-dim)",border:"1px solid var(--border)",borderRadius:3,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},W={...V,width:48,fontSize:10,whiteSpace:"nowrap"};return(0,d.jsxs)("div",{className:"widget-frame",style:{position:A?"fixed":"relative",inset:A?12:void 0,zIndex:A?1e3:void 0,marginTop:4*!A,marginBottom:4*!A,borderRadius:A?8:6,background:A?"var(--bg)":void 0,boxShadow:A?"0 24px 80px rgba(0, 0, 0, 0.35)":void 0,display:A?"flex":void 0,flexDirection:A?"column":void 0},children:[(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"4px 10px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderBottom:"none",borderRadius:`${A?8:6}px ${A?8:6}px 0 0`,fontSize:11,color:"var(--text-dim)",minHeight:26,flexShrink:0},children:[(0,d.jsx)("span",{style:{fontWeight:600,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:c||"Widget"}),b&&(0,d.jsx)("span",{style:{fontSize:10,color:"var(--accent)",animation:"pulse 1.5s infinite",flexShrink:0},children:"streaming…"}),C&&(0,d.jsx)("span",{"aria-live":"polite",style:{marginLeft:"auto",fontSize:10,color:"var(--text-muted)",flexShrink:0},children:C}),(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4,marginLeft:C?0:"auto",flexShrink:0},children:[(0,d.jsx)("button",{type:"button",onClick:R,title:"Copy show-widget source","aria-label":"Copy show-widget source",style:V,children:(0,d.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("polyline",{points:"16 18 22 12 16 6"}),(0,d.jsx)("polyline",{points:"8 6 2 12 8 18"})]})}),(0,d.jsx)("button",{type:"button",onClick:S,title:"Copy widget HTML/SVG","aria-label":"Copy widget HTML/SVG",style:V,children:(0,d.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),(0,d.jsx)("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}),(0,d.jsx)("button",{type:"button",onClick:T,disabled:b||E,title:b?"PNG export is available after streaming finishes":"Export widget as PNG","aria-label":"Export widget as PNG",style:{...V,...b||E?{opacity:.45,cursor:"not-allowed"}:null},children:E?(0,d.jsx)("span",{style:{fontSize:9},children:"..."}):(0,d.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,d.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,d.jsx)("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}),(0,d.jsx)("button",{type:"button",onClick:()=>B(a=>!a),title:A?"Exit full screen":"View full screen","aria-label":A?"Exit full screen":"View full screen",style:V,children:A?(0,d.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("polyline",{points:"4 14 10 14 10 20"}),(0,d.jsx)("polyline",{points:"20 10 14 10 14 4"}),(0,d.jsx)("line",{x1:"14",y1:"10",x2:"21",y2:"3"}),(0,d.jsx)("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]}):(0,d.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("polyline",{points:"15 3 21 3 21 9"}),(0,d.jsx)("polyline",{points:"9 21 3 21 3 15"}),(0,d.jsx)("line",{x1:"21",y1:"3",x2:"14",y2:"10"}),(0,d.jsx)("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]})}),(0,d.jsx)("button",{type:"button",onClick:()=>z(a=>!a),title:y?"Show widget preview":"Show widget code","aria-pressed":y,style:W,children:y?"Preview":"Code"})]})]}),y&&(0,d.jsx)("pre",{style:{margin:0,padding:"8px 10px",fontSize:11,fontFamily:"var(--font-mono)",color:"var(--text-muted)",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:"0 0 6px 6px",overflow:"auto",maxHeight:A?"none":400,flex:A?1:void 0,whiteSpace:"pre-wrap"},children:a}),(0,d.jsx)("iframe",{ref:m,sandbox:"allow-scripts",srcDoc:M,title:c||"Widget",onLoad:()=>{v(!0),J(null)},style:{width:"100%",height:A?"calc(100vh - 50px)":w,minHeight:w>0?void 0:80,border:"1px solid var(--border)",borderRadius:`0 0 ${A?8:6}px ${A?8:6}px`,display:y?"none":"block",overflow:"hidden",background:"transparent",flex:A?1:void 0,transition:K.current?"height 0.2s ease-out":"none"}}),I&&!y&&(0,d.jsxs)("div",{style:{border:"1px solid var(--border)",borderTop:"none",borderRadius:`0 0 ${A?8:6}px ${A?8:6}px`,padding:"12px 14px",color:"var(--text-muted)",background:"var(--bg)",fontSize:12},children:["Widget preview failed: ",I]}),U&&!y&&!I&&(0,d.jsx)("div",{className:"widget-shimmer",style:{position:"absolute",inset:0,top:26,pointerEvents:"none",borderRadius:"0 0 6px 6px"}})]})}},31343:(a,b,c)=>{"use strict";function d(a){return/^[a-zA-Z]:[\\/]/.test(a)||a.startsWith("\\\\")?a.replace(/\\/g,"/"):a}c.d(b,{HG:()=>h,HR:()=>g,WP:()=>i,e_:()=>k,qP:()=>j});let e=/^[A-Za-z]:[\\/]/;function f(a){let b=d(a),c=b.startsWith("/")||e.test(b);if(e.test(b))return b;let f=[];for(let a of b.split("/"))if(a&&"."!==a){if(".."===a){f.length>0&&".."!==f[f.length-1]?f.pop():c||f.push(a);continue}f.push(a)}return`${c?"/":""}${f.join("/")}`}function g(a,b,c){let g=a.trim().replace(/^file:\/\//i,"").replace(/[),.;:!?]+$/g,"");if(!g||g.startsWith("//"))return null;if((g=d(g)).startsWith("~/")){let a=function(a){if(!a)return null;let b=d(a),c=b.match(/^(\/Users\/[^/]+|\/home\/[^/]+)(?:\/|$)/);if(c)return c[1];let e=b.match(/^([A-Za-z]:\/Users\/[^/]+)(?:\/|$)/);return e?e[1]:null}(b);return a?f(`${a}/${g.slice(2)}`):null}if(g.startsWith("/")||e.test(g))return f(g);if(c){let a=d(c),b=a.lastIndexOf("/"),e=b>=0?a.slice(0,b):"";return f(`${e}/${g}`)}return b?f(`${b.replace(/\/+$/,"")}/${g.replace(/^\.?\//,"")}`):null}function h(a){return d(a).split("/").filter(Boolean).map(encodeURIComponent).join("/")}function i(a){let b=d(a).replace(/\/+$/,"");return b.split("/").pop()??b}function j(a,b){if(!b)return a;let c=d(a),e=d(b).replace(/\/$/,"");return c.startsWith(e+"/")?c.slice(e.length+1):a}function k(a,b){return`${d(a).replace(/\/$/,"")}/${b}`}},32056:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>i,metadata:()=>h});var d=c(5735),e=c(59452),f=c.n(e),g=c(93968);c(82704),c(25319);let h={title:"AnnoVibe",description:"AI-native bioinformatics workspace by Annoroad",icons:{icon:[{url:"/icon.svg",type:"image/svg+xml"}],shortcut:[{url:"/icon.svg",type:"image/svg+xml"}]}};function i({children:a}){return(0,d.jsxs)("html",{lang:"en",className:f().variable,suppressHydrationWarning:!0,children:[(0,d.jsx)("head",{children:(0,d.jsx)(g.default,{id:"theme-init",strategy:"beforeInteractive",children:'(function(){try{var t=localStorage.getItem("pi-theme");if(t==="dark")document.documentElement.classList.add("dark")}catch(e){}})();'})}),(0,d.jsx)("body",{style:{height:"100dvh",display:"flex",flexDirection:"column"},children:a})]})}},39868:(a,b,c)=>{"use strict";function d(a){if(navigator.clipboard?.writeText)return navigator.clipboard.writeText(a);try{let b=document.createElement("textarea");return b.value=a,b.style.position="fixed",b.style.opacity="0",document.body.appendChild(b),b.select(),document.execCommand("copy"),document.body.removeChild(b),Promise.resolve()}catch{return Promise.reject()}}c.d(b,{D:()=>d})},40648:(a,b,c)=>{"use strict";c.d(b,{n:()=>f,r:()=>g});var d=c(48249),e=c(67484);function f({children:a,duration:b=2,style:c,...g}){let[h,i]=(0,e.useState)(!1);return h?(0,d.jsx)("span",{...g,children:a}):(0,d.jsx)("span",{style:{display:"inline-block",backgroundImage:"linear-gradient(90deg, var(--text-dim) 25%, var(--text-muted) 50%, var(--text-dim) 75%)",backgroundSize:"200% 100%",backgroundClip:"text",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",color:"transparent",animation:`text-shimmer ${b}s linear infinite`,...c},...g,children:a})}function g({className:a,style:b,height:c=80}){let[f,h]=(0,e.useState)(!1),i={borderRadius:6,background:"var(--bg-panel)",overflow:"hidden",height:c,...b};return f?(0,d.jsx)("div",{className:a,style:i}):(0,d.jsx)("div",{className:a,style:i,children:(0,d.jsx)("div",{style:{width:"100%",height:"100%",background:"linear-gradient(90deg, transparent 0%, var(--bg-hover) 50%, transparent 100%)",backgroundSize:"200% 100%",animation:"surface-shimmer 1.5s ease-in-out infinite"}})})}},41044:(a,b,c)=>{"use strict";c.d(b,{Gb:()=>f,U1:()=>i,s2:()=>e});var d=c(48249);function e(a,b){return a?.isError?"error":a?"success":b?"running":"unknown"}function f(a){return"success"===a?"#16a34a":"error"===a?"#f87171":"running"===a?"#f59e0b":"var(--text-dim)"}function g(a){return"success"===a?"Done":"error"===a?"Error":"running"===a?"Running":"Unknown"}function h({status:a}){return"running"===a?(0,d.jsx)("span",{style:{width:6,height:6,borderRadius:999,background:f(a),animation:"pulse 1.2s ease-in-out infinite"}}):"success"===a?(0,d.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,d.jsx)("polyline",{points:"20 6 9 17 4 12"})}):"error"===a?(0,d.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,d.jsx)("path",{d:"m18 6-12 12"}),(0,d.jsx)("path",{d:"m6 6 12 12"})]}):(0,d.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,d.jsx)("path",{d:"M12 8v5"}),(0,d.jsx)("path",{d:"M12 16h.01"})]})}function i({status:a}){let b=f(a);return(0,d.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:5,minHeight:18,padding:"0 6px",borderRadius:999,border:`1px solid color-mix(in srgb, ${b} 35%, transparent)`,background:`color-mix(in srgb, ${b} 10%, transparent)`,color:b,fontSize:10,fontWeight:600,whiteSpace:"nowrap",flexShrink:0},title:g(a),children:[(0,d.jsx)(h,{status:a}),(0,d.jsx)("span",{children:g(a)})]})}},45396:(a,b,c)=>{Promise.resolve().then(c.t.bind(c,95547,23)),Promise.resolve().then(c.t.bind(c,15098,23)),Promise.resolve().then(c.t.bind(c,47644,23)),Promise.resolve().then(c.t.bind(c,33859,23)),Promise.resolve().then(c.t.bind(c,98099,23)),Promise.resolve().then(c.t.bind(c,16237,23)),Promise.resolve().then(c.t.bind(c,98562,23)),Promise.resolve().then(c.t.bind(c,36675,23))},51415:(a,b,c)=>{"use strict";c.d(b,{T:()=>M});var d=c(48249),e=c(67484),f=c(44885),g=c(38368),h=c(86875),i=c(56483),j=c(97376),k=c(50535),l=c(2857),m=c(19581),n=c(65950);function o({code:a,language:b,showLineNumbers:c=!0,testAsyncDelayMs:f=0}){let{isDark:g}=(0,l.D)(),h=(0,e.useMemo)(()=>(0,n.Rd)(a,b,g),[a,g,b]),[i,j]=(0,e.useState)(()=>h?.tokens??null),[k,m]=(0,e.useState)(()=>h?"cache":"raw");(0,e.useRef)("");let p=(0,e.useMemo)(()=>(0,n.nS)(a).tokens,[a]),q=i??h?.tokens??p,r="async"===k?"async":h?"cache":k;return(0,d.jsx)("pre",{"data-highlight-source":r,"data-highlight-language":b||"text",style:{margin:0,padding:"10px 12px",fontSize:12.5,lineHeight:1.6,overflow:"auto",background:"var(--bg)",fontFamily:"var(--font-mono)"},children:(0,d.jsx)("code",{children:q.map((a,b)=>(0,d.jsxs)("span",{style:{display:"block"},children:[c&&(0,d.jsx)("span",{style:{display:"inline-block",width:"2rem",textAlign:"right",marginRight:"1rem",color:"var(--text-dim)",userSelect:"none",fontFamily:"var(--font-mono)"},children:b+1}),0===a.length?"\n":a.map((a,b)=>{let c=(0,n.tG)(a.fontStyle);return(0,d.jsx)("span",{style:{color:a.color??"inherit",...c},children:a.content},b)})]},b))})})}var p=c(39868);function q({code:a,language:b,variant:c,isStreaming:f=!1,testAsyncDelayMs:g=0,activeFilePath:h,agentRunning:i,onApplyToFile:j,onRunCode:k}){let[l,n]=(0,e.useState)(!1),[r,s]=(0,e.useState)(!1),t="chat"===c&&!f,u=a.replace(/\r\n/g,"\n").replace(/\r/g,"\n").split("\n").length,v=b||"text",w=f?(0,d.jsx)("pre",{"data-highlight-source":"raw","data-highlight-language":v,style:{margin:0,padding:"10px 12px",fontSize:12.5,lineHeight:1.6,overflow:"auto",background:"var(--bg)",fontFamily:"var(--font-mono)",whiteSpace:"pre-wrap",wordBreak:"break-all",color:"var(--text)"},children:(0,d.jsx)("code",{children:a})}):(0,d.jsx)(o,{code:a,language:v,showLineNumbers:"chat"===c,testAsyncDelayMs:g});return(0,d.jsxs)(m.NG,{className:`markdown-code-block markdown-code-block-${c}`,style:{marginTop:"file"===c?12:4,marginBottom:"file"===c?12:4},children:[(0,d.jsx)(m.iO,{title:v,actions:(0,d.jsxs)(d.Fragment,{children:[t&&h&&j&&(0,d.jsx)(m.Mi,{onClick:()=>j(a,b,h??void 0),title:`Write code to ${h}`,ariaLabel:`Write code to ${h}`,label:"apply",activeLabel:"apply",active:!1}),t&&!h&&j&&(0,d.jsx)(m.Mi,{onClick:()=>j(a,b),title:"Write code to a file",ariaLabel:"Write code to a file",label:"apply...",activeLabel:"apply",active:!1}),t&&k&&!i&&(0,d.jsx)(m.Mi,{onClick:()=>k(a,b),title:"Run code in terminal and show output",ariaLabel:"Run code in terminal",label:"run",activeLabel:"run",active:!1}),(0,d.jsx)(m.Mi,{onClick:()=>{let c=b||"",d=a.includes("```")?"````":"```",e=`${d}${c}
257
257
  ${a}
258
- ${d}`;(0,p.D)(e).then(()=>{s(!0),setTimeout(()=>s(!1),1500)})},title:"Copy as Markdown fence",ariaLabel:"Copy as Markdown fence",label:"markdown",activeLabel:"md copied",active:r}),(0,d.jsx)(m.Mi,{onClick:()=>{(0,p.D)(a).then(()=>{n(!0),setTimeout(()=>n(!1),1500)})},ariaLabel:"Copy code",label:"copy",activeLabel:"copied",active:l})]})}),(0,d.jsx)(m.oG,{totalLines:u,children:w})]})}function r({chart:a}){let{isDark:b}=(0,l.D)(),[c,f]=(0,e.useState)(null),[g,h]=(0,e.useState)(null);return((0,e.useRef)(`mermaid-${Math.random().toString(36).slice(2)}`),g)?(0,d.jsxs)("div",{className:"mermaid-diagram mermaid-diagram-error",children:[(0,d.jsx)("div",{className:"mermaid-diagram-error-title",children:"Mermaid render failed"}),(0,d.jsx)("div",{className:"mermaid-diagram-error-message",children:g}),(0,d.jsx)("pre",{children:a})]}):(0,d.jsx)("div",{className:"mermaid-diagram",children:c?(0,d.jsx)("div",{className:"mermaid-diagram-canvas",dangerouslySetInnerHTML:{__html:c}}):(0,d.jsx)("div",{className:"mermaid-diagram-loading",children:"Rendering diagram..."})})}var s=c(31218),t=c(52515);function u({code:a,onAcceptDiff:b,agentRunning:c}){let f=(0,e.useMemo)(()=>(function(a){let b=a.split("\n"),c=[],d=null,e=1;for(let a of b){let b=/^\+\+\+ [ab]\/(.+)/.exec(a);if(b){d=b[1];continue}if(/^@@ /.test(a)){let b=/@@ -\d+(?:,\d+)? \+(\d+)/.exec(a);b&&(e=parseInt(b[1],10));continue}/^--- /.test(a)||(a.startsWith("+")&&!a.startsWith("+++")?c.push({type:"added",text:a.slice(1),lineNo:e++}):a.startsWith("-")&&!a.startsWith("---")?c.push({type:"removed",text:a.slice(1),lineNo:0}):a.startsWith(" ")?c.push({type:"unchanged",text:a.slice(1),lineNo:e++}):c.push({type:"unchanged",text:a,lineNo:e++}))}return{lines:c,filePath:d}})(a),[a]),g=(0,e.useMemo)(()=>(function(a){let b=0,c=0;for(let d of a)"added"===d.type&&b++,"removed"===d.type&&c++;return{added:b,removed:c}})(f.lines),[f.lines]);return(0,d.jsxs)(m.NG,{className:"markdown-code-block markdown-code-block-chat",style:{marginTop:4,marginBottom:4},children:[(0,d.jsx)(m.iO,{title:(0,d.jsxs)("span",{children:["diff ",f.filePath&&(0,d.jsx)("span",{style:{opacity:.7},children:f.filePath})," ",(0,d.jsxs)("span",{style:{color:"var(--text-dim)",fontWeight:400},children:["(",(0,d.jsxs)("span",{style:{color:"#16a34a"},children:["+",g.added]})," /"," ",(0,d.jsxs)("span",{style:{color:"#dc2626"},children:["-",g.removed]}),")"]})]}),actions:b&&!c?(0,d.jsx)(m.Mi,{onClick:()=>b(a,f.filePath),title:"Ask the agent to apply this diff",ariaLabel:"Ask the agent to apply this diff",label:"apply",activeLabel:"apply",active:!1}):void 0}),(0,d.jsx)(t.pg,{diff:f.lines,emptyLabel:"No changes detected"})]})}let v=new Set,w=new Map,x=null;function y(){return x||(x=Promise.resolve().then(c.bind(c,78908)).then(a=>{if(0===v.size){for(let b of Object.keys(a.bundledLanguages??{}))v.add(b.toLowerCase());for(let b of a.bundledLanguagesInfo??[]){let a=b.id.toLowerCase();for(let c of b.aliases??[])w.set(c.toLowerCase(),a)}}return a})),x}var z=c(7952),A=c(31343);function B(a){return a?.replace(/^language-/,"").trim()??""}function C(a){return/^[a-z][a-z\d+.-]*:/i.test(a)||a.startsWith("//")}function D(a,b,c){let d;if(!c||c.startsWith("#")||C(c))return null;let e=(d=/^([^?#]*)(.*)$/.exec(c),d?.[1]??c);if(!e)return null;let f=function(a){try{return decodeURI(a)}catch{return a}}(e);return(0,A.HR)(f,b,a)}function E(a){return`/api/files/${(0,A.HG)(a)}?type=read`}function F({value:a,baseFilePath:b,cwd:c,onOpenLocalFile:e,onOpenFileAtLine:f}){let g=(0,d.jsx)("code",{style:{background:"var(--bg-selected)",padding:"1px 4px",borderRadius:3,fontFamily:"var(--font-mono)",fontSize:"0.9em"},children:a});return/^(?:\.{1,2}\/|\/|~\/|[\w@.-]+\/)[\w@./+-]+\.[A-Za-z0-9]{1,12}:\d+$/.test(a.trim())?(0,d.jsx)(I,{href:a,baseFilePath:b,cwd:c,onOpenLocalFile:e,onOpenFileAtLine:f,style:{textDecoration:"none"},children:g}):g}function G(a){let b=/^\s*!\[([^\]]*)\]\((.+)\)\s*$/.exec(a);if(!b)return null;let c=b[2]?.trim()??"";if(!c)return null;let d=/^(.+?)\s+(?:"[^"]*"|'[^']*')\s*$/.exec(c);return{alt:b[1]?.trim()||void 0,src:(d?.[1]??c).trim()}}function H({items:a,baseFilePath:b,cwd:c,onOpenLocalFile:e}){let f=1===a.length;return(0,d.jsx)("div",{className:"report-image-gallery",style:{display:"grid",gridTemplateColumns:f?"minmax(0, 1fr)":"repeat(auto-fit, minmax(min(100%, 240px), 1fr))",gap:12,margin:"16px 0"},children:a.map((a,g)=>{let h=D(b,c,a.src),i=h?E(h):a.src,j=a.alt??a.caption??`Figure ${g+1}`,k=(0,d.jsx)("img",{src:i,alt:j,loading:"lazy",title:h??a.src,style:{display:"block",width:"100%",maxHeight:f?520:340,objectFit:"contain",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)"}});return(0,d.jsxs)("figure",{style:{margin:0,minWidth:0},children:[h&&e?(0,d.jsx)("button",{type:"button",onClick:()=>e(h,(0,A.WP)(h)),title:`Open ${h}`,style:{display:"block",width:"100%",padding:0,border:"none",background:"none",cursor:"zoom-in"},children:k}):k,a.caption&&(0,d.jsx)("figcaption",{style:{marginTop:6,color:"var(--text-muted)",fontSize:12,lineHeight:1.45},children:a.caption})]},`${a.src}-${g}`)})})}function I({href:a,children:b,baseFilePath:c,cwd:e,onOpenLocalFile:f,onOpenFileAtLine:g,title:h,...i}){let j=a?/^(.*):(\d+)$/.exec(a.replace(/[?#].*$/,"")):null,k=j?j[1]:a,l=j?parseInt(j[2],10):void 0,m=D(c,e,k),n=!!m,o=!!a&&C(a),p=m&&l?`${E(m)}#L${l}`:n?E(m):a;return(0,d.jsx)("a",{...i,href:p,target:o?"_blank":void 0,rel:o?"noreferrer":void 0,onClick:a=>{if(!m)return;a.preventDefault();let b=(0,A.WP)(m);g?g(m,b,l):f&&f(m,b)},title:n?m:h,children:b})}function J({src:a,alt:b,title:c,baseFilePath:e,cwd:f,onOpenLocalFile:g,...h}){let i="string"==typeof a?a:void 0,j=D(e,f,i),k=j?E(j):i,l=(0,d.jsx)("img",{...h,src:k,alt:b??"",loading:"lazy",title:j??c,style:{...h.style??{},cursor:k?"zoom-in":h.style?.cursor}});return k?(0,d.jsx)("a",{href:k,target:"_blank",rel:"noreferrer",title:j??c??"Open image",style:{display:"inline-block",maxWidth:"100%"},onClick:a=>{j&&g&&(a.preventDefault(),g(j,(0,A.WP)(j)))},children:l}):l}function K({code:a,language:b,variant:c,isStreaming:e=!1,baseFilePath:f,cwd:g,onOpenLocalFile:h,onWidgetSendMessage:i,renderVisualCodeBlocks:j=!1,testAsyncCodeDelayMs:k=0,activeFilePath:l,agentRunning:m,onApplyToFile:n,onRunCode:o,onAcceptDiff:p}){let t,v,w,x;if("mermaid"===(t=b.trim().toLowerCase())||"mmd"===t)return(0,d.jsx)(r,{chart:a});if("diff"===(v=b.trim().toLowerCase())||"patch"===v||"unified-diff"===v)return(0,d.jsx)(u,{code:a,onAcceptDiff:p,agentRunning:m});if("show-widget"===b.trim().toLowerCase()){let b,c=(b=(0,z.aH)(`\`\`\`show-widget
258
+ ${d}`;(0,p.D)(e).then(()=>{s(!0),setTimeout(()=>s(!1),1500)})},title:"Copy as Markdown fence",ariaLabel:"Copy as Markdown fence",label:"markdown",activeLabel:"md copied",active:r}),(0,d.jsx)(m.Mi,{onClick:()=>{(0,p.D)(a).then(()=>{n(!0),setTimeout(()=>n(!1),1500)})},ariaLabel:"Copy code",label:"copy",activeLabel:"copied",active:l})]})}),(0,d.jsx)(m.oG,{totalLines:u,children:w})]})}function r({chart:a}){let{isDark:b}=(0,l.D)(),[c,f]=(0,e.useState)(null),[g,h]=(0,e.useState)(null);return((0,e.useId)().replace(/:/g,""),g)?(0,d.jsxs)("div",{className:"mermaid-diagram mermaid-diagram-error",children:[(0,d.jsx)("div",{className:"mermaid-diagram-error-title",children:"Mermaid render failed"}),(0,d.jsx)("div",{className:"mermaid-diagram-error-message",children:g}),(0,d.jsx)("pre",{children:a})]}):(0,d.jsx)("div",{className:"mermaid-diagram",children:c?(0,d.jsx)("div",{className:"mermaid-diagram-canvas",dangerouslySetInnerHTML:{__html:c}}):(0,d.jsx)("div",{className:"mermaid-diagram-loading",children:"Rendering diagram..."})})}var s=c(31218),t=c(52515);function u({code:a,onAcceptDiff:b,agentRunning:c}){let f=(0,e.useMemo)(()=>(function(a){let b=a.split("\n"),c=[],d=null,e=1;for(let a of b){let b=/^\+\+\+ [ab]\/(.+)/.exec(a);if(b){d=b[1];continue}if(/^@@ /.test(a)){let b=/@@ -\d+(?:,\d+)? \+(\d+)/.exec(a);b&&(e=parseInt(b[1],10));continue}/^--- /.test(a)||(a.startsWith("+")&&!a.startsWith("+++")?c.push({type:"added",text:a.slice(1),lineNo:e++}):a.startsWith("-")&&!a.startsWith("---")?c.push({type:"removed",text:a.slice(1),lineNo:0}):a.startsWith(" ")?c.push({type:"unchanged",text:a.slice(1),lineNo:e++}):c.push({type:"unchanged",text:a,lineNo:e++}))}return{lines:c,filePath:d}})(a),[a]),g=(0,e.useMemo)(()=>(function(a){let b=0,c=0;for(let d of a)"added"===d.type&&b++,"removed"===d.type&&c++;return{added:b,removed:c}})(f.lines),[f.lines]);return(0,d.jsxs)(m.NG,{className:"markdown-code-block markdown-code-block-chat",style:{marginTop:4,marginBottom:4},children:[(0,d.jsx)(m.iO,{title:(0,d.jsxs)("span",{children:["diff ",f.filePath&&(0,d.jsx)("span",{style:{opacity:.7},children:f.filePath})," ",(0,d.jsxs)("span",{style:{color:"var(--text-dim)",fontWeight:400},children:["(",(0,d.jsxs)("span",{style:{color:"#16a34a"},children:["+",g.added]})," /"," ",(0,d.jsxs)("span",{style:{color:"#dc2626"},children:["-",g.removed]}),")"]})]}),actions:b&&!c?(0,d.jsx)(m.Mi,{onClick:()=>b(a,f.filePath),title:"Ask the agent to apply this diff",ariaLabel:"Ask the agent to apply this diff",label:"apply",activeLabel:"apply",active:!1}):void 0}),(0,d.jsx)(t.pg,{diff:f.lines,emptyLabel:"No changes detected"})]})}let v=new Set,w=new Map,x=null;function y(){return x||(x=Promise.resolve().then(c.bind(c,78908)).then(a=>{if(0===v.size){for(let b of Object.keys(a.bundledLanguages??{}))v.add(b.toLowerCase());for(let b of a.bundledLanguagesInfo??[]){let a=b.id.toLowerCase();for(let c of b.aliases??[])w.set(c.toLowerCase(),a)}}return a})),x}var z=c(7952),A=c(31343);function B(a){return a?.replace(/^language-/,"").trim()??""}function C(a){return/^[a-z][a-z\d+.-]*:/i.test(a)||a.startsWith("//")}function D(a,b,c){let d;if(!c||c.startsWith("#")||C(c))return null;let e=(d=/^([^?#]*)(.*)$/.exec(c),d?.[1]??c);if(!e)return null;let f=function(a){try{return decodeURI(a)}catch{return a}}(e);return(0,A.HR)(f,b,a)}function E(a){return`/api/files/${(0,A.HG)(a)}?type=read`}function F({value:a,baseFilePath:b,cwd:c,onOpenLocalFile:e,onOpenFileAtLine:f}){let g=(0,d.jsx)("code",{style:{background:"var(--bg-selected)",padding:"1px 4px",borderRadius:3,fontFamily:"var(--font-mono)",fontSize:"0.9em"},children:a});return/^(?:\.{1,2}\/|\/|~\/|[\w@.-]+\/)[\w@./+-]+\.[A-Za-z0-9]{1,12}:\d+$/.test(a.trim())?(0,d.jsx)(I,{href:a,baseFilePath:b,cwd:c,onOpenLocalFile:e,onOpenFileAtLine:f,style:{textDecoration:"none"},children:g}):g}function G(a){let b=/^\s*!\[([^\]]*)\]\((.+)\)\s*$/.exec(a);if(!b)return null;let c=b[2]?.trim()??"";if(!c)return null;let d=/^(.+?)\s+(?:"[^"]*"|'[^']*')\s*$/.exec(c);return{alt:b[1]?.trim()||void 0,src:(d?.[1]??c).trim()}}function H({items:a,baseFilePath:b,cwd:c,onOpenLocalFile:e}){let f=1===a.length;return(0,d.jsx)("div",{className:"report-image-gallery",style:{display:"grid",gridTemplateColumns:f?"minmax(0, 1fr)":"repeat(auto-fit, minmax(min(100%, 240px), 1fr))",gap:12,margin:"16px 0"},children:a.map((a,g)=>{let h=D(b,c,a.src),i=h?E(h):a.src,j=a.alt??a.caption??`Figure ${g+1}`,k=(0,d.jsx)("img",{src:i,alt:j,loading:"lazy",title:h??a.src,style:{display:"block",width:"100%",maxHeight:f?520:340,objectFit:"contain",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)"}});return(0,d.jsxs)("figure",{style:{margin:0,minWidth:0},children:[h&&e?(0,d.jsx)("button",{type:"button",onClick:()=>e(h,(0,A.WP)(h)),title:`Open ${h}`,style:{display:"block",width:"100%",padding:0,border:"none",background:"none",cursor:"zoom-in"},children:k}):k,a.caption&&(0,d.jsx)("figcaption",{style:{marginTop:6,color:"var(--text-muted)",fontSize:12,lineHeight:1.45},children:a.caption})]},`${a.src}-${g}`)})})}function I({href:a,children:b,baseFilePath:c,cwd:e,onOpenLocalFile:f,onOpenFileAtLine:g,title:h,...i}){let j=a?/^(.*):(\d+)$/.exec(a.replace(/[?#].*$/,"")):null,k=j?j[1]:a,l=j?parseInt(j[2],10):void 0,m=D(c,e,k),n=!!m,o=!!a&&C(a),p=m&&l?`${E(m)}#L${l}`:n?E(m):a;return(0,d.jsx)("a",{...i,href:p,target:o?"_blank":void 0,rel:o?"noreferrer":void 0,onClick:a=>{if(!m)return;a.preventDefault();let b=(0,A.WP)(m);g?g(m,b,l):f&&f(m,b)},title:n?m:h,children:b})}function J({src:a,alt:b,title:c,baseFilePath:e,cwd:f,onOpenLocalFile:g,...h}){let i="string"==typeof a?a:void 0,j=D(e,f,i),k=j?E(j):i,l=(0,d.jsx)("img",{...h,src:k,alt:b??"",loading:"lazy",title:j??c,style:{...h.style??{},cursor:k?"zoom-in":h.style?.cursor}});return k?(0,d.jsx)("a",{href:k,target:"_blank",rel:"noreferrer",title:j??c??"Open image",style:{display:"inline-block",maxWidth:"100%"},onClick:a=>{j&&g&&(a.preventDefault(),g(j,(0,A.WP)(j)))},children:l}):l}function K({code:a,language:b,variant:c,isStreaming:e=!1,baseFilePath:f,cwd:g,onOpenLocalFile:h,onWidgetSendMessage:i,renderVisualCodeBlocks:j=!1,testAsyncCodeDelayMs:k=0,activeFilePath:l,agentRunning:m,onApplyToFile:n,onRunCode:o,onAcceptDiff:p}){let t,v,w,x;if("mermaid"===(t=b.trim().toLowerCase())||"mmd"===t)return(0,d.jsx)(r,{chart:a});if("diff"===(v=b.trim().toLowerCase())||"patch"===v||"unified-diff"===v)return(0,d.jsx)(u,{code:a,onAcceptDiff:p,agentRunning:m});if("show-widget"===b.trim().toLowerCase()){let b,c=(b=(0,z.aH)(`\`\`\`show-widget
259
259
  ${a}
260
260
  \`\`\``).find(a=>"widget"===a.type),b?.type==="widget"?{title:b.title,code:b.code}:null);if(c)return(0,d.jsx)(s.u,{code:c.code,isStreaming:!1,title:c.title,onSendMessage:i})}if("report-gallery"===b.trim().toLowerCase()){let b=function(a){try{let b=JSON.parse(a);if(!Array.isArray(b))return null;let c=b.flatMap(a=>a&&"object"==typeof a&&"string"==typeof a.src&&a.src.trim()?[{src:a.src.trim(),alt:"string"==typeof a.alt&&a.alt.trim()?a.alt.trim():void 0,caption:"string"==typeof a.caption&&a.caption.trim()?a.caption.trim():void 0}]:[]);return c.length>0?c.slice(0,12):null}catch{return null}}(a);if(b)return(0,d.jsx)(H,{items:b,baseFilePath:f,cwd:g,onOpenLocalFile:h})}return j&&(w=b.trim().toLowerCase(),(x=a.trim())&&("svg"===w||"xml"===w&&/^<svg[\s>]/i.test(x)?/^<svg[\s>]/i.test(x):!("html"!==w||/<!doctype|<html[\s>]|<head[\s>]|<body[\s>]/i.test(x))&&/^<(style|svg|div|section|article|main|figure|canvas)\b/i.test(x)))?(0,d.jsx)(s.u,{code:a,isStreaming:!1,title:`${b||"visual"} preview`,onSendMessage:i}):(0,d.jsx)(q,{code:a,language:b,variant:c,isStreaming:e,testAsyncDelayMs:k,activeFilePath:l,agentRunning:m,onApplyToFile:n,onRunCode:o})}function L({children:a,className:b,node:c,baseFilePath:e,cwd:f,onOpenLocalFile:g,onWidgetSendMessage:h,renderVisualCodeBlocks:i=!1,isStreaming:j=!1,testAsyncCodeDelayMs:k=0,activeFilePath:l,agentRunning:m,onApplyToFile:n,onRunCode:o,onOpenFileAtLine:p,onAcceptDiff:q,...r}){let s=("string"==typeof a?a:Array.isArray(a)?a.map(a=>"string"==typeof a?a:"").join(""):"").replace(/\n$/,""),t=B(b);return"data-block"in r?(0,d.jsx)(K,{code:s,language:t,variant:"chat",isStreaming:j||!!r["data-incomplete"],baseFilePath:e,cwd:f,onOpenLocalFile:g,onWidgetSendMessage:h,renderVisualCodeBlocks:i,testAsyncCodeDelayMs:k,activeFilePath:l,agentRunning:m,onApplyToFile:n,onRunCode:o,onAcceptDiff:q}):(0,d.jsx)(F,{value:s,baseFilePath:e,cwd:f,onOpenLocalFile:g,onOpenFileAtLine:p})}function M({content:a,className:b="markdown-body",style:c,codeBlockVariant:m="chat",baseFilePath:o,cwd:p,onOpenLocalFile:q,onWidgetSendMessage:r,renderVisualCodeBlocks:s=!1,enableImageGallery:t=!1,isStreaming:u=!1,renderer:x="react-markdown",testAsyncCodeDelayMs:z=0,activeFilePath:A,agentRunning:C,onApplyToFile:D,onRunCode:E,onOpenFileAtLine:H,onAcceptDiff:N}){let O,P,{isDark:Q}=(0,l.D)(),R=t?function(a){let b=a.split("\n"),c=[],d=0;for(;d<b.length;){if(!G(b[d])){c.push(b[d]),d+=1;continue}let a=[],e=d;for(;e<b.length;){let c=G(b[e]);if(!c)break;let d=e+1,f=d;for(;f<b.length&&!b[f].trim();)f+=1;let g=f<b.length?function(a){let b=/^\s*(?:_([^_]+)_|\*([^*]+)\*)\s*$/.exec(a);return(b?.[1]??b?.[2]??"").trim()||null}(b[f]):null;g&&(c.caption=g,d=f+1),a.push(c);let h=d;for(;h<b.length&&!b[h].trim();)h+=1;if(!G(b[h])){e=d;break}e=h}if(a.length>1||a.some(a=>a.caption)){c.push(["```report-gallery",JSON.stringify(a,null,2),"```"].join("\n")),d=e;continue}c.push(b[d]),d+=1}return c.join("\n")}(a):a,S=H?(O=R.split("\n"),P=!1,O.map(a=>/^\s*(```|~~~)/.test(a)?(P=!P,a):P||/\]\([^)]*$/.test(a)?a:a.replace(/(^|[\s([{"'])((?:\.{1,2}\/|\/|~\/|[\w@.-]+\/)[\w@./+-]+\.[A-Za-z0-9]{1,12}:\d+)\b/g,(a,b,c)=>`${b}[${c}](${c})`)).join("\n")):R,T=(0,e.useMemo)(()=>u?{cjk:i.h,math:j.D,mermaid:k.a}:{cjk:i.h,math:j.D,mermaid:k.a,code:function(a,b=[n.cx,n.aU]){return y(),{name:"shiki",type:"code-highlighter",getSupportedLanguages:()=>[...v],getThemes:()=>b,supportsLanguage(a){let b;return 0===v.size||null!==((b=a.trim().toLowerCase())?v.has(b)?b:w.get(b)??null:null)},highlight(b,c){let d=b.language,e=(0,n.wY)(b.code,d,a,a=>{c?.({tokens:a.tokens,bg:a.bg,fg:a.fg})});return e?{tokens:e.tokens,bg:e.bg,fg:e.fg}:(y(),null)}}}(Q)},[Q,u]);return"streamdown"!==x||o||t?(0,d.jsx)("div",{className:b,style:c,children:(0,d.jsx)(f.oz,{remarkPlugins:[g.A],components:{code({className:a,children:b,node:c}){let e=B(a),f=String(b),g=f.replace(/\n$/,"");return a?.includes("language-")||f.includes("\n")?(0,d.jsx)(K,{code:g,language:e,variant:m,isStreaming:u,baseFilePath:o,cwd:p,onOpenLocalFile:q,onWidgetSendMessage:r,renderVisualCodeBlocks:s,testAsyncCodeDelayMs:z,activeFilePath:A,agentRunning:C,onApplyToFile:D,onRunCode:E,onAcceptDiff:N}):(0,d.jsx)(F,{value:g,baseFilePath:o,cwd:p,onOpenLocalFile:q,onOpenFileAtLine:H})},pre:({children:a})=>(0,d.jsx)(d.Fragment,{children:a}),a:({href:a,children:b,node:c,...e})=>(0,d.jsx)(I,{...e,href:a,baseFilePath:o,cwd:p,onOpenLocalFile:q,onOpenFileAtLine:H,children:b}),img:({src:a,alt:b,node:c,...e})=>(0,d.jsx)(J,{...e,src:a,alt:b,baseFilePath:o,cwd:p,onOpenLocalFile:q})},children:S})}):(0,d.jsx)("div",{className:b,style:c,children:(0,d.jsx)(h.jH,{mode:u?"streaming":"static",isAnimating:!!u,plugins:T,components:{code:({children:a,className:b,node:c,...e})=>(0,d.jsx)(L,{...e,node:c,className:b,baseFilePath:o,cwd:p,onOpenLocalFile:q,onWidgetSendMessage:r,renderVisualCodeBlocks:s,isStreaming:u,testAsyncCodeDelayMs:z,activeFilePath:A,agentRunning:C,onApplyToFile:D,onRunCode:E,onOpenFileAtLine:H,onAcceptDiff:N,children:a}),a:({href:a,children:b,node:c,...e})=>(0,d.jsx)(I,{...e,href:a,baseFilePath:o,cwd:p,onOpenLocalFile:q,onOpenFileAtLine:H,children:b}),img:({src:a,alt:b,node:c,...e})=>(0,d.jsx)(J,{...e,src:a,alt:b,baseFilePath:o,cwd:p,onOpenLocalFile:q})},children:S})})}},51810:(a,b,c)=>{Promise.resolve().then(c.t.bind(c,81921,23))},52515:(a,b,c)=>{"use strict";c.d(b,{K$:()=>h,Ph:()=>g,Tg:()=>m,fj:()=>f,mK:()=>i,ml:()=>j,nG:()=>k,pg:()=>l,v7:()=>e});var d=c(48249);function e(a){return a<1024?`${a} B`:a<1048576?`${(a/1024).toFixed(1)} KB`:`${(a/1048576).toFixed(1)} MB`}function f({children:a,style:b}){return(0,d.jsx)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden",...b},children:a})}function g({children:a,style:b}){return(0,d.jsx)("div",{style:{flex:1,overflow:"auto",background:"var(--bg)",...b},children:a})}function h({pathLabel:a,title:b,trailing:c,style:e}){return(0,d.jsxs)("div",{"data-file-viewer-surface":"status-bar",style:{display:"flex",alignItems:"center",gap:12,padding:"4px 16px",borderBottom:"1px solid var(--border)",fontSize:11,color:"var(--text-dim)",background:"var(--bg)",flexShrink:0,...e},children:[(0,d.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"var(--font-mono)"},title:b??a,children:a}),c]})}function i({watching:a}){return(0,d.jsxs)("span",{title:a?"Live sync active":"Not watching",style:{display:"flex",alignItems:"center",gap:4,color:a?"#4ade80":"var(--text-dim)"},children:[(0,d.jsx)("span",{style:{width:7,height:7,borderRadius:"50%",background:a?"#4ade80":"var(--border)",display:"inline-block",boxShadow:a?"0 0 4px #4ade80":"none"}}),a?"live":"static"]})}function j({children:a,onClick:b,title:c,disabled:e=!1,active:f=!1,emphasis:g="default",style:h}){let i="primary"==g,k="danger"==g;return(0,d.jsx)("button",{"data-file-viewer-surface":"toolbar-button",onClick:b,disabled:e,title:c,style:{padding:"2px 10px",fontSize:11,cursor:e?"not-allowed":"pointer",background:i?"var(--accent)":k?"rgba(239,68,68,0.1)":f?"var(--bg-selected)":"var(--bg-hover)",color:i?"#fff":k?"#ef4444":f?"var(--text)":"var(--text-muted)",border:`1px solid ${i?"var(--accent)":k?"rgba(239,68,68,0.3)":"var(--border)"}`,borderRadius:5,fontWeight:f||i||k?600:400,opacity:e?.6:1,...h},children:a})}function k({children:a,tone:b="muted",style:c}){return(0,d.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",padding:24,color:"error"===b?"#f87171":"var(--text-muted)",fontSize:13,textAlign:"center",...c},children:a})}function l({diff:a,emptyLabel:b="No changes"}){if(!a.some(a=>"unchanged"!==a.type))return(0,d.jsx)("div",{style:{padding:"12px 16px",fontSize:12,color:"var(--text-dim)",fontFamily:"var(--font-mono)"},children:b});let c=new Set(a.flatMap((a,b)=>"unchanged"!==a.type?[b]:[])),e=new Set;for(let b of c)for(let c=Math.max(0,b-3);c<=Math.min(a.length-1,b+3);c++)e.add(c);let f=[],g=0;for(;g<a.length;)if(e.has(g)){let b=[];for(;g<a.length&&e.has(g);)b.push(a[g]),g++;f.push({hidden:!1,lines:b})}else{let b=0;for(;g<a.length&&!e.has(g);)b++,g++;f.push({hidden:!0,count:b})}let h=[],i=1;for(let b of a)"removed"===b.type?h.push(0):h.push(i++);let j=0;return(0,d.jsx)("div",{style:{fontFamily:"var(--font-mono)",fontSize:13,lineHeight:1.6},children:f.map((a,b)=>{if(a.hidden){let c=(0,d.jsxs)("div",{style:{padding:"2px 16px",color:"var(--text-dim)",background:"var(--bg-panel)",fontSize:11,borderTop:"1px solid var(--border)",borderBottom:"1px solid var(--border)"},children:["... ",a.count," unchanged lines ..."]},b);return j+=a.count,c}let c=a.lines.map((a,b)=>{let c=h[j+b],e="added"===a.type?"rgba(0,200,80,0.12)":"removed"===a.type?"rgba(240,60,60,0.14)":"transparent",f="added"===a.type?"+":"removed"===a.type?"-":" ",g="added"===a.type?"#4ade80":"removed"===a.type?"#f87171":"var(--text-dim)";return(0,d.jsxs)("div",{style:{display:"flex",background:e,borderLeft:"added"===a.type?"3px solid #4ade80":"removed"===a.type?"3px solid #f87171":"3px solid transparent"},children:[(0,d.jsx)("span",{style:{minWidth:44,padding:"0 8px 0 16px",textAlign:"right",color:"var(--text-dim)",userSelect:"none",fontSize:11,lineHeight:1.6,borderRight:"1px solid var(--border)",background:"var(--bg-panel)",flexShrink:0},children:"removed"===a.type?a.lineNo:c||""}),(0,d.jsx)("span",{style:{minWidth:16,padding:"0 6px",color:g,userSelect:"none",flexShrink:0,fontWeight:600},children:f}),(0,d.jsx)("span",{style:{flex:1,padding:"0 8px 0 0",whiteSpace:"pre",color:"var(--text)",overflowX:"auto"},children:a.text||"\xa0"})]},b)});return j+=a.lines.length,(0,d.jsx)("div",{children:c},b)})})}function m({options:a}){return(0,d.jsx)("div",{"data-file-viewer-surface":"segmented-toggle",style:{display:"flex",borderRadius:5,overflow:"hidden",border:"1px solid var(--border)"},children:a.map((a,b)=>(0,d.jsx)("button",{onClick:a.onClick,style:{padding:"2px 8px",fontSize:11,border:"none",borderLeft:0===b?"none":"1px solid var(--border)",cursor:"pointer",background:a.active?"var(--bg-selected)":"var(--bg-hover)",color:a.active?"var(--text)":"var(--text-muted)",fontWeight:a.active?600:400},children:a.label},a.key))})}},54097:(a,b,c)=>{"use strict";c.d(b,{p:()=>f,t:()=>e});var d=c(48249);function e({children:a,style:b,kind:c}){return(0,d.jsx)("div",{"data-disclosure-surface":"panel","data-disclosure-kind":c,style:{border:"1px solid var(--border)",borderRadius:6,overflow:"hidden",background:"var(--bg-panel)",...b},children:a})}function f({children:a,style:b}){return(0,d.jsx)("div",{"data-disclosure-surface":"body",style:{borderTop:"1px solid var(--border)",...b},children:a})}},57703:(a,b,c)=>{"use strict";c.d(b,{V:()=>h});var d=c(48249),e=c(6954),f=c(40648),g=c(41044);function h({expanded:a,onToggle:b,status:c,title:i,summary:j,durationLabel:k,leading:l,titleTooltip:m,summaryTooltip:n,buttonStyle:o,titleStyle:p,summaryStyle:q,durationStyle:r}){return(0,d.jsxs)(e.R,{expanded:a,onToggle:b,buttonStyle:o,children:[l,(0,d.jsx)("span",{title:m??i,style:{color:"var(--text-muted)",fontFamily:"var(--font-mono)",fontWeight:600,fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flexShrink:+!j,minWidth:0,flex:j?void 0:1,...p},children:"running"===c?(0,d.jsx)(f.n,{children:i}):i}),j?(0,d.jsx)("span",{title:n??j,style:{color:"var(--text-dim)",fontFamily:"var(--font-mono)",fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,minWidth:0,...q},children:"running"===c?(0,d.jsx)(f.n,{children:j}):j}):(0,d.jsx)("span",{style:{flex:1,minWidth:0}}),(0,d.jsx)(g.U1,{status:c}),k?(0,d.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)",fontVariantNumeric:"tabular-nums",flexShrink:0,...r},children:k}):null]})}},60125:(a,b,c)=>{Promise.resolve().then(c.t.bind(c,33071,23))},62418:(a,b,c)=>{"use strict";c.d(b,{D:()=>O});var d=c(48249),e=c(67484),f=c(51415),g=c(40648),h=c(73383),i=c(8033),j=c(41044),k=c(129),l=c(31218),m=c(7952);function n({block:a,toolResults:b,isStreaming:c,streamingDuration:e,toolCallDurations:f,onSendMessage:g,renderVisualCodeBlocks:h,cwd:i,activeFilePath:j,agentRunning:l,onApplyToFile:m,onRunCode:p,onOpenFileAtLine:q,onAcceptDiff:t}){if("text"===a.type)return(0,d.jsx)(o,{block:a,isStreaming:c,onSendMessage:g,renderVisualCodeBlocks:h,cwd:i,activeFilePath:j,agentRunning:l,onApplyToFile:m,onRunCode:p,onOpenFileAtLine:q,onAcceptDiff:t});if("image"===a.type)return(0,d.jsx)(k.O7,{images:[a]});if("thinking"===a.type)return(0,d.jsx)(r,{block:a,duration:e,isStreaming:c});let u=b?.get(a.toolCallId),v=f?.get(a.toolCallId);return(0,d.jsx)(s,{block:a,result:u,duration:v,isStreaming:c,cwd:i})}function o({block:a,isStreaming:b,onSendMessage:c,renderVisualCodeBlocks:e,cwd:f,activeFilePath:g,agentRunning:h,onApplyToFile:i,onRunCode:j,onOpenFileAtLine:k,onAcceptDiff:n}){let r=a.text,s=(0,m.aH)(r);if(!s.some(a=>"widget"===a.type)){if(b&&(0,m.qk)(r)){let a=s.filter(a=>"text"===a.type).map(a=>a.content).join("\n\n");return(0,d.jsxs)(d.Fragment,{children:[a&&(0,d.jsx)(p,{text:a,isStreaming:b,onSendMessage:c,renderVisualCodeBlocks:e,cwd:f,activeFilePath:g,agentRunning:h,onApplyToFile:i,onRunCode:j,onOpenFileAtLine:k,onAcceptDiff:n}),(0,d.jsx)(q,{})]})}return(0,d.jsx)(p,{text:r,isStreaming:b,onSendMessage:c,renderVisualCodeBlocks:e,cwd:f,activeFilePath:g,agentRunning:h,onApplyToFile:i,onRunCode:j,onOpenFileAtLine:k,onAcceptDiff:n})}return(0,d.jsx)(d.Fragment,{children:s.map((a,m)=>"text"===a.type?(0,d.jsx)(p,{text:a.content,isStreaming:b,onSendMessage:c,renderVisualCodeBlocks:e,cwd:f,activeFilePath:g,agentRunning:h,onApplyToFile:i,onRunCode:j,onOpenFileAtLine:k,onAcceptDiff:n},m):(0,d.jsx)(l.u,{code:a.code,isStreaming:!!a.partial,title:a.title,showOverlay:a.showOverlay,onSendMessage:c},m))})}function p({text:a,isStreaming:b,onSendMessage:c,renderVisualCodeBlocks:g,cwd:h,activeFilePath:i,agentRunning:j,onApplyToFile:l,onRunCode:m,onOpenFileAtLine:n,onAcceptDiff:o}){let q=(0,e.useMemo)(()=>(0,k.qn)(a,h),[h,a]);return(0,d.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8*(q.length>0)},children:[(0,d.jsx)(f.T,{content:a,cwd:h,onWidgetSendMessage:c,renderVisualCodeBlocks:g,isStreaming:b,renderer:"streamdown",activeFilePath:i,agentRunning:j,onApplyToFile:l,onRunCode:m,onOpenFileAtLine:n,onAcceptDiff:o}),q.length>0&&(0,d.jsx)(k.eR,{imagePaths:q})]})}function q(){return(0,d.jsx)(g.r,{height:88,style:{border:"1px solid var(--border)"}})}function r({block:a,duration:b,isStreaming:c}){return(0,d.jsx)(h.pm,{content:a.thinking,durationLabel:void 0!==b?`${b}s`:null,isStreaming:c,buttonStyle:{width:"100%",padding:"6px 10px",fontSize:12},containerStyle:{fontSize:13},contentStyle:{background:"var(--bg-panel)"}})}function s({block:a,result:b,duration:c,isStreaming:e,cwd:f}){let g=(0,j.s2)(b,e),h=(0,j.Gb)(g),k="bash"===a.toolName;return(0,d.jsx)(i.Dm,{tool:a,result:b,status:g,durationLabel:void 0!==c?`${c}s`:null,cwd:f,titleStyle:{color:h},collapsedPreviewBackground:`color-mix(in srgb, ${h} 5%, transparent)`,buttonStyle:{display:"flex",alignItems:"center",gap:7,width:"100%",padding:"6px 10px",background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:12,textAlign:"left",minWidth:0},containerStyle:{border:`1px solid color-mix(in srgb, ${h} 38%, transparent)`,background:`color-mix(in srgb, ${h} 8%, transparent)`},notebookStyle:k})}var t=c(39868);function u(a=768){let[b,c]=(0,e.useState)(!1);return b}function v({children:a,hovered:b,onHoverChange:c,style:e}){return(0,d.jsx)("div",{style:e,onMouseEnter:()=>c?.(!0),onMouseLeave:()=>c?.(!1),"data-message-hovered":b?"true":"false",children:a})}function w({children:a,justify:b="flex-start",style:c}){let e=u();return(0,d.jsx)("div",{"data-message-surface":"footer",style:{display:"flex",alignItems:"center",justifyContent:b,gap:e?4:6,marginTop:4,...c},children:a})}function x({children:a,alignEnd:b=!1,style:c}){return(0,d.jsx)("span",{"data-message-surface":"timestamp",style:{fontSize:10,color:"var(--text-dim)",marginLeft:b?"auto":void 0,...c},children:a})}function y({children:a,visible:b,style:c}){return(0,d.jsx)("div",{style:{display:"flex",gap:3,opacity:+!!b,pointerEvents:b?"auto":"none",transition:"opacity 0.12s",...c},children:a})}function z({children:a,onClick:b,disabled:c=!1,title:e,active:f=!1,style:g,onMouseEnterColor:h="var(--accent)",onMouseLeaveColor:i="var(--text-dim)",iconOnlyOnMobile:j=!1}){let k=u();return(0,d.jsx)("button",{onClick:b,disabled:c,title:e,style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",height:22,background:"none",border:"none",borderRadius:5,color:f?"var(--accent)":"var(--text-dim)",cursor:c?"not-allowed":"pointer",fontSize:11,fontWeight:400,whiteSpace:"nowrap",transition:"color 0.12s",...g},onMouseEnter:a=>{c||(a.currentTarget.style.color=h)},onMouseLeave:a=>{c||(a.currentTarget.style.color=i)},children:j&&k&&Array.isArray(a)?a[0]:a})}function A({children:a,hovered:b,onHoverChange:c}){let e=u();return(0,d.jsx)(v,{hovered:b,onHoverChange:c,style:{marginBottom:e?12:16,display:"flex",flexDirection:"column",alignItems:"flex-end"},children:a})}function B({children:a}){let b=u();return(0,d.jsx)("div",{style:{display:"flex",alignItems:"flex-end",gap:b?4:6,maxWidth:b?"92%":"85%"},children:(0,d.jsx)("div",{style:{flex:1,minWidth:0,background:"var(--user-bg)",border:"1px solid rgba(59,130,246,0.2)",borderRadius:12,padding:b?"7px 10px":"8px 12px",fontSize:14,lineHeight:1.6,color:"var(--text)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:a})})}function C({children:a,hasBody:b=!1}){let c=u();return(0,d.jsx)("div",{style:{display:"flex",gap:c?4:6,flexWrap:"wrap",marginBottom:b?c?6:8:0},children:a})}function D({children:a,hovered:b,onHoverChange:c}){let e=u();return(0,d.jsx)(v,{hovered:b,onHoverChange:c,style:{marginBottom:e?12:16},children:a})}function E({children:a}){let b=u();return(0,d.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:b?6:8},children:a})}function F({children:a,accent:b="default"}){let c="subagent"===b;return(0,d.jsx)("div",{"data-message-surface":"custom-card","data-message-accent":b,style:{padding:"8px 14px",borderRadius:8,border:`1px solid ${c?"rgba(99,102,241,0.25)":"var(--border)"}`,background:c?"rgba(99,102,241,0.05)":"var(--bg-panel)",fontSize:13,lineHeight:1.6,color:"var(--text-muted)"},children:a})}function G({icon:a,children:b}){return(0,d.jsxs)("div",{"data-message-surface":"custom-icon-row",style:{display:"flex",alignItems:"flex-start",gap:8},children:[(0,d.jsx)("span",{style:{flexShrink:0,fontSize:14},children:a}),(0,d.jsx)("div",{style:{flex:1,minWidth:0},children:b})]})}function H({text:a,title:b="Copy message",style:c}){let[f,g]=(0,e.useState)(!1),h=u();return(0,d.jsxs)("button",{onClick:()=>{(0,t.D)(a).then(()=>{g(!0),setTimeout(()=>g(!1),1500)})},title:b,style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",height:22,background:"none",border:"none",borderRadius:5,color:f?"var(--accent)":"var(--text-dim)",cursor:"pointer",fontSize:11,fontWeight:400,whiteSpace:"nowrap",transition:"color 0.12s",...c},onMouseEnter:a=>{f||(a.currentTarget.style.color="var(--accent)")},onMouseLeave:a=>{f||(a.currentTarget.style.color="var(--text-dim)")},children:[f?(0,d.jsx)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:(0,d.jsx)("polyline",{points:"20 6 9 17 4 12"})}):(0,d.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),(0,d.jsx)("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),(0,d.jsx)("span",{style:h?{display:"none"}:void 0,children:f?"Copied":"Copy"})]})}function I({provider:a,model:b,modelNames:c,isStreaming:e=!1,estimatedTokens:f=0,tps:g=null}){let h=a&&b?c?.[`${a}:${b}`]??c?.[b]??b:null;return(0,d.jsxs)("div",{style:{fontSize:11,color:"var(--text-dim)",marginBottom:4,display:"flex",alignItems:"center",gap:6},children:[h&&(0,d.jsx)("span",{children:h}),e&&f>0&&(0,d.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:4,color:"var(--text)"},title:"预估 token 数(流式接收中)",children:[(0,d.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:2,fontSize:11,fontWeight:400},children:[(0,d.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("line",{x1:"5",y1:"1.5",x2:"5",y2:"8.5"}),(0,d.jsx)("polyline",{points:"2 6 5 8.5 8 6"})]}),f]}),null!==g&&(0,d.jsxs)("span",{style:{marginLeft:6,padding:"1px 6px",borderRadius:4,background:g>=50?"#53b3cb":g>=30?"#9bc53d":g>=15?"#f9c22e":"#e01a4f",color:"#fff",fontSize:11,fontWeight:400},children:[g.toFixed(1)," t/s"]})]})]})}var J=c(27563);let K=[],L=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function M(a){return a.toString().padStart(2,"0")}function N(a){if(!a)return null;let b=new Date(a),c=new Date,d=b.getFullYear()===c.getFullYear()&&b.getMonth()===c.getMonth()&&b.getDate()===c.getDate(),e=`${M(b.getHours())}:${M(b.getMinutes())}`;if(d)return e;let f=[`${L[b.getMonth()]} ${b.getDate()}`];b.getFullYear()!==c.getFullYear()&&f.push(String(b.getFullYear()));let g=f.join(", ");return`${g} ${e}`}function O({message:a,isStreaming:b,toolResults:c,modelNames:e,entryId:f,onFork:g,forking:h,onNavigate:i,prevAssistantEntryId:j,onEditContent:k,onSendMessage:l,showTimestamp:m,prevTimestamp:n,renderVisualCodeBlocks:o,cwd:p,onOpenImage:q,activeFilePath:r,agentRunning:s,onApplyToFile:t,onRunCode:u,onOpenFileAtLine:v,onAcceptDiff:w,compactionShadowCount:x,onLoadShadowed:y,forkFresh:z}){return"user"===a.role?(0,d.jsx)(P,{message:a,entryId:f,onFork:g,forking:h,onNavigate:i,prevAssistantEntryId:j,onEditContent:k,onOpenImage:q,compactionShadowCount:x,onLoadShadowed:y}):"assistant"===a.role?(0,d.jsx)(Q,{message:a,isStreaming:b,toolResults:c,modelNames:e,onSendMessage:l,showTimestamp:m,prevTimestamp:n,renderVisualCodeBlocks:o,cwd:p,activeFilePath:r,agentRunning:s,onApplyToFile:t,onRunCode:u,onOpenFileAtLine:v,onAcceptDiff:w,forkFresh:z}):"toolResult"===a.role?null:"custom"===a.role?(0,d.jsx)(R,{message:a,showTimestamp:m}):null}function P({message:a,entryId:b,onFork:c,forking:g,onNavigate:h,prevAssistantEntryId:i,onEditContent:j,onOpenImage:l,compactionShadowCount:m,onLoadShadowed:n}){let[o,p]=(0,e.useState)(!1),[q,r]=(0,e.useState)(null),[s,t]=(0,e.useState)(!1),u="string"==typeof a.content?a.content:a.content.filter(a=>"text"===a.type).map(a=>a.text).join("\n"),v="string"==typeof a.content?[]:a.content.filter(a=>"image"===a.type),D=v.flatMap(a=>{let b=(0,k.h5)(a);return b?[{src:b}]:[]}),E=N(a.timestamp),F=!!b&&!!c,G=!!i&&!!h;return(0,d.jsxs)(A,{hovered:o,onHoverChange:p,children:[(0,d.jsxs)(B,{children:[v.length>0&&(0,d.jsx)(C,{hasBody:!!u,children:v.map((a,b)=>{let c=(0,k.h5)(a);if(!c)return null;let e=a.path&&c.startsWith("/api/files/");return(0,d.jsx)("a",{href:c,target:e||!l?"_blank":void 0,rel:e||!l?"noreferrer":void 0,title:"Open image",style:{display:"block",cursor:"zoom-in"},onClick:a=>{l&&(a.preventDefault(),l(c,void 0,D))},children:(0,d.jsx)("img",{src:c,alt:"",style:{maxWidth:240,maxHeight:240,borderRadius:6,objectFit:"contain",display:"block",border:"1px solid rgba(59,130,246,0.15)"}})},b)})}),u]}),null!=m&&m>0&&(0,d.jsx)("div",{style:{marginTop:4,textAlign:"left"},children:null===q?(0,d.jsx)("button",{onClick:()=>{s||null!==q||(t(!0),(b&&n?n(b):Promise.resolve([])).then(a=>r(a)).catch(()=>r([])).finally(()=>t(!1)))},disabled:s,style:{padding:"5px 12px",fontSize:12,color:"var(--accent)",background:"var(--bg-panel)",border:"1px solid var(--border)",borderRadius:6,cursor:s?"wait":"pointer"},children:s?"Loading…":`Show ${m} compacted message${1===m?"":"s"}`}):(0,d.jsxs)("div",{style:{border:"1px solid var(--border)",borderRadius:7,background:"var(--bg-panel)",padding:"8px 10px",maxHeight:360,overflowY:"auto"},children:[(0,d.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:6},children:[(0,d.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Compacted history"}),(0,d.jsx)("button",{onClick:()=>r(null),style:{padding:"2px 8px",fontSize:11,color:"var(--text-dim)",background:"transparent",border:"1px solid var(--border)",borderRadius:5,cursor:"pointer"},children:"Hide"})]}),0===q.length&&(0,d.jsx)("div",{style:{fontSize:12,color:"var(--text-muted)"},children:"No earlier messages to show."}),q.map((a,b)=>{let c,e="string"==typeof(c=a.content)?c:Array.isArray(c)?c.filter(a=>!!a&&"object"==typeof a&&"text"===a.type&&"string"==typeof a.text).map(a=>a.text).join("\n"):"";if(!e.trim())return null;let g="user"===a.role?"User":"assistant"===a.role?"Assistant":"Tool";return(0,d.jsxs)("div",{style:{marginBottom:8,paddingBottom:8,borderBottom:b===q.length-1?"none":"1px solid var(--border)"},children:[(0,d.jsx)("div",{style:{fontSize:10,color:"var(--text-dim)",marginBottom:2},children:g}),(0,d.jsx)(f.T,{content:e,style:{fontSize:12.5}})]},b)})]})}),(0,d.jsxs)(w,{justify:"flex-end",style:{marginTop:3},children:[(0,d.jsx)(y,{visible:o,children:(0,d.jsx)(H,{text:u})}),(F||G)&&(0,d.jsxs)(y,{visible:o||!!g,children:[G&&(0,d.jsxs)(z,{iconOnlyOnMobile:!0,onClick:()=>{h(i),j?.(u)},title:"Edit from here — branches within this session",children:[(0,d.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("polyline",{points:"15 10 20 15 15 20"}),(0,d.jsx)("path",{d:"M4 4v7a4 4 0 0 0 4 4h12"})]}),"Edit from here"]}),F&&(0,d.jsxs)(z,{iconOnlyOnMobile:!0,onClick:()=>{c(b)},disabled:g,active:!!g,title:g?"Creating new session…":"New session — creates an independent copy from here",children:[(0,d.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("line",{x1:"6",y1:"3",x2:"6",y2:"15"}),(0,d.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,d.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,d.jsx)("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),g?"Creating…":"New session"]})]}),E&&(0,d.jsx)(x,{children:E})]})]})}function Q({message:a,isStreaming:b,toolResults:c,modelNames:f,onSendMessage:g,showTimestamp:h,prevTimestamp:i,renderVisualCodeBlocks:j,cwd:k,activeFilePath:l,agentRunning:m,onApplyToFile:o,onRunCode:p,onOpenFileAtLine:q,onAcceptDiff:r,forkFresh:s}){var t;let u,v=h?N(a.timestamp):null,A=a.content??K,[B,C]=(0,e.useState)(!1);(0,e.useRef)(null),(0,e.useRef)(new Map);let F=(0,e.useRef)(A),[G,L]=(0,e.useState)(null),[M,O]=(0,e.useState)(new Map);F.current=A;let P=(0,e.useMemo)(()=>{if(!a.timestamp||!i)return;let b=Math.round((a.timestamp-i)/1e3);return b>0?b:void 0},[a.timestamp,i]),R=(0,e.useMemo)(()=>(function(a,b){let c=new Map;if(!a||!b)return c;for(let[d,e]of a){if(!e.timestamp)continue;let a=Math.round((e.timestamp-b)/1e3);a>0&&c.set(d,a)}return c})(c,a.timestamp),[c,a.timestamp]),S=(0,e.useMemo)(()=>(function(a,b,c){let d=[],e=[],f=[];for(let[g,h]of a.entries()){if("thinking"===h.type){e.push({content:h.thinking,duration:b.get(g)??c});continue}if("toolCall"===h.type){d.push(h);continue}f.push(h)}return{tools:d,thinkingBlocks:e,visibleBlocks:f}})(A,M,P),[A,M,P]),T=(0,e.useMemo)(()=>A.filter(a=>"text"===a.type).map(a=>a.text).join("\n"),[A]),U=(0,e.useMemo)(()=>Math.round(function(a){let b=0;for(let c of a){if("text"===c.type){b+=c.text.length;continue}if("thinking"===c.type){b+=c.thinking.length;continue}"toolCall"===c.type&&(b+=JSON.stringify(c.input??{}).length)}return b}(A)/4),[A]);return(0,d.jsxs)(D,{hovered:B,onHoverChange:C,children:[(0,d.jsx)(I,{provider:a.provider,model:a.model,modelNames:f,isStreaming:b,estimatedTokens:U,tps:G}),(0,d.jsxs)(E,{children:[!b&&"error"===a.stopReason&&a.errorMessage?.trim()&&(0,d.jsxs)("div",{role:"alert","data-message-surface":"assistant-error",style:{border:"1px solid rgba(248,113,113,0.35)",borderRadius:6,background:"rgba(248,113,113,0.07)",padding:"8px 10px",color:"#f87171",fontSize:12,lineHeight:1.5,overflowWrap:"anywhere"},children:[(0,d.jsx)("strong",{style:{display:"block",marginBottom:2,fontWeight:600},children:"Model response failed"}),a.errorMessage.trim()]}),(S.tools.length>0||S.thinkingBlocks.length>0)&&(0,d.jsx)(J.kD,{tools:S.tools,results:c,durations:R,thinkingBlocks:S.thinkingBlocks,isStreaming:b,cwd:k}),S.visibleBlocks.map((a,e)=>(0,d.jsx)(n,{block:a,toolResults:c,isStreaming:b,toolCallDurations:R,onSendMessage:g,renderVisualCodeBlocks:j,cwd:k,activeFilePath:l,agentRunning:m,onApplyToFile:o,onRunCode:p,onOpenFileAtLine:q,onAcceptDiff:r},e))]}),(0,d.jsxs)(w,{style:{gap:8},children:[a.usage&&!b&&(0,d.jsx)("div",{style:{fontSize:11,color:"var(--text-dim)"},children:(t=a.usage,u=[],t.input&&u.push(`${t.input.toLocaleString()} in`),t.output&&u.push(`${t.output.toLocaleString()} out`),t.cacheRead&&u.push(`${t.cacheRead.toLocaleString()} cache`),u.join(" \xb7 "))}),T&&!b&&(0,d.jsx)(y,{visible:B,children:(0,d.jsx)(H,{text:T})}),s?.show&&!b&&(0,d.jsxs)(d.Fragment,{children:[s.error&&(0,d.jsx)("span",{style:{fontSize:11,color:"#f87171"},children:s.error}),(0,d.jsxs)(z,{onClick:s.onFork,disabled:s.busy,title:"Fork 新会话 — 携带精简摘要,避免每次提问都等待模型 prefill 变慢",children:[(0,d.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("line",{x1:"6",y1:"3",x2:"6",y2:"15"}),(0,d.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,d.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,d.jsx)("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),s.busy?"Forking…":"Fork 新会话"]})]}),v&&(0,d.jsx)(x,{alignEnd:!0,children:v})]})]})}function R({message:a,showTimestamp:b}){if(!a.display)return null;let c=b?N(a.timestamp):null,e="string"==typeof a.content?a.content:a.content.filter(a=>"text"===a.type).map(a=>a.text).join("\n"),g="subagent-notify"===a.customType,h=e.match(/^Background task (completed|failed|paused):\s*\*\*(.+?)\*\*/),i=h?"completed"===h[1]?"✅":"failed"===h[1]?"❌":"⏸":g?"\uD83E\uDD16":"ℹ";return(0,d.jsxs)("div",{style:{marginBottom:12},children:[(0,d.jsx)(F,{accent:g?"subagent":"default",children:(0,d.jsx)(G,{icon:i,children:(0,d.jsx)("div",{"data-message-surface":"custom-body",children:(0,d.jsx)(f.T,{content:e,style:{fontSize:13}})})})}),(c||h)&&(0,d.jsxs)(w,{justify:"flex-end",style:{marginTop:3},children:[h&&(0,d.jsx)(x,{children:h[2]}),c&&(0,d.jsx)(x,{children:c})]})]})}},63956:(a,b,c)=>{Promise.resolve().then(c.t.bind(c,81921,23)),Promise.resolve().then(c.t.bind(c,60440,23)),Promise.resolve().then(c.t.bind(c,84342,23)),Promise.resolve().then(c.t.bind(c,82265,23)),Promise.resolve().then(c.t.bind(c,35421,23)),Promise.resolve().then(c.t.bind(c,61335,23)),Promise.resolve().then(c.t.bind(c,70664,23)),Promise.resolve().then(c.bind(c,74661))},65950:(a,b,c)=>{"use strict";c.d(b,{aU:()=>f,cx:()=>e,nS:()=>r,Rd:()=>q,wY:()=>p,tG:()=>m});class d{#a;#b;constructor(a){this.#b=new Map,this.#a=a}get(a){if(!this.#b.has(a))return;let b=this.#b.get(a);return this.#b.delete(a),this.#b.set(a,b),b}set(a,b){for(this.#b.has(a)&&this.#b.delete(a);this.#b.size>=this.#a;){let a=this.#b.keys().next().value;if(void 0===a)break;this.#b.delete(a)}this.#b.set(a,b)}delete(a){this.#b.delete(a)}get size(){return this.#b.size}}let e="github-light",f="github-dark",g=new d(10),h=new d(200),i=new Set,j=new Map,k=null;function l(a,b,c){let d=a.slice(0,100),e=a.length>100?a.slice(-100):"";return`${b}:${c}:${a.length}:${d}:${e}`}function m(a){return void 0===a||0===a?{}:{fontStyle:1&a?"italic":void 0,fontWeight:2&a?700:void 0,textDecorationLine:4&a?"underline":void 0}}function n(){return k||(k=Promise.resolve().then(c.bind(c,78908)).then(a=>{if(0===i.size){for(let b of Object.keys(a.bundledLanguages??{}))i.add(b.toLowerCase());for(let b of a.bundledLanguagesInfo??[]){let a=b.id.toLowerCase();for(let c of b.aliases??[])j.set(c.toLowerCase(),a)}}return a})),k}async function o(a,b=e,c=f){let d=`${a}:${b}:${c}`,h=g.get(d);if(h)return h;let i=n().then(({createHighlighter:d})=>d({langs:[a],themes:[b,c]})).catch(a=>{throw g.delete(d),a});return g.set(d,i),i}function p(a,b,c,d){let g=q(a,b,c);if(g)return g;let k=c?f:e,m=b.trim().toLowerCase();if(!m)return null;let p=l(a,m,k);return n().then(()=>{let c,g=(c=b.trim().toLowerCase())?i.has(c)?c:j.get(c)??null:null;return g?o(g,e,f).then(b=>{let c=b.codeToTokens(a,{lang:g,theme:k}),e={bg:c.bg??"transparent",fg:c.fg??"inherit",tokens:c.tokens};return h.set(p,e),d(e),e}):null}).catch(a=>{console.warn("[Shiki] highlight failed:",a)}),null}function q(a,b,c){let d=b.trim().toLowerCase();if(!d)return null;let g=l(a,d,c?f:e);return h.get(g)??null}function r(a){return{bg:"transparent",fg:"inherit",tokens:a.replace(/\r\n/g,"\n").replace(/\r/g,"\n").split("\n").map(a=>""===a?[]:[{color:"inherit",content:a}])}}},73383:(a,b,c)=>{"use strict";c.d(b,{pm:()=>k});var d=c(48249),e=c(67484),f=c(54097),g=c(6954),h=c(40648);function i({expanded:a,onToggle:b,durationLabel:c,isStreaming:e=!1,leading:f,label:j="Thinking",buttonStyle:k,labelStyle:l,durationStyle:m}){return(0,d.jsxs)(g.R,{expanded:a,onToggle:b,buttonStyle:{width:"100%",display:"flex",alignItems:"center",gap:7,minWidth:0,textAlign:"left",cursor:"pointer",border:"none",background:"transparent",color:"var(--text-muted)",...k},children:[f,(0,d.jsx)("span",{style:{fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,flex:1,...l},children:e?(0,d.jsx)(h.n,{children:j}):j}),c&&(0,d.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)",fontVariantNumeric:"tabular-nums",flexShrink:0,...m},children:c})]})}function j({content:a,contentStyle:b}){return(0,d.jsx)(f.p,{style:{color:"var(--text-muted)",fontSize:12,lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word",...b},children:(0,d.jsx)("div",{style:{padding:"8px 10px"},children:a})})}function k({content:a,durationLabel:b,isStreaming:c=!1,leading:g,label:h="Thinking",containerStyle:l,buttonStyle:m,labelStyle:n,durationStyle:o,contentStyle:p}){let[q,r]=(0,e.useState)(!1);return(0,d.jsxs)(f.t,{kind:"thinking",style:l,children:[(0,d.jsx)(i,{expanded:q,onToggle:()=>r(a=>!a),durationLabel:b,isStreaming:c,leading:g,label:h,buttonStyle:m,labelStyle:n,durationStyle:o}),q&&(0,d.jsx)(j,{content:a,contentStyle:p})]})}},78335:()=>{},80251:(a,b,c)=>{"use strict";function d(a,b){for(let c of b){let b=a[c];if(null!=b&&""!==b)return String(b)}return null}function e(a,b=60){let c=a.replace(/\s+/g," ").trim();return c.length<=b?c:`${c.slice(0,Math.max(0,b-3))}...`}function f(a){let b=a.toLowerCase().split("__").filter(Boolean);return b[b.length-1]??a.toLowerCase()}function g(a,b=120){let c=Object.keys(a);return 0===c.length?"":"command"in a?String(a.command).slice(0,b):"cmd"in a?String(a.cmd).slice(0,b):"path"in a?String(a.path).slice(0,b):"file_path"in a?String(a.file_path).slice(0,b):"pattern"in a?String(a.pattern).slice(0,b):"query"in a?String(a.query).slice(0,b):String(a[c[0]]).slice(0,b)}function h(a){let b=a.toolName||"tool",c=f(b),g=a.input??{};if(["bash","execute","run","shell","exec_command","execute_command"].includes(c))return{canonicalName:c,kind:"terminal",label:"Shell",summary:e(d(g,["command","cmd"])??b,60)};if(["read","readfile","read_file"].includes(c))return{canonicalName:c,kind:"read",label:"Read",summary:e(d(g,["file_path","path"])??b,60)};if(["write","edit","write_file","create_file","notebook_edit"].includes(c)){let a,f=d(g,["file_path","path","notebook_path","filename"]);return{canonicalName:c,kind:"edit",label:"Edit",summary:e(f?(a=f.split(/[\\/]/).filter(Boolean))[a.length-1]??f:b,60)}}if(["search","grep","glob","find","find_files","websearch"].includes(c))return{canonicalName:c,kind:"search",label:"Search",summary:e(d(g,["pattern","query","glob"])??b,60)};if(["subagent","agent"].includes(c))return{canonicalName:c,kind:"agent",label:"Agent",summary:e([d(g,["agent","name","agentName"]),d(g,["prompt","task","message"])].filter(Boolean).join(": ")||b,60)};let h=d(g,["command","cmd","path","file_path","pattern","query","glob","prompt","description"])??function(a){try{return JSON.stringify(a)}catch{return String(a)}}(g)??b;return{canonicalName:c,kind:"tool",label:e(b,60),summary:e(h,60)}}c.d(b,{WI:()=>f,Wm:()=>g,wS:()=>h})},82704:()=>{},86364:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>e});var d=c(88868);let e=async a=>[{type:"image/svg+xml",sizes:"any",url:(0,d.fillMetadataSegment)(".",await a.params,"icon.svg",!0)+"?6eceb6fbd1a5bb90"}]},96487:()=>{}};
@@ -38,10 +38,10 @@ for (.name in sort(ls(envir=.GlobalEnv))) {
38
38
  }
39
39
  cat("WORKBENCH_INSPECT_END\\n")`),title:"Inspect live workbench kernel state",timeoutMs:b.timeoutMs??15e3,signal:c});return{content:[{type:"text",text:function(a){let b=s(a.stdout),c=[`kernel_plot_inspect ${a.status}`,`run_id: ${a.runId}`,`runtime: ${a.runtime}`,`objects: ${b.length}`];for(let a of b.slice(0,80))c.push(`- ${a.name}: ${a.type}${a.shape?` (${a.shape})`:""}${a.attrs?` — ${a.attrs}`:""}`);let d=p(a.stderr,1200).trim();return d&&c.push("stderr:",d),a.error&&c.push(`error: ${a.error}`),c.join("\n")}(h)}],details:{schema:"kernel-plot.inspect.v1",kind:"inspect",run:{runId:h.runId,status:h.status,language:h.language,runtime:h.runtime,title:h.title},objects:s(h.stdout),stderrPreview:p(h.stderr),error:h.error}}}})),a.registerTool((0,f.defineTool)({name:"kernel_plot_stop",label:"Workbench Stop",description:"Stop the current Pi session's warm Workbench kernel for one language or all languages.",promptSnippet:"Stop warm R/Python Workbench kernels and release their memory.",promptGuidelines:u,executionMode:"sequential",parameters:e.Type.Object({language:e.Type.Optional(e.Type.Union([e.Type.Literal("python"),e.Type.Literal("r")]))}),async execute(a,b,c,d,e){let f=await m(),g=n(e);return await f.stopSession({ownerId:g,language:b.language}),{content:[{type:"text",text:`kernel_plot_stop stopped ${b.language??"all languages"}`}],details:{schema:"kernel-plot.result.v1",kind:"stop",stopped:{ownerId:g,language:b.language},artifacts:[],nextAction:"Use kernel_plot_run to start a fresh warm kernel when needed."}}}})),a.registerTool((0,f.defineTool)({name:"kernel_plot_artifacts",label:"Workbench Artifacts",description:"List recent archived Workbench artifacts for the current Pi session.",promptSnippet:"List recent R/Python Workbench artifact paths for this session.",promptGuidelines:u,parameters:e.Type.Object({limit:e.Type.Optional(e.Type.Number({description:"Maximum number of recent artifacts to list."}))}),async execute(a,b,c,d,e){let f=await m(),g=n(e),h=await f.listArtifacts({cwd:e.cwd,ownerId:g,limit:b.limit});return{content:[{type:"text",text:["kernel_plot_artifacts",...q(h)].join("\n")}],details:{schema:"kernel-plot.result.v1",kind:"artifacts",ownerId:g,artifacts:h,nextAction:"Open or inspect the listed artifact paths, or continue plotting with kernel_plot_run."}}}})),a.on("session_shutdown",async(a,b)=>{let c=await m();await c.stopSession({ownerId:n(b)}).catch(a=>{b.ui.notify(`kernel plot cleanup failed: ${a instanceof Error?a.message:String(a)}`,"warning")})})}d()}catch(a){d(a)}})},7048:(a,b,c)=>{"use strict";c.d(b,{Y:()=>j});var d=c(29021),e=c(21820),f=c(33873);let g="pi-subagents";function h(a){try{return JSON.parse((0,d.readFileSync)(a,"utf-8"))}catch{return null}}function i(a){return"string"==typeof a?a:a&&"object"==typeof a?"string"==typeof a.source?a.source:"string"==typeof a.name?a.name:"string"==typeof a.package?a.package:null:null}function j(a=process.env.PI_CODING_AGENT_DIR??(0,f.join)((0,e.homedir)(),".pi","agent")){let b=(0,f.join)(a,"npm","node_modules",g),c=(0,f.join)(b,"package.json"),k=h(c),l=(0,d.existsSync)(c),m=h((0,f.join)(a,"settings.json")),n=(Array.isArray(m?.packages)?m.packages:[]).map(i).some(a=>a===g||a===`npm:${g}`||a?.endsWith(`/${g}`));return{installed:l,configured:n,ready:l&&n,packageName:g,packagePath:b,version:"string"==typeof k?.version?k.version:void 0,installCommand:"pi install npm:pi-subagents"}}},9774:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{cV:()=>k,p6:()=>l});var e=c(29021),f=c(33873),g=c(75430),h=a([g]);g=(h.then?(await h)():h)[0];let m={generativeUI:!0,plotIdleTimeoutMs:1728e5,saveFormat:"pdf",saveDpi:300,saveWidth:800,saveHeight:600,forkEnabled:!0,forkSuggestTokens:18e4,forkAutoTokens:4e5,forkMinMessages:20};function i(){return(0,f.join)((0,g.getAgentDir)(),"annovibe-settings.json")}function j(a){if(!a||"object"!=typeof a)return{...m};let b="number"==typeof a.plotIdleTimeoutMs&&Number.isFinite(a.plotIdleTimeoutMs)&&a.plotIdleTimeoutMs>=0?Math.min(Math.round(a.plotIdleTimeoutMs),2592e6):m.plotIdleTimeoutMs;return{generativeUI:"boolean"==typeof a.generativeUI?a.generativeUI:m.generativeUI,plotIdleTimeoutMs:b,saveFormat:"png"===a.saveFormat||"svg"===a.saveFormat?a.saveFormat:"pdf",saveDpi:"number"==typeof a.saveDpi&&Number.isFinite(a.saveDpi)&&a.saveDpi>=72&&a.saveDpi<=1200?a.saveDpi:m.saveDpi,saveWidth:"number"==typeof a.saveWidth&&Number.isFinite(a.saveWidth)&&a.saveWidth>=100&&a.saveWidth<=8e3?a.saveWidth:m.saveWidth,saveHeight:"number"==typeof a.saveHeight&&Number.isFinite(a.saveHeight)&&a.saveHeight>=100&&a.saveHeight<=8e3?a.saveHeight:m.saveHeight,forkEnabled:"boolean"==typeof a.forkEnabled?a.forkEnabled:m.forkEnabled,forkSuggestTokens:"number"==typeof a.forkSuggestTokens&&Number.isFinite(a.forkSuggestTokens)&&a.forkSuggestTokens>=1e4?Math.min(Math.round(a.forkSuggestTokens),9e5):m.forkSuggestTokens,forkAutoTokens:"number"==typeof a.forkAutoTokens&&Number.isFinite(a.forkAutoTokens)&&a.forkAutoTokens>=2e4?Math.min(Math.round(a.forkAutoTokens),2e6):m.forkAutoTokens,forkMinMessages:"number"==typeof a.forkMinMessages&&Number.isFinite(a.forkMinMessages)&&a.forkMinMessages>=5?Math.min(Math.round(a.forkMinMessages),500):m.forkMinMessages}}function k(){let a=i(),b=(0,e.existsSync)(a)?a:(0,f.join)((0,g.getAgentDir)(),"pidex-settings.json");if(!(0,e.existsSync)(b))return{...m};try{return j(JSON.parse((0,e.readFileSync)(b,"utf8")))}catch{return{...m}}}function l(a){let b=j({...k(),...a}),c=i(),d=(0,f.dirname)(c);return(0,e.existsSync)(d)||(0,e.mkdirSync)(d,{recursive:!0}),(0,e.writeFileSync)(c,JSON.stringify(b,null,2),"utf8"),b}d()}catch(a){d(a)}})},9805:(a,b,c)=>{"use strict";c.d(b,{FE:()=>i,J:()=>h,zN:()=>j});let d='<widget-capability>\nYou can create interactive visualizations using the `show-widget` code fence.\n\nUse `show-widget` by default when visual output is the primary answer. This includes charts, diagrams, flowcharts, dashboards, UI prototypes, mockups, SVG illustrations, icons, logos, infographics, timelines, hierarchies, comparison views, and visual explanations.\n\nFor diagrams, flowcharts, architecture maps, sequence-style explanations, and Markdown-to-diagram requests, prefer `show-widget` with SVG/HTML over Mermaid. Widgets stream more reliably in this UI. Use Mermaid only when the user explicitly asks for Mermaid source, raw Mermaid, raw Markdown, or a saved Mermaid/Markdown file.\n\nFormat:\n```show-widget\n{"title":"Human-readable title","widget_code":"<raw HTML/SVG string>"}\n```\n\nDetailed specs:\nWhen a `<widget-guidelines>` block is present, follow it. It contains the module-specific design rules for the current request.\n\nRequired rules:\n1. `widget_code` is a JSON string: escape quotes and newlines. Always close the JSON object and fence.\n - ✅ Correct: {"title":"T","widget_code":"<div>\\n <p>hi</p>\\n</div>"}\n - ❌ Wrong — raw newlines inside the string are invalid JSON (write \\n instead):\n {"title":"T","widget_code":"<div>\n <p>hi</p>\n </div>"}\n - ❌ Wrong — bare quotes inside HTML/SVG text must be escaped as \\":\n {"title":"T","widget_code":"<svg><text>say "hi"</text></svg>"}\n - ❌ Wrong — only the keys `title` and `widget_code` are allowed; never add extra keys like `widget_code2`, and always put a comma between members:\n {"title":"T","widget_code":"<svg/>" "widget_code2":""}\n - The entire object must be valid JSON, ending with a closing `}` before the closing fence. If the widget is large, write compact one-line JSON rather than pretty-printing with raw newlines.\n2. Do not include DOCTYPE, html, head, body, iframe, object, embed, form, link, base, or meta tags.\n3. Keep outer backgrounds transparent. The host supplies theme variables.\n4. Use a single concise widget per fence. For multiple widgets, interleave prose and use a separate `show-widget` fence for each widget.\n5. Streaming order: SVG puts `<defs>` before visible shapes; HTML uses `<style>`, then visible markup, then `<script>` last.\n6. Prefer responsive SVG for static visuals and small HTML widgets for controls.\n7. SVG widgets use `<svg width="100%" viewBox="0 0 680 H">` and keep all content inside the viewBox.\n8. Interactive controls must visibly update the output. For Chart.js, call `chart.update()` after changes.\n9. Clickable drill-down actions call `window.__widgetSendMessage("short request")`.\n10. Cross-widget filters publish with `window.__widgetPublish("topic", { key: "value" })`; other widgets listen for `widget-filter`.\n11. Allowed CDN hosts: `cdnjs.cloudflare.com`, `cdn.jsdelivr.net`, `unpkg.com`, `esm.sh`.\n12. CDN scripts must use an `onload` initializer plus an `if (window.Lib) init();` fallback.\n13. Use `min-height` instead of fixed outer `height` to prevent clipping.\n14. Title should be human-readable in the user\'s language.\n15. Put explanatory prose outside the code fence.\n16. Do not output raw ```svg, ```html, or plain Mermaid for visual answers unless the user explicitly asks for source code, raw Markdown, raw Mermaid, or a saved file.\n17. Do not convert Markdown outlines into Mermaid by default. Render them as a `show-widget` diagram unless Mermaid/source text is explicitly requested.\n</widget-capability>',e=/\n?\s*<widget-capability>[\s\S]*?<\/widget-capability>\s*/g,f=/\n?\s*<visualization_harness>[\s\S]*?<\/visualization_harness>\s*/g,g=/\n?\s*<widget-guidelines\b[^>]*>[\s\S]*?<\/widget-guidelines>\s*/g;function h(a){let b=a.toLowerCase();return b.includes("show-widget")&&(b.includes("# visualization harness")||b.includes("## when to visualize")||b.includes("widget format"))}function i(a){return a.replace(e,"\n").replace(f,"\n").replace(g,"\n").replace(/\n{3,}/g,"\n\n").trim()}function j(a){return a.includes("<widget-capability>")?a:a.trim()?`${a.trimEnd()}
40
40
 
41
- ${d}`:d}},11745:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{$:()=>j});var e=c(28802),f=c(75430),g=a([e,f]);function h(a){return a>=1e6?`${(a/1e6).toFixed(1)}M`:a>=1e3?`${(a/1e3).toFixed(1)}K`:String(a)}function i(a){if(a<60)return`${a}s`;let b=Math.floor(a/60);if(b<60)return`${b}m ${String(a%60).padStart(2,"0")}s`;let c=Math.floor(b/60);return`${c}h ${b%60}m`}function j(a){let b=null,c=null,d=!1;function g(){return Date.now()}function j(){return{input:0,output:0,cacheRead:0,cacheWrite:0}}function k(){var a;if(!d||!b||!c)return;let e=j(),f=(a=c,Math.max(0,e.input-a.input)+Math.max(0,e.cacheWrite-a.cacheWrite)+Math.max(0,e.output-a.output));f>0&&(b.tokensUsed+=f,b.updatedAt=g(),void 0!==b.tokenBudget&&b.tokensUsed>=b.tokenBudget&&"active"===b.status&&(b.status="budget-limited")),c={...e}}function l(){a.appendEntry("goal-mode",b?{...b}:null)}a.registerTool((0,f.defineTool)({name:"goal",label:"Goal",description:'Use the goal tool to manage your current task objective.\n- goal(op="create", objective="...", token_budget=N?) — set a goal with optional token budget\n- goal(op="get") — check current goal status\n- goal(op="complete") — mark goal as complete\n- goal(op="drop") — abandon the current goal\nWhen you have a clear objective, set a goal to track progress and budget.',parameters:e.Type.Object({op:e.Type.Union([e.Type.Literal("create"),e.Type.Literal("get"),e.Type.Literal("complete"),e.Type.Literal("drop"),e.Type.Literal("resume")],{description:"goal operation"}),objective:e.Type.Optional(e.Type.String({description:"goal objective (required for create)"})),token_budget:e.Type.Optional(e.Type.Number({description:"token budget limit (optional)"}))}),execute:async(a,e,f,m)=>{let n=e.op,o=e.objective?.trim(),p=e.token_budget;switch(n){case"create":{if(!o)return{content:[{type:"text",text:"Error: objective is required for goal create."}],details:null};if(b&&"dropped"!==b.status&&"complete"!==b.status)return{content:[{type:"text",text:"Error: a goal is already active. Complete or drop it first."}],details:null};let a=g();b={id:`goal-${a}`,objective:o,status:"active",tokenBudget:p&&p>0?p:void 0,tokensUsed:0,timeUsedSeconds:0,createdAt:a,updatedAt:a},d=!0,c=j(),l();let e=b.tokenBudget?` | budget: ${h(b.tokenBudget)} tokens`:"";return{content:[{type:"text",text:`Goal set: "${o}"${e}`}],details:{...b}}}case"get":{if(!b)return{content:[{type:"text",text:"No active goal."}],details:null};k();let a=Math.floor((g()-b.createdAt)/1e3);b.timeUsedSeconds=Math.max(b.timeUsedSeconds,a);let c=b.tokenBudget?` | ${h(b.tokensUsed)} / ${h(b.tokenBudget)} tokens`:` | ${h(b.tokensUsed)} tokens`;return{content:[{type:"text",text:`Goal: "${b.objective}"
41
+ ${d}`:d}},11745:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{$:()=>j});var e=c(28802),f=c(75430),g=a([e,f]);function h(a){return a>=1e6?`${(a/1e6).toFixed(1)}M`:a>=1e3?`${(a/1e3).toFixed(1)}K`:String(a)}function i(a){if(a<60)return`${a}s`;let b=Math.floor(a/60);if(b<60)return`${b}m ${String(a%60).padStart(2,"0")}s`;let c=Math.floor(b/60);return`${c}h ${b%60}m`}function j(a){let b=null,c=null,d=!1;function g(){return Date.now()}function j(){return{input:0,output:0,cacheRead:0,cacheWrite:0}}function k(){var a;if(!d||!b||!c)return;let e=j(),f=(a=c,Math.max(0,e.input-a.input)+Math.max(0,e.cacheWrite-a.cacheWrite)+Math.max(0,e.output-a.output));f>0&&(b.tokensUsed+=f,b.updatedAt=g(),void 0!==b.tokenBudget&&b.tokensUsed>=b.tokenBudget&&"active"===b.status&&(b.status="budget-limited")),c={...e}}function l(){a.appendEntry("goal-mode",b?{...b}:null)}a.registerTool((0,f.defineTool)({name:"goal",label:"Goal",description:'Use the goal tool to manage your current task objective.\n- goal(op="create", objective="...", token_budget=N?) — set a goal with optional token budget\n- goal(op="get") — check current goal status\n- goal(op="complete") — mark goal as complete\n- goal(op="drop") — abandon the current goal\nWhen you have a clear objective, set a goal to track progress and budget.',parameters:e.Type.Object({op:e.Type.Union([e.Type.Literal("create"),e.Type.Literal("get"),e.Type.Literal("complete"),e.Type.Literal("drop"),e.Type.Literal("resume")],{description:"goal operation"}),objective:e.Type.Optional(e.Type.String({description:"goal objective (required for create)"})),token_budget:e.Type.Optional(e.Type.Number({description:"token budget limit (optional)"}))}),execute:async(a,e)=>{let f=e.op,m=e.objective?.trim(),n=e.token_budget;switch(f){case"create":{if(!m)return{content:[{type:"text",text:"Error: objective is required for goal create."}],details:null};if(b&&"dropped"!==b.status&&"complete"!==b.status)return{content:[{type:"text",text:"Error: a goal is already active. Complete or drop it first."}],details:null};let a=g();b={id:`goal-${a}`,objective:m,status:"active",tokenBudget:n&&n>0?n:void 0,tokensUsed:0,timeUsedSeconds:0,createdAt:a,updatedAt:a},d=!0,c=j(),l();let e=b.tokenBudget?` | budget: ${h(b.tokenBudget)} tokens`:"";return{content:[{type:"text",text:`Goal set: "${m}"${e}`}],details:{...b}}}case"get":{if(!b)return{content:[{type:"text",text:"No active goal."}],details:null};k();let a=Math.floor((g()-b.createdAt)/1e3);b.timeUsedSeconds=Math.max(b.timeUsedSeconds,a);let c=b.tokenBudget?` | ${h(b.tokensUsed)} / ${h(b.tokenBudget)} tokens`:` | ${h(b.tokensUsed)} tokens`;return{content:[{type:"text",text:`Goal: "${b.objective}"
42
42
  Status: ${b.status}${c}
43
- Time: ${i(b.timeUsedSeconds)}`}],details:{...b}}}case"complete":{var q;let a;if(!b)return{content:[{type:"text",text:"No active goal to complete."}],details:null};k(),b.status="complete",b.updatedAt=g(),d=!1;let c=(q=b,a=[],void 0!==q.tokenBudget&&a.push(`tokens used: ${q.tokensUsed} of ${q.tokenBudget}`),q.timeUsedSeconds>0&&a.push(`time used: ${i(q.timeUsedSeconds)}`),a.length>0?`Goal achieved. Final budget: ${a.join("; ")}.`:null);return l(),{content:[{type:"text",text:`Goal completed: "${b.objective}"${c?`
44
- ${c}`:""}`}],details:{...b}}}case"drop":if(!b)return{content:[{type:"text",text:"No active goal to drop."}],details:null};return b.status="dropped",b.updatedAt=g(),d=!1,l(),{content:[{type:"text",text:`Goal dropped: "${b.objective}"`}],details:{...b}};case"resume":if(!b)return{content:[{type:"text",text:"No goal to resume."}],details:null};if("complete"===b.status)return{content:[{type:"text",text:"Cannot resume a completed goal."}],details:null};return b.status="active",b.updatedAt=g(),d=!0,c=j(),l(),{content:[{type:"text",text:`Goal resumed: "${b.objective}"`}],details:{...b}};default:return{content:[{type:"text",text:`Unknown goal operation: ${n}`}],details:null}}}})),a.on("before_agent_start",async()=>{if(b&&"active"===b.status){var a;return k(),{message:{customType:"goal-context",content:(a=b,["<goal_context>",`You are working toward a goal: "${a.objective}"`,void 0!==a.tokenBudget?`Token budget: ${h(a.tokenBudget)} (${h(a.tokensUsed)} used, ${h(a.tokenBudget-a.tokensUsed)} remaining).`:`Tokens used so far: ${h(a.tokensUsed)}.`,`Time spent: ${i(a.timeUsedSeconds)}.`,void 0!==a.tokenBudget&&a.tokensUsed>=a.tokenBudget?'BUDGET EXCEEDED. Complete the goal now with goal(op="complete").':'Stay focused. Call goal(op="get") to check progress, goal(op="complete") when finished.',"</goal_context>"].join("\n")),display:!1}}}}),a.on("tool_result",async()=>{k()}),a.on("turn_start",async()=>{d&&(c=j()),l()}),a.on("agent_end",async()=>{k(),l()}),a.on("session_start",async(a,e)=>{let f=e.sessionManager.getEntries().filter(a=>"custom"===a.type&&"goal-mode"===a.customType).pop();f?.data&&(b=f.data,(d="active"===b.status)&&(c=j()))})}[e,f]=g.then?(await g)():g,d()}catch(a){d(a)}})},27348:(a,b,c)=>{"use strict";c.d(b,{WO:()=>B});let d=["interactive","chart","mockup","art","diagram"],e=/\n?\s*<widget-guidelines\b[^>]*>[\s\S]*?<\/widget-guidelines>\s*/g,f="## Core design system\n\n### When to use widgets\n- Use `show-widget` by default when visual output is the primary answer.\n- This includes charts, diagrams, flowcharts, timelines, dashboards, UI prototypes, mockups, SVG illustrations, icons, logos, infographics, hierarchy views, comparisons, and visual explanations.\n- Do not output raw ```svg, ```html, or plain Mermaid for visual answers unless the user explicitly asks for source code, raw Markdown, raw Mermaid, or a saved file.\n- For diagrams, flowcharts, architecture maps, sequence-style explanations, and Markdown-to-diagram requests, prefer `show-widget` with SVG/HTML over Mermaid because widgets stream more reliably in this UI.\n- Put explanatory prose outside the code fence. The fence contains exactly one JSON object.\n\n### Format rules\n- `widget_code` is a JSON string: escape quotes and newlines, close the JSON object, then close the fence.\n- Do not include DOCTYPE, html, head, body, iframe, object, embed, form, link, base, or meta tags.\n- Keep outer backgrounds transparent. Use host variables: `--bg`, `--bg-panel`, `--bg-hover`, `--bg-selected`, `--border`, `--text`, `--text-muted`, `--text-dim`, `--accent`, `--accent-hover`.\n- CodePilot-compatible variables are also available: `--color-background-primary`, `--color-background-secondary`, `--color-background-tertiary`, `--color-text-primary`, `--color-text-secondary`, `--color-text-tertiary`, `--color-border-tertiary`, `--color-border-secondary`, `--color-border-primary`, `--font-sans`, `--font-mono`.\n- HTML widgets should stream in this order: `<style>`, visible markup, `<script>`. SVG widgets should put `<defs>` before visible shapes.\n- Use `min-height` instead of fixed outer `height`; avoid bottom clipping at chat widths.\n- Use readable text: no font smaller than 11px, no negative letter spacing, no text overlap.\n\n### Visual style\n- The widget should feel native to chat, not like a foreign embed.\n- Use flat, solid fills with clear borders. Avoid decorative gradients, shadows, blur, glow, neon, and busy backgrounds.\n- Use 2-3 color ramps per widget and gray/slate for structure.\n- Prefer the visualization type that best fits the content. Do not default to one type for every request.\n- Title should be human-readable in the user's language.",g=`## Color and layout
43
+ Time: ${i(b.timeUsedSeconds)}`}],details:{...b}}}case"complete":{var o;let a;if(!b)return{content:[{type:"text",text:"No active goal to complete."}],details:null};k(),b.status="complete",b.updatedAt=g(),d=!1;let c=(o=b,a=[],void 0!==o.tokenBudget&&a.push(`tokens used: ${o.tokensUsed} of ${o.tokenBudget}`),o.timeUsedSeconds>0&&a.push(`time used: ${i(o.timeUsedSeconds)}`),a.length>0?`Goal achieved. Final budget: ${a.join("; ")}.`:null);return l(),{content:[{type:"text",text:`Goal completed: "${b.objective}"${c?`
44
+ ${c}`:""}`}],details:{...b}}}case"drop":if(!b)return{content:[{type:"text",text:"No active goal to drop."}],details:null};return b.status="dropped",b.updatedAt=g(),d=!1,l(),{content:[{type:"text",text:`Goal dropped: "${b.objective}"`}],details:{...b}};case"resume":if(!b)return{content:[{type:"text",text:"No goal to resume."}],details:null};if("complete"===b.status)return{content:[{type:"text",text:"Cannot resume a completed goal."}],details:null};return b.status="active",b.updatedAt=g(),d=!0,c=j(),l(),{content:[{type:"text",text:`Goal resumed: "${b.objective}"`}],details:{...b}};default:return{content:[{type:"text",text:`Unknown goal operation: ${f}`}],details:null}}}})),a.on("before_agent_start",async()=>{if(b&&"active"===b.status){var a;return k(),{message:{customType:"goal-context",content:(a=b,["<goal_context>",`You are working toward a goal: "${a.objective}"`,void 0!==a.tokenBudget?`Token budget: ${h(a.tokenBudget)} (${h(a.tokensUsed)} used, ${h(a.tokenBudget-a.tokensUsed)} remaining).`:`Tokens used so far: ${h(a.tokensUsed)}.`,`Time spent: ${i(a.timeUsedSeconds)}.`,void 0!==a.tokenBudget&&a.tokensUsed>=a.tokenBudget?'BUDGET EXCEEDED. Complete the goal now with goal(op="complete").':'Stay focused. Call goal(op="get") to check progress, goal(op="complete") when finished.',"</goal_context>"].join("\n")),display:!1}}}}),a.on("tool_result",async()=>{k()}),a.on("turn_start",async()=>{d&&(c=j()),l()}),a.on("agent_end",async()=>{k(),l()}),a.on("session_start",async(a,e)=>{let f=e.sessionManager.getEntries().filter(a=>"custom"===a.type&&"goal-mode"===a.customType).pop();f?.data&&(b=f.data,(d="active"===b.status)&&(c=j()))})}[e,f]=g.then?(await g)():g,d()}catch(a){d(a)}})},27348:(a,b,c)=>{"use strict";c.d(b,{WO:()=>B});let d=["interactive","chart","mockup","art","diagram"],e=/\n?\s*<widget-guidelines\b[^>]*>[\s\S]*?<\/widget-guidelines>\s*/g,f="## Core design system\n\n### When to use widgets\n- Use `show-widget` by default when visual output is the primary answer.\n- This includes charts, diagrams, flowcharts, timelines, dashboards, UI prototypes, mockups, SVG illustrations, icons, logos, infographics, hierarchy views, comparisons, and visual explanations.\n- Do not output raw ```svg, ```html, or plain Mermaid for visual answers unless the user explicitly asks for source code, raw Markdown, raw Mermaid, or a saved file.\n- For diagrams, flowcharts, architecture maps, sequence-style explanations, and Markdown-to-diagram requests, prefer `show-widget` with SVG/HTML over Mermaid because widgets stream more reliably in this UI.\n- Put explanatory prose outside the code fence. The fence contains exactly one JSON object.\n\n### Format rules\n- `widget_code` is a JSON string: escape quotes and newlines, close the JSON object, then close the fence.\n- Do not include DOCTYPE, html, head, body, iframe, object, embed, form, link, base, or meta tags.\n- Keep outer backgrounds transparent. Use host variables: `--bg`, `--bg-panel`, `--bg-hover`, `--bg-selected`, `--border`, `--text`, `--text-muted`, `--text-dim`, `--accent`, `--accent-hover`.\n- CodePilot-compatible variables are also available: `--color-background-primary`, `--color-background-secondary`, `--color-background-tertiary`, `--color-text-primary`, `--color-text-secondary`, `--color-text-tertiary`, `--color-border-tertiary`, `--color-border-secondary`, `--color-border-primary`, `--font-sans`, `--font-mono`.\n- HTML widgets should stream in this order: `<style>`, visible markup, `<script>`. SVG widgets should put `<defs>` before visible shapes.\n- Use `min-height` instead of fixed outer `height`; avoid bottom clipping at chat widths.\n- Use readable text: no font smaller than 11px, no negative letter spacing, no text overlap.\n\n### Visual style\n- The widget should feel native to chat, not like a foreign embed.\n- Use flat, solid fills with clear borders. Avoid decorative gradients, shadows, blur, glow, neon, and busy backgrounds.\n- Use 2-3 color ramps per widget and gray/slate for structure.\n- Prefer the visualization type that best fits the content. Do not default to one type for every request.\n- Title should be human-readable in the user's language.",g=`## Color and layout
45
45
 
46
46
  - Palette ramps:
47
47
  - Indigo: \`#EEF2FF/#C7D2FE/#818CF8/#4F46E5/#3730A3\`
@@ -139,7 +139,7 @@ ${h.content}
139
139
 
140
140
  ${j}`:j}},34429:(a,b,c)=>{"use strict";c.d(b,{O:()=>f});let d=/\bstream(?:[_\s-]+)read(?:[_\s-]+)error\b/i,e=new WeakSet;function f(a){if(e.has(a))return!0;let b=a._isRetryableError;return"function"==typeof b&&(a._isRetryableError=function(a){return!!a&&"object"==typeof a&&"error"===a.stopReason&&"string"==typeof a.errorMessage&&d.test(a.errorMessage)||b.call(this,a)},e.add(a),!0)}},36945:(a,b,c)=>{"use strict";function d(a){if(!a.afterEventId)return{afterSequence:void 0,replayGap:!1};let b=a.afterEventId.lastIndexOf(":"),c=b>0?a.afterEventId.slice(0,b):"",d=b>0?Number(a.afterEventId.slice(b+1)):NaN;if(c!==a.streamEpoch||!Number.isSafeInteger(d))return{afterSequence:void 0,replayGap:!0};let e=a.events.length>0?Number(a.events[0].__eventSequence):a.nextSequence;return!Number.isSafeInteger(e)||d<e-1?{afterSequence:void 0,replayGap:!0}:{afterSequence:d,replayGap:!1}}c.d(b,{Z:()=>d})},39773:(a,b,c)=>{"use strict";c.d(b,{X:()=>g,w:()=>f});var d=c(55511);let e=new Map;function f(a){let b=(0,d.randomUUID)().replace(/-/g,"").slice(0,24);return e.set(b,{...a,token:b,expiresAt:Date.now()+18e5}),b}function g(a){let b=e.get(a);return b?Date.now()>b.expiresAt?(e.delete(a),null):b:null}setInterval(()=>{let a=Date.now();for(let[b,c]of e)a>c.expiresAt&&e.delete(b)},3e5)},41761:(a,b,c)=>{"use strict";c.d(b,{C1:()=>e,lA:()=>d});let d="subagent",e=["bash","read","edit","write","grep","find","ls"];[...e],[...e]},44036:(a,b,c)=>{"use strict";c.d(b,{FJ:()=>g,R4:()=>h,X8:()=>f});let d="<workbench-guidelines>\nAnnoVibe Workbench is active. Use it for reproducible R/Python analysis plots, data visualizations, and warm-runtime analysis work.\n\nTool routing:\n- Use `kernel_plot_render` for one-shot iterative plot previews — images auto-render inline in chat without saving files. Call `render_plot()` to mark the preview target. ggplot2 (R) and plt.show() (Python) are auto-captured as convenience.\n- Use `kernel_plot_inspect` after resuming a workbench session, after suspected kernel restart, or whenever you are unsure whether objects like `adata`/`seurat_obj` are still live in memory.\n- Use `kernel_plot_run` when plots depend on data already loaded in warm kernel memory, or when saving final artifacts to disk.\n- Use `runtime: \"kernel-lite\"` in `kernel_plot_run` when variables or loaded data should persist across turns.\n- Use `runtime: \"worker\"` for one-shot scripts that should be isolated.\n- Do not run Rscript/python plotting through `bash` unless the workbench tools are unavailable.\n- Do not use bash with `conda run python`, `Rscript`, or direct interpreter calls for analysis code — always prefer `kernel_plot_run`.\n\nkernel-lite memory rules — CRITICAL:\n- Packages imported (import scanpy, library(Seurat), etc.) and variables assigned in one kernel_plot_run call persist while the same kernel-lite runtime is alive. Do NOT repeat imports in every call. Import each package only once, in the first call that needs it.\n- Large data objects loaded via sc.read(), readRDS(), qread(), pd.read_csv(), etc. stay in memory while the warm kernel is alive. Before calling any load function, check whether the object already exists:\n Python: `if 'adata' not in globals(): adata = sc.read(path)`\n R: `if (!exists('seurat_obj')) seurat_obj <- readRDS(path)`\n Print a brief note when reusing in-memory data vs loading fresh.\n- Do NOT put sc.read() / readRDS() / qread() at the top of every call. This reloads multi-GB files needlessly and is the #1 performance mistake in workbench sessions.\n- After browser refreshes, model switches, compaction, or a resumed workbench session, treat prior history as inferred only: first use `kernel_plot_inspect` or an explicit existence check to see whether required objects still exist, then reload only missing objects from the known source path.\n\nWorkbench artifact rules:\n- Save every output under `WARMPLOT_OUTPUT_DIR` or `PI_KERNEL_PLOT_OUTPUT_DIR`.\n- Create a primary PNG/JPEG/WebP preview for chat display whenever a figure is produced, not PDF-only output. Keep the preview reasonably sized so it can be embedded inline.\n- If a publication-quality PDF/SVG is needed, save it in addition to the preview image.\n- Name the primary preview clearly, for example `00_preview.png`, so it is easy to identify.\n- When the user asks to save final outputs to a specific project directory, use that directory (not WARMPLOT_OUTPUT_DIR) for the final artifacts.\n\nChat display rules:\n- The web chat renders returned image artifacts inline. Do not say that images cannot be displayed.\n- Do not use `open`, `xdg-open`, or desktop viewers to show plots.\n- After generating any plot, make the chat response displayable by including the PNG/JPEG/WebP preview path in the final answer or by returning it as a tool image artifact. Do not mention only PDF paths when an image preview exists.\n- When using shell tools for plotting, still save a PNG/JPEG/WebP preview and include that preview path in the final answer; avoid a final answer that only says a desktop window was opened.\n- When the user asks to show an existing PNG/JPEG/WebP file, use `read` on that image path; the UI will display the image even if the model cannot inspect pixels.\n- If only a PDF exists and the user asks to see it in chat, generate a PNG preview with `kernel_plot_run` or report the PDF path only if conversion is not practical.\n- After a successful plot, summarize the result briefly and include both preview image paths and any publication-quality PDF/SVG paths.\n</workbench-guidelines>",e=/\n?\s*(?:<plot-mode-guidelines>[\s\S]*?<\/plot-mode-guidelines>|<workbench-guidelines>[\s\S]*?<\/workbench-guidelines>)\s*/g;function f(a){return a.replace(e,"\n").replace(/\n{3,}/g,"\n\n").trim()}function g(a){return a.includes("<plot-mode-guidelines>")||a.includes("<workbench-guidelines>")?a:a.trim()?`${a.trimEnd()}
141
141
 
142
- ${d}`:d}function h(a){for(let b of a)if("kernel_plot_run"===b)return!0;return!1}},56429:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{A4:()=>J,Bj:()=>P,Fn:()=>M,HG:()=>K,OF:()=>Q,V$:()=>N,dU:()=>U,kp:()=>A});var e=c(75430),f=c(40402),g=c(9774),h=c(3867),i=c(85097),j=c(11745),k=c(9805),l=c(27348),m=c(44036),n=c(66469),o=c(29021),p=c(33873),q=c(55511),r=c(7048),s=c(41761),t=c(74788),u=c(91179),v=c(57149),w=c(60103),x=c(36945),y=c(34429),z=a([e,f,g,h,i,j,t,u]);[e,f,g,h,i,j,t,u]=z.then?(await z)():z;class R extends Error{constructor(a){super(`Session ${a} is already processing another command`),this.code="SESSION_BUSY",this.name="SessionBusyError"}}function A(a){return a instanceof R||!!a&&"object"==typeof a&&"SESSION_BUSY"===a.code}class S extends Error{constructor(a,b){super(b),this.reason=a,this.code="COMPACTION_ERROR",this.name="CompactionError"}}let T=s.C1;class U{constructor(a,b,c={}){this.inner=a,this.modelRegistry=b,this.options=c,this.listeners=[],this.replayEvents=[],this.unsubscribe=null,this.idleTimer=null,this.onDestroyCallback=null,this.busyOperations=new Set,this.activeTools=new Map,this.currentRuntimePhase="idle",this.phaseStartedAtMs=null,this.promptRunId=0,this.activePromptRunId=null,this.abortedPromptRunId=0,this.runStartedAtMs=null,this.firstModelEventAtMs=null,this.lastEventAtMs=null,this.lastEventType=null,this.lastErrorMessage=null,this.streamEpoch=(0,q.randomUUID)(),this.nextEventId=1,this._alive=!0,this._lastAppliedPromptKey="",this._kernelStateCache=null,(0,y.O)(a)}get sessionId(){return this.inner.sessionId}get sessionFile(){return this.inner.sessionFile??""}isAlive(){return this._alive}isBusy(){return this.busyOperations.size>0||this.inner.isStreaming||this.inner.isCompacting}getRuntimeStatus(){let a=Date.now(),b=this.getPhase(),c=this.inner.model?{provider:this.inner.model.provider,id:this.inner.model.id}:null;return{sessionId:this.sessionId,sessionFile:this.sessionFile,cwd:D(this.inner),busy:this.isBusy(),operations:[...this.busyOperations],isStreaming:this.inner.isStreaming,isCompacting:this.inner.isCompacting,phase:b,model:c,activeTools:[...this.activeTools.entries()].map(([a,b])=>({id:a,name:b})),runStartedAt:E(this.runStartedAtMs),firstModelEventAt:E(this.firstModelEventAtMs),lastEventAt:E(this.lastEventAtMs),lastEventType:this.lastEventType,uptimeMs:this.runStartedAtMs?Math.max(0,a-this.runStartedAtMs):null,waitingForModelMs:"waiting_model"===b&&this.phaseStartedAtMs?Math.max(0,a-this.phaseStartedAtMs):null,pendingMessageCount:"number"==typeof this.inner.pendingMessageCount?this.inner.pendingMessageCount:null,errorMessage:this.lastErrorMessage}}start(){this.unsubscribe=this.inner.subscribe(a=>{"message_end"===a.type?queueMicrotask(()=>this.forwardEvent(this.withLatestEntryId(a))):"agent_end"===a.type?queueMicrotask(()=>this.forwardEvent(a)):this.forwardEvent(a)}),this.resetIdleTimer(),O()}forwardEvent(a){let b=null!==this.activePromptRunId&&void 0===a.__runId?{...a,__runId:this.activePromptRunId}:a;this.recordRuntimeEvent(b),("message_end"===a.type||"compaction_end"===a.type||"auto_compaction_end"===a.type)&&this.bumpSessionCwd();let c=this.sequenceEvent(b);for(let b of(this.bufferReplayEvent(c),this.resetIdleTimer(),("agent_end"===a.type||"agent_start"===a.type)&&O(),this.listeners))b(c)}withLatestEntryId(a){let b=a.message;if(!b||"user"!==b.role&&"assistant"!==b.role&&"toolResult"!==b.role)return a;try{let c=this.inner.sessionManager.getEntries(),d=JSON.stringify(b);for(let b=c.length-1;b>=0;b--){let e=c[b];if("message"===e.type&&"string"==typeof e.id&&JSON.stringify(e.message)===d)return{...a,__entryId:e.id}}}catch{}let c=function(a){let b="string"==typeof a.role?a.role:null;if(!b)return null;let c="number"==typeof a.timestamp?a.timestamp:0,d=0;try{let b=JSON.stringify(a.content??"");for(let a=0;a<b.length;a++)d=(d<<5)-d+b.charCodeAt(a)|0}catch{}return`synth:${b}:${c}:${(d>>>0).toString(36)}`}(b);return c?{...a,__entryId:c}:a}resetIdleTimer(){this.idleTimer&&clearTimeout(this.idleTimer),this.idleTimer=setTimeout(()=>{this.isBusy()?this.resetIdleTimer():this.destroy()},6e5)}sequenceEvent(a){"string"!=typeof this.streamEpoch&&(this.streamEpoch=(0,q.randomUUID)());let b=Number.isSafeInteger(this.nextEventId)?this.nextEventId:1;return this.nextEventId=b+1,{...a,__eventId:`${this.streamEpoch}:${b}`,__eventSequence:b,__streamEpoch:this.streamEpoch}}bufferReplayEvent(a){"agent_start"===a.type&&(this.replayEvents=[]),this.replayEvents.push(a),this.replayEvents.length>200&&this.replayEvents.splice(0,this.replayEvents.length-200)}onEvent(a,b={}){if(this.listeners.push(a),b.replay){let c=(0,x.Z)({streamEpoch:this.streamEpoch,nextSequence:this.nextEventId,events:this.replayEvents,afterEventId:b.afterEventId}),{afterSequence:d}=c;for(let e of(c.replayGap&&(a({type:"replay_gap",requestedAfter:b.afterEventId,streamEpoch:this.streamEpoch,oldestEventId:this.replayEvents[0]?.__eventId??null}),d=void 0),this.replayEvents)){let b="number"==typeof e.__eventSequence?e.__eventSequence:0;(void 0===d||b>d)&&a(e)}}return()=>{let b=this.listeners.indexOf(a);-1!==b&&this.listeners.splice(b,1)}}onDestroy(a){this.onDestroyCallback=a}async send(a){this.resetIdleTimer();let b=a.type;switch(b){case"prompt":{if(null!==this.activePromptRunId||this.isBusy())throw new R(this.sessionId);Number.isSafeInteger(this.promptRunId)||(this.promptRunId=0);let b=++this.promptRunId;this.activePromptRunId=b,this.busyOperations.add("prompt"),this.setRuntimePhase("waiting_model"),this.resetIdleTimer(),this.replayEvents=[],this.emit({type:"prompt_admitted",__runId:b}),O();try{let c="string"==typeof a.leafId&&a.leafId.trim()?a.leafId:null;if(c&&this.inner.sessionManager.getLeafId()!==c&&(await this.inner.navigateTree(c,{})).cancelled)throw Error(`Failed to navigate session to leaf ${c}`);if("string"==typeof a.provider&&"string"==typeof a.modelId&&await this.applyModelSelection(a.provider,a.modelId),"string"==typeof a.thinkingLevel&&this.applyThinkingLevel(a.thinkingLevel),Array.isArray(a.toolNames)){let b=this.filterAvailableToolNames(a.toolNames);this.inner.setActiveToolsByName(b)}this.preparePromptContext(a.message);let d=a.images,e=this.inner.model?.input,f=!e||0===e.length||e.includes("image")?d:void 0;return this.inner.prompt(a.message,f?.length?{images:f}:void 0).then(()=>{this.emit({type:"prompt_done",__runId:b})}).catch(a=>{this.abortedPromptRunId!==b&&this.emit({type:"prompt_error",__runId:b,error:a instanceof Error?a.message:String(a)})}).finally(()=>this.finishPromptRun(b)),{runId:b}}catch(a){throw this.emit({type:"prompt_error",__runId:b,error:a instanceof Error?a.message:String(a)}),this.finishPromptRun(b),a}}case"abort":return this.abortedPromptRunId=this.promptRunId,await this.inner.abort(),null;case"get_state":{let a=this.inner.model,b=this.inner.getContextUsage(),c=this.inner.agent.state?.systemPrompt??"",d=(0,g.cV)(),e=(0,t.U5)(this.inner.sessionId),f=this.getRuntimeStatus();return{sessionId:this.inner.sessionId,sessionFile:this.inner.sessionFile??"",isStreaming:this.inner.isStreaming,isCompacting:this.inner.isCompacting,autoCompactionEnabled:this.inner.autoCompactionEnabled,autoRetryEnabled:this.inner.autoRetryEnabled,model:a?{id:a.id,provider:a.provider}:void 0,messageCount:0,pendingMessageCount:0,phase:f.phase,activeTools:f.activeTools,lastEventAt:f.lastEventAt,lastEventType:f.lastEventType,errorMessage:f.errorMessage,goal:e?.goal??null,contextUsage:b?{percent:b.percent,contextWindow:b.contextWindow,tokens:b.tokens}:null,systemPrompt:d.generativeUI?c:(0,k.FE)(c),thinkingLevel:this.inner.agent.state?.thinkingLevel??"off"}}case"set_model":{if(this.isBusy())throw new R(this.sessionId);let{provider:b,modelId:c}=a,d=await this.applyModelSelection(b,c);return{id:d.id,provider:d.provider,thinkingLevel:this.inner.agent.state?.thinkingLevel??"off"}}case"fork":{let b;if(this.isBusy())throw new R(this.sessionId);let c=a.entryId,d=this.inner.sessionManager,g=this.inner.sessionFile;if(!d.isPersisted())return{cancelled:!0};if(!g)throw Error("Persisted session is missing a session file");let h=d.getEntry(c);if(!h)throw Error("Invalid entry ID for forking");let i=d.getSessionDir();if(h.parentId){let a=e.SessionManager.open(g,i).createBranchedSession(h.parentId);if(!a)throw Error("Failed to create forked session");b=a}else{let a=e.SessionManager.create(d.getCwd(),i);a.newSession({parentSession:g}),b=a.getSessionFile()}let j=e.SessionManager.open(b,i).getSessionId();(0,f.O8)(j,b);let k=D(this.inner),l=(0,t.U5)(this.sessionId);return l&&await (0,t.oR)(j,{...l,createdBy:"fork",createdAt:new Date().toISOString()},k?{cwd:k}:{}),this.destroy(),k&&((0,u.fd)(k),(0,u.E8)()),{cancelled:!1,newSessionId:j}}case"navigate_tree":if(this.isBusy())throw new R(this.sessionId);return{cancelled:(await this.inner.navigateTree(a.targetId,{})).cancelled};case"set_thinking_level":if(this.isBusy())throw new R(this.sessionId);return this.applyThinkingLevel(a.level),null;case"compact":{let b;if(this.isBusy())throw new R(this.sessionId);let{findCutPoint:d,DEFAULT_COMPACTION_SETTINGS:e}=await Promise.resolve().then(c.bind(c,75430)),f=this.inner.sessionManager.getBranch(),g={...e,...this.inner.settingsManager.getCompactionSettings()},h=-1;for(let a=f.length-1;a>=0;a--)if("compaction"===f[a].type){h=a;break}let i=h+1,j=d(f,i,f.length,g.keepRecentTokens);if((j.isSplitTurn?j.turnStartIndex:j.firstKeptEntryIndex)<=i)throw new S("too-short","Conversation is too short to compact");try{b=await this.trackBusy("compact",this.inner.compact(a.customInstructions))}catch(c){let a,b;throw(b=(a=c instanceof Error?c.message:String(c)).toLowerCase()).includes("already compacted")?new S("already-compacted","This session has already been compacted"):b.includes("too small")||b.includes("nothing to compact")||b.includes("too short")?new S("too-short","Conversation is too short to compact"):b.includes("cancelled")||b.includes("abort")?new S("cancelled","Compaction was cancelled"):new S("failed",a||"Compaction failed")}let k=b;return{tokensBefore:"number"==typeof k?.tokensBefore?k.tokensBefore:null,tokensAfter:"number"==typeof k?.estimatedTokensAfter?k.estimatedTokensAfter:null,reducedBy:"number"==typeof k?.tokensBefore&&"number"==typeof k?.estimatedTokensAfter?Math.max(0,k.tokensBefore-k.estimatedTokensAfter):null}}case"set_auto_compaction":return this.inner.setAutoCompactionEnabled(a.enabled),null;case"steer":{this.preparePromptContext(a.message);let b=a.images,c=this.inner.model?.input,d=!c||0===c.length||c.includes("image")?b:void 0;return await this.trackBusy("steer",this.inner.steer(a.message,d?.length?d:void 0)),null}case"follow_up":{this.preparePromptContext(a.message);let b=a.images,c=this.inner.model?.input,d=!c||0===c.length||c.includes("image")?b:void 0;return await this.trackBusy("follow_up",this.inner.followUp(a.message,d?.length?d:void 0)),null}case"get_tools":{let a=this.inner.getAllTools(),b=new Set(this.inner.getActiveToolNames());return a.map(a=>({name:a.name,description:a.description,active:b.has(a.name)}))}case"set_tools":{if(this.isBusy())throw new R(this.sessionId);let b=this.filterAvailableToolNames(a.toolNames);return this.inner.setActiveToolsByName(b),this.applyRuntimePrompts(),(0,t.LN)(this.sessionId,{lastToolNames:this.inner.getActiveToolNames()}).catch(()=>{}),null}case"abort_compaction":return this.inner.abortCompaction(),null;case"set_session_name":{let b=a.name?.trim();if(!b)throw Error("Session name cannot be empty");return this.inner.setSessionName(b),(0,f.lG)(this.sessionId),(0,u.xm)(this.sessionId),null}case"append_message":{if(this.isBusy())throw new R(this.sessionId);let b=a.message;if("string"!=typeof b||!b.trim())return null;if(!this.inner.sendCustomMessage)throw Error("Session does not support append_message");return await this.inner.sendCustomMessage({customType:"string"==typeof a.customType&&a.customType?a.customType:"context-note",content:b,display:"boolean"!=typeof a.display||a.display},{triggerTurn:!1}),null}case"set_auto_retry":return this.inner.setAutoRetryEnabled(a.enabled),null;default:throw Error(`Unsupported command: ${b}`)}}destroy(){this._alive&&(this._alive=!1,this.idleTimer&&clearTimeout(this.idleTimer),this.unsubscribe?.(),this.onDestroyCallback?.(),O())}bumpSessionCwd(){let a=D(this.inner);a&&(0,u.fd)(a)}async applyModelSelection(a,b){let c=this.modelRegistry.find(a,b);if(!c){let d=a.toLowerCase().replace(/-/g,"");d!==a&&(c=this.modelRegistry.find(d,b))}if(!c)throw Error(`Model not found: ${a}/${b}`);return await this.inner.setModel(c),c}applyThinkingLevel(a){this.inner.setThinkingLevel(a),"xhigh"===a&&this.inner.model?.compat?.thinkingFormat==="deepseek"&&this.inner.agent?.state&&(this.inner.agent.state.thinkingLevel="xhigh")}preparePromptContext(a){this.applyRuntimePrompts(a)}finishPromptRun(a){this.activePromptRunId===a&&(this.activePromptRunId=null,this.busyOperations.delete("prompt"),this.isBusy()||this.setRuntimePhase("idle"),this.resetIdleTimer(),O())}async trackBusy(a,b){this.busyOperations.add(a),this.setRuntimePhase("compact"===a?"compacting":"waiting_model"),this.resetIdleTimer(),O();try{return await b}finally{this.busyOperations.delete(a),this.isBusy()||this.setRuntimePhase("idle"),this.resetIdleTimer(),O()}}setRuntimePhase(a,b=Date.now()){this.currentRuntimePhase!==a&&(this.currentRuntimePhase=a,this.phaseStartedAtMs="idle"===a?null:b)}getPhase(){if(this.inner.isCompacting||this.busyOperations.has("compact"))return"compacting";if(this.activeTools.size>0)return"running_tools";if(this.isBusy()){let a=this.currentRuntimePhase;return a&&"idle"!==a?a:"waiting_model"}return"idle"}emit(a){let b=this.sequenceEvent(a);for(let a of(this.bufferReplayEvent(b),this.listeners))a(b)}recordRuntimeEvent(a){let b=Date.now();switch(this.lastEventAtMs=b,this.lastEventType=a.type,a.type){case"agent_start":this.runStartedAtMs=b,this.firstModelEventAtMs=null,this.lastErrorMessage=null,this.activeTools.clear(),this.setRuntimePhase("waiting_model",b);break;case"message_start":case"message_update":{let c=a.message;c?.role==="assistant"?(this.firstModelEventAtMs||(this.firstModelEventAtMs=b),"string"==typeof c.errorMessage&&(this.lastErrorMessage=c.errorMessage),this.setRuntimePhase("streaming",b)):c?.role==="user"&&this.setRuntimePhase("waiting_model",b);break}case"message_end":{let c=a.message;c?.role==="assistant"&&"string"==typeof c.errorMessage&&(this.lastErrorMessage=c.errorMessage),this.setRuntimePhase("waiting_model",b);break}case"tool_execution_start":{let c="string"==typeof a.toolCallId?a.toolCallId:"",d="string"==typeof a.toolName?a.toolName:"tool";c&&this.activeTools.set(c,d),this.setRuntimePhase("running_tools",b);break}case"tool_execution_end":{let c="string"==typeof a.toolCallId?a.toolCallId:"";c&&this.activeTools.delete(c),this.setRuntimePhase(this.activeTools.size>0?"running_tools":"waiting_model",b);break}case"auto_retry_start":this.setRuntimePhase("waiting_model",b);break;case"compaction_start":case"auto_compaction_start":this.setRuntimePhase("compacting",b);break;case"compaction_end":case"auto_compaction_end":this.setRuntimePhase(this.isBusy()?"waiting_model":"idle",b);break;case"agent_end":this.activeTools.clear(),!0===a.willRetry?this.setRuntimePhase("waiting_model",b):(this.setRuntimePhase("idle",b),this.runStartedAtMs=null,this.firstModelEventAtMs=null)}}applyRuntimePrompts(a){if(!this.inner.agent.state||this.options.systemPromptDisabled)return;let b=(0,g.cV)(),c=this.inner.getActiveToolNames(),d=(0,m.R4)(c),e=B(this.inner),f=0;if(this.sessionFile)try{f=(0,o.statSync)(this.sessionFile).mtimeMs}catch{f=0}let h=null;if(d&&this.sessionFile)if(this._kernelStateCache&&this._kernelStateCache.mtime===f)h=this._kernelStateCache.summary;else{let a=(0,w.f)(this.sessionFile);a?(h=(0,w.v)(a),this._kernelStateCache={mtime:f,summary:h}):this._kernelStateCache=null}else this._kernelStateCache=null;let i=h?`|mtime=${f}`:"",j=a??"",n=`${d}|${b.generativeUI}|${j.length>0?"msg":"no-msg"}${i}`;if(this._lastAppliedPromptKey===n&&e.length>0)return;if(!b.generativeUI){let a=(0,m.X8)((0,k.FE)(e)),b=F(a,d),c=h?`${b}
142
+ ${d}`:d}function h(a){for(let b of a)if("kernel_plot_run"===b)return!0;return!1}},56429:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{A4:()=>J,Bj:()=>P,Fn:()=>M,HG:()=>K,OF:()=>Q,V$:()=>N,dU:()=>U,kp:()=>A});var e=c(75430),f=c(40402),g=c(9774),h=c(3867),i=c(85097),j=c(11745),k=c(9805),l=c(27348),m=c(44036),n=c(66469),o=c(29021),p=c(33873),q=c(55511),r=c(7048),s=c(41761),t=c(74788),u=c(91179),v=c(57149),w=c(60103),x=c(36945),y=c(34429),z=a([e,f,g,h,i,j,t,u]);[e,f,g,h,i,j,t,u]=z.then?(await z)():z;class R extends Error{constructor(a){super(`Session ${a} is already processing another command`),this.code="SESSION_BUSY",this.name="SessionBusyError"}}function A(a){return a instanceof R||!!a&&"object"==typeof a&&"SESSION_BUSY"===a.code}class S extends Error{constructor(a,b){super(b),this.reason=a,this.code="COMPACTION_ERROR",this.name="CompactionError"}}let T=s.C1;class U{constructor(a,b,c={}){this.inner=a,this.modelRegistry=b,this.options=c,this.listeners=[],this.replayEvents=[],this.unsubscribe=null,this.idleTimer=null,this.pendingAgentEndTimer=null,this.onDestroyCallback=null,this.busyOperations=new Set,this.activeTools=new Map,this.currentRuntimePhase="idle",this.phaseStartedAtMs=null,this.promptRunId=0,this.activePromptRunId=null,this.abortedPromptRunId=0,this.runStartedAtMs=null,this.firstModelEventAtMs=null,this.lastEventAtMs=null,this.lastEventType=null,this.lastErrorMessage=null,this.streamEpoch=(0,q.randomUUID)(),this.nextEventId=1,this._alive=!0,this._lastAppliedPromptKey="",this._kernelStateCache=null,(0,y.O)(a)}get sessionId(){return this.inner.sessionId}get sessionFile(){return this.inner.sessionFile??""}isAlive(){return this._alive}isBusy(){return this.busyOperations.size>0||this.inner.isStreaming||this.inner.isCompacting}getRuntimeStatus(){let a=Date.now(),b=this.getPhase(),c=this.inner.model?{provider:this.inner.model.provider,id:this.inner.model.id}:null;return{sessionId:this.sessionId,sessionFile:this.sessionFile,cwd:D(this.inner),busy:this.isBusy(),operations:[...this.busyOperations],isStreaming:this.inner.isStreaming,isCompacting:this.inner.isCompacting,phase:b,model:c,activeTools:[...this.activeTools.entries()].map(([a,b])=>({id:a,name:b})),runStartedAt:E(this.runStartedAtMs),firstModelEventAt:E(this.firstModelEventAtMs),lastEventAt:E(this.lastEventAtMs),lastEventType:this.lastEventType,uptimeMs:this.runStartedAtMs?Math.max(0,a-this.runStartedAtMs):null,waitingForModelMs:"waiting_model"===b&&this.phaseStartedAtMs?Math.max(0,a-this.phaseStartedAtMs):null,pendingMessageCount:"number"==typeof this.inner.pendingMessageCount?this.inner.pendingMessageCount:null,errorMessage:this.lastErrorMessage}}start(){this.unsubscribe=this.inner.subscribe(a=>{let b=null!==this.activePromptRunId&&void 0===a.__runId?{...a,__runId:this.activePromptRunId}:a;if("message_end"===a.type)return void queueMicrotask(()=>this.forwardEvent(this.withLatestEntryId(b)));if("agent_end"===a.type){this.pendingAgentEndTimer&&clearTimeout(this.pendingAgentEndTimer),this.pendingAgentEndTimer=setTimeout(()=>{this.pendingAgentEndTimer=null,this.forwardEvent(b)},0);return}"agent_start"===a.type&&this.pendingAgentEndTimer&&(clearTimeout(this.pendingAgentEndTimer),this.pendingAgentEndTimer=null),this.forwardEvent(b)}),this.resetIdleTimer(),O()}forwardEvent(a){let b=null!==this.activePromptRunId&&void 0===a.__runId?{...a,__runId:this.activePromptRunId}:a;this.recordRuntimeEvent(b),("message_end"===a.type||"compaction_end"===a.type||"auto_compaction_end"===a.type)&&this.bumpSessionCwd();let c=this.sequenceEvent(b);for(let b of(this.bufferReplayEvent(c),this.resetIdleTimer(),("agent_end"===a.type||"agent_start"===a.type)&&O(),this.listeners))b(c)}withLatestEntryId(a){let b=a.message;if(!b||"user"!==b.role&&"assistant"!==b.role&&"toolResult"!==b.role)return a;try{let c=this.inner.sessionManager.getEntries(),d=JSON.stringify(b);for(let b=c.length-1;b>=0;b--){let e=c[b];if("message"===e.type&&"string"==typeof e.id&&JSON.stringify(e.message)===d)return{...a,__entryId:e.id}}}catch{}let c=function(a){let b="string"==typeof a.role?a.role:null;if(!b)return null;let c="number"==typeof a.timestamp?a.timestamp:0,d=0;try{let b=JSON.stringify(a.content??"");for(let a=0;a<b.length;a++)d=(d<<5)-d+b.charCodeAt(a)|0}catch{}return`synth:${b}:${c}:${(d>>>0).toString(36)}`}(b);return c?{...a,__entryId:c}:a}resetIdleTimer(){this.idleTimer&&clearTimeout(this.idleTimer),this.idleTimer=setTimeout(()=>{this.isBusy()?this.resetIdleTimer():this.destroy()},6e5)}sequenceEvent(a){"string"!=typeof this.streamEpoch&&(this.streamEpoch=(0,q.randomUUID)());let b=Number.isSafeInteger(this.nextEventId)?this.nextEventId:1;return this.nextEventId=b+1,{...a,__eventId:`${this.streamEpoch}:${b}`,__eventSequence:b,__streamEpoch:this.streamEpoch}}bufferReplayEvent(a){"agent_start"===a.type&&(this.replayEvents=[]),this.replayEvents.push(a),this.replayEvents.length>200&&this.replayEvents.splice(0,this.replayEvents.length-200)}onEvent(a,b={}){if(this.listeners.push(a),b.replay){let c=(0,x.Z)({streamEpoch:this.streamEpoch,nextSequence:this.nextEventId,events:this.replayEvents,afterEventId:b.afterEventId}),{afterSequence:d}=c;for(let e of(c.replayGap&&(a({type:"replay_gap",requestedAfter:b.afterEventId,streamEpoch:this.streamEpoch,oldestEventId:this.replayEvents[0]?.__eventId??null}),d=void 0),this.replayEvents)){let b="number"==typeof e.__eventSequence?e.__eventSequence:0;(void 0===d||b>d)&&a(e)}}return()=>{let b=this.listeners.indexOf(a);-1!==b&&this.listeners.splice(b,1)}}onDestroy(a){this.onDestroyCallback=a}async send(a){this.resetIdleTimer();let b=a.type;switch(b){case"prompt":{if(null!==this.activePromptRunId||this.isBusy())throw new R(this.sessionId);Number.isSafeInteger(this.promptRunId)||(this.promptRunId=0);let b=++this.promptRunId;this.activePromptRunId=b,this.busyOperations.add("prompt"),this.setRuntimePhase("waiting_model"),this.resetIdleTimer(),this.replayEvents=[],this.emit({type:"prompt_admitted",__runId:b}),O();try{let c="string"==typeof a.leafId&&a.leafId.trim()?a.leafId:null;if(c&&this.inner.sessionManager.getLeafId()!==c&&(await this.inner.navigateTree(c,{})).cancelled)throw Error(`Failed to navigate session to leaf ${c}`);if("string"==typeof a.provider&&"string"==typeof a.modelId&&await this.applyModelSelection(a.provider,a.modelId),"string"==typeof a.thinkingLevel&&this.applyThinkingLevel(a.thinkingLevel),Array.isArray(a.toolNames)){let b=this.filterAvailableToolNames(a.toolNames);this.inner.setActiveToolsByName(b)}this.preparePromptContext(a.message);let d=a.images,e=this.inner.model?.input,f=!e||0===e.length||e.includes("image")?d:void 0;return this.inner.prompt(a.message,f?.length?{images:f}:void 0).then(()=>{this.emit({type:"prompt_done",__runId:b})}).catch(a=>{this.abortedPromptRunId!==b&&this.emit({type:"prompt_error",__runId:b,error:a instanceof Error?a.message:String(a)})}).finally(()=>this.finishPromptRun(b)),{runId:b}}catch(a){throw this.emit({type:"prompt_error",__runId:b,error:a instanceof Error?a.message:String(a)}),this.finishPromptRun(b),a}}case"abort":return this.abortedPromptRunId=this.promptRunId,await this.inner.abort(),null;case"get_state":{let a=this.inner.model,b=this.inner.getContextUsage(),c=this.inner.agent.state?.systemPrompt??"",d=(0,g.cV)(),e=(0,t.U5)(this.inner.sessionId),f=this.getRuntimeStatus();return{sessionId:this.inner.sessionId,sessionFile:this.inner.sessionFile??"",isStreaming:this.inner.isStreaming,isCompacting:this.inner.isCompacting,autoCompactionEnabled:this.inner.autoCompactionEnabled,autoRetryEnabled:this.inner.autoRetryEnabled,model:a?{id:a.id,provider:a.provider}:void 0,messageCount:0,pendingMessageCount:0,phase:f.phase,activeTools:f.activeTools,lastEventAt:f.lastEventAt,lastEventType:f.lastEventType,errorMessage:f.errorMessage,goal:e?.goal??null,contextUsage:b?{percent:b.percent,contextWindow:b.contextWindow,tokens:b.tokens}:null,systemPrompt:d.generativeUI?c:(0,k.FE)(c),thinkingLevel:this.inner.agent.state?.thinkingLevel??"off"}}case"set_model":{if(this.isBusy())throw new R(this.sessionId);let{provider:b,modelId:c}=a,d=await this.applyModelSelection(b,c);return{id:d.id,provider:d.provider,thinkingLevel:this.inner.agent.state?.thinkingLevel??"off"}}case"fork":{let b;if(this.isBusy())throw new R(this.sessionId);let c=a.entryId,d=this.inner.sessionManager,g=this.inner.sessionFile;if(!d.isPersisted())return{cancelled:!0};if(!g)throw Error("Persisted session is missing a session file");let h=d.getEntry(c);if(!h)throw Error("Invalid entry ID for forking");let i=d.getSessionDir();if(h.parentId){let a=e.SessionManager.open(g,i).createBranchedSession(h.parentId);if(!a)throw Error("Failed to create forked session");b=a}else{let a=e.SessionManager.create(d.getCwd(),i);a.newSession({parentSession:g}),b=a.getSessionFile()}let j=e.SessionManager.open(b,i).getSessionId();(0,f.O8)(j,b);let k=D(this.inner),l=(0,t.U5)(this.sessionId);return l&&await (0,t.oR)(j,{...l,createdBy:"fork",createdAt:new Date().toISOString()},k?{cwd:k}:{}),this.destroy(),k&&((0,u.fd)(k),(0,u.E8)()),{cancelled:!1,newSessionId:j}}case"navigate_tree":if(this.isBusy())throw new R(this.sessionId);return{cancelled:(await this.inner.navigateTree(a.targetId,{})).cancelled};case"set_thinking_level":if(this.isBusy())throw new R(this.sessionId);return this.applyThinkingLevel(a.level),null;case"compact":{let b;if(this.isBusy())throw new R(this.sessionId);let{findCutPoint:d,DEFAULT_COMPACTION_SETTINGS:e}=await Promise.resolve().then(c.bind(c,75430)),f=this.inner.sessionManager.getBranch(),g={...e,...this.inner.settingsManager.getCompactionSettings()},h=-1;for(let a=f.length-1;a>=0;a--)if("compaction"===f[a].type){h=a;break}let i=h+1,j=d(f,i,f.length,g.keepRecentTokens);if((j.isSplitTurn?j.turnStartIndex:j.firstKeptEntryIndex)<=i)throw new S("too-short","Conversation is too short to compact");try{b=await this.trackBusy("compact",this.inner.compact(a.customInstructions))}catch(c){let a,b;throw(b=(a=c instanceof Error?c.message:String(c)).toLowerCase()).includes("already compacted")?new S("already-compacted","This session has already been compacted"):b.includes("too small")||b.includes("nothing to compact")||b.includes("too short")?new S("too-short","Conversation is too short to compact"):b.includes("cancelled")||b.includes("abort")?new S("cancelled","Compaction was cancelled"):new S("failed",a||"Compaction failed")}let k=b;return{tokensBefore:"number"==typeof k?.tokensBefore?k.tokensBefore:null,tokensAfter:"number"==typeof k?.estimatedTokensAfter?k.estimatedTokensAfter:null,reducedBy:"number"==typeof k?.tokensBefore&&"number"==typeof k?.estimatedTokensAfter?Math.max(0,k.tokensBefore-k.estimatedTokensAfter):null}}case"set_auto_compaction":return this.inner.setAutoCompactionEnabled(a.enabled),null;case"steer":{this.preparePromptContext(a.message);let b=a.images,c=this.inner.model?.input,d=!c||0===c.length||c.includes("image")?b:void 0;return await this.trackBusy("steer",this.inner.steer(a.message,d?.length?d:void 0)),null}case"follow_up":{this.preparePromptContext(a.message);let b=a.images,c=this.inner.model?.input,d=!c||0===c.length||c.includes("image")?b:void 0;return await this.trackBusy("follow_up",this.inner.followUp(a.message,d?.length?d:void 0)),null}case"get_tools":{let a=this.inner.getAllTools(),b=new Set(this.inner.getActiveToolNames());return a.map(a=>({name:a.name,description:a.description,active:b.has(a.name)}))}case"set_tools":{if(this.isBusy())throw new R(this.sessionId);let b=this.filterAvailableToolNames(a.toolNames);return this.inner.setActiveToolsByName(b),this.applyRuntimePrompts(),(0,t.LN)(this.sessionId,{lastToolNames:this.inner.getActiveToolNames()}).catch(()=>{}),null}case"abort_compaction":return this.inner.abortCompaction(),null;case"set_session_name":{let b=a.name?.trim();if(!b)throw Error("Session name cannot be empty");return this.inner.setSessionName(b),(0,f.lG)(this.sessionId),(0,u.xm)(this.sessionId),null}case"append_message":{if(this.isBusy())throw new R(this.sessionId);let b=a.message;if("string"!=typeof b||!b.trim())return null;if(!this.inner.sendCustomMessage)throw Error("Session does not support append_message");return await this.inner.sendCustomMessage({customType:"string"==typeof a.customType&&a.customType?a.customType:"context-note",content:b,display:"boolean"!=typeof a.display||a.display},{triggerTurn:!1}),null}case"set_auto_retry":return this.inner.setAutoRetryEnabled(a.enabled),null;default:throw Error(`Unsupported command: ${b}`)}}destroy(){this._alive&&(this._alive=!1,this.idleTimer&&clearTimeout(this.idleTimer),this.pendingAgentEndTimer&&clearTimeout(this.pendingAgentEndTimer),this.pendingAgentEndTimer=null,this.unsubscribe?.(),this.onDestroyCallback?.(),O())}bumpSessionCwd(){let a=D(this.inner);a&&(0,u.fd)(a)}async applyModelSelection(a,b){let c=this.modelRegistry.find(a,b);if(!c){let d=a.toLowerCase().replace(/-/g,"");d!==a&&(c=this.modelRegistry.find(d,b))}if(!c)throw Error(`Model not found: ${a}/${b}`);return await this.inner.setModel(c),c}applyThinkingLevel(a){this.inner.setThinkingLevel(a),"xhigh"===a&&this.inner.model?.compat?.thinkingFormat==="deepseek"&&this.inner.agent?.state&&(this.inner.agent.state.thinkingLevel="xhigh")}preparePromptContext(a){this.applyRuntimePrompts(a)}finishPromptRun(a){this.activePromptRunId===a&&(this.activePromptRunId=null,this.busyOperations.delete("prompt"),this.isBusy()||this.setRuntimePhase("idle"),this.resetIdleTimer(),O())}async trackBusy(a,b){this.busyOperations.add(a),this.setRuntimePhase("compact"===a?"compacting":"waiting_model"),this.resetIdleTimer(),O();try{return await b}finally{this.busyOperations.delete(a),this.isBusy()||this.setRuntimePhase("idle"),this.resetIdleTimer(),O()}}setRuntimePhase(a,b=Date.now()){this.currentRuntimePhase!==a&&(this.currentRuntimePhase=a,this.phaseStartedAtMs="idle"===a?null:b)}getPhase(){if(this.inner.isCompacting||this.busyOperations.has("compact"))return"compacting";if(this.activeTools.size>0)return"running_tools";if(this.isBusy()){let a=this.currentRuntimePhase;return a&&"idle"!==a?a:"waiting_model"}return"idle"}emit(a){let b=this.sequenceEvent(a);for(let a of(this.bufferReplayEvent(b),this.listeners))a(b)}recordRuntimeEvent(a){let b=Date.now();switch(this.lastEventAtMs=b,this.lastEventType=a.type,a.type){case"agent_start":this.runStartedAtMs=b,this.firstModelEventAtMs=null,this.lastErrorMessage=null,this.activeTools.clear(),this.setRuntimePhase("waiting_model",b);break;case"message_start":case"message_update":{let c=a.message;c?.role==="assistant"?(this.firstModelEventAtMs||(this.firstModelEventAtMs=b),"string"==typeof c.errorMessage&&(this.lastErrorMessage=c.errorMessage),this.setRuntimePhase("streaming",b)):c?.role==="user"&&this.setRuntimePhase("waiting_model",b);break}case"message_end":{let c=a.message;c?.role==="assistant"&&"string"==typeof c.errorMessage&&(this.lastErrorMessage=c.errorMessage),this.setRuntimePhase("waiting_model",b);break}case"tool_execution_start":{let c="string"==typeof a.toolCallId?a.toolCallId:"",d="string"==typeof a.toolName?a.toolName:"tool";c&&this.activeTools.set(c,d),this.setRuntimePhase("running_tools",b);break}case"tool_execution_end":{let c="string"==typeof a.toolCallId?a.toolCallId:"";c&&this.activeTools.delete(c),this.setRuntimePhase(this.activeTools.size>0?"running_tools":"waiting_model",b);break}case"auto_retry_start":this.setRuntimePhase("waiting_model",b);break;case"compaction_start":case"auto_compaction_start":this.setRuntimePhase("compacting",b);break;case"compaction_end":case"auto_compaction_end":this.setRuntimePhase(this.isBusy()?"waiting_model":"idle",b);break;case"agent_end":this.activeTools.clear(),!0===a.willRetry?this.setRuntimePhase("waiting_model",b):(this.setRuntimePhase("idle",b),this.runStartedAtMs=null,this.firstModelEventAtMs=null)}}applyRuntimePrompts(a){if(!this.inner.agent.state||this.options.systemPromptDisabled)return;let b=(0,g.cV)(),c=this.inner.getActiveToolNames(),d=(0,m.R4)(c),e=B(this.inner),f=0;if(this.sessionFile)try{f=(0,o.statSync)(this.sessionFile).mtimeMs}catch{f=0}let h=null;if(d&&this.sessionFile)if(this._kernelStateCache&&this._kernelStateCache.mtime===f)h=this._kernelStateCache.summary;else{let a=(0,w.f)(this.sessionFile);a?(h=(0,w.v)(a),this._kernelStateCache={mtime:f,summary:h}):this._kernelStateCache=null}else this._kernelStateCache=null;let i=h?`|mtime=${f}`:"",j=a??"",n=`${d}|${b.generativeUI}|${j.length>0?"msg":"no-msg"}${i}`;if(this._lastAppliedPromptKey===n&&e.length>0)return;if(!b.generativeUI){let a=(0,m.X8)((0,k.FE)(e)),b=F(a,d),c=h?`${b}
143
143
 
144
144
  ${h}`:b;C(this.inner,c),this._lastAppliedPromptKey=n;return}let p=(0,m.X8)((0,k.FE)(e)),q=(0,k.zN)(p),r=F(q,d),s=a?(0,l.WO)(r,a,{force:function(a){try{return a.getBranch().some(a=>!!a&&"object"==typeof a&&"message"===a.type&&!!a.message&&JSON.stringify(a.message).includes("show-widget"))}catch{return!1}}(this.inner.sessionManager)}):r;h&&(s=`${s}
145
145