pi-web 0.3.7 → 0.3.9

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.
@@ -13,6 +13,6 @@ Error generating stack: `+a.message+`
13
13
  transition-transform duration-200
14
14
  ${Zl?"translate-x-0":"-translate-x-full"}
15
15
  md:translate-x-0
16
- `,children:[_.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-pi-border-muted",children:[_.jsxs("h1",{className:"text-base font-semibold text-pi-accent",children:["pi-web ",_.jsxs("span",{className:"text-pi-dim font-normal text-xs",children:["v","0.3.6"]})]}),_.jsxs("div",{className:"flex items-center gap-2",children:[_.jsx("button",{onClick:Qa,title:"new session",className:"bg-pi-accent text-white p-1.5 rounded-lg hover:opacity-85 cursor-pointer",children:_.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[_.jsx("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),_.jsx("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]})}),_.jsx("button",{onClick:()=>tl(!1),className:"md:hidden text-pi-muted p-1.5 cursor-pointer",children:_.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[_.jsx("line",{x1:"3",y1:"3",x2:"13",y2:"13"}),_.jsx("line",{x1:"13",y1:"3",x2:"3",y2:"13"})]})})]})]}),_.jsx("div",{className:"flex-1 overflow-y-auto p-2",children:Gu.map(p=>_.jsx(gy,{folder:p,expanded:Pt.has(p.cwd),activeSessionFile:U,onToggle:()=>Xa(p.cwd),onNewSession:()=>{jt(x=>new Set([...x,p.cwd])),Ga(p.cwd),tl(!1)},onSelectSession:x=>{ii(x),tl(!1)},onDeleteSession:Yu},p.cwd))})]}),_.jsxs("main",{className:"flex-1 flex flex-col min-h-0",children:[_.jsxs("div",{className:"md:hidden flex items-center gap-2 px-3 py-2 border-b border-pi-border-muted bg-pi-card-bg",children:[_.jsx("button",{onClick:()=>tl(!0),className:"text-pi-muted p-1 cursor-pointer",children:_.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[_.jsx("line",{x1:"2",y1:"4",x2:"16",y2:"4"}),_.jsx("line",{x1:"2",y1:"9",x2:"16",y2:"9"}),_.jsx("line",{x1:"2",y1:"14",x2:"16",y2:"14"})]})}),_.jsx("span",{className:"text-pi-muted truncate",children:U?U.split("/").pop():"no session selected"})]}),_.jsx("div",{ref:hl,className:"flex-1 overflow-y-auto px-4 py-4 md:px-6",children:C.length===0?_.jsx("div",{className:"flex items-center justify-center h-full text-pi-muted text-base",children:"start a new session or select one from the list."}):C.filter(p=>p.role==="user"||p.parts.some(x=>(x.content??"").trim()||x.type==="toolCall")).map(p=>_.jsx(vy,{msg:p},p.id))}),_.jsxs("div",{className:"flex items-center gap-3 px-4 py-1.5 border-t border-pi-border-muted bg-pi-card-bg text-xs text-pi-muted flex-wrap",children:[_.jsxs("span",{className:"flex items-center gap-1.5",children:[_.jsx("span",{className:`inline-block w-2 h-2 rounded-full ${Ie}`}),j?"streaming":L?"connected":"disconnected"]}),Gt.length>0&&_.jsxs("span",{className:"flex items-center gap-1.5",children:[_.jsx("select",{value:Vt,onChange:p=>ul(p.target.value),disabled:j,className:"text-xs font-mono text-gray-700 bg-white border border-pi-border-muted rounded px-1 py-0.5 cursor-pointer disabled:opacity-50 max-w-[120px]",children:H.map(p=>_.jsx("option",{value:p,children:p},p))}),_.jsx("select",{value:Lt?.provider===Vt?Lt.id:"",onChange:p=>fi(p.target.value),disabled:j,className:"text-xs font-mono text-gray-700 bg-white border border-pi-border-muted rounded px-1 py-0.5 cursor-pointer disabled:opacity-50 max-w-[160px]",children:V.map(p=>_.jsx("option",{value:p.id,children:p.id},p.id))})]}),Gt.length===0&&Lt&&_.jsx("span",{children:Lt.id}),zt&&_.jsxs("span",{className:"flex items-center gap-2 text-pi-dim ml-auto flex-wrap",children:[zt.tokens.input>0&&_.jsxs("span",{children:["↑",qu(zt.tokens.input)]}),zt.tokens.output>0&&_.jsxs("span",{children:["↓",qu(zt.tokens.output)]}),zt.tokens.cacheRead>0&&_.jsxs("span",{children:["r",qu(zt.tokens.cacheRead)]}),zt.tokens.cacheWrite>0&&_.jsxs("span",{children:["w",qu(zt.tokens.cacheWrite)]}),zt.cost>0&&_.jsxs("span",{children:["$",zt.cost.toFixed(3)]}),Lt?.contextWindow&&$&&(()=>{const p=$/Lt.contextWindow*100,x=p>90?"text-pi-error":p>70?"text-pi-warning":"";return _.jsxs("span",{className:x,children:[p.toFixed(1),"%/",qu(Lt.contextWindow)]})})()]}),j&&_.jsxs("span",{children:["responding",Qt.length>0?` · ${Qt.length} queued`:""]})]}),_.jsx("div",{className:"px-4 pb-4 pt-3 md:px-6 border-t border-pi-border-muted bg-pi-card-bg",children:_.jsxs("div",{className:"flex gap-2 items-center",children:[_.jsx("textarea",{ref:Kt,rows:1,placeholder:I?"send a message...":"select a session to start",disabled:!I,value:k,onChange:p=>B(p.target.value),onKeyDown:p=>{p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),Bu())},className:"flex-1 bg-white border border-pi-border-muted rounded-lg px-3 py-2.5 text-base md:text-sm font-mono resize-none min-h-[42px] max-h-[200px] outline-none focus:border-pi-accent disabled:opacity-50 disabled:cursor-default"}),_.jsxs("div",{className:"flex flex-row gap-1 flex-shrink-0",children:[_.jsxs("button",{onClick:Bu,disabled:!L||!I,title:j?"queue message":"send",className:"relative bg-pi-accent text-white p-2 rounded-lg cursor-pointer disabled:opacity-40 disabled:cursor-default hover:opacity-85",children:[_.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[_.jsx("line",{x1:"2",y1:"9",x2:"16",y2:"9"}),_.jsx("polyline",{points:"10,3 16,9 10,15"})]}),Qt.length>0&&_.jsx("span",{className:"absolute -top-1.5 -right-1.5 bg-pi-warning text-white text-[10px] w-4 h-4 rounded-full flex items-center justify-center leading-none",children:Qt.length})]}),_.jsx("button",{onClick:ci,disabled:!j||!I,title:"stop",className:"bg-pi-error text-white p-2 rounded-lg cursor-pointer disabled:opacity-40 disabled:cursor-default hover:opacity-85",children:_.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"currentColor",children:_.jsx("rect",{x:"4",y:"4",width:"10",height:"10",rx:"1.5"})})})]})]})})]})]})}function vy({msg:h}){const O=h.role==="user";return _.jsxs("div",{className:"mb-4 min-w-0",children:[_.jsxs("div",{className:"flex items-center gap-2 mb-1 min-w-0",children:[_.jsx("span",{className:"text-[11px] font-semibold tracking-wide text-pi-muted shrink-0",children:O?"you":"assistant"}),!O&&(h.model||h.provider)&&_.jsx("span",{className:"text-[10px] text-pi-dim truncate",children:[h.provider,h.model].filter(Boolean).join(" / ")}),h.timestamp!=null&&_.jsx("span",{className:"text-[10px] text-pi-dim ml-auto shrink-0",children:Ty(h.timestamp)})]}),_.jsx("div",{className:`rounded-lg px-4 py-3 min-w-0 overflow-hidden ${O?"bg-pi-user-bg":"bg-pi-card-bg border border-pi-border-muted"}`,children:_.jsx("div",{className:"text-xs md:text-sm leading-relaxed break-words min-w-0",children:h.parts.map((U,d)=>_.jsx(Sy,{part:U},`${h.id}-${d}`))})})]})}function gy({folder:h,expanded:O,activeSessionFile:U,onToggle:d,onNewSession:C,onSelectSession:Y,onDeleteSession:L}){const yt=h.sessions.some(j=>j.file===U);return _.jsxs("div",{className:"mb-1",children:[_.jsxs("div",{className:"flex items-center gap-1 rounded-lg",children:[_.jsxs("button",{onClick:d,className:`flex-1 flex items-center gap-1.5 text-left px-2 py-1.5 rounded-lg text-xs font-semibold hover:bg-pi-user-bg cursor-pointer min-w-0 ${yt?"text-pi-accent":"text-gray-700"}`,children:[_.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:`text-pi-muted transition-transform duration-150 flex-shrink-0 ${O?"rotate-90":""}`,children:_.jsx("polyline",{points:"3,2 9,6 3,10"})}),_.jsx("span",{className:"flex-1 truncate min-w-0",children:h.label}),_.jsx("span",{className:"text-[11px] text-pi-dim font-normal flex-shrink-0",children:h.sessions.length})]}),_.jsx("button",{onClick:C,title:"new session here",className:"text-pi-muted hover:text-pi-accent hover:bg-pi-user-bg p-1.5 rounded-lg cursor-pointer flex-shrink-0",children:_.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 13 13",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[_.jsx("line",{x1:"6.5",y1:"1.5",x2:"6.5",y2:"11.5"}),_.jsx("line",{x1:"1.5",y1:"6.5",x2:"11.5",y2:"6.5"})]})})]}),O&&_.jsx("div",{className:"pl-3 mt-0.5",children:h.sessions.map(j=>{const A=j.file===U,k=j.firstPrompt||j.id.slice(0,8),B=j.timestamp?new Date(j.timestamp).toLocaleString():"";return _.jsxs("div",{onClick:()=>Y(j.file),className:`group relative px-2.5 py-2 rounded-lg cursor-pointer mb-0.5 border ${A?"border-pi-accent bg-pi-user-bg":"border-transparent hover:bg-pi-user-bg"}`,children:[_.jsx("div",{className:"text-xs truncate pr-5",children:k}),_.jsxs("div",{className:"text-[11px] text-pi-dim mt-0.5",children:[j.messageCount," msgs · ",B]}),_.jsx("button",{onClick:I=>{I.stopPropagation(),L(j.file)},title:"delete session",className:"absolute top-1/2 right-1.5 -translate-y-1/2 hidden group-hover:flex active:flex items-center justify-center w-5 h-5 rounded text-pi-muted bg-pi-user-bg hover:text-pi-error hover:bg-pi-tool-error cursor-pointer",children:_.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[_.jsx("line",{x1:"1.5",y1:"1.5",x2:"8.5",y2:"8.5"}),_.jsx("line",{x1:"8.5",y1:"1.5",x2:"1.5",y2:"8.5"})]})})]},j.file)})})]})}function Sy({part:h}){return h.type==="text"?_.jsx("div",{dangerouslySetInnerHTML:{__html:py(h.content||"")}}):h.type==="thinking"?_.jsx("div",{className:"text-pi-muted italic border-l-2 border-pi-border-muted pl-3 my-1.5 text-xs",children:h.content}):h.type==="tool"?_.jsx(by,{part:h}):null}function by({part:h}){const[O,U]=W.useState(!1),d=h.args?typeof h.args=="string"?h.args:JSON.stringify(h.args,null,2):"",C=h.content||"",Y=d||C;return _.jsxs("div",{className:"bg-pi-tool-success border border-pi-border-muted rounded-lg my-1.5 text-xs overflow-hidden",children:[_.jsxs("button",{onClick:()=>Y&&U(L=>!L),className:`w-full flex items-center gap-2 px-3 py-2 text-left ${Y?"cursor-pointer hover:brightness-95":"cursor-default"}`,children:[_.jsx("span",{className:"text-pi-success font-semibold",children:h.name}),!O&&d&&_.jsxs("span",{className:"text-pi-muted truncate flex-1",children:[d.slice(0,80),d.length>80?"…":""]}),Y&&_.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:`ml-auto text-pi-dim flex-shrink-0 transition-transform duration-150 ${O?"rotate-180":""}`,children:_.jsx("polyline",{points:"1,3 5,7 9,3"})})]}),O&&_.jsxs("div",{className:"border-t border-pi-border-muted",children:[d&&_.jsxs("div",{className:"px-3 py-2 border-b border-pi-border-muted/40",children:[_.jsx("div",{className:"text-[10px] font-semibold text-pi-muted mb-1",children:"input"}),_.jsx("pre",{className:"whitespace-pre-wrap break-all text-pi-muted font-mono",children:d})]}),C&&_.jsxs("div",{className:"px-3 py-2",children:[_.jsx("div",{className:"text-[10px] font-semibold text-pi-muted mb-1",children:"output"}),_.jsx("pre",{className:"whitespace-pre-wrap break-all text-pi-tool-output max-h-48 overflow-y-auto font-mono",children:C})]})]})]})}function py(h){const O=h.split(`
16
+ `,children:[_.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-pi-border-muted",children:[_.jsxs("h1",{className:"text-base font-semibold text-pi-accent",children:["pi-web ",_.jsxs("span",{className:"text-pi-dim font-normal text-xs",children:["v","0.3.8"]})]}),_.jsxs("div",{className:"flex items-center gap-2",children:[_.jsx("button",{onClick:Qa,title:"new session",className:"bg-pi-accent text-white p-1.5 rounded-lg hover:opacity-85 cursor-pointer",children:_.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[_.jsx("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),_.jsx("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]})}),_.jsx("button",{onClick:()=>tl(!1),className:"md:hidden text-pi-muted p-1.5 cursor-pointer",children:_.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[_.jsx("line",{x1:"3",y1:"3",x2:"13",y2:"13"}),_.jsx("line",{x1:"13",y1:"3",x2:"3",y2:"13"})]})})]})]}),_.jsx("div",{className:"flex-1 overflow-y-auto p-2",children:Gu.map(p=>_.jsx(gy,{folder:p,expanded:Pt.has(p.cwd),activeSessionFile:U,onToggle:()=>Xa(p.cwd),onNewSession:()=>{jt(x=>new Set([...x,p.cwd])),Ga(p.cwd),tl(!1)},onSelectSession:x=>{ii(x),tl(!1)},onDeleteSession:Yu},p.cwd))})]}),_.jsxs("main",{className:"flex-1 flex flex-col min-h-0",children:[_.jsxs("div",{className:"md:hidden flex items-center gap-2 px-3 py-2 border-b border-pi-border-muted bg-pi-card-bg",children:[_.jsx("button",{onClick:()=>tl(!0),className:"text-pi-muted p-1 cursor-pointer",children:_.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[_.jsx("line",{x1:"2",y1:"4",x2:"16",y2:"4"}),_.jsx("line",{x1:"2",y1:"9",x2:"16",y2:"9"}),_.jsx("line",{x1:"2",y1:"14",x2:"16",y2:"14"})]})}),_.jsx("span",{className:"text-pi-muted truncate",children:U?U.split("/").pop():"no session selected"})]}),_.jsx("div",{ref:hl,className:"flex-1 overflow-y-auto px-4 py-4 md:px-6",children:C.length===0?_.jsx("div",{className:"flex items-center justify-center h-full text-pi-muted text-base",children:"start a new session or select one from the list."}):C.filter(p=>p.role==="user"||p.parts.some(x=>(x.content??"").trim()||x.type==="toolCall")).map(p=>_.jsx(vy,{msg:p},p.id))}),_.jsxs("div",{className:"flex items-center gap-3 px-4 py-1.5 border-t border-pi-border-muted bg-pi-card-bg text-xs text-pi-muted flex-wrap",children:[_.jsxs("span",{className:"flex items-center gap-1.5",children:[_.jsx("span",{className:`inline-block w-2 h-2 rounded-full ${Ie}`}),j?"streaming":L?"connected":"disconnected"]}),Gt.length>0&&_.jsxs("span",{className:"flex items-center gap-1.5",children:[_.jsx("select",{value:Vt,onChange:p=>ul(p.target.value),disabled:j,className:"text-xs font-mono text-gray-700 bg-white border border-pi-border-muted rounded px-1 py-0.5 cursor-pointer disabled:opacity-50 max-w-[120px]",children:H.map(p=>_.jsx("option",{value:p,children:p},p))}),_.jsx("select",{value:Lt?.provider===Vt?Lt.id:"",onChange:p=>fi(p.target.value),disabled:j,className:"text-xs font-mono text-gray-700 bg-white border border-pi-border-muted rounded px-1 py-0.5 cursor-pointer disabled:opacity-50 max-w-[160px]",children:V.map(p=>_.jsx("option",{value:p.id,children:p.id},p.id))})]}),Gt.length===0&&Lt&&_.jsx("span",{children:Lt.id}),zt&&_.jsxs("span",{className:"flex items-center gap-2 text-pi-dim ml-auto flex-wrap",children:[zt.tokens.input>0&&_.jsxs("span",{children:["↑",qu(zt.tokens.input)]}),zt.tokens.output>0&&_.jsxs("span",{children:["↓",qu(zt.tokens.output)]}),zt.tokens.cacheRead>0&&_.jsxs("span",{children:["r",qu(zt.tokens.cacheRead)]}),zt.tokens.cacheWrite>0&&_.jsxs("span",{children:["w",qu(zt.tokens.cacheWrite)]}),zt.cost>0&&_.jsxs("span",{children:["$",zt.cost.toFixed(3)]}),Lt?.contextWindow&&$&&(()=>{const p=$/Lt.contextWindow*100,x=p>90?"text-pi-error":p>70?"text-pi-warning":"";return _.jsxs("span",{className:x,children:[p.toFixed(1),"%/",qu(Lt.contextWindow)]})})()]}),j&&_.jsxs("span",{children:["responding",Qt.length>0?` · ${Qt.length} queued`:""]})]}),_.jsx("div",{className:"px-4 pb-4 pt-3 md:px-6 border-t border-pi-border-muted bg-pi-card-bg",children:_.jsxs("div",{className:"flex gap-2 items-center",children:[_.jsx("textarea",{ref:Kt,rows:1,placeholder:I?"send a message...":"select a session to start",disabled:!I,value:k,onChange:p=>B(p.target.value),onKeyDown:p=>{p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),Bu())},className:"flex-1 bg-white border border-pi-border-muted rounded-lg px-3 py-2.5 text-base md:text-sm font-mono resize-none min-h-[42px] max-h-[200px] outline-none focus:border-pi-accent disabled:opacity-50 disabled:cursor-default"}),_.jsxs("div",{className:"flex flex-row gap-1 flex-shrink-0",children:[_.jsxs("button",{onClick:Bu,disabled:!L||!I,title:j?"queue message":"send",className:"relative bg-pi-accent text-white p-2 rounded-lg cursor-pointer disabled:opacity-40 disabled:cursor-default hover:opacity-85",children:[_.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[_.jsx("line",{x1:"2",y1:"9",x2:"16",y2:"9"}),_.jsx("polyline",{points:"10,3 16,9 10,15"})]}),Qt.length>0&&_.jsx("span",{className:"absolute -top-1.5 -right-1.5 bg-pi-warning text-white text-[10px] w-4 h-4 rounded-full flex items-center justify-center leading-none",children:Qt.length})]}),_.jsx("button",{onClick:ci,disabled:!j||!I,title:"stop",className:"bg-pi-error text-white p-2 rounded-lg cursor-pointer disabled:opacity-40 disabled:cursor-default hover:opacity-85",children:_.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"currentColor",children:_.jsx("rect",{x:"4",y:"4",width:"10",height:"10",rx:"1.5"})})})]})]})})]})]})}function vy({msg:h}){const O=h.role==="user";return _.jsxs("div",{className:"mb-4 min-w-0",children:[_.jsxs("div",{className:"flex items-center gap-2 mb-1 min-w-0",children:[_.jsx("span",{className:"text-[11px] font-semibold tracking-wide text-pi-muted shrink-0",children:O?"you":"assistant"}),!O&&(h.model||h.provider)&&_.jsx("span",{className:"text-[10px] text-pi-dim truncate",children:[h.provider,h.model].filter(Boolean).join(" / ")}),h.timestamp!=null&&_.jsx("span",{className:"text-[10px] text-pi-dim ml-auto shrink-0",children:Ty(h.timestamp)})]}),_.jsx("div",{className:`rounded-lg px-4 py-3 min-w-0 overflow-hidden ${O?"bg-pi-user-bg":"bg-pi-card-bg border border-pi-border-muted"}`,children:_.jsx("div",{className:"text-xs md:text-sm leading-relaxed break-words min-w-0",children:h.parts.map((U,d)=>_.jsx(Sy,{part:U},`${h.id}-${d}`))})})]})}function gy({folder:h,expanded:O,activeSessionFile:U,onToggle:d,onNewSession:C,onSelectSession:Y,onDeleteSession:L}){const yt=h.sessions.some(j=>j.file===U);return _.jsxs("div",{className:"mb-1",children:[_.jsxs("div",{className:"flex items-center gap-1 rounded-lg",children:[_.jsxs("button",{onClick:d,className:`flex-1 flex items-center gap-1.5 text-left px-2 py-1.5 rounded-lg text-xs font-semibold hover:bg-pi-user-bg cursor-pointer min-w-0 ${yt?"text-pi-accent":"text-gray-700"}`,children:[_.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:`text-pi-muted transition-transform duration-150 flex-shrink-0 ${O?"rotate-90":""}`,children:_.jsx("polyline",{points:"3,2 9,6 3,10"})}),_.jsx("span",{className:"flex-1 truncate min-w-0",children:h.label}),_.jsx("span",{className:"text-[11px] text-pi-dim font-normal flex-shrink-0",children:h.sessions.length})]}),_.jsx("button",{onClick:C,title:"new session here",className:"text-pi-muted hover:text-pi-accent hover:bg-pi-user-bg p-1.5 rounded-lg cursor-pointer flex-shrink-0",children:_.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 13 13",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[_.jsx("line",{x1:"6.5",y1:"1.5",x2:"6.5",y2:"11.5"}),_.jsx("line",{x1:"1.5",y1:"6.5",x2:"11.5",y2:"6.5"})]})})]}),O&&_.jsx("div",{className:"pl-3 mt-0.5",children:h.sessions.map(j=>{const A=j.file===U,k=j.firstPrompt||j.id.slice(0,8),B=j.timestamp?new Date(j.timestamp).toLocaleString():"";return _.jsxs("div",{onClick:()=>Y(j.file),className:`group relative px-2.5 py-2 rounded-lg cursor-pointer mb-0.5 border ${A?"border-pi-accent bg-pi-user-bg":"border-transparent hover:bg-pi-user-bg"}`,children:[_.jsx("div",{className:"text-xs truncate pr-5",children:k}),_.jsxs("div",{className:"text-[11px] text-pi-dim mt-0.5",children:[j.messageCount," msgs · ",B]}),_.jsx("button",{onClick:I=>{I.stopPropagation(),L(j.file)},title:"delete session",className:"absolute top-1/2 right-1.5 -translate-y-1/2 hidden group-hover:flex active:flex items-center justify-center w-5 h-5 rounded text-pi-muted bg-pi-user-bg hover:text-pi-error hover:bg-pi-tool-error cursor-pointer",children:_.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[_.jsx("line",{x1:"1.5",y1:"1.5",x2:"8.5",y2:"8.5"}),_.jsx("line",{x1:"8.5",y1:"1.5",x2:"1.5",y2:"8.5"})]})})]},j.file)})})]})}function Sy({part:h}){return h.type==="text"?_.jsx("div",{dangerouslySetInnerHTML:{__html:py(h.content||"")}}):h.type==="thinking"?_.jsx("div",{className:"text-pi-muted italic border-l-2 border-pi-border-muted pl-3 my-1.5 text-xs",children:h.content}):h.type==="tool"?_.jsx(by,{part:h}):null}function by({part:h}){const[O,U]=W.useState(!1),d=h.args?typeof h.args=="string"?h.args:JSON.stringify(h.args,null,2):"",C=h.content||"",Y=d||C;return _.jsxs("div",{className:"bg-pi-tool-success border border-pi-border-muted rounded-lg my-1.5 text-xs overflow-hidden",children:[_.jsxs("button",{onClick:()=>Y&&U(L=>!L),className:`w-full flex items-center gap-2 px-3 py-2 text-left ${Y?"cursor-pointer hover:brightness-95":"cursor-default"}`,children:[_.jsx("span",{className:"text-pi-success font-semibold",children:h.name}),!O&&d&&_.jsxs("span",{className:"text-pi-muted truncate flex-1",children:[d.slice(0,80),d.length>80?"…":""]}),Y&&_.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:`ml-auto text-pi-dim flex-shrink-0 transition-transform duration-150 ${O?"rotate-180":""}`,children:_.jsx("polyline",{points:"1,3 5,7 9,3"})})]}),O&&_.jsxs("div",{className:"border-t border-pi-border-muted",children:[d&&_.jsxs("div",{className:"px-3 py-2 border-b border-pi-border-muted/40",children:[_.jsx("div",{className:"text-[10px] font-semibold text-pi-muted mb-1",children:"input"}),_.jsx("pre",{className:"whitespace-pre-wrap break-all text-pi-muted font-mono",children:d})]}),C&&_.jsxs("div",{className:"px-3 py-2",children:[_.jsx("div",{className:"text-[10px] font-semibold text-pi-muted mb-1",children:"output"}),_.jsx("pre",{className:"whitespace-pre-wrap break-all text-pi-tool-output max-h-48 overflow-y-auto font-mono",children:C})]})]})]})}function py(h){const O=h.split(`
17
17
  `),U=[];let d=0;for(;d<O.length;){const C=O[d];if(/^```/.test(C)){const L=C.slice(3).trim(),yt=[];for(d++;d<O.length&&!/^```/.test(O[d]);)yt.push(Of(O[d])),d++;U.push(`<pre class="bg-pi-page-bg border border-pi-border-muted rounded-lg p-3 overflow-x-auto my-2 text-xs font-mono text-pi-md-code-block"><code${L?` class="language-${Of(L)}"`:""}>${yt.join(`
18
18
  `)}</code></pre>`),d++;continue}if(/^\|/.test(C)&&d+1<O.length&&/^\|[\s\-:|]+\|/.test(O[d+1])){const L=Br(O[d]),yt=zy(O[d+1]);d+=2;const j=[];for(;d<O.length&&/^\|/.test(O[d]);)j.push(Br(O[d])),d++;const A=L.map((B,I)=>`<th class="border border-pi-border-muted px-3 py-1.5 bg-pi-page-bg font-semibold text-left" style="${Yr(yt[I])}">${ni(B)}</th>`).join(""),k=j.map(B=>`<tr>${B.map((I,Mt)=>`<td class="border border-pi-border-muted px-3 py-1.5" style="${Yr(yt[Mt])}">${ni(I)}</td>`).join("")}</tr>`).join("");U.push(`<div class="overflow-x-auto my-2"><table class="border-collapse text-xs w-full"><thead><tr>${A}</tr></thead><tbody>${k}</tbody></table></div>`);continue}const Y=C.match(/^(#{1,6})\s+(.*)/);if(Y){const L=Y[1].length,yt=["text-lg","text-base","text-sm","text-sm","text-xs","text-xs"];U.push(`<h${L} class="font-semibold ${yt[L-1]} mt-3 mb-1 text-pi-md-heading">${ni(Y[2])}</h${L}>`),d++;continue}if(/^(-{3,}|\*{3,}|_{3,})$/.test(C.trim())){U.push('<hr class="border-t border-pi-border-muted my-3">'),d++;continue}if(C.trim()===""){U.push("<br>"),d++;continue}U.push(`<span>${ni(C)}</span><br>`),d++}return U.join("")}function Br(h){return h.replace(/^\||\|$/g,"").split("|").map(O=>O.trim())}function zy(h){return h.replace(/^\||\|$/g,"").split("|").map(O=>(O=O.trim(),O.startsWith(":")&&O.endsWith(":")?"center":O.endsWith(":")?"right":"left"))}function Yr(h){return`text-align:${h}`}function ni(h){let O=Of(h);return O=O.replace(/`([^`]+)`/g,'<code class="bg-pi-page-bg text-pi-md-code px-1 py-0.5 rounded text-xs font-mono">$1</code>'),O=O.replace(/\*\*\*([^*]+)\*\*\*/g,"<strong><em>$1</em></strong>"),O=O.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),O=O.replace(/\*([^*\n]+)\*/g,"<em>$1</em>"),O=O.replace(/~~([^~]+)~~/g,"<del class='opacity-60'>$1</del>"),O=O.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" target="_blank" rel="noopener" class="text-pi-md-link underline">$1</a>'),O}function Of(h){return h.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Ty(h){return new Date(h).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}function xy(h){if(!h)return 0;if(typeof h.totalTokens=="number"&&Number.isFinite(h.totalTokens))return h.totalTokens;const O=typeof h.input=="number"&&Number.isFinite(h.input)?h.input:0,U=typeof h.output=="number"&&Number.isFinite(h.output)?h.output:0,d=typeof h.cacheRead=="number"&&Number.isFinite(h.cacheRead)?h.cacheRead:0,C=typeof h.cacheWrite=="number"&&Number.isFinite(h.cacheWrite)?h.cacheWrite:0;return O+U+d+C}function Gr(h){let O=0;for(const U of h.parts){if(U.type==="text"||U.type==="thinking"){O+=(U.content??"").length;continue}if(U.type==="tool"&&(O+=(U.name??"").length,O+=(U.content??"").length,U.args!=null))try{O+=JSON.stringify(U.args).length}catch{}}return Math.ceil(O/4)}function Ey(h){for(let U=h.length-1;U>=0;U--){const d=h[U];if(d.role!=="assistant")continue;const C=xy(d.usage);if(C<=0)continue;let Y=0;for(let L=U+1;L<h.length;L++)Y+=Gr(h[L]);return C+Y}const O=h.reduce((U,d)=>U+Gr(d),0);return O>0?O:null}function qu(h){return h<1e3?String(h):h<1e4?`${(h/1e3).toFixed(1)}k`:h<1e6?`${Math.round(h/1e3)}k`:h<1e7?`${(h/1e6).toFixed(1)}m`:`${Math.round(h/1e6)}m`}dy.createRoot(document.getElementById("root")).render(_.jsx(ay.StrictMode,{children:_.jsx(hy,{})}));
package/dist/index.html CHANGED
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>pi-web</title>
7
- <script type="module" crossorigin src="/assets/index-H1kje-sZ.js"></script>
7
+ <script type="module" crossorigin src="/assets/index-DJ5XZ9sy.js"></script>
8
8
  <link rel="stylesheet" crossorigin href="/assets/index-CnPPbq9y.css">
9
9
  </head>
10
10
  <body>
package/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "name": "pi-web",
3
- "version": "0.3.7",
3
+ "version": "0.3.9",
4
4
  "type": "module",
5
+ "engines": {
6
+ "node": "^24"
7
+ },
5
8
  "description": "Web UI for the pi coding agent",
6
9
  "repository": {
7
10
  "type": "git",