@kb-labs/agent-entry 2.105.0 → 2.107.0

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.
@@ -1 +1 @@
1
- "use strict";(self.rspackChunk_kb_labs_agent_entry=self.rspackChunk_kb_labs_agent_entry||[]).push([[596],{6026(e,t){var n=Symbol.for("react.transitional.element");function r(e,t,r){var o=null;if(void 0!==r&&(o=""+r),void 0!==t.key&&(o=""+t.key),"key"in t)for(var i in r={},t)"key"!==i&&(r[i]=t[i]);else r=t;return{$$typeof:n,type:e,key:o,ref:void 0!==(t=r.ref)?t:null,props:r}}t.Fragment=Symbol.for("react.fragment"),t.jsx=r,t.jsxs=r},4552(e,t,n){e.exports=n(6026)},5916(e,t,n){n.r(t),n.d(t,{default:()=>$});var r=n(4552),o=n(92),i=n(7493),l=n(5155),s=n(4519);function a(e){var t,n=e.currentSessionId,o=e.onSessionChange,i=e.onNewChat,a=(0,l.useUITheme)().token,c=(0,s.useData)("/v1/plugins/agents/sessions?limit=20"),u=c.data,d=c.isLoading,p=null!=(t=null==u?void 0:u.sessions)?t:[],f=function(e){var t=p.find(function(t){return t.id===e});t&&o(e,t)};return(0,r.jsxs)(l.UISpace,{size:"small",style:{width:"100%"},children:[(0,r.jsx)(l.UIIcon,{name:"HistoryOutlined",style:{color:a.colorTextTertiary}}),(0,r.jsx)(l.UISelect,{style:{flex:1,minWidth:200},placeholder:"New chat",value:null!=n?n:void 0,onChange:function(e){return f(e)},loading:d,allowClear:!0,onClear:i,notFoundContent:d?(0,r.jsx)(l.UISpin,{size:"small"}):(0,r.jsx)(l.UITypographyText,{type:"secondary",children:"No sessions yet"}),optionLabelProp:"label",options:p.map(function(e){return{value:e.id,label:e.name||e.task||"Untitled",lastActivityAt:e.lastActivityAt}}),optionRender:function(e){var t,n,o,i,s;return(0,r.jsxs)(l.UISpace,{style:{width:"100%",justifyContent:"space-between"},children:[(0,r.jsx)(l.UITypographyText,{ellipsis:!0,style:{maxWidth:180},children:e.label}),(0,r.jsx)(l.UITypographyText,{type:"secondary",style:{fontSize:11},children:(t=new Date(e.data.lastActivityAt),o=Math.floor((n=new Date().getTime()-t.getTime())/6e4),i=Math.floor(n/36e5),s=Math.floor(n/864e5),o<1?"just now":o<60?"".concat(o,"m ago"):i<24?"".concat(i,"h ago"):s<7?"".concat(s,"d ago"):t.toLocaleDateString())})]})}}),(0,r.jsx)(l.UITooltip,{title:"New Chat",children:(0,r.jsx)(l.UIButton,{variant:"primary",icon:(0,r.jsx)(l.UIIcon,{name:"PlusOutlined"}),onClick:i})})]})}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function u(e,t,n,r,o,i,l){try{var s=e[i](l),a=s.value}catch(e){n(e);return}s.done?t(a):Promise.resolve(a).then(r,o)}function d(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){u(i,r,o,l,s,"next",e)}function s(e){u(i,r,o,l,s,"throw",e)}l(void 0)})}}function p(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function f(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function y(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],l=!0,s=!1;try{for(o=o.call(e);!(l=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);l=!0);}catch(e){s=!0,r=e}finally{try{l||null==o.return||o.return()}finally{if(s)throw r}}return i}}(e,t)||h(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(e,t){if(e){if("string"==typeof e)return c(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return c(e,t)}}function g(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),s=Object.defineProperty;return s(l,"next",{value:a(0)}),s(l,"throw",{value:a(1)}),s(l,"return",{value:a(2)}),"function"==typeof Symbol&&s(l,Symbol.iterator,{value:function(){return this}}),l;function a(s){return function(a){var c=[s,a];if(n)throw TypeError("Generator is already executing.");for(;l&&(l=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var x=n(9497).theme.useToken;function m(e){var t=e.turns,n=e.isLoading,o=e.isError,i=e.onRetry,s=e.sessionId,a=x().token;return n?(0,r.jsxs)(l.UIFlex,{justify:"center",align:"center",style:{minHeight:240,gap:8},children:[(0,r.jsx)(l.UISpin,{size:"small"}),(0,r.jsx)(l.UITypographyText,{type:"secondary",style:{fontSize:13},children:"Loading history..."})]}):o?(0,r.jsxs)("div",{style:{minHeight:240,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:12},children:[(0,r.jsx)(l.UIIcon,{name:"DisconnectOutlined",style:{fontSize:24,color:a.colorTextTertiary}}),(0,r.jsx)(l.UITypographyText,{type:"secondary",children:"Failed to load history"}),i&&(0,r.jsx)(l.UIButton,{size:"small",onClick:i,children:"Retry"})]}):0===t.length?(0,r.jsx)(l.UIFlex,{justify:"center",align:"center",style:{minHeight:240},children:(0,r.jsx)(l.UITypographyText,{type:"secondary",style:{fontSize:14},children:"Ask anything to get started"})}):(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",padding:"16px 16px 40px",gap:24},children:t.map(function(e){return(0,r.jsx)(v,{turn:e,sessionId:s,token:a},e.id)})})}function v(e){var t,n,o,i,s,a,c,u,d=e.turn,p=e.sessionId,f=e.token;if("user"===d.type){var y=d.steps.find(function(e){return"text"===e.type});return(0,r.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"flex-end",gap:8},children:[(0,r.jsx)("span",{style:{maxWidth:"68%",background:f.colorFillTertiary,borderRadius:"".concat(f.borderRadiusLG,"px ").concat(f.borderRadiusLG,"px 3px ").concat(f.borderRadiusLG,"px"),padding:"10px 16px",fontSize:14,lineHeight:1.55,color:f.colorText,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:(null==y?void 0:y.type)==="text"?y.content:""}),(0,r.jsx)("div",{style:{width:28,height:28,borderRadius:"50%",background:f.colorFillSecondary,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:(0,r.jsx)(l.UIIcon,{name:"UserOutlined",style:{fontSize:13,color:f.colorTextSecondary}})})]})}var h="streaming"===d.status,g=d.steps.filter(function(e){return"text"===e.type}),x=g.filter(function(e){var t,n;return!P(null!=(t=e.content)?t:"")&&(null==(n=e.content)?void 0:n.trim())}),m=d.steps.find(function(e){return"tool_use"===e.type&&"report"===e.toolName}),v=null==m||null==(a=m.input)?void 0:a.answer,j=d.steps.filter(function(e){return"text"!==e.type&&("tool_use"!==e.type||"report"!==e.toolName)}),I=j.length>0||h&&g.every(function(e){var t;return P(null!=(t=e.content)?t:"")}),k=null!=v?v:null,w=null==(c=d.metadata)?void 0:c.fileChanges,T=null==(u=d.metadata)?void 0:u.runId,U=!h&&w&&w.length>0&&!!p&&!!T,z={display:"flex",flexDirection:"column",borderLeft:"2px solid ".concat(f.colorBorderSecondary),paddingLeft:12,gap:6,marginLeft:6};return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,r.jsx)("div",{style:{width:22,height:22,borderRadius:"50%",background:f.colorFillSecondary,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:(0,r.jsx)(l.UIIcon,{name:"RobotOutlined",style:{fontSize:12,color:f.colorTextSecondary}})}),(0,r.jsx)(l.UITypographyText,{type:"secondary",style:{fontSize:12},children:"Agent"}),(0,r.jsxs)(l.UITypographyText,{type:"secondary",style:{fontSize:11},children:["\xb7 ",(t=new Date(d.startedAt),o=Math.floor((n=new Date().getTime()-t.getTime())/6e4),i=Math.floor(n/36e5),s=Math.floor(n/864e5),o<1?"just now":o<60?"".concat(o,"m ago"):i<24?"".concat(i,"h ago"):s<7?"".concat(s,"d ago"):t.toLocaleDateString())]}),h&&(0,r.jsx)(l.UITag,{color:"processing",style:{fontSize:11,lineHeight:"18px"},children:"Running"}),"failed"===d.status&&(0,r.jsx)(l.UITag,{color:"error",style:{fontSize:11,lineHeight:"18px"},children:"Failed"})]}),I&&(0,r.jsx)("div",{style:z,children:(0,r.jsx)(b,{steps:j,isStreaming:h,token:f})}),k&&(0,r.jsx)("div",{style:z,children:(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[(0,r.jsx)(S,{color:f.colorPrimary}),(0,r.jsx)(l.UIMarkdownViewer,{content:k,style:{flex:1}})]})}),!k&&x.map(function(e){var t;return"text"===e.type&&(null==(t=e.content)?void 0:t.trim())?(0,r.jsx)("div",{style:z,children:(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[(0,r.jsx)(S,{color:f.colorPrimary}),(0,r.jsx)(l.UIMarkdownViewer,{content:e.content,style:{flex:1}})]})},e.id):null}),U&&(0,r.jsx)("div",{style:z,children:(0,r.jsx)(O,{sessionId:p,runId:T,fileChanges:w,token:f})})]})}function b(e){var t=e.steps,n=e.isStreaming,i=e.token,s=y((0,o.useState)(n),2),a=s[0],c=s[1];(0,o.useEffect)(function(){n&&c(!0)},[n]);var u=Object.entries(function(e){var t={},n=!0,r=!1,o=void 0;try{for(var i,l=e[Symbol.iterator]();!(n=(i=l.next()).done);n=!0){var s=i.value;if("tool_use"===s.type){var a,c=A(s.toolName);t[c]=(null!=(a=t[c])?a:0)+1}}}catch(e){r=!0,o=e}finally{try{n||null==l.return||l.return()}finally{if(r)throw o}}return t}(t)).map(function(e){var t=y(e,2),n=t[0],r=t[1];return r>1?"".concat(n," \xd7").concat(r):n}),d=t.reduce(function(e,t){var n;return e+("tool_use"===t.type&&null!=(n=t.durationMs)?n:0)},0),p={display:"inline-flex",alignItems:"center",gap:5,background:"none",border:"none",padding:"2px 0",cursor:"pointer",fontSize:12,color:i.colorTextSecondary,fontFamily:"inherit"};return(0,r.jsxs)("div",{children:[(0,r.jsxs)("button",{style:p,onClick:function(){return c(function(e){return!e})},children:[(0,r.jsx)(l.UIIcon,{name:a?"DownOutlined":"RightOutlined",style:{fontSize:9,color:i.colorTextTertiary}}),n?(0,r.jsx)(l.UIIcon,{name:"LoadingOutlined",style:{fontSize:11,color:i.colorTextTertiary}}):null,(0,r.jsxs)("span",{style:{fontWeight:500,color:i.colorText},children:[t.length," ",1===t.length?"action":"actions"]}),!a&&u.length>0&&(0,r.jsxs)("span",{style:{color:i.colorTextTertiary},children:["— ",u.join(" ")]}),!a&&d>0&&(0,r.jsxs)("span",{style:{color:i.colorTextTertiary},children:["\xb7 ",(d/1e3).toFixed(1),"s"]})]}),a&&(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:5,marginTop:4},children:[t.map(function(e,o){return(0,r.jsx)(I,{step:e,isLast:!1,isStreaming:n&&o===t.length-1,token:i},e.id)}),n&&0===t.length&&(0,r.jsx)(j,{token:i})]})]})}function S(e){var t=e.color,n=e.pulse;return(0,r.jsx)("span",{style:{flexShrink:0,width:8,height:8,marginTop:6,borderRadius:"50%",background:t,opacity:n?.6:1}})}function j(e){var t=e.token;return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,r.jsx)(l.UIIcon,{name:"LoadingOutlined",style:{fontSize:11,color:t.colorTextTertiary}}),(0,r.jsx)(l.UITypographyText,{type:"secondary",style:{fontSize:13},children:"Thinking..."})]})}function I(e){var t,n,o,i=e.step,s=e.isStreaming,a=e.token;switch(i.type){case"thinking":var c,u,d=null!=(c=null==(u=i.content)?void 0:u.trim())?c:"";if(P(d))return null;return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[(0,r.jsx)(S,{color:a.colorWarning,pulse:s}),(0,r.jsx)("div",{style:{flex:1},children:(0,r.jsx)(l.UIMarkdownViewer,{content:d,style:{fontSize:13,opacity:.8}})})]});case"tool_use":return(0,r.jsx)(k,{step:i,isStreaming:s,token:a});case"tool_result":return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[(0,r.jsx)(l.UIIcon,{name:i.success?"CheckCircleOutlined":"CloseCircleOutlined",style:{fontSize:13,marginTop:2,color:i.success?a.colorSuccess:a.colorError}}),(0,r.jsxs)("div",{style:{flex:1},children:[(0,r.jsxs)("span",{style:{fontSize:13,color:a.colorTextSecondary},children:[(0,r.jsx)("span",{style:{fontWeight:500,color:a.colorText},children:A(i.toolName)}),void 0!==i.durationMs&&(0,r.jsxs)("span",{style:{marginLeft:6,fontSize:11,color:a.colorTextTertiary},children:[i.durationMs,"ms"]})]}),!i.success&&i.error&&(0,r.jsx)("p",{style:{margin:"4px 0 0",fontSize:12,color:a.colorError},children:i.error})]})]});case"subagent":return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[(0,r.jsx)(l.UIIcon,{name:"RobotOutlined",style:{fontSize:13,marginTop:2,color:a.colorPrimary}}),(0,r.jsxs)("span",{style:{fontSize:13,color:a.colorTextSecondary},children:[(0,r.jsxs)("span",{style:{fontWeight:500,color:a.colorText},children:["Agent: ",i.agentName]}),(0,r.jsxs)("span",{style:{marginLeft:6},children:["— ",null==(n=i.task)?void 0:n.slice(0,60),(null!=(t=null==(o=i.task)?void 0:o.length)?t:0)>60?"...":""]})]})]});case"error":return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[(0,r.jsx)(l.UIIcon,{name:"ExclamationCircleOutlined",style:{fontSize:13,marginTop:2,color:a.colorError}}),(0,r.jsxs)("div",{style:{flex:1},children:[(0,r.jsx)("span",{style:{fontSize:13,fontWeight:500,color:a.colorError},children:i.code}),(0,r.jsx)("p",{style:{margin:"4px 0 0",fontSize:12,color:a.colorError},children:i.message})]})]});default:return null}}function k(e){var t,n,i,s=e.step,a=e.isStreaming,c=e.token,u=y((0,o.useState)(!1),2),d=u[0],p=u[1],f="pending"===s.status,h="done"===s.status,g="error"===s.status,x=h&&!1===s.success,m=function(e){var t=e.input;if(!t)return{};var n=e.toolName.toLowerCase(),r=n.includes("read"),o=n.includes("write")||n.includes("patch")||n.includes("edit"),i=null!=(s=null!=(a=null!=(c=t.path)?c:t.filePath)?a:t.file_path)?s:t.file;if(i){var l=null!=(h=String(i).split("/").pop())?h:String(i);if(r){var s,a,c,u,d,p,f,y,h,g,x,m,v,b,S=null!=(x=null!=(m=t.offset)?m:t.startLine)?x:t.start_line,j=null!=(v=null!=(b=t.limit)?b:t.endLine)?v:t.end_line;void 0!==S&&void 0!==j?g="".concat(S,"-").concat(Number(S)+Number(j)):void 0!==j&&(g="".concat(j," lines"))}return{summary:l,filePath:String(i),badge:g}}var I=null!=(u=null!=(d=null!=(p=t.query)?p:t.text)?d:t.pattern)?u:t.search;if(I)return{summary:String(I).slice(0,100)};var k=null!=(f=t.command)?f:t.cmd;if(k)return{summary:String(k).slice(0,100)};if(o)return{};var w=null!=(y=t.content)?y:t.message;return w?{summary:String(w).slice(0,100)}:{}}(s),v=h&&!!(null==(i=s.metadata)?void 0:i.diff),b=h&&null!=s.output,S=s.input,j=/write|patch|edit/i.test(s.toolName)&&h&&!!(null!=(n=null==S?void 0:S.content)?n:null==S?void 0:S.new_content),I=b||v||j||g,k=f?a?c.colorTextTertiary:c.colorPrimary:h&&!x?c.colorSuccess:c.colorError,T=s.metadata,O=h&&(null==T?void 0:T.uiHint)==="todo"&&null!=T.structured?T.structured.todoList:void 0;return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[(0,r.jsx)(l.UIIcon,{name:f&&a?"LoadingOutlined":(t=s.toolName.toLowerCase(),/read|open/.test(t)?"FileTextOutlined":/write|patch|edit/.test(t)?"EditOutlined":/bash|exec|shell|run/.test(t)?"CodeOutlined":/grep|search|glob|find/.test(t)?"SearchOutlined":/todo/.test(t)?"CheckSquareOutlined":/rag|mind|embed/.test(t)?"BulbOutlined":/agent|subagent/.test(t)?"RobotOutlined":/delete|remove/.test(t)?"DeleteOutlined":"ApiOutlined"),style:{fontSize:13,marginTop:2,color:k,flexShrink:0}}),(0,r.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,r.jsxs)("button",{onClick:function(){return I&&p(function(e){return!e})},disabled:!I,style:{display:"inline-flex",alignItems:"center",gap:6,background:"none",border:"none",padding:0,cursor:I?"pointer":"default",fontSize:13,color:c.colorText,flexWrap:"wrap",fontFamily:"inherit"},children:[(0,r.jsx)("span",{style:{fontWeight:500},children:A(s.toolName)}),m.badge&&(0,r.jsx)("span",{style:{fontSize:11,color:c.colorTextSecondary,background:c.colorFillSecondary,borderRadius:c.borderRadiusSM,padding:"0 5px"},children:m.badge}),h&&(null==T?void 0:T.resultCount)!==void 0&&(0,r.jsxs)("span",{style:{fontSize:11,color:c.colorTextSecondary,background:c.colorFillSecondary,borderRadius:c.borderRadiusSM,padding:"0 5px"},children:[T.resultCount," results"]}),h&&(null==T?void 0:T.exitCode)!==void 0&&0!==T.exitCode&&(0,r.jsxs)("span",{style:{fontSize:11,color:c.colorError,background:c.colorErrorBg,borderRadius:c.borderRadiusSM,padding:"0 5px"},children:["exit ",T.exitCode]}),h&&((null==T?void 0:T.linesAdded)!==void 0||(null==T?void 0:T.linesRemoved)!==void 0)&&(0,r.jsxs)("span",{style:{fontSize:11,color:c.colorSuccess,background:c.colorSuccessBg,borderRadius:c.borderRadiusSM,padding:"0 5px"},children:[(null==T?void 0:T.linesAdded)!=null&&T.linesAdded>0?"+".concat(T.linesAdded):"",(null==T?void 0:T.linesRemoved)!=null&&T.linesRemoved>0?" -".concat(T.linesRemoved):""]}),!f&&void 0!==s.durationMs&&(0,r.jsxs)("span",{style:{fontSize:11,color:c.colorTextTertiary},children:[s.durationMs,"ms"]}),I&&(0,r.jsx)("span",{style:{fontSize:11,color:c.colorTextTertiary},children:d?"▲":"▼"})]}),m.summary&&(0,r.jsx)("p",{style:{margin:"2px 0 0",fontSize:12,color:c.colorTextSecondary},children:m.filePath?(0,r.jsx)(U,{path:m.filePath,label:m.summary,token:c}):m.summary}),null!=O&&(0,r.jsx)(R,{todoList:O,token:c}),g&&s.error&&(0,r.jsx)("p",{style:{margin:"4px 0 0",fontSize:12,color:c.colorError},children:s.error}),x&&!d&&null!=s.output&&(0,r.jsx)("p",{style:{margin:"4px 0 0",fontSize:12,color:c.colorError},children:String(s.output)}),d&&(0,r.jsx)("div",{style:{marginTop:6},children:(0,r.jsx)(w,{step:s,hasDiff:v,hasOutput:b,token:c})})]})]})}function w(e){var t=e.step,n=e.hasDiff,o=e.hasOutput,i=e.token,s=t.input,a=t.toolName.toLowerCase(),c=a.includes("write")||a.includes("patch")||a.includes("edit"),u=a.includes("read"),d=a.includes("bash")||a.includes("exec")||a.includes("shell")||a.includes("run"),y=a.includes("grep")||a.includes("search")||a.includes("glob")||a.includes("list")||a.includes("rag"),h={margin:0,padding:"8px 10px",fontSize:12,lineHeight:1.5,borderRadius:i.borderRadius,overflow:"auto",maxHeight:300,whiteSpace:"pre-wrap",wordBreak:"break-all"};if(c){if(n)return(0,r.jsx)(T,{diff:t.metadata.diff,token:i});var g=null!=(x=null!=(m=null==s?void 0:s.content)?m:null==s?void 0:s.new_content)?x:null==s?void 0:s.text;if(g){var x,m,v,b,S,j=null!=(v=null!=(b=null!=(S=null==s?void 0:s.path)?S:null==s?void 0:s.filePath)?b:null==s?void 0:s.file_path)?v:null==s?void 0:s.file,I=j?j.split(".").pop():void 0;return(0,r.jsxs)("div",{children:[j&&(0,r.jsx)("div",{style:{fontSize:11,color:i.colorTextTertiary,padding:"3px 8px",background:i.colorFillSecondary,borderRadius:"".concat(i.borderRadius,"px ").concat(i.borderRadius,"px 0 0")},children:j}),(0,r.jsx)("pre",{style:f(p({},h),{background:i.colorFillSecondary,borderRadius:j?"0 0 ".concat(i.borderRadius,"px ").concat(i.borderRadius,"px"):i.borderRadius}),className:I?"lang-".concat(I):void 0,children:String(g)})]})}return null}if(u&&o)return(0,r.jsx)("pre",{style:f(p({},h),{background:i.colorFillSecondary}),children:D(t.output)});if(d&&o)return(0,r.jsx)("pre",{style:f(p({},h),{background:i.colorBgSpotlight,color:i.colorTextLightSolid}),children:D(t.output)});if(y&&o)return(0,r.jsx)("pre",{style:f(p({},h),{background:i.colorFillSecondary}),children:D(t.output)});if(n)return(0,r.jsx)(T,{diff:t.metadata.diff,token:i});if(o){var k="done"===t.status&&!1===t.success,w=D(t.output);return k?(0,r.jsx)("pre",{style:f(p({},h),{background:i.colorErrorBg,color:i.colorError}),children:w}):(0,r.jsx)(l.UIMarkdownViewer,{content:w,style:{fontSize:12}})}return null}function T(e){var t=e.diff,n=e.token,o=t.split("\n");return(0,r.jsx)("pre",{style:{margin:0,padding:"8px 10px",fontSize:12,lineHeight:1.5,borderRadius:n.borderRadius,overflow:"auto",maxHeight:300,background:n.colorFillSecondary,whiteSpace:"pre"},children:o.map(function(e,t){var o=e.startsWith("+")&&!e.startsWith("+++")?n.colorSuccess:e.startsWith("-")&&!e.startsWith("---")?n.colorError:e.startsWith("@@")?n.colorInfo:void 0;return(0,r.jsxs)("span",{style:o?{color:o}:void 0,children:[e,"\n"]},t)})})}function U(e){var t=e.path,n=e.label,i=e.token,l=y((0,o.useState)(!1),2),s=l[0],a=l[1];return(0,r.jsxs)("span",{onClick:function(e){e.stopPropagation(),navigator.clipboard.writeText(t).then(function(){a(!0),setTimeout(function(){return a(!1)},1500)})},title:t,style:{cursor:"pointer",color:s?i.colorSuccess:i.colorTextSecondary,fontFamily:"monospace",fontSize:12},children:[n,s?" ✓":""]})}function O(e){var t=e.sessionId,n=e.runId,i=e.fileChanges,a=e.token,u=y((0,o.useState)(new Set),2),p=u[0],f=u[1],x=(0,s.useMutateData)("/v1/plugins/agents/sessions/".concat(t,"/rollback"),"POST"),m=(0,s.useMutateData)("/v1/plugins/agents/sessions/".concat(t,"/approve"),"POST"),v=i.filter(function(e){return!p.has(e.changeId)&&!e.approved});return 0===v.length?null:(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[(0,r.jsx)(l.UIIcon,{name:"FileOutlined",style:{fontSize:13,marginTop:2,color:a.colorSuccess}}),(0,r.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:4},children:[(0,r.jsxs)(l.UITypographyText,{style:{fontSize:13,fontWeight:500},children:[v.length," ",L(v.length)," changed"]}),(0,r.jsxs)(l.UIFlex,{gap:4,children:[(0,r.jsx)("button",{onClick:function(){d(function(){return g(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,m.mutateAsync({runId:n})];case 1:return e.sent(),f(new Set(v.map(function(e){return e.changeId}))),[3,3];case 2:return e.sent(),console.error("Failed to approve changes"),[3,3];case 3:return[2]}})})()},disabled:m.isLoading||x.isLoading,title:"Approve all",style:{background:a.colorSuccessBg,border:"1px solid ".concat(a.colorSuccessBorder),color:a.colorSuccess,borderRadius:a.borderRadius,padding:"2px 8px",fontSize:12,cursor:"pointer"},children:"✓"}),(0,r.jsx)("button",{onClick:function(){(0,l.UIModalConfirm)({title:"Rollback changes?",content:"This will revert ".concat(v.length," ").concat(L(v.length)," to the state before the agent run."),okText:"Rollback",okButtonProps:{danger:!0},cancelText:"Cancel",onOk:function(){return d(function(){var e,t;return g(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,x.mutateAsync({runId:n})];case 1:return(null==(e=(t=r.sent()).conflicts)?void 0:e.length)&&console.warn("Rolled back: ".concat(t.rolledBack,", skipped: ").concat(t.skipped)),f(new Set(v.map(function(e){return e.changeId}))),[3,3];case 2:return r.sent(),console.error("Failed to rollback changes"),[3,3];case 3:return[2]}})})()}})},disabled:x.isLoading||m.isLoading,title:"Rollback all",style:{background:a.colorErrorBg,border:"1px solid ".concat(a.colorErrorBorder),color:a.colorError,borderRadius:a.borderRadius,padding:"2px 8px",fontSize:12,cursor:"pointer"},children:"✕"})]})]}),(0,r.jsx)("ul",{style:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:2},children:v.map(function(e){return(0,r.jsx)(z,{change:e,sessionId:t,onDismiss:function(){return f(function(t){return new Set(((function(e){if(Array.isArray(e))return c(e)})(t)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||h(t)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).concat([e.changeId]))})},token:a},e.changeId)})})]})]})}function z(e){var t,n=e.change,i=e.sessionId,a=e.onDismiss,c=e.token,u=y((0,o.useState)(!1),2),p=u[0],f=u[1],h=(0,s.useMutateData)("/v1/plugins/agents/sessions/".concat(i,"/rollback"),"POST"),x=(0,s.useMutateData)("/v1/plugins/agents/sessions/".concat(i,"/approve"),"POST"),m=p?"/v1/plugins/agents/sessions/".concat(i,"/changes/").concat(encodeURIComponent(n.changeId),"/diff"):"",v=(0,s.useData)(m,{enabled:p}),b=v.data,S=v.isLoading,j=v.isError,I=n.isNew?(0,r.jsx)(l.UITag,{color:"success",children:"new"}):"delete"===n.operation?(0,r.jsx)(l.UITag,{color:"error",children:"del"}):(0,r.jsx)(l.UITag,{color:"blue",children:"mod"});return(0,r.jsxs)("li",{children:[(0,r.jsxs)("div",{onClick:function(){return f(function(e){return!e})},style:{display:"flex",alignItems:"center",gap:6,fontSize:12,cursor:"pointer",padding:"2px 4px",borderRadius:c.borderRadiusSM,background:p?c.colorFillSecondary:"transparent"},children:[I,(0,r.jsx)("span",{style:{flex:1,fontFamily:"monospace",color:c.colorTextSecondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:null!=(t=n.filePath.split("/").pop())?t:n.filePath}),(0,r.jsx)("span",{style:{color:c.colorTextTertiary,fontFamily:"monospace",fontSize:11},children:n.filePath.includes("/")?n.filePath.slice(0,n.filePath.lastIndexOf("/")):""}),!n.approved&&(0,r.jsxs)("div",{style:{display:"flex",gap:4},onClick:function(e){return e.stopPropagation()},children:[(0,r.jsx)("button",{onClick:function(e){e.stopPropagation(),x.mutateAsync({changeIds:[n.changeId]}).then(a).catch(function(){console.error("Failed to approve file")})},disabled:x.isLoading,title:"Approve",style:{background:"none",border:"none",cursor:"pointer",color:c.colorSuccess,fontSize:13,padding:"0 2px"},children:"✓"}),(0,r.jsx)("button",{onClick:function(e){e.stopPropagation(),(0,l.UIModalConfirm)({title:"Rollback file?",content:n.filePath,okText:"Rollback",okButtonProps:{danger:!0},cancelText:"Cancel",onOk:function(){return d(function(){return g(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,h.mutateAsync({changeIds:[n.changeId]})];case 1:return e.sent(),a(),[3,3];case 2:return e.sent(),console.error("Failed to rollback file"),[3,3];case 3:return[2]}})})()}})},disabled:h.isLoading,title:"Rollback",style:{background:"none",border:"none",cursor:"pointer",color:c.colorError,fontSize:13,padding:"0 2px"},children:"✕"})]})]}),p&&(0,r.jsxs)("div",{style:{marginTop:4,marginLeft:4},children:[S&&(0,r.jsx)(l.UISpin,{size:"small"}),(null==b?void 0:b.diff)&&(0,r.jsx)(T,{diff:b.diff,token:c}),j&&(0,r.jsx)("span",{style:{color:c.colorError,fontSize:12},children:"Failed to load diff"})]})]})}var C={completed:"✓","in-progress":"●",blocked:"✕",pending:"○"};function R(e){var t,n=e.todoList,o=e.token;if(!(null==n||null==(t=n.items)?void 0:t.length))return null;var i=n.items.filter(function(e){return"completed"===e.status}).length;return(0,r.jsxs)("div",{style:{marginTop:6,background:o.colorFillTertiary,borderRadius:o.borderRadius,padding:"8px 10px"},children:[(0,r.jsxs)("div",{style:{fontSize:11,color:o.colorTextTertiary,marginBottom:6,fontWeight:500},children:[i,"/",n.items.length]}),(0,r.jsx)("ul",{style:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:2},children:n.items.map(function(e){var t;return(0,r.jsxs)("li",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13,lineHeight:1.5,padding:"2px 0"},children:[(0,r.jsx)("span",{style:{fontSize:12,flexShrink:0,width:14,textAlign:"center",lineHeight:1},children:null!=(t=C[e.status])?t:"○"}),"completed"===e.status?(0,r.jsx)(l.UITypographyText,{type:"success",style:{flex:1,minWidth:0,textDecoration:"line-through"},children:e.description}):"pending"===e.status||"blocked"===e.status?(0,r.jsx)(l.UITypographyText,{type:"secondary",style:{flex:1,minWidth:0},children:e.description}):(0,r.jsx)(l.UITypographyText,{style:{flex:1,minWidth:0},children:e.description}),"medium"!==e.priority&&(0,r.jsx)(l.UITypographyText,{type:"secondary",style:{fontSize:11,flexShrink:0},children:e.priority})]},e.id)})})]})}function A(e){var t=e.trim().toLowerCase().replace(/[_-]/g," ");if(t.includes("fs read")||t.includes("read file"))return"Read";if(t.includes("fs write")||t.includes("write file"))return"Write";if(t.includes("fs patch")||t.includes("patch file")||t.includes("fs edit")||t.includes("edit file"))return"Edit";if(t.includes("fs delete")||t.includes("delete file")||t.includes("remove file"))return"Delete";if(t.includes("fs list")||t.includes("list files")||t.includes("glob"))return"Glob";if(t.includes("grep")||t.includes("search content"))return"Grep";if(t.includes("bash")||t.includes("exec")||t.includes("shell")||t.includes("run command"))return"Bash";if(t.includes("rag")||t.includes("mind"))return"Mind";if(t.includes("todo"))return"TodoWrite";var n=e.indexOf(":");return(n>=0?e.slice(n+1):e).replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/\b\w/g,function(e){return e.toUpperCase()})}function P(e){var t=e.trim().toLowerCase();return!!("[executing tools...]"===t||"[thinking...]"===t||"[planning...]"===t||"[analyzing...]"===t||"analyzing context and choosing the next step."===t||t.startsWith("checking facts with tool:")||t.startsWith("running step with tool:")||t.startsWith("running the next step"))||"done."===t||"ok."===t||"done"===t||"ok"===t}function L(e){return 1===e?"file":"files"}function D(e){if("string"==typeof e)return e.slice(0,2e3);try{return JSON.stringify(e,null,2).slice(0,2e3)}catch(t){return String(e).slice(0,2e3)}}function E(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function M(e,t,n,r,o,i,l){try{var s=e[i](l),a=s.value}catch(e){n(e);return}s.done?t(a):Promise.resolve(a).then(r,o)}function F(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){M(i,r,o,l,s,"next",e)}function s(e){M(i,r,o,l,s,"throw",e)}l(void 0)})}}function B(e,t){return null!=t&&"u">typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function W(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],l=!0,s=!1;try{for(o=o.call(e);!(l=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);l=!0);}catch(e){s=!0,r=e}finally{try{l||null==o.return||o.return()}finally{if(s)throw r}}return i}}(e,t)||N(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _(e){return function(e){if(Array.isArray(e))return E(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||N(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function N(e,t){if(e){if("string"==typeof e)return E(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return E(e,t)}}function q(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),s=Object.defineProperty;return s(l,"next",{value:a(0)}),s(l,"throw",{value:a(1)}),s(l,"return",{value:a(2)}),"function"==typeof Symbol&&s(l,Symbol.iterator,{value:function(){return this}}),l;function a(s){return function(a){var c=[s,a];if(n)throw TypeError("Generator is already executing.");for(;l&&(l=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}function H(e,t){if(e.sequence!==t.sequence)return e.sequence-t.sequence;if(e.type!==t.type){if("user"===e.type)return -1;if("user"===t.type)return 1}return e.startedAt.localeCompare(t.startedAt)}function G(e){var t=e.status,n=e.sessionId,o=e.onReconnect,i=(0,l.useUITheme)().token;return n&&"connected"!==t?"connecting"===t?(0,r.jsxs)(l.UISpace,{size:4,children:[(0,r.jsx)(l.UIIcon,{name:"LoadingOutlined",style:{fontSize:12,color:i.colorTextTertiary}}),(0,r.jsx)(l.UITypographyText,{type:"secondary",style:{fontSize:12},children:"Connecting..."})]}):(0,r.jsxs)(l.UISpace,{size:4,children:[(0,r.jsx)(l.UIIcon,{name:"DisconnectOutlined",style:{fontSize:12,color:i.colorError}}),(0,r.jsx)(l.UIButton,{variant:"link",size:"small",style:{padding:0,fontSize:12,height:"auto"},onClick:o,children:"Reconnect"})]}):null}let $=function(){var e,t,n=(0,l.useUITheme)().token,c=(0,o.useRef)(null),u=W((0,i.useSearchParams)(),2),d=u[0],p=u[1],f=W((0,o.useState)(function(){return d.get("session")}),2),y=f[0],h=f[1],g=W((0,o.useState)(function(){return d.get("session")}),2),x=g[0],v=g[1],b=W((0,o.useState)(""),2),S=b[0],j=b[1],I=W((0,o.useState)(null),2),k=I[0],w=I[1],T=W((0,o.useState)("idle"),2),U=T[0],O=T[1],z=W((0,o.useState)([]),2),C=z[0],R=z[1],A=W((0,o.useState)([]),2),P=A[0],L=A[1],D=W((0,o.useState)("auto"),2),E=D[0],M=D[1],N=W((0,o.useState)("medium"),2),$=N[0],V=N[1],K=W((0,o.useState)(!0),2),J=K[0],Z=K[1],Q=W((0,o.useState)("execute"),2),X=Q[0],Y=Q[1],ee=W((0,o.useState)(!1),2),et=ee[0],en=ee[1],er="mind-assistant",eo=y?(e="https:"===window.location.protocol?"wss:":"ws:",t=window.location.host,"".concat(e,"//").concat(t,"/api/v1/ws/plugins/agents/session/").concat(y)):null,ei=(0,s.useMutateData)("/v1/plugins/agents/run","POST"),el=(0,s.useMutateData)(k?"/v1/plugins/agents/run/".concat(k,"/stop"):"/v1/plugins/agents/run/noop/stop","POST"),es=y?"/v1/plugins/agents/sessions/".concat(y,"/turns"):"",ea=(0,s.useData)(es,{enabled:!!y}),ec=ea.data,eu=ea.isFetching,ed=ea.isError,ep=ea.refetch;(0,o.useEffect)(function(){y&&(ec||ed)&&!eu&&v(y)},[y,ec,ed,eu]);var ef=(0,s.useWebSocket)(eo,{reconnect:!0,maxReconnects:10,reconnectIntervalMs:2e3,onMessage:function(e){switch(e.type){case"conversation:snapshot":L(_(e.payload.completedTurns).concat(_(e.payload.activeTurns)).sort(function(e,t){return e.sequence-t.sequence})),R([]);break;case"turn:snapshot":var t=e.payload.turn;L(function(e){var n=e.findIndex(function(e){return e.id===t.id});if(n>=0){var r=_(e);return r[n]=t,r}return _(e).concat([t]).sort(function(e,t){return e.sequence-t.sequence})});break;case"run:completed":var n=e.payload,r=n.success,o=n.summary;O(r?"completed":"failed"),R([]),ep(),console.log("[AgentsPage] Run completed:",o);break;case"error":var i=e.payload,s=i.code,a=i.message;l.UIMessage.error("Agent error [".concat(s,"]: ").concat(a))}}});(0,o.useEffect)(function(){var e=c.current;e&&(e.scrollTop=e.scrollHeight)},[P.length,C.length]);var ey=(0,o.useCallback)(function(e,t){h(e),v(null),p({session:e},{replace:!0}),w(null),O("idle"),R([]),L([]),ef.clear()},[ef,p]),eh=(0,o.useCallback)(function(){h(null),v(null),p({},{replace:!0}),w(null),O("idle"),R([]),L([]),ef.clear()},[ef,p]),eg=(0,o.useCallback)(function(){return F(function(){var e,t,n,r;return q(this,function(o){switch(o.label){case 0:if(!S.trim())return[2];e=S.trim(),j(""),O("running"),t={id:"optimistic-user-".concat(Date.now()),type:"user",sequence:9999,startedAt:new Date().toISOString(),completedAt:new Date().toISOString(),status:"completed",steps:[{type:"text",id:"opt-1",timestamp:new Date().toISOString(),content:e,role:"user"}],metadata:{agentId:"user"}},R(function(e){return _(e).concat([t])}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,ei.mutateAsync({task:e,agentId:er,sessionId:null!=y?y:void 0,tier:$,enableEscalation:J,responseMode:E,mode:X})];case 2:return n=o.sent(),y||(h(n.sessionId),v(n.sessionId),p({session:n.sessionId},{replace:!0})),w(n.runId),ef.isConnected&&setTimeout(function(){return R([])},500),[3,4];case 3:return r=o.sent(),R(function(e){return e.filter(function(e){return e.id!==t.id})}),O("failed"),l.UIMessage.error("Failed to start: ".concat(B(r,Error)?r.message:String(r))),[3,4];case 4:return[2]}})})()},[S,er,y,$,J,E,X,p,ei,ef]),ex=(0,o.useCallback)(function(){return F(function(){var e;return q(this,function(t){switch(t.label){case 0:if(!k)return[2];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,el.mutateAsync({reason:"Stopped by user"})];case 2:return t.sent(),O("stopped"),l.UIMessage.info("Stopped"),[3,4];case 3:return e=t.sent(),l.UIMessage.error("Failed to stop: ".concat(B(e,Error)?e.message:String(e))),[3,4];case 4:return[2]}})})()},[k,el]),em="running"===U||ei.isLoading,ev=null!==y&&y!==x,eb=function(){if(ev)return[];var e=null!=(i=null==ec?void 0:ec.turns)?i:[],t=new Map;if(0===P.length){var n=!0,r=!1,o=void 0;try{for(var i,l,s=e[Symbol.iterator]();!(n=(l=s.next()).done);n=!0){var a=l.value;t.set(a.id,a)}}catch(e){r=!0,o=e}finally{try{n||null==s.return||s.return()}finally{if(r)throw o}}}else{var c=!0,u=!1,d=void 0;try{for(var p,f=e[Symbol.iterator]();!(c=(p=f.next()).done);c=!0){var y=p.value;t.set(y.id,y)}}catch(e){u=!0,d=e}finally{try{c||null==f.return||f.return()}finally{if(u)throw d}}var h=!0,g=!1,x=void 0;try{for(var m,v=P[Symbol.iterator]();!(h=(m=v.next()).done);h=!0){var b=m.value;t.set(b.id,b)}}catch(e){g=!0,x=e}finally{try{h||null==v.return||v.return()}finally{if(g)throw x}}}var S=new Set(_(t.values()).filter(function(e){return"user"===e.type}).flatMap(function(e){return e.steps.filter(function(e){return"text"===e.type}).map(function(e){var t;return null==(t=e.content)?void 0:t.trim()})}).filter(Boolean)),j=!0,I=!1,k=void 0;try{for(var w,T=C[Symbol.iterator]();!(j=(w=T.next()).done);j=!0){var U,O,z=w.value,R=null==(O=z.steps.find(function(e){return"text"===e.type}))||null==(U=O.content)?void 0:U.trim();R&&!S.has(R)&&t.set(z.id,z)}}catch(e){I=!0,k=e}finally{try{j||null==T.return||T.return()}finally{if(I)throw k}}return _(t.values()).sort(H)}(),eS=function(){if(!em||eb.some(function(e){return"assistant"===e.type&&"streaming"===e.status}))return eb;var e=_(eb).reverse().find(function(e){return"user"===e.type});if(!e||eb.some(function(t){return"assistant"===t.type&&"completed"===t.status&&t.sequence>e.sequence}))return eb;var t={id:"thinking-loader-".concat(e.id),type:"assistant",sequence:e.sequence+.1,startedAt:new Date().toISOString(),completedAt:null,status:"streaming",steps:[],metadata:{agentId:"assistant-loader"}};return _(eb).concat([t]).sort(H)}(),ej=ev||eu&&0===eb.length&&!!y;return(0,r.jsx)("div",{style:{height:"100%",overflow:"hidden",display:"flex",flexDirection:"column"},children:(0,r.jsxs)(l.UICard,{title:(0,r.jsxs)(l.UISpace,{children:[(0,r.jsx)(l.UIIcon,{name:"RobotOutlined"}),(0,r.jsx)("span",{children:"Agent"})]}),extra:(0,r.jsx)(a,{currentSessionId:y,onSessionChange:ey,onNewChat:eh}),style:{height:"100%",display:"flex",flexDirection:"column"},styles:{body:{flex:1,display:"flex",flexDirection:"column",padding:0,overflow:"hidden"}},children:[(0,r.jsx)("div",{ref:c,style:{flex:1,overflow:"auto"},children:(0,r.jsx)(m,{turns:eS,isLoading:ej,isError:ed,onRetry:function(){ep()},sessionId:y})}),(0,r.jsx)("div",{style:{borderTop:"1px solid ".concat(n.colorBorderSecondary),padding:"12px 16px",background:n.colorBgContainer},children:(0,r.jsxs)("div",{onFocus:function(){return en(!0)},onBlur:function(){return en(!1)},style:{border:"1px solid ".concat(et?"execute"===X?n.colorError:n.colorPrimary:"plan"===X?n.colorPrimary:n.colorBorder),borderRadius:n.borderRadiusLG,background:n.colorBgContainer,boxShadow:et?"0 0 0 2px ".concat("execute"===X?n.colorErrorBg:n.colorPrimaryBg):"none",transition:"border-color 0.2s, box-shadow 0.2s",overflow:"hidden"},children:[(0,r.jsx)(l.UIInputTextArea,{value:S,onChange:function(e){return j(e.target.value)},onKeyDown:function(e){"Enter"!==e.key||e.shiftKey||"running"===U||ei.isLoading||(e.preventDefault(),eg())},placeholder:"Message...",autoSize:{minRows:2,maxRows:8},disabled:em,variant:"borderless",style:{resize:"none",padding:"10px 12px 4px",border:"none",boxShadow:"none",outline:"none"}}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 8px 8px"},children:[(0,r.jsxs)(l.UISpace,{size:6,children:[(0,r.jsx)(G,{status:ef.status,sessionId:y,onReconnect:function(){return ef.connect()}}),(0,r.jsx)(l.UISelect,{value:X,onChange:function(e){return Y(e)},disabled:em,size:"small",variant:"borderless",style:{width:110},options:[{value:"execute",label:"Execute"},{value:"plan",label:"Plan"}]}),(0,r.jsx)(l.UISelect,{value:E,onChange:function(e){return M(e)},disabled:em,size:"small",variant:"borderless",style:{width:80},options:[{value:"auto",label:"Auto"},{value:"brief",label:"Brief"},{value:"deep",label:"Deep"}]}),(0,r.jsx)(l.UISelect,{value:$,onChange:function(e){return V(e)},disabled:em,size:"small",variant:"borderless",style:{width:100},options:[{value:"small",label:"Small"},{value:"medium",label:"Medium"},{value:"large",label:"Large"}]}),(0,r.jsxs)(l.UISpace,{size:4,align:"center",children:[(0,r.jsx)(l.UISwitch,{checked:J,onChange:Z,disabled:em||"large"===$,size:"small"}),(0,r.jsx)(l.UITypographyText,{type:"secondary",style:{fontSize:12},children:"Auto escalate"})]})]}),(0,r.jsx)("div",{children:em?(0,r.jsx)(l.UIButton,{danger:!0,size:"small",icon:el.isLoading?(0,r.jsx)(l.UIIcon,{name:"LoadingOutlined"}):(0,r.jsx)(l.UIIcon,{name:"StopOutlined"}),onClick:ex,disabled:el.isLoading,children:"Stop"}):(0,r.jsx)(l.UIButton,{variant:"primary",size:"small",icon:ei.isLoading?(0,r.jsx)(l.UIIcon,{name:"LoadingOutlined"}):(0,r.jsx)(l.UIIcon,{name:"SendOutlined"}),onClick:eg,disabled:!S.trim()||ei.isLoading,children:"Send"})})]})]})})]})})}}}]);
1
+ "use strict";(self.rspackChunk_kb_labs_agent_entry=self.rspackChunk_kb_labs_agent_entry||[]).push([[596],{6026(e,t){var n=Symbol.for("react.transitional.element");function r(e,t,r){var o=null;if(void 0!==r&&(o=""+r),void 0!==t.key&&(o=""+t.key),"key"in t)for(var i in r={},t)"key"!==i&&(r[i]=t[i]);else r=t;return{$$typeof:n,type:e,key:o,ref:void 0!==(t=r.ref)?t:null,props:r}}t.Fragment=Symbol.for("react.fragment"),t.jsx=r,t.jsxs=r},4552(e,t,n){e.exports=n(6026)},5916(e,t,n){n.r(t),n.d(t,{default:()=>$});var r=n(4552),o=n(92),i=n(5963),l=n(5155),s=n(4519);function a(e){var t,n=e.currentSessionId,o=e.onSessionChange,i=e.onNewChat,a=(0,l.useUITheme)().token,c=(0,s.useData)("/v1/plugins/agents/sessions?limit=20"),u=c.data,d=c.isLoading,p=null!=(t=null==u?void 0:u.sessions)?t:[],f=function(e){var t=p.find(function(t){return t.id===e});t&&o(e,t)};return(0,r.jsxs)(l.UISpace,{size:"small",style:{width:"100%"},children:[(0,r.jsx)(l.UIIcon,{name:"HistoryOutlined",style:{color:a.colorTextTertiary}}),(0,r.jsx)(l.UISelect,{style:{flex:1,minWidth:200},placeholder:"New chat",value:null!=n?n:void 0,onChange:function(e){return f(e)},loading:d,allowClear:!0,onClear:i,notFoundContent:d?(0,r.jsx)(l.UISpin,{size:"small"}):(0,r.jsx)(l.UITypographyText,{type:"secondary",children:"No sessions yet"}),optionLabelProp:"label",options:p.map(function(e){return{value:e.id,label:e.name||e.task||"Untitled",lastActivityAt:e.lastActivityAt}}),optionRender:function(e){var t,n,o,i,s;return(0,r.jsxs)(l.UISpace,{style:{width:"100%",justifyContent:"space-between"},children:[(0,r.jsx)(l.UITypographyText,{ellipsis:!0,style:{maxWidth:180},children:e.label}),(0,r.jsx)(l.UITypographyText,{type:"secondary",style:{fontSize:11},children:(t=new Date(e.data.lastActivityAt),o=Math.floor((n=new Date().getTime()-t.getTime())/6e4),i=Math.floor(n/36e5),s=Math.floor(n/864e5),o<1?"just now":o<60?"".concat(o,"m ago"):i<24?"".concat(i,"h ago"):s<7?"".concat(s,"d ago"):t.toLocaleDateString())})]})}}),(0,r.jsx)(l.UITooltip,{title:"New Chat",children:(0,r.jsx)(l.UIButton,{variant:"primary",icon:(0,r.jsx)(l.UIIcon,{name:"PlusOutlined"}),onClick:i})})]})}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function u(e,t,n,r,o,i,l){try{var s=e[i](l),a=s.value}catch(e){n(e);return}s.done?t(a):Promise.resolve(a).then(r,o)}function d(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){u(i,r,o,l,s,"next",e)}function s(e){u(i,r,o,l,s,"throw",e)}l(void 0)})}}function p(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function f(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function y(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],l=!0,s=!1;try{for(o=o.call(e);!(l=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);l=!0);}catch(e){s=!0,r=e}finally{try{l||null==o.return||o.return()}finally{if(s)throw r}}return i}}(e,t)||h(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(e,t){if(e){if("string"==typeof e)return c(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return c(e,t)}}function g(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),s=Object.defineProperty;return s(l,"next",{value:a(0)}),s(l,"throw",{value:a(1)}),s(l,"return",{value:a(2)}),"function"==typeof Symbol&&s(l,Symbol.iterator,{value:function(){return this}}),l;function a(s){return function(a){var c=[s,a];if(n)throw TypeError("Generator is already executing.");for(;l&&(l=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var x=n(9497).theme.useToken;function m(e){var t=e.turns,n=e.isLoading,o=e.isError,i=e.onRetry,s=e.sessionId,a=x().token;return n?(0,r.jsxs)(l.UIFlex,{justify:"center",align:"center",style:{minHeight:240,gap:8},children:[(0,r.jsx)(l.UISpin,{size:"small"}),(0,r.jsx)(l.UITypographyText,{type:"secondary",style:{fontSize:13},children:"Loading history..."})]}):o?(0,r.jsxs)("div",{style:{minHeight:240,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:12},children:[(0,r.jsx)(l.UIIcon,{name:"DisconnectOutlined",style:{fontSize:24,color:a.colorTextTertiary}}),(0,r.jsx)(l.UITypographyText,{type:"secondary",children:"Failed to load history"}),i&&(0,r.jsx)(l.UIButton,{size:"small",onClick:i,children:"Retry"})]}):0===t.length?(0,r.jsx)(l.UIFlex,{justify:"center",align:"center",style:{minHeight:240},children:(0,r.jsx)(l.UITypographyText,{type:"secondary",style:{fontSize:14},children:"Ask anything to get started"})}):(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",padding:"16px 16px 40px",gap:24},children:t.map(function(e){return(0,r.jsx)(v,{turn:e,sessionId:s,token:a},e.id)})})}function v(e){var t,n,o,i,s,a,c,u,d=e.turn,p=e.sessionId,f=e.token;if("user"===d.type){var y=d.steps.find(function(e){return"text"===e.type});return(0,r.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"flex-end",gap:8},children:[(0,r.jsx)("span",{style:{maxWidth:"68%",background:f.colorFillTertiary,borderRadius:"".concat(f.borderRadiusLG,"px ").concat(f.borderRadiusLG,"px 3px ").concat(f.borderRadiusLG,"px"),padding:"10px 16px",fontSize:14,lineHeight:1.55,color:f.colorText,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:(null==y?void 0:y.type)==="text"?y.content:""}),(0,r.jsx)("div",{style:{width:28,height:28,borderRadius:"50%",background:f.colorFillSecondary,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:(0,r.jsx)(l.UIIcon,{name:"UserOutlined",style:{fontSize:13,color:f.colorTextSecondary}})})]})}var h="streaming"===d.status,g=d.steps.filter(function(e){return"text"===e.type}),x=g.filter(function(e){var t,n;return!P(null!=(t=e.content)?t:"")&&(null==(n=e.content)?void 0:n.trim())}),m=d.steps.find(function(e){return"tool_use"===e.type&&"report"===e.toolName}),v=null==m||null==(a=m.input)?void 0:a.answer,j=d.steps.filter(function(e){return"text"!==e.type&&("tool_use"!==e.type||"report"!==e.toolName)}),I=j.length>0||h&&g.every(function(e){var t;return P(null!=(t=e.content)?t:"")}),k=null!=v?v:null,w=null==(c=d.metadata)?void 0:c.fileChanges,T=null==(u=d.metadata)?void 0:u.runId,U=!h&&w&&w.length>0&&!!p&&!!T,z={display:"flex",flexDirection:"column",borderLeft:"2px solid ".concat(f.colorBorderSecondary),paddingLeft:12,gap:6,marginLeft:6};return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,r.jsx)("div",{style:{width:22,height:22,borderRadius:"50%",background:f.colorFillSecondary,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:(0,r.jsx)(l.UIIcon,{name:"RobotOutlined",style:{fontSize:12,color:f.colorTextSecondary}})}),(0,r.jsx)(l.UITypographyText,{type:"secondary",style:{fontSize:12},children:"Agent"}),(0,r.jsxs)(l.UITypographyText,{type:"secondary",style:{fontSize:11},children:["\xb7 ",(t=new Date(d.startedAt),o=Math.floor((n=new Date().getTime()-t.getTime())/6e4),i=Math.floor(n/36e5),s=Math.floor(n/864e5),o<1?"just now":o<60?"".concat(o,"m ago"):i<24?"".concat(i,"h ago"):s<7?"".concat(s,"d ago"):t.toLocaleDateString())]}),h&&(0,r.jsx)(l.UITag,{color:"processing",style:{fontSize:11,lineHeight:"18px"},children:"Running"}),"failed"===d.status&&(0,r.jsx)(l.UITag,{color:"error",style:{fontSize:11,lineHeight:"18px"},children:"Failed"})]}),I&&(0,r.jsx)("div",{style:z,children:(0,r.jsx)(b,{steps:j,isStreaming:h,token:f})}),k&&(0,r.jsx)("div",{style:z,children:(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[(0,r.jsx)(S,{color:f.colorPrimary}),(0,r.jsx)(l.UIMarkdownViewer,{content:k,style:{flex:1}})]})}),!k&&x.map(function(e){var t;return"text"===e.type&&(null==(t=e.content)?void 0:t.trim())?(0,r.jsx)("div",{style:z,children:(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[(0,r.jsx)(S,{color:f.colorPrimary}),(0,r.jsx)(l.UIMarkdownViewer,{content:e.content,style:{flex:1}})]})},e.id):null}),U&&(0,r.jsx)("div",{style:z,children:(0,r.jsx)(O,{sessionId:p,runId:T,fileChanges:w,token:f})})]})}function b(e){var t=e.steps,n=e.isStreaming,i=e.token,s=y((0,o.useState)(n),2),a=s[0],c=s[1];(0,o.useEffect)(function(){n&&c(!0)},[n]);var u=Object.entries(function(e){var t={},n=!0,r=!1,o=void 0;try{for(var i,l=e[Symbol.iterator]();!(n=(i=l.next()).done);n=!0){var s=i.value;if("tool_use"===s.type){var a,c=A(s.toolName);t[c]=(null!=(a=t[c])?a:0)+1}}}catch(e){r=!0,o=e}finally{try{n||null==l.return||l.return()}finally{if(r)throw o}}return t}(t)).map(function(e){var t=y(e,2),n=t[0],r=t[1];return r>1?"".concat(n," \xd7").concat(r):n}),d=t.reduce(function(e,t){var n;return e+("tool_use"===t.type&&null!=(n=t.durationMs)?n:0)},0),p={display:"inline-flex",alignItems:"center",gap:5,background:"none",border:"none",padding:"2px 0",cursor:"pointer",fontSize:12,color:i.colorTextSecondary,fontFamily:"inherit"};return(0,r.jsxs)("div",{children:[(0,r.jsxs)("button",{style:p,onClick:function(){return c(function(e){return!e})},children:[(0,r.jsx)(l.UIIcon,{name:a?"DownOutlined":"RightOutlined",style:{fontSize:9,color:i.colorTextTertiary}}),n?(0,r.jsx)(l.UIIcon,{name:"LoadingOutlined",style:{fontSize:11,color:i.colorTextTertiary}}):null,(0,r.jsxs)("span",{style:{fontWeight:500,color:i.colorText},children:[t.length," ",1===t.length?"action":"actions"]}),!a&&u.length>0&&(0,r.jsxs)("span",{style:{color:i.colorTextTertiary},children:["— ",u.join(" ")]}),!a&&d>0&&(0,r.jsxs)("span",{style:{color:i.colorTextTertiary},children:["\xb7 ",(d/1e3).toFixed(1),"s"]})]}),a&&(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:5,marginTop:4},children:[t.map(function(e,o){return(0,r.jsx)(I,{step:e,isLast:!1,isStreaming:n&&o===t.length-1,token:i},e.id)}),n&&0===t.length&&(0,r.jsx)(j,{token:i})]})]})}function S(e){var t=e.color,n=e.pulse;return(0,r.jsx)("span",{style:{flexShrink:0,width:8,height:8,marginTop:6,borderRadius:"50%",background:t,opacity:n?.6:1}})}function j(e){var t=e.token;return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,r.jsx)(l.UIIcon,{name:"LoadingOutlined",style:{fontSize:11,color:t.colorTextTertiary}}),(0,r.jsx)(l.UITypographyText,{type:"secondary",style:{fontSize:13},children:"Thinking..."})]})}function I(e){var t,n,o,i=e.step,s=e.isStreaming,a=e.token;switch(i.type){case"thinking":var c,u,d=null!=(c=null==(u=i.content)?void 0:u.trim())?c:"";if(P(d))return null;return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[(0,r.jsx)(S,{color:a.colorWarning,pulse:s}),(0,r.jsx)("div",{style:{flex:1},children:(0,r.jsx)(l.UIMarkdownViewer,{content:d,style:{fontSize:13,opacity:.8}})})]});case"tool_use":return(0,r.jsx)(k,{step:i,isStreaming:s,token:a});case"tool_result":return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[(0,r.jsx)(l.UIIcon,{name:i.success?"CheckCircleOutlined":"CloseCircleOutlined",style:{fontSize:13,marginTop:2,color:i.success?a.colorSuccess:a.colorError}}),(0,r.jsxs)("div",{style:{flex:1},children:[(0,r.jsxs)("span",{style:{fontSize:13,color:a.colorTextSecondary},children:[(0,r.jsx)("span",{style:{fontWeight:500,color:a.colorText},children:A(i.toolName)}),void 0!==i.durationMs&&(0,r.jsxs)("span",{style:{marginLeft:6,fontSize:11,color:a.colorTextTertiary},children:[i.durationMs,"ms"]})]}),!i.success&&i.error&&(0,r.jsx)("p",{style:{margin:"4px 0 0",fontSize:12,color:a.colorError},children:i.error})]})]});case"subagent":return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[(0,r.jsx)(l.UIIcon,{name:"RobotOutlined",style:{fontSize:13,marginTop:2,color:a.colorPrimary}}),(0,r.jsxs)("span",{style:{fontSize:13,color:a.colorTextSecondary},children:[(0,r.jsxs)("span",{style:{fontWeight:500,color:a.colorText},children:["Agent: ",i.agentName]}),(0,r.jsxs)("span",{style:{marginLeft:6},children:["— ",null==(n=i.task)?void 0:n.slice(0,60),(null!=(t=null==(o=i.task)?void 0:o.length)?t:0)>60?"...":""]})]})]});case"error":return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[(0,r.jsx)(l.UIIcon,{name:"ExclamationCircleOutlined",style:{fontSize:13,marginTop:2,color:a.colorError}}),(0,r.jsxs)("div",{style:{flex:1},children:[(0,r.jsx)("span",{style:{fontSize:13,fontWeight:500,color:a.colorError},children:i.code}),(0,r.jsx)("p",{style:{margin:"4px 0 0",fontSize:12,color:a.colorError},children:i.message})]})]});default:return null}}function k(e){var t,n,i,s=e.step,a=e.isStreaming,c=e.token,u=y((0,o.useState)(!1),2),d=u[0],p=u[1],f="pending"===s.status,h="done"===s.status,g="error"===s.status,x=h&&!1===s.success,m=function(e){var t=e.input;if(!t)return{};var n=e.toolName.toLowerCase(),r=n.includes("read"),o=n.includes("write")||n.includes("patch")||n.includes("edit"),i=null!=(s=null!=(a=null!=(c=t.path)?c:t.filePath)?a:t.file_path)?s:t.file;if(i){var l=null!=(h=String(i).split("/").pop())?h:String(i);if(r){var s,a,c,u,d,p,f,y,h,g,x,m,v,b,S=null!=(x=null!=(m=t.offset)?m:t.startLine)?x:t.start_line,j=null!=(v=null!=(b=t.limit)?b:t.endLine)?v:t.end_line;void 0!==S&&void 0!==j?g="".concat(S,"-").concat(Number(S)+Number(j)):void 0!==j&&(g="".concat(j," lines"))}return{summary:l,filePath:String(i),badge:g}}var I=null!=(u=null!=(d=null!=(p=t.query)?p:t.text)?d:t.pattern)?u:t.search;if(I)return{summary:String(I).slice(0,100)};var k=null!=(f=t.command)?f:t.cmd;if(k)return{summary:String(k).slice(0,100)};if(o)return{};var w=null!=(y=t.content)?y:t.message;return w?{summary:String(w).slice(0,100)}:{}}(s),v=h&&!!(null==(i=s.metadata)?void 0:i.diff),b=h&&null!=s.output,S=s.input,j=/write|patch|edit/i.test(s.toolName)&&h&&!!(null!=(n=null==S?void 0:S.content)?n:null==S?void 0:S.new_content),I=b||v||j||g,k=f?a?c.colorTextTertiary:c.colorPrimary:h&&!x?c.colorSuccess:c.colorError,T=s.metadata,O=h&&(null==T?void 0:T.uiHint)==="todo"&&null!=T.structured?T.structured.todoList:void 0;return(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[(0,r.jsx)(l.UIIcon,{name:f&&a?"LoadingOutlined":(t=s.toolName.toLowerCase(),/read|open/.test(t)?"FileTextOutlined":/write|patch|edit/.test(t)?"EditOutlined":/bash|exec|shell|run/.test(t)?"CodeOutlined":/grep|search|glob|find/.test(t)?"SearchOutlined":/todo/.test(t)?"CheckSquareOutlined":/rag|mind|embed/.test(t)?"BulbOutlined":/agent|subagent/.test(t)?"RobotOutlined":/delete|remove/.test(t)?"DeleteOutlined":"ApiOutlined"),style:{fontSize:13,marginTop:2,color:k,flexShrink:0}}),(0,r.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,r.jsxs)("button",{onClick:function(){return I&&p(function(e){return!e})},disabled:!I,style:{display:"inline-flex",alignItems:"center",gap:6,background:"none",border:"none",padding:0,cursor:I?"pointer":"default",fontSize:13,color:c.colorText,flexWrap:"wrap",fontFamily:"inherit"},children:[(0,r.jsx)("span",{style:{fontWeight:500},children:A(s.toolName)}),m.badge&&(0,r.jsx)("span",{style:{fontSize:11,color:c.colorTextSecondary,background:c.colorFillSecondary,borderRadius:c.borderRadiusSM,padding:"0 5px"},children:m.badge}),h&&(null==T?void 0:T.resultCount)!==void 0&&(0,r.jsxs)("span",{style:{fontSize:11,color:c.colorTextSecondary,background:c.colorFillSecondary,borderRadius:c.borderRadiusSM,padding:"0 5px"},children:[T.resultCount," results"]}),h&&(null==T?void 0:T.exitCode)!==void 0&&0!==T.exitCode&&(0,r.jsxs)("span",{style:{fontSize:11,color:c.colorError,background:c.colorErrorBg,borderRadius:c.borderRadiusSM,padding:"0 5px"},children:["exit ",T.exitCode]}),h&&((null==T?void 0:T.linesAdded)!==void 0||(null==T?void 0:T.linesRemoved)!==void 0)&&(0,r.jsxs)("span",{style:{fontSize:11,color:c.colorSuccess,background:c.colorSuccessBg,borderRadius:c.borderRadiusSM,padding:"0 5px"},children:[(null==T?void 0:T.linesAdded)!=null&&T.linesAdded>0?"+".concat(T.linesAdded):"",(null==T?void 0:T.linesRemoved)!=null&&T.linesRemoved>0?" -".concat(T.linesRemoved):""]}),!f&&void 0!==s.durationMs&&(0,r.jsxs)("span",{style:{fontSize:11,color:c.colorTextTertiary},children:[s.durationMs,"ms"]}),I&&(0,r.jsx)("span",{style:{fontSize:11,color:c.colorTextTertiary},children:d?"▲":"▼"})]}),m.summary&&(0,r.jsx)("p",{style:{margin:"2px 0 0",fontSize:12,color:c.colorTextSecondary},children:m.filePath?(0,r.jsx)(U,{path:m.filePath,label:m.summary,token:c}):m.summary}),null!=O&&(0,r.jsx)(R,{todoList:O,token:c}),g&&s.error&&(0,r.jsx)("p",{style:{margin:"4px 0 0",fontSize:12,color:c.colorError},children:s.error}),x&&!d&&null!=s.output&&(0,r.jsx)("p",{style:{margin:"4px 0 0",fontSize:12,color:c.colorError},children:String(s.output)}),d&&(0,r.jsx)("div",{style:{marginTop:6},children:(0,r.jsx)(w,{step:s,hasDiff:v,hasOutput:b,token:c})})]})]})}function w(e){var t=e.step,n=e.hasDiff,o=e.hasOutput,i=e.token,s=t.input,a=t.toolName.toLowerCase(),c=a.includes("write")||a.includes("patch")||a.includes("edit"),u=a.includes("read"),d=a.includes("bash")||a.includes("exec")||a.includes("shell")||a.includes("run"),y=a.includes("grep")||a.includes("search")||a.includes("glob")||a.includes("list")||a.includes("rag"),h={margin:0,padding:"8px 10px",fontSize:12,lineHeight:1.5,borderRadius:i.borderRadius,overflow:"auto",maxHeight:300,whiteSpace:"pre-wrap",wordBreak:"break-all"};if(c){if(n)return(0,r.jsx)(T,{diff:t.metadata.diff,token:i});var g=null!=(x=null!=(m=null==s?void 0:s.content)?m:null==s?void 0:s.new_content)?x:null==s?void 0:s.text;if(g){var x,m,v,b,S,j=null!=(v=null!=(b=null!=(S=null==s?void 0:s.path)?S:null==s?void 0:s.filePath)?b:null==s?void 0:s.file_path)?v:null==s?void 0:s.file,I=j?j.split(".").pop():void 0;return(0,r.jsxs)("div",{children:[j&&(0,r.jsx)("div",{style:{fontSize:11,color:i.colorTextTertiary,padding:"3px 8px",background:i.colorFillSecondary,borderRadius:"".concat(i.borderRadius,"px ").concat(i.borderRadius,"px 0 0")},children:j}),(0,r.jsx)("pre",{style:f(p({},h),{background:i.colorFillSecondary,borderRadius:j?"0 0 ".concat(i.borderRadius,"px ").concat(i.borderRadius,"px"):i.borderRadius}),className:I?"lang-".concat(I):void 0,children:String(g)})]})}return null}if(u&&o)return(0,r.jsx)("pre",{style:f(p({},h),{background:i.colorFillSecondary}),children:D(t.output)});if(d&&o)return(0,r.jsx)("pre",{style:f(p({},h),{background:i.colorBgSpotlight,color:i.colorTextLightSolid}),children:D(t.output)});if(y&&o)return(0,r.jsx)("pre",{style:f(p({},h),{background:i.colorFillSecondary}),children:D(t.output)});if(n)return(0,r.jsx)(T,{diff:t.metadata.diff,token:i});if(o){var k="done"===t.status&&!1===t.success,w=D(t.output);return k?(0,r.jsx)("pre",{style:f(p({},h),{background:i.colorErrorBg,color:i.colorError}),children:w}):(0,r.jsx)(l.UIMarkdownViewer,{content:w,style:{fontSize:12}})}return null}function T(e){var t=e.diff,n=e.token,o=t.split("\n");return(0,r.jsx)("pre",{style:{margin:0,padding:"8px 10px",fontSize:12,lineHeight:1.5,borderRadius:n.borderRadius,overflow:"auto",maxHeight:300,background:n.colorFillSecondary,whiteSpace:"pre"},children:o.map(function(e,t){var o=e.startsWith("+")&&!e.startsWith("+++")?n.colorSuccess:e.startsWith("-")&&!e.startsWith("---")?n.colorError:e.startsWith("@@")?n.colorInfo:void 0;return(0,r.jsxs)("span",{style:o?{color:o}:void 0,children:[e,"\n"]},t)})})}function U(e){var t=e.path,n=e.label,i=e.token,l=y((0,o.useState)(!1),2),s=l[0],a=l[1];return(0,r.jsxs)("span",{onClick:function(e){e.stopPropagation(),navigator.clipboard.writeText(t).then(function(){a(!0),setTimeout(function(){return a(!1)},1500)})},title:t,style:{cursor:"pointer",color:s?i.colorSuccess:i.colorTextSecondary,fontFamily:"monospace",fontSize:12},children:[n,s?" ✓":""]})}function O(e){var t=e.sessionId,n=e.runId,i=e.fileChanges,a=e.token,u=y((0,o.useState)(new Set),2),p=u[0],f=u[1],x=(0,s.useMutateData)("/v1/plugins/agents/sessions/".concat(t,"/rollback"),"POST"),m=(0,s.useMutateData)("/v1/plugins/agents/sessions/".concat(t,"/approve"),"POST"),v=i.filter(function(e){return!p.has(e.changeId)&&!e.approved});return 0===v.length?null:(0,r.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[(0,r.jsx)(l.UIIcon,{name:"FileOutlined",style:{fontSize:13,marginTop:2,color:a.colorSuccess}}),(0,r.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:4},children:[(0,r.jsxs)(l.UITypographyText,{style:{fontSize:13,fontWeight:500},children:[v.length," ",L(v.length)," changed"]}),(0,r.jsxs)(l.UIFlex,{gap:4,children:[(0,r.jsx)("button",{onClick:function(){d(function(){return g(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,m.mutateAsync({runId:n})];case 1:return e.sent(),f(new Set(v.map(function(e){return e.changeId}))),[3,3];case 2:return e.sent(),console.error("Failed to approve changes"),[3,3];case 3:return[2]}})})()},disabled:m.isLoading||x.isLoading,title:"Approve all",style:{background:a.colorSuccessBg,border:"1px solid ".concat(a.colorSuccessBorder),color:a.colorSuccess,borderRadius:a.borderRadius,padding:"2px 8px",fontSize:12,cursor:"pointer"},children:"✓"}),(0,r.jsx)("button",{onClick:function(){(0,l.UIModalConfirm)({title:"Rollback changes?",content:"This will revert ".concat(v.length," ").concat(L(v.length)," to the state before the agent run."),okText:"Rollback",okButtonProps:{danger:!0},cancelText:"Cancel",onOk:function(){return d(function(){var e,t;return g(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,x.mutateAsync({runId:n})];case 1:return(null==(e=(t=r.sent()).conflicts)?void 0:e.length)&&console.warn("Rolled back: ".concat(t.rolledBack,", skipped: ").concat(t.skipped)),f(new Set(v.map(function(e){return e.changeId}))),[3,3];case 2:return r.sent(),console.error("Failed to rollback changes"),[3,3];case 3:return[2]}})})()}})},disabled:x.isLoading||m.isLoading,title:"Rollback all",style:{background:a.colorErrorBg,border:"1px solid ".concat(a.colorErrorBorder),color:a.colorError,borderRadius:a.borderRadius,padding:"2px 8px",fontSize:12,cursor:"pointer"},children:"✕"})]})]}),(0,r.jsx)("ul",{style:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:2},children:v.map(function(e){return(0,r.jsx)(z,{change:e,sessionId:t,onDismiss:function(){return f(function(t){return new Set(((function(e){if(Array.isArray(e))return c(e)})(t)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||h(t)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).concat([e.changeId]))})},token:a},e.changeId)})})]})]})}function z(e){var t,n=e.change,i=e.sessionId,a=e.onDismiss,c=e.token,u=y((0,o.useState)(!1),2),p=u[0],f=u[1],h=(0,s.useMutateData)("/v1/plugins/agents/sessions/".concat(i,"/rollback"),"POST"),x=(0,s.useMutateData)("/v1/plugins/agents/sessions/".concat(i,"/approve"),"POST"),m=p?"/v1/plugins/agents/sessions/".concat(i,"/changes/").concat(encodeURIComponent(n.changeId),"/diff"):"",v=(0,s.useData)(m,{enabled:p}),b=v.data,S=v.isLoading,j=v.isError,I=n.isNew?(0,r.jsx)(l.UITag,{color:"success",children:"new"}):"delete"===n.operation?(0,r.jsx)(l.UITag,{color:"error",children:"del"}):(0,r.jsx)(l.UITag,{color:"blue",children:"mod"});return(0,r.jsxs)("li",{children:[(0,r.jsxs)("div",{onClick:function(){return f(function(e){return!e})},style:{display:"flex",alignItems:"center",gap:6,fontSize:12,cursor:"pointer",padding:"2px 4px",borderRadius:c.borderRadiusSM,background:p?c.colorFillSecondary:"transparent"},children:[I,(0,r.jsx)("span",{style:{flex:1,fontFamily:"monospace",color:c.colorTextSecondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:null!=(t=n.filePath.split("/").pop())?t:n.filePath}),(0,r.jsx)("span",{style:{color:c.colorTextTertiary,fontFamily:"monospace",fontSize:11},children:n.filePath.includes("/")?n.filePath.slice(0,n.filePath.lastIndexOf("/")):""}),!n.approved&&(0,r.jsxs)("div",{style:{display:"flex",gap:4},onClick:function(e){return e.stopPropagation()},children:[(0,r.jsx)("button",{onClick:function(e){e.stopPropagation(),x.mutateAsync({changeIds:[n.changeId]}).then(a).catch(function(){console.error("Failed to approve file")})},disabled:x.isLoading,title:"Approve",style:{background:"none",border:"none",cursor:"pointer",color:c.colorSuccess,fontSize:13,padding:"0 2px"},children:"✓"}),(0,r.jsx)("button",{onClick:function(e){e.stopPropagation(),(0,l.UIModalConfirm)({title:"Rollback file?",content:n.filePath,okText:"Rollback",okButtonProps:{danger:!0},cancelText:"Cancel",onOk:function(){return d(function(){return g(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,h.mutateAsync({changeIds:[n.changeId]})];case 1:return e.sent(),a(),[3,3];case 2:return e.sent(),console.error("Failed to rollback file"),[3,3];case 3:return[2]}})})()}})},disabled:h.isLoading,title:"Rollback",style:{background:"none",border:"none",cursor:"pointer",color:c.colorError,fontSize:13,padding:"0 2px"},children:"✕"})]})]}),p&&(0,r.jsxs)("div",{style:{marginTop:4,marginLeft:4},children:[S&&(0,r.jsx)(l.UISpin,{size:"small"}),(null==b?void 0:b.diff)&&(0,r.jsx)(T,{diff:b.diff,token:c}),j&&(0,r.jsx)("span",{style:{color:c.colorError,fontSize:12},children:"Failed to load diff"})]})]})}var C={completed:"✓","in-progress":"●",blocked:"✕",pending:"○"};function R(e){var t,n=e.todoList,o=e.token;if(!(null==n||null==(t=n.items)?void 0:t.length))return null;var i=n.items.filter(function(e){return"completed"===e.status}).length;return(0,r.jsxs)("div",{style:{marginTop:6,background:o.colorFillTertiary,borderRadius:o.borderRadius,padding:"8px 10px"},children:[(0,r.jsxs)("div",{style:{fontSize:11,color:o.colorTextTertiary,marginBottom:6,fontWeight:500},children:[i,"/",n.items.length]}),(0,r.jsx)("ul",{style:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:2},children:n.items.map(function(e){var t;return(0,r.jsxs)("li",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13,lineHeight:1.5,padding:"2px 0"},children:[(0,r.jsx)("span",{style:{fontSize:12,flexShrink:0,width:14,textAlign:"center",lineHeight:1},children:null!=(t=C[e.status])?t:"○"}),"completed"===e.status?(0,r.jsx)(l.UITypographyText,{type:"success",style:{flex:1,minWidth:0,textDecoration:"line-through"},children:e.description}):"pending"===e.status||"blocked"===e.status?(0,r.jsx)(l.UITypographyText,{type:"secondary",style:{flex:1,minWidth:0},children:e.description}):(0,r.jsx)(l.UITypographyText,{style:{flex:1,minWidth:0},children:e.description}),"medium"!==e.priority&&(0,r.jsx)(l.UITypographyText,{type:"secondary",style:{fontSize:11,flexShrink:0},children:e.priority})]},e.id)})})]})}function A(e){var t=e.trim().toLowerCase().replace(/[_-]/g," ");if(t.includes("fs read")||t.includes("read file"))return"Read";if(t.includes("fs write")||t.includes("write file"))return"Write";if(t.includes("fs patch")||t.includes("patch file")||t.includes("fs edit")||t.includes("edit file"))return"Edit";if(t.includes("fs delete")||t.includes("delete file")||t.includes("remove file"))return"Delete";if(t.includes("fs list")||t.includes("list files")||t.includes("glob"))return"Glob";if(t.includes("grep")||t.includes("search content"))return"Grep";if(t.includes("bash")||t.includes("exec")||t.includes("shell")||t.includes("run command"))return"Bash";if(t.includes("rag")||t.includes("mind"))return"Mind";if(t.includes("todo"))return"TodoWrite";var n=e.indexOf(":");return(n>=0?e.slice(n+1):e).replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/\b\w/g,function(e){return e.toUpperCase()})}function P(e){var t=e.trim().toLowerCase();return!!("[executing tools...]"===t||"[thinking...]"===t||"[planning...]"===t||"[analyzing...]"===t||"analyzing context and choosing the next step."===t||t.startsWith("checking facts with tool:")||t.startsWith("running step with tool:")||t.startsWith("running the next step"))||"done."===t||"ok."===t||"done"===t||"ok"===t}function L(e){return 1===e?"file":"files"}function D(e){if("string"==typeof e)return e.slice(0,2e3);try{return JSON.stringify(e,null,2).slice(0,2e3)}catch(t){return String(e).slice(0,2e3)}}function E(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function M(e,t,n,r,o,i,l){try{var s=e[i](l),a=s.value}catch(e){n(e);return}s.done?t(a):Promise.resolve(a).then(r,o)}function F(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function l(e){M(i,r,o,l,s,"next",e)}function s(e){M(i,r,o,l,s,"throw",e)}l(void 0)})}}function B(e,t){return null!=t&&"u">typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function W(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],l=!0,s=!1;try{for(o=o.call(e);!(l=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);l=!0);}catch(e){s=!0,r=e}finally{try{l||null==o.return||o.return()}finally{if(s)throw r}}return i}}(e,t)||N(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _(e){return function(e){if(Array.isArray(e))return E(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||N(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function N(e,t){if(e){if("string"==typeof e)return E(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return E(e,t)}}function q(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),s=Object.defineProperty;return s(l,"next",{value:a(0)}),s(l,"throw",{value:a(1)}),s(l,"return",{value:a(2)}),"function"==typeof Symbol&&s(l,Symbol.iterator,{value:function(){return this}}),l;function a(s){return function(a){var c=[s,a];if(n)throw TypeError("Generator is already executing.");for(;l&&(l=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}function H(e,t){if(e.sequence!==t.sequence)return e.sequence-t.sequence;if(e.type!==t.type){if("user"===e.type)return -1;if("user"===t.type)return 1}return e.startedAt.localeCompare(t.startedAt)}function G(e){var t=e.status,n=e.sessionId,o=e.onReconnect,i=(0,l.useUITheme)().token;return n&&"connected"!==t?"connecting"===t?(0,r.jsxs)(l.UISpace,{size:4,children:[(0,r.jsx)(l.UIIcon,{name:"LoadingOutlined",style:{fontSize:12,color:i.colorTextTertiary}}),(0,r.jsx)(l.UITypographyText,{type:"secondary",style:{fontSize:12},children:"Connecting..."})]}):(0,r.jsxs)(l.UISpace,{size:4,children:[(0,r.jsx)(l.UIIcon,{name:"DisconnectOutlined",style:{fontSize:12,color:i.colorError}}),(0,r.jsx)(l.UIButton,{variant:"link",size:"small",style:{padding:0,fontSize:12,height:"auto"},onClick:o,children:"Reconnect"})]}):null}let $=function(){var e,t,n=(0,l.useUITheme)().token,c=(0,o.useRef)(null),u=W((0,i.useSearchParams)(),2),d=u[0],p=u[1],f=W((0,o.useState)(function(){return d.get("session")}),2),y=f[0],h=f[1],g=W((0,o.useState)(function(){return d.get("session")}),2),x=g[0],v=g[1],b=W((0,o.useState)(""),2),S=b[0],j=b[1],I=W((0,o.useState)(null),2),k=I[0],w=I[1],T=W((0,o.useState)("idle"),2),U=T[0],O=T[1],z=W((0,o.useState)([]),2),C=z[0],R=z[1],A=W((0,o.useState)([]),2),P=A[0],L=A[1],D=W((0,o.useState)("auto"),2),E=D[0],M=D[1],N=W((0,o.useState)("medium"),2),$=N[0],V=N[1],K=W((0,o.useState)(!0),2),J=K[0],Z=K[1],Q=W((0,o.useState)("execute"),2),X=Q[0],Y=Q[1],ee=W((0,o.useState)(!1),2),et=ee[0],en=ee[1],er="mind-assistant",eo=y?(e="https:"===window.location.protocol?"wss:":"ws:",t=window.location.host,"".concat(e,"//").concat(t,"/api/v1/ws/plugins/agents/session/").concat(y)):null,ei=(0,s.useMutateData)("/v1/plugins/agents/run","POST"),el=(0,s.useMutateData)(k?"/v1/plugins/agents/run/".concat(k,"/stop"):"/v1/plugins/agents/run/noop/stop","POST"),es=y?"/v1/plugins/agents/sessions/".concat(y,"/turns"):"",ea=(0,s.useData)(es,{enabled:!!y}),ec=ea.data,eu=ea.isFetching,ed=ea.isError,ep=ea.refetch;(0,o.useEffect)(function(){y&&(ec||ed)&&!eu&&v(y)},[y,ec,ed,eu]);var ef=(0,s.useWebSocket)(eo,{reconnect:!0,maxReconnects:10,reconnectIntervalMs:2e3,onMessage:function(e){switch(e.type){case"conversation:snapshot":L(_(e.payload.completedTurns).concat(_(e.payload.activeTurns)).sort(function(e,t){return e.sequence-t.sequence})),R([]);break;case"turn:snapshot":var t=e.payload.turn;L(function(e){var n=e.findIndex(function(e){return e.id===t.id});if(n>=0){var r=_(e);return r[n]=t,r}return _(e).concat([t]).sort(function(e,t){return e.sequence-t.sequence})});break;case"run:completed":var n=e.payload,r=n.success,o=n.summary;O(r?"completed":"failed"),R([]),ep(),console.log("[AgentsPage] Run completed:",o);break;case"error":var i=e.payload,s=i.code,a=i.message;l.UIMessage.error("Agent error [".concat(s,"]: ").concat(a))}}});(0,o.useEffect)(function(){var e=c.current;e&&(e.scrollTop=e.scrollHeight)},[P.length,C.length]);var ey=(0,o.useCallback)(function(e,t){h(e),v(null),p({session:e},{replace:!0}),w(null),O("idle"),R([]),L([]),ef.clear()},[ef,p]),eh=(0,o.useCallback)(function(){h(null),v(null),p({},{replace:!0}),w(null),O("idle"),R([]),L([]),ef.clear()},[ef,p]),eg=(0,o.useCallback)(function(){return F(function(){var e,t,n,r;return q(this,function(o){switch(o.label){case 0:if(!S.trim())return[2];e=S.trim(),j(""),O("running"),t={id:"optimistic-user-".concat(Date.now()),type:"user",sequence:9999,startedAt:new Date().toISOString(),completedAt:new Date().toISOString(),status:"completed",steps:[{type:"text",id:"opt-1",timestamp:new Date().toISOString(),content:e,role:"user"}],metadata:{agentId:"user"}},R(function(e){return _(e).concat([t])}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,ei.mutateAsync({task:e,agentId:er,sessionId:null!=y?y:void 0,tier:$,enableEscalation:J,responseMode:E,mode:X})];case 2:return n=o.sent(),y||(h(n.sessionId),v(n.sessionId),p({session:n.sessionId},{replace:!0})),w(n.runId),ef.isConnected&&setTimeout(function(){return R([])},500),[3,4];case 3:return r=o.sent(),R(function(e){return e.filter(function(e){return e.id!==t.id})}),O("failed"),l.UIMessage.error("Failed to start: ".concat(B(r,Error)?r.message:String(r))),[3,4];case 4:return[2]}})})()},[S,er,y,$,J,E,X,p,ei,ef]),ex=(0,o.useCallback)(function(){return F(function(){var e;return q(this,function(t){switch(t.label){case 0:if(!k)return[2];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,el.mutateAsync({reason:"Stopped by user"})];case 2:return t.sent(),O("stopped"),l.UIMessage.info("Stopped"),[3,4];case 3:return e=t.sent(),l.UIMessage.error("Failed to stop: ".concat(B(e,Error)?e.message:String(e))),[3,4];case 4:return[2]}})})()},[k,el]),em="running"===U||ei.isLoading,ev=null!==y&&y!==x,eb=function(){if(ev)return[];var e=null!=(i=null==ec?void 0:ec.turns)?i:[],t=new Map;if(0===P.length){var n=!0,r=!1,o=void 0;try{for(var i,l,s=e[Symbol.iterator]();!(n=(l=s.next()).done);n=!0){var a=l.value;t.set(a.id,a)}}catch(e){r=!0,o=e}finally{try{n||null==s.return||s.return()}finally{if(r)throw o}}}else{var c=!0,u=!1,d=void 0;try{for(var p,f=e[Symbol.iterator]();!(c=(p=f.next()).done);c=!0){var y=p.value;t.set(y.id,y)}}catch(e){u=!0,d=e}finally{try{c||null==f.return||f.return()}finally{if(u)throw d}}var h=!0,g=!1,x=void 0;try{for(var m,v=P[Symbol.iterator]();!(h=(m=v.next()).done);h=!0){var b=m.value;t.set(b.id,b)}}catch(e){g=!0,x=e}finally{try{h||null==v.return||v.return()}finally{if(g)throw x}}}var S=new Set(_(t.values()).filter(function(e){return"user"===e.type}).flatMap(function(e){return e.steps.filter(function(e){return"text"===e.type}).map(function(e){var t;return null==(t=e.content)?void 0:t.trim()})}).filter(Boolean)),j=!0,I=!1,k=void 0;try{for(var w,T=C[Symbol.iterator]();!(j=(w=T.next()).done);j=!0){var U,O,z=w.value,R=null==(O=z.steps.find(function(e){return"text"===e.type}))||null==(U=O.content)?void 0:U.trim();R&&!S.has(R)&&t.set(z.id,z)}}catch(e){I=!0,k=e}finally{try{j||null==T.return||T.return()}finally{if(I)throw k}}return _(t.values()).sort(H)}(),eS=function(){if(!em||eb.some(function(e){return"assistant"===e.type&&"streaming"===e.status}))return eb;var e=_(eb).reverse().find(function(e){return"user"===e.type});if(!e||eb.some(function(t){return"assistant"===t.type&&"completed"===t.status&&t.sequence>e.sequence}))return eb;var t={id:"thinking-loader-".concat(e.id),type:"assistant",sequence:e.sequence+.1,startedAt:new Date().toISOString(),completedAt:null,status:"streaming",steps:[],metadata:{agentId:"assistant-loader"}};return _(eb).concat([t]).sort(H)}(),ej=ev||eu&&0===eb.length&&!!y;return(0,r.jsx)("div",{style:{height:"100%",overflow:"hidden",display:"flex",flexDirection:"column"},children:(0,r.jsxs)(l.UICard,{title:(0,r.jsxs)(l.UISpace,{children:[(0,r.jsx)(l.UIIcon,{name:"RobotOutlined"}),(0,r.jsx)("span",{children:"Agent"})]}),extra:(0,r.jsx)(a,{currentSessionId:y,onSessionChange:ey,onNewChat:eh}),style:{height:"100%",display:"flex",flexDirection:"column"},styles:{body:{flex:1,display:"flex",flexDirection:"column",padding:0,overflow:"hidden"}},children:[(0,r.jsx)("div",{ref:c,style:{flex:1,overflow:"auto"},children:(0,r.jsx)(m,{turns:eS,isLoading:ej,isError:ed,onRetry:function(){ep()},sessionId:y})}),(0,r.jsx)("div",{style:{borderTop:"1px solid ".concat(n.colorBorderSecondary),padding:"12px 16px",background:n.colorBgContainer},children:(0,r.jsxs)("div",{onFocus:function(){return en(!0)},onBlur:function(){return en(!1)},style:{border:"1px solid ".concat(et?"execute"===X?n.colorError:n.colorPrimary:"plan"===X?n.colorPrimary:n.colorBorder),borderRadius:n.borderRadiusLG,background:n.colorBgContainer,boxShadow:et?"0 0 0 2px ".concat("execute"===X?n.colorErrorBg:n.colorPrimaryBg):"none",transition:"border-color 0.2s, box-shadow 0.2s",overflow:"hidden"},children:[(0,r.jsx)(l.UIInputTextArea,{value:S,onChange:function(e){return j(e.target.value)},onKeyDown:function(e){"Enter"!==e.key||e.shiftKey||"running"===U||ei.isLoading||(e.preventDefault(),eg())},placeholder:"Message...",autoSize:{minRows:2,maxRows:8},disabled:em,variant:"borderless",style:{resize:"none",padding:"10px 12px 4px",border:"none",boxShadow:"none",outline:"none"}}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 8px 8px"},children:[(0,r.jsxs)(l.UISpace,{size:6,children:[(0,r.jsx)(G,{status:ef.status,sessionId:y,onReconnect:function(){return ef.connect()}}),(0,r.jsx)(l.UISelect,{value:X,onChange:function(e){return Y(e)},disabled:em,size:"small",variant:"borderless",style:{width:110},options:[{value:"execute",label:"Execute"},{value:"plan",label:"Plan"}]}),(0,r.jsx)(l.UISelect,{value:E,onChange:function(e){return M(e)},disabled:em,size:"small",variant:"borderless",style:{width:80},options:[{value:"auto",label:"Auto"},{value:"brief",label:"Brief"},{value:"deep",label:"Deep"}]}),(0,r.jsx)(l.UISelect,{value:$,onChange:function(e){return V(e)},disabled:em,size:"small",variant:"borderless",style:{width:100},options:[{value:"small",label:"Small"},{value:"medium",label:"Medium"},{value:"large",label:"Large"}]}),(0,r.jsxs)(l.UISpace,{size:4,align:"center",children:[(0,r.jsx)(l.UISwitch,{checked:J,onChange:Z,disabled:em||"large"===$,size:"small"}),(0,r.jsx)(l.UITypographyText,{type:"secondary",style:{fontSize:12},children:"Auto escalate"})]})]}),(0,r.jsx)("div",{children:em?(0,r.jsx)(l.UIButton,{danger:!0,size:"small",icon:el.isLoading?(0,r.jsx)(l.UIIcon,{name:"LoadingOutlined"}):(0,r.jsx)(l.UIIcon,{name:"StopOutlined"}),onClick:ex,disabled:el.isLoading,children:"Stop"}):(0,r.jsx)(l.UIButton,{variant:"primary",size:"small",icon:ei.isLoading?(0,r.jsx)(l.UIIcon,{name:"LoadingOutlined"}):(0,r.jsx)(l.UIIcon,{name:"SendOutlined"}),onClick:eg,disabled:!S.trim()||ei.isLoading,children:"Send"})})]})]})})]})})}}}]);
@@ -5,7 +5,7 @@
5
5
  "name": "agentPlugin",
6
6
  "globalName": "agentPlugin",
7
7
  "buildInfo": {
8
- "buildVersion": "2.105.0",
8
+ "buildVersion": "2.107.0",
9
9
  "buildName": "@kb-labs/agent-entry"
10
10
  },
11
11
  "publicPath": "auto",
@@ -25,15 +25,16 @@
25
25
  },
26
26
  "shared": [
27
27
  {
28
- "id": "agentPlugin:react-router-dom",
29
- "name": "react-router-dom",
30
- "version": "7.17.0",
28
+ "id": "agentPlugin:@kb-labs/studio-event-bus",
29
+ "name": "@kb-labs/studio-event-bus",
30
+ "version": "2.107.0",
31
31
  "singleton": true,
32
- "requiredVersion": "^7.0.0",
32
+ "requiredVersion": "^2.0.0",
33
33
  "assets": {
34
34
  "js": {
35
35
  "sync": [
36
- "733.js"
36
+ "50.js",
37
+ "669.js"
37
38
  ],
38
39
  "async": []
39
40
  },
@@ -46,7 +47,7 @@
46
47
  {
47
48
  "id": "agentPlugin:@kb-labs/studio-ui-core",
48
49
  "name": "@kb-labs/studio-ui-core",
49
- "version": "2.105.0",
50
+ "version": "2.107.0",
50
51
  "singleton": true,
51
52
  "requiredVersion": "^2.0.0",
52
53
  "assets": {
@@ -85,7 +86,7 @@
85
86
  {
86
87
  "id": "agentPlugin:@kb-labs/studio-hooks",
87
88
  "name": "@kb-labs/studio-hooks",
88
- "version": "2.105.0",
89
+ "version": "2.107.0",
89
90
  "singleton": true,
90
91
  "requiredVersion": "^2.0.0",
91
92
  "assets": {
@@ -105,7 +106,7 @@
105
106
  {
106
107
  "id": "agentPlugin:@kb-labs/studio-ui-kit",
107
108
  "name": "@kb-labs/studio-ui-kit",
108
- "version": "2.105.0",
109
+ "version": "2.107.0",
109
110
  "singleton": true,
110
111
  "requiredVersion": "^2.0.0",
111
112
  "assets": {
@@ -125,16 +126,15 @@
125
126
  }
126
127
  },
127
128
  {
128
- "id": "agentPlugin:react-dom",
129
- "name": "react-dom",
129
+ "id": "agentPlugin:react",
130
+ "name": "react",
130
131
  "version": "19.2.5",
131
132
  "singleton": true,
132
133
  "requiredVersion": "^19.0.0",
133
134
  "assets": {
134
135
  "js": {
135
136
  "sync": [
136
- "165.js",
137
- "546.js"
137
+ "405.js"
138
138
  ],
139
139
  "async": []
140
140
  },
@@ -145,15 +145,16 @@
145
145
  }
146
146
  },
147
147
  {
148
- "id": "agentPlugin:react",
149
- "name": "react",
148
+ "id": "agentPlugin:react-dom",
149
+ "name": "react-dom",
150
150
  "version": "19.2.5",
151
151
  "singleton": true,
152
152
  "requiredVersion": "^19.0.0",
153
153
  "assets": {
154
154
  "js": {
155
155
  "sync": [
156
- "405.js"
156
+ "165.js",
157
+ "546.js"
157
158
  ],
158
159
  "async": []
159
160
  },
@@ -184,16 +185,15 @@
184
185
  }
185
186
  },
186
187
  {
187
- "id": "agentPlugin:@kb-labs/studio-event-bus",
188
- "name": "@kb-labs/studio-event-bus",
189
- "version": "2.105.0",
188
+ "id": "agentPlugin:react-router-dom",
189
+ "name": "react-router-dom",
190
+ "version": "7.18.1",
190
191
  "singleton": true,
191
- "requiredVersion": "^2.0.0",
192
+ "requiredVersion": "^7.0.0",
192
193
  "assets": {
193
194
  "js": {
194
195
  "sync": [
195
- "50.js",
196
- "669.js"
196
+ "875.js"
197
197
  ],
198
198
  "async": []
199
199
  },
@@ -5,7 +5,7 @@
5
5
  "name": "agentPlugin",
6
6
  "globalName": "agentPlugin",
7
7
  "buildInfo": {
8
- "buildVersion": "2.105.0",
8
+ "buildVersion": "2.107.0",
9
9
  "buildName": "@kb-labs/agent-entry"
10
10
  },
11
11
  "publicPath": "auto",
@@ -25,15 +25,16 @@
25
25
  },
26
26
  "shared": [
27
27
  {
28
- "id": "agentPlugin:react-router-dom",
29
- "name": "react-router-dom",
30
- "version": "7.17.0",
31
- "requiredVersion": "^7.0.0",
28
+ "id": "agentPlugin:@kb-labs/studio-event-bus",
29
+ "name": "@kb-labs/studio-event-bus",
30
+ "version": "2.107.0",
31
+ "requiredVersion": "^2.0.0",
32
32
  "singleton": true,
33
33
  "assets": {
34
34
  "js": {
35
35
  "sync": [
36
- "733.js"
36
+ "50.js",
37
+ "669.js"
37
38
  ],
38
39
  "async": []
39
40
  },
@@ -42,15 +43,13 @@
42
43
  "async": []
43
44
  }
44
45
  },
45
- "usedIn": [
46
- "src/studio/pages/AgentsPage.tsx"
47
- ],
46
+ "usedIn": [],
48
47
  "usedExports": []
49
48
  },
50
49
  {
51
50
  "id": "agentPlugin:@kb-labs/studio-ui-core",
52
51
  "name": "@kb-labs/studio-ui-core",
53
- "version": "2.105.0",
52
+ "version": "2.107.0",
54
53
  "requiredVersion": "^2.0.0",
55
54
  "singleton": true,
56
55
  "assets": {
@@ -93,7 +92,7 @@
93
92
  {
94
93
  "id": "agentPlugin:@kb-labs/studio-hooks",
95
94
  "name": "@kb-labs/studio-hooks",
96
- "version": "2.105.0",
95
+ "version": "2.107.0",
97
96
  "requiredVersion": "^2.0.0",
98
97
  "singleton": true,
99
98
  "assets": {
@@ -115,7 +114,7 @@
115
114
  {
116
115
  "id": "agentPlugin:@kb-labs/studio-ui-kit",
117
116
  "name": "@kb-labs/studio-ui-kit",
118
- "version": "2.105.0",
117
+ "version": "2.107.0",
119
118
  "requiredVersion": "^2.0.0",
120
119
  "singleton": true,
121
120
  "assets": {
@@ -137,16 +136,15 @@
137
136
  "usedExports": []
138
137
  },
139
138
  {
140
- "id": "agentPlugin:react-dom",
141
- "name": "react-dom",
139
+ "id": "agentPlugin:react",
140
+ "name": "react",
142
141
  "version": "19.2.5",
143
142
  "requiredVersion": "^19.0.0",
144
143
  "singleton": true,
145
144
  "assets": {
146
145
  "js": {
147
146
  "sync": [
148
- "165.js",
149
- "546.js"
147
+ "405.js"
150
148
  ],
151
149
  "async": []
152
150
  },
@@ -155,19 +153,22 @@
155
153
  "async": []
156
154
  }
157
155
  },
158
- "usedIn": [],
156
+ "usedIn": [
157
+ "src/studio/pages/AgentsPage.tsx"
158
+ ],
159
159
  "usedExports": []
160
160
  },
161
161
  {
162
- "id": "agentPlugin:react",
163
- "name": "react",
162
+ "id": "agentPlugin:react-dom",
163
+ "name": "react-dom",
164
164
  "version": "19.2.5",
165
165
  "requiredVersion": "^19.0.0",
166
166
  "singleton": true,
167
167
  "assets": {
168
168
  "js": {
169
169
  "sync": [
170
- "405.js"
170
+ "165.js",
171
+ "546.js"
171
172
  ],
172
173
  "async": []
173
174
  },
@@ -176,9 +177,7 @@
176
177
  "async": []
177
178
  }
178
179
  },
179
- "usedIn": [
180
- "src/studio/pages/AgentsPage.tsx"
181
- ],
180
+ "usedIn": [],
182
181
  "usedExports": []
183
182
  },
184
183
  {
@@ -204,16 +203,15 @@
204
203
  "usedExports": []
205
204
  },
206
205
  {
207
- "id": "agentPlugin:@kb-labs/studio-event-bus",
208
- "name": "@kb-labs/studio-event-bus",
209
- "version": "2.105.0",
210
- "requiredVersion": "^2.0.0",
206
+ "id": "agentPlugin:react-router-dom",
207
+ "name": "react-router-dom",
208
+ "version": "7.18.1",
209
+ "requiredVersion": "^7.0.0",
211
210
  "singleton": true,
212
211
  "assets": {
213
212
  "js": {
214
213
  "sync": [
215
- "50.js",
216
- "669.js"
214
+ "875.js"
217
215
  ],
218
216
  "async": []
219
217
  },
@@ -222,7 +220,9 @@
222
220
  "async": []
223
221
  }
224
222
  },
225
- "usedIn": [],
223
+ "usedIn": [
224
+ "src/studio/pages/AgentsPage.tsx"
225
+ ],
226
226
  "usedExports": []
227
227
  }
228
228
  ],
@@ -234,8 +234,8 @@
234
234
  "id": "agentPlugin:AgentsPage",
235
235
  "name": "AgentsPage",
236
236
  "requires": [
237
- "react",
238
- "react-router-dom"
237
+ "react-router-dom",
238
+ "react"
239
239
  ],
240
240
  "assets": {
241
241
  "js": {