shraga 0.1.19 → 0.1.20
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.
- package/defaults/skills/platform.md +1 -1
- package/dist/client/assets/{index-D5KxKl57.js → index-Dhv0RZ8g.js} +1 -1
- package/dist/client/index.html +1 -1
- package/package.json +1 -1
- package/src/client/components/ConfigPanel.tsx +2 -1
- package/src/server/engine/claude-code.ts +2 -1
- package/src/server/model-aliases.ts +2 -1
|
@@ -30,7 +30,7 @@ Users can prefix any message with `[directives]` to override settings. Parsed se
|
|
|
30
30
|
|
|
31
31
|
| Position | What | Examples |
|
|
32
32
|
|----------|------|----------|
|
|
33
|
-
| 1st | Model alias | `fable`, `opus`, `sonnet`, `haiku`, `fable-5`, `opus-4-8`, `opus-4-7` |
|
|
33
|
+
| 1st | Model alias | `fable`, `opus`, `sonnet`, `haiku`, `fable-5`, `opus-5`, `opus-4-8`, `opus-4-7` |
|
|
34
34
|
| 2nd | Max turns (integer) | `5`, `20`, `100` |
|
|
35
35
|
|
|
36
36
|
### Named directives
|
|
@@ -1942,5 +1942,5 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1942
1942
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function F0e(e,t){if(e){if(typeof e=="string")return MR(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?MR(e,t):void 0}}function MR(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function H0e(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,a,l,c=[],u=!0,f=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(u=(r=a.call(n)).done)&&(c.push(r.value),c.length!==t);u=!0);}catch(h){f=!0,i=h}finally{try{if(!u&&n.return!=null&&(l=n.return(),Object(l)!==l))return}finally{if(f)throw i}}return c}}function K0e(e){if(Array.isArray(e))return e}var q0e=()=>(Bde(),null);function hg(e){if(typeof e=="number")return e;if(typeof e=="string"){var t=parseFloat(e);if(!Number.isNaN(t))return t}return 0}var G0e=b.forwardRef((e,t)=>{var n,r,i=b.useRef(null),a=b.useState({containerWidth:hg((n=e.style)===null||n===void 0?void 0:n.width),containerHeight:hg((r=e.style)===null||r===void 0?void 0:r.height)}),l=dg(a,2),c=l[0],u=l[1],f=b.useCallback((p,g)=>{u(v=>{var w=Math.round(p),y=Math.round(g);return v.containerWidth===w&&v.containerHeight===y?v:{containerWidth:w,containerHeight:y}})},[]),h=b.useCallback(p=>{if(typeof t=="function"&&t(p),i.current!=null&&(i.current.disconnect(),i.current=null),p!=null&&typeof ResizeObserver<"u"){var g=p.getBoundingClientRect(),v=g.width,w=g.height;f(v,w);var y=A=>{var O=A[0];if(O!=null){var k=O.contentRect,T=k.width,C=k.height;f(T,C)}},S=new ResizeObserver(y);S.observe(p),i.current=S}},[t,f]);return b.useEffect(()=>()=>{var p=i.current;p!=null&&p.disconnect()},[f]),b.createElement(b.Fragment,null,b.createElement(Nd,{width:c.containerWidth,height:c.containerHeight}),b.createElement("div",Jo({ref:h},e)))}),V0e=b.forwardRef((e,t)=>{var n=e.width,r=e.height,i=b.useState({containerWidth:hg(n),containerHeight:hg(r)}),a=dg(i,2),l=a[0],c=a[1],u=b.useCallback((h,p)=>{c(g=>{var v=Math.round(h),w=Math.round(p);return g.containerWidth===v&&g.containerHeight===w?g:{containerWidth:v,containerHeight:w}})},[]),f=b.useCallback(h=>{if(typeof t=="function"&&t(h),h!=null){var p=h.getBoundingClientRect(),g=p.width,v=p.height;u(g,v)}},[t,u]);return b.createElement(b.Fragment,null,b.createElement(Nd,{width:l.containerWidth,height:l.containerHeight}),b.createElement("div",Jo({ref:f},e)))}),W0e=b.forwardRef((e,t)=>{var n=e.width,r=e.height;return b.createElement(b.Fragment,null,b.createElement(Nd,{width:n,height:r}),b.createElement("div",Jo({ref:t},e)))}),Y0e=b.forwardRef((e,t)=>{var n=e.width,r=e.height;return typeof n=="string"||typeof r=="string"?b.createElement(V0e,Jo({},e,{ref:t})):typeof n=="number"&&typeof r=="number"?b.createElement(W0e,Jo({},e,{width:n,height:r,ref:t})):b.createElement(b.Fragment,null,b.createElement(Nd,{width:n,height:r}),b.createElement("div",Jo({ref:t},e)))});function X0e(e){return e?G0e:Y0e}var Z0e=b.forwardRef((e,t)=>{var n=e.children,r=e.className,i=e.height,a=e.onClick,l=e.onContextMenu,c=e.onDoubleClick,u=e.onMouseDown,f=e.onMouseEnter,h=e.onMouseLeave,p=e.onMouseMove,g=e.onMouseUp,v=e.onTouchEnd,w=e.onTouchMove,y=e.onTouchStart,S=e.style,A=e.width,O=e.responsive,k=e.dispatchTouchEvents,T=k===void 0?!0:k,C=b.useRef(null),N=Pt(),D=b.useState(null),B=dg(D,2),P=B[0],M=B[1],z=b.useState(null),R=dg(z,2),H=R[0],Y=R[1],q=j0e(),U=D1(),G=(U==null?void 0:U.width)>0?U.width:A,K=(U==null?void 0:U.height)>0?U.height:i,ee=b.useCallback(Oe=>{q(Oe),typeof t=="function"&&t(Oe),M(Oe),Y(Oe),Oe!=null&&(C.current=Oe)},[q,t,M,Y]),j=b.useCallback(Oe=>{N(D5(Oe)),N(ui({handler:a,reactEvent:Oe}))},[N,a]),F=b.useCallback(Oe=>{N(pw(Oe)),N(ui({handler:f,reactEvent:Oe}))},[N,f]),J=b.useCallback(Oe=>{N(fB()),N(ui({handler:h,reactEvent:Oe}))},[N,h]),$=b.useCallback(Oe=>{N(pw(Oe)),N(ui({handler:p,reactEvent:Oe}))},[N,p]),de=b.useCallback(()=>{N(U5())},[N]),xe=b.useCallback(()=>{N($5())},[N]),ve=b.useCallback(Oe=>{N(B5(Oe.key))},[N]),De=b.useCallback(Oe=>{N(ui({handler:l,reactEvent:Oe}))},[N,l]),Ze=b.useCallback(Oe=>{N(ui({handler:c,reactEvent:Oe}))},[N,c]),fe=b.useCallback(Oe=>{N(ui({handler:u,reactEvent:Oe}))},[N,u]),Te=b.useCallback(Oe=>{N(ui({handler:g,reactEvent:Oe}))},[N,g]),we=b.useCallback(Oe=>{N(ui({handler:y,reactEvent:Oe}))},[N,y]),ue=b.useCallback(Oe=>{T&&N(K5(Oe)),N(ui({handler:w,reactEvent:Oe}))},[N,T,w]),Et=b.useCallback(Oe=>{N(ui({handler:v,reactEvent:Oe}))},[N,v]),Ge=X0e(O);return b.createElement(RB.Provider,{value:P},b.createElement(Pj.Provider,{value:H},b.createElement(Ge,{width:G??(S==null?void 0:S.width),height:K??(S==null?void 0:S.height),className:gt("recharts-wrapper",r),style:L0e({position:"relative",cursor:"default",width:G,height:K},S),onClick:j,onContextMenu:De,onDoubleClick:Ze,onFocus:de,onBlur:xe,onKeyDown:ve,onMouseDown:fe,onMouseEnter:F,onMouseLeave:J,onMouseMove:$,onMouseUp:Te,onTouchEnd:Et,onTouchMove:ue,onTouchStart:we,ref:ee},b.createElement(q0e,null),n)))}),Q0e=["width","height","responsive","children","className","style","compact","title","desc"];function J0e(e,t){if(e==null)return{};var n,r,i=exe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function exe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var Z5=b.forwardRef((e,t)=>{var n=e.width,r=e.height,i=e.responsive,a=e.children,l=e.className,c=e.style,u=e.compact,f=e.title,h=e.desc,p=J0e(e,Q0e),g=Wr(p);return u?b.createElement(b.Fragment,null,b.createElement(Nd,{width:n,height:r}),b.createElement(NR,{otherAttributes:g,title:f,desc:h},a)):b.createElement(Z0e,{className:l,style:c,width:n,height:r,responsive:i??!1,onClick:e.onClick,onMouseLeave:e.onMouseLeave,onMouseEnter:e.onMouseEnter,onMouseMove:e.onMouseMove,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onContextMenu:e.onContextMenu,onDoubleClick:e.onDoubleClick,onTouchStart:e.onTouchStart,onTouchMove:e.onTouchMove,onTouchEnd:e.onTouchEnd},b.createElement(NR,{otherAttributes:g,title:f,desc:h,ref:t},b.createElement(Vge,null,a)))});function mw(){return mw=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},mw.apply(null,arguments)}function RR(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function txe(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?RR(Object(n),!0).forEach(function(r){nxe(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):RR(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function nxe(e,t,n){return(t=rxe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function rxe(e){var t=ixe(e,"string");return typeof t=="symbol"?t:t+""}function ixe(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var axe={top:5,right:5,bottom:5,left:5},oxe=txe({accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:axe,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},AS),Q5=b.forwardRef(function(t,n){var r,i=Rn(t.categoricalChartProps,oxe),a=t.chartName,l=t.defaultTooltipEventType,c=t.validateTooltipEventTypes,u=t.tooltipPayloadSearcher,f=t.categoricalChartProps,h={chartName:a,defaultTooltipEventType:l,validateTooltipEventTypes:c,tooltipPayloadSearcher:u,eventEmitter:void 0};return b.createElement(V5,{preloadedState:{options:h},reduxStoreName:(r=f.id)!==null&&r!==void 0?r:a},b.createElement(d5,{chartData:f.data}),b.createElement(W5,{layout:i.layout,margin:i.margin}),b.createElement(X5,{throttleDelay:i.throttleDelay,throttledEvents:i.throttledEvents}),b.createElement(Y5,{baseValue:i.baseValue,accessibilityLayer:i.accessibilityLayer,barCategoryGap:i.barCategoryGap,maxBarSize:i.maxBarSize,stackOffset:i.stackOffset,barGap:i.barGap,barSize:i.barSize,syncId:i.syncId,syncMethod:i.syncMethod,className:i.className,reverseStackOrder:i.reverseStackOrder}),b.createElement(Z5,mw({},i,{ref:n})))}),lxe=["axis"],sxe=b.forwardRef((e,t)=>b.createElement(Q5,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:lxe,tooltipPayloadSearcher:XE,categoricalChartProps:e,ref:t})),cxe=["axis","item"],uxe=b.forwardRef((e,t)=>b.createElement(Q5,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:cxe,tooltipPayloadSearcher:XE,categoricalChartProps:e,ref:t}));function fxe(e){var t=Pt();return b.useEffect(()=>{t(m0e(e))},[t,e]),null}var dxe=["layout"];function gw(){return gw=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},gw.apply(null,arguments)}function hxe(e,t){if(e==null)return{};var n,r,i=pxe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function pxe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function DR(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function mxe(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?DR(Object(n),!0).forEach(function(r){gxe(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):DR(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function gxe(e,t,n){return(t=vxe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function vxe(e){var t=yxe(e,"string");return typeof t=="symbol"?t:t+""}function yxe(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var bxe={top:5,right:5,bottom:5,left:5},J5=mxe({accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:bxe,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},AS),xxe=b.forwardRef(function(t,n){var r,i=Rn(t.categoricalChartProps,J5),a=i.layout,l=hxe(i,dxe),c=t.chartName,u=t.defaultTooltipEventType,f=t.validateTooltipEventTypes,h=t.tooltipPayloadSearcher,p={chartName:c,defaultTooltipEventType:u,validateTooltipEventTypes:f,tooltipPayloadSearcher:h,eventEmitter:void 0};return b.createElement(V5,{preloadedState:{options:p},reduxStoreName:(r=i.id)!==null&&r!==void 0?r:c},b.createElement(d5,{chartData:i.data}),b.createElement(W5,{layout:a,margin:i.margin}),b.createElement(X5,{throttleDelay:i.throttleDelay,throttledEvents:i.throttledEvents}),b.createElement(Y5,{baseValue:void 0,accessibilityLayer:i.accessibilityLayer,barCategoryGap:i.barCategoryGap,maxBarSize:i.maxBarSize,stackOffset:i.stackOffset,barGap:i.barGap,barSize:i.barSize,syncId:i.syncId,syncMethod:i.syncMethod,className:i.className,reverseStackOrder:i.reverseStackOrder}),b.createElement(fxe,{cx:i.cx,cy:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius}),b.createElement(Z5,gw({},l,{ref:n})))});function PR(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function jR(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?PR(Object(n),!0).forEach(function(r){wxe(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):PR(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function wxe(e,t,n){return(t=Exe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Exe(e){var t=Sxe(e,"string");return typeof t=="symbol"?t:t+""}function Sxe(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var _xe=["item"],Axe=jR(jR({},J5),{},{layout:"centric",startAngle:0,endAngle:360}),kxe=b.forwardRef((e,t)=>{var n=Rn(e,Axe);return b.createElement(xxe,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:_xe,tooltipPayloadSearcher:XE,categoricalChartProps:n,ref:t})});const wc=["#6366f1","#f59e0b","#10b981","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function Oxe(e){const t=e.trim();if(!t.startsWith("{")&&!t.startsWith("["))return null;try{return JSON.parse(t)}catch{return null}}function Txe(e){var l;const t=((l=e.data)==null?void 0:l.values)??e.values??e.series;if(!t||typeof t!="object")return null;const n=t,r=Object.keys(n);if(r.length===0)return null;const i=n[r[0]];return!i||typeof i!="object"?null:Object.keys(i).map(c=>{var f;const u={label:c};for(const h of r)u[h]=((f=n[h])==null?void 0:f[c])??0;return u})}function Nxe(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e;return"file"in t&&"sizeBytes"in t}function Cxe(e){if(Nxe(e))return null;if(Array.isArray(e))return e.length===0?null:typeof e[0]=="object"&&e[0]!==null?e:null;if(typeof e=="object"&&e!==null){const t=Txe(e);if(t)return t}return null}function Ixe(e,t,n){return n.length===0?"table":n.length===1&&e.length<=8?"pie":e.map(a=>String(a[t]??"")).some(a=>/^\d{4}-\d{2}/.test(a))||e.length>20?"line":"bar"}function Mxe(e){const t=[...new Set(e.flatMap(Object.keys))],n=[];let r="";for(const i of t){const a=e.map(c=>c[i]).filter(c=>c!=null);a.filter(c=>typeof c=="number").length>a.length*.5?n.push(i):r||(r=i)}return r||(r=t[0]??"label"),{labelKey:r,numericKeys:n}}function Rxe({data:e}){const{rows:t,labelKey:n,numericKeys:r,chartType:i}=b.useMemo(()=>{const a=Cxe(e);if(!a||a.length===0)return{rows:null,labelKey:"",numericKeys:[],chartType:"table"};const{labelKey:l,numericKeys:c}=Mxe(a),u=Ixe(a,l,c);return{rows:a,labelKey:l,numericKeys:c,chartType:u}},[e]);return t?i==="table"?E.jsx(LR,{rows:t}):E.jsxs("div",{className:"space-y-2",children:[E.jsx("div",{className:"h-64 w-full",children:E.jsx(Kre,{width:"100%",height:"100%",children:i==="pie"?E.jsxs(kxe,{children:[E.jsx(c5,{data:t,dataKey:r[0],nameKey:n,cx:"50%",cy:"50%",outerRadius:80,label:!0,children:t.map((a,l)=>E.jsx(qd,{fill:wc[l%wc.length]},l))}),E.jsx(j0,{}),E.jsx(em,{})]}):i==="line"?E.jsxs(sxe,{data:t,children:[E.jsx(aw,{strokeDasharray:"3 3",className:"opacity-30"}),E.jsx(uw,{dataKey:n,tick:{fontSize:11}}),E.jsx(hw,{tick:{fontSize:11}}),E.jsx(j0,{}),r.length>1&&E.jsx(em,{}),r.map((a,l)=>E.jsx(O5,{type:"monotone",dataKey:a,stroke:wc[l%wc.length],strokeWidth:2,dot:!1},a))]}):E.jsxs(uxe,{data:t,children:[E.jsx(aw,{strokeDasharray:"3 3",className:"opacity-30"}),E.jsx(uw,{dataKey:n,tick:{fontSize:11}}),E.jsx(hw,{tick:{fontSize:11}}),E.jsx(j0,{}),r.length>1&&E.jsx(em,{}),r.map((a,l)=>E.jsx(M5,{dataKey:a,fill:wc[l%wc.length],radius:[3,3,0,0]},a))]})})}),E.jsx(LR,{rows:t})]}):E.jsx("pre",{className:"text-xs whitespace-pre-wrap break-words",children:JSON.stringify(e,null,2)})}function LR({rows:e}){const t=[...new Set(e.flatMap(Object.keys))];return E.jsx("div",{className:"overflow-auto max-h-96 rounded border text-xs",children:E.jsxs("table",{className:"w-full text-left",children:[E.jsx("thead",{className:"bg-muted sticky top-0",children:E.jsx("tr",{children:t.map(n=>E.jsx("th",{className:"px-2 py-1 font-medium",children:n},n))})}),E.jsx("tbody",{children:e.map((n,r)=>E.jsx("tr",{className:"border-t",children:t.map(i=>{const a=n[i],l=a==null?"":typeof a=="object"?JSON.stringify(a,null,2):String(a);return E.jsx("td",{className:"px-2 py-1 max-w-[400px] whitespace-pre-wrap break-words align-top",title:l,children:l},i)})},r))})]})})}const vw=/^\/uploads\//;function kS({src:e,alt:t,className:n,onClick:r}){const{getToken:i}=Rw(),[a,l]=b.useState(vw.test(e)?null:e);return b.useEffect(()=>{if(!vw.test(e)){l(e);return}let c=null,u=!1;return l(null),(async()=>{try{const f=await i(),h=await fetch(e,{headers:f?{Authorization:`Bearer ${f}`}:{}});if(!h.ok)throw new Error(`${h.status} ${h.statusText}`);c=URL.createObjectURL(await h.blob()),u?URL.revokeObjectURL(c):l(c)}catch(f){console.error("[authed-image] load failed:",e,f)}})(),()=>{u=!0,c&&URL.revokeObjectURL(c)}},[e,i]),a?E.jsx("img",{src:a,alt:t??"",className:n,onClick:()=>r==null?void 0:r(a)}):E.jsx("div",{className:n,"aria-busy":"true"})}function Dxe({src:e,name:t,className:n}){const{getToken:r}=Rw(),i=async a=>{if(vw.test(e)){a.preventDefault();try{const l=await r(),c=await fetch(e,{headers:l?{Authorization:`Bearer ${l}`}:{}});if(!c.ok)throw new Error(`${c.status} ${c.statusText}`);const u=URL.createObjectURL(await c.blob()),f=document.createElement("a");f.href=u,f.download=t,f.click(),setTimeout(()=>URL.revokeObjectURL(u),1e4)}catch(l){console.error("[authed-file] open failed:",e,l)}}};return E.jsxs("a",{href:e,onClick:i,target:"_blank",rel:"noopener noreferrer",className:n,children:[E.jsx(jw,{className:"w-4 h-4 shrink-0"}),E.jsx("span",{className:"truncate max-w-[200px]",children:t})]})}const yw=1,e4=10,Df={scale:1,tx:0,ty:0},zR=e=>Math.min(e4,Math.max(yw,e));function Pxe({src:e,alt:t=""}){const n=b.useRef(null),r=b.useRef(null),[i,a]=b.useState(Df),[l,c]=b.useState(!1),u=(A,O)=>{var T;const k=(T=n.current)==null?void 0:T.getBoundingClientRect();return k?{cx:A-k.left-k.width/2,cy:O-k.top-k.height/2}:{cx:0,cy:0}},f=b.useCallback((A,O,k)=>{a(T=>{const C=zR(A);if(C===T.scale)return T;if(C<=yw)return Df;const N=C/T.scale;return{scale:C,tx:O-N*(O-T.tx),ty:k-N*(k-T.ty)}})},[]),h=A=>{A.preventDefault();const{cx:O,cy:k}=u(A.clientX,A.clientY),T=A.deltaY<0?1.15:1/1.15;a(C=>{const N=zR(C.scale*T);if(N===C.scale)return C;if(N<=yw)return Df;const D=N/C.scale;return{scale:N,tx:O-D*(O-C.tx),ty:k-D*(k-C.ty)}})},p=A=>{i.scale<=1||(A.currentTarget.setPointerCapture(A.pointerId),r.current={x:A.clientX,y:A.clientY,tx:i.tx,ty:i.ty},c(!0))},g=A=>{const O=r.current;O&&a(k=>({...k,tx:O.tx+(A.clientX-O.x),ty:O.ty+(A.clientY-O.y)}))},v=()=>{r.current=null,c(!1)},w=A=>{const{cx:O,cy:k}=u(A.clientX,A.clientY);i.scale>1?a(Df):f(2.5,O,k)},y=A=>f(i.scale*A,0,0),S=i.scale>1;return E.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[E.jsx("div",{ref:n,className:"w-full h-full overflow-hidden flex items-center justify-center",onWheel:h,onPointerDown:p,onPointerMove:g,onPointerUp:v,onPointerCancel:v,onDoubleClick:w,style:{cursor:S?l?"grabbing":"grab":"zoom-in",touchAction:"none"},children:E.jsx("img",{src:e,alt:t,draggable:!1,className:"max-w-full max-h-[85vh] object-contain rounded-lg select-none",style:{transform:`translate(${i.tx}px, ${i.ty}px) scale(${i.scale})`,transition:l?"none":"transform 0.08s ease-out",transformOrigin:"center center"}})}),E.jsxs("div",{className:"absolute bottom-3 left-1/2 -translate-x-1/2 flex items-center gap-1 rounded-full bg-background/90 border shadow-sm px-1.5 py-1 backdrop-blur",children:[E.jsx("button",{type:"button",onClick:()=>y(1/1.4),title:"Zoom out",className:"p-1.5 rounded-full hover:bg-muted transition-colors disabled:opacity-40",disabled:!S,children:E.jsx(LH,{className:"w-4 h-4"})}),E.jsxs("span",{className:"text-xs tabular-nums w-11 text-center text-muted-foreground select-none",children:[Math.round(i.scale*100),"%"]}),E.jsx("button",{type:"button",onClick:()=>y(1.4),title:"Zoom in",className:"p-1.5 rounded-full hover:bg-muted transition-colors disabled:opacity-40",disabled:i.scale>=e4,children:E.jsx(jH,{className:"w-4 h-4"})}),E.jsx("button",{type:"button",onClick:()=>a(Df),title:"Reset",className:"p-1.5 rounded-full hover:bg-muted transition-colors disabled:opacity-40",disabled:!S,children:E.jsx(Lw,{className:"w-4 h-4"})})]})]})}const jxe=new Set(["p","li","h1","h2","h3","h4","h5","h6","blockquote","td","th"]),Lxe=()=>e=>{const t=n=>{for(const r of n.children??[])r.type==="element"&&(jxe.has(r.tagName)&&(r.properties??(r.properties={}),r.properties.dir="auto"),t(r))};t(e)};var r2,i2;const zxe=typeof window<"u"&&!!((i2=(r2=window.webkit)==null?void 0:r2.messageHandlers)!=null&&i2.appwrap);function Bxe({text:e,onImageClick:t}){const n=e.replace(/\[Image #\d+\]\s*/g,"").trim();return zxe?E.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert break-words min-w-0 whitespace-pre-wrap",children:n}):E.jsx(dP,{remarkPlugins:[jP],rehypePlugins:[ij,Lxe],className:"prose prose-sm max-w-none dark:prose-invert prose-pre:bg-muted prose-pre:border prose-code:before:content-none prose-code:after:content-none break-words min-w-0",components:{pre:({children:r,...i})=>E.jsx(ewe,{...i,children:r}),a:({href:r,children:i})=>E.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:i}),img:({src:r,alt:i})=>E.jsx(kS,{src:r??"",alt:i??"",className:"max-h-[80vh] max-w-full rounded-xl border object-contain cursor-pointer hover:opacity-80 transition-opacity",onClick:a=>t==null?void 0:t(a)})},children:n})}function BR(e){const t=new Date(e),n=new Date,r=t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});if(t.toDateString()===n.toDateString())return r;const i=t.getFullYear()===n.getFullYear();return`${t.toLocaleDateString([],{month:"short",day:"numeric",...!i&&{year:"numeric"}})}, ${r}`}const UR="shraga:showDetails";function Uxe({messages:e,busy:t,connectionStatus:n,onPermissionRespond:r,onQuestionRespond:i,onReplay:a,onEdit:l,onFork:c,multiParticipant:u,statusItems:f}){var C;const h=sa(),p=b.useRef(null),g=b.useRef(null),v=b.useRef(!0),[w,y]=b.useState(()=>localStorage.getItem(UR)==="true"),[S,A]=b.useState(null),O=()=>{const N=g.current;N&&(v.current=N.scrollHeight-N.scrollTop-N.clientHeight<80)},k=b.useMemo(()=>Vxe(e),[e]);if(b.useEffect(()=>{var N;v.current&&((N=p.current)==null||N.scrollIntoView({behavior:"smooth"}))},[e,t]),e.length===0&&!t)return E.jsx("div",{className:"flex-1 flex items-center justify-center",children:E.jsxs("div",{className:"text-center space-y-3 max-w-md px-4",children:[E.jsx("div",{className:"mx-auto w-12 h-12 rounded-full bg-muted flex items-center justify-center",children:E.jsx(Dc,{className:"w-6 h-6 text-muted-foreground"})}),E.jsx("h2",{className:"text-lg font-medium",children:"How can I help?"}),E.jsx("p",{className:"text-sm text-muted-foreground",children:"I can read files, edit code, run commands, search the web, and use any configured MCP tools on the remote machine."})]})});const T=()=>{y(N=>(localStorage.setItem(UR,String(!N)),!N))};return E.jsxs("div",{ref:g,onScroll:O,className:"flex-1 overflow-y-auto overflow-x-hidden",children:[E.jsxs("div",{className:"max-w-3xl mx-auto px-2 sm:px-4 py-4 sm:py-6 space-y-1",children:[E.jsx("div",{className:"flex justify-end mb-2",children:E.jsxs("button",{onClick:T,className:"flex items-center gap-1.5 px-2 py-1 rounded-md text-xs text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",title:w?"Hide tool details":"Show tool details",children:[w?E.jsx(gH,{className:"w-3.5 h-3.5"}):E.jsx(mH,{className:"w-3.5 h-3.5"}),"Details"]})}),e.map((N,D)=>E.jsx($xe,{message:N,messageIndex:D,isLast:D===e.length-1,showDetails:w,onPermissionRespond:r,onQuestionRespond:i,onReplay:a,onEdit:l,onFork:c,onImageClick:A,busy:t&&D===e.length-1,screenMap:k,multiParticipant:u},N.id)),t&&((C=e[e.length-1])==null?void 0:C.role)!=="assistant"&&E.jsxs("div",{className:"flex gap-3 py-4",children:[E.jsx("div",{className:"w-7 h-7 rounded-full bg-muted flex items-center justify-center shrink-0 mt-0.5",children:E.jsx(Dc,{className:"w-4 h-4 text-muted-foreground"})}),E.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:E.jsxs("span",{className:"inline-flex gap-1",children:[E.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-muted-foreground animate-bounce",style:{animationDelay:"0ms"}}),E.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-muted-foreground animate-bounce",style:{animationDelay:"150ms"}}),E.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-muted-foreground animate-bounce",style:{animationDelay:"300ms"}})]})})]}),!!(f!=null&&f.length)&&h.statusChips&&E.jsxs("div",{className:"flex gap-3 py-2",children:[E.jsx("div",{className:"w-7 h-7 rounded-full bg-muted flex items-center justify-center shrink-0 mt-0.5",children:E.jsx(Dc,{className:"w-4 h-4 text-muted-foreground"})}),E.jsx("div",{className:"flex-1 min-w-0 pt-1",children:h.statusChips(f)})]}),n&&n!=="update_available"&&E.jsx("div",{className:Xe("text-center text-xs py-1.5 rounded-md transition-opacity",n==="reconnected"?"text-green-600 dark:text-green-400":"text-amber-600 dark:text-amber-400"),children:n==="server_restarting"?"Server updating — reconnecting automatically…":n==="disconnected"?"Connection lost — reconnecting...":"Reconnected."}),E.jsx("div",{ref:p})]}),E.jsx(el,{open:!!S,onOpenChange:N=>{N||A(null)},children:E.jsx(Va,{className:"max-w-[90vw] max-h-[90vh] w-[90vw] h-[90vh] p-2 flex items-center justify-center bg-background/95",children:S&&E.jsx(Pxe,{src:S})})})]})}function $xe({message:e,messageIndex:t,isLast:n,showDetails:r,onPermissionRespond:i,onQuestionRespond:a,onReplay:l,onEdit:c,onFork:u,onImageClick:f,busy:h,screenMap:p,multiParticipant:g}){var M;const v=e.blocks.find(z=>z.type==="compact_marker");if(v&&v.type==="compact_marker")return E.jsx(Fxe,{summary:v.summary,compactedCount:v.compactedCount});const w=e.role==="user",y=w?((M=e.blocks.find(z=>z.type==="text"))==null?void 0:M.text)??"":"",S=w?e.blocks.filter(z=>z.type==="image"||z.type==="file").map(z=>z.type==="image"?{url:z.src,name:z.src.split("/").pop()??"image",mimeType:"image/png",path:z.src}:{url:z.src,name:z.name,mimeType:z.mimeType,path:z.src}):void 0,[A,O]=b.useState(!1),[k,T]=b.useState(""),[C,N]=b.useState(!1),D=b.useRef(null),B=()=>{T(y),O(!0),setTimeout(()=>{const z=D.current;z&&(z.style.height="auto",z.style.height=z.scrollHeight+"px",z.focus(),z.setSelectionRange(z.value.length,z.value.length))},0)},P=()=>{const z=k.trim();z&&(O(!1),c==null||c(e.id,z,S!=null&&S.length?S:void 0))};return E.jsxs("div",{className:Xe("flex gap-3 py-4 group/row",w&&"flex-row-reverse"),onTouchStart:z=>{z.target.closest("button")||N(R=>!R)},children:[!w&&E.jsx("div",{className:"w-7 h-7 rounded-full bg-primary/10 flex items-center justify-center shrink-0 mt-0.5",children:E.jsx(Dc,{className:"w-4 h-4 text-primary"})}),w&&E.jsx("div",{className:"w-7 h-7 rounded-full bg-muted flex items-center justify-center shrink-0 mt-0.5",children:E.jsx(DH,{className:"w-4 h-4 text-muted-foreground"})}),E.jsxs("div",{className:Xe("min-w-0 max-w-[92%] sm:max-w-[85%] space-y-2"),children:[g&&w&&e.senderName&&E.jsx("div",{className:"text-[11px] font-medium text-muted-foreground text-right px-1",children:e.senderName}),A?E.jsxs("div",{className:"inline-block text-left w-full",children:[E.jsx("textarea",{ref:D,value:k,onChange:z=>{T(z.target.value),z.target.style.height="auto",z.target.style.height=z.target.scrollHeight+"px"},onKeyDown:z=>{z.key==="Enter"&&!z.shiftKey&&(z.preventDefault(),P()),z.key==="Escape"&&O(!1)},className:"w-full rounded-xl border bg-muted/50 px-4 py-2.5 text-sm resize-none outline-none focus:ring-1 focus:ring-primary min-h-[40px]"}),E.jsxs("div",{className:"flex gap-1 justify-end mt-1",children:[E.jsx("button",{onClick:()=>O(!1),className:"p-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",title:"Cancel",children:E.jsx(ls,{className:"w-3.5 h-3.5"})}),E.jsx("button",{onClick:P,className:"p-1 rounded-md text-primary hover:bg-primary/10 transition-colors",title:"Send",children:E.jsx(fm,{className:"w-3.5 h-3.5"})})]})]}):E.jsxs(E.Fragment,{children:[e.blocks.filter(z=>r?!0:z.type==="tool_use"&&z.tool==="AskUserQuestion"?e.blocks.some(R=>R.type==="tool_result"&&R.toolUseId===z.toolUseId):z.type!=="tool_use"&&z.type!=="tool_result"&&z.type!=="thinking").filter(z=>z.type!=="tool_result"?!0:!e.blocks.some(R=>R.type==="tool_use"&&R.toolUseId===z.toolUseId)).map((z,R,H)=>{const Y=z.type==="tool_use"?e.blocks.find(q=>q.type==="tool_result"&&q.toolUseId===z.toolUseId):void 0;return E.jsx(Hxe,{block:z,isUser:w,onPermissionRespond:i,onQuestionRespond:a,pairedResult:Y,onImageClick:f,busy:h,screenMap:p},R)}),w&&y&&E.jsxs("div",{className:Xe("flex gap-1 items-center justify-end transition-opacity",C?"opacity-100":"opacity-0 group-hover/row:opacity-100"),children:[e.ts&&E.jsx("span",{className:"text-[10px] text-muted-foreground/50 select-none mr-1",children:BR(e.ts)}),E.jsx("button",{onClick:()=>l==null?void 0:l(e.id,y,S!=null&&S.length?S:void 0),className:"p-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",title:"Replay",children:E.jsx(NH,{className:"w-3.5 h-3.5"})}),E.jsx("button",{onClick:B,className:"p-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",title:"Edit & resend",children:E.jsx(Bw,{className:"w-3.5 h-3.5"})})]}),!w&&!(h&&n)&&E.jsxs("div",{className:Xe("flex gap-1 items-center transition-opacity",C?"opacity-100":"opacity-0 group-hover/row:opacity-100"),children:[e.ts&&E.jsx("span",{className:"text-[10px] text-muted-foreground/40 select-none mr-1",children:BR(e.ts)}),E.jsx("button",{onClick:()=>u==null?void 0:u(t),className:"p-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",title:"Fork from here",children:E.jsx(uD,{className:"w-3.5 h-3.5"})})]})]})]})]})}function Fxe({summary:e,compactedCount:t}){const[n,r]=b.useState(!1);return E.jsxs("div",{className:"py-3",children:[E.jsxs("div",{className:"flex items-center gap-3",children:[E.jsx("div",{className:"flex-1 border-t border-amber-500/30"}),E.jsxs("button",{onClick:()=>r(!n),className:"flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium bg-amber-500/10 text-amber-600 dark:text-amber-400 border border-amber-500/20 hover:bg-amber-500/20 transition-colors",children:[E.jsx(zw,{className:"w-3 h-3"}),"Compacted · ",t," messages",E.jsx(sl,{className:Xe("w-3 h-3 transition-transform",n&&"rotate-90")})]}),E.jsx("div",{className:"flex-1 border-t border-amber-500/30"})]}),n&&E.jsx("div",{className:"mt-2 mx-auto max-w-2xl px-4 py-3 rounded-lg border border-amber-500/20 bg-amber-500/5 text-xs text-muted-foreground whitespace-pre-wrap",children:e})]})}function Hxe({block:e,isUser:t,onPermissionRespond:n,onQuestionRespond:r,pairedResult:i,onImageClick:a,busy:l,screenMap:c}){var f;const u=sa();return e.type==="image"?E.jsx(kS,{src:e.src,className:"max-h-[80vh] max-w-full rounded-xl border object-contain cursor-pointer hover:opacity-80 transition-opacity",onClick:h=>a==null?void 0:a(h)}):e.type==="file"?E.jsx("div",{children:E.jsx(Dxe,{src:e.src,name:e.name,className:"inline-flex items-center gap-2 px-3 py-2 rounded-lg border bg-muted/50 text-sm text-muted-foreground hover:bg-muted transition-colors"})}):e.type==="context"?E.jsx(qxe,{label:e.label,text:e.text}):e.type==="thinking"?E.jsx(Gxe,{text:e.text}):e.type==="error"?E.jsx(Kxe,{text:e.text}):e.type==="text"?t?E.jsx("div",{dir:"auto",className:"inline-block bg-primary text-primary-foreground rounded-2xl rounded-tr-sm px-4 py-2.5 text-sm break-words min-w-0 max-w-full whitespace-pre-wrap",children:e.text}):E.jsx("div",{className:"text-sm",dir:"auto",children:E.jsx(Bxe,{text:e.text,onImageClick:a})}):e.type==="tool_use"?e.tool==="AskUserQuestion"&&(i!=null&&i.output)?E.jsx(Yxe,{input:e.input,result:i.output}):E.jsx(Xxe,{block:e,tool:e.tool,input:e.input,result:i==null?void 0:i.output,busy:l,screenMap:c}):e.type==="tool_result"?E.jsx(Zxe,{output:e.output}):e.type==="permission_request"?E.jsx(Qxe,{id:e.id,tool:e.tool,input:e.input,onRespond:n}):e.type==="question_request"?E.jsx(Jxe,{id:e.id,questions:e.questions,onRespond:r}):((f=u.extensionBlocks)==null?void 0:f.call(u,{block:e,onImageClick:a}))??null}function Kxe({text:e}){return E.jsxs("div",{dir:"auto",className:"border border-destructive/40 rounded-lg bg-destructive/10 px-3 py-2 text-sm text-destructive break-words",children:[E.jsx("span",{className:"font-medium",children:"⚠️ Run failed"}),E.jsx("div",{className:"mt-1 text-xs opacity-90 whitespace-pre-wrap font-mono",children:e})]})}function qxe({label:e,text:t}){const[n,r]=b.useState(!1);return E.jsxs("div",{className:"border border-blue-500/20 rounded-lg overflow-hidden text-xs bg-blue-500/5",children:[E.jsxs("button",{onClick:()=>r(!n),className:"flex items-center gap-1.5 w-full px-3 py-2 hover:bg-blue-500/10 transition-colors text-left",children:[E.jsx(wH,{className:"w-3.5 h-3.5 text-blue-400 shrink-0"}),E.jsx("span",{className:"text-blue-300 font-medium",children:e}),E.jsx(sl,{className:Xe("w-3.5 h-3.5 text-muted-foreground transition-transform shrink-0 ml-auto",n&&"rotate-90")})]}),n&&E.jsx("div",{className:"px-3 py-2 border-t border-blue-500/20 text-muted-foreground whitespace-pre-wrap",children:t})]})}function Gxe({text:e}){const[t,n]=b.useState(!1),r=e.slice(0,120).replace(/\n/g," ");return E.jsxs("div",{className:"border border-violet-500/20 rounded-lg overflow-hidden text-xs bg-violet-500/5",children:[E.jsxs("button",{onClick:()=>n(!t),className:"flex items-center gap-1.5 w-full px-3 py-2 hover:bg-violet-500/10 transition-colors text-left",children:[E.jsx(dH,{className:"w-3.5 h-3.5 text-violet-400 shrink-0"}),E.jsx("span",{className:"text-violet-300 font-medium",children:"Thinking"}),E.jsx("span",{className:"text-muted-foreground truncate",children:r}),E.jsx(sl,{className:Xe("w-3.5 h-3.5 text-muted-foreground transition-transform shrink-0 ml-auto",t&&"rotate-90")})]}),t&&E.jsx("div",{className:"px-3 py-2 border-t border-violet-500/20 text-muted-foreground whitespace-pre-wrap",children:e})]})}function Vxe(e){const t=new Map;for(const n of e)for(const r of n.blocks)if(!(r.type!=="tool_result"||!r.output))try{const i=JSON.parse(r.output);typeof(i==null?void 0:i.sessionId)=="string"&&Array.isArray(i==null?void 0:i.screen)&&t.set(i.sessionId,i.screen)}catch{}return t}function Wxe(e){const t={},n=/"([^"]+)"="([^"]+)"/g;let r;for(;(r=n.exec(e))!==null;)t[r[1]]=r[2];return t}function Yxe({input:e,result:t}){const n=e,r=(n==null?void 0:n.questions)??[],i=Wxe(t);return!r.length||!Object.keys(i).length?null:E.jsxs("div",{className:"border rounded-lg overflow-hidden text-xs bg-blue-500/5 border-blue-500/20",children:[E.jsxs("div",{className:"flex items-center gap-1.5 px-2 sm:px-3 py-2 bg-blue-50 dark:bg-blue-950/40",children:[E.jsx(Uw,{className:"w-3.5 h-3.5 text-blue-400 shrink-0"}),E.jsx("span",{className:"font-medium text-blue-300",children:"Questions answered"})]}),E.jsx("div",{className:"px-2 sm:px-3 py-2 space-y-2",children:r.map((a,l)=>{const c=i[a.question];return c?E.jsxs("div",{className:"space-y-0.5",children:[E.jsxs("div",{className:"text-muted-foreground",children:[a.header?`${a.header}: `:"",a.question]}),E.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-blue-500/20 text-blue-300 font-medium",children:[E.jsx(na,{className:"w-2.5 h-2.5"}),c]})]},l):null})})]})}function Xxe({block:e,tool:t,input:n,result:r,busy:i,screenMap:a}){var S;const l=sa(),[c,u]=b.useState(!1),f=typeof n=="string"?n:JSON.stringify(n,null,2),h=typeof n=="object"&&n!==null&&Object.keys(n).length===0,p=h?"":typeof n=="object"&&n!==null?Object.keys(n).join(", "):String(n).slice(0,60),g=r!=null?t4(r.trim().replace(/\[Image #\d+\]\s*/g,"").trim()):void 0,v=r!=null,w=g?/^(Error|ERROR)|"status"\s*:\s*[45]\d\d|ENOENT|EACCES|Permission denied|command not found|No such file/i.test(g):!1,y=v?w?E.jsx(um,{className:"w-3 h-3 text-red-400 shrink-0"}):E.jsx(na,{className:"w-3 h-3 text-green-400 shrink-0"}):null;return E.jsxs("div",{className:"text-xs min-w-0 space-y-2",children:[E.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[E.jsxs("button",{onClick:()=>u(!c),className:"flex items-center gap-1.5 w-full px-2 sm:px-3 py-2 bg-muted/50 hover:bg-muted transition-colors text-left min-w-0",children:[E.jsx(PH,{className:"w-3.5 h-3.5 text-muted-foreground shrink-0"}),E.jsx("span",{className:"font-medium text-foreground shrink-0",children:t}),!h&&E.jsx("span",{className:"text-muted-foreground truncate min-w-0",children:p}),v?y:i?E.jsx(Xf,{className:"w-3 h-3 text-muted-foreground animate-spin shrink-0"}):E.jsx("span",{title:"Interrupted",children:E.jsx(um,{className:"w-3 h-3 text-amber-400 shrink-0"})}),E.jsx(sl,{className:Xe("w-3.5 h-3.5 text-muted-foreground transition-transform shrink-0 ml-auto",c&&"rotate-90")})]}),c&&E.jsxs("div",{className:"border-t",children:[!h&&E.jsx("pre",{className:"p-3 overflow-auto max-h-64 text-xs bg-background whitespace-pre-wrap break-all",children:f}),g&&E.jsx("pre",{className:Xe("p-3 overflow-auto max-h-64 text-xs whitespace-pre-wrap break-words",!h&&"border-t",w?"bg-red-50 dark:bg-red-950/20 text-red-700 dark:text-red-300":"bg-muted/30 text-foreground/80"),children:g})]})]}),(S=l.toolRenderers)==null?void 0:S.call(l,{block:e,result:r,screens:a})]})}function t4(e){const t=e.split(`
|
|
1943
1943
|
`);return t.length<2||!t.filter(r=>r.length>0).every(r=>/^\s*\d+\t/.test(r))?e:t.map(r=>r.replace(/^\s*\d+\t/,"")).join(`
|
|
1944
1944
|
`)}function Zxe({output:e}){const[t,n]=b.useState(!1),r=e.trim().replace(/\[Image #\d+\]\s*/g,"").trim(),i=t4(r);if(!i)return null;const a=/^(Error|ERROR)|"status"\s*:\s*[45]\d\d|ENOENT|EACCES|Permission denied|command not found|No such file/i.test(i),l=a?null:Oxe(i),c=i.length>200,u=i.slice(0,120).replace(/\n/g," "),f=a?um:na,h=a?"border-red-200 dark:border-red-900":"border-green-200 dark:border-green-900",p=a?"bg-red-50 dark:bg-red-950/30 hover:bg-red-100 dark:hover:bg-red-950/50":"bg-green-50 dark:bg-green-950/30 hover:bg-green-100 dark:hover:bg-green-950/50",g=a?"text-red-600 dark:text-red-400":"text-green-600 dark:text-green-400";return E.jsxs("div",{className:Xe("border rounded-lg overflow-hidden text-xs min-w-0",h),children:[E.jsxs("button",{onClick:()=>n(!t),className:Xe("flex items-center gap-1.5 w-full px-2 sm:px-3 py-2 transition-colors text-left min-w-0",p),children:[E.jsx(f,{className:Xe("w-3.5 h-3.5 shrink-0",g)}),E.jsx("span",{className:"text-muted-foreground truncate flex-1 min-w-0",children:c?u+"…":u}),E.jsx(sl,{className:Xe("w-3.5 h-3.5 text-muted-foreground transition-transform shrink-0",t&&"rotate-90")})]}),t&&E.jsx("div",{className:"p-3 bg-background border-t",children:l?E.jsx(Rxe,{data:l}):E.jsx("pre",{className:"overflow-auto max-h-96 text-xs whitespace-pre-wrap break-words",children:i})})]})}function Qxe({id:e,tool:t,input:n,onRespond:r}){const[i,a]=b.useState(!1),l=JSON.stringify(n,null,2),c=Object.keys(n).join(", ");return E.jsxs("div",{className:"border-2 rounded-lg overflow-hidden text-xs border-amber-300 dark:border-amber-700 animate-in fade-in slide-in-from-bottom-2 min-w-0",children:[E.jsxs("div",{className:"flex items-center gap-1.5 px-2 sm:px-3 py-2 bg-amber-50 dark:bg-amber-950/40 min-w-0",children:[E.jsx(Uw,{className:"w-4 h-4 text-amber-600 dark:text-amber-400 shrink-0"}),E.jsx("span",{className:"font-medium text-foreground shrink-0",children:t}),E.jsxs("button",{onClick:()=>a(!i),className:"text-muted-foreground truncate min-w-0 text-left hover:text-foreground transition-colors",children:[c,E.jsx(sl,{className:Xe("w-3.5 h-3.5 inline ml-1 transition-transform",i&&"rotate-90")})]})]}),i&&E.jsx("pre",{className:"p-3 overflow-auto max-h-48 text-xs bg-background border-t border-amber-200 dark:border-amber-800 whitespace-pre-wrap break-all",children:l}),E.jsxs("div",{className:"flex flex-wrap gap-2 px-2 sm:px-3 py-2 bg-amber-50/50 dark:bg-amber-950/20 border-t border-amber-200 dark:border-amber-800",children:[E.jsxs("button",{onClick:()=>r==null?void 0:r(e,!0),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium bg-green-600 text-white hover:bg-green-700 transition-colors",children:[E.jsx(qO,{className:"w-3.5 h-3.5"}),"Allow"]}),E.jsxs("button",{onClick:()=>r==null?void 0:r(e,!0,!0),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium border border-green-600 text-green-700 dark:text-green-400 hover:bg-green-50 dark:hover:bg-green-950/30 transition-colors",children:[E.jsx(qO,{className:"w-3.5 h-3.5"}),"Always Allow"]}),E.jsxs("button",{onClick:()=>r==null?void 0:r(e,!1),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium bg-red-600 text-white hover:bg-red-700 transition-colors",children:[E.jsx(um,{className:"w-3.5 h-3.5"}),"Deny"]})]})]})}function Jxe({id:e,questions:t,onRespond:n}){const[r,i]=b.useState({}),[a,l]=b.useState({}),[c,u]=b.useState(!1),f=sa();b.useEffect(()=>{var y;return(y=f.onCardInteraction)==null?void 0:y.call(f,{id:e,questions:t,onAnswers:S=>{i(()=>{const A={};return t.forEach((O,k)=>{const T=S[O.question];T!=null&&(A[k]=new Set(Array.isArray(T)?T:[T]))}),A})}})},[e,t,f]);const h=(y,S,A)=>{i(O=>{const k=new Set(O[y]??[]);return A?k.has(S)?k.delete(S):k.add(S):(k.clear(),k.add(S)),{...O,[y]:k}})},p="__other__",g=t.filter((y,S)=>{var O;const A=r[S];return!(!A||A.size===0||A.has(p)&&!((O=a[S])!=null&&O.trim()))}).length,v=g===t.length,w=()=>{if(!v||c)return;const y={};t.forEach((S,A)=>{const O=[...r[A]??[]].map(k=>k===p?a[A].trim():k);y[S.question]=S.multiSelect?O:O[0]}),u(!0),n==null||n(e,y)};return E.jsxs("div",{className:"border-2 rounded-lg overflow-hidden text-xs border-blue-300 dark:border-blue-700 animate-in fade-in slide-in-from-bottom-2 min-w-0",children:[E.jsxs("div",{className:"flex items-center gap-1.5 px-2 sm:px-3 py-2 bg-blue-50 dark:bg-blue-950/40",children:[E.jsx(Uw,{className:"w-4 h-4 text-blue-600 dark:text-blue-400 shrink-0"}),E.jsx("span",{className:"font-medium text-foreground",children:"Questions for you"})]}),E.jsx("div",{className:"px-2 sm:px-3 py-2 space-y-4 bg-background",children:t.map((y,S)=>{const A=!!y.multiSelect,O=r[S]??new Set;return E.jsxs("div",{className:"space-y-1.5",children:[E.jsx("div",{className:"font-medium text-foreground",children:y.question}),E.jsxs("div",{className:"space-y-1",children:[y.options.map(k=>E.jsxs("button",{disabled:c,onClick:()=>h(S,k.label,A),className:Xe("flex items-start gap-2 w-full text-left px-2 py-1.5 rounded-md border transition-colors",O.has(k.label)?"border-blue-500 bg-blue-50 dark:bg-blue-950/40":"border-border hover:bg-muted/50"),children:[E.jsx("span",{className:Xe("mt-0.5 w-3.5 h-3.5 shrink-0 border flex items-center justify-center",A?"rounded-sm":"rounded-full",O.has(k.label)?"bg-blue-500 border-blue-500":"border-muted-foreground"),children:O.has(k.label)&&E.jsx(na,{className:"w-2.5 h-2.5 text-white"})}),E.jsxs("span",{className:"min-w-0",children:[E.jsx("span",{className:"font-medium text-foreground",children:k.label}),k.description&&E.jsxs("span",{className:"text-muted-foreground",children:[" — ",k.description]})]})]},k.label)),E.jsxs("div",{className:Xe("flex items-center gap-2 px-2 py-1.5 rounded-md border",O.has(p)?"border-blue-500 bg-blue-50 dark:bg-blue-950/40":"border-border"),children:[E.jsx("button",{disabled:c,onClick:()=>h(S,p,A),className:Xe("w-3.5 h-3.5 shrink-0 border flex items-center justify-center",A?"rounded-sm":"rounded-full",O.has(p)?"bg-blue-500 border-blue-500":"border-muted-foreground"),children:O.has(p)&&E.jsx(na,{className:"w-2.5 h-2.5 text-white"})}),E.jsx("input",{type:"text",disabled:c,value:a[S]??"",placeholder:"Other…",onChange:k=>{l(T=>({...T,[S]:k.target.value})),k.target.value&&!O.has(p)&&h(S,p,A)},className:"flex-1 bg-transparent outline-none text-foreground placeholder:text-muted-foreground"})]})]})]},S)})}),E.jsxs("div",{className:"flex items-center gap-2 px-2 sm:px-3 py-2 bg-blue-50/50 dark:bg-blue-950/20 border-t border-blue-200 dark:border-blue-800",children:[E.jsxs("button",{onClick:w,disabled:!v||c,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium bg-blue-600 text-white hover:bg-blue-700 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:[E.jsx(fm,{className:"w-3.5 h-3.5"}),c?"Sent":"Submit"]}),E.jsxs("span",{className:"text-muted-foreground",children:[g,"/",t.length," answered"]})]})]})}function ewe({children:e,...t}){const n=b.useRef(null);return E.jsxs("div",{className:"relative group",children:[E.jsx("pre",{ref:n,...t,className:"rounded-lg border bg-muted p-4 overflow-x-auto text-xs text-foreground",children:e}),E.jsx(twe,{getText:()=>{var r;return((r=n.current)==null?void 0:r.textContent)||""}})]})}function twe({getText:e}){const[t,n]=b.useState(!1);return E.jsx("button",{onClick:()=>{navigator.clipboard.writeText(e()),n(!0),setTimeout(()=>n(!1),2e3)},className:"absolute top-2 right-2 p-1.5 rounded-md bg-background/80 border opacity-0 group-hover:opacity-100 transition-opacity",title:"Copy",children:t?E.jsx(na,{className:"w-3 h-3"}):E.jsx(Pw,{className:"w-3 h-3"})})}const n4=b.forwardRef(function({value:t,onChange:n,onKeyDown:r,onPaste:i,skills:a=[],workspaceFiles:l=[],placeholder:c,className:u,rows:f=1,disabled:h,autoResize:p=!0,maxHeight:g=200},v){const w=b.useRef(null),[y,S]=b.useState(null),[A,O]=b.useState(0);b.useImperativeHandle(v,()=>({focus:()=>{var B;return(B=w.current)==null?void 0:B.focus()},setValue:B=>{n(B),p&&T()}}));const k=y?[...a.filter(B=>B.toLowerCase().includes(y.query.toLowerCase())).map(B=>({kind:"skill",value:B})),...y.kind==="mention"?l.filter(B=>B.toLowerCase().includes(y.query.toLowerCase())).map(B=>({kind:"workspace",value:B})):[]]:[];function T(){setTimeout(()=>{const B=w.current;B&&(B.style.height="auto",B.style.height=Math.min(B.scrollHeight,g)+"px")},0)}const C=B=>{if(!y)return;const P=y.kind==="command"?"/":"@",M=t.slice(0,y.start),z=t.slice(y.start+y.query.length+1),R=`${M}${P}${B} ${z}`;n(R),S(null),setTimeout(()=>{const H=w.current;if(!H)return;p&&(H.style.height="auto",H.style.height=Math.min(H.scrollHeight,g)+"px");const Y=M.length+B.length+2;H.setSelectionRange(Y,Y),H.focus()},0)},N=B=>{if(y&&k.length>0){if(B.key==="ArrowDown"){B.preventDefault(),O(P=>(P+1)%k.length);return}if(B.key==="ArrowUp"){B.preventDefault(),O(P=>(P-1+k.length)%k.length);return}if(B.key==="Enter"||B.key==="Tab"){B.preventDefault(),C(k[A].value);return}if(B.key==="Escape"){S(null);return}}r==null||r(B)},D=B=>{const P=B.target.value;n(P);const M=B.target;p&&(M.style.height="auto",M.style.height=Math.min(M.scrollHeight,g)+"px");const z=M.selectionStart??P.length,R=P.slice(0,z),H=R.match(/(?:^|\n)\/([\w-]*)$/),Y=R.match(/@([\w\-./]*)$/);H?(S({query:H[1],start:H.index+(R[H.index]===`
|
|
1945
|
-
`?1:0),kind:"command"}),O(0)):Y?(S({query:Y[1],start:Y.index,kind:"mention"}),O(0)):S(null)};return b.useEffect(()=>{const B=()=>S(null);return y&&document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[y]),E.jsxs("div",{className:"relative flex-1 min-w-0",children:[y&&k.length>0&&E.jsx("div",{className:"absolute bottom-full mb-1 left-0 z-50 bg-background border rounded-lg shadow-lg overflow-hidden min-w-[220px] max-h-64 overflow-y-auto",children:k.map((B,P)=>E.jsxs("button",{onMouseDown:M=>{M.preventDefault(),C(B.value)},className:`w-full text-left px-3 py-1.5 text-sm hover:bg-accent transition-colors flex items-center gap-2 ${P===A?"bg-accent":""}`,children:[E.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground shrink-0 w-14",children:(y==null?void 0:y.kind)==="command"?"cmd":B.kind==="skill"?"skill":"file"}),E.jsxs("span",{className:"truncate",children:[E.jsx("span",{className:"text-muted-foreground",children:(y==null?void 0:y.kind)==="command"?"/":"@"}),B.value]})]},`${B.kind}:${B.value}`))}),E.jsx("textarea",{ref:w,value:t,onChange:D,onKeyDown:N,onPaste:i,placeholder:c,disabled:h,rows:f,dir:"auto",className:u})]})}),OS="shraga:draft:";function q0(e,t){const n=OS+(e??"new");t.trim()?localStorage.setItem(n,t):localStorage.removeItem(n)}function $R(e){return localStorage.getItem(OS+(e??"new"))??""}function FR(e){localStorage.removeItem(OS+(e??"new"))}const nwe=b.forwardRef(function({onSend:t,onSteer:n,onQueue:r,onRemoveQueued:i,queue:a,onUpload:l,onCancel:c,disabled:u,busy:f,skills:h=[],workspaceFiles:p=[],sessionId:g,inputCtx:v},w){var U,G;const y=sa(),[S,A]=b.useState(()=>$R(g)),[O,k]=b.useState([]),[T,C]=b.useState(!1),N=b.useRef(null),D=b.useRef(null),B=b.useRef(g);b.useEffect(()=>{var j;if(B.current===g)return;const K=B.current;if(B.current=g,!g){FR(K),q0(void 0,S);return}q0(K,S);const ee=$R(g);A(ee),(j=D.current)==null||j.setValue(ee)},[g]);const P=b.useCallback(K=>{A(K),q0(B.current,K)},[]);b.useImperativeHandle(w,()=>({prefill(K){var ee,j;P(K),(ee=D.current)==null||ee.setValue(K),(j=D.current)==null||j.focus()},setText(K){var ee;P(K),(ee=D.current)==null||ee.setValue(K)},focus(){var K;(K=D.current)==null||K.focus()}}));const M=(K="send")=>{var j;const ee=S.trim();!ee&&O.length===0||(K==="steer"?n(ee):K==="queue"?r(ee):t(ee,O.length>0?O:void 0),A(""),FR(B.current),k([]),(j=D.current)==null||j.setValue(""))},z=typeof window<"u"&&((U=window.matchMedia)==null?void 0:U.call(window,"(pointer: coarse)").matches),R=K=>{if(K.key==="Enter"&&!K.shiftKey&&(!z||K.metaKey||K.ctrlKey)){K.preventDefault(),M(f?"steer":"send");return}if(K.key==="Tab"&&f&&S.trim()){K.preventDefault(),M("queue");return}},H=b.useCallback(async K=>{C(!0);try{const ee=await l(K);ee&&k(j=>[...j,ee])}finally{C(!1)}},[l]),Y=b.useCallback(K=>{const ee=Array.from(K.clipboardData.items);for(const j of ee)if(j.type.startsWith("image/")||j.type==="application/pdf"){const F=j.getAsFile();F&&H(F)}},[H]),q=K=>{var j;const ee=(j=K.target.files)==null?void 0:j[0];ee&&(H(ee),K.target.value="")};return E.jsx("div",{className:"border-t bg-background",style:{paddingBottom:"env(safe-area-inset-bottom)"},children:E.jsxs("div",{className:"max-w-3xl mx-auto px-2 sm:px-4 py-3",children:[(O.length>0||T)&&E.jsxs("div",{className:"flex gap-2 mb-2 flex-wrap items-center",children:[O.map((K,ee)=>E.jsxs("div",{className:"relative group",children:[K.mimeType.startsWith("image/")?E.jsx(kS,{src:K.url,alt:K.name,className:"h-16 w-16 object-cover rounded-lg border"}):E.jsxs("div",{className:"h-16 px-3 flex items-center gap-2 rounded-lg border bg-muted/50 text-xs text-muted-foreground",children:[E.jsx(jw,{className:"w-4 h-4 shrink-0"}),E.jsx("span",{className:"truncate max-w-[120px]",children:K.name})]}),E.jsx("button",{onClick:()=>k(j=>j.filter((F,J)=>J!==ee)),className:"absolute -top-1.5 -right-1.5 bg-destructive text-destructive-foreground rounded-full w-5 h-5 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity shadow-sm",children:E.jsx(ls,{className:"w-3 h-3"})})]},ee)),T&&E.jsx("span",{className:"text-xs text-muted-foreground animate-pulse",children:"Uploading…"})]}),E.jsxs("div",{className:"flex items-center gap-2 bg-muted/50 rounded-xl border px-3 py-2",children:[E.jsx(Me,{variant:"ghost",size:"icon",className:"h-9 w-9 sm:h-8 sm:w-8 shrink-0",onClick:()=>{var K;return(K=N.current)==null?void 0:K.click()},disabled:u,title:"Attach file or image",children:E.jsx(kH,{className:"w-4 h-4"})}),E.jsx("input",{ref:N,type:"file",className:"hidden",onChange:q}),E.jsx(n4,{ref:D,value:S,onChange:P,onKeyDown:R,onPaste:Y,skills:h,workspaceFiles:p,placeholder:f?"Steer or queue…":"Message Claude…",disabled:u,rows:1,className:"w-full bg-transparent border-none outline-none resize-none text-sm py-1.5 placeholder:text-muted-foreground min-h-[28px] max-h-[200px]"}),(G=y.inputAdornments)==null?void 0:G.call(y,v),f?E.jsxs("div",{className:"flex items-center gap-2",children:[S.trim()&&E.jsx(Me,{size:"icon",className:"h-9 w-9 sm:h-8 sm:w-8 shrink-0 rounded-lg",onClick:()=>M("steer"),title:"Steer (inject into current turn)",children:E.jsx(fm,{className:"w-4 h-4"})}),E.jsx(Me,{variant:"destructive",size:"icon",className:"h-9 w-9 sm:h-8 sm:w-8 shrink-0 rounded-lg",onClick:()=>c(),title:"Stop generation",children:E.jsx(hD,{className:"w-3.5 h-3.5"})})]}):E.jsx(Me,{size:"icon",className:"h-9 w-9 sm:h-8 sm:w-8 shrink-0 rounded-lg",onClick:()=>M(),disabled:u||T||!S.trim()&&O.length===0,children:E.jsx(fm,{className:"w-4 h-4"})})]}),a.length>0&&E.jsx("div",{className:"flex gap-1.5 flex-wrap mt-2",children:a.map((K,ee)=>E.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-blue-50 dark:bg-blue-950/40 px-2.5 py-1 text-xs text-blue-700 dark:text-blue-300 ring-1 ring-inset ring-blue-600/20 dark:ring-blue-400/30",children:[E.jsx("span",{className:"truncate max-w-[200px]",children:K}),E.jsx("button",{onClick:()=>i(ee),className:"hover:text-blue-900 dark:hover:text-blue-100",children:E.jsx(ls,{className:"w-3 h-3"})})]},ee))}),E.jsx("p",{className:"text-[10px] text-muted-foreground text-center mt-2",children:f?"Enter to steer (redirect) · Tab to queue (after done) · Shift+Enter for newline":"Enter to send · Shift+Enter for newline · @ for skills · / for commands"})]})})}),rwe={"fb-feed":[1080,1080],"fb-story":[1080,1920],"fb-landscape":[1200,628],"ig-square":[1080,1080],"ig-story":[1080,1920],"ig-landscape":[1080,566],"banner-leaderboard":[728,90],"banner-medium":[300,250]};function iwe({artifacts:e,selectedId:t,sessionId:n,getToken:r,onSelect:i,onClose:a}){var D;const[l,c]=b.useState(!1),[u,f]=b.useState(!1),[h,p]=b.useState(!1),[g,v]=b.useState(1),w=b.useRef(null),y=e.find(B=>B.id===t),S=b.useCallback(()=>{if(!w.current||!y)return;const{clientWidth:B,clientHeight:P}=w.current,M=32,z=B-M,R=P-M,[H,Y]=y.dimensions;v(Math.min(z/H,R/Y,1))},[y]);b.useEffect(()=>{let B=!0;return r().then(P=>fetch("/api/features",{headers:P?{Authorization:`Bearer ${P}`}:{}})).then(P=>P.json()).then(P=>{B&&p(!!P.artifactPngExport)}).catch(P=>console.error("[artifact] features fetch failed:",P)),()=>{B=!1}},[r]),b.useEffect(()=>{S();const B=w.current;if(!B)return;const P=new ResizeObserver(S);return P.observe(B),()=>P.disconnect()},[S]);const A=async()=>{if(y){f(!0);try{const B=await r(),P=await fetch(`/api/artifacts/${n}/${y.id}/export`,{method:"POST",headers:{"Content-Type":"application/json",...B?{Authorization:`Bearer ${B}`}:{}},body:JSON.stringify({dimensions:y.dimensions})});if(!P.ok)throw new Error(await P.text());const M=await P.blob(),z=URL.createObjectURL(M),R=document.createElement("a");R.href=z,R.download=`${y.title.replace(/\s+/g,"-").toLowerCase()}.png`,R.click(),URL.revokeObjectURL(z)}catch(B){console.error("[artifact] export failed:",B)}finally{f(!1)}}},O=y?(D=Object.entries(rwe).find(([,B])=>B[0]===y.dimensions[0]&&B[1]===y.dimensions[1]))==null?void 0:D[0]:null,[k,T]=(y==null?void 0:y.dimensions)??[0,0],C=k*g,N=T*g;return E.jsxs("div",{className:Xe("flex flex-col border-l bg-background transition-all",l?"fixed inset-0 z-50":"fixed inset-0 z-50 sm:relative sm:inset-auto sm:z-auto sm:w-[480px] sm:shrink-0"),children:[E.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 border-b bg-muted/30",children:[E.jsx(Me,{variant:"ghost",size:"icon",className:"h-7 w-7 sm:hidden shrink-0",onClick:a,title:"Back to chat",children:E.jsx(sD,{className:"w-4 h-4"})}),e.length>1&&E.jsx("select",{className:"text-xs bg-transparent border rounded px-1 py-0.5 max-w-[160px] truncate",value:t??"",onChange:B=>i(B.target.value),children:e.map(B=>E.jsx("option",{value:B.id,children:B.title},B.id))}),e.length<=1&&y&&E.jsx("span",{className:"text-xs font-medium truncate max-w-[160px]",children:y.title}),y&&E.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[O??`${k}×${T}`,g<1&&` · ${Math.round(g*100)}%`]}),E.jsx("div",{className:"flex-1"}),h&&E.jsx(Me,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:A,disabled:!y||u,title:"Export PNG",children:u?E.jsx("span",{className:"w-3 h-3 border-2 border-current border-t-transparent rounded-full animate-spin"}):E.jsx(xH,{className:"w-3.5 h-3.5"})}),E.jsx(Me,{variant:"ghost",size:"icon",className:"h-6 w-6 hidden sm:inline-flex",onClick:()=>c(!l),title:l?"Minimize":"Maximize",children:l?E.jsx(zw,{className:"w-3.5 h-3.5"}):E.jsx(Lw,{className:"w-3.5 h-3.5"})}),E.jsx(Me,{variant:"ghost",size:"icon",className:"h-6 w-6 hidden sm:inline-flex",onClick:a,title:"Close",children:E.jsx(ls,{className:"w-3.5 h-3.5"})})]}),E.jsx("div",{ref:w,className:"flex-1 overflow-hidden flex items-center justify-center bg-muted/10",children:y?E.jsx("div",{style:{width:C,height:N},children:E.jsx("iframe",{src:`/api/artifacts/${n}/${y.id}`,sandbox:"allow-scripts",className:"border shadow-sm bg-white origin-top-left",style:{width:k,height:T,transform:`scale(${g})`},title:y.title})}):E.jsx("p",{className:"text-sm text-muted-foreground",children:"No artifact selected"})})]})}const vv=b.forwardRef(({className:e,...t},n)=>E.jsx("textarea",{className:Xe("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 resize-none",e),ref:n,...t}));vv.displayName="Textarea";const awe=[{value:"",label:"Default (claude-sonnet-5)"},{value:"claude-fable-5",label:"Fable 5 — frontier, most capable"},{value:"claude-opus-4-8",label:"Opus 4.8 — most capable, best for complex/agentic tasks"},{value:"claude-opus-4-7",label:"Opus 4.7"},{value:"claude-opus-4-6",label:"Opus 4.6"},{value:"claude-sonnet-5",label:"Sonnet 5 — balanced speed & intelligence"},{value:"claude-sonnet-4-6",label:"Sonnet 4.6"},{value:"claude-haiku-4-5",label:"Haiku 4.5 — fastest"}],owe=[{value:"acceptEdits",label:"Accept Edits (auto-approve file changes)"},{value:"plan",label:"Plan (read-only, suggest changes)"},{value:"bypassPermissions",label:"Bypass All (dangerous — no prompts)"}];function lwe({getToken:e,onSaved:t,trigger:n,sessionId:r,sessionDirectives:i,onDirectivesSaved:a}){var P;const l=sa(),[c,u]=b.useState({}),[f,h]=b.useState(!1),[p,g]=b.useState(!1),[v,w]=b.useState([]),[y,S]=b.useState(!1),A=b.useRef({});b.useEffect(()=>{f&&e().then(M=>{M&&(fetch("/api/config",{headers:{Authorization:`Bearer ${M}`}}).then(z=>z.json()).then(z=>{A.current=z;const R=r?i:void 0;u({...z,...(R==null?void 0:R.engine)!==void 0?{engine:R.engine}:{},...(R==null?void 0:R.model)!==void 0?{model:R.model}:{},...(R==null?void 0:R.turns)!==void 0?{maxTurns:R.turns}:{},...(R==null?void 0:R.thinking)!==void 0?{thinking:R.thinking}:{}})}).catch(()=>{}),fetch("/api/engines",{headers:{Authorization:`Bearer ${M}`}}).then(z=>z.json()).then(z=>{w(z.engines??[]),S(z.multiEngine??!1)}).catch(()=>{}))})},[f,e,r,i]);const O=async()=>{g(!0);const z={Authorization:`Bearer ${await e()??""}`,"Content-Type":"application/json"};try{if(r){const R={engine:c.engine,model:c.model,turns:c.maxTurns,thinking:c.thinking},H=await fetch(`/api/sessions/${r}/directives`,{method:"PUT",headers:z,body:JSON.stringify(R)}).then(q=>q.json()).catch(q=>(console.warn("[config] directives save failed",q),null));H!=null&&H.directives&&(a==null||a(H.directives));const Y={...c,engine:A.current.engine,model:A.current.model,maxTurns:A.current.maxTurns,thinking:A.current.thinking};await fetch("/api/config",{method:"PUT",headers:z,body:JSON.stringify(Y)}),t==null||t(Y)}else await fetch("/api/config",{method:"PUT",headers:z,body:JSON.stringify(c)}),t==null||t(c);h(!1)}finally{g(!1)}},k=c.engine||"claude-code",T=v.find(M=>M.name===k),C=(T==null?void 0:T.models)??awe;b.useEffect(()=>{!T||!C.length||C.some(M=>(M.value||"")===(c.model??""))||u(M=>({...M,model:C[0].value||void 0}))},[T,C,c.model]);const D=C.some(M=>M.provider)?Array.from(C.reduce((M,z)=>{const R=z.provider||"default";return M.has(R)||M.set(R,[]),M.get(R).push(z),M},new Map)):null,B="flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2";return E.jsxs(el,{open:f,onOpenChange:h,children:[E.jsx(Sd,{asChild:!0,children:n||E.jsx(Me,{variant:"ghost",size:"icon",title:"Agent Config",children:E.jsx(IH,{className:"w-4 h-4"})})}),E.jsxs(Va,{className:"max-w-lg",children:[E.jsx(cs,{children:E.jsx(tl,{children:"Agent Configuration"})}),E.jsxs(Cj,{className:"space-y-4",children:[r&&E.jsxs("p",{className:"text-xs text-muted-foreground rounded-md bg-muted/50 px-3 py-2",children:["Engine, Model, Max Turns & Thinking apply to ",E.jsx("strong",{children:"this conversation"}),". Other settings are global defaults for new sessions."]}),y&&E.jsxs("div",{children:[E.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Engine"}),E.jsx("select",{value:c.engine??"",onChange:M=>{const z=M.target.value||void 0;u(R=>({...R,engine:z,model:void 0}))},className:B,children:v.map(M=>E.jsx("option",{value:M.name,children:M.name==="claude-code"?"Claude Code (default)":M.name},M.name))})]}),E.jsxs("div",{children:[E.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Model"}),E.jsx("select",{value:c.model??"",onChange:M=>u(z=>({...z,model:M.target.value||void 0})),className:B,children:D?D.map(([M,z])=>E.jsx("optgroup",{label:M.charAt(0).toUpperCase()+M.slice(1),children:z.map(R=>E.jsx("option",{value:R.value,children:R.label},R.value))},M)):C.map(M=>E.jsx("option",{value:M.value,children:M.label},M.value))})]}),(P=l.settingsSections)==null?void 0:P.call(l,{getToken:e,sessionId:r}),E.jsxs("div",{children:[E.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Permission Mode"}),E.jsx("select",{value:c.permissionMode??"acceptEdits",onChange:M=>u(z=>({...z,permissionMode:M.target.value})),className:B,children:owe.map(M=>E.jsx("option",{value:M.value,children:M.label},M.value))})]}),E.jsxs("div",{children:[E.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Max Turns"}),E.jsx(In,{type:"number",min:1,max:200,value:c.maxTurns??50,onChange:M=>u(z=>({...z,maxTurns:Number(M.target.value)||50}))})]}),E.jsxs("div",{children:[E.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Thinking"}),E.jsxs("select",{value:c.thinking??"",onChange:M=>u(z=>({...z,thinking:M.target.value||void 0})),className:B,children:[E.jsx("option",{value:"",children:"Default (off)"}),E.jsx("option",{value:"adaptive",children:"Adaptive (Claude decides)"}),E.jsx("option",{value:"enabled",children:"Enabled (always think)"}),E.jsx("option",{value:"disabled",children:"Disabled"})]})]}),E.jsxs("div",{children:[E.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Effort"}),E.jsxs("select",{value:c.effort??"",onChange:M=>u(z=>({...z,effort:M.target.value||void 0})),className:B,children:[E.jsx("option",{value:"",children:"Default"}),E.jsx("option",{value:"low",children:"Low — fast"}),E.jsx("option",{value:"medium",children:"Medium"}),E.jsx("option",{value:"high",children:"High"}),E.jsx("option",{value:"max",children:"Max"})]})]}),E.jsxs("div",{children:[E.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Allowed Tools"}),E.jsx(In,{placeholder:"Read, Edit, Bash, WebSearch, Glob, LS",value:(c.allowedTools??[]).join(", "),onChange:M=>u(z=>({...z,allowedTools:M.target.value.split(",").map(R=>R.trim()).filter(Boolean)}))}),E.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Comma-separated list of tools Claude can use"})]}),E.jsxs("div",{className:"flex items-center justify-between",children:[E.jsxs("div",{children:[E.jsx("label",{className:"text-sm font-medium",children:"Skill Discovery"}),E.jsx("p",{className:"text-xs text-muted-foreground",children:"Index all skills + auto-inject on trigger match"})]}),E.jsx("button",{type:"button",role:"switch","aria-checked":c.skillDiscovery!==!1,onClick:()=>u(M=>({...M,skillDiscovery:M.skillDiscovery===!1})),className:`relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors ${c.skillDiscovery!==!1?"bg-primary":"bg-muted"}`,children:E.jsx("span",{className:`pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform ${c.skillDiscovery!==!1?"translate-x-5":"translate-x-0"}`})})]}),E.jsxs("div",{children:[E.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"System Prompt (optional)"}),E.jsx(vv,{placeholder:"Additional instructions appended to Claude's system prompt…",value:c.systemPrompt??"",onChange:M=>u(z=>({...z,systemPrompt:M.target.value||void 0})),rows:4})]})]}),E.jsx(Ij,{children:E.jsx(Me,{onClick:O,disabled:p,children:p?"Saving…":"Save Configuration"})})]})]})}function swe({sessionId:e,config:t,sessionDirectives:n,actualModel:r,scheduleId:i,onScheduleClick:a}){const[l,c]=b.useState(!1),u=(n==null?void 0:n.engine)||t.engine||"claude-code",f=r?!r.includes("/"):void 0,h=u==="claude-code"||u==="cursor",g=(f!==void 0&&f===h?r:void 0)||(n==null?void 0:n.model)||t.model||(u==="cursor"?"cursor/composer-2.5":"sonnet-4-6"),v=h?g.replace("claude-",""):`${u} · ${g.replace("claude-","")}`,w=g.includes("/")?g.split("/")[0]:"anthropic",y=u==="claude-code"&&t.claudeAuthSource==="subscription",S=y?"sub":w==="cursor"?"plan":"metered",A=S==="sub"?"bg-emerald-50 text-emerald-700 ring-emerald-600/20 dark:bg-emerald-950/50 dark:text-emerald-300 dark:ring-emerald-400/30":S==="plan"?"bg-amber-50 text-amber-700 ring-amber-600/20 dark:bg-amber-950/50 dark:text-amber-300 dark:ring-amber-400/30":"bg-rose-50 text-rose-700 ring-rose-600/20 dark:bg-rose-950/50 dark:text-rose-300 dark:ring-rose-400/30",O=S==="sub"?"Claude.ai subscription (OAuth login) — no API key in use":S==="plan"?`Runs on your ${w} API key — usage may draw on your ${w} plan/subscription`:`Runs on your ${w} API key — metered per-token billing`,k=t.permissionMode||"acceptEdits",T=k==="bypassPermissions"?"bypass":k==="plan"?"plan":k==="default"?"prompt":"edits",C=(n==null?void 0:n.thinking)||t.thinking,N=()=>{e&&(navigator.clipboard.writeText(e),c(!0),setTimeout(()=>c(!1),1500))};return E.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[E.jsx("span",{className:"inline-flex items-center rounded-md bg-blue-50 px-1.5 py-0.5 text-[10px] font-medium text-blue-700 ring-1 ring-inset ring-blue-600/20 dark:bg-blue-950/50 dark:text-blue-300 dark:ring-blue-400/30",children:v}),E.jsx("span",{title:O,className:`inline-flex items-center rounded-md px-1.5 py-0.5 text-[10px] font-medium ring-1 ring-inset ${A}`,children:y?"sub":`API·${w}`}),E.jsx("span",{className:"inline-flex items-center rounded-md bg-amber-50 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 ring-1 ring-inset ring-amber-600/20 dark:bg-amber-950/50 dark:text-amber-300 dark:ring-amber-400/30",children:T}),E.jsxs("span",{className:"inline-flex items-center rounded-md bg-green-50 px-1.5 py-0.5 text-[10px] font-medium text-green-700 ring-1 ring-inset ring-green-600/20 dark:bg-green-950/50 dark:text-green-300 dark:ring-green-400/30",children:[(n==null?void 0:n.turns)??t.maxTurns??50," steps"]}),C&&C!=="disabled"&&E.jsx("span",{className:"inline-flex items-center rounded-md bg-violet-50 px-1.5 py-0.5 text-[10px] font-medium text-violet-700 ring-1 ring-inset ring-violet-600/20 dark:bg-violet-950/50 dark:text-violet-300 dark:ring-violet-400/30",children:"think"}),e&&E.jsxs("button",{onClick:N,className:"inline-flex items-center gap-0.5 rounded-md bg-muted px-1.5 py-0.5 text-[10px] font-mono text-muted-foreground ring-1 ring-inset ring-border hover:bg-accent transition-colors",title:`Session: ${e}
|
|
1945
|
+
`?1:0),kind:"command"}),O(0)):Y?(S({query:Y[1],start:Y.index,kind:"mention"}),O(0)):S(null)};return b.useEffect(()=>{const B=()=>S(null);return y&&document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[y]),E.jsxs("div",{className:"relative flex-1 min-w-0",children:[y&&k.length>0&&E.jsx("div",{className:"absolute bottom-full mb-1 left-0 z-50 bg-background border rounded-lg shadow-lg overflow-hidden min-w-[220px] max-h-64 overflow-y-auto",children:k.map((B,P)=>E.jsxs("button",{onMouseDown:M=>{M.preventDefault(),C(B.value)},className:`w-full text-left px-3 py-1.5 text-sm hover:bg-accent transition-colors flex items-center gap-2 ${P===A?"bg-accent":""}`,children:[E.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground shrink-0 w-14",children:(y==null?void 0:y.kind)==="command"?"cmd":B.kind==="skill"?"skill":"file"}),E.jsxs("span",{className:"truncate",children:[E.jsx("span",{className:"text-muted-foreground",children:(y==null?void 0:y.kind)==="command"?"/":"@"}),B.value]})]},`${B.kind}:${B.value}`))}),E.jsx("textarea",{ref:w,value:t,onChange:D,onKeyDown:N,onPaste:i,placeholder:c,disabled:h,rows:f,dir:"auto",className:u})]})}),OS="shraga:draft:";function q0(e,t){const n=OS+(e??"new");t.trim()?localStorage.setItem(n,t):localStorage.removeItem(n)}function $R(e){return localStorage.getItem(OS+(e??"new"))??""}function FR(e){localStorage.removeItem(OS+(e??"new"))}const nwe=b.forwardRef(function({onSend:t,onSteer:n,onQueue:r,onRemoveQueued:i,queue:a,onUpload:l,onCancel:c,disabled:u,busy:f,skills:h=[],workspaceFiles:p=[],sessionId:g,inputCtx:v},w){var U,G;const y=sa(),[S,A]=b.useState(()=>$R(g)),[O,k]=b.useState([]),[T,C]=b.useState(!1),N=b.useRef(null),D=b.useRef(null),B=b.useRef(g);b.useEffect(()=>{var j;if(B.current===g)return;const K=B.current;if(B.current=g,!g){FR(K),q0(void 0,S);return}q0(K,S);const ee=$R(g);A(ee),(j=D.current)==null||j.setValue(ee)},[g]);const P=b.useCallback(K=>{A(K),q0(B.current,K)},[]);b.useImperativeHandle(w,()=>({prefill(K){var ee,j;P(K),(ee=D.current)==null||ee.setValue(K),(j=D.current)==null||j.focus()},setText(K){var ee;P(K),(ee=D.current)==null||ee.setValue(K)},focus(){var K;(K=D.current)==null||K.focus()}}));const M=(K="send")=>{var j;const ee=S.trim();!ee&&O.length===0||(K==="steer"?n(ee):K==="queue"?r(ee):t(ee,O.length>0?O:void 0),A(""),FR(B.current),k([]),(j=D.current)==null||j.setValue(""))},z=typeof window<"u"&&((U=window.matchMedia)==null?void 0:U.call(window,"(pointer: coarse)").matches),R=K=>{if(K.key==="Enter"&&!K.shiftKey&&(!z||K.metaKey||K.ctrlKey)){K.preventDefault(),M(f?"steer":"send");return}if(K.key==="Tab"&&f&&S.trim()){K.preventDefault(),M("queue");return}},H=b.useCallback(async K=>{C(!0);try{const ee=await l(K);ee&&k(j=>[...j,ee])}finally{C(!1)}},[l]),Y=b.useCallback(K=>{const ee=Array.from(K.clipboardData.items);for(const j of ee)if(j.type.startsWith("image/")||j.type==="application/pdf"){const F=j.getAsFile();F&&H(F)}},[H]),q=K=>{var j;const ee=(j=K.target.files)==null?void 0:j[0];ee&&(H(ee),K.target.value="")};return E.jsx("div",{className:"border-t bg-background",style:{paddingBottom:"env(safe-area-inset-bottom)"},children:E.jsxs("div",{className:"max-w-3xl mx-auto px-2 sm:px-4 py-3",children:[(O.length>0||T)&&E.jsxs("div",{className:"flex gap-2 mb-2 flex-wrap items-center",children:[O.map((K,ee)=>E.jsxs("div",{className:"relative group",children:[K.mimeType.startsWith("image/")?E.jsx(kS,{src:K.url,alt:K.name,className:"h-16 w-16 object-cover rounded-lg border"}):E.jsxs("div",{className:"h-16 px-3 flex items-center gap-2 rounded-lg border bg-muted/50 text-xs text-muted-foreground",children:[E.jsx(jw,{className:"w-4 h-4 shrink-0"}),E.jsx("span",{className:"truncate max-w-[120px]",children:K.name})]}),E.jsx("button",{onClick:()=>k(j=>j.filter((F,J)=>J!==ee)),className:"absolute -top-1.5 -right-1.5 bg-destructive text-destructive-foreground rounded-full w-5 h-5 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity shadow-sm",children:E.jsx(ls,{className:"w-3 h-3"})})]},ee)),T&&E.jsx("span",{className:"text-xs text-muted-foreground animate-pulse",children:"Uploading…"})]}),E.jsxs("div",{className:"flex items-center gap-2 bg-muted/50 rounded-xl border px-3 py-2",children:[E.jsx(Me,{variant:"ghost",size:"icon",className:"h-9 w-9 sm:h-8 sm:w-8 shrink-0",onClick:()=>{var K;return(K=N.current)==null?void 0:K.click()},disabled:u,title:"Attach file or image",children:E.jsx(kH,{className:"w-4 h-4"})}),E.jsx("input",{ref:N,type:"file",className:"hidden",onChange:q}),E.jsx(n4,{ref:D,value:S,onChange:P,onKeyDown:R,onPaste:Y,skills:h,workspaceFiles:p,placeholder:f?"Steer or queue…":"Message Claude…",disabled:u,rows:1,className:"w-full bg-transparent border-none outline-none resize-none text-sm py-1.5 placeholder:text-muted-foreground min-h-[28px] max-h-[200px]"}),(G=y.inputAdornments)==null?void 0:G.call(y,v),f?E.jsxs("div",{className:"flex items-center gap-2",children:[S.trim()&&E.jsx(Me,{size:"icon",className:"h-9 w-9 sm:h-8 sm:w-8 shrink-0 rounded-lg",onClick:()=>M("steer"),title:"Steer (inject into current turn)",children:E.jsx(fm,{className:"w-4 h-4"})}),E.jsx(Me,{variant:"destructive",size:"icon",className:"h-9 w-9 sm:h-8 sm:w-8 shrink-0 rounded-lg",onClick:()=>c(),title:"Stop generation",children:E.jsx(hD,{className:"w-3.5 h-3.5"})})]}):E.jsx(Me,{size:"icon",className:"h-9 w-9 sm:h-8 sm:w-8 shrink-0 rounded-lg",onClick:()=>M(),disabled:u||T||!S.trim()&&O.length===0,children:E.jsx(fm,{className:"w-4 h-4"})})]}),a.length>0&&E.jsx("div",{className:"flex gap-1.5 flex-wrap mt-2",children:a.map((K,ee)=>E.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-blue-50 dark:bg-blue-950/40 px-2.5 py-1 text-xs text-blue-700 dark:text-blue-300 ring-1 ring-inset ring-blue-600/20 dark:ring-blue-400/30",children:[E.jsx("span",{className:"truncate max-w-[200px]",children:K}),E.jsx("button",{onClick:()=>i(ee),className:"hover:text-blue-900 dark:hover:text-blue-100",children:E.jsx(ls,{className:"w-3 h-3"})})]},ee))}),E.jsx("p",{className:"text-[10px] text-muted-foreground text-center mt-2",children:f?"Enter to steer (redirect) · Tab to queue (after done) · Shift+Enter for newline":"Enter to send · Shift+Enter for newline · @ for skills · / for commands"})]})})}),rwe={"fb-feed":[1080,1080],"fb-story":[1080,1920],"fb-landscape":[1200,628],"ig-square":[1080,1080],"ig-story":[1080,1920],"ig-landscape":[1080,566],"banner-leaderboard":[728,90],"banner-medium":[300,250]};function iwe({artifacts:e,selectedId:t,sessionId:n,getToken:r,onSelect:i,onClose:a}){var D;const[l,c]=b.useState(!1),[u,f]=b.useState(!1),[h,p]=b.useState(!1),[g,v]=b.useState(1),w=b.useRef(null),y=e.find(B=>B.id===t),S=b.useCallback(()=>{if(!w.current||!y)return;const{clientWidth:B,clientHeight:P}=w.current,M=32,z=B-M,R=P-M,[H,Y]=y.dimensions;v(Math.min(z/H,R/Y,1))},[y]);b.useEffect(()=>{let B=!0;return r().then(P=>fetch("/api/features",{headers:P?{Authorization:`Bearer ${P}`}:{}})).then(P=>P.json()).then(P=>{B&&p(!!P.artifactPngExport)}).catch(P=>console.error("[artifact] features fetch failed:",P)),()=>{B=!1}},[r]),b.useEffect(()=>{S();const B=w.current;if(!B)return;const P=new ResizeObserver(S);return P.observe(B),()=>P.disconnect()},[S]);const A=async()=>{if(y){f(!0);try{const B=await r(),P=await fetch(`/api/artifacts/${n}/${y.id}/export`,{method:"POST",headers:{"Content-Type":"application/json",...B?{Authorization:`Bearer ${B}`}:{}},body:JSON.stringify({dimensions:y.dimensions})});if(!P.ok)throw new Error(await P.text());const M=await P.blob(),z=URL.createObjectURL(M),R=document.createElement("a");R.href=z,R.download=`${y.title.replace(/\s+/g,"-").toLowerCase()}.png`,R.click(),URL.revokeObjectURL(z)}catch(B){console.error("[artifact] export failed:",B)}finally{f(!1)}}},O=y?(D=Object.entries(rwe).find(([,B])=>B[0]===y.dimensions[0]&&B[1]===y.dimensions[1]))==null?void 0:D[0]:null,[k,T]=(y==null?void 0:y.dimensions)??[0,0],C=k*g,N=T*g;return E.jsxs("div",{className:Xe("flex flex-col border-l bg-background transition-all",l?"fixed inset-0 z-50":"fixed inset-0 z-50 sm:relative sm:inset-auto sm:z-auto sm:w-[480px] sm:shrink-0"),children:[E.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 border-b bg-muted/30",children:[E.jsx(Me,{variant:"ghost",size:"icon",className:"h-7 w-7 sm:hidden shrink-0",onClick:a,title:"Back to chat",children:E.jsx(sD,{className:"w-4 h-4"})}),e.length>1&&E.jsx("select",{className:"text-xs bg-transparent border rounded px-1 py-0.5 max-w-[160px] truncate",value:t??"",onChange:B=>i(B.target.value),children:e.map(B=>E.jsx("option",{value:B.id,children:B.title},B.id))}),e.length<=1&&y&&E.jsx("span",{className:"text-xs font-medium truncate max-w-[160px]",children:y.title}),y&&E.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[O??`${k}×${T}`,g<1&&` · ${Math.round(g*100)}%`]}),E.jsx("div",{className:"flex-1"}),h&&E.jsx(Me,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:A,disabled:!y||u,title:"Export PNG",children:u?E.jsx("span",{className:"w-3 h-3 border-2 border-current border-t-transparent rounded-full animate-spin"}):E.jsx(xH,{className:"w-3.5 h-3.5"})}),E.jsx(Me,{variant:"ghost",size:"icon",className:"h-6 w-6 hidden sm:inline-flex",onClick:()=>c(!l),title:l?"Minimize":"Maximize",children:l?E.jsx(zw,{className:"w-3.5 h-3.5"}):E.jsx(Lw,{className:"w-3.5 h-3.5"})}),E.jsx(Me,{variant:"ghost",size:"icon",className:"h-6 w-6 hidden sm:inline-flex",onClick:a,title:"Close",children:E.jsx(ls,{className:"w-3.5 h-3.5"})})]}),E.jsx("div",{ref:w,className:"flex-1 overflow-hidden flex items-center justify-center bg-muted/10",children:y?E.jsx("div",{style:{width:C,height:N},children:E.jsx("iframe",{src:`/api/artifacts/${n}/${y.id}`,sandbox:"allow-scripts",className:"border shadow-sm bg-white origin-top-left",style:{width:k,height:T,transform:`scale(${g})`},title:y.title})}):E.jsx("p",{className:"text-sm text-muted-foreground",children:"No artifact selected"})})]})}const vv=b.forwardRef(({className:e,...t},n)=>E.jsx("textarea",{className:Xe("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 resize-none",e),ref:n,...t}));vv.displayName="Textarea";const awe=[{value:"",label:"Default (claude-sonnet-5)"},{value:"claude-fable-5",label:"Fable 5 — frontier, most capable"},{value:"claude-opus-5",label:"Opus 5 — most capable, best for complex/agentic tasks"},{value:"claude-opus-4-8",label:"Opus 4.8"},{value:"claude-opus-4-7",label:"Opus 4.7"},{value:"claude-opus-4-6",label:"Opus 4.6"},{value:"claude-sonnet-5",label:"Sonnet 5 — balanced speed & intelligence"},{value:"claude-sonnet-4-6",label:"Sonnet 4.6"},{value:"claude-haiku-4-5",label:"Haiku 4.5 — fastest"}],owe=[{value:"acceptEdits",label:"Accept Edits (auto-approve file changes)"},{value:"plan",label:"Plan (read-only, suggest changes)"},{value:"bypassPermissions",label:"Bypass All (dangerous — no prompts)"}];function lwe({getToken:e,onSaved:t,trigger:n,sessionId:r,sessionDirectives:i,onDirectivesSaved:a}){var P;const l=sa(),[c,u]=b.useState({}),[f,h]=b.useState(!1),[p,g]=b.useState(!1),[v,w]=b.useState([]),[y,S]=b.useState(!1),A=b.useRef({});b.useEffect(()=>{f&&e().then(M=>{M&&(fetch("/api/config",{headers:{Authorization:`Bearer ${M}`}}).then(z=>z.json()).then(z=>{A.current=z;const R=r?i:void 0;u({...z,...(R==null?void 0:R.engine)!==void 0?{engine:R.engine}:{},...(R==null?void 0:R.model)!==void 0?{model:R.model}:{},...(R==null?void 0:R.turns)!==void 0?{maxTurns:R.turns}:{},...(R==null?void 0:R.thinking)!==void 0?{thinking:R.thinking}:{}})}).catch(()=>{}),fetch("/api/engines",{headers:{Authorization:`Bearer ${M}`}}).then(z=>z.json()).then(z=>{w(z.engines??[]),S(z.multiEngine??!1)}).catch(()=>{}))})},[f,e,r,i]);const O=async()=>{g(!0);const z={Authorization:`Bearer ${await e()??""}`,"Content-Type":"application/json"};try{if(r){const R={engine:c.engine,model:c.model,turns:c.maxTurns,thinking:c.thinking},H=await fetch(`/api/sessions/${r}/directives`,{method:"PUT",headers:z,body:JSON.stringify(R)}).then(q=>q.json()).catch(q=>(console.warn("[config] directives save failed",q),null));H!=null&&H.directives&&(a==null||a(H.directives));const Y={...c,engine:A.current.engine,model:A.current.model,maxTurns:A.current.maxTurns,thinking:A.current.thinking};await fetch("/api/config",{method:"PUT",headers:z,body:JSON.stringify(Y)}),t==null||t(Y)}else await fetch("/api/config",{method:"PUT",headers:z,body:JSON.stringify(c)}),t==null||t(c);h(!1)}finally{g(!1)}},k=c.engine||"claude-code",T=v.find(M=>M.name===k),C=(T==null?void 0:T.models)??awe;b.useEffect(()=>{!T||!C.length||C.some(M=>(M.value||"")===(c.model??""))||u(M=>({...M,model:C[0].value||void 0}))},[T,C,c.model]);const D=C.some(M=>M.provider)?Array.from(C.reduce((M,z)=>{const R=z.provider||"default";return M.has(R)||M.set(R,[]),M.get(R).push(z),M},new Map)):null,B="flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2";return E.jsxs(el,{open:f,onOpenChange:h,children:[E.jsx(Sd,{asChild:!0,children:n||E.jsx(Me,{variant:"ghost",size:"icon",title:"Agent Config",children:E.jsx(IH,{className:"w-4 h-4"})})}),E.jsxs(Va,{className:"max-w-lg",children:[E.jsx(cs,{children:E.jsx(tl,{children:"Agent Configuration"})}),E.jsxs(Cj,{className:"space-y-4",children:[r&&E.jsxs("p",{className:"text-xs text-muted-foreground rounded-md bg-muted/50 px-3 py-2",children:["Engine, Model, Max Turns & Thinking apply to ",E.jsx("strong",{children:"this conversation"}),". Other settings are global defaults for new sessions."]}),y&&E.jsxs("div",{children:[E.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Engine"}),E.jsx("select",{value:c.engine??"",onChange:M=>{const z=M.target.value||void 0;u(R=>({...R,engine:z,model:void 0}))},className:B,children:v.map(M=>E.jsx("option",{value:M.name,children:M.name==="claude-code"?"Claude Code (default)":M.name},M.name))})]}),E.jsxs("div",{children:[E.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Model"}),E.jsx("select",{value:c.model??"",onChange:M=>u(z=>({...z,model:M.target.value||void 0})),className:B,children:D?D.map(([M,z])=>E.jsx("optgroup",{label:M.charAt(0).toUpperCase()+M.slice(1),children:z.map(R=>E.jsx("option",{value:R.value,children:R.label},R.value))},M)):C.map(M=>E.jsx("option",{value:M.value,children:M.label},M.value))})]}),(P=l.settingsSections)==null?void 0:P.call(l,{getToken:e,sessionId:r}),E.jsxs("div",{children:[E.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Permission Mode"}),E.jsx("select",{value:c.permissionMode??"acceptEdits",onChange:M=>u(z=>({...z,permissionMode:M.target.value})),className:B,children:owe.map(M=>E.jsx("option",{value:M.value,children:M.label},M.value))})]}),E.jsxs("div",{children:[E.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Max Turns"}),E.jsx(In,{type:"number",min:1,max:200,value:c.maxTurns??50,onChange:M=>u(z=>({...z,maxTurns:Number(M.target.value)||50}))})]}),E.jsxs("div",{children:[E.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Thinking"}),E.jsxs("select",{value:c.thinking??"",onChange:M=>u(z=>({...z,thinking:M.target.value||void 0})),className:B,children:[E.jsx("option",{value:"",children:"Default (off)"}),E.jsx("option",{value:"adaptive",children:"Adaptive (Claude decides)"}),E.jsx("option",{value:"enabled",children:"Enabled (always think)"}),E.jsx("option",{value:"disabled",children:"Disabled"})]})]}),E.jsxs("div",{children:[E.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Effort"}),E.jsxs("select",{value:c.effort??"",onChange:M=>u(z=>({...z,effort:M.target.value||void 0})),className:B,children:[E.jsx("option",{value:"",children:"Default"}),E.jsx("option",{value:"low",children:"Low — fast"}),E.jsx("option",{value:"medium",children:"Medium"}),E.jsx("option",{value:"high",children:"High"}),E.jsx("option",{value:"max",children:"Max"})]})]}),E.jsxs("div",{children:[E.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Allowed Tools"}),E.jsx(In,{placeholder:"Read, Edit, Bash, WebSearch, Glob, LS",value:(c.allowedTools??[]).join(", "),onChange:M=>u(z=>({...z,allowedTools:M.target.value.split(",").map(R=>R.trim()).filter(Boolean)}))}),E.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Comma-separated list of tools Claude can use"})]}),E.jsxs("div",{className:"flex items-center justify-between",children:[E.jsxs("div",{children:[E.jsx("label",{className:"text-sm font-medium",children:"Skill Discovery"}),E.jsx("p",{className:"text-xs text-muted-foreground",children:"Index all skills + auto-inject on trigger match"})]}),E.jsx("button",{type:"button",role:"switch","aria-checked":c.skillDiscovery!==!1,onClick:()=>u(M=>({...M,skillDiscovery:M.skillDiscovery===!1})),className:`relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors ${c.skillDiscovery!==!1?"bg-primary":"bg-muted"}`,children:E.jsx("span",{className:`pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform ${c.skillDiscovery!==!1?"translate-x-5":"translate-x-0"}`})})]}),E.jsxs("div",{children:[E.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"System Prompt (optional)"}),E.jsx(vv,{placeholder:"Additional instructions appended to Claude's system prompt…",value:c.systemPrompt??"",onChange:M=>u(z=>({...z,systemPrompt:M.target.value||void 0})),rows:4})]})]}),E.jsx(Ij,{children:E.jsx(Me,{onClick:O,disabled:p,children:p?"Saving…":"Save Configuration"})})]})]})}function swe({sessionId:e,config:t,sessionDirectives:n,actualModel:r,scheduleId:i,onScheduleClick:a}){const[l,c]=b.useState(!1),u=(n==null?void 0:n.engine)||t.engine||"claude-code",f=r?!r.includes("/"):void 0,h=u==="claude-code"||u==="cursor",g=(f!==void 0&&f===h?r:void 0)||(n==null?void 0:n.model)||t.model||(u==="cursor"?"cursor/composer-2.5":"sonnet-4-6"),v=h?g.replace("claude-",""):`${u} · ${g.replace("claude-","")}`,w=g.includes("/")?g.split("/")[0]:"anthropic",y=u==="claude-code"&&t.claudeAuthSource==="subscription",S=y?"sub":w==="cursor"?"plan":"metered",A=S==="sub"?"bg-emerald-50 text-emerald-700 ring-emerald-600/20 dark:bg-emerald-950/50 dark:text-emerald-300 dark:ring-emerald-400/30":S==="plan"?"bg-amber-50 text-amber-700 ring-amber-600/20 dark:bg-amber-950/50 dark:text-amber-300 dark:ring-amber-400/30":"bg-rose-50 text-rose-700 ring-rose-600/20 dark:bg-rose-950/50 dark:text-rose-300 dark:ring-rose-400/30",O=S==="sub"?"Claude.ai subscription (OAuth login) — no API key in use":S==="plan"?`Runs on your ${w} API key — usage may draw on your ${w} plan/subscription`:`Runs on your ${w} API key — metered per-token billing`,k=t.permissionMode||"acceptEdits",T=k==="bypassPermissions"?"bypass":k==="plan"?"plan":k==="default"?"prompt":"edits",C=(n==null?void 0:n.thinking)||t.thinking,N=()=>{e&&(navigator.clipboard.writeText(e),c(!0),setTimeout(()=>c(!1),1500))};return E.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[E.jsx("span",{className:"inline-flex items-center rounded-md bg-blue-50 px-1.5 py-0.5 text-[10px] font-medium text-blue-700 ring-1 ring-inset ring-blue-600/20 dark:bg-blue-950/50 dark:text-blue-300 dark:ring-blue-400/30",children:v}),E.jsx("span",{title:O,className:`inline-flex items-center rounded-md px-1.5 py-0.5 text-[10px] font-medium ring-1 ring-inset ${A}`,children:y?"sub":`API·${w}`}),E.jsx("span",{className:"inline-flex items-center rounded-md bg-amber-50 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 ring-1 ring-inset ring-amber-600/20 dark:bg-amber-950/50 dark:text-amber-300 dark:ring-amber-400/30",children:T}),E.jsxs("span",{className:"inline-flex items-center rounded-md bg-green-50 px-1.5 py-0.5 text-[10px] font-medium text-green-700 ring-1 ring-inset ring-green-600/20 dark:bg-green-950/50 dark:text-green-300 dark:ring-green-400/30",children:[(n==null?void 0:n.turns)??t.maxTurns??50," steps"]}),C&&C!=="disabled"&&E.jsx("span",{className:"inline-flex items-center rounded-md bg-violet-50 px-1.5 py-0.5 text-[10px] font-medium text-violet-700 ring-1 ring-inset ring-violet-600/20 dark:bg-violet-950/50 dark:text-violet-300 dark:ring-violet-400/30",children:"think"}),e&&E.jsxs("button",{onClick:N,className:"inline-flex items-center gap-0.5 rounded-md bg-muted px-1.5 py-0.5 text-[10px] font-mono text-muted-foreground ring-1 ring-inset ring-border hover:bg-accent transition-colors",title:`Session: ${e}
|
|
1946
1946
|
Click to copy`,children:[e.slice(0,8),l?E.jsx(na,{className:"w-2.5 h-2.5"}):E.jsx(Pw,{className:"w-2.5 h-2.5"})]}),i&&E.jsxs("button",{onClick:a,className:"inline-flex items-center gap-0.5 rounded-md bg-purple-50 px-1.5 py-0.5 text-[10px] font-mono text-purple-700 ring-1 ring-inset ring-purple-600/20 dark:bg-purple-950/50 dark:text-purple-300 dark:ring-purple-400/30 hover:bg-purple-100 dark:hover:bg-purple-950/70 transition-colors",title:"Open schedule details",children:[E.jsx(Dw,{className:"w-2.5 h-2.5"}),i.slice(0,8)]})]})}function cwe({sessionId:e,agentConfig:t,sessionDirectives:n,sessionLastModel:r,sessionScheduleId:i,artifactCount:a,getToken:l,onConfigSaved:c,onDirectivesSaved:u,onFork:f,onToggleArtifacts:h,onScheduleClick:p}){return E.jsxs("div",{className:"flex items-center gap-1.5 px-2 sm:px-3 py-1.5 border-b bg-background/60 overflow-x-auto",children:[E.jsx(swe,{sessionId:e,config:t,sessionDirectives:n,actualModel:r,scheduleId:i,onScheduleClick:p}),E.jsx("div",{className:"flex-1"}),e&&E.jsx(Me,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:f,title:"Fork conversation",children:E.jsx(uD,{className:"w-3.5 h-3.5"})}),E.jsx(lwe,{getToken:l,onSaved:c,sessionId:e,sessionDirectives:n,onDirectivesSaved:u}),a>0&&E.jsx(Me,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:h,title:"Toggle artifacts panel",children:E.jsx(EH,{className:"w-3.5 h-3.5"})})]})}function uwe({nodeId:e,sessionId:t}){var U;const n=Rw(),r=sa(),i=b.useRef(null),[a,l]=b.useState(),[c,u]=b.useState([]),f=b.useRef(void 0),[h,p]=b.useState(t),g=b.useRef(h);g.current=h;const v=b.useRef(t).current,[w,y]=b.useState(),[S,A]=b.useState(),[O,k]=b.useState(),[T,C]=b.useState(!1),N=dJ(h,n.getToken,n.token),D=b.useRef(!1),B=b.useCallback(G=>{n.bumpSidebar(),G!==g.current&&(p(G),n.assignSession(e,G))},[n,e]),P=b.useCallback(G=>{G.type==="artifact"?G.sessionId===g.current&&N.handleArtifactEvent(G):G.type==="directives"?D.current&&k(void 0):G.type==="model_resolved"&&G.sessionId===g.current&&k(G.model)},[n,e,N]),M=cJ(n.socket,{getToken:n.getToken,initialSessionId:t,onNewSession:B,onDirectivesChanged:y,onParticipantsChanged:C,onEvent:P});D.current=M.busy,b.useEffect(()=>{if(!v)return;let G=!1;return(async()=>{try{const ee=await(await Vl(`/api/sessions/${v}/messages`,n.getToken)).json();if(G)return;M.setMessages(iD(ee)),C(Array.isArray(ee.participants)&&ee.participants.length>1),ee.busy&&M.setBusy(!0)}catch(K){G||console.error("[pane] history load failed:",K)}})(),()=>{G=!0}},[v]),b.useEffect(()=>{if(!h){y(void 0),A(void 0),k(void 0);return}Vl(`/api/sessions/${h}/meta`,n.getToken).then(G=>G.json()).then(G=>{y(G.directives),A(G.scheduleId),k(G.lastModel),G.runStatus==="running"&&M.setBusy(!0)}).catch(()=>{})},[h,n.getToken]);const z=b.useCallback((G,K,ee)=>{var j;M.sendMessage(G,g.current,ee,K,(j=f.current)==null?void 0:j.call(f))},[M]),R={sessionId:h,busy:M.busy,socket:n.socket,getToken:n.getToken,setInputCtx:l,setSendOptions:G=>{f.current=G},setInputText:G=>{var K;return(K=i.current)==null?void 0:K.setText(G)},send:(G,K,ee)=>M.sendMessage(G,g.current,void 0,void 0,K,(ee==null?void 0:ee.echo)!==!1),appendAssistant:G=>M.setMessages(K=>K.concat({id:Yo(),role:"assistant",blocks:G})),setStatusItems:u},H=b.useCallback(async G=>{const K=await n.getToken();if(!K)return null;try{return await(await fetch("/api/upload",{method:"POST",headers:{Authorization:`Bearer ${K}`,"x-filename":encodeURIComponent(G.name),"Content-Type":G.type||"application/octet-stream","x-session-id":g.current||""},body:G})).json()}catch(ee){return console.error("[upload] Failed:",ee),null}},[n]),Y=b.useCallback(async G=>{const K=g.current;if(!K)return;const ee=await n.getToken();if(ee)try{const j=await fetch(`/api/sessions/${K}/fork`,{method:"POST",headers:{Authorization:`Bearer ${ee}`,"Content-Type":"application/json"},body:JSON.stringify(G!=null?{truncateAtIndex:G}:{})});if(!j.ok){console.error("[fork] server error:",(await j.json().catch(()=>({}))).error||j.status);return}const{sessionId:F}=await j.json();n.bumpSidebar(),n.openSession(F)}catch(j){console.error("[fork] failed:",j)}},[n]),q=b.useCallback((G,K,ee)=>{if(M.busy)return;const j=M.messages.findIndex(F=>F.id===G);j>=0&&M.setMessages(M.messages.slice(0,j)),z(K,j>=0?j:void 0,ee)},[M,z]);return E.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[(U=r.conversationController)==null?void 0:U.call(r,R),E.jsx(cwe,{sessionId:h,agentConfig:n.agentConfig,sessionDirectives:w,sessionLastModel:O,sessionScheduleId:S,artifactCount:N.artifacts.length,getToken:n.getToken,onConfigSaved:n.setAgentConfig,onDirectivesSaved:y,onFork:()=>Y(),onToggleArtifacts:N.togglePanel,onScheduleClick:n.openSchedules}),E.jsxs("div",{className:"flex-1 flex min-h-0",children:[E.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[E.jsx(Uxe,{messages:M.messages,busy:M.busy,multiParticipant:T,connectionStatus:n.connectionStatus??void 0,onPermissionRespond:M.respondPermission,onQuestionRespond:M.respondQuestion,onReplay:q,onEdit:q,onFork:G=>Y(G),statusItems:c}),E.jsx(nwe,{ref:i,onSend:(G,K)=>z(G,void 0,K),onSteer:M.steer,onQueue:M.addToQueue,onRemoveQueued:M.removeFromQueue,queue:M.queue,onUpload:H,onCancel:M.cancel,disabled:!1,busy:M.busy,skills:n.skills,workspaceFiles:n.workspaceFiles,sessionId:h,inputCtx:a})]}),N.panelOpen&&N.artifacts.length>0&&h&&E.jsx(iwe,{artifacts:N.artifacts,selectedId:N.selectedId,sessionId:h,getToken:n.getToken,onSelect:N.selectArtifact,onClose:N.closePanel})]})]})}const fwe=()=>({command:"",args:[],env:{}});function HR({getToken:e,trigger:t}){const[n,r]=b.useState({}),[i,a]=b.useState(!1),[l,c]=b.useState(!1),[u,f]=b.useState(new Set),h=k=>f(T=>{const C=new Set(T);return C.has(k)?C.delete(k):C.add(k),C});b.useEffect(()=>{i&&e().then(k=>{k&&fetch("/api/mcps",{headers:{Authorization:`Bearer ${k}`}}).then(T=>{if(!T.ok)throw new Error(`HTTP ${T.status}`);return T.json()}).then(r).catch(T=>console.error("[McpManager] fetch failed",T))})},[i,e]);const p=async()=>{c(!0);const k=await e();try{await fetch("/api/mcps",{method:"PUT",headers:{Authorization:`Bearer ${k??""}`,"Content-Type":"application/json"},body:JSON.stringify(n)}),a(!1)}finally{c(!1)}},g=()=>{const k=`server-${Date.now()}`;r(T=>({...T,[k]:fwe()}))},v=k=>{r(T=>{const C={...T};return delete C[k],C})},w=(k,T,C)=>{r(N=>({...N,[k]:{...N[k],[T]:T==="args"?C.split(" "):C}}))},y=(k,T,C)=>{r(N=>{const D={...N[k].env},B=D[T]??"";return delete D[T],C.trim()&&(D[C.trim()]=B),{...N,[k]:{...N[k],env:D}}})},S=(k,T,C)=>{r(N=>({...N,[k]:{...N[k],env:{...N[k].env,[T]:C}}}))},A=(k,T)=>{r(C=>{const N={...C[k].env};return delete N[T],{...C,[k]:{...C[k],env:N}}})},O=k=>{const T=`KEY_${Date.now()}`;r(C=>({...C,[k]:{...C[k],env:{...C[k].env,[T]:""}}}))};return E.jsxs(el,{open:i,onOpenChange:a,children:[E.jsx(Sd,{asChild:!0,children:t||E.jsx(Me,{variant:"ghost",size:"icon",title:"MCP Servers",children:E.jsx(fD,{className:"w-4 h-4"})})}),E.jsxs(Va,{className:"max-w-[95vw] sm:max-w-2xl",children:[E.jsx(cs,{children:E.jsx(tl,{children:"MCP Servers"})}),E.jsxs(Cj,{className:"space-y-4",children:[Object.entries(n).map(([k,T])=>{const C=!!T.readonly;return E.jsxs("div",{className:`border rounded-lg p-4 space-y-3 ${C?"opacity-70":""}`,children:[E.jsxs("div",{className:"flex items-center justify-between",children:[E.jsxs("span",{className:"font-medium text-sm flex items-center gap-1.5",children:[C&&E.jsx(Gp,{className:"w-3 h-3 text-muted-foreground"}),k]}),!C&&E.jsx(Me,{variant:"ghost",size:"icon",onClick:()=>v(k),children:E.jsx(Zf,{className:"w-4 h-4 text-destructive"})})]}),C?E.jsx("p",{className:"text-xs text-muted-foreground",children:"Configured in shraga.config.ts"}):E.jsxs("div",{className:"grid gap-2",children:[E.jsx(In,{placeholder:"Command (e.g. npx)",value:T.command,onChange:N=>w(k,"command",N.target.value)}),E.jsx(In,{placeholder:"Args (space-separated)",value:(T.args||[]).join(" "),onChange:N=>w(k,"args",N.target.value)}),Object.entries(T.env||{}).length>0&&E.jsxs("div",{className:"space-y-2",children:[E.jsx("span",{className:"text-xs text-muted-foreground",children:"Environment variables"}),Object.entries(T.env||{}).map(([N,D])=>E.jsxs("div",{className:"flex gap-2 items-center",children:[E.jsx(In,{className:"w-1/3 font-mono text-xs",value:N,onChange:B=>y(k,N,B.target.value),placeholder:"KEY"}),u.has(`${k}:${N}`)?E.jsx(In,{className:"flex-1 font-mono text-xs",placeholder:"paste new value",autoFocus:!0,onChange:B=>S(k,N,B.target.value),onBlur:()=>h(`${k}:${N}`)}):E.jsx("span",{className:"flex-1 font-mono text-xs text-muted-foreground truncate cursor-pointer px-3 py-2 border rounded-md bg-background hover:border-ring",onClick:()=>h(`${k}:${N}`),title:"Click to change",children:D||"(empty — click to set)"}),E.jsx(Me,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",onClick:()=>A(k,N),children:E.jsx(Zf,{className:"w-3 h-3 text-muted-foreground"})})]},N))]}),E.jsx(Me,{variant:"ghost",size:"sm",className:"text-xs text-muted-foreground",onClick:()=>O(k),children:"+ Add env var"})]})]},k)}),Object.keys(n).length===0&&E.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No MCP servers configured"})]}),E.jsxs(Ij,{className:"flex gap-2",children:[E.jsxs(Me,{variant:"outline",onClick:g,className:"gap-2",children:[E.jsx(bg,{className:"w-4 h-4"})," Add Server"]}),E.jsx(Me,{onClick:p,disabled:l,children:l?"Saving…":"Save"})]})]})]})}function TS(e){return typeof e=="string"?e:e.name}function KR(e){return typeof e=="string"?!1:e.capped===!0||typeof e.capped=="number"&&e.capped>0}function Pf(e,t){return e.some(n=>TS(n)===t)}function qR(e,t){return e.find(n=>TS(n)===t)}async function Da(e,t,n){return fetch(e,{...n,headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json",...(n==null?void 0:n.headers)??{}}})}function GR({getToken:e,onSkillsChange:t,trigger:n}){const[r,i]=b.useState(!1),[a,l]=b.useState([]),[c,u]=b.useState([]),[f,h]=b.useState([]),[p,g]=b.useState(null),[v,w]=b.useState(""),[y,S]=b.useState(!1),[A,O]=b.useState(null),[k,T]=b.useState(""),C=p?c.includes(p):!1,N=async()=>{const q=await e();if(!q)return;const[U,G]=await Promise.all([Da("/api/skills",q),Da("/api/skills-defaults",q)]),K=await U.json(),ee=await G.json();l(K.skills),u(K.builtins),h(ee),t==null||t(K.skills)},D=async q=>{const U=await e();if(!U)return;const K=await(await Da(`/api/skills/${q}`,U)).json();w(K.content),g(q),S(!1)},B=async()=>{if(!p||C)return;const q=await e();q&&(await Da(`/api/skills/${p}`,q,{method:"PUT",body:JSON.stringify({content:v})}),S(!1))},P=async()=>{const q=k.trim().replace(/\s+/g,"-");if(!q)return;const U=await e();if(U){if(A==="create")await Da(`/api/skills/${q}`,U,{method:"PUT",body:JSON.stringify({content:""})}),await N(),await D(q);else if(A==="duplicate"&&p){if(!(await Da(`/api/skills/${p}/duplicate`,U,{method:"POST",body:JSON.stringify({newName:q})})).ok)return;await N(),await D(q)}else if(A==="rename"&&p){if(!(await Da(`/api/skills/${p}/rename`,U,{method:"POST",body:JSON.stringify({newName:q})})).ok)return;await N(),await D(q)}O(null),T("")}},M=async q=>{const U=await e();!U||!(await Da(`/api/skills/${q}`,U,{method:"DELETE"})).ok||(p===q&&(g(null),w("")),await N())},z=async q=>{const U=await e();if(!U)return;const G=Pf(f,q)?f.filter(K=>TS(K)!==q):[...f,q];await Da("/api/skills-defaults",U,{method:"PUT",body:JSON.stringify(G)}),h(G)},R=q=>{O(q),T(q==="rename"&&p?p:q==="duplicate"&&p?`${p}-copy`:"")},H=()=>{O(null),T("")};b.useEffect(()=>{r&&N()},[r]);const Y=A==="create"?"skill-name":A==="rename"?"new-name":"copy-name";return E.jsxs(el,{open:r,onOpenChange:i,children:[E.jsx(Sd,{asChild:!0,children:n||E.jsx(Me,{variant:"ghost",size:"icon",title:"Skills",className:"h-8 w-8",children:E.jsx(ix,{className:"w-4 h-4"})})}),E.jsxs(Va,{className:"max-w-[95vw] sm:max-w-2xl h-[70dvh] sm:h-[520px] flex flex-col gap-0 p-0",children:[E.jsx(cs,{className:"px-4 pt-4 pb-2 border-b shrink-0",children:E.jsxs(tl,{className:"flex items-center gap-2",children:[E.jsx(ix,{className:"w-4 h-4"})," Skills"]})}),E.jsxs("div",{className:"flex flex-col sm:flex-row flex-1 overflow-hidden",children:[E.jsxs("div",{className:`sm:w-52 border-r flex flex-col shrink-0 ${p?"hidden sm:flex":"flex"}`,children:[E.jsx("div",{className:"flex-1 overflow-y-auto py-1",children:a.map(q=>E.jsxs("div",{className:`group flex items-center gap-1.5 px-3 py-1.5 cursor-pointer text-sm hover:bg-accent transition-colors ${p===q?"bg-accent font-medium":""}`,onClick:()=>D(q),children:[E.jsx("button",{className:`shrink-0 transition-colors ${Pf(f,q)?"text-amber-500":"text-muted-foreground/30 hover:text-amber-400"}`,onClick:U=>{U.stopPropagation(),z(q)},title:Pf(f,q)?"Remove from defaults":"Set as default (always active)",children:E.jsx(WO,{className:`w-3 h-3 ${Pf(f,q)?"fill-current":""}`})}),E.jsxs("span",{className:"truncate flex-1",children:["@",q]}),c.includes(q)&&E.jsx("span",{title:"Built-in (read-only)",children:E.jsx(Gp,{className:"w-2.5 h-2.5 text-muted-foreground/40 shrink-0"})}),!c.includes(q)&&E.jsx("button",{className:"opacity-0 group-hover:opacity-100 text-muted-foreground hover:text-destructive transition-opacity shrink-0",onClick:U=>{U.stopPropagation(),M(q)},title:"Delete",children:E.jsx(Zf,{className:"w-3 h-3"})})]},q))}),E.jsx("div",{className:"border-t p-2",children:A?E.jsxs("div",{className:"flex gap-1",children:[E.jsx(In,{value:k,onChange:q=>T(q.target.value),onKeyDown:q=>{q.key==="Enter"&&P(),q.key==="Escape"&&H()},placeholder:Y,className:"h-7 text-xs",autoFocus:!0}),E.jsx(Me,{size:"icon",className:"h-7 w-7 shrink-0",onClick:P,children:E.jsx(na,{className:"w-3 h-3"})}),E.jsx(Me,{size:"icon",variant:"ghost",className:"h-7 w-7 shrink-0",onClick:H,children:E.jsx(ls,{className:"w-3 h-3"})})]}):E.jsxs(Me,{variant:"outline",size:"sm",className:"w-full h-7 text-xs",onClick:()=>R("create"),children:[E.jsx(bg,{className:"w-3 h-3 mr-1"})," New skill"]})})]}),E.jsx("div",{className:`flex-1 flex flex-col overflow-hidden ${p?"":"hidden sm:flex"}`,children:p?E.jsxs(E.Fragment,{children:[E.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b text-sm shrink-0",children:[E.jsxs("div",{className:"flex items-center gap-0.5 font-medium",children:[E.jsx("button",{className:"sm:hidden mr-1.5 text-muted-foreground",onClick:()=>{g(null),w(""),S(!1)},children:E.jsx(sD,{className:"w-4 h-4"})}),E.jsx("span",{className:"text-muted-foreground",children:"@"}),E.jsx("span",{children:p})]}),E.jsxs("div",{className:"flex items-center gap-1.5",children:[C&&E.jsxs("span",{className:"text-[10px] text-muted-foreground bg-muted px-1.5 py-0.5 rounded font-medium flex items-center gap-0.5",children:[E.jsx(Gp,{className:"w-2.5 h-2.5"})," read-only"]}),Pf(f,p)&&E.jsxs(E.Fragment,{children:[E.jsx("span",{className:"text-[10px] text-amber-600 bg-amber-50 dark:bg-amber-950/50 dark:text-amber-400 px-1.5 py-0.5 rounded font-medium",children:"default"}),E.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${KR(qR(f,p))?"text-blue-600 bg-blue-50 dark:bg-blue-950/50 dark:text-blue-400":"text-emerald-600 bg-emerald-50 dark:bg-emerald-950/50 dark:text-emerald-400"}`,children:KR(qR(f,p))?"capped":"full"})]}),E.jsx(Me,{variant:"ghost",size:"sm",className:"h-6 text-xs px-1.5",onClick:()=>R("duplicate"),title:"Duplicate",children:E.jsx(Pw,{className:"w-3 h-3"})}),!C&&E.jsx(Me,{variant:"ghost",size:"sm",className:"h-6 text-xs px-1.5",onClick:()=>R("rename"),title:"Rename",children:E.jsx(Bw,{className:"w-3 h-3"})}),y&&!C&&E.jsxs(Me,{size:"sm",className:"h-6 text-xs",onClick:B,children:[E.jsx(na,{className:"w-3 h-3 mr-1"})," Save"]})]})]}),E.jsx(vv,{value:v,onChange:q=>{C||(w(q.target.value),S(!0))},readOnly:C,className:`flex-1 resize-none rounded-none border-0 font-mono text-xs focus-visible:ring-0 ${C?"opacity-70 cursor-default":""}`,placeholder:"Write the skill instructions here…"})]}):E.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-muted-foreground text-sm gap-1",children:[E.jsx("p",{children:"Select or create a skill"}),E.jsxs("p",{className:"text-xs",children:[E.jsx(WO,{className:"w-3 h-3 inline fill-amber-500 text-amber-500"})," = injected in every conversation"]}),E.jsxs("p",{className:"text-xs",children:[E.jsx(Gp,{className:"w-3 h-3 inline"})," = built-in, duplicate to customize"]})]})})]})]})]})}async function jf(e,t,n){const r=await t(),i=await fetch(e,{...n,headers:{Authorization:`Bearer ${r??""}`,"Content-Type":"application/json",...n==null?void 0:n.headers}});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.error||`${i.status} ${i.statusText}`)}return i.json()}function dwe(e,t,n=0){const[r,i]=b.useState([]),[a,l]=b.useState([]),[c,u]=b.useState(!1),[f,h]=b.useState(!1),[p,g]=b.useState(null),v=b.useCallback(async()=>{h(!0),g(null);try{const O=await jf("/api/modules",e);i(O.installed??[]),l(O.available??[]),u(!1)}catch(O){/^404\b/.test(O.message)?u(!0):g(O.message)}finally{h(!1)}},[e]);b.useEffect(()=>{t&&v()},[t,v,n]);const w=b.useCallback(async O=>{await jf("/api/modules/install",e,{method:"POST",body:JSON.stringify(O)}),await v()},[e,v]),y=b.useCallback(async(O,k)=>{await jf(`/api/modules/${O}/${k?"enable":"disable"}`,e,{method:"POST"}),await v()},[e,v]),S=b.useCallback(async(O,k)=>{await jf(`/api/modules/${O}/config`,e,{method:"PUT",body:JSON.stringify({config:k})}),await v()},[e,v]),A=b.useCallback(async O=>{await jf(`/api/modules/${O}`,e,{method:"DELETE"}),await v()},[e,v]);return{installed:r,available:a,unsupported:c,loading:f,error:p,refresh:v,install:w,toggle:y,updateConfig:S,uninstall:A}}function r4({checked:e,onChange:t,title:n,disabled:r}){return E.jsx("button",{type:"button",role:"switch","aria-checked":e,title:n,disabled:r,onClick:()=>t(!e),className:`relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${e?"bg-primary":"bg-muted"}`,children:E.jsx("span",{className:`pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform ${e?"translate-x-5":"translate-x-0"}`})})}function VR(e){const t=Object.keys(e.config??{});return t.length===0?"":t.slice(0,3).map(n=>`${n}: ${String(e.config[n])}`).join(" · ")+(t.length>3?` · +${t.length-3}`:"")}function hwe({schema:e,config:t,onSave:n,saving:r}){const[i,a]=b.useState(()=>{const h={};for(const[p,g]of Object.entries(e)){const v=t[p]??g.default;h[p]=g.type==="boolean"?!!v:v==null?"":String(v)}return h}),[l,c]=b.useState({}),u=(h,p)=>{a(g=>({...g,[h]:p})),c(g=>g[h]?{...g,[h]:""}:g)},f=()=>{const h={},p={};for(const[g,v]of Object.entries(e)){const w=i[g];if(v.type==="boolean"){const S=!!w;if(!S&&t[g]===void 0&&typeof v.default!="boolean")continue;h[g]=S;continue}const y=String(w??"").trim();if(y===""){(v.type==="number"&&typeof v.default=="number"&&Number.isFinite(v.default)||v.type==="string"&&typeof v.default=="string"&&v.default!=="")&&(h[g]=v.default);continue}if(v.type==="number"){const S=Number(y);if(!Number.isFinite(S)){p[g]="Not a number";continue}h[g]=S}else h[g]=y}if(Object.values(p).some(Boolean)){c(p);return}c({}),n(h)};return E.jsxs("div",{className:"space-y-2 pt-2",children:[Object.entries(e).map(([h,p])=>E.jsxs("div",{className:"flex items-center gap-2",children:[E.jsx("label",{className:"text-xs w-36 shrink-0 truncate",title:p.description||h,children:h}),p.type==="boolean"?E.jsx(r4,{checked:!!i[h],onChange:g=>u(h,g)}):E.jsxs("div",{className:"flex-1 min-w-0",children:[E.jsx(In,{type:"text",inputMode:p.type==="number"?"decimal":void 0,value:String(i[h]??""),onChange:g=>u(h,g.target.value),className:`h-7 text-xs w-full ${l[h]?"border-destructive":""}`,placeholder:p.description}),l[h]&&E.jsx("p",{className:"text-[10px] text-destructive mt-0.5",children:l[h]})]})]},h)),E.jsxs(Me,{size:"sm",className:"h-6 text-xs",disabled:r,onClick:f,children:[r?E.jsx(Xf,{className:"w-3 h-3 mr-1 animate-spin"}):E.jsx(na,{className:"w-3 h-3 mr-1"})," Save config"]})]})}function WR({getToken:e,trigger:t}){const[n,r]=b.useState(!1),{installed:i,available:a,unsupported:l,loading:c,error:u,install:f,toggle:h,updateConfig:p,uninstall:g}=dwe(e,n),[v,w]=b.useState(null),[y,S]=b.useState(null),[A,O]=b.useState(null),k=async(C,N)=>{if(!y){S(C),O(null);try{await N()}catch(D){O(D.message)}finally{S(null)}}},T=a.filter(C=>!C.installed);return E.jsxs(el,{open:n,onOpenChange:r,children:[E.jsx(Sd,{asChild:!0,children:t||E.jsx(Me,{variant:"ghost",size:"icon",title:"Modules",className:"h-8 w-8",children:E.jsx(rx,{className:"w-4 h-4"})})}),E.jsxs(Va,{className:"max-w-[95vw] sm:max-w-2xl h-[70dvh] sm:h-[520px] flex flex-col gap-0 p-0",children:[E.jsx(cs,{className:"px-4 pt-4 pb-2 border-b shrink-0",children:E.jsxs(tl,{className:"flex items-center gap-2",children:[E.jsx(rx,{className:"w-4 h-4"})," Modules"]})}),E.jsxs("div",{className:"flex-1 overflow-y-auto p-3 space-y-4",children:[l&&E.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"This server does not support modules yet."}),(u||A)&&E.jsx("p",{className:"text-xs text-destructive",children:A||u}),c&&i.length===0&&!l&&E.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"Loading…"}),!l&&!c&&i.length===0&&T.length===0&&!u&&E.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No modules available."}),i.length>0&&E.jsxs("div",{className:"space-y-2",children:[E.jsx("h3",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Installed"}),i.map(C=>{const N=v===C.name,D=C.configSchema&&Object.keys(C.configSchema).length>0,B=[C.skillCount?`provides ${C.skillCount} skill${C.skillCount===1?"":"s"}`:"",C.scheduleCount?`${C.scheduleCount} schedule${C.scheduleCount===1?"":"s"}`:""].filter(Boolean).join(", ");return E.jsxs("div",{className:"border rounded-lg p-3 space-y-1",children:[E.jsxs("div",{className:"flex items-center gap-2",children:[E.jsx(r4,{checked:C.enabled,onChange:P=>k(`toggle-${C.name}`,()=>h(C.name,P)),title:C.enabled?"Disable":"Enable",disabled:y===`toggle-${C.name}`}),E.jsx("span",{className:"font-medium text-sm truncate",children:C.name}),E.jsxs("span",{className:"text-[10px] font-mono px-1.5 py-0.5 rounded bg-muted text-muted-foreground shrink-0",children:["v",C.version]}),!C.enabled&&E.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground shrink-0",children:"disabled"}),E.jsx("div",{className:"flex-1"}),y===`toggle-${C.name}`&&E.jsx(Xf,{className:"w-3 h-3 animate-spin text-muted-foreground"}),(D||C.readme)&&E.jsx("button",{className:"text-muted-foreground hover:text-foreground transition-colors",onClick:()=>w(N?null:C.name),title:"Details",children:N?E.jsx(hH,{className:"w-3.5 h-3.5"}):E.jsx(sl,{className:"w-3.5 h-3.5"})}),E.jsx("button",{className:"text-muted-foreground hover:text-destructive transition-colors",onClick:()=>{confirm(`Uninstall module "${C.name}"? Its skills and schedules will be removed (seeds/data stay).`)&&k(`rm-${C.name}`,()=>g(C.name))},title:"Uninstall",children:E.jsx(Zf,{className:"w-3.5 h-3.5"})})]}),C.description&&E.jsx("p",{className:"text-xs text-muted-foreground",children:C.description}),B&&E.jsx("p",{className:"text-[10px] text-muted-foreground",children:B}),!N&&VR(C)&&E.jsx("p",{className:"text-[10px] font-mono text-muted-foreground truncate",children:VR(C)}),N&&C.readme&&E.jsx("pre",{className:"text-[11px] text-muted-foreground whitespace-pre-wrap font-sans bg-muted/40 rounded p-2 max-h-48 overflow-y-auto",children:C.readme}),N&&D&&E.jsx(hwe,{schema:C.configSchema,config:C.config,saving:y===`cfg-${C.name}`,onSave:P=>k(`cfg-${C.name}`,()=>p(C.name,P))},JSON.stringify(C.config))]},C.name)})]}),T.length>0&&E.jsxs("div",{className:"space-y-2",children:[E.jsx("h3",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Available"}),T.map(C=>E.jsxs("div",{className:"border rounded-lg p-3 flex items-center gap-2",children:[E.jsxs("div",{className:"min-w-0 flex-1",children:[E.jsxs("div",{className:"flex items-center gap-2",children:[E.jsx("span",{className:"font-medium text-sm truncate",children:C.name}),E.jsxs("span",{className:"text-[10px] font-mono px-1.5 py-0.5 rounded bg-muted text-muted-foreground shrink-0",children:["v",C.version]})]}),C.description&&E.jsx("p",{className:"text-xs text-muted-foreground",children:C.description})]}),E.jsxs(Me,{size:"sm",variant:"outline",className:"h-7 text-xs shrink-0",disabled:y===`install-${C.name}`,onClick:()=>k(`install-${C.name}`,()=>f({name:C.name})),children:[y===`install-${C.name}`?E.jsx(Xf,{className:"w-3 h-3 mr-1 animate-spin"}):E.jsx(cD,{className:"w-3 h-3 mr-1"}),"Install"]})]},C.name))]})]})]})]})}async function $l(e,t,n){const r=await t(),i=await fetch(e,{...n,headers:{Authorization:`Bearer ${r??""}`,"Content-Type":"application/json",...n==null?void 0:n.headers}});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.error||`${i.status} ${i.statusText}`)}return i.json()}function pwe(e,t,n=0){const[r,i]=b.useState([]),[a,l]=b.useState(new Set),[c,u]=b.useState(!1),[f,h]=b.useState(null),p=b.useCallback(async()=>{u(!0),h(null);try{const O=await $l("/api/schedules",e);i(O.schedules),l(new Set(O.runningIds))}catch(O){h(O.message)}finally{u(!1)}},[e]);b.useEffect(()=>{t&&p()},[t,p,n]);const g=b.useCallback(async O=>{const k=await $l("/api/schedules",e,{method:"POST",body:JSON.stringify(O)});return await p(),k},[e,p]),v=b.useCallback(async(O,k)=>{const T=await $l(`/api/schedules/${O}`,e,{method:"PUT",body:JSON.stringify(k)});return await p(),T},[e,p]),w=b.useCallback(async O=>{await $l(`/api/schedules/${O}`,e,{method:"DELETE"}),await p()},[e,p]),y=b.useCallback(async(O,k)=>{await $l(`/api/schedules/${O}/toggle`,e,{method:"POST",body:JSON.stringify({enabled:k})}),await p()},[e,p]),S=b.useCallback(async(O,k)=>{const T=await $l(`/api/schedules/${O}/run`,e,{method:"POST",body:JSON.stringify(k?{override:k}:{})});return await p(),T.sessionId},[e,p]),A=b.useCallback(async O=>{await $l(`/api/schedules/${O}/cancel`,e,{method:"POST"}),await p()},[e,p]);return{schedules:r,serverRunningIds:a,loading:c,error:f,refresh:p,create:g,update:v,remove:w,toggle:y,runNow:S,cancelRun:A}}var G0={exports:{}},YR;function mwe(){return YR||(YR=1,(function(e,t){(function(r,i){e.exports=i()})(globalThis,()=>(()=>{var n={949(l,c,u){Object.defineProperty(c,"__esModule",{value:!0}),c.CronParser=void 0;var f=u(515),h=(function(){function p(g,v,w){v===void 0&&(v=!0),w===void 0&&(w=!1),this.expression=g,this.dayOfWeekStartIndexZero=v,this.monthStartIndexZero=w}return p.prototype.parse=function(){var g,v,w=(g=this.expression)!==null&&g!==void 0?g:"";if(w==="@reboot")return v=["@reboot","","","","","",""],v;if(w.startsWith("@")){var y=this.parseSpecial(this.expression);v=this.extractParts(y)}else v=this.extractParts(this.expression);return this.normalize(v),this.validate(v),v},p.prototype.parseSpecial=function(g){var v={"@yearly":"0 0 1 1 *","@annually":"0 0 1 1 *","@monthly":"0 0 1 * *","@weekly":"0 0 * * 0","@daily":"0 0 * * *","@midnight":"0 0 * * *","@hourly":"0 * * * *","@reboot":"@reboot"},w=v[g];if(!w)throw new Error("Unknown special expression.");return w},p.prototype.extractParts=function(g){if(!this.expression)throw new Error("cron expression is empty");for(var v=g.trim().split(/[ ]+/),w=0;w<v.length;w++)if(v[w].includes(",")){var y=v[w].split(",").map(function(A){return A.trim()}).filter(function(A){return A!==""}).map(function(A){return isNaN(Number(A))?A:Number(A)}).filter(function(A){return A!==null&&A!==""});y.length===0&&y.push("*"),y.sort(function(A,O){return A!==null&&O!==null?A-O:0}),v[w]=y.map(function(A){return A!==null?A.toString():""}).join(",")}if(v.length<5)throw new Error("Expression has only ".concat(v.length," part").concat(v.length==1?"":"s",". At least 5 parts are required."));if(v.length==5)v.unshift(""),v.push("");else if(v.length==6){var S=/\d{4}$/.test(v[5])||v[4]=="?"||v[2]=="?";S?v.unshift(""):v.push("")}else if(v.length>7)throw new Error("Expression has ".concat(v.length," parts; too many!"));return v},p.prototype.normalize=function(g){var v=this;if(g[3]=g[3].replace("?","*"),g[5]=g[5].replace("?","*"),g[2]=g[2].replace("?","*"),g[0].indexOf("0/")==0&&(g[0]=g[0].replace("0/","*/")),g[1].indexOf("0/")==0&&(g[1]=g[1].replace("0/","*/")),g[2].indexOf("0/")==0&&(g[2]=g[2].replace("0/","*/")),g[3].indexOf("1/")==0&&(g[3]=g[3].replace("1/","*/")),g[4].indexOf("1/")==0&&(g[4]=g[4].replace("1/","*/")),g[6].indexOf("1/")==0&&(g[6]=g[6].replace("1/","*/")),g[5]=g[5].replace(/(^\d)|([^#/\s]\d)/g,function(C){var N=C.replace(/\D/,""),D=N;return v.dayOfWeekStartIndexZero?N=="7"&&(D="0"):D=(parseInt(N)-1).toString(),C.replace(N,D)}),g[5]=="L"&&(g[5]="6"),g[3]=="?"&&(g[3]="*"),g[3].indexOf("W")>-1&&(g[3].indexOf(",")>-1||g[3].indexOf("-")>-1))throw new Error("The 'W' character can be specified only when the day-of-month is a single day, not a range or list of days.");var w={SUN:0,MON:1,TUE:2,WED:3,THU:4,FRI:5,SAT:6};for(var y in w)g[5]=g[5].replace(new RegExp(y,"gi"),w[y].toString());g[4]=g[4].replace(/(^\d{1,2})|([^#/\s]\d{1,2})/g,function(C){var N=C.replace(/\D/,""),D=N;return v.monthStartIndexZero&&(D=(parseInt(N)+1).toString()),C.replace(N,D)});var S={JAN:1,FEB:2,MAR:3,APR:4,MAY:5,JUN:6,JUL:7,AUG:8,SEP:9,OCT:10,NOV:11,DEC:12};for(var A in S)g[4]=g[4].replace(new RegExp(A,"gi"),S[A].toString());g[0]=="0"&&(g[0]=""),!/\*|\-|\,|\//.test(g[2])&&(/\*|\//.test(g[1])||/\*|\//.test(g[0]))&&(g[2]+="-".concat(g[2]));for(var O=0;O<g.length;O++)if(g[O].indexOf(",")!=-1&&(g[O]=g[O].split(",").filter(function(C){return C!==""}).join(",")||"*"),g[O]=="*/1"&&(g[O]="*"),g[O].indexOf("/")>-1&&!/^\*|\-|\,/.test(g[O])){var k=null;switch(O){case 4:k="12";break;case 5:k="6";break;case 6:k="9999";break;default:k=null;break}if(k!==null){var T=g[O].split("/");g[O]="".concat(T[0],"-").concat(k,"/").concat(T[1])}}},p.prototype.validate=function(g){var v="0-9,\\-*/";this.validateOnlyExpectedCharactersFound(g[0],v),this.validateOnlyExpectedCharactersFound(g[1],v),this.validateOnlyExpectedCharactersFound(g[2],v),this.validateOnlyExpectedCharactersFound(g[3],"0-9,\\-*/LW"),this.validateOnlyExpectedCharactersFound(g[4],v),this.validateOnlyExpectedCharactersFound(g[5],"0-9,\\-*/L#"),this.validateOnlyExpectedCharactersFound(g[6],v),this.validateAnyRanges(g)},p.prototype.validateAnyRanges=function(g){f.default.secondRange(g[0]),f.default.minuteRange(g[1]),f.default.hourRange(g[2]),f.default.dayOfMonthRange(g[3]),f.default.monthRange(g[4],this.monthStartIndexZero),f.default.dayOfWeekRange(g[5],this.dayOfWeekStartIndexZero)},p.prototype.validateOnlyExpectedCharactersFound=function(g,v){var w=g.match(new RegExp("[^".concat(v,"]+"),"gi"));if(w&&w.length)throw new Error("Expression contains invalid values: '".concat(w.toString(),"'"))},p})();c.CronParser=h},333(l,c,u){Object.defineProperty(c,"__esModule",{value:!0}),c.ExpressionDescriptor=void 0;var f=u(823),h=u(949),p=(function(){function g(v,w){if(this.expression=v,this.options=w,this.expressionParts=new Array(5),!this.options.locale&&g.defaultLocale&&(this.options.locale=g.defaultLocale),!g.locales[this.options.locale]){var y=Object.keys(g.locales)[0];console.warn("Locale '".concat(this.options.locale,"' could not be found; falling back to '").concat(y,"'.")),this.options.locale=y}this.i18n=g.locales[this.options.locale],w.use24HourTimeFormat===void 0&&(w.use24HourTimeFormat=this.i18n.use24HourTimeFormatByDefault())}return g.toString=function(v,w){var y=w===void 0?{}:w,S=y.throwExceptionOnParseError,A=S===void 0?!0:S,O=y.verbose,k=O===void 0?!1:O,T=y.dayOfWeekStartIndexZero,C=T===void 0?!0:T,N=y.monthStartIndexZero,D=N===void 0?!1:N,B=y.use24HourTimeFormat,P=y.trimHoursLeadingZero,M=P===void 0?!1:P,z=y.locale,R=z===void 0?null:z,H=y.logicalAndDayFields,Y=H===void 0?!1:H,q={throwExceptionOnParseError:A,verbose:k,dayOfWeekStartIndexZero:C,monthStartIndexZero:D,use24HourTimeFormat:B,trimHoursLeadingZero:M,locale:R,logicalAndDayFields:Y};q.tzOffset&&console.warn("'tzOffset' option has been deprecated and is no longer supported.");var U=new g(v,q);return U.getFullDescription()},g.initialize=function(v,w){w===void 0&&(w="en"),g.specialCharacters=["/","-",",","*"],g.defaultLocale=w,v.load(g.locales)},g.prototype.getFullDescription=function(){var v,w,y="";try{var S=new h.CronParser(this.expression,this.options.dayOfWeekStartIndexZero,this.options.monthStartIndexZero);if(this.expressionParts=S.parse(),this.expressionParts[0]==="@reboot")return((w=(v=this.i18n).atReboot)===null||w===void 0?void 0:w.call(v))||"Run once, at startup";var A=this.getTimeOfDayDescription(),O=this.getDayOfMonthDescription(),k=this.getMonthDescription(),T=this.getDayOfWeekDescription(),C=this.getYearDescription();y+=A+O+T+k+C,y=this.transformVerbosity(y,!!this.options.verbose),y=y.charAt(0).toLocaleUpperCase()+y.substr(1)}catch(N){if(!this.options.throwExceptionOnParseError)y=this.i18n.anErrorOccuredWhenGeneratingTheExpressionD();else throw"".concat(N)}return y},g.prototype.getTimeOfDayDescription=function(){var v=this.expressionParts[0],w=this.expressionParts[1],y=this.expressionParts[2],S="";if(!f.StringUtilities.containsAny(w,g.specialCharacters)&&!f.StringUtilities.containsAny(y,g.specialCharacters)&&!f.StringUtilities.containsAny(v,g.specialCharacters))S+=this.i18n.atSpace()+this.formatTime(y,w,v);else if(!v&&w.indexOf("-")>-1&&!(w.indexOf(",")>-1)&&!(w.indexOf("/")>-1)&&!f.StringUtilities.containsAny(y,g.specialCharacters)){var A=w.split("-");S+=f.StringUtilities.format(this.i18n.everyMinuteBetweenX0AndX1(),this.formatTime(y,A[0],""),this.formatTime(y,A[1],""))}else if(!v&&y.indexOf(",")>-1&&y.indexOf("-")==-1&&y.indexOf("/")==-1&&!f.StringUtilities.containsAny(w,g.specialCharacters)){var O=y.split(",");S+=this.i18n.at();for(var k=0;k<O.length;k++)S&&(S+=" "),S+=this.formatTime(O[k],w,""),k<O.length-2&&(S+=","),k==O.length-2&&(S+=this.i18n.spaceAnd())}else{var T=this.getSecondsDescription(),C=this.getMinutesDescription(),N=this.getHoursDescription();if(S+=T,S&&C&&(S+=", "),S+=C,C===N)return S;S&&N&&(S+=", "),S+=N}return S},g.prototype.getSecondsDescription=function(){var v=this,w=this.getSegmentDescription(this.expressionParts[0],this.i18n.everySecond(),function(y){return y},function(y){return f.StringUtilities.format(v.i18n.everyX0Seconds(y),y)},function(y){return v.i18n.secondsX0ThroughX1PastTheMinute()},function(y){return y=="0"?"":parseInt(y)<20?v.i18n.atX0SecondsPastTheMinute(y):v.i18n.atX0SecondsPastTheMinuteGt20()||v.i18n.atX0SecondsPastTheMinute(y)});return w},g.prototype.getMinutesDescription=function(){var v=this,w=this.expressionParts[0],y=this.expressionParts[2],S=this.getSegmentDescription(this.expressionParts[1],this.i18n.everyMinute(),function(A){return A},function(A){return f.StringUtilities.format(v.i18n.everyX0Minutes(A),A)},function(A){return v.i18n.minutesX0ThroughX1PastTheHour()},function(A){var O,k;try{return A=="0"&&y.indexOf("/")==-1&&w==""?v.i18n.everyHour():A=="0"?((k=(O=v.i18n).onTheHour)===null||k===void 0?void 0:k.call(O))||v.i18n.atX0MinutesPastTheHour(A):parseInt(A)<20?v.i18n.atX0MinutesPastTheHour(A):v.i18n.atX0MinutesPastTheHourGt20()||v.i18n.atX0MinutesPastTheHour(A)}catch{return v.i18n.atX0MinutesPastTheHour(A)}});return S},g.prototype.getHoursDescription=function(){var v=this,w=this.expressionParts[2],y=0,S=[];w.split("/")[0].split(",").forEach(function(k){var T=k.split("-");T.length===2&&S.push({value:T[1],index:y+1}),y+=T.length});var A=0,O=this.getSegmentDescription(w,this.i18n.everyHour(),function(k){var T=S.find(function(N){return N.value===k&&N.index===A}),C=T&&v.expressionParts[1]!=="0";return A++,C?v.formatTime(k,"59",""):v.formatTime(k,"0","")},function(k){return f.StringUtilities.format(v.i18n.everyX0Hours(k),k)},function(k){return v.i18n.betweenX0AndX1()},function(k){return v.i18n.atX0()});return O},g.prototype.getDayOfWeekDescription=function(){var v=this,w=this.i18n.daysOfTheWeek(),y=null;return this.expressionParts[5]=="*"?y="":y=this.getSegmentDescription(this.expressionParts[5],this.i18n.commaEveryDay(),function(S,A){var O=S;S.indexOf("#")>-1?O=S.substring(0,S.indexOf("#")):S.indexOf("L")>-1&&(O=O.replace("L",""));var k=parseInt(O),T=v.i18n.daysOfTheWeekInCase?v.i18n.daysOfTheWeekInCase(A)[k]:w[k];if(S.indexOf("#")>-1){var C=null,N=S.substring(S.indexOf("#")+1),D=S.substring(0,S.indexOf("#"));switch(N){case"1":C=v.i18n.first(D);break;case"2":C=v.i18n.second(D);break;case"3":C=v.i18n.third(D);break;case"4":C=v.i18n.fourth(D);break;case"5":C=v.i18n.fifth(D);break}T=C+" "+T}return T},function(S){return parseInt(S)==1?"":f.StringUtilities.format(v.i18n.commaEveryX0DaysOfTheWeek(S),S)},function(S){var A=S.substring(0,S.indexOf("-")),O=v.expressionParts[3]!="*";return O?v.i18n.commaAndX0ThroughX1(A):v.i18n.commaX0ThroughX1(A)},function(S){var A=null;if(S.indexOf("#")>-1){var O=S.substring(S.indexOf("#")+1),k=S.substring(0,S.indexOf("#"));A=v.i18n.commaOnThe(O,k).trim()+v.i18n.spaceX0OfTheMonth()}else if(S.indexOf("L")>-1)A=v.i18n.commaOnTheLastX0OfTheMonth(S.replace("L",""));else{var T=v.expressionParts[3]!="*";T?v.options.logicalAndDayFields?A=v.i18n.commaOnlyOnX0(S):A=v.i18n.commaAndOnX0():A=v.i18n.commaOnlyOnX0(S)}return A}),y},g.prototype.getMonthDescription=function(){var v=this,w=this.i18n.monthsOfTheYear(),y=this.getSegmentDescription(this.expressionParts[4],"",function(S,A){return A&&v.i18n.monthsOfTheYearInCase?v.i18n.monthsOfTheYearInCase(A)[parseInt(S)-1]:w[parseInt(S)-1]},function(S){return parseInt(S)==1?"":f.StringUtilities.format(v.i18n.commaEveryX0Months(S),S)},function(S){return v.i18n.commaMonthX0ThroughMonthX1()||v.i18n.commaX0ThroughX1()},function(S){return v.i18n.commaOnlyInMonthX0?v.i18n.commaOnlyInMonthX0():v.i18n.commaOnlyInX0()});return y},g.prototype.getDayOfMonthDescription=function(){var v=this,w=null,y=this.expressionParts[3];switch(y){case"L":w=this.i18n.commaOnTheLastDayOfTheMonth();break;case"WL":case"LW":w=this.i18n.commaOnTheLastWeekdayOfTheMonth();break;default:var S=y.match(/(\d{1,2}W)|(W\d{1,2})/);if(S){var A=parseInt(S[0].replace("W","")),O=A==1?this.i18n.firstWeekday():f.StringUtilities.format(this.i18n.weekdayNearestDayX0(),A.toString());w=f.StringUtilities.format(this.i18n.commaOnTheX0OfTheMonth(),O);break}else{var k=y.match(/L-(\d{1,2})/);if(k){var T=k[1];w=f.StringUtilities.format(this.i18n.commaDaysBeforeTheLastDayOfTheMonth(T),T);break}else{if(y=="*"&&this.expressionParts[5]!="*")return"";w=this.getSegmentDescription(y,this.i18n.commaEveryDay(),function(C){return C=="L"?v.i18n.lastDay():v.i18n.dayX0?f.StringUtilities.format(v.i18n.dayX0(),C):C},function(C){return C=="1"?v.i18n.commaEveryDay():v.i18n.commaEveryX0Days(C)},function(C){return v.i18n.commaBetweenDayX0AndX1OfTheMonth(C)},function(C){return v.i18n.commaOnDayX0OfTheMonth(C)})}break}}return w},g.prototype.getYearDescription=function(){var v=this,w=this.getSegmentDescription(this.expressionParts[6],"",function(y){return/^\d+$/.test(y)?new Date(parseInt(y),1).getFullYear().toString():y},function(y){return f.StringUtilities.format(v.i18n.commaEveryX0Years(y),y)},function(y){return v.i18n.commaYearX0ThroughYearX1()||v.i18n.commaX0ThroughX1()},function(y){return v.i18n.commaOnlyInYearX0?v.i18n.commaOnlyInYearX0():v.i18n.commaOnlyInX0()});return w},g.prototype.getSegmentDescription=function(v,w,y,S,A,O){var k=null,T=v.indexOf("/")>-1,C=v.indexOf("-")>-1,N=v.indexOf(",")>-1;if(!v)k="";else if(v==="*")k=w;else if(!T&&!C&&!N)k=f.StringUtilities.format(O(v),y(v));else if(N){for(var D=v.split(","),B="",P=this.i18n.spaceAnd(),M=0;M<D.length;M++)if(M>0&&D.length>2&&(B+=",",M<D.length-1&&(B+=" ")),M>0&&D.length>1&&(M==D.length-1||D.length==2)&&(B+=P==","&&D.length>2?" ":"".concat(P," ")),D[M].indexOf("/")>-1||D[M].indexOf("-")>-1){var z=D[M].indexOf("-")>-1&&D[M].indexOf("/")==-1,R=this.getSegmentDescription(D[M],w,y,S,z?this.i18n.commaX0ThroughX1:A,O);z&&(R=R.replace(", ","")),B+=R}else if(!T)B+=y(D[M]);else{var H=this.getSegmentDescription(D[M],w,y,S,A,O);H&&H.startsWith(", ")&&(H=H.substring(2)),B+=H}T?k=B:k=f.StringUtilities.format(O(v),B)}else if(T){var D=v.split("/");if(k=f.StringUtilities.format(S(D[1]),D[1]),D[0].indexOf("-")>-1){var Y=this.generateRangeSegmentDescription(D[0],A,y);Y.indexOf(", ")!=0&&(k+=", "),k+=Y}else if(D[0].indexOf("*")==-1){var q=f.StringUtilities.format(O(D[0]),y(D[0]));q=q.replace(", ",""),k+=f.StringUtilities.format(this.i18n.commaStartingX0(),q)}}else C&&(k=this.generateRangeSegmentDescription(v,A,y));return k},g.prototype.generateRangeSegmentDescription=function(v,w,y){var S="",A=v.split("-"),O=y(A[0],1),k=y(A[1],2),T=w(v);return S+=f.StringUtilities.format(T,O,k),S},g.prototype.formatTime=function(v,w,y){var S=0,A=0,O=parseInt(v)+S,k=parseInt(w)+A;k>=60?(k-=60,O+=1):k<0&&(k+=60,O-=1),O>=24?O=O-24:O<0&&(O=24+O);var T="",C=!1;this.options.use24HourTimeFormat||(C=!!(this.i18n.setPeriodBeforeTime&&this.i18n.setPeriodBeforeTime()),T=C?"".concat(this.getPeriod(O)," "):" ".concat(this.getPeriod(O)),O>12&&(O-=12),O===0&&(O=12));var N="";y&&(N=":".concat(("00"+y).substring(y.length)));var D=O.toString(),B=("00"+D).substring(D.length),P=k.toString(),M=("00"+P).substring(P.length),z=this.options.trimHoursLeadingZero?D:B;return"".concat(C?T:"").concat(z,":").concat(M).concat(N).concat(C?"":T)},g.prototype.transformVerbosity=function(v,w){if(!w&&(v=v.replace(new RegExp(", ".concat(this.i18n.everyMinute()),"g"),""),v=v.replace(new RegExp(", ".concat(this.i18n.everyHour()),"g"),""),v=v.replace(new RegExp(this.i18n.commaEveryDay(),"g"),""),v=v.replace(/\, ?$/,""),this.i18n.conciseVerbosityReplacements))for(var y=0,S=Object.entries(this.i18n.conciseVerbosityReplacements());y<S.length;y++){var A=S[y],O=A[0],k=A[1];v=v.replace(new RegExp(O,"g"),k)}return v},g.prototype.getPeriod=function(v){return v>=12?this.i18n.pm&&this.i18n.pm()||"PM":this.i18n.am&&this.i18n.am()||"AM"},g.locales={},g})();c.ExpressionDescriptor=p},747(l,c,u){Object.defineProperty(c,"__esModule",{value:!0}),c.enLocaleLoader=void 0;var f=u(486),h=(function(){function p(){}return p.prototype.load=function(g){g.en=new f.en},p})();c.enLocaleLoader=h},486(l,c){Object.defineProperty(c,"__esModule",{value:!0}),c.en=void 0;var u=(function(){function f(){}return f.prototype.atX0SecondsPastTheMinuteGt20=function(){return null},f.prototype.atX0MinutesPastTheHourGt20=function(){return null},f.prototype.commaMonthX0ThroughMonthX1=function(){return null},f.prototype.commaYearX0ThroughYearX1=function(){return null},f.prototype.use24HourTimeFormatByDefault=function(){return!1},f.prototype.anErrorOccuredWhenGeneratingTheExpressionD=function(){return"An error occurred when generating the expression description. Check the cron expression syntax."},f.prototype.everyMinute=function(){return"every minute"},f.prototype.everyHour=function(){return"every hour"},f.prototype.atSpace=function(){return"At "},f.prototype.everyMinuteBetweenX0AndX1=function(){return"Every minute between %s and %s"},f.prototype.at=function(){return"At"},f.prototype.spaceAnd=function(){return" and"},f.prototype.everySecond=function(){return"every second"},f.prototype.everyX0Seconds=function(){return"every %s seconds"},f.prototype.secondsX0ThroughX1PastTheMinute=function(){return"seconds %s through %s past the minute"},f.prototype.atX0SecondsPastTheMinute=function(){return"at %s seconds past the minute"},f.prototype.everyX0Minutes=function(){return"every %s minutes"},f.prototype.minutesX0ThroughX1PastTheHour=function(){return"minutes %s through %s past the hour"},f.prototype.atX0MinutesPastTheHour=function(){return"at %s minutes past the hour"},f.prototype.everyX0Hours=function(){return"every %s hours"},f.prototype.betweenX0AndX1=function(){return"between %s and %s"},f.prototype.atX0=function(){return"at %s"},f.prototype.commaEveryDay=function(){return", every day"},f.prototype.commaEveryX0DaysOfTheWeek=function(){return", every %s days of the week"},f.prototype.commaX0ThroughX1=function(){return", %s through %s"},f.prototype.commaAndX0ThroughX1=function(){return", %s through %s"},f.prototype.first=function(){return"first"},f.prototype.second=function(){return"second"},f.prototype.third=function(){return"third"},f.prototype.fourth=function(){return"fourth"},f.prototype.fifth=function(){return"fifth"},f.prototype.commaOnThe=function(){return", on the "},f.prototype.spaceX0OfTheMonth=function(){return" %s of the month"},f.prototype.lastDay=function(){return"the last day"},f.prototype.commaOnTheLastX0OfTheMonth=function(){return", on the last %s of the month"},f.prototype.commaOnlyOnX0=function(){return", only on %s"},f.prototype.commaAndOnX0=function(){return", and on %s"},f.prototype.commaEveryX0Months=function(){return", every %s months"},f.prototype.commaOnlyInX0=function(){return", only in %s"},f.prototype.commaOnTheLastDayOfTheMonth=function(){return", on the last day of the month"},f.prototype.commaOnTheLastWeekdayOfTheMonth=function(){return", on the last weekday of the month"},f.prototype.commaDaysBeforeTheLastDayOfTheMonth=function(){return", %s days before the last day of the month"},f.prototype.firstWeekday=function(){return"first weekday"},f.prototype.weekdayNearestDayX0=function(){return"weekday nearest day %s"},f.prototype.commaOnTheX0OfTheMonth=function(){return", on the %s of the month"},f.prototype.commaEveryX0Days=function(){return", every %s days in a month"},f.prototype.commaBetweenDayX0AndX1OfTheMonth=function(){return", between day %s and %s of the month"},f.prototype.commaOnDayX0OfTheMonth=function(){return", on day %s of the month"},f.prototype.commaEveryHour=function(){return", every hour"},f.prototype.commaEveryX0Years=function(){return", every %s years"},f.prototype.commaStartingX0=function(){return", starting %s"},f.prototype.daysOfTheWeek=function(){return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},f.prototype.monthsOfTheYear=function(){return["January","February","March","April","May","June","July","August","September","October","November","December"]},f.prototype.atReboot=function(){return"Run once, at startup"},f.prototype.onTheHour=function(){return"on the hour"},f})();c.en=u},515(l,c){Object.defineProperty(c,"__esModule",{value:!0});function u(h,p){if(!h)throw new Error(p)}var f=(function(){function h(){}return h.secondRange=function(p){for(var g=p.split(","),v=0;v<g.length;v++)if(!isNaN(parseInt(g[v],10))){var w=parseInt(g[v],10);u(w>=0&&w<=59,"seconds part must be >= 0 and <= 59")}},h.minuteRange=function(p){for(var g=p.split(","),v=0;v<g.length;v++)if(!isNaN(parseInt(g[v],10))){var w=parseInt(g[v],10);u(w>=0&&w<=59,"minutes part must be >= 0 and <= 59")}},h.hourRange=function(p){for(var g=p.split(","),v=0;v<g.length;v++)if(!isNaN(parseInt(g[v],10))){var w=parseInt(g[v],10);u(w>=0&&w<=23,"hours part must be >= 0 and <= 23")}},h.dayOfMonthRange=function(p){for(var g=p.split(","),v=0;v<g.length;v++)if(!isNaN(parseInt(g[v],10))){var w=parseInt(g[v],10);u(w>=1&&w<=31,"DOM part must be >= 1 and <= 31")}},h.monthRange=function(p,g){for(var v=p.split(","),w=0;w<v.length;w++)if(!isNaN(parseInt(v[w],10))){var y=parseInt(v[w],10);u(y>=1&&y<=12,g?"month part must be >= 0 and <= 11":"month part must be >= 1 and <= 12")}},h.dayOfWeekRange=function(p,g){for(var v=p.split(","),w=0;w<v.length;w++)if(!isNaN(parseInt(v[w],10))){var y=parseInt(v[w],10);u(y>=0&&y<=6,g?"DOW part must be >= 0 and <= 6":"DOW part must be >= 1 and <= 7")}},h})();c.default=f},823(l,c){Object.defineProperty(c,"__esModule",{value:!0}),c.StringUtilities=void 0;var u=(function(){function f(){}return f.format=function(h){for(var p=[],g=1;g<arguments.length;g++)p[g-1]=arguments[g];return h.replace(/%s/g,function(v){return p.shift()})},f.containsAny=function(h,p){return p.some(function(g){return h.indexOf(g)>-1})},f})();c.StringUtilities=u}},r={};function i(l){var c=r[l];if(c!==void 0)return c.exports;var u=r[l]={exports:{}};return n[l](u,u.exports,i),u.exports}var a={};return(()=>{var l=a;Object.defineProperty(l,"__esModule",{value:!0}),l.toString=void 0;var c=i(333),u=i(747);c.ExpressionDescriptor.initialize(new u.enLocaleLoader),l.default=c.ExpressionDescriptor;var f=c.ExpressionDescriptor.toString;l.toString=f})(),a})())})(G0)),G0.exports}var gwe=mwe();const i4=eu(gwe);function vwe(e){return e.trigger.kind}function ywe(e){var n;const t=e.trigger;if(t.kind==="once")return`Once at ${new Date(t.at).toLocaleString()}`;if(t.kind==="interval"){const r=Math.round(t.everyMs/1e3);return r>=86400?`Every ${Math.round(r/86400)}d`:r>=3600?`Every ${Math.round(r/3600)}h`:r>=60?`Every ${Math.round(r/60)}m`:`Every ${r}s`}if(t.kind==="event"){const r=t.match?Object.entries(t.match).map(([i,a])=>`${i}=${a}`).join(", "):"";return`On event "${t.source}"${r?` where ${r}`:""}`}try{const r=t.tz||"UTC",i=bwe(t.expr,r),a=i4.toString(t.expr),l=r==="UTC"?"UTC":((n=r.split("/").pop())==null?void 0:n.replace(/_/g," "))||r;return i?`${i} (${a} ${l})`:`${a} ${l}`}catch{return t.expr}}function bwe(e,t){try{const n=e.split(/\s+/);if(n.length<5)return null;const r=parseInt(n[0],10),i=parseInt(n[1],10);if(isNaN(r)||isNaN(i))return null;const a=new Date,l=new Date(a.toLocaleString("en-US",{timeZone:t})).getTime()-new Date(a.toLocaleString("en-US",{timeZone:"UTC"})).getTime(),c=new Date;return c.setUTCHours(i,r,0,0),new Date(c.getTime()-l).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",hour12:!1,timeZone:"UTC"})}catch{return null}}function XR(e){if(!e)return"—";const t=e-Date.now(),n=Math.abs(t),r=Math.round(n/6e4);if(n<6e4)return t>0?"in <1m":"<1m ago";if(r<60)return t>0?`in ${r}m`:`${r}m ago`;const i=Math.round(r/60);if(i<24)return t>0?`in ${i}h`:`${i}h ago`;const a=Math.round(i/24);return t>0?`in ${a}d`:`${a}d ago`}const xwe={ok:"bg-green-50 text-green-700 dark:bg-green-950/50 dark:text-green-300",error:"bg-red-50 text-red-700 dark:bg-red-950/50 dark:text-red-300",running:"bg-blue-50 text-blue-700 dark:bg-blue-950/50 dark:text-blue-300",aborted:"bg-amber-50 text-amber-700 dark:bg-amber-950/50 dark:text-amber-300"};function wwe(e){return e.scope==="system"}function Ewe(e){return e==="prompt"?"Additional instructions (appended to prompt)":e==="bash"?"Override command":"Override args"}function Swe(e){return e==="prompt"?"e.g. Dry run — compose the message but do NOT post to Slack":e==="bash"?"e.g. bun run report:fb-ads-spend --dry-run":"e.g. --dry-run"}function _we(e,t){var n;return e.scope==="system"?"system":((n=e.createdBy)==null?void 0:n.uid)===t?"mine":"others"}function Awe({schedules:e,currentUserUid:t,onCreate:n,onEdit:r,onDelete:i,onToggle:a,onRunNow:l,onCancel:c,onOpenRun:u,runningIds:f=new Set}){const[h,p]=b.useState(null),[g,v]=b.useState(""),[w,y]=b.useState({mine:!0,others:!0,system:!0}),[S,A]=b.useState({once:!0,interval:!0,cron:!0,event:!0}),[O,k]=b.useState(!1),T=P=>y(M=>{if(Object.values(M).every(Boolean))return{mine:!1,others:!1,system:!1,[P]:!0};const R={...M,[P]:!M[P]};return Object.values(R).some(Boolean)?R:{mine:!0,others:!0,system:!0}}),C=P=>A(M=>{if(Object.values(M).every(Boolean))return{once:!1,interval:!1,cron:!1,event:!1,[P]:!0};const R={...M,[P]:!M[P]};return Object.values(R).some(Boolean)?R:{once:!0,interval:!0,cron:!0,event:!0}}),N=e.filter(P=>w[_we(P,t)]&&S[vwe(P)]),D=P=>{const M=localStorage.getItem(`schedule-override-${P.id}`);v(M??""),p(P.id)},B=async()=>{if(h){k(!0);try{const P=g.trim()||void 0;P&&localStorage.setItem(`schedule-override-${h}`,P);const M=await l(h,P);p(null),v(""),M&&u(M)}finally{k(!1)}}};return E.jsxs("div",{className:"space-y-3",children:[E.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[E.jsxs("div",{className:"flex gap-1 flex-wrap",children:[["mine","others","system"].map(P=>E.jsx("button",{onClick:()=>T(P),className:`text-[11px] px-2 py-0.5 rounded-full border transition-colors ${w[P]?"bg-primary text-primary-foreground border-primary":"bg-transparent text-muted-foreground border-border hover:border-muted-foreground"}`,children:P},P)),E.jsx("span",{className:"w-px h-4 bg-border mx-1"}),["once","interval","cron","event"].map(P=>E.jsx("button",{onClick:()=>C(P),className:`text-[11px] px-2 py-0.5 rounded-full border transition-colors ${S[P]?"bg-primary text-primary-foreground border-primary":"bg-transparent text-muted-foreground border-border hover:border-muted-foreground"}`,children:P},P))]}),E.jsxs(Me,{size:"sm",onClick:n,className:"gap-1",children:[E.jsx(bg,{className:"w-4 h-4"})," New schedule"]})]}),N.length===0&&E.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:e.length===0?"No schedules yet.":"No schedules match filters."}),N.map(P=>{var M,z;return E.jsxs("div",{className:"border rounded-lg p-3 space-y-2 overflow-hidden",children:[E.jsxs("div",{className:"flex items-start justify-between gap-2 flex-wrap",children:[E.jsxs("div",{className:"min-w-0 flex-1",children:[E.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-wrap",children:[E.jsx("input",{type:"checkbox",checked:P.enabled,onChange:R=>a(P.id,R.target.checked),title:P.enabled?"Disable":"Enable",className:"shrink-0"}),E.jsx("span",{className:"font-medium text-sm truncate max-w-[280px]",title:P.name,children:P.name}),E.jsx("span",{className:"shrink-0 text-[10px] font-mono px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:P.task.kind}),E.jsx("span",{className:"shrink-0 text-[10px] font-mono px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:P.trigger.kind}),f.has(P.id)&&E.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-blue-50 text-blue-700 dark:bg-blue-950/50 dark:text-blue-300",children:[E.jsx(Xf,{className:"w-3 h-3 animate-spin"}),"running"]}),E.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-blue-50 text-blue-700 dark:bg-blue-950/50 dark:text-blue-300",children:wwe(P)?"system":((z=(M=P.createdBy)==null?void 0:M.email)==null?void 0:z.split("@")[0])??"unknown"})]}),E.jsx("div",{className:"mt-1 text-xs text-muted-foreground truncate",children:ywe(P)}),E.jsxs("div",{className:"mt-1 flex items-center gap-3 text-xs text-muted-foreground",children:[E.jsxs("span",{children:["Next: ",P.enabled?XR(P.nextRun):"disabled"]}),P.lastRun&&E.jsxs("button",{className:`px-1.5 py-0.5 rounded text-[10px] ${xwe[P.lastRun.status]??""}`,onClick:()=>u(P.lastRun.sessionId),title:"Open last run",children:["last: ",P.lastRun.status," ",XR(P.lastRun.at)]}),E.jsxs("span",{children:["runs: ",P.runCount??0]})]})]}),E.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[f.has(P.id)?E.jsx(Me,{variant:"ghost",size:"icon",title:"Stop run",onClick:()=>c(P.id),children:E.jsx(hD,{className:"w-4 h-4 text-destructive"})}):E.jsx(Me,{variant:"ghost",size:"icon",title:"Run now",onClick:()=>D(P),children:E.jsx(OH,{className:"w-4 h-4"})}),E.jsx(Me,{variant:"ghost",size:"icon",title:"Edit",onClick:()=>r(P),children:E.jsx(Bw,{className:"w-4 h-4"})}),E.jsx(Me,{variant:"ghost",size:"icon",title:"Delete",onClick:()=>i(P.id),children:E.jsx(Zf,{className:"w-4 h-4 text-destructive"})})]})]}),h===P.id&&E.jsxs("div",{className:"border-t pt-2 mt-2 space-y-2",children:[E.jsx("label",{className:"text-xs text-muted-foreground",children:Ewe(P.task.kind)}),E.jsx("input",{type:"text",className:"w-full text-sm border rounded px-2 py-1.5 bg-background",placeholder:Swe(P.task.kind),value:g,onChange:R=>v(R.target.value),onKeyDown:R=>{R.key==="Enter"&&!O&&B(),R.key==="Escape"&&p(null)},disabled:O,autoFocus:!0}),E.jsxs("div",{className:"flex gap-2 justify-end",children:[E.jsx(Me,{size:"sm",variant:"ghost",onClick:()=>p(null),disabled:O,children:"Cancel"}),E.jsx(Me,{size:"sm",onClick:B,disabled:O,children:O?"Running...":"Run"})]})]})]},P.id)})]})}function kwe(e){const t=new Date(e??Date.now()+6e4),n=r=>String(r).padStart(2,"0");return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}const Owe=[{label:"1 min",ms:6e4},{label:"5 min",ms:5*6e4},{label:"15 min",ms:15*6e4},{label:"1 hour",ms:60*6e4},{label:"6 hours",ms:360*6e4},{label:"1 day",ms:1440*6e4}],Twe=[{label:"Every hour",expr:"0 * * * *"},{label:"Daily 9am",expr:"0 9 * * *"},{label:"Weekdays 9am",expr:"0 9 * * 1-5"},{label:"Mondays 9am",expr:"0 9 * * 1"}];function Nwe({match:e,onChange:t}){const n=Object.entries(e),r=(l,c,u)=>{const f={};n.forEach(([h,p],g)=>{f[g===l?c:h]=g===l?u:p}),t(f)},i=l=>t(Object.fromEntries(n.filter((c,u)=>u!==l))),a=()=>t({...e,"":""});return E.jsxs("div",{className:"space-y-1",children:[E.jsx("label",{className:"text-xs text-muted-foreground",children:"Match filter (optional — all must match)"}),n.map(([l,c],u)=>E.jsxs("div",{className:"flex gap-1",children:[E.jsx(In,{className:"text-xs font-mono",value:l,onChange:f=>r(u,f.target.value,c),placeholder:"payload.path (e.g. type)"}),E.jsx(In,{className:"text-xs font-mono",value:c,onChange:f=>r(u,l,f.target.value),placeholder:"value (e.g. invoice.paid)"}),E.jsx(Me,{type:"button",variant:"ghost",size:"sm",onClick:()=>i(u),children:"×"})]},u)),E.jsx(Me,{type:"button",variant:"outline",size:"sm",onClick:a,children:"+ Add filter"})]})}function ZR({initial:e,onSave:t,onCancel:n,skills:r=[],workspaceFiles:i=[]}){const a=b.useMemo(()=>Intl.DateTimeFormat().resolvedOptions().timeZone,[]),[l,c]=b.useState((e==null?void 0:e.name)??"New schedule"),[u,f]=b.useState((e==null?void 0:e.enabled)??!0),[h,p]=b.useState((e==null?void 0:e.trigger)??{kind:"cron",expr:"0 9 * * *",tz:a}),[g,v]=b.useState((e==null?void 0:e.task)??{kind:"prompt",prompt:""}),[w,y]=b.useState(!1),[S,A]=b.useState(null),O=b.useMemo(()=>{if(h.kind!=="cron")return"";try{return i4.toString(h.expr)}catch{return"Invalid cron"}},[h]),k=async()=>{y(!0),A(null);try{await t({name:l,enabled:u,trigger:h,task:g})}catch(T){A(T.message)}finally{y(!1)}};return E.jsxs("div",{className:"space-y-4",children:[E.jsxs("div",{className:"space-y-1",children:[E.jsx("label",{className:"text-xs text-muted-foreground",children:"Name"}),E.jsx(In,{value:l,onChange:T=>c(T.target.value),placeholder:"e.g. Daily standup summary"})]}),E.jsxs("div",{className:"space-y-2",children:[E.jsx("label",{className:"text-xs text-muted-foreground",children:"Trigger"}),E.jsx("div",{className:"flex gap-1",children:["once","interval","cron","event"].map(T=>E.jsx(Me,{type:"button",variant:h.kind===T?"default":"outline",size:"sm",onClick:()=>{p(T==="once"?{kind:"once",at:Date.now()+5*6e4}:T==="interval"?{kind:"interval",everyMs:60*6e4}:T==="event"?{kind:"event",source:""}:{kind:"cron",expr:"0 9 * * *",tz:a})},children:T},T))}),h.kind==="once"&&E.jsx(In,{type:"datetime-local",value:kwe(h.at),onChange:T=>{const C=new Date(T.target.value);isNaN(C.getTime())||p({kind:"once",at:C.getTime()})}}),h.kind==="interval"&&E.jsxs("div",{className:"space-y-2",children:[E.jsx("div",{className:"flex gap-1 flex-wrap",children:Owe.map(T=>E.jsx(Me,{type:"button",variant:h.everyMs===T.ms?"default":"outline",size:"sm",onClick:()=>p({kind:"interval",everyMs:T.ms}),children:T.label},T.ms))}),E.jsx(In,{type:"number",min:1,value:Math.round(h.everyMs/1e3),onChange:T=>p({kind:"interval",everyMs:Math.max(1,Number(T.target.value))*1e3}),placeholder:"seconds"}),E.jsxs("p",{className:"text-xs text-muted-foreground",children:["Every ",Math.round(h.everyMs/1e3),"s"]})]}),h.kind==="cron"&&E.jsxs("div",{className:"space-y-2",children:[E.jsx("div",{className:"flex gap-1 flex-wrap",children:Twe.map(T=>E.jsx(Me,{type:"button",variant:"outline",size:"sm",onClick:()=>p({kind:"cron",expr:T.expr,tz:a}),children:T.label},T.expr))}),E.jsx(In,{className:"font-mono text-xs",value:h.expr,onChange:T=>p({...h,expr:T.target.value}),placeholder:"0 9 * * *"}),E.jsx(In,{className:"text-xs",value:h.tz,onChange:T=>p({...h,tz:T.target.value}),placeholder:"IANA timezone"}),E.jsxs("p",{className:"text-xs text-muted-foreground",children:[O," (",h.tz,")"]})]}),h.kind==="event"&&E.jsxs("div",{className:"space-y-2",children:[E.jsx(In,{value:h.source,onChange:T=>p({...h,source:T.target.value}),placeholder:"Event source (e.g. stripe, github, deploy)"}),E.jsxs("p",{className:"text-xs text-muted-foreground",children:["Fires when an event with this source arrives via ",E.jsxs("code",{children:["POST /api/events/",h.source||":source"]})," or ",E.jsx("code",{children:"ctx.emitEvent()"}),"."]}),E.jsx(Nwe,{match:h.match??{},onChange:T=>p({...h,match:T})})]})]}),E.jsxs("div",{className:"space-y-2",children:[E.jsx("label",{className:"text-xs text-muted-foreground",children:"Task"}),E.jsx("div",{className:"flex gap-1",children:["prompt","bash"].map(T=>E.jsx(Me,{type:"button",variant:g.kind===T?"default":"outline",size:"sm",onClick:()=>v(T==="prompt"?{kind:"prompt",prompt:""}:{kind:"bash",command:""}),children:T==="prompt"?"Prompt":"Bash command"},T))}),g.kind==="prompt"?E.jsx(n4,{rows:5,value:g.prompt,onChange:T=>v({...g,prompt:T}),placeholder:"What should the agent do? (@ for skills, / for commands)",skills:r,workspaceFiles:i,autoResize:!1,className:"flex min-h-[80px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"}):g.kind==="bash"?E.jsx(vv,{rows:3,className:"font-mono text-xs",value:g.command,onChange:T=>v({...g,command:T.target.value}),placeholder:"ls -la ~/"}):E.jsxs("p",{className:"text-xs text-muted-foreground",children:["Command: ",g.command]})]}),E.jsxs("div",{className:"flex items-center gap-2",children:[E.jsx("input",{id:"sched-enabled",type:"checkbox",checked:u,onChange:T=>f(T.target.checked)}),E.jsx("label",{htmlFor:"sched-enabled",className:"text-sm",children:"Enabled"})]}),S&&E.jsx("p",{className:"text-xs text-destructive",children:S}),E.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[E.jsx(Me,{variant:"outline",onClick:n,disabled:w,children:"Cancel"}),E.jsx(Me,{onClick:k,disabled:w,children:w?"Saving…":"Save"})]})]})}const QR=b.forwardRef(function({getToken:t,onOpenSession:n,refreshKey:r=0,runningIds:i=new Set,skills:a=[],workspaceFiles:l=[],trigger:c},u){const[f,h]=b.useState(!1),{user:p}=Z2(),{schedules:g,serverRunningIds:v,create:w,update:y,remove:S,toggle:A,runNow:O,cancelRun:k}=pwe(t,f,r);b.useImperativeHandle(u,()=>({open:()=>h(!0)}),[]);const[T,C]=b.useState(null),[N,D]=b.useState(!1),[B,P]=b.useState(new Set),M=()=>{C(null),D(!1)},z=async(R,H)=>{P(Y=>new Set(Y).add(R));try{return await O(R,H)}finally{setTimeout(()=>{P(Y=>{const q=new Set(Y);return q.delete(R),q})},1500)}};return E.jsxs(el,{open:f,onOpenChange:R=>{h(R),R||M()},children:[E.jsx(Sd,{asChild:!0,children:c||E.jsx(Me,{variant:"ghost",size:"icon",className:"h-8 w-8",title:"Scheduled Tasks",children:E.jsx(Dw,{className:"w-4 h-4"})})}),E.jsxs(Va,{className:"max-w-[95vw] sm:max-w-2xl",children:[E.jsx(cs,{children:E.jsx(tl,{children:N?"New Schedule":T?`Edit: ${T.name}`:"Scheduled Tasks"})}),N?E.jsx(ZR,{onSave:async R=>{await w(R),M()},onCancel:M,skills:a,workspaceFiles:l},"__new__"):T?E.jsx(ZR,{initial:T,onSave:async R=>{await y(T.id,R),M()},onCancel:M,skills:a,workspaceFiles:l},T.id):E.jsx(Awe,{schedules:g,currentUserUid:p==null?void 0:p.uid,onCreate:()=>D(!0),onEdit:R=>C(R),onDelete:R=>{confirm("Delete this schedule?")&&S(R)},onToggle:A,onRunNow:z,onCancel:k,runningIds:new Set([...i,...v,...B]),onOpenRun:R=>{h(!1),n(R)}})]})]})});function a4(){const e=localStorage.getItem("dark-mode");return e!==null?e==="true":window.matchMedia("(prefers-color-scheme: dark)").matches}let as=typeof window<"u"?a4():!0;const bw=new Set;function o4(){document.documentElement.classList.toggle("dark",as),localStorage.setItem("dark-mode",String(as)),bw.forEach(e=>e())}typeof window<"u"&&o4();function l4(e){e!==as&&(as=e,o4())}function Cwe(e){bw.add(e);const t=n=>{n.key==="dark-mode"&&l4(a4())};return window.addEventListener("storage",t),()=>{bw.delete(e),window.removeEventListener("storage",t)}}function Iwe(){return{dark:b.useSyncExternalStore(Cwe,()=>as,()=>as),toggle:()=>l4(!as)}}const JR=4;function Mwe(e,t){const[n,r]=b.useState({}),[i,a]=b.useState([]),l=b.useRef(t);l.current=t;const c=b.useRef(!document.hidden),u=b.useRef(e);u.current=e,b.useEffect(()=>{const y=()=>{var O;c.current=!document.hidden,(O=u.current)==null||O.sendPresence(l.current,c.current),c.current&&l.current&&h(l.current)},S=()=>{var O;c.current=!0,(O=u.current)==null||O.sendPresence(l.current,!0),l.current&&h(l.current)},A=()=>{var O;c.current=!1,(O=u.current)==null||O.sendPresence(l.current,!1)};return document.addEventListener("visibilitychange",y),window.addEventListener("focus",S),window.addEventListener("blur",A),()=>{document.removeEventListener("visibilitychange",y),window.removeEventListener("focus",S),window.removeEventListener("blur",A)}},[]),b.useEffect(()=>{e==null||e.sendPresence(t,c.current),t&&c.current&&h(t)},[t,e]),b.useEffect(()=>{},[i.length]);const f=b.useCallback(y=>{var S,A;if(y.type==="unread"){if(l.current===y.sessionId&&c.current){(S=u.current)==null||S.markRead(y.sessionId);return}r(k=>({...k,[y.sessionId]:{count:y.count,preview:y.preview,source:y.source,title:y.title}})),a(k=>{const T=k.filter(N=>N.sessionId!==y.sessionId);return[{id:`${y.sessionId}-${Date.now()}`,sessionId:y.sessionId,preview:y.preview,title:y.title,ts:Date.now()},...T].slice(0,JR)})}if(y.type==="unread_sync"){const O={};for(const[k,T]of Object.entries(y.sessions)){if(k===l.current&&c.current){(A=u.current)==null||A.markRead(k);continue}O[k]={count:T.count,preview:T.preview,source:T.source,title:T.title}}r(O)}y.type==="unread_cleared"&&r(O=>{const k={...O};return delete k[y.sessionId],k})},[]),h=b.useCallback(y=>{var S;r(A=>{if(!A[y])return A;const O={...A};return delete O[y],O}),a(A=>A.filter(O=>O.sessionId!==y)),(S=u.current)==null||S.markRead(y)},[]),p=b.useCallback(y=>{a(S=>S.filter(A=>A.id!==y))},[]),g=b.useCallback(y=>{l.current===y.sessionId&&c.current||a(S=>{const A=S.filter(k=>k.sessionId!==y.sessionId);return[{id:`${y.sessionId}-${Date.now()}`,sessionId:y.sessionId,preview:y.preview,title:y.title,ts:Date.now()},...A].slice(0,JR)})},[]),v=Object.keys(n).length;b.useEffect(()=>{const y="Shraga";document.title=v>0?`(${v}) ${y}`:y,Rwe(v)},[v]);const w=b.useRef(0);return b.useEffect(()=>{v>w.current,w.current=v},[v]),{unreads:n,toasts:i,totalUnread:v,markRead:h,dismissToast:p,addToast:g,handleUnreadEvent:f}}let Ec=null,V0=null;function Rwe(e){if(typeof document>"u")return;if(!V0){const n=document.querySelector('link[rel="icon"]');V0=(n==null?void 0:n.href)??""}if(e===0){e2(V0||"");return}Ec||(Ec=document.createElement("canvas"),Ec.width=32,Ec.height=32);const t=Ec.getContext("2d");t&&(t.clearRect(0,0,32,32),t.fillStyle="#6366f1",t.beginPath(),t.arc(16,16,14,0,Math.PI*2),t.fill(),t.fillStyle="#ef4444",t.beginPath(),t.arc(24,8,8,0,Math.PI*2),t.fill(),t.fillStyle="#fff",t.font="bold 10px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(e>9?"9+":String(e),24,8),e2(Ec.toDataURL()))}function e2(e){let t=document.querySelector('link[rel="icon"]');t||(t=document.createElement("link"),t.rel="icon",document.head.appendChild(t)),t.href!==e&&(t.href=e)}function Dwe({toasts:e,onDismiss:t,onOpen:n}){return e.length===0?null:E.jsx("div",{className:"fixed bottom-4 right-4 z-[100] flex flex-col-reverse gap-2 max-w-sm w-full pointer-events-none",children:e.map((r,i)=>E.jsxs("div",{className:Xe("pointer-events-auto bg-white dark:bg-zinc-800 border border-zinc-300 dark:border-zinc-600 rounded-lg shadow-[0_8px_30px_rgb(0,0,0,0.12)] dark:shadow-[0_8px_30px_rgb(0,0,0,0.5)] p-3 pr-7 cursor-pointer relative","transform transition-all duration-300 ease-out","hover:bg-zinc-50 dark:hover:bg-zinc-700 group",i===0?"animate-in slide-in-from-bottom-2 fade-in":""),onClick:()=>{n(r.sessionId),t(r.id)},children:[E.jsx("button",{onClick:a=>{a.stopPropagation(),t(r.id)},className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity p-0.5 hover:bg-muted rounded",children:E.jsx(ls,{className:"w-3 h-3 text-muted-foreground"})}),E.jsxs("div",{className:"flex items-start gap-2.5",children:[E.jsx(ax,{className:"w-4 h-4 mt-0.5 shrink-0 text-blue-500"}),E.jsxs("div",{className:"flex-1 min-w-0",children:[E.jsx("div",{className:"text-xs font-medium text-foreground truncate",children:r.title||`Session ${r.sessionId.slice(0,8)}`}),E.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-2",children:r.preview})]})]})]},r.id))})}function t2(){return new URLSearchParams(window.location.search).get("session")||void 0}function Pwe(e){const t=new URL(window.location.href);e?t.searchParams.set("session",e):t.searchParams.delete("session");const n=t.toString()!==window.location.href;e&&n?window.history.pushState(null,"",t.toString()):window.history.replaceState(null,"",t.toString())}function jwe(){return E.jsx(lH,{value:{},children:E.jsx(Lwe,{})})}function Lwe(){var Ln,vr;const e=sa(),{dark:t,toggle:n}=Iwe(),{user:r,token:i,getToken:a,loading:l,mode:c,needsSetup:u,loginLocal:f,registerLocal:h,logout:p}=Z2(),[g,v]=b.useState(()=>localStorage.getItem("shraga:sidebarOpen")!=="false"),w=b.useCallback(he=>{v($e=>{const ot=typeof he=="function"?he($e):he;return localStorage.setItem("shraga:sidebarOpen",String(ot)),ot})},[]),[y,S]=b.useState(!1),[A,O]=b.useState({top:52,right:8}),k=b.useRef(null),T=b.useCallback(()=>{var $e;const he=($e=k.current)==null?void 0:$e.getBoundingClientRect();he&&O({top:he.bottom+4,right:Math.max(4,window.innerWidth-he.right)}),S(ot=>!ot)},[]),[C,N]=b.useState({}),D=b.useRef(null),[B,P]=b.useState(0),[M,z]=b.useState(0),[R,H]=b.useState(new Set),[Y,q]=b.useState([]),[U,G]=b.useState([]),[K,ee]=b.useState(0),[j,F]=b.useState(new Set),[J,$]=b.useState(!1),[de,xe]=b.useState(()=>localStorage.getItem("shraga:authorized")==="1"?!0:null),[ve,De]=b.useState(()=>t2()),Ze=b.useCallback((he,$e)=>De(he),[]),fe=b.useCallback((he,$e)=>De($e),[]),Te=b.useCallback((he,$e)=>{},[]),we=b.useCallback(()=>P(he=>he+1),[]),ue=b.useRef(!1);b.useEffect(()=>{if(!i){!ue.current&&localStorage.getItem("shraga:authorized")!=="1"&&xe(null);return}a().then(async he=>{var $e,ot,pt;if(!he)return xe(!1);try{const un=await fetch("/api/config",{headers:{Authorization:`Bearer ${he}`}});if(un.ok)return ue.current=!0,localStorage.setItem("shraga:authorized","1"),xe(!0);const kn=await un.json().catch(()=>({}));if(un.status===401&&(($e=kn.error)!=null&&$e.includes("audience")||(ot=kn.error)!=null&&ot.includes("aud"))){console.warn("[auth] Token audience mismatch — signing out stale session"),p();return}if(un.status===403&&((pt=kn.error)!=null&&pt.toLowerCase().includes("whitelist")))return localStorage.removeItem("shraga:authorized"),xe(!1);if(ue.current)return;xe(un.status!==401&&un.status!==403)}catch{if(ue.current)return;xe(!0)}})},[i,a]);const Et=b.useCallback(()=>{i&&(ee(he=>he+1),Vl("/api/workspace",a).then(he=>he.json()).then(he=>G(he.entries??[])).catch(he=>console.warn("[workspace] refresh failed",he)))},[i,a]),Ge=b.useCallback(he=>{z($e=>$e+1),he.type==="schedule:run_started"?(H($e=>new Set($e).add(he.scheduleId)),we()):he.type==="schedule:run_finished"?(H($e=>{const ot=new Set($e);return ot.delete(he.scheduleId),ot}),we()):he.type==="schedule:deleted"&&H($e=>{const ot=new Set($e);return ot.delete(he.id),ot})},[we]),Oe=b.useRef(null),Le=b.useRef(null),an=b.useRef(ve);an.current=ve;const Hn=b.useCallback(he=>{var $e,ot;if(($e=Le.current)==null||$e.call(Le,he),he.type.startsWith("schedule:")){Ge(he);return}switch(he.type,he.type){case"workspace_change":Et();break;case"session_title_updated":we();break;case"session_messages_changed":we(),he.sessionId===an.current&&((ot=Oe.current)==null||ot.call(Oe,he.sessionId));break;case"session_busy":F(pt=>{const un=new Set(pt);return he.busy?un.add(he.sessionId):un.delete(he.sessionId),un}),he.busy||we();break}},[Ge,Et,we]),{socket:Qn,connectionStatus:Rr,authError:da}=xF(i,a,Hn),{unreads:pl,toasts:oo,markRead:St,dismissToast:lo,addToast:ae,handleUnreadEvent:ge}=Mwe(Qn,ve);Le.current=ge,Oe.current=St,rH({socket:Qn,getToken:a,pushEnabled:J,activeSessionId:ve,switchTo:()=>{},openSession:Ze,onForegroundMessage:he=>{var ot;const $e=typeof((ot=he.data)==null?void 0:ot.session)=="string"?he.data.session:void 0;$e&&ae({sessionId:$e,preview:he.body||"New message",title:he.title})}}),b.useEffect(()=>{iH()},[]),b.useEffect(()=>{Pwe(ve),ve&&St(ve)},[ve,St]),b.useEffect(()=>{const he=()=>De(t2());return window.addEventListener("popstate",he),()=>window.removeEventListener("popstate",he)},[]),b.useEffect(()=>{i&&(Vl("/api/config",a).then(he=>he.json()).then(N).catch(()=>{}),Vl("/api/skills",a).then(he=>he.json()).then(he=>q(he.skills)).catch(()=>{}),Vl("/api/features",a).then(he=>he.json()).then(he=>$(!!he.push)).catch(()=>{}))},[i,a]),b.useEffect(()=>{Et()},[Et]);const ze=b.useCallback(()=>{De(void 0),window.innerWidth<640&&w(!1)},[w]),We=b.useMemo(()=>U.filter(he=>he.type==="file").map(he=>he.path),[U]),ht=b.useMemo(()=>({socket:Qn,connectionStatus:Rr,getToken:a,token:i,agentConfig:C,setAgentConfig:N,activeSessionId:ve,skills:Y,workspaceFiles:We,openSchedules:()=>{var he;return(he=D.current)==null?void 0:he.open()},markRead:St,bumpSidebar:we,assignSession:fe,renameTab:Te,openSession:Ze}),[Qn,Rr,a,i,C,ve,Y,We,St,we,fe,Te,Ze]);return l?E.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground text-sm",children:"Loading…"}):!r||!i?E.jsx(ZH,{mode:c,needsSetup:u,onLoginLocal:f,onRegisterLocal:h}):de===null?E.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground text-sm",children:"Verifying access…"}):!de||da?E.jsx("div",{className:"flex h-full items-center justify-center bg-background",children:E.jsxs("div",{className:"flex flex-col items-center gap-4 p-8 rounded-xl border bg-card shadow-sm w-full max-w-sm text-center",children:[E.jsx("div",{className:"flex items-center justify-center w-12 h-12 rounded-full bg-destructive/10 text-destructive",children:E.jsx(Db,{className:"w-6 h-6"})}),E.jsx("h2",{className:"text-lg font-semibold",children:"Access Denied"}),E.jsx("p",{className:"text-sm text-muted-foreground",children:"Your account is not authorized to use this app."}),E.jsxs("p",{className:"text-xs text-muted-foreground",children:["Signed in as ",r.email]}),E.jsx(Me,{variant:"outline",onClick:()=>p(),children:"Sign out"})]})}):window.location.pathname==="/oauth/authorize"?E.jsx(QH,{getToken:a,userEmail:r.email??""}):window.location.pathname==="/cli-auth"?E.jsx(JH,{getToken:a,userEmail:r.email??""}):E.jsxs("div",{className:"flex h-full",children:[g&&E.jsxs("div",{className:"fixed inset-0 z-50 bg-background sm:relative sm:inset-auto sm:z-auto sm:w-64 sm:shrink-0 sm:border-r flex flex-col",children:[E.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b sm:hidden",style:{paddingTop:"max(0.5rem, env(safe-area-inset-top))"},children:[E.jsx("span",{className:"text-sm font-medium",children:"Sessions"}),E.jsx(Me,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>w(!1),children:E.jsx(VO,{className:"w-4 h-4"})})]}),E.jsx("div",{className:"flex-1 min-h-0",children:E.jsx(sJ,{getToken:a,activeSessionId:ve,onSelect:(he,$e)=>{Ze(he,$e),St(he),window.innerWidth<640&&w(!1)},onNew:ze,refreshKey:B,workspaceRefreshKey:K,onRefreshWorkspace:Et,userUid:r.uid,userEmail:r.email||"",unreads:pl,busySessions:j,socket:Qn})})]}),E.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[E.jsx("header",{className:"border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60",style:{paddingTop:"env(safe-area-inset-top)"},children:E.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 px-2 sm:px-3 py-1.5",children:[E.jsx(Me,{variant:"ghost",size:"icon",className:"h-9 w-9 sm:h-8 sm:w-8 shrink-0",onClick:()=>w(!g),title:"Toggle sidebar",children:g?E.jsx(VO,{className:"w-4 h-4"}):E.jsx(AH,{className:"w-4 h-4"})}),E.jsx(Me,{variant:"ghost",size:"icon",className:"h-9 w-9 sm:h-8 sm:w-8 shrink-0",onClick:ze,title:"New chat (⌘N)",children:E.jsx(MH,{className:"w-4 h-4"})}),E.jsx("div",{className:"flex-1"}),E.jsxs("div",{className:"hidden sm:flex items-center gap-0.5 shrink-0",children:[E.jsx(Me,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:n,title:t?"Light mode":"Dark mode",children:t?E.jsx(YO,{className:"w-4 h-4"}):E.jsx(GO,{className:"w-4 h-4"})}),(Ln=e.headerActions)==null?void 0:Ln.call(e),E.jsx(HR,{getToken:a}),E.jsx(GR,{getToken:a,onSkillsChange:q}),E.jsx(WR,{getToken:a}),E.jsx(QR,{ref:D,getToken:a,refreshKey:M,runningIds:R,onOpenSession:he=>Ze(he),skills:Y,workspaceFiles:We}),E.jsx(Me,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>p(),title:"Sign out",children:E.jsx(Db,{className:"w-4 h-4"})})]}),E.jsxs("div",{className:"relative sm:hidden shrink-0",children:[E.jsx(Me,{ref:k,variant:"ghost",size:"icon",className:"h-9 w-9",onClick:T,children:E.jsx(pH,{className:"w-4 h-4"})}),y&&nu.createPortal(E.jsxs(E.Fragment,{children:[E.jsx("div",{className:"fixed inset-0 z-[1090] cursor-pointer",onClick:()=>S(!1)}),E.jsxs("div",{className:"fixed z-[1100] border rounded-lg shadow-lg p-1 min-w-[170px] bg-white dark:bg-zinc-900 whitespace-nowrap",style:{top:A.top,right:A.right},children:[(vr=e.headerActions)==null?void 0:vr.call(e),E.jsx(HR,{getToken:a,trigger:E.jsxs("button",{className:"flex w-full items-center gap-2.5 rounded-md px-3 py-2.5 text-sm hover:bg-accent",children:[E.jsx(fD,{className:"w-3.5 h-3.5"})," MCPs"]})}),E.jsx(GR,{getToken:a,onSkillsChange:q,trigger:E.jsxs("button",{className:"flex w-full items-center gap-2.5 rounded-md px-3 py-2.5 text-sm hover:bg-accent",children:[E.jsx(ix,{className:"w-3.5 h-3.5"})," Skills"]})}),E.jsx(WR,{getToken:a,trigger:E.jsxs("button",{className:"flex w-full items-center gap-2.5 rounded-md px-3 py-2.5 text-sm hover:bg-accent",children:[E.jsx(rx,{className:"w-3.5 h-3.5"})," Modules"]})}),E.jsx(QR,{getToken:a,refreshKey:M,runningIds:R,onOpenSession:he=>Ze(he),skills:Y,workspaceFiles:We,trigger:E.jsxs("button",{className:"flex w-full items-center gap-2.5 rounded-md px-3 py-2.5 text-sm hover:bg-accent",children:[E.jsx(Dw,{className:"w-3.5 h-3.5"})," Schedules"]})}),E.jsx("div",{className:"border-t my-1"}),E.jsxs("button",{className:"flex w-full items-center gap-2.5 rounded-md px-3 py-2.5 text-sm hover:bg-accent",onClick:()=>{S(!1),n()},children:[t?E.jsx(YO,{className:"w-3.5 h-3.5"}):E.jsx(GO,{className:"w-3.5 h-3.5"}),t?"Light mode":"Dark mode"]}),E.jsxs("button",{className:"flex w-full items-center gap-2.5 rounded-md px-3 py-2.5 text-sm hover:bg-accent",onClick:()=>p(),children:[E.jsx(Db,{className:"w-3.5 h-3.5"})," Sign out"]})]})]}),document.body)]})]})}),Rr==="update_available"&&E.jsxs("div",{className:"flex items-center justify-center gap-3 py-2.5 px-4 bg-amber-500 dark:bg-amber-600 text-white text-sm font-medium animate-pulse",children:[E.jsx("span",{children:"A new version is available"}),E.jsx("button",{onClick:()=>window.location.reload(),className:"px-3 py-1 bg-white text-amber-700 rounded font-semibold text-xs hover:bg-amber-50 transition-colors",children:"Reload now"})]}),E.jsx(oH,{value:ht,children:E.jsx("div",{className:"flex-1 min-h-0",children:E.jsx(uwe,{nodeId:"main",sessionId:ve},ve??"new")})})]}),E.jsx(Dwe,{toasts:oo,onDismiss:lo,onOpen:he=>{Ze(he),St(he)}})]})}const n2="unclaw:",zwe="shraga:";function Bwe(){try{const e=Object.keys(localStorage).filter(t=>t.startsWith(n2));for(const t of e){const n=zwe+t.slice(n2.length);if(localStorage.getItem(n)===null){const r=localStorage.getItem(t);r!==null&&localStorage.setItem(n,r)}localStorage.removeItem(t)}}catch(e){console.warn("[storage] legacy key migration skipped:",e instanceof Error?e.message:String(e))}}Bwe();E$.createRoot(document.getElementById("root")).render(E.jsx(b.StrictMode,{children:E.jsx(jwe,{})}));
|
package/dist/client/index.html
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
14
14
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
15
15
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet" />
|
|
16
|
-
<script type="module" crossorigin src="/assets/index-
|
|
16
|
+
<script type="module" crossorigin src="/assets/index-Dhv0RZ8g.js"></script>
|
|
17
17
|
<link rel="stylesheet" crossorigin href="/assets/index-nyZagTjP.css">
|
|
18
18
|
</head>
|
|
19
19
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shraga",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.20",
|
|
4
4
|
"description": "The teammate you delegate coding to — a self-hostable, multi-user AI coding agent web UI (Claude Code, with a pluggable engine seam).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -32,7 +32,8 @@ interface EngineInfo {
|
|
|
32
32
|
const FALLBACK_MODELS: EngineModel[] = [
|
|
33
33
|
{ value: '', label: 'Default (claude-sonnet-5)' },
|
|
34
34
|
{ value: 'claude-fable-5', label: 'Fable 5 — frontier, most capable' },
|
|
35
|
-
{ value: 'claude-opus-
|
|
35
|
+
{ value: 'claude-opus-5', label: 'Opus 5 — most capable, best for complex/agentic tasks' },
|
|
36
|
+
{ value: 'claude-opus-4-8', label: 'Opus 4.8' },
|
|
36
37
|
{ value: 'claude-opus-4-7', label: 'Opus 4.7' },
|
|
37
38
|
{ value: 'claude-opus-4-6', label: 'Opus 4.6' },
|
|
38
39
|
{ value: 'claude-sonnet-5', label: 'Sonnet 5 — balanced speed & intelligence' },
|
|
@@ -163,7 +163,8 @@ export class ClaudeCodeEngine implements AgentEngine {
|
|
|
163
163
|
return [
|
|
164
164
|
{ value: '', label: `Default (${DEFAULT_MODEL})` },
|
|
165
165
|
{ value: 'claude-fable-5', label: 'Fable 5 — frontier, most capable' },
|
|
166
|
-
{ value: 'claude-opus-
|
|
166
|
+
{ value: 'claude-opus-5', label: 'Opus 5 — most capable' },
|
|
167
|
+
{ value: 'claude-opus-4-8', label: 'Opus 4.8' },
|
|
167
168
|
{ value: 'claude-opus-4-7', label: 'Opus 4.7' },
|
|
168
169
|
{ value: 'claude-opus-4-6', label: 'Opus 4.6' },
|
|
169
170
|
{ value: 'claude-sonnet-5', label: 'Sonnet 5 — balanced' },
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
export const MODEL_ALIASES: Record<string, string> = {
|
|
11
11
|
fable: 'claude-fable-5',
|
|
12
12
|
'fable-5': 'claude-fable-5',
|
|
13
|
-
opus: 'claude-opus-
|
|
13
|
+
opus: 'claude-opus-5',
|
|
14
|
+
'opus-5': 'claude-opus-5',
|
|
14
15
|
'opus-4-8': 'claude-opus-4-8',
|
|
15
16
|
'opus-4-7': 'claude-opus-4-7',
|
|
16
17
|
'opus-4-6': 'claude-opus-4-6',
|