@dahawa/hawa-code 2.5.2 → 2.6.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.
package/hawa.js CHANGED
@@ -9,4 +9,4 @@ const __dirname = dirname(__filename);
9
9
 
10
10
  import{spawn as ie}from"child_process";import k from"path";import{fileURLToPath as ae}from"url";import{existsSync as U,readFileSync as Oe,writeFileSync as I,mkdirSync as Ee,watch as ne}from"fs";import{join as se,dirname as we}from"path";import{homedir as Ae}from"os";import{existsSync as q,mkdirSync as pe}from"fs";import{dirname as de,join as g}from"path";import{writeFileSync as fe,readFileSync as Ze,appendFileSync as me}from"fs";import{randomUUID as Se}from"crypto";import{homedir as he}from"os";var Y="hcode",x=".hcode";var ce="HAWA_CODE_GIT_BASH_PATH";var le="Bash",ue="PowerShell";var Ue=H()?ue:le;function H(){return process.platform!=="win32"?!1:process.env.HAWA_CODE_POWER_SHELL_ENABLE==="true"||process.env.HAWA_CODE_POWER_SHELL_ENABLE==="1"?!0:!(process.env.HAWA_CODE_POWER_SHELL_ENABLE==="false"||process.env.HAWA_CODE_POWER_SHELL_ENABLE==="0"||process.env[ce])}import*as Z from"os";import{randomUUID as ge}from"crypto";var W=class{listeners=new Map;registry=new FinalizationRegistry(e=>{for(let[t,n]of this.listeners.entries()){for(let s of Array.from(n))s.token===e&&n.delete(s);n.size===0&&this.listeners.delete(t)}});on(e,t,n){let s=this.listeners.get(e);s||(s=new Set,this.listeners.set(e,s));let r={callback:t,thisRef:n?new WeakRef(n):void 0};if(n){let i={};r.token=i,this.registry.register(n,i,i)}return s.add(r),()=>{this.off(e,t,n)}}off(e,t,n){let s=this.listeners.get(e);if(s){if(!t&&n===void 0){for(let r of s)r.token&&this.registry.unregister(r.token);this.listeners.delete(e);return}for(let r of Array.from(s)){let i=t?r.callback===t:!0,l=!0;n!==void 0&&(l=r.thisRef?.deref()===n),i&&l&&(r.token&&this.registry.unregister(r.token),s.delete(r))}s.size===0&&this.listeners.delete(e)}}emit(e,t){let n=this.listeners.get(e);if(n)for(let s of Array.from(n)){let r;if(s.thisRef&&(r=s.thisRef.deref(),!r)){n.delete(s);continue}try{let i=s.callback.call(r,t);i instanceof Promise&&i.catch(l=>{h(`Async error in listener for "${e}"`,l)})}catch(i){h(`Error in listener for "${e}"`,i)}}}},y=new W;var N=class{datas={};setData(e,t){this.datas[e]=t}getData(e){return this.datas[e]}takeData(e){let t=this.datas[e];return delete this.datas[e],t}clear(){this.datas={}}},P=class extends N{startTime;constructor(e=null){super(),this.startTime=e}},K=ge(),$=class extends N{PENDING_PROMPTS_KEY="pendingPrompts";addPendingPrompt(e){let t=this.getPendingPrompts();t.push(e),this.setData(this.PENDING_PROMPTS_KEY,t)}getPendingPrompts(){let e=this.getData(this.PENDING_PROMPTS_KEY);return Array.isArray(e)?e:[]}takePendingPrompts(){let e=this.getPendingPrompts();return this.setData(this.PENDING_PROMPTS_KEY,[]),e}async waitGetPendingPrompts(e){let n=Date.now(),s=e*1e3;for(;Date.now()-n<s;){let r=this.getPendingPrompts();if(r.length>0)return r;await new Promise(i=>setTimeout(i,200))}return[]}getSessionId(){return K}switchSessionId(e){K=e}},z=class o{static sessionContext={};static inQueryContextHolder={};static queryContext={};onQueryStart(e="defalt",t){e||(e="defalt");let n=o.inQueryContextHolder[e+""];n&&n.startTime&&n.startTime>0||(o.inQueryContextHolder[e+""]=new P(Date.now()),y.emit("webserver:agent_status",{agentId:e,status:"started",agentType:t?.agentType,agentName:t?.agentName,description:t?.description,timestamp:Date.now()}))}onQueryEnd(e="defalt",t=!1){e||(e="defalt"),o.inQueryContextHolder[e+""]=new P(-1),t||(o.queryContext[e+""]={}),y.emit("webserver:agent_status",{agentId:e,status:"ended",timestamp:Date.now()})}getSessionContext(e="defalt"){e||(e="defalt");let t=o.sessionContext[e+""];return t||(t=new $,o.sessionContext[e+""]=t),t}getInQueryContext(e="defalt"){e||(e="defalt");let t=o.inQueryContextHolder[e+""];return t||(t=new P,o.inQueryContextHolder[e+""]=t),t}getQueryContext(e="defalt"){e||(e="defalt");let t=o.queryContext[e+""];return t||(t={},o.queryContext[e+""]=t),t}isQuerying(e="defalt"){return e||(e="defalt"),this.getInQueryContext(e).startTime>0}},X=new z;var at=Se(),f=g(he(),x);function m(o){return o.replace(/[^a-zA-Z0-9]/g,"-")}function ye(){return X.getSessionContext().getSessionId()||G}function be(){try{let o=b().planDirectory;if(o)return o}catch{}return g(f,"plan")}var ee={temp:()=>g(Z.tmpdir(),`${Y}`),plan:()=>be(),memory:()=>g(f,"projects",m(process.cwd()),"memory"),apis:()=>g(f,"projects",m(process.cwd()),"apis"),errors:()=>g(f,"projects",m(process.cwd()),"errors"),messages:()=>g(f,"projects",m(process.cwd()),"messages"),mcpLogs:o=>g(f,"projects",m(process.cwd()),`mcp-logs-${o}`),log:()=>g(f,"projects",m(process.cwd()),"log"),vcrFixtures:()=>g(f,"projects",m(process.cwd()),"vcr-fixtures"),sessionSummary:()=>g(f,"projects",m(process.cwd()),"messages",ye(),"session-summary")};function _e(o){return o.toISOString().replace(/[:.]/g,"-")}var G=_e(new Date);function Me(){return g(ee.log(),G+".log")}function Te(){return g(ee.log(),"error-"+G+".log")}function te(o,e,...t){let n=t.map(s=>s instanceof Error?`${s.name}: ${s.message}
11
11
  ${s.stack.replace(/^/gm," ")}`:s);xe(e,{level:o,message:n.length==1?n[0]:n})}function O(...o){te("info",Me(),...o)}function h(...o){te("error",Te(),...o)}function v(...o){h(...o)}function xe(o,e){let t=de(o);q(t)||pe(t,{recursive:!0});let s=(typeof e=="string"?e:JSON.stringify(e))+`
12
- `;q(o)?me(o,s,"utf8"):fe(o,s,"utf8")}var ct=5*1024*1024,lt=1024*1024,ut=Buffer.from('"compact_boundary"');var R=class o{static getTools=e=>[];static getMCPCommands=()=>[];static getMcpServer=e=>{};static getClients=async()=>[];static reloadClients=async()=>[];static reconnect=async(e,t,n)=>{};static registerIDEClient=(e,t)=>{};static cache=[];static add(e){o.cache.push(e)}static clear(){o.cache.forEach(e=>{e.cache.clear?.()})}};var j={env:{},permissions:{allow:[],deny:[],ask:[]},enableAllProjectMcpServers:!1,enabledMcpjsonServers:[],autoCompactEnabled:!0,language:"auto",thinking:"medium",disableSuggestion:!1,lazyTool:"loading",memo:!1,messageArchiving:!1,archiveToolUseInputs:!1,autoMode:{enabled:!0,model:"",maxConsecutiveDenials:3,maxTotalDenials:20},autoMemory:{enabled:!0,minTokens:3e3,minTurns:3,teamMemoryEnabled:!1},autoDream:{enabled:!0,minHours:24,minSessions:5},proxy:!1,agentDepth:1,codemodeMethodsMax:20,plugins:{pluginClaudeCompat:!0}},L=class o{static test=!1;static testSettings;static setSettings(e){o.testSettings=e}static instance;static isTasksEnable(){return process.env.HAWA_CODE_ENABLE_TASKS=="true"||o.isAgentTeamEnable()}static isAgentTeamEnable(){return process.env.HAWA_CODE_EXPERIMENTAL_AGENT_TEAMS=="1"}static getLazyToolMode(){let t=b().lazyTool;return t==="proxy"||t==="loading"||t==="off"?t:t===!0?"loading":t===!1?"off":"loading"}static isLazyToolEnable(){return o.getLazyToolMode()==="loading"}static isProxyToolEnable(){return o.getLazyToolMode()==="proxy"}static isLazyOrProxyEnable(){return o.getLazyToolMode()!=="off"}static isPowerShellToolEnable(){return H()}static isMemoEnable(){return b().memo===!0}static isMessageArchivingEnable(){return b().messageArchiving===!0}static isArchiveToolUseInputsEnable(){return b().archiveToolUseInputs===!0}static getCodemodeMethodsMax(){let e=b().codemodeMethodsMax;return typeof e!="number"||Number.isNaN(e)?20:Math.min(100,Math.max(1,Math.floor(e)))}constructor(){this.initializeConfigDirectories()}initializeConfigDirectories(){let e=this.getUserSettingsPath(),t=this.getProjectSettingsPath();this.ensureDirExists(e),U(e)||I(e,JSON.stringify(this.getDefaultSettingsStructure(),null,2),"utf-8"),this.ensureDirExists(t),U(t)||I(t,JSON.stringify(this.getDefaultSettingsStructure(),null,2),"utf-8")}getDefaultSettingsStructure(){return{env:{},permissions:{allow:[],deny:[],ask:[]},autoMode:{enabled:!0,model:"",maxConsecutiveDenials:3,maxTotalDenials:20},thinking:"medium"}}static getInstance(){return o.instance||(o.instance=new o),o.instance}addProjectAllowedTools(e){let t=this.loadSettingsFromFile(this.getProjectSettingsPath()),n=t.permissions||{allow:[],deny:[]};if(n.allow||(n.allow=[]),n.allow.includes(e))O(`\u5DE5\u5177 '${e}' \u5DF2\u5B58\u5728\u4E8E\u9879\u76EE\u5141\u8BB8\u5217\u8868\u4E2D\uFF0C\u65E0\u9700\u91CD\u590D\u6DFB\u52A0`);else{n.allow.push(e),n.allow.sort();let s={...t,permissions:{...n}};this.saveSettingsToFile(this.getProjectSettingsPath(),s,j),O(`\u5DF2\u5C06\u5DE5\u5177 '${e}' \u6DFB\u52A0\u5230\u9879\u76EE\u5141\u8BB8\u5217\u8868`)}}getUserSettingsPath(){return se(Ae(),".hcode","settings.json")}getProjectSettingsPath(){let e=process.cwd();return se(e,".hcode","settings.json")}ensureDirExists(e){let t=we(e);U(t)||Ee(t,{recursive:!0})}loadSettingsFromFile(e){if(!U(e))return{};let t="";try{return t=Oe(e,"utf-8"),JSON.parse(t)}catch(n){return console.error(`Error reading settings file ${e} => ${t} `,n),{}}}saveSettingsToFile(e,t,n){let s={...t};for(let[r,i]of Object.entries(t))if(r in n)if(typeof i=="object"&&typeof n[r]=="object"){if(JSON.stringify(i)===JSON.stringify(n[r]))delete s[r];else if(r==="permissions"&&i&&typeof i=="object"){let l=n.permissions||{},c=i;Array.isArray(c.allow)&&Array.isArray(l.allow)&&JSON.stringify(c.allow)===JSON.stringify(l.allow)&&delete c.allow,Array.isArray(c.deny)&&Array.isArray(l.deny)&&JSON.stringify(c.deny)===JSON.stringify(l.deny)&&delete c.deny,Object.keys(c).length===0&&delete s[r]}}else i===n[r]&&delete s[r];this.ensureDirExists(e),Object.keys(s).length===0?I(e,"{}","utf-8"):I(e,JSON.stringify(s,null,2),"utf-8")}mergeStringArrays(e,t){if(!e&&!t)return;let n=[...e||[]];return(t||[]).forEach(s=>{n.includes(s)||n.push(s)}),n}loadSettings(){let e=this.loadSettingsFromFile(this.getUserSettingsPath()),t=this.loadSettingsFromFile(this.getProjectSettingsPath()),n={...e.env,...t.env},s={...e.permissions};if(e.permissions?.allow&&t.permissions?.allow){let a=[...e.permissions.allow];t.permissions.allow.forEach(u=>{a.includes(u)||a.push(u)}),s.allow=a}else t.permissions?.allow&&(s.allow=[...t.permissions.allow]);if(e.permissions?.deny&&t.permissions?.deny){let a=[...e.permissions.deny];t.permissions.deny.forEach(u=>{a.includes(u)||a.push(u)}),s.deny=a}else t.permissions?.deny&&(s.deny=[...t.permissions.deny]);if(e.permissions?.ask&&t.permissions?.ask){let a=[...e.permissions.ask];t.permissions.ask.forEach(u=>{a.includes(u)||a.push(u)}),s.ask=a}else t.permissions?.ask&&(s.ask=[...t.permissions.ask]);let r={...j,...e,...t};n&&Object.keys(n).length>0&&(r.env=n),s&&(s.allow||s.deny||s.ask)&&(r.permissions=s);let i=e.sandbox,l=t.sandbox;if(i||l){let a={...i,...l},u=i?.filesystem,_=l?.filesystem;(u||_)&&(a.filesystem={...u,..._,allowWrite:this.mergeStringArrays(u?.allowWrite,_?.allowWrite),denyWrite:this.mergeStringArrays(u?.denyWrite,_?.denyWrite),denyRead:this.mergeStringArrays(u?.denyRead,_?.denyRead),allowRead:this.mergeStringArrays(u?.allowRead,_?.allowRead)});let A=i?.network,C=l?.network;(A||C)&&(a.network={...A,...C,allowedDomains:this.mergeStringArrays(A?.allowedDomains,C?.allowedDomains),deniedDomains:this.mergeStringArrays(A?.deniedDomains,C?.deniedDomains),allowUnixSockets:this.mergeStringArrays(A?.allowUnixSockets,C?.allowUnixSockets)});let F=i?.ignoreViolations,B=l?.ignoreViolations;if(F||B){let M={};if(F)for(let[T,D]of Object.entries(F))M[T]=[...D];if(B)for(let[T,D]of Object.entries(B))M[T]?M[T]=this.mergeStringArrays(M[T],D)??[]:M[T]=[...D];a.ignoreViolations=M}r.sandbox=a}let c=e.plugins,d=t.plugins;if(c||d){let a={...c,...d};(c?.enabledPlugins||d?.enabledPlugins)&&(a.enabledPlugins=this.mergeStringArrays(c?.enabledPlugins,d?.enabledPlugins)),(c?.disabledPlugins||d?.disabledPlugins)&&(a.disabledPlugins=this.mergeStringArrays(c?.disabledPlugins,d?.disabledPlugins)),(c?.pluginMarketplaceAllowlist||d?.pluginMarketplaceAllowlist)&&(a.pluginMarketplaceAllowlist=this.mergeStringArrays(c?.pluginMarketplaceAllowlist,d?.pluginMarketplaceAllowlist)),(c?.pluginConfigs||d?.pluginConfigs)&&(a.pluginConfigs={...c?.pluginConfigs,...d?.pluginConfigs}),r.plugins=a}return r}saveUserSettings(e){let t=this.getUserSettingsPath();this.saveSettingsToFile(t,e,j)}saveProjectSettings(e){let t=this.getProjectSettingsPath();this.saveSettingsToFile(t,e,j)}getSetting(e){return this.loadSettings()[e]}updateSetting(e,t){let s={...this.loadSettings(),[e]:t};this.saveProjectSettings(s),p=s}resetSetting(e){let n={...this.loadSettings()};delete n[e],this.saveProjectSettings(n),p=n}getAllSettings(){return this.loadSettings()}},E=L.getInstance(),p=E.getAllSettings(),b=function(){return L.test?L.testSettings:(p||(p=E.getAllSettings(),R.clear(),p.env&&Object.keys(p.env).length>0&&(Object.entries(p.env).forEach(([o,e])=>{let t;typeof e=="string"?t=e:t=String(e),t.length>0&&(process.env[o]=t)}),O(`\u5DF2\u4ECE\u914D\u7F6E\u6587\u4EF6\u52A0\u8F7D ${Object.keys(p.env).length} \u4E2A\u73AF\u5883\u53D8\u91CF`,p.env))),p)};function J(){let o=E.getUserSettingsPath(),e=E.getProjectSettingsPath();ne(o,(t,n)=>{t==="change"&&(p=null,y.emit("webserver:settings_changed",{scope:"user"}),O("\u7528\u6237\u7EA7\u914D\u7F6E\u5DF2\u70ED\u52A0\u8F7D"))}).on("error",t=>{h("\u7528\u6237\u7EA7\u914D\u7F6E\u76D1\u63A7\u51FA\u9519:",t),setTimeout(()=>J(),100)}).unref(),ne(e,(t,n)=>{t==="change"&&(p=null,y.emit("webserver:settings_changed",{scope:"project"}),O("\u9879\u76EE\u7EA7\u914D\u7F6E\u5DF2\u70ED\u52A0\u8F7D",n))}).on("error",t=>{h("\u9879\u76EE\u7EA7\u914D\u7F6E\u76D1\u63A7\u51FA\u9519:",t),setTimeout(()=>J(),100)}).unref()}J();import Ce from"os";import re from"path";import S from"fs";var Q={sources:{openai:{base_url:"https://api.openai.com/v1",auth_token:"{apikey}",api_type:"openai",models:["gpt-5.5","gpt-5.4-mini"]},kimi:{base_url:"https://api.kimi.com/coding",auth_token:"{apikey}",api_type:"anthropic",models:["K2.5","K2.6"]},"qwen-coding":{base_url:"https://coding.dashscope.aliyuncs.com/apps/anthropic",auth_token:"{apikey}",api_type:"anthropic",models:["qwen3-coder-plus"]}},routing:{MODEL:[{source:"kimi",model:"K2.6",weight:60},{source:"openai",model:"gpt-5.5",weight:40}],SMALL_FAST_MODEL:[{source:"qwen-coding",model:"qwen3-coder-plus",weight:50},{source:"kimi",model:"K2.5",weight:50}]}};function Pe(){let o=Ce.homedir();return re.join(o,x,"config.json")}function oe(o){if(o.length===0)throw new Error("No items to select from");if(o.length===1)return o[0];let e=o.reduce((n,s)=>n+(s.weight??100),0),t=Math.random()*e;for(let n of o){let s=n.weight??100;if(t-=s,t<=0)return n}return o[o.length-1]}var V=class{config;configPath;constructor(e){this.configPath=e||Pe();try{this.config=this.loadModelConfig()}catch(t){console.log(t)}}initConfig(){if(!S.existsSync(this.configPath))try{let e=re.dirname(this.configPath);S.mkdirSync(e,{recursive:!0}),S.writeFileSync(this.configPath,JSON.stringify(Q,null,2))}catch(e){v(e)}}reload(){this.config=this.loadModelConfig()}loadModelConfig(){try{if(!S.existsSync(this.configPath))return Q;let e=S.readFileSync(this.configPath,"utf-8"),t=JSON.parse(e);return t.sources&&t.routing?t:Q}catch(e){throw v(e),e}}getConfig(){return this.config}hasModelRouting(){return!!(this.config.routing?.MODEL&&this.config.routing.MODEL.length>0)}getModelRoutingModels(){let e=this.config.routing?.MODEL;return!e||e.length===0?[]:e.map(t=>t.model)}hasSmallFastModelRouting(){return!!(this.config.routing?.SMALL_FAST_MODEL&&this.config.routing.SMALL_FAST_MODEL.length>0)}getModel(){let e=this.config.routing?.MODEL;if(!e||e.length===0)throw new Error("No MODEL routing configuration found");let t=oe(e);return`${t.source}__${t.model}`}getSmallFastModel(){let e=this.config.routing?.SMALL_FAST_MODEL;if(!e||e.length===0)throw new Error("No SMALL_FAST_MODEL routing configuration found");let t=oe(e);return`${t.source}__${t.model}`}getSourceConfig(e){return this.config.sources?.[e]}parseModelKey(e){let t=e.indexOf("__");return t===-1?{source:"",model:e}:{source:e.slice(0,t),model:e.slice(t+2)}}getModelSourceConfig(e){let{source:t}=this.parseModelKey(e);if(t)return this.getSourceConfig(t)}setModelRouting(e){this.config.routing.MODEL=e,this.saveConfig()}setSmallFastModelRouting(e){this.config.routing.SMALL_FAST_MODEL=e,this.saveConfig()}updateConfig(e){this.config=e,this.saveConfig()}getAvailableModels(){let e=[];for(let[t,n]of Object.entries(this.config.sources||{}))for(let s of n.models||[])e.push(`${t}__${s}`);return e}saveConfig(){try{let e={};if(S.existsSync(this.configPath)){let n=S.readFileSync(this.configPath,"utf-8");e=JSON.parse(n)}let t={...e,sources:this.config.sources,routing:this.config.routing};S.writeFileSync(this.configPath,JSON.stringify(t,null,2))}catch(e){v(e)}}},w=new V;import Le from"os";function ke(){return k.join(Le.homedir(),x,"config.json")}function De(){try{w.reload()}catch(s){return console.error(`\u914D\u7F6E\u6587\u4EF6\u9519\u8BEF: ${s instanceof Error?s.message:String(s)}`),console.error(`\u914D\u7F6E\u6587\u4EF6\u8DEF\u5F84: ${ke()}`),!1}let o=w.hasModelRouting(),e=w.hasSmallFastModelRouting();if(!o&&!e)return!1;let t=w.getConfig(),n=t.routing||{};for(let[s,r]of Object.entries(n))for(let i of r)if(!t.sources[i.source])return console.error(`\u914D\u7F6E\u9519\u8BEF: routing.${s} \u4E2D\u5F15\u7528\u7684 source "${i.source}" \u5728 sources \u4E2D\u4E0D\u5B58\u5728`),!1;return!0}function Ne(){if(w.initConfig(),!De()){process.exit(0);return}(async()=>{let o=E.getSetting("env")||{},e=ae(import.meta.url),t=k.dirname(e),n=k.join(t,"cli.js"),s=ie(process.execPath,["--no-deprecation",n,...process.argv.slice(2)],{env:{...process.env,...o},stdio:"inherit",cwd:process.cwd()});s.on("error",r=>{console.error("Failed to start command:",r.message),process.exit(1)}),s.on("close",r=>{process.exit(r||0)})})()}async function ve(){let o=ae(import.meta.url),e=k.dirname(o),t=k.join(e,"cli.js"),n=ie(process.execPath,["--no-deprecation",t,...process.argv.slice(2)],{env:process.env,stdio:"inherit",cwd:process.cwd()});n.on("error",s=>{console.error("Failed to start command:",s.message),process.exit(1)}),n.on("close",s=>{process.exit(s||0)})}async function Re(){process.argv.length<=2?Ne():await ve()}await Re();
12
+ `;q(o)?me(o,s,"utf8"):fe(o,s,"utf8")}var ct=5*1024*1024,lt=1024*1024,ut=Buffer.from('"compact_boundary"');var R=class o{static getTools=e=>[];static getMCPCommands=()=>[];static getMcpServer=e=>{};static getClients=async()=>[];static reloadClients=async()=>[];static reconnect=async(e,t,n)=>{};static registerIDEClient=(e,t)=>{};static cache=[];static add(e){o.cache.push(e)}static clear(){o.cache.forEach(e=>{e.cache.clear?.()})}};var j={env:{},permissions:{allow:[],deny:[],ask:[]},enableAllProjectMcpServers:!1,enabledMcpjsonServers:[],autoCompactEnabled:!0,language:"auto",thinking:"medium",disableSuggestion:!1,lazyTool:"proxy",memo:!1,messageArchiving:!1,archiveToolUseInputs:!1,autoMode:{enabled:!0,model:"",maxConsecutiveDenials:3,maxTotalDenials:20},autoMemory:{enabled:!1,minTokens:3e3,minTurns:3,teamMemoryEnabled:!1},autoDream:{enabled:!1,minHours:24,minSessions:5},proxy:!1,agentDepth:1,codemodeMethodsMax:20,plugins:{pluginClaudeCompat:!0}},L=class o{static test=!1;static testSettings;static setSettings(e){o.testSettings=e}static instance;static isTasksEnable(){return process.env.HAWA_CODE_ENABLE_TASKS=="true"||o.isAgentTeamEnable()}static isAgentTeamEnable(){return process.env.HAWA_CODE_EXPERIMENTAL_AGENT_TEAMS=="1"}static getLazyToolMode(){let t=b().lazyTool;return t==="proxy"||t==="loading"||t==="off"?t:"proxy"}static isLazyToolEnable(){return o.getLazyToolMode()==="loading"}static isProxyToolEnable(){return o.getLazyToolMode()==="proxy"}static isLazyOrProxyEnable(){return o.getLazyToolMode()!=="off"}static isPowerShellToolEnable(){return H()}static isMemoEnable(){return b().memo===!0}static isMessageArchivingEnable(){return b().messageArchiving===!0}static isArchiveToolUseInputsEnable(){return b().archiveToolUseInputs===!0}static getCodemodeMethodsMax(){let e=b().codemodeMethodsMax;return typeof e!="number"||Number.isNaN(e)?20:Math.min(100,Math.max(1,Math.floor(e)))}constructor(){this.initializeConfigDirectories()}initializeConfigDirectories(){let e=this.getUserSettingsPath(),t=this.getProjectSettingsPath();this.ensureDirExists(e),U(e)||I(e,JSON.stringify(this.getDefaultSettingsStructure(),null,2),"utf-8"),this.ensureDirExists(t),U(t)||I(t,JSON.stringify(this.getDefaultSettingsStructure(),null,2),"utf-8")}getDefaultSettingsStructure(){return{env:{},permissions:{allow:[],deny:[],ask:[]},autoMode:{enabled:!0,model:"",maxConsecutiveDenials:3,maxTotalDenials:20},thinking:"medium"}}static getInstance(){return o.instance||(o.instance=new o),o.instance}addProjectAllowedTools(e){let t=this.loadSettingsFromFile(this.getProjectSettingsPath()),n=t.permissions||{allow:[],deny:[]};if(n.allow||(n.allow=[]),n.allow.includes(e))O(`\u5DE5\u5177 '${e}' \u5DF2\u5B58\u5728\u4E8E\u9879\u76EE\u5141\u8BB8\u5217\u8868\u4E2D\uFF0C\u65E0\u9700\u91CD\u590D\u6DFB\u52A0`);else{n.allow.push(e),n.allow.sort();let s={...t,permissions:{...n}};this.saveSettingsToFile(this.getProjectSettingsPath(),s,j),O(`\u5DF2\u5C06\u5DE5\u5177 '${e}' \u6DFB\u52A0\u5230\u9879\u76EE\u5141\u8BB8\u5217\u8868`)}}getUserSettingsPath(){return se(Ae(),".hcode","settings.json")}getProjectSettingsPath(){let e=process.cwd();return se(e,".hcode","settings.json")}ensureDirExists(e){let t=we(e);U(t)||Ee(t,{recursive:!0})}loadSettingsFromFile(e){if(!U(e))return{};let t="";try{return t=Oe(e,"utf-8"),JSON.parse(t)}catch(n){return console.error(`Error reading settings file ${e} => ${t} `,n),{}}}saveSettingsToFile(e,t,n){let s={...t};for(let[r,i]of Object.entries(t))if(r in n)if(typeof i=="object"&&typeof n[r]=="object"){if(JSON.stringify(i)===JSON.stringify(n[r]))delete s[r];else if(r==="permissions"&&i&&typeof i=="object"){let l=n.permissions||{},c=i;Array.isArray(c.allow)&&Array.isArray(l.allow)&&JSON.stringify(c.allow)===JSON.stringify(l.allow)&&delete c.allow,Array.isArray(c.deny)&&Array.isArray(l.deny)&&JSON.stringify(c.deny)===JSON.stringify(l.deny)&&delete c.deny,Object.keys(c).length===0&&delete s[r]}}else i===n[r]&&delete s[r];this.ensureDirExists(e),Object.keys(s).length===0?I(e,"{}","utf-8"):I(e,JSON.stringify(s,null,2),"utf-8")}mergeStringArrays(e,t){if(!e&&!t)return;let n=[...e||[]];return(t||[]).forEach(s=>{n.includes(s)||n.push(s)}),n}loadSettings(){let e=this.loadSettingsFromFile(this.getUserSettingsPath()),t=this.loadSettingsFromFile(this.getProjectSettingsPath()),n={...e.env,...t.env},s={...e.permissions};if(e.permissions?.allow&&t.permissions?.allow){let a=[...e.permissions.allow];t.permissions.allow.forEach(u=>{a.includes(u)||a.push(u)}),s.allow=a}else t.permissions?.allow&&(s.allow=[...t.permissions.allow]);if(e.permissions?.deny&&t.permissions?.deny){let a=[...e.permissions.deny];t.permissions.deny.forEach(u=>{a.includes(u)||a.push(u)}),s.deny=a}else t.permissions?.deny&&(s.deny=[...t.permissions.deny]);if(e.permissions?.ask&&t.permissions?.ask){let a=[...e.permissions.ask];t.permissions.ask.forEach(u=>{a.includes(u)||a.push(u)}),s.ask=a}else t.permissions?.ask&&(s.ask=[...t.permissions.ask]);let r={...j,...e,...t};n&&Object.keys(n).length>0&&(r.env=n),s&&(s.allow||s.deny||s.ask)&&(r.permissions=s);let i=e.sandbox,l=t.sandbox;if(i||l){let a={...i,...l},u=i?.filesystem,_=l?.filesystem;(u||_)&&(a.filesystem={...u,..._,allowWrite:this.mergeStringArrays(u?.allowWrite,_?.allowWrite),denyWrite:this.mergeStringArrays(u?.denyWrite,_?.denyWrite),denyRead:this.mergeStringArrays(u?.denyRead,_?.denyRead),allowRead:this.mergeStringArrays(u?.allowRead,_?.allowRead)});let A=i?.network,C=l?.network;(A||C)&&(a.network={...A,...C,allowedDomains:this.mergeStringArrays(A?.allowedDomains,C?.allowedDomains),deniedDomains:this.mergeStringArrays(A?.deniedDomains,C?.deniedDomains),allowUnixSockets:this.mergeStringArrays(A?.allowUnixSockets,C?.allowUnixSockets)});let F=i?.ignoreViolations,B=l?.ignoreViolations;if(F||B){let M={};if(F)for(let[T,D]of Object.entries(F))M[T]=[...D];if(B)for(let[T,D]of Object.entries(B))M[T]?M[T]=this.mergeStringArrays(M[T],D)??[]:M[T]=[...D];a.ignoreViolations=M}r.sandbox=a}let c=e.plugins,d=t.plugins;if(c||d){let a={...c,...d};(c?.enabledPlugins||d?.enabledPlugins)&&(a.enabledPlugins=this.mergeStringArrays(c?.enabledPlugins,d?.enabledPlugins)),(c?.disabledPlugins||d?.disabledPlugins)&&(a.disabledPlugins=this.mergeStringArrays(c?.disabledPlugins,d?.disabledPlugins)),(c?.pluginMarketplaceAllowlist||d?.pluginMarketplaceAllowlist)&&(a.pluginMarketplaceAllowlist=this.mergeStringArrays(c?.pluginMarketplaceAllowlist,d?.pluginMarketplaceAllowlist)),(c?.pluginConfigs||d?.pluginConfigs)&&(a.pluginConfigs={...c?.pluginConfigs,...d?.pluginConfigs}),r.plugins=a}return r}saveUserSettings(e){let t=this.getUserSettingsPath();this.saveSettingsToFile(t,e,j)}saveProjectSettings(e){let t=this.getProjectSettingsPath();this.saveSettingsToFile(t,e,j)}getSetting(e){return this.loadSettings()[e]}updateSetting(e,t){let s={...this.loadSettings(),[e]:t};this.saveProjectSettings(s),p=s}resetSetting(e){let n={...this.loadSettings()};delete n[e],this.saveProjectSettings(n),p=n}getAllSettings(){return this.loadSettings()}},E=L.getInstance(),p=E.getAllSettings(),b=function(){return L.test?L.testSettings:(p||(p=E.getAllSettings(),R.clear(),p.env&&Object.keys(p.env).length>0&&(Object.entries(p.env).forEach(([o,e])=>{let t;typeof e=="string"?t=e:t=String(e),t.length>0&&(process.env[o]=t)}),O(`\u5DF2\u4ECE\u914D\u7F6E\u6587\u4EF6\u52A0\u8F7D ${Object.keys(p.env).length} \u4E2A\u73AF\u5883\u53D8\u91CF`,p.env))),p)};function J(){let o=E.getUserSettingsPath(),e=E.getProjectSettingsPath();ne(o,(t,n)=>{t==="change"&&(p=null,y.emit("webserver:settings_changed",{scope:"user"}),O("\u7528\u6237\u7EA7\u914D\u7F6E\u5DF2\u70ED\u52A0\u8F7D"))}).on("error",t=>{h("\u7528\u6237\u7EA7\u914D\u7F6E\u76D1\u63A7\u51FA\u9519:",t),setTimeout(()=>J(),100)}).unref(),ne(e,(t,n)=>{t==="change"&&(p=null,y.emit("webserver:settings_changed",{scope:"project"}),O("\u9879\u76EE\u7EA7\u914D\u7F6E\u5DF2\u70ED\u52A0\u8F7D",n))}).on("error",t=>{h("\u9879\u76EE\u7EA7\u914D\u7F6E\u76D1\u63A7\u51FA\u9519:",t),setTimeout(()=>J(),100)}).unref()}J();import Ce from"os";import re from"path";import S from"fs";var Q={sources:{openai:{base_url:"https://api.openai.com/v1",auth_token:"{apikey}",api_type:"openai",models:["gpt-5.5","gpt-5.4-mini"]},kimi:{base_url:"https://api.kimi.com/coding",auth_token:"{apikey}",api_type:"anthropic",models:["K2.5","K2.6"]},"qwen-coding":{base_url:"https://coding.dashscope.aliyuncs.com/apps/anthropic",auth_token:"{apikey}",api_type:"anthropic",models:["qwen3-coder-plus"]}},routing:{MODEL:[{source:"kimi",model:"K2.6",weight:60},{source:"openai",model:"gpt-5.5",weight:40}],SMALL_FAST_MODEL:[{source:"qwen-coding",model:"qwen3-coder-plus",weight:50},{source:"kimi",model:"K2.5",weight:50}]}};function Pe(){let o=Ce.homedir();return re.join(o,x,"config.json")}function oe(o){if(o.length===0)throw new Error("No items to select from");if(o.length===1)return o[0];let e=o.reduce((n,s)=>n+(s.weight??100),0),t=Math.random()*e;for(let n of o){let s=n.weight??100;if(t-=s,t<=0)return n}return o[o.length-1]}var V=class{config;configPath;constructor(e){this.configPath=e||Pe();try{this.config=this.loadModelConfig()}catch(t){console.log(t)}}initConfig(){if(!S.existsSync(this.configPath))try{let e=re.dirname(this.configPath);S.mkdirSync(e,{recursive:!0}),S.writeFileSync(this.configPath,JSON.stringify(Q,null,2))}catch(e){v(e)}}reload(){this.config=this.loadModelConfig()}loadModelConfig(){try{if(!S.existsSync(this.configPath))return Q;let e=S.readFileSync(this.configPath,"utf-8"),t=JSON.parse(e);return t.sources&&t.routing?t:Q}catch(e){throw v(e),e}}getConfig(){return this.config}hasModelRouting(){return!!(this.config.routing?.MODEL&&this.config.routing.MODEL.length>0)}getModelRoutingModels(){let e=this.config.routing?.MODEL;return!e||e.length===0?[]:e.map(t=>t.model)}hasSmallFastModelRouting(){return!!(this.config.routing?.SMALL_FAST_MODEL&&this.config.routing.SMALL_FAST_MODEL.length>0)}getModel(){let e=this.config.routing?.MODEL;if(!e||e.length===0)throw new Error("No MODEL routing configuration found");let t=oe(e);return`${t.source}__${t.model}`}getSmallFastModel(){let e=this.config.routing?.SMALL_FAST_MODEL;if(!e||e.length===0)throw new Error("No SMALL_FAST_MODEL routing configuration found");let t=oe(e);return`${t.source}__${t.model}`}getSourceConfig(e){return this.config.sources?.[e]}parseModelKey(e){let t=e.indexOf("__");return t===-1?{source:"",model:e}:{source:e.slice(0,t),model:e.slice(t+2)}}getModelSourceConfig(e){let{source:t}=this.parseModelKey(e);if(t)return this.getSourceConfig(t)}setModelRouting(e){this.config.routing.MODEL=e,this.saveConfig()}setSmallFastModelRouting(e){this.config.routing.SMALL_FAST_MODEL=e,this.saveConfig()}updateConfig(e){this.config=e,this.saveConfig()}getAvailableModels(){let e=[];for(let[t,n]of Object.entries(this.config.sources||{}))for(let s of n.models||[])e.push(`${t}__${s}`);return e}saveConfig(){try{let e={};if(S.existsSync(this.configPath)){let n=S.readFileSync(this.configPath,"utf-8");e=JSON.parse(n)}let t={...e,sources:this.config.sources,routing:this.config.routing};S.writeFileSync(this.configPath,JSON.stringify(t,null,2))}catch(e){v(e)}}},w=new V;import Le from"os";function ke(){return k.join(Le.homedir(),x,"config.json")}function De(){try{w.reload()}catch(s){return console.error(`\u914D\u7F6E\u6587\u4EF6\u9519\u8BEF: ${s instanceof Error?s.message:String(s)}`),console.error(`\u914D\u7F6E\u6587\u4EF6\u8DEF\u5F84: ${ke()}`),!1}let o=w.hasModelRouting(),e=w.hasSmallFastModelRouting();if(!o&&!e)return!1;let t=w.getConfig(),n=t.routing||{};for(let[s,r]of Object.entries(n))for(let i of r)if(!t.sources[i.source])return console.error(`\u914D\u7F6E\u9519\u8BEF: routing.${s} \u4E2D\u5F15\u7528\u7684 source "${i.source}" \u5728 sources \u4E2D\u4E0D\u5B58\u5728`),!1;return!0}function Ne(){if(w.initConfig(),!De()){process.exit(0);return}(async()=>{let o=E.getSetting("env")||{},e=ae(import.meta.url),t=k.dirname(e),n=k.join(t,"cli.js"),s=ie(process.execPath,["--no-deprecation",n,...process.argv.slice(2)],{env:{...process.env,...o},stdio:"inherit",cwd:process.cwd()});s.on("error",r=>{console.error("Failed to start command:",r.message),process.exit(1)}),s.on("close",r=>{process.exit(r||0)})})()}async function ve(){let o=ae(import.meta.url),e=k.dirname(o),t=k.join(e,"cli.js"),n=ie(process.execPath,["--no-deprecation",t,...process.argv.slice(2)],{env:process.env,stdio:"inherit",cwd:process.cwd()});n.on("error",s=>{console.error("Failed to start command:",s.message),process.exit(1)}),n.on("close",s=>{process.exit(s||0)})}async function Re(){process.argv.length<=2?Ne():await ve()}await Re();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dahawa/hawa-code",
3
- "version": "2.5.2",
3
+ "version": "2.6.0",
4
4
  "bin": {
5
5
  "hcode": "hawa.js"
6
6
  },
package/webServer/app.js CHANGED
@@ -68,8 +68,8 @@ ${e}</tr>
68
68
  `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${dn(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let l=this.parser.parseInline(n),a=Qv(e);if(a===null)return l;e=a;let s='<a href="'+e+'"';return t&&(s+=' title="'+dn(t)+'"'),s+=">"+l+"</a>",s}image({href:e,title:t,text:n,tokens:l}){l&&(n=this.parser.parseInline(l,this.parser.textRenderer));let a=Qv(e);if(a===null)return dn(n);e=a;let s=`<img src="${e}" alt="${n}"`;return t&&(s+=` title="${dn(t)}"`),s+=">",s}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:dn(e.text)}},bd=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}},Ft=class cd{constructor(t){re(this,"options");re(this,"renderer");re(this,"textRenderer");this.options=t||ea,this.options.renderer=this.options.renderer||new Xu,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new bd}static parse(t,n){return new cd(n).parse(t)}static parseInline(t,n){return new cd(n).parseInline(t)}parse(t,n=!0){let l="";for(let a=0;a<t.length;a++){let s=t[a];if(this.options.extensions?.renderers?.[s.type]){let o=s,u=this.options.extensions.renderers[o.type].call({parser:this},o);if(u!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(o.type)){l+=u||"";continue}}let i=s;switch(i.type){case"space":{l+=this.renderer.space(i);continue}case"hr":{l+=this.renderer.hr(i);continue}case"heading":{l+=this.renderer.heading(i);continue}case"code":{l+=this.renderer.code(i);continue}case"table":{l+=this.renderer.table(i);continue}case"blockquote":{l+=this.renderer.blockquote(i);continue}case"list":{l+=this.renderer.list(i);continue}case"html":{l+=this.renderer.html(i);continue}case"def":{l+=this.renderer.def(i);continue}case"paragraph":{l+=this.renderer.paragraph(i);continue}case"text":{let o=i,u=this.renderer.text(o);for(;a+1<t.length&&t[a+1].type==="text";)o=t[++a],u+=`
69
69
  `+this.renderer.text(o);n?l+=this.renderer.paragraph({type:"paragraph",raw:u,text:u,tokens:[{type:"text",raw:u,text:u,escaped:!0}]}):l+=u;continue}default:{let o='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return l}parseInline(t,n=this.renderer){let l="";for(let a=0;a<t.length;a++){let s=t[a];if(this.options.extensions?.renderers?.[s.type]){let o=this.options.extensions.renderers[s.type].call({parser:this},s);if(o!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){l+=o||"";continue}}let i=s;switch(i.type){case"escape":{l+=n.text(i);break}case"html":{l+=n.html(i);break}case"link":{l+=n.link(i);break}case"image":{l+=n.image(i);break}case"strong":{l+=n.strong(i);break}case"em":{l+=n.em(i);break}case"codespan":{l+=n.codespan(i);break}case"br":{l+=n.br(i);break}case"del":{l+=n.del(i);break}case"text":{l+=n.text(i);break}default:{let o='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return l}},Qu,Ri=(Qu=class{constructor(e){re(this,"options");re(this,"block");this.options=e||ea}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?It.lex:It.lexInline}provideParser(){return this.block?Ft.parse:Ft.parseInline}},re(Qu,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),re(Qu,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Qu),jT=class{constructor(...e){re(this,"defaults",fd());re(this,"options",this.setOptions);re(this,"parse",this.parseMarkdown(!0));re(this,"parseInline",this.parseMarkdown(!1));re(this,"Parser",Ft);re(this,"Renderer",Xu);re(this,"TextRenderer",bd);re(this,"Lexer",It);re(this,"Tokenizer",Zu);re(this,"Hooks",Ri);this.use(...e)}walkTokens(e,t){let n=[];for(let l of e)switch(n=n.concat(t.call(this,l)),l.type){case"table":{let a=l;for(let s of a.header)n=n.concat(this.walkTokens(s.tokens,t));for(let s of a.rows)for(let i of s)n=n.concat(this.walkTokens(i.tokens,t));break}case"list":{let a=l;n=n.concat(this.walkTokens(a.items,t));break}default:{let a=l;this.defaults.extensions?.childTokens?.[a.type]?this.defaults.extensions.childTokens[a.type].forEach(s=>{let i=a[s].flat(1/0);n=n.concat(this.walkTokens(i,t))}):a.tokens&&(n=n.concat(this.walkTokens(a.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let l={...n};if(l.async=this.defaults.async||l.async||!1,n.extensions&&(n.extensions.forEach(a=>{if(!a.name)throw new Error("extension name required");if("renderer"in a){let s=t.renderers[a.name];s?t.renderers[a.name]=function(...i){let o=a.renderer.apply(this,i);return o===!1&&(o=s.apply(this,i)),o}:t.renderers[a.name]=a.renderer}if("tokenizer"in a){if(!a.level||a.level!=="block"&&a.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=t[a.level];s?s.unshift(a.tokenizer):t[a.level]=[a.tokenizer],a.start&&(a.level==="block"?t.startBlock?t.startBlock.push(a.start):t.startBlock=[a.start]:a.level==="inline"&&(t.startInline?t.startInline.push(a.start):t.startInline=[a.start]))}"childTokens"in a&&a.childTokens&&(t.childTokens[a.name]=a.childTokens)}),l.extensions=t),n.renderer){let a=this.defaults.renderer||new Xu(this.defaults);for(let s in n.renderer){if(!(s in a))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let i=s,o=n.renderer[i],u=a[i];a[i]=(...f)=>{let r=o.apply(a,f);return r===!1&&(r=u.apply(a,f)),r||""}}l.renderer=a}if(n.tokenizer){let a=this.defaults.tokenizer||new Zu(this.defaults);for(let s in n.tokenizer){if(!(s in a))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let i=s,o=n.tokenizer[i],u=a[i];a[i]=(...f)=>{let r=o.apply(a,f);return r===!1&&(r=u.apply(a,f)),r}}l.tokenizer=a}if(n.hooks){let a=this.defaults.hooks||new Ri;for(let s in n.hooks){if(!(s in a))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let i=s,o=n.hooks[i],u=a[i];Ri.passThroughHooks.has(s)?a[i]=f=>{if(this.defaults.async&&Ri.passThroughHooksRespectAsync.has(s))return(async()=>{let d=await o.call(a,f);return u.call(a,d)})();let r=o.call(a,f);return u.call(a,r)}:a[i]=(...f)=>{if(this.defaults.async)return(async()=>{let d=await o.apply(a,f);return d===!1&&(d=await u.apply(a,f)),d})();let r=o.apply(a,f);return r===!1&&(r=u.apply(a,f)),r}}l.hooks=a}if(n.walkTokens){let a=this.defaults.walkTokens,s=n.walkTokens;l.walkTokens=function(i){let o=[];return o.push(s.call(this,i)),a&&(o=o.concat(a.call(this,i))),o}}this.defaults={...this.defaults,...l}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return It.lex(e,t??this.defaults)}parser(e,t){return Ft.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let l={...n},a={...this.defaults,...l},s=this.onError(!!a.silent,!!a.async);if(this.defaults.async===!0&&l.async===!1)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(a.hooks&&(a.hooks.options=a,a.hooks.block=e),a.async)return(async()=>{let i=a.hooks?await a.hooks.preprocess(t):t,o=await(a.hooks?await a.hooks.provideLexer():e?It.lex:It.lexInline)(i,a),u=a.hooks?await a.hooks.processAllTokens(o):o;a.walkTokens&&await Promise.all(this.walkTokens(u,a.walkTokens));let f=await(a.hooks?await a.hooks.provideParser():e?Ft.parse:Ft.parseInline)(u,a);return a.hooks?await a.hooks.postprocess(f):f})().catch(s);try{a.hooks&&(t=a.hooks.preprocess(t));let i=(a.hooks?a.hooks.provideLexer():e?It.lex:It.lexInline)(t,a);a.hooks&&(i=a.hooks.processAllTokens(i)),a.walkTokens&&this.walkTokens(i,a.walkTokens);let o=(a.hooks?a.hooks.provideParser():e?Ft.parse:Ft.parseInline)(i,a);return a.hooks&&(o=a.hooks.postprocess(o)),o}catch(i){return s(i)}}}onError(e,t){return n=>{if(n.message+=`
70
70
  Please report this to https://github.com/markedjs/marked.`,e){let l="<p>An error occurred:</p><pre>"+dn(n.message+"",!0)+"</pre>";return t?Promise.resolve(l):l}if(t)return Promise.reject(n);throw n}}},Fl=new jT;function ne(e,t){return Fl.parse(e,t)}ne.options=ne.setOptions=function(e){return Fl.setOptions(e),ne.defaults=Fl.defaults,Xv(ne.defaults),ne};ne.getDefaults=fd;ne.defaults=ea;ne.use=function(...e){return Fl.use(...e),ne.defaults=Fl.defaults,Xv(ne.defaults),ne};ne.walkTokens=function(e,t){return Fl.walkTokens(e,t)};ne.parseInline=Fl.parseInline;ne.Parser=Ft;ne.parser=Ft.parse;ne.Renderer=Xu;ne.TextRenderer=bd;ne.Lexer=It;ne.lexer=It.lex;ne.Tokenizer=Zu;ne.Hooks=Ri;ne.parse=ne;var w_=ne.options,z_=ne.setOptions,U_=ne.use,D_=ne.walkTokens,L_=ne.parseInline;var B_=Ft.parse,H_=It.lex;var Sb=v($(),1);var as=v(y(),1);function ny({input:e}){return(0,as.jsxs)("div",{className:"tool-use-detail",children:[(0,as.jsx)("span",{className:"tool-badge",children:"Read"}),(0,as.jsx)("span",{className:"file-path",children:e.file_path}),(e.offset||e.limit)&&(0,as.jsxs)("span",{className:"tool-meta",children:[e.offset?`from line ${e.offset}`:"",e.limit?` (${e.limit} lines)`:""]})]})}var ss=v(y(),1);function ly({input:e}){let t=e.old_string===""?"Create":e.new_string===""?"Delete":"Update";return(0,ss.jsxs)("div",{className:"tool-use-detail",children:[(0,ss.jsx)("span",{className:"tool-badge",children:t}),(0,ss.jsx)("span",{className:"file-path",children:e.file_path}),e.replace_all&&(0,ss.jsx)("span",{className:"tool-meta",children:"(replace all)"})]})}var is=v(y(),1);function ay({input:e}){let t=e.content?e.content.split(`
71
- `).length:0;return(0,is.jsxs)("div",{className:"tool-use-detail",children:[(0,is.jsx)("span",{className:"tool-badge",children:"Write"}),(0,is.jsx)("span",{className:"file-path",children:e.file_path}),(0,is.jsxs)("span",{className:"tool-meta",children:["(",t," lines)"]})]})}var ta=v(y(),1);function sy({input:e}){return(0,ta.jsxs)("div",{className:"tool-use-detail",children:[(0,ta.jsx)("span",{className:"tool-badge",children:"Bash"}),e.run_in_background&&(0,ta.jsx)("span",{className:"tool-meta",children:"(background)"}),(0,ta.jsx)("pre",{className:"command-block",children:(0,ta.jsx)("code",{children:e.command})})]})}var Qn=v(y(),1);function iy({input:e}){return(0,Qn.jsxs)("div",{className:"tool-use-detail",children:[(0,Qn.jsx)("span",{className:"tool-badge",children:"Grep"}),(0,Qn.jsxs)("code",{className:"pattern-text",children:["/",e.pattern,"/"]}),e.path&&(0,Qn.jsxs)("span",{className:"tool-meta",children:["in ",e.path]}),e.glob&&(0,Qn.jsxs)("span",{className:"tool-meta",children:["(",e.glob,")"]}),e.type&&(0,Qn.jsxs)("span",{className:"tool-meta",children:["type: ",e.type]}),e.output_mode&&(0,Qn.jsxs)("span",{className:"tool-meta",children:["[",e.output_mode,"]"]})]})}var os=v(y(),1);function oy({input:e}){return(0,os.jsxs)("div",{className:"tool-use-detail",children:[(0,os.jsx)("span",{className:"tool-badge",children:"Glob"}),(0,os.jsx)("code",{className:"pattern-text",children:e.pattern}),e.path&&(0,os.jsxs)("span",{className:"tool-meta",children:["in ",e.path]})]})}var Ai=v(y(),1);function uy({input:e}){return(0,Ai.jsxs)("div",{className:"tool-use-detail",children:[(0,Ai.jsx)("span",{className:"tool-badge",children:"LS"}),(0,Ai.jsx)("span",{className:"file-path",children:e.path||"."})]})}var ry=v($(),1),jn=v(y(),1),$u=120;function cy({input:e}){let[t,n]=(0,ry.useState)(!1),{description:l,prompt:a,subagent_type:s,model_name:i,resume:o,run_in_background:u,name:f,team_name:r,mode:d,isolation:c}=e,p=typeof a=="string"&&a.length>0,b=p&&a.length>$u?a.substring(0,$u)+"...":a,S=p&&(t||a.length<=$u),T=p&&a.length>$u,m=[];return s&&m.push(`type: ${s}`),i&&m.push(`model: ${i}`),o&&m.push(`resume: ${o}`),u&&m.push("background"),r&&f&&m.push(`team: ${r}/${f}`),d&&m.push(`mode: ${d}`),c&&m.push(`isolation: ${c}`),(0,jn.jsxs)("div",{className:"tool-use-detail",children:[(0,jn.jsx)("span",{className:"tool-badge",children:"Agent"}),l&&(0,jn.jsx)("span",{className:"tool-description",children:l}),m.length>0&&(0,jn.jsxs)("span",{className:"tool-meta",children:["(",m.join(", "),")"]}),S&&(0,jn.jsx)("div",{className:"tool-input agent-prompt-detail",children:(0,jn.jsx)("code",{children:t?a:b})}),T&&(0,jn.jsx)("span",{className:"tool-meta detail-toggle",onClick:()=>n(!t),style:{cursor:"pointer"},children:t?"collapse details":"details"})]})}var Tl=v(y(),1);function fy({input:e}){return(0,Tl.jsxs)("div",{className:"tool-use-detail",children:[(0,Tl.jsx)("span",{className:"tool-badge",children:"LSP"}),(0,Tl.jsx)("span",{className:"tool-meta",children:e.operation}),e.filePath&&(0,Tl.jsx)("span",{className:"file-path",children:e.filePath}),e.line!==void 0&&(0,Tl.jsxs)("span",{className:"tool-meta",children:[":",e.line+1,e.character!==void 0?`:${e.character+1}`:""]}),e.query&&(0,Tl.jsx)("code",{className:"pattern-text",children:e.query})]})}var Sd=v(y(),1);function dy({}){return(0,Sd.jsx)("div",{className:"tool-use-detail",children:(0,Sd.jsx)("span",{className:"tool-badge",children:"Cwd"})})}var Mi=v(y(),1);function py({input:e,displayName:t}){let l=Object.entries(e||{}).map(([a,s])=>`${a}: ${JSON.stringify(s)}`).join(", ");return(0,Mi.jsxs)("div",{className:"tool-use-detail tool-use-mcp",children:[(0,Mi.jsx)("span",{className:"tool-badge",children:t}),l&&(0,Mi.jsxs)("span",{className:"tool-meta mcp-input-summary",children:["(",l,")"]})]})}var Ci=v(y(),1);function my({input:e}){let t=e.task_id.startsWith("a"),n=e.block!==!1?`Reading ${t?"Task":"shell"} output (blocking until complete${e.timeout?` timeout ${e.timeout}`:""})`:`Reading ${t?"Task":"shell"} output (non-blocking)`;return(0,Ci.jsxs)("div",{className:"tool-use-detail",children:[(0,Ci.jsx)("span",{className:"tool-badge",children:t?"TaskOutput":"ShellOutput"}),(0,Ci.jsxs)("span",{className:"tool-meta",children:[n," (ID: ",e.task_id,")"]})]})}var na=v(y(),1);function gy({input:e}){return(0,na.jsxs)("div",{className:"tool-use-detail",children:[(0,na.jsx)("span",{className:"tool-badge",children:"PowerShell"}),e.run_in_background&&(0,na.jsx)("span",{className:"tool-meta",children:"(background)"}),(0,na.jsx)("pre",{className:"command-block",children:(0,na.jsx)("code",{children:e.command})})]})}var Oi=v(y(),1);function hy({input:e}){let t=e.toolNames||[];return(0,Oi.jsxs)("div",{className:"tool-use-detail",children:[(0,Oi.jsx)("span",{className:"tool-badge",children:"ToolLoader"}),(0,Oi.jsxs)("span",{className:"tool-meta",children:["Loading tool",t.length>1?"s":"",": ",t.join(", ")]})]})}var wi=v(y(),1);function vy({input:e}){let t=e.toolNames||[];return(0,wi.jsxs)("div",{className:"tool-use-detail",children:[(0,wi.jsx)("span",{className:"tool-badge",children:"ToolUnLoader"}),(0,wi.jsxs)("span",{className:"tool-meta",children:["Unloading tool",t.length>1?"s":"",": ",t.join(", ")]})]})}var la=v(y(),1);function yy({input:e}){return(0,la.jsxs)("div",{className:"tool-use-detail",children:[(0,la.jsx)("span",{className:"tool-badge",children:"NotebookEdit"}),(0,la.jsxs)("span",{className:"tool-meta",children:[e.notebook_path," (cell ",e.cell_number,", ",e.edit_mode||"replace",")"]}),(0,la.jsx)("pre",{className:"command-block",children:(0,la.jsxs)("code",{children:[e.new_source.slice(0,200),e.new_source.length>200?"...":""]})})]})}var zi=v(y(),1);function by({input:e}){return(0,zi.jsxs)("div",{className:"tool-use-detail",children:[(0,zi.jsx)("span",{className:"tool-badge",children:"WebSearch"}),(0,zi.jsx)("span",{className:"tool-meta",children:e.query})]})}var us=v(y(),1);function Sy({input:e}){return(0,us.jsxs)("div",{className:"tool-use-detail",children:[(0,us.jsx)("span",{className:"tool-badge",children:"WebFetch"}),(0,us.jsx)("span",{className:"tool-meta",children:e.url}),(0,us.jsx)("div",{className:"tool-input",children:e.prompt})]})}var Ui=v(y(),1);function Ny({input:e}){return(0,Ui.jsxs)("div",{className:"tool-use-detail",children:[(0,Ui.jsx)("span",{className:"tool-badge",children:"TaskStop"}),(0,Ui.jsxs)("span",{className:"tool-meta",children:["Stop task: ",e.task_id]})]})}var Di=v(y(),1);function Ty({input:e}){let t=e.todos?.find(n=>n.status==="in_progress");return(0,Di.jsxs)("div",{className:"tool-use-detail",children:[(0,Di.jsx)("span",{className:"tool-badge",children:"TodoWrite"}),(0,Di.jsx)("span",{className:"tool-meta",children:t?`${t.activeForm}\u2026`:"update todo"})]})}var Li=v(y(),1);function Ey({input:e}){return(0,Li.jsxs)("div",{className:"tool-use-detail",children:[(0,Li.jsx)("span",{className:"tool-badge",children:"Think"}),(0,Li.jsx)("div",{className:"tool-input",children:e.thought})]})}var Bi=v(y(),1);function _y({input:e}){let t=e.questions?.length||0,n=e.questions?.reduce((l,a)=>l+(a.options?.length||0),0)||0;return(0,Bi.jsxs)("div",{className:"tool-use-detail",children:[(0,Bi.jsx)("span",{className:"tool-badge",children:"AskUserQuestion"}),(0,Bi.jsxs)("span",{className:"tool-meta",children:["Asking ",t," question",t>1?"s":""," with ",n," total options"]})]})}var We=v($(),1),be=v(y(),1);function Ry({questions:e,onSubmit:t,onCancel:n}){let[l,a]=(0,We.useState)(0),[s,i]=(0,We.useState)({}),[o,u]=(0,We.useState)({}),[f,r]=(0,We.useState)({}),[d,c]=(0,We.useState)({}),[p,b]=(0,We.useState)(!1),S=e[l],T=l===e.length-1,m=(0,We.useCallback)(w=>(s[w]?.length??0)>0||(o[w]?.length??0)>0,[s,o]),g=(0,We.useCallback)(w=>{let B=S.options[w];i(M=>{let E=M[l]||[];if(S.multiSelect){let q=E.includes(B.label)?E.filter(ee=>ee!==B.label):[...E,B.label];return{...M,[l]:q}}else return{...M,[l]:[B.label]}}),r(M=>({...M,[l]:!1}))},[l,S]),h=(0,We.useCallback)(()=>{i(w=>{let B=w[l]||[];if(S.multiSelect){let E=B.includes("Custom answer")?B:[...B,"Custom answer"];return{...w,[l]:E}}else return{...w,[l]:["Custom answer"]}}),r(w=>({...w,[l]:!0})),c(w=>({...w,[l]:w[l]||o[l]||""}))},[l,S,o]),N=(0,We.useCallback)(()=>{let w=d[l]?.trim()||"";w&&(u(B=>({...B,[l]:w})),r(B=>({...B,[l]:!1})))},[l,d]),x=(0,We.useCallback)(()=>{r(w=>({...w,[l]:!1})),i(w=>{let M=(w[l]||[]).filter(E=>E!=="Custom answer");return{...w,[l]:M}}),c(w=>({...w,[l]:""})),u(w=>{let B={...w};return delete B[l],B})},[l]),U=(0,We.useCallback)(()=>{let w={};e.forEach((B,M)=>{let E=o[M],z=s[M]||[];E?w[B.question]=E:z.length>0?w[B.question]=z.filter(q=>q!=="Custom answer").join(", "):w[B.question]="No answer provided"}),b(!0),t(w)},[e,s,o,t]),k=(0,We.useCallback)(()=>{b(!0),n()},[n]),O=(0,We.useCallback)(()=>{l<e.length-1&&a(w=>w+1)},[l,e.length]),R=(0,We.useCallback)(()=>{l>0&&a(w=>w-1)},[l]),A=s[l]?.includes("Custom answer")||!1,H=A&&f[l],j=o[l]!==void 0;return(0,be.jsxs)("div",{className:"ask-user-question-form",children:[(0,be.jsx)("div",{className:"ask-user-question-header",children:e.map((w,B)=>(0,be.jsx)("span",{className:`ask-user-question-step ${m(B)?"answered":""} ${B===l?"active":""}`,children:w.header},B))}),(0,be.jsx)("div",{className:"ask-user-question-title",children:S.question}),S.multiSelect&&(0,be.jsx)("div",{className:"ask-user-question-hint",children:"You can select multiple options"}),(0,be.jsxs)("div",{className:"ask-user-question-options",children:[S.options.map((w,B)=>{let M=(s[l]||[]).includes(w.label),E=S.multiSelect?"checkbox":"radio";return(0,be.jsxs)("label",{className:`ask-user-question-option ${M?"selected":""}`,children:[(0,be.jsx)("input",{type:E,name:`question-${l}`,checked:M,onChange:()=>g(B),disabled:p}),(0,be.jsx)("span",{className:"ask-user-question-option-label",children:w.label}),(0,be.jsx)("span",{className:"ask-user-question-option-description",children:w.description})]},B)}),(0,be.jsxs)("label",{className:`ask-user-question-option ${A?"selected":""}`,children:[(0,be.jsx)("input",{type:S.multiSelect?"checkbox":"radio",name:`question-${l}`,checked:A,onChange:h,disabled:p}),(0,be.jsx)("span",{className:"ask-user-question-option-label",children:"Type something"}),j&&!H&&(0,be.jsxs)("span",{className:"ask-user-question-option-description",children:["Custom: ",o[l]]})]}),H&&(0,be.jsxs)("div",{className:"ask-user-question-custom-inline",children:[(0,be.jsx)("input",{type:"text",className:"ask-user-question-custom-input",value:d[l]||"",onChange:w=>c(B=>({...B,[l]:w.target.value})),placeholder:"Type your answer...",disabled:p,autoFocus:!0}),(0,be.jsxs)("div",{className:"ask-user-question-custom-inline-actions",children:[(0,be.jsx)("button",{onClick:N,disabled:p||!d[l]?.trim(),children:"OK"}),(0,be.jsx)("button",{onClick:x,disabled:p,children:"Cancel"})]})]})]}),(0,be.jsxs)("div",{className:"ask-user-question-actions",children:[(0,be.jsx)("button",{onClick:R,disabled:l===0||p,children:"Previous"}),T?(0,be.jsx)("button",{onClick:U,disabled:p,children:"Submit"}):(0,be.jsx)("button",{onClick:O,disabled:p,children:"Next"}),(0,be.jsx)("button",{onClick:k,disabled:p,children:"Cancel"})]})]})}var Hi=v(y(),1);function ky(e){return(0,Hi.jsxs)("div",{className:"tool-use-detail",children:[(0,Hi.jsx)("span",{className:"tool-badge",children:"EnterPlanMode"}),(0,Hi.jsx)("span",{className:"tool-meta",children:"Entering plan mode"})]})}var xy=v($(),1),El=v(y(),1);function Ay({onApprove:e}){let[t,n]=(0,xy.useState)(!1);return(0,El.jsxs)("div",{className:"plan-mode-inline-form",children:[(0,El.jsx)("div",{className:"plan-mode-inline-title",children:"Enter plan mode?"}),(0,El.jsx)("div",{className:"plan-mode-inline-description",children:"Plan mode will ask you to approve a plan before making changes."}),(0,El.jsxs)("div",{className:"plan-mode-inline-actions",children:[(0,El.jsx)("button",{onClick:()=>{n(!0),e(!0)},disabled:t,children:"Yes, enter plan mode"}),(0,El.jsx)("button",{onClick:()=>{n(!0),e(!1)},disabled:t,children:"No, stay in current mode"})]})]})}var qi=v(y(),1);function My({input:e}){return(0,qi.jsxs)("div",{className:"tool-use-detail",children:[(0,qi.jsx)("span",{className:"tool-badge",children:"ExitPlanMode"}),(0,qi.jsx)("span",{className:"tool-meta",children:"Presenting plan to user for approval"})]})}var Cy=v($(),1),Ie=v(y(),1);function Oy({plan:e,planFilePath:t,onApprove:n,onReject:l}){let[a,s]=(0,Cy.useState)(!1);return e?(0,Ie.jsxs)("div",{className:"plan-mode-inline-form",children:[(0,Ie.jsx)("div",{className:"plan-mode-inline-title",children:"Approve plan to exit plan mode"}),(0,Ie.jsx)("div",{className:"plan-mode-inline-plan",children:(0,Ie.jsx)("pre",{children:e})}),t&&(0,Ie.jsxs)("div",{className:"plan-mode-inline-path",children:["Plan file: ",t]}),(0,Ie.jsxs)("div",{className:"plan-mode-inline-actions",children:[(0,Ie.jsx)("button",{onClick:()=>{s(!0),n(!1)},disabled:a,children:"Auto-accept edits"}),(0,Ie.jsx)("button",{onClick:()=>{s(!0),n(!0)},disabled:a,children:"Manual approval"}),(0,Ie.jsx)("button",{onClick:()=>{s(!0),l()},disabled:a,children:"Reject"})]})]}):(0,Ie.jsxs)("div",{className:"plan-mode-inline-form",children:[(0,Ie.jsx)("div",{className:"plan-mode-inline-title",children:"No plan found"}),(0,Ie.jsx)("div",{className:"plan-mode-inline-description",children:"There is no plan to approve. Do you want to exit plan mode?"}),(0,Ie.jsxs)("div",{className:"plan-mode-inline-actions",children:[(0,Ie.jsx)("button",{onClick:()=>{s(!0),n(!1)},disabled:a,children:"Yes, exit plan mode"}),(0,Ie.jsx)("button",{onClick:()=>{s(!0),l()},disabled:a,children:"No, keep planning"})]})]})}var Gi=v(y(),1);function wy({input:e}){return(0,Gi.jsxs)("div",{className:"tool-use-detail",children:[(0,Gi.jsx)("span",{className:"tool-badge",children:"EnterWorktree"}),(0,Gi.jsx)("span",{className:"tool-meta",children:e.name?`Creating worktree: ${e.name}`:"Creating worktree"})]})}var Yi=v(y(),1);function zy({input:e}){return(0,Yi.jsxs)("div",{className:"tool-use-detail",children:[(0,Yi.jsx)("span",{className:"tool-badge",children:"ExitWorktree"}),(0,Yi.jsx)("span",{className:"tool-meta",children:e.action==="remove"?"Exiting and removing worktree":"Exiting worktree"})]})}var Qi=v(y(),1);function Uy({input:e}){return(0,Qi.jsxs)("div",{className:"tool-use-detail",children:[(0,Qi.jsx)("span",{className:"tool-badge",children:"SlashCommand"}),(0,Qi.jsxs)("span",{className:"tool-meta",children:["Executing ",e.command]})]})}var ji=v(y(),1);function Dy({input:e}){return(0,ji.jsxs)("div",{className:"tool-use-detail",children:[(0,ji.jsx)("span",{className:"tool-badge",children:"Skill"}),(0,ji.jsx)("span",{className:"tool-meta",children:e.skill})]})}var Zi=v(y(),1);function Ly({input:e}){let t=e.prompt?.length>60?e.prompt.slice(0,60)+"...":e.prompt;return(0,Zi.jsxs)("div",{className:"tool-use-detail",children:[(0,Zi.jsx)("span",{className:"tool-badge",children:"CronCreate"}),(0,Zi.jsxs)("span",{className:"tool-meta",children:[e.cron,": ",t]})]})}var Xi=v(y(),1);function By({input:e}){return(0,Xi.jsxs)("div",{className:"tool-use-detail",children:[(0,Xi.jsx)("span",{className:"tool-badge",children:"CronDelete"}),(0,Xi.jsx)("span",{className:"tool-meta",children:e.id})]})}var Vi=v(y(),1);function Hy(e){return(0,Vi.jsxs)("div",{className:"tool-use-detail",children:[(0,Vi.jsx)("span",{className:"tool-badge",children:"CronList"}),(0,Vi.jsx)("span",{className:"tool-meta",children:"List scheduled cron jobs"})]})}var Ki=v(y(),1);function qy({input:e}){return(0,Ki.jsxs)("div",{className:"tool-use-detail",children:[(0,Ki.jsx)("span",{className:"tool-badge",children:"TeamCreate"}),(0,Ki.jsxs)("span",{className:"tool-meta",children:["Creating team: ",e.team_name]})]})}var $i=v(y(),1);function Gy(e){return(0,$i.jsxs)("div",{className:"tool-use-detail",children:[(0,$i.jsx)("span",{className:"tool-badge",children:"TeamDelete"}),(0,$i.jsx)("span",{className:"tool-meta",children:"Deleting current team"})]})}var Ji=v(y(),1);function Yy({input:e}){let t="";switch(e.type){case"message":t=`Sending message to ${e.recipient}: ${e.summary||e.content?.slice(0,50)||""}`;break;case"broadcast":t=`Broadcasting to all teammates: ${e.summary||e.content?.slice(0,50)||""}`;break;case"shutdown_request":t=`Requesting shutdown for ${e.recipient}`;break;case"shutdown_response":t=`Responding to shutdown request: ${e.approve?"approved":"rejected"}`;break;case"plan_approval_response":t=`Responding to plan approval: ${e.approve?"approved":"rejected"}`;break;default:t=`Sending message (${e.type})`}return(0,Ji.jsxs)("div",{className:"tool-use-detail",children:[(0,Ji.jsx)("span",{className:"tool-badge",children:"SendMessage"}),(0,Ji.jsx)("span",{className:"tool-meta",children:t})]})}var Pi=v(y(),1);function ZT(e){let t=!1,n=!1;for(let l of Object.values(e))for(let a of l)a==="__tool_result__"?t=!0:n=!0;return{hasToolResult:t,hasInputFields:n}}function Qy({input:e}){let t=e.action==="archive"?"Archiving":"Unarchiving",n=e.archiveToolUseInputFields??{},l=Object.keys(n).length,{hasToolResult:a,hasInputFields:s}=ZT(n),i="tool result(s)";return a&&s?i="tool result(s) and input field(s)":s&&(i="input field(s)"),(0,Pi.jsxs)("div",{className:"tool-use-detail",children:[(0,Pi.jsx)("span",{className:"tool-badge",children:"MessageArchiving"}),(0,Pi.jsxs)("span",{className:"tool-meta",children:[t," ",i," for ",l," tool use(s)"]})]})}var jy=v($(),1),pn=v(y(),1),Ju=120;function Zy({input:e}){let[t,n]=(0,jy.useState)(!1),{action:l,key:a,summary:s,content:i}=e,o=l==="write"?"write":l==="read"?"read":l==="list"?"list":"delete",u=typeof i=="string"&&i.length>0,f=u&&i.length>Ju?i.substring(0,Ju)+"...":i,r=u&&(t||i.length<=Ju),d=u&&i.length>Ju;return(0,pn.jsxs)("div",{className:"tool-use-detail",children:[(0,pn.jsx)("span",{className:"tool-badge",children:"Memo"}),(0,pn.jsx)("span",{className:"tool-badge memo-action-badge",children:o}),a&&(0,pn.jsx)("span",{className:"file-path",children:a}),s&&(0,pn.jsx)("span",{className:"tool-meta",children:s}),r&&(0,pn.jsx)("div",{className:"tool-input memo-content-detail",children:(0,pn.jsx)("code",{children:t?i:f})}),d&&(0,pn.jsx)("span",{className:"tool-meta detail-toggle",onClick:()=>n(!t),style:{cursor:"pointer"},children:t?"collapse details":"details"})]})}var Xy=v($(),1),rs=v(y(),1);function Nd({input:e,isLoad:t}){let n=t?(e?.toolNames??[]).join(", "):e?.toolName??"",l=e?.arguments,a=!t&&l&&Object.keys(l).length>0,[s,i]=(0,Xy.useState)(!1);return(0,rs.jsxs)("div",{className:"tool-use-detail",children:[(0,rs.jsx)("span",{className:"tool-badge",children:t?"LoadTool":"ProxyToolCall"}),(0,rs.jsx)("span",{className:"tool-meta",children:n}),a&&(0,rs.jsx)("div",{className:"tool-input",onClick:()=>i(!s),style:{cursor:"pointer"},children:s?JSON.stringify(l,null,2):JSON.stringify(l)})]})}var tr=v($(),1),Md=v(fb(),1),yb=v(vb(),1),ia=v(y(),1);Md.default.registerLanguage("javascript",yb.default);function bb({input:e}){let t=e?.code??"",n=t.split(`
72
- `),l=n.length>1,[a,s]=(0,tr.useState)(!1),i=a||!l?t:n[0],o=(0,tr.useMemo)(()=>{try{return Md.default.highlight(i,{language:"javascript"}).value}catch{return null}},[i]);return(0,ia.jsxs)("div",{className:"tool-use-detail",children:[(0,ia.jsx)("span",{className:"tool-badge",children:"Code"}),(0,ia.jsx)("pre",{className:"command-block",onClick:()=>l&&s(!a),style:{cursor:l?"pointer":"default"},children:o!==null?(0,ia.jsx)("code",{className:"hljs language-javascript",dangerouslySetInnerHTML:{__html:l&&!a?`${o} \u2026`:o}}):(0,ia.jsx)("code",{children:l&&!a?`${n[0]} \u2026`:t})})]})}var L=v(y(),1);function Nb({message:e,pendingUserResponses:t,sendUserResponse:n}){let{toolName:l,toolInputRaw:a,toolInput:s,toolUseId:i,isRemote:o,isInProgress:u,isProxyCall:f}=e.metadata||{},[r,d]=(0,Sb.useState)(!1),c=o?`\u2601 ${l}`:l,p=f?(0,L.jsx)("span",{className:"tool-proxy-prefix",title:"via ProxyTool",children:"<>"}):null,b=u?(0,L.jsx)("span",{className:"tool-status-loading",title:"executing"}):null,S=()=>{switch(l){case"AskUserQuestion":{let m=i?t.get(i):void 0;if(m){let g=m.data;return(0,L.jsx)(Ry,{questions:g?.questions||[],onSubmit:h=>n(i,{answers:h}),onCancel:()=>n(i,{cancelled:!0})})}return(0,L.jsx)(_y,{input:T})}case"Read":return(0,L.jsx)(ny,{input:T});case"Edit":return(0,L.jsx)(ly,{input:T});case"Write":return(0,L.jsx)(ay,{input:T});case"Bash":return(0,L.jsx)(sy,{input:T});case"Grep":return(0,L.jsx)(iy,{input:T});case"Glob":return(0,L.jsx)(oy,{input:T});case"LS":return(0,L.jsx)(uy,{input:T});case"Agent":return(0,L.jsx)(cy,{input:T});case"LSP":return(0,L.jsx)(fy,{input:T});case"Cwd":return(0,L.jsx)(dy,{input:T});case"TaskOutput":return(0,L.jsx)(my,{input:T});case"PowerShell":return(0,L.jsx)(gy,{input:T});case"ToolLoader":return(0,L.jsx)(hy,{input:T});case"ToolUnLoader":return(0,L.jsx)(vy,{input:T});case"NotebookEdit":return(0,L.jsx)(yy,{input:T});case"WebSearch":return(0,L.jsx)(by,{input:T});case"WebFetch":return(0,L.jsx)(Sy,{input:T});case"TaskStop":return(0,L.jsx)(Ny,{input:T});case"TodoWrite":return(0,L.jsx)(Ty,{input:T});case"Think":return(0,L.jsx)(Ey,{input:T});case"EnterPlanMode":return(i?t.get(i):void 0)?(0,L.jsx)(Ay,{onApprove:g=>n(i,{approved:g})}):(0,L.jsx)(ky,{input:T});case"ExitPlanMode":{let m=i?t.get(i):void 0;if(m){let g=m.data;return(0,L.jsx)(Oy,{plan:g?.plan||null,planFilePath:g?.planFilePath,onApprove:h=>n(i,{approved:!0,manualApproval:h,cancelled:!1}),onReject:()=>n(i,{approved:!1,manualApproval:!1,cancelled:!0})})}return(0,L.jsx)(My,{input:T})}case"EnterWorktreeTool":return(0,L.jsx)(wy,{input:T});case"ExitWorktreeTool":return(0,L.jsx)(zy,{input:T});case"SlashCommand":return(0,L.jsx)(Uy,{input:T});case"Skill":return(0,L.jsx)(Dy,{input:T});case"CronCreate":return(0,L.jsx)(Ly,{input:T});case"CronDelete":return(0,L.jsx)(By,{input:T});case"CronList":return(0,L.jsx)(Hy,{input:T});case"TeamCreate":return(0,L.jsx)(qy,{input:T});case"TeamDelete":return(0,L.jsx)(Gy,{input:T});case"SendMessage":return(0,L.jsx)(Yy,{input:T});case"MessageArchiving":return(0,L.jsx)(Qy,{input:T});case"Memo":return(0,L.jsx)(Zy,{input:T});case"ProxyToolLoad":return(0,L.jsx)(Nd,{input:T,isLoad:!0});case"ProxyToolCall":return(0,L.jsx)(Nd,{input:T,isLoad:!1});case"codemode":return(0,L.jsx)(bb,{input:T});default:return(0,L.jsxs)("div",{className:"tool-use-detail",children:[(0,L.jsx)("span",{className:"tool-badge",children:l}),s&&(0,L.jsx)("div",{className:"tool-input",onClick:()=>d(!r),style:{cursor:"pointer"},children:r?s:s.length>100?s.substring(0,100)+"...":s})]})}};if(!a)return(0,L.jsxs)("div",{className:"message-item message-tool-use",children:[(0,L.jsxs)("div",{children:[b,(0,L.jsx)("span",{className:"tool-name",children:c||e.content})]}),s&&(0,L.jsx)("div",{className:"tool-input",onClick:()=>d(!r),style:{cursor:"pointer"},children:r?s:s.length>100?s.substring(0,100)+"...":s})]});let T=a;if(l&&l.startsWith("mcp_")){let m=(0,L.jsx)(py,{input:T,displayName:e.metadata?.toolDisplayName||l});return(0,L.jsxs)("div",{className:`message-item message-tool-use${o?" remote":""}`,children:[b,f?(0,L.jsxs)("span",{className:"tool-proxy-row",children:[p,m]}):m]})}return(0,L.jsxs)("div",{className:`message-item message-tool-use${o?" remote":""}`,children:[b,f?(0,L.jsxs)("span",{className:"tool-proxy-row",children:[p,S()]}):S()]})}var ur=v($(),1);var Tb=v($(),1),At=v(y(),1);function Eb({data:e}){let[t,n]=(0,Tb.useState)(!1);if(e.type==="image")return(0,At.jsx)("div",{className:"tool-result-detail tool-result-read",children:(0,At.jsx)("div",{className:"result-header",children:"Read image"})});if(e.type==="notebook"){let o=e.file?.cells?.length||0;return(0,At.jsx)("div",{className:"tool-result-detail tool-result-read",children:(0,At.jsxs)("div",{className:"result-header",children:["Read ",o," cells"]})})}let l=e.file;if(!l)return null;let a=l.content.split(`
71
+ `).length:0;return(0,is.jsxs)("div",{className:"tool-use-detail",children:[(0,is.jsx)("span",{className:"tool-badge",children:"Write"}),(0,is.jsx)("span",{className:"file-path",children:e.file_path}),(0,is.jsxs)("span",{className:"tool-meta",children:["(",t," lines)"]})]})}var ta=v(y(),1);function sy({input:e}){return(0,ta.jsxs)("div",{className:"tool-use-detail",children:[(0,ta.jsx)("span",{className:"tool-badge",children:"Bash"}),e.run_in_background&&(0,ta.jsx)("span",{className:"tool-meta",children:"(background)"}),(0,ta.jsx)("pre",{className:"command-block",children:(0,ta.jsx)("code",{children:e.command})})]})}var Qn=v(y(),1);function iy({input:e}){return(0,Qn.jsxs)("div",{className:"tool-use-detail",children:[(0,Qn.jsx)("span",{className:"tool-badge",children:"Grep"}),(0,Qn.jsxs)("code",{className:"pattern-text",children:["/",e.pattern,"/"]}),e.path&&(0,Qn.jsxs)("span",{className:"tool-meta",children:["in ",e.path]}),e.glob&&(0,Qn.jsxs)("span",{className:"tool-meta",children:["(",e.glob,")"]}),e.type&&(0,Qn.jsxs)("span",{className:"tool-meta",children:["type: ",e.type]}),e.output_mode&&(0,Qn.jsxs)("span",{className:"tool-meta",children:["[",e.output_mode,"]"]})]})}var os=v(y(),1);function oy({input:e}){return(0,os.jsxs)("div",{className:"tool-use-detail",children:[(0,os.jsx)("span",{className:"tool-badge",children:"Glob"}),(0,os.jsx)("code",{className:"pattern-text",children:e.pattern}),e.path&&(0,os.jsxs)("span",{className:"tool-meta",children:["in ",e.path]})]})}var Ai=v(y(),1);function uy({input:e}){return(0,Ai.jsxs)("div",{className:"tool-use-detail",children:[(0,Ai.jsx)("span",{className:"tool-badge",children:"LS"}),(0,Ai.jsx)("span",{className:"file-path",children:e.path||"."})]})}var ry=v($(),1),jn=v(y(),1),$u=120;function cy({input:e}){let[t,n]=(0,ry.useState)(!1),{description:l,prompt:a,subagent_type:s,model_name:i,resume:o,run_in_background:u,name:f,team_name:r,mode:d,isolation:c}=e,p=typeof a=="string"&&a.length>0,b=p&&a.length>$u?a.substring(0,$u)+"...":a,S=p&&(t||a.length<=$u),T=p&&a.length>$u,m=[];return s&&m.push(`type: ${s}`),i&&m.push(`model: ${i}`),o&&m.push(`resume: ${o}`),u&&m.push("background"),r&&f&&m.push(`team: ${r}/${f}`),d&&m.push(`mode: ${d}`),c&&m.push(`isolation: ${c}`),(0,jn.jsxs)("div",{className:"tool-use-detail",children:[(0,jn.jsx)("span",{className:"tool-badge",children:"Agent"}),l&&(0,jn.jsx)("span",{className:"tool-description",children:l}),m.length>0&&(0,jn.jsxs)("span",{className:"tool-meta",children:["(",m.join(", "),")"]}),S&&(0,jn.jsx)("div",{className:"tool-input agent-prompt-detail",children:(0,jn.jsx)("code",{children:t?a:b})}),T&&(0,jn.jsx)("span",{className:"tool-meta detail-toggle",onClick:()=>n(!t),style:{cursor:"pointer"},children:t?"collapse details":"details"})]})}var Tl=v(y(),1);function fy({input:e}){return(0,Tl.jsxs)("div",{className:"tool-use-detail",children:[(0,Tl.jsx)("span",{className:"tool-badge",children:"LSP"}),(0,Tl.jsx)("span",{className:"tool-meta",children:e.operation}),e.filePath&&(0,Tl.jsx)("span",{className:"file-path",children:e.filePath}),e.line!==void 0&&(0,Tl.jsxs)("span",{className:"tool-meta",children:[":",e.line+1,e.character!==void 0?`:${e.character+1}`:""]}),e.query&&(0,Tl.jsx)("code",{className:"pattern-text",children:e.query})]})}var Sd=v(y(),1);function dy({}){return(0,Sd.jsx)("div",{className:"tool-use-detail",children:(0,Sd.jsx)("span",{className:"tool-badge",children:"Cwd"})})}var Mi=v(y(),1);function py({input:e,displayName:t}){let l=Object.entries(e||{}).map(([a,s])=>`${a}: ${JSON.stringify(s)}`).join(", ");return(0,Mi.jsxs)("div",{className:"tool-use-detail tool-use-mcp",children:[(0,Mi.jsx)("span",{className:"tool-badge",children:t}),l&&(0,Mi.jsxs)("span",{className:"tool-meta mcp-input-summary",children:["(",l,")"]})]})}var Ci=v(y(),1);function my({input:e}){let t=e.task_id.startsWith("a"),n=e.block!==!1?`Reading ${t?"Task":"shell"} output (blocking until complete${e.timeout?` timeout ${e.timeout}`:""})`:`Reading ${t?"Task":"shell"} output (non-blocking)`;return(0,Ci.jsxs)("div",{className:"tool-use-detail",children:[(0,Ci.jsx)("span",{className:"tool-badge",children:t?"TaskOutput":"ShellOutput"}),(0,Ci.jsxs)("span",{className:"tool-meta",children:[n," (ID: ",e.task_id,")"]})]})}var na=v(y(),1);function gy({input:e}){return(0,na.jsxs)("div",{className:"tool-use-detail",children:[(0,na.jsx)("span",{className:"tool-badge",children:"PowerShell"}),e.run_in_background&&(0,na.jsx)("span",{className:"tool-meta",children:"(background)"}),(0,na.jsx)("pre",{className:"command-block",children:(0,na.jsx)("code",{children:e.command})})]})}var Oi=v(y(),1);function hy({input:e}){let t=e.toolNames||[];return(0,Oi.jsxs)("div",{className:"tool-use-detail",children:[(0,Oi.jsx)("span",{className:"tool-badge",children:"ToolLoader"}),(0,Oi.jsxs)("span",{className:"tool-meta",children:["Loading tool",t.length>1?"s":"",": ",t.join(", ")]})]})}var wi=v(y(),1);function vy({input:e}){let t=e.toolNames||[];return(0,wi.jsxs)("div",{className:"tool-use-detail",children:[(0,wi.jsx)("span",{className:"tool-badge",children:"ToolUnLoader"}),(0,wi.jsxs)("span",{className:"tool-meta",children:["Unloading tool",t.length>1?"s":"",": ",t.join(", ")]})]})}var la=v(y(),1);function yy({input:e}){return(0,la.jsxs)("div",{className:"tool-use-detail",children:[(0,la.jsx)("span",{className:"tool-badge",children:"NotebookEdit"}),(0,la.jsxs)("span",{className:"tool-meta",children:[e.notebook_path," (cell ",e.cell_number,", ",e.edit_mode||"replace",")"]}),(0,la.jsx)("pre",{className:"command-block",children:(0,la.jsxs)("code",{children:[e.new_source.slice(0,200),e.new_source.length>200?"...":""]})})]})}var zi=v(y(),1);function by({input:e}){return(0,zi.jsxs)("div",{className:"tool-use-detail",children:[(0,zi.jsx)("span",{className:"tool-badge",children:"WebSearch"}),(0,zi.jsx)("span",{className:"tool-meta",children:e.query})]})}var us=v(y(),1);function Sy({input:e}){return(0,us.jsxs)("div",{className:"tool-use-detail",children:[(0,us.jsx)("span",{className:"tool-badge",children:"WebFetch"}),(0,us.jsx)("span",{className:"tool-meta",children:e.url}),(0,us.jsx)("div",{className:"tool-input",children:e.prompt})]})}var Ui=v(y(),1);function Ny({input:e}){return(0,Ui.jsxs)("div",{className:"tool-use-detail",children:[(0,Ui.jsx)("span",{className:"tool-badge",children:"TaskStop"}),(0,Ui.jsxs)("span",{className:"tool-meta",children:["Stop task: ",e.task_id]})]})}var Di=v(y(),1);function Ty({input:e}){let t=e.todos?.find(n=>n.status==="in_progress");return(0,Di.jsxs)("div",{className:"tool-use-detail",children:[(0,Di.jsx)("span",{className:"tool-badge",children:"TodoWrite"}),(0,Di.jsx)("span",{className:"tool-meta",children:t?`${t.activeForm}\u2026`:"update todo"})]})}var Li=v(y(),1);function Ey({input:e}){return(0,Li.jsxs)("div",{className:"tool-use-detail",children:[(0,Li.jsx)("span",{className:"tool-badge",children:"Think"}),(0,Li.jsx)("div",{className:"tool-input",children:e.thought})]})}var Bi=v(y(),1);function _y({input:e}){let t=e.questions?.length||0,n=e.questions?.reduce((l,a)=>l+(a.options?.length||0),0)||0;return(0,Bi.jsxs)("div",{className:"tool-use-detail",children:[(0,Bi.jsx)("span",{className:"tool-badge",children:"AskUserQuestion"}),(0,Bi.jsxs)("span",{className:"tool-meta",children:["Asking ",t," question",t>1?"s":""," with ",n," total options"]})]})}var We=v($(),1),be=v(y(),1);function Ry({questions:e,onSubmit:t,onCancel:n}){let[l,a]=(0,We.useState)(0),[s,i]=(0,We.useState)({}),[o,u]=(0,We.useState)({}),[f,r]=(0,We.useState)({}),[d,c]=(0,We.useState)({}),[p,b]=(0,We.useState)(!1),S=e[l],T=l===e.length-1,m=(0,We.useCallback)(w=>(s[w]?.length??0)>0||(o[w]?.length??0)>0,[s,o]),g=(0,We.useCallback)(w=>{let B=S.options[w];i(M=>{let E=M[l]||[];if(S.multiSelect){let q=E.includes(B.label)?E.filter(ee=>ee!==B.label):[...E,B.label];return{...M,[l]:q}}else return{...M,[l]:[B.label]}}),r(M=>({...M,[l]:!1}))},[l,S]),h=(0,We.useCallback)(()=>{i(w=>{let B=w[l]||[];if(S.multiSelect){let E=B.includes("Custom answer")?B:[...B,"Custom answer"];return{...w,[l]:E}}else return{...w,[l]:["Custom answer"]}}),r(w=>({...w,[l]:!0})),c(w=>({...w,[l]:w[l]||o[l]||""}))},[l,S,o]),N=(0,We.useCallback)(()=>{let w=d[l]?.trim()||"";w&&(u(B=>({...B,[l]:w})),r(B=>({...B,[l]:!1})))},[l,d]),x=(0,We.useCallback)(()=>{r(w=>({...w,[l]:!1})),i(w=>{let M=(w[l]||[]).filter(E=>E!=="Custom answer");return{...w,[l]:M}}),c(w=>({...w,[l]:""})),u(w=>{let B={...w};return delete B[l],B})},[l]),U=(0,We.useCallback)(()=>{let w={};e.forEach((B,M)=>{let E=o[M],z=s[M]||[];E?w[B.question]=E:z.length>0?w[B.question]=z.filter(q=>q!=="Custom answer").join(", "):w[B.question]="No answer provided"}),b(!0),t(w)},[e,s,o,t]),k=(0,We.useCallback)(()=>{b(!0),n()},[n]),O=(0,We.useCallback)(()=>{l<e.length-1&&a(w=>w+1)},[l,e.length]),R=(0,We.useCallback)(()=>{l>0&&a(w=>w-1)},[l]),A=s[l]?.includes("Custom answer")||!1,H=A&&f[l],j=o[l]!==void 0;return(0,be.jsxs)("div",{className:"ask-user-question-form",children:[(0,be.jsx)("div",{className:"ask-user-question-header",children:e.map((w,B)=>(0,be.jsx)("span",{className:`ask-user-question-step ${m(B)?"answered":""} ${B===l?"active":""}`,children:w.header},B))}),(0,be.jsx)("div",{className:"ask-user-question-title",children:S.question}),S.multiSelect&&(0,be.jsx)("div",{className:"ask-user-question-hint",children:"You can select multiple options"}),(0,be.jsxs)("div",{className:"ask-user-question-options",children:[S.options.map((w,B)=>{let M=(s[l]||[]).includes(w.label),E=S.multiSelect?"checkbox":"radio";return(0,be.jsxs)("label",{className:`ask-user-question-option ${M?"selected":""}`,children:[(0,be.jsx)("input",{type:E,name:`question-${l}`,checked:M,onChange:()=>g(B),disabled:p}),(0,be.jsx)("span",{className:"ask-user-question-option-label",children:w.label}),(0,be.jsx)("span",{className:"ask-user-question-option-description",children:w.description})]},B)}),(0,be.jsxs)("label",{className:`ask-user-question-option ${A?"selected":""}`,children:[(0,be.jsx)("input",{type:S.multiSelect?"checkbox":"radio",name:`question-${l}`,checked:A,onChange:h,disabled:p}),(0,be.jsx)("span",{className:"ask-user-question-option-label",children:"Type something"}),j&&!H&&(0,be.jsxs)("span",{className:"ask-user-question-option-description",children:["Custom: ",o[l]]})]}),H&&(0,be.jsxs)("div",{className:"ask-user-question-custom-inline",children:[(0,be.jsx)("input",{type:"text",className:"ask-user-question-custom-input",value:d[l]||"",onChange:w=>c(B=>({...B,[l]:w.target.value})),placeholder:"Type your answer...",disabled:p,autoFocus:!0}),(0,be.jsxs)("div",{className:"ask-user-question-custom-inline-actions",children:[(0,be.jsx)("button",{onClick:N,disabled:p||!d[l]?.trim(),children:"OK"}),(0,be.jsx)("button",{onClick:x,disabled:p,children:"Cancel"})]})]})]}),(0,be.jsxs)("div",{className:"ask-user-question-actions",children:[(0,be.jsx)("button",{onClick:R,disabled:l===0||p,children:"Previous"}),T?(0,be.jsx)("button",{onClick:U,disabled:p,children:"Submit"}):(0,be.jsx)("button",{onClick:O,disabled:p,children:"Next"}),(0,be.jsx)("button",{onClick:k,disabled:p,children:"Cancel"})]})]})}var Hi=v(y(),1);function ky(e){return(0,Hi.jsxs)("div",{className:"tool-use-detail",children:[(0,Hi.jsx)("span",{className:"tool-badge",children:"EnterPlanMode"}),(0,Hi.jsx)("span",{className:"tool-meta",children:"Entering plan mode"})]})}var xy=v($(),1),El=v(y(),1);function Ay({onApprove:e}){let[t,n]=(0,xy.useState)(!1);return(0,El.jsxs)("div",{className:"plan-mode-inline-form",children:[(0,El.jsx)("div",{className:"plan-mode-inline-title",children:"Enter plan mode?"}),(0,El.jsx)("div",{className:"plan-mode-inline-description",children:"Plan mode will ask you to approve a plan before making changes."}),(0,El.jsxs)("div",{className:"plan-mode-inline-actions",children:[(0,El.jsx)("button",{onClick:()=>{n(!0),e(!0)},disabled:t,children:"Yes, enter plan mode"}),(0,El.jsx)("button",{onClick:()=>{n(!0),e(!1)},disabled:t,children:"No, stay in current mode"})]})]})}var qi=v(y(),1);function My({input:e}){return(0,qi.jsxs)("div",{className:"tool-use-detail",children:[(0,qi.jsx)("span",{className:"tool-badge",children:"ExitPlanMode"}),(0,qi.jsx)("span",{className:"tool-meta",children:"Presenting plan to user for approval"})]})}var Cy=v($(),1),Ie=v(y(),1);function Oy({plan:e,planFilePath:t,onApprove:n,onReject:l}){let[a,s]=(0,Cy.useState)(!1);return e?(0,Ie.jsxs)("div",{className:"plan-mode-inline-form",children:[(0,Ie.jsx)("div",{className:"plan-mode-inline-title",children:"Approve plan to exit plan mode"}),(0,Ie.jsx)("div",{className:"plan-mode-inline-plan",children:(0,Ie.jsx)("pre",{children:e})}),t&&(0,Ie.jsxs)("div",{className:"plan-mode-inline-path",children:["Plan file: ",t]}),(0,Ie.jsxs)("div",{className:"plan-mode-inline-actions",children:[(0,Ie.jsx)("button",{onClick:()=>{s(!0),n(!1)},disabled:a,children:"Auto-accept edits"}),(0,Ie.jsx)("button",{onClick:()=>{s(!0),n(!0)},disabled:a,children:"Manual approval"}),(0,Ie.jsx)("button",{onClick:()=>{s(!0),l()},disabled:a,children:"Reject"})]})]}):(0,Ie.jsxs)("div",{className:"plan-mode-inline-form",children:[(0,Ie.jsx)("div",{className:"plan-mode-inline-title",children:"No plan found"}),(0,Ie.jsx)("div",{className:"plan-mode-inline-description",children:"There is no plan to approve. Do you want to exit plan mode?"}),(0,Ie.jsxs)("div",{className:"plan-mode-inline-actions",children:[(0,Ie.jsx)("button",{onClick:()=>{s(!0),n(!1)},disabled:a,children:"Yes, exit plan mode"}),(0,Ie.jsx)("button",{onClick:()=>{s(!0),l()},disabled:a,children:"No, keep planning"})]})]})}var Gi=v(y(),1);function wy({input:e}){return(0,Gi.jsxs)("div",{className:"tool-use-detail",children:[(0,Gi.jsx)("span",{className:"tool-badge",children:"EnterWorktree"}),(0,Gi.jsx)("span",{className:"tool-meta",children:e.name?`Creating worktree: ${e.name}`:"Creating worktree"})]})}var Yi=v(y(),1);function zy({input:e}){return(0,Yi.jsxs)("div",{className:"tool-use-detail",children:[(0,Yi.jsx)("span",{className:"tool-badge",children:"ExitWorktree"}),(0,Yi.jsx)("span",{className:"tool-meta",children:e.action==="remove"?"Exiting and removing worktree":"Exiting worktree"})]})}var Qi=v(y(),1);function Uy({input:e}){return(0,Qi.jsxs)("div",{className:"tool-use-detail",children:[(0,Qi.jsx)("span",{className:"tool-badge",children:"SlashCommand"}),(0,Qi.jsxs)("span",{className:"tool-meta",children:["Executing ",e.command]})]})}var ji=v(y(),1);function Dy({input:e}){return(0,ji.jsxs)("div",{className:"tool-use-detail",children:[(0,ji.jsx)("span",{className:"tool-badge",children:"Skill"}),(0,ji.jsx)("span",{className:"tool-meta",children:e.skill})]})}var Zi=v(y(),1);function Ly({input:e}){let t=e.prompt?.length>60?e.prompt.slice(0,60)+"...":e.prompt;return(0,Zi.jsxs)("div",{className:"tool-use-detail",children:[(0,Zi.jsx)("span",{className:"tool-badge",children:"CronCreate"}),(0,Zi.jsxs)("span",{className:"tool-meta",children:[e.cron,": ",t]})]})}var Xi=v(y(),1);function By({input:e}){return(0,Xi.jsxs)("div",{className:"tool-use-detail",children:[(0,Xi.jsx)("span",{className:"tool-badge",children:"CronDelete"}),(0,Xi.jsx)("span",{className:"tool-meta",children:e.id})]})}var Vi=v(y(),1);function Hy(e){return(0,Vi.jsxs)("div",{className:"tool-use-detail",children:[(0,Vi.jsx)("span",{className:"tool-badge",children:"CronList"}),(0,Vi.jsx)("span",{className:"tool-meta",children:"List scheduled cron jobs"})]})}var Ki=v(y(),1);function qy({input:e}){return(0,Ki.jsxs)("div",{className:"tool-use-detail",children:[(0,Ki.jsx)("span",{className:"tool-badge",children:"TeamCreate"}),(0,Ki.jsxs)("span",{className:"tool-meta",children:["Creating team: ",e.team_name]})]})}var $i=v(y(),1);function Gy(e){return(0,$i.jsxs)("div",{className:"tool-use-detail",children:[(0,$i.jsx)("span",{className:"tool-badge",children:"TeamDelete"}),(0,$i.jsx)("span",{className:"tool-meta",children:"Deleting current team"})]})}var Ji=v(y(),1);function Yy({input:e}){let t="";switch(e.type){case"message":t=`Sending message to ${e.recipient}: ${e.summary||e.content?.slice(0,50)||""}`;break;case"broadcast":t=`Broadcasting to all teammates: ${e.summary||e.content?.slice(0,50)||""}`;break;case"shutdown_request":t=`Requesting shutdown for ${e.recipient}`;break;case"shutdown_response":t=`Responding to shutdown request: ${e.approve?"approved":"rejected"}`;break;case"plan_approval_response":t=`Responding to plan approval: ${e.approve?"approved":"rejected"}`;break;default:t=`Sending message (${e.type})`}return(0,Ji.jsxs)("div",{className:"tool-use-detail",children:[(0,Ji.jsx)("span",{className:"tool-badge",children:"SendMessage"}),(0,Ji.jsx)("span",{className:"tool-meta",children:t})]})}var Pi=v(y(),1);function ZT(e){let t=!1,n=!1;for(let l of Object.values(e))for(let a of l)a==="__tool_result__"?t=!0:n=!0;return{hasToolResult:t,hasInputFields:n}}function Qy({input:e}){let t=e.action==="archive"?"Archiving":"Unarchiving",n=e.archiveToolUseInputFields??{},l=Object.keys(n).length,{hasToolResult:a,hasInputFields:s}=ZT(n),i="tool result(s)";return a&&s?i="tool result(s) and input field(s)":s&&(i="input field(s)"),(0,Pi.jsxs)("div",{className:"tool-use-detail",children:[(0,Pi.jsx)("span",{className:"tool-badge",children:"MessageArchiving"}),(0,Pi.jsxs)("span",{className:"tool-meta",children:[t," ",i," for ",l," tool use(s)"]})]})}var jy=v($(),1),pn=v(y(),1),Ju=120;function Zy({input:e}){let[t,n]=(0,jy.useState)(!1),{action:l,key:a,summary:s,content:i}=e,o=l==="write"?"write":l==="read"?"read":l==="list"?"list":"delete",u=typeof i=="string"&&i.length>0,f=u&&i.length>Ju?i.substring(0,Ju)+"...":i,r=u&&(t||i.length<=Ju),d=u&&i.length>Ju;return(0,pn.jsxs)("div",{className:"tool-use-detail",children:[(0,pn.jsx)("span",{className:"tool-badge",children:"Memo"}),(0,pn.jsx)("span",{className:"tool-badge memo-action-badge",children:o}),a&&(0,pn.jsx)("span",{className:"file-path",children:a}),s&&(0,pn.jsx)("span",{className:"tool-meta",children:s}),r&&(0,pn.jsx)("div",{className:"tool-input memo-content-detail",children:(0,pn.jsx)("code",{children:t?i:f})}),d&&(0,pn.jsx)("span",{className:"tool-meta detail-toggle",onClick:()=>n(!t),style:{cursor:"pointer"},children:t?"collapse details":"details"})]})}var Xy=v($(),1),rs=v(y(),1);function Nd({input:e,isLoad:t}){let n=e?.toolName??"",l=e?.arguments,a=!t&&l&&Object.keys(l).length>0,[s,i]=(0,Xy.useState)(!1);return(0,rs.jsxs)("div",{className:"tool-use-detail",children:[(0,rs.jsx)("span",{className:"tool-badge",children:t?"LoadTool":"ProxyToolCall"}),(0,rs.jsx)("span",{className:"tool-meta",children:n}),a&&(0,rs.jsx)("div",{className:"tool-input",onClick:()=>i(!s),style:{cursor:"pointer"},children:s?JSON.stringify(l,null,2):JSON.stringify(l)})]})}var tr=v($(),1),Md=v(fb(),1),yb=v(vb(),1),ia=v(y(),1);Md.default.registerLanguage("javascript",yb.default);function bb({input:e}){let t=e?.code??"",n=t.split(`
72
+ `),l=n.length>1,[a,s]=(0,tr.useState)(!1),i=a||!l?t:n[0],o=(0,tr.useMemo)(()=>{try{return Md.default.highlight(i,{language:"javascript"}).value}catch{return null}},[i]);return(0,ia.jsxs)("div",{className:"tool-use-detail",children:[(0,ia.jsx)("span",{className:"tool-badge",children:"Code"}),(0,ia.jsx)("pre",{className:"command-block",onClick:()=>l&&s(!a),style:{cursor:l?"pointer":"default"},children:o!==null?(0,ia.jsx)("code",{className:"hljs language-javascript",dangerouslySetInnerHTML:{__html:l&&!a?`${o} \u2026`:o}}):(0,ia.jsx)("code",{children:l&&!a?`${n[0]} \u2026`:t})})]})}var L=v(y(),1);function Nb({message:e,pendingUserResponses:t,sendUserResponse:n}){let{toolName:l,toolInputRaw:a,toolInput:s,toolUseId:i,isRemote:o,isInProgress:u,isProxyCall:f}=e.metadata||{},[r,d]=(0,Sb.useState)(!1),c=o?`\u2601 ${l}`:l,p=f?(0,L.jsx)("span",{className:"tool-proxy-prefix",title:"via ProxyTool",children:"<>"}):null,b=u?(0,L.jsx)("span",{className:"tool-status-loading",title:"executing"}):null,S=()=>{switch(l){case"AskUserQuestion":{let m=i?t.get(i):void 0;if(m){let g=m.data;return(0,L.jsx)(Ry,{questions:g?.questions||[],onSubmit:h=>n(i,{answers:h}),onCancel:()=>n(i,{cancelled:!0})})}return(0,L.jsx)(_y,{input:T})}case"Read":return(0,L.jsx)(ny,{input:T});case"Edit":return(0,L.jsx)(ly,{input:T});case"Write":return(0,L.jsx)(ay,{input:T});case"Bash":return(0,L.jsx)(sy,{input:T});case"Grep":return(0,L.jsx)(iy,{input:T});case"Glob":return(0,L.jsx)(oy,{input:T});case"LS":return(0,L.jsx)(uy,{input:T});case"Agent":return(0,L.jsx)(cy,{input:T});case"LSP":return(0,L.jsx)(fy,{input:T});case"Cwd":return(0,L.jsx)(dy,{input:T});case"TaskOutput":return(0,L.jsx)(my,{input:T});case"PowerShell":return(0,L.jsx)(gy,{input:T});case"ToolLoader":return(0,L.jsx)(hy,{input:T});case"ToolUnLoader":return(0,L.jsx)(vy,{input:T});case"NotebookEdit":return(0,L.jsx)(yy,{input:T});case"WebSearch":return(0,L.jsx)(by,{input:T});case"WebFetch":return(0,L.jsx)(Sy,{input:T});case"TaskStop":return(0,L.jsx)(Ny,{input:T});case"TodoWrite":return(0,L.jsx)(Ty,{input:T});case"Think":return(0,L.jsx)(Ey,{input:T});case"EnterPlanMode":return(i?t.get(i):void 0)?(0,L.jsx)(Ay,{onApprove:g=>n(i,{approved:g})}):(0,L.jsx)(ky,{input:T});case"ExitPlanMode":{let m=i?t.get(i):void 0;if(m){let g=m.data;return(0,L.jsx)(Oy,{plan:g?.plan||null,planFilePath:g?.planFilePath,onApprove:h=>n(i,{approved:!0,manualApproval:h,cancelled:!1}),onReject:()=>n(i,{approved:!1,manualApproval:!1,cancelled:!0})})}return(0,L.jsx)(My,{input:T})}case"EnterWorktreeTool":return(0,L.jsx)(wy,{input:T});case"ExitWorktreeTool":return(0,L.jsx)(zy,{input:T});case"SlashCommand":return(0,L.jsx)(Uy,{input:T});case"Skill":return(0,L.jsx)(Dy,{input:T});case"CronCreate":return(0,L.jsx)(Ly,{input:T});case"CronDelete":return(0,L.jsx)(By,{input:T});case"CronList":return(0,L.jsx)(Hy,{input:T});case"TeamCreate":return(0,L.jsx)(qy,{input:T});case"TeamDelete":return(0,L.jsx)(Gy,{input:T});case"SendMessage":return(0,L.jsx)(Yy,{input:T});case"MessageArchiving":return(0,L.jsx)(Qy,{input:T});case"Memo":return(0,L.jsx)(Zy,{input:T});case"ProxyToolLoad":return(0,L.jsx)(Nd,{input:T,isLoad:!0});case"ProxyToolCall":return(0,L.jsx)(Nd,{input:T,isLoad:!1});case"CodeMode":return(0,L.jsx)(bb,{input:T});default:return(0,L.jsxs)("div",{className:"tool-use-detail",children:[(0,L.jsx)("span",{className:"tool-badge",children:l}),s&&(0,L.jsx)("div",{className:"tool-input",onClick:()=>d(!r),style:{cursor:"pointer"},children:r?s:s.length>100?s.substring(0,100)+"...":s})]})}};if(!a)return(0,L.jsxs)("div",{className:"message-item message-tool-use",children:[(0,L.jsxs)("div",{children:[b,(0,L.jsx)("span",{className:"tool-name",children:c||e.content})]}),s&&(0,L.jsx)("div",{className:"tool-input",onClick:()=>d(!r),style:{cursor:"pointer"},children:r?s:s.length>100?s.substring(0,100)+"...":s})]});let T=a;if(l&&l.startsWith("mcp_")){let m=(0,L.jsx)(py,{input:T,displayName:e.metadata?.toolDisplayName||l});return(0,L.jsxs)("div",{className:`message-item message-tool-use${o?" remote":""}`,children:[b,f?(0,L.jsxs)("span",{className:"tool-proxy-row",children:[p,m]}):m]})}return(0,L.jsxs)("div",{className:`message-item message-tool-use${o?" remote":""}`,children:[b,f?(0,L.jsxs)("span",{className:"tool-proxy-row",children:[p,S()]}):S()]})}var ur=v($(),1);var Tb=v($(),1),At=v(y(),1);function Eb({data:e}){let[t,n]=(0,Tb.useState)(!1);if(e.type==="image")return(0,At.jsx)("div",{className:"tool-result-detail tool-result-read",children:(0,At.jsx)("div",{className:"result-header",children:"Read image"})});if(e.type==="notebook"){let o=e.file?.cells?.length||0;return(0,At.jsx)("div",{className:"tool-result-detail tool-result-read",children:(0,At.jsxs)("div",{className:"result-header",children:["Read ",o," cells"]})})}let l=e.file;if(!l)return null;let a=l.content.split(`
73
73
  `),s=t?a:a.slice(0,20),i=a.length>20;return(0,At.jsxs)("div",{className:"tool-result-detail tool-result-read",children:[(0,At.jsxs)("div",{className:"result-header",children:[(0,At.jsx)("span",{className:"file-path",children:l.filePath}),(0,At.jsxs)("span",{className:"tool-meta",children:[l.numLines," lines (from ",l.startLine,", total ",l.totalLines,")"]})]}),(0,At.jsx)("pre",{className:"code-block",children:(0,At.jsx)("code",{children:s.join(`
74
74
  `)})}),i&&!t&&(0,At.jsxs)("div",{className:"expand-toggle",onClick:()=>n(!0),children:["... ",a.length-20," more lines (click to expand)"]})]})}var Rb=v($(),1);var _b=v($(),1),mn=v(y(),1);function qE(e,t){let n=t,l=[],a=[...e];for(;a.length>0;){let{code:s,type:i}=a.shift(),o={code:s,type:i,lineNo:n};switch(i){case"context":n++,l.push(o);break;case"add":n++,l.push(o);break;case"remove":{l.push(o);let u=0;for(;a[0]?.type==="remove";){n++;let f=a.shift();l.push({code:f.code,type:f.type,lineNo:n}),u++}n-=u;break}}}return l}function nr({structuredPatch:e,filePath:t}){let n=(0,_b.useMemo)(()=>{let s=[];for(let i=0;i<e.length;i++){let o=e[i];i>0&&s.push({type:"separator"});let u=o.lines.map(r=>r.startsWith("+")?{type:"add",code:" "+r.slice(1)}:r.startsWith("-")?{type:"remove",code:" "+r.slice(1)}:{type:"context",code:r}),f=qE(u,o.oldStart);s.push(...f)}return s},[e]);if(n.length===0)return(0,mn.jsx)("div",{className:"diff-empty",children:"No changes"});let l=Math.max(...n.filter(s=>s.type!=="separator").map(s=>s.lineNo)),a=Math.max(l.toString().length,1);return(0,mn.jsx)("div",{className:"diff-view",children:n.map((s,i)=>{if(s.type==="separator")return(0,mn.jsxs)("div",{className:"diff-line diff-separator",children:[(0,mn.jsx)("span",{className:"diff-line-no",style:{width:`${a+1}ch`}}),(0,mn.jsx)("span",{className:"diff-code",children:"..."})]},i);let o=s;return(0,mn.jsxs)("div",{className:`diff-line diff-${o.type}`,children:[(0,mn.jsx)("span",{className:"diff-line-no",style:{width:`${a+1}ch`},children:o.lineNo.toString().padStart(a)}),(0,mn.jsx)("span",{className:"diff-code",children:o.code})]},i)})})}var gn=v(y(),1);function GE(e){let t=e.split(/[/\\]/);return t[t.length-1]||e}function kb({data:e}){let{numAdditions:t,numRemovals:n}=(0,Rb.useMemo)(()=>{if(!e.structuredPatch||e.structuredPatch.length===0)return{numAdditions:0,numRemovals:0};let i=0,o=0;for(let u of e.structuredPatch)for(let f of u.lines||[])f.startsWith("+")?i++:f.startsWith("-")&&o++;return{numAdditions:i,numRemovals:o}},[e.structuredPatch]),l=GE(e.filePath),a=[];t>0&&a.push(`${t} ${t>1?"additions":"addition"}`),n>0&&a.push(`${n} ${n>1?"removals":"removal"}`);let s=a.length>0?` with ${a.join(" and ")}`:"";return(0,gn.jsxs)("div",{className:"tool-result-detail tool-result-edit",children:[(0,gn.jsx)("div",{className:"result-header",children:(0,gn.jsxs)("span",{className:"result-summary",children:["Updated ",(0,gn.jsx)("span",{className:"file-path",children:l}),s]})}),e.structuredPatch&&e.structuredPatch.length>0?(0,gn.jsx)(nr,{structuredPatch:e.structuredPatch,filePath:e.filePath}):(0,gn.jsxs)("div",{className:"diff-preview-inline",children:[(0,gn.jsxs)("div",{className:"diff-line diff-remove",children:["- ",e.oldString]}),(0,gn.jsxs)("div",{className:"diff-line diff-add",children:["+ ",e.newString]})]})]})}var xb=v($(),1);var ot=v(y(),1);function Ab({data:e}){let[t,n]=(0,xb.useState)(!1);if(e.type==="create"){let l=e.content.split(`
75
75
  `),a=t?l:l.slice(0,10),s=l.length>10;return(0,ot.jsxs)("div",{className:"tool-result-detail tool-result-write",children:[(0,ot.jsxs)("div",{className:"result-header",children:[(0,ot.jsx)("span",{className:"file-path",children:e.filePath}),(0,ot.jsxs)("span",{className:"result-status status-success",children:["Created (",l.length," lines)"]})]}),(0,ot.jsx)("pre",{className:"code-block",children:(0,ot.jsx)("code",{children:a.join(`
@@ -89,13 +89,13 @@ Please report this to https://github.com/markedjs/marked.`,e){let l="<p>An error
89
89
  `):[],d=t?r:r.slice(0,30),c=r.length>30;return(0,rt.jsxs)("div",{className:"tool-result-detail tool-result-taskoutput",children:[(0,rt.jsxs)("div",{className:"result-header",children:[(0,rt.jsxs)("span",{className:`result-status ${i?"status-error":o?"status-success":"status-warn"}`,children:[l?"Task":"Shell"," ",a,e.exit_code!==null&&e.exit_code!==void 0&&` (exit ${e.exit_code})`]}),(0,rt.jsx)("span",{className:"tool-meta",children:e.task_id})]}),s&&(0,rt.jsx)("div",{className:"result-note",children:l?"Task is still running...":"Shell is still running..."}),u&&(0,rt.jsxs)(rt.Fragment,{children:[(0,rt.jsx)("pre",{className:"code-block stdout-block",children:(0,rt.jsx)("code",{children:d.join(`
90
90
  `)})}),c&&!t&&(0,rt.jsxs)("div",{className:"expand-toggle",onClick:()=>n(!0),children:["... ",r.length-30," more lines (click to expand)"]})]}),f&&(0,rt.jsx)("pre",{className:"code-block stderr-block",children:(0,rt.jsx)("code",{children:e.stderr})})]})}var Xb=v($(),1),Oe=v(y(),1);function Vb({data:e}){let[t,n]=(0,Xb.useState)(!1);if(e.run_in_background)return(0,Oe.jsx)("div",{className:"tool-result-detail tool-result-powershell",children:(0,Oe.jsx)("div",{className:"result-header",children:(0,Oe.jsx)("span",{className:"result-status status-info",children:"Running in background"})})});let l=e.stdout&&e.stdout.trim(),a=e.stderr&&e.stderr.trim();if(!l&&!a&&!e.interrupted)return(0,Oe.jsx)("div",{className:"tool-result-detail tool-result-powershell",children:(0,Oe.jsx)("div",{className:"result-header",children:(0,Oe.jsx)("span",{className:"result-status status-success",children:"Done (no output)"})})});let s=l?e.stdout.split(`
91
91
  `):[],i=t?s:s.slice(0,30),o=s.length>30;return(0,Oe.jsxs)("div",{className:"tool-result-detail tool-result-powershell",children:[(0,Oe.jsxs)("div",{className:"result-header",children:[e.interrupted?(0,Oe.jsx)("span",{className:"result-status status-warn",children:"Interrupted"}):(0,Oe.jsx)("span",{className:"result-status status-success",children:"exit 0"}),e.stdoutLines>0&&(0,Oe.jsxs)("span",{className:"tool-meta",children:[e.stdoutLines," lines"]})]}),l&&(0,Oe.jsxs)(Oe.Fragment,{children:[(0,Oe.jsx)("pre",{className:"code-block stdout-block",children:(0,Oe.jsx)("code",{children:i.join(`
92
- `)})}),o&&!t&&(0,Oe.jsxs)("div",{className:"expand-toggle",onClick:()=>n(!0),children:["... ",s.length-30," more lines (click to expand)"]})]}),a&&(0,Oe.jsx)("pre",{className:"code-block stderr-block",children:(0,Oe.jsx)("code",{children:e.stderr})}),e.interrupted&&(0,Oe.jsx)("div",{className:"result-note",children:"Command was aborted before completion"})]})}var lr=v(y(),1);function Kb({data:e}){let t=e.toolNames||[];return(0,lr.jsx)("div",{className:"tool-result-detail tool-result-toolloader",children:(0,lr.jsx)("div",{className:"result-header",children:(0,lr.jsx)("span",{className:"result-status status-success",children:e.message||`Tools loaded: ${t.join(", ")}`})})})}var ar=v(y(),1);function $b({data:e}){let n=e.message?.startsWith("<error>")?"status-error":"status-success";return(0,ar.jsx)("div",{className:"tool-result-detail tool-result-toolunloader",children:(0,ar.jsx)("div",{className:"result-header",children:(0,ar.jsx)("span",{className:`result-status ${n}`,children:e.message||"Tools unloaded"})})})}var yn=v(y(),1);function Jb({data:e}){return e.error?(0,yn.jsx)("div",{className:"tool-result-detail tool-result-notebookedit",children:(0,yn.jsx)("div",{className:"result-header",children:(0,yn.jsx)("span",{className:"result-status status-error",children:e.error})})}):(0,yn.jsxs)("div",{className:"tool-result-detail tool-result-notebookedit",children:[(0,yn.jsx)("div",{className:"result-header",children:(0,yn.jsx)("span",{className:"result-status status-success",children:e.edit_mode==="delete"?`Deleted cell ${e.cell_number}`:`${e.edit_mode==="insert"?"Inserted":"Updated"} cell ${e.cell_number}`})}),(0,yn.jsx)("pre",{className:"code-block",children:(0,yn.jsx)("code",{children:e.new_source})})]})}var Zn=v(y(),1);function Pb({data:e}){return(0,Zn.jsxs)("div",{className:"tool-result-detail tool-result-websearch",children:[(0,Zn.jsx)("div",{className:"result-header",children:(0,Zn.jsxs)("span",{className:"result-status status-success",children:["Found ",e.results.length," ",e.results.length===1?"result":"results"]})}),e.summaryText&&(0,Zn.jsx)("div",{className:"result-summary markdown-body",children:e.summaryText}),e.results.length>0&&(0,Zn.jsx)("ul",{className:"result-list",children:e.results.map((t,n)=>(0,Zn.jsx)("li",{children:(0,Zn.jsx)("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.title})},n))})]})}var Wb=v($(),1),Rl=v(y(),1);function Ib({data:e}){let[t,n]=(0,Wb.useState)(!1),l=e.aiAnalysis||"No content could be analyzed",a=l.length>400,s=t||!a?l:l.slice(0,400)+"...";return(0,Rl.jsxs)("div",{className:"tool-result-detail tool-result-webfetch",children:[(0,Rl.jsxs)("div",{className:"result-header",children:[(0,Rl.jsxs)("span",{className:"result-status status-success",children:["Content ",e.fromCache?"from cache":"fetched"," and analyzed"]}),(0,Rl.jsx)("span",{className:"tool-meta",children:e.url})]}),(0,Rl.jsx)("div",{className:"result-content markdown-body",style:{whiteSpace:"pre-wrap"},children:s}),a&&!t&&(0,Rl.jsx)("div",{className:"expand-toggle",onClick:()=>n(!0),children:"click to expand"})]})}var ds=v(y(),1);function Fb({data:e}){return(0,ds.jsx)("div",{className:"tool-result-detail tool-result-taskstop",children:(0,ds.jsxs)("div",{className:"result-header",children:[(0,ds.jsx)("span",{className:`result-status ${e.stopped?"status-success":"status-error"}`,children:e.message}),(0,ds.jsxs)("span",{className:"tool-meta",children:[e.task_id," (",e.task_type,")"]})]})})}var Xn=v(y(),1);function QE(e){return e==="completed"?"\u2612":"\u2610"}function e0({data:e}){let t=e.todos||[];return t.length===0?(0,Xn.jsx)("div",{className:"tool-result-detail tool-result-todowrite",children:(0,Xn.jsx)("div",{className:"result-header",children:(0,Xn.jsx)("span",{className:"result-status status-info",children:"No todos currently"})})}):(0,Xn.jsx)("div",{className:"tool-result-detail tool-result-todowrite",children:t.map((n,l)=>{let a=n.status==="completed",s=n.status==="in_progress";return(0,Xn.jsxs)("div",{className:"todo-item",children:[(0,Xn.jsx)("span",{className:`todo-checkbox ${a?"completed":""}`,children:QE(n.status)}),(0,Xn.jsx)("span",{className:`todo-content ${a?"completed":""} ${s?"in-progress":""}`,children:n.content})]},l)})})}var ps=v(y(),1);function t0({data:e}){return(0,ps.jsxs)("div",{className:"tool-result-detail tool-result-think",children:[(0,ps.jsx)("div",{className:"result-header",children:(0,ps.jsx)("span",{className:"result-status status-success",children:"Thought logged"})}),(0,ps.jsx)("div",{className:"result-content",children:e.thought})]})}var Fe=v(y(),1);function n0({data:e}){if(e.error)return(0,Fe.jsx)("div",{className:"tool-result-detail tool-result-askuserquestion",children:(0,Fe.jsx)("div",{className:"result-header",children:(0,Fe.jsx)("span",{className:"result-status status-error",children:e.error})})});if(e.cancelled)return(0,Fe.jsx)("div",{className:"tool-result-detail tool-result-askuserquestion",children:(0,Fe.jsx)("div",{className:"result-header",children:(0,Fe.jsx)("span",{className:"result-status status-warn",children:"Question asking was cancelled"})})});let t=Object.entries(e.answers||{});return t.length===0?(0,Fe.jsx)("div",{className:"tool-result-detail tool-result-askuserquestion",children:(0,Fe.jsx)("div",{className:"result-header",children:(0,Fe.jsx)("span",{className:"result-status status-info",children:"No answers provided by user"})})}):(0,Fe.jsxs)("div",{className:"tool-result-detail tool-result-askuserquestion",children:[(0,Fe.jsx)("div",{className:"result-header",children:(0,Fe.jsx)("span",{className:"result-status status-success",children:"User answered questions"})}),(0,Fe.jsx)("ul",{className:"result-list",children:t.map(([n,l],a)=>(0,Fe.jsxs)("li",{children:[(0,Fe.jsx)("strong",{children:n})," \u2192 ",l]},a))})]})}var oa=v(y(),1);function l0({data:e}){return e.error?(0,oa.jsx)("div",{className:"tool-result-detail tool-result-enterplanmode",children:(0,oa.jsx)("div",{className:"result-header",children:(0,oa.jsx)("span",{className:"result-status status-error",children:e.error})})}):(0,oa.jsx)("div",{className:"tool-result-detail tool-result-enterplanmode",children:(0,oa.jsx)("div",{className:"result-header",children:(0,oa.jsx)("span",{className:`result-status ${e.approved?"status-success":"status-warn"}`,children:e.approved?"Entered plan mode":"User declined to enter plan mode"})})})}var Mt=v(y(),1);function a0({data:e}){return e.error?(0,Mt.jsx)("div",{className:"tool-result-detail tool-result-exitplanmode",children:(0,Mt.jsx)("div",{className:"result-header",children:(0,Mt.jsx)("span",{className:"result-status status-error",children:e.error})})}):e.cancelled||!e.approved?(0,Mt.jsx)("div",{className:"tool-result-detail tool-result-exitplanmode",children:(0,Mt.jsx)("div",{className:"result-header",children:(0,Mt.jsx)("span",{className:"result-status status-warn",children:"Keep planning"})})}):(0,Mt.jsxs)("div",{className:"tool-result-detail tool-result-exitplanmode",children:[(0,Mt.jsx)("div",{className:"result-header",children:(0,Mt.jsxs)("span",{className:"result-status status-success",children:["User approved ",e.manualApproval?"manual approval":"auto-accept"," plan"]})}),e.plan&&(0,Mt.jsx)("div",{className:"result-content markdown-body",children:e.plan}),e.planFilePath&&(0,Mt.jsxs)("div",{className:"tool-meta",children:["Plan saved to: ",e.planFilePath]})]})}var ms=v(y(),1);function s0({data:e}){let t=e.message?.startsWith("Failed")||!e.worktreePath;return(0,ms.jsxs)("div",{className:"tool-result-detail tool-result-enterworktree",children:[(0,ms.jsx)("div",{className:"result-header",children:(0,ms.jsx)("span",{className:`result-status ${t?"status-error":"status-success"}`,children:t?"Failed":"Created worktree"})}),(0,ms.jsx)("div",{className:"result-content",children:e.message})]})}var ua=v(y(),1);function i0({data:e}){let t=e.message?.startsWith("Error")||e.message?.startsWith("Cancelled");return(0,ua.jsxs)("div",{className:"tool-result-detail tool-result-exitworktree",children:[(0,ua.jsxs)("div",{className:"result-header",children:[(0,ua.jsx)("span",{className:`result-status ${t?"status-error":"status-success"}`,children:t?"Failed":"Exited worktree"}),(0,ua.jsx)("span",{className:"tool-meta",children:e.action})]}),(0,ua.jsx)("div",{className:"result-content",children:e.message})]})}var gs=v(y(),1);function o0({data:e}){let t=e.message?.startsWith("<error>");return(0,gs.jsxs)("div",{className:"tool-result-detail tool-result-slashcommand",children:[(0,gs.jsx)("div",{className:"result-header",children:(0,gs.jsxs)("span",{className:`result-status ${t?"status-error":"status-info"}`,children:['The "',e.commandWithArgs?.split(" ")[0],'" slash command is running']})}),t&&(0,gs.jsx)("div",{className:"result-content",children:e.message})]})}var kl=v(y(),1);function u0({data:e}){let t=e.message?.startsWith("<error>");return(0,kl.jsxs)("div",{className:"tool-result-detail tool-result-skill",children:[(0,kl.jsxs)("div",{className:"result-header",children:[(0,kl.jsx)("span",{className:`result-status ${t?"status-error":"status-success"}`,children:t?"Skill error":e.fork?"Skill completed":"Successfully loaded skill"}),(0,kl.jsx)("span",{className:"tool-meta",children:e.skillName})]}),!t&&e.baseDirectory&&(0,kl.jsxs)("div",{className:"tool-meta",children:["Base directory: ",e.baseDirectory]}),t&&(0,kl.jsx)("div",{className:"result-content",children:e.message})]})}var sr=v(y(),1);function r0({data:e}){let t=e.message?.startsWith("Error");return(0,sr.jsx)("div",{className:"tool-result-detail tool-result-croncreate",children:(0,sr.jsx)("div",{className:"result-header",children:(0,sr.jsx)("span",{className:`result-status ${t?"status-error":"status-success"}`,children:t?e.message:`Scheduled ${e.jobId} ${e.description}`})})})}var ir=v(y(),1);function c0({data:e}){return(0,ir.jsx)("div",{className:"tool-result-detail tool-result-crondelete",children:(0,ir.jsx)("div",{className:"result-header",children:(0,ir.jsx)("span",{className:`result-status ${e.success?"status-success":"status-warn"}`,children:e.message})})})}var Kt=v(y(),1);function f0({data:e}){return!e.jobs||e.jobs.length===0?(0,Kt.jsx)("div",{className:"tool-result-detail tool-result-cronlist",children:(0,Kt.jsx)("div",{className:"result-header",children:(0,Kt.jsx)("span",{className:"result-status status-info",children:"No cron jobs scheduled"})})}):(0,Kt.jsxs)("div",{className:"tool-result-detail tool-result-cronlist",children:[(0,Kt.jsx)("div",{className:"result-header",children:(0,Kt.jsx)("span",{className:"result-status status-success",children:"Scheduled cron jobs"})}),(0,Kt.jsx)("ul",{className:"result-list",children:e.jobs.map(t=>{let n=t.prompt.length>50?t.prompt.slice(0,50)+"...":t.prompt;return(0,Kt.jsxs)("li",{children:[(0,Kt.jsx)("code",{children:t.id}),": ",n," ",(0,Kt.jsxs)("span",{className:"tool-meta",children:["(",t.recurring?"recurring":"one-shot"," \xB7 ",t.description,")"]})]},t.id)})})]})}var Vn=v(y(),1);function d0({data:e}){return(0,Vn.jsxs)("div",{className:"tool-result-detail tool-result-teamcreate",children:[(0,Vn.jsx)("div",{className:"result-header",children:(0,Vn.jsxs)("span",{className:"result-status status-success",children:["Created team: ",e.name]})}),(0,Vn.jsxs)("div",{className:"result-content",children:[e.description&&(0,Vn.jsxs)("div",{children:["Description: ",e.description]}),(0,Vn.jsxs)("div",{children:["Lead: ",e.leadAgentId]}),(0,Vn.jsxs)("div",{children:["Members: ",e.members?.length||0]})]})]})}var hs=v(y(),1);function p0({data:e}){return(0,hs.jsxs)("div",{className:"tool-result-detail tool-result-teamdelete",children:[(0,hs.jsx)("div",{className:"result-header",children:(0,hs.jsx)("span",{className:`result-status ${e.success?"status-success":"status-error"}`,children:e.success?`Deleted team: ${e.teamName}`:`Failed to delete team: ${e.teamName}`})}),!e.success&&(0,hs.jsx)("div",{className:"result-content",children:e.message})]})}var vs=v(y(),1);function m0({data:e}){return(0,vs.jsxs)("div",{className:"tool-result-detail tool-result-sendmessage",children:[(0,vs.jsx)("div",{className:"result-header",children:(0,vs.jsx)("span",{className:`result-status ${e.success?"status-success":"status-error"}`,children:e.success?e.message:"Failed to send message"})}),!e.success&&(0,vs.jsx)("div",{className:"result-content",children:e.message})]})}var Kn=v(y(),1);function jE(e){let t=!1,n=!1;for(let l of Object.values(e))for(let a of l)a==="__tool_result__"?t=!0:n=!0;return{hasToolResult:t,hasInputFields:n}}function ZE(e){return e==="__tool_result__"?"tool result":`input field "${e}"`}function g0({data:e}){let t=e.action==="archive"?"Archived":"Unarchived",n=e.action==="archive"?e.archivedToolUseInputFields??{}:e.unarchivedToolUseInputFields??{},l=Object.keys(n).length,{hasToolResult:a,hasInputFields:s}=jE(n),i="tool result(s)";return a&&s?i="tool result(s) and input field(s)":s&&(i="input field(s)"),(0,Kn.jsxs)("div",{className:"tool-result-detail tool-result-messagearchiving",children:[(0,Kn.jsx)("div",{className:"result-header",children:(0,Kn.jsxs)("span",{className:"result-status status-success",children:[t," ",i," for ",l," tool use(s)"]})}),Object.entries(n).map(([o,u])=>(0,Kn.jsxs)("div",{className:"result-fields",children:[(0,Kn.jsxs)("span",{className:"result-tool-use-id",children:[o,":"]}),u.map((f,r)=>(0,Kn.jsxs)("span",{className:"result-field",children:[r>0?", ":"",ZE(f)]},`${f}-${r}`))]},o)),e.action==="archive"&&e.summary&&(0,Kn.jsx)("div",{className:"result-summary",children:e.summary})]})}var I=v(y(),1);function h0({data:e}){return(0,I.jsx)("div",{className:"tool-result-detail tool-result-memo",children:(()=>{switch(e.action){case"write":{let{result:n}=e;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)("div",{className:"result-header",children:[(0,I.jsxs)("span",{className:`result-status ${n.success?"status-success":"status-error"}`,children:["\u23BF Memo ",n.success?"saved":"failed",": ",n.key]}),n.success&&n.savedChars!==void 0&&(0,I.jsxs)("span",{className:"result-meta",children:["(",n.savedChars," chars)"]})]}),!n.success&&n.error&&(0,I.jsx)("div",{className:"memo-error",children:n.error})]})}case"read":{let{note:n}=e;return n?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)("div",{className:"result-header",children:[(0,I.jsxs)("span",{className:"result-status status-success",children:["\u23BF Memo read: ",n.key]}),(0,I.jsx)("span",{className:"result-meta",children:n.summary})]}),(0,I.jsx)("div",{className:"memo-content",children:n.content})]}):(0,I.jsx)("div",{className:"result-header",children:(0,I.jsx)("span",{className:"result-status status-warn",children:"\u23BF Memo not found"})})}case"list":{let{notes:n}=e;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)("div",{className:"result-header",children:(0,I.jsxs)("span",{className:"result-status status-info",children:["\u23BF Memo list (",n.length," memos)"]})}),n.length>0&&(0,I.jsxs)("table",{className:"memo-table",children:[(0,I.jsx)("thead",{children:(0,I.jsxs)("tr",{children:[(0,I.jsx)("th",{children:"#"}),(0,I.jsx)("th",{children:"Key"}),(0,I.jsx)("th",{children:"Summary"}),(0,I.jsx)("th",{children:"Updated"})]})}),(0,I.jsx)("tbody",{children:n.map((l,a)=>(0,I.jsxs)("tr",{children:[(0,I.jsx)("td",{children:a+1}),(0,I.jsx)("td",{className:"memo-key",children:l.key}),(0,I.jsx)("td",{children:l.summary}),(0,I.jsx)("td",{className:"memo-date",children:l.updatedAt})]},l.key))})]})]})}case"delete":{let{success:n,key:l}=e;return(0,I.jsx)("div",{className:"result-header",children:(0,I.jsxs)("span",{className:`result-status ${n?"status-success":"status-warn"}`,children:["\u23BF Memo ",n?"deleted":"not found",": ",l]})})}default:return null}})()})}var or=v(y(),1);function zd({data:e,isLoad:t}){let n=(e?.results??[]).filter(s=>!s.error).length,l=(e?.results??[]).filter(s=>s.error).map(s=>s.name).filter(Boolean),a=t?e?.error?l.join(", ")||(e?.message??""):`${n} tools loaded${l.length?` (${l.join(", ")} failed)`:""}`:e?.message??"";return(0,or.jsx)("div",{className:"tool-result-detail tool-result-proxy",children:(0,or.jsx)("div",{className:"result-header",children:(0,or.jsx)("span",{className:"result-status status-success",children:a})})})}var v0=v($(),1),$t=v(y(),1);function y0({data:e}){let[t,n]=(0,v0.useState)(!1);if(e?.error)return(0,$t.jsx)("div",{className:"tool-result-detail tool-result-codemode",children:(0,$t.jsx)("div",{className:"result-header",children:(0,$t.jsxs)("span",{className:"result-status status-error",children:["Error: ",e.error]})})});let a=((typeof e?.result=="string"?e.result:JSON.stringify(e?.result,null,2))??"").split(`
92
+ `)})}),o&&!t&&(0,Oe.jsxs)("div",{className:"expand-toggle",onClick:()=>n(!0),children:["... ",s.length-30," more lines (click to expand)"]})]}),a&&(0,Oe.jsx)("pre",{className:"code-block stderr-block",children:(0,Oe.jsx)("code",{children:e.stderr})}),e.interrupted&&(0,Oe.jsx)("div",{className:"result-note",children:"Command was aborted before completion"})]})}var lr=v(y(),1);function Kb({data:e}){let t=e.toolNames||[];return(0,lr.jsx)("div",{className:"tool-result-detail tool-result-toolloader",children:(0,lr.jsx)("div",{className:"result-header",children:(0,lr.jsx)("span",{className:"result-status status-success",children:e.message||`Tools loaded: ${t.join(", ")}`})})})}var ar=v(y(),1);function $b({data:e}){let n=e.message?.startsWith("<error>")?"status-error":"status-success";return(0,ar.jsx)("div",{className:"tool-result-detail tool-result-toolunloader",children:(0,ar.jsx)("div",{className:"result-header",children:(0,ar.jsx)("span",{className:`result-status ${n}`,children:e.message||"Tools unloaded"})})})}var yn=v(y(),1);function Jb({data:e}){return e.error?(0,yn.jsx)("div",{className:"tool-result-detail tool-result-notebookedit",children:(0,yn.jsx)("div",{className:"result-header",children:(0,yn.jsx)("span",{className:"result-status status-error",children:e.error})})}):(0,yn.jsxs)("div",{className:"tool-result-detail tool-result-notebookedit",children:[(0,yn.jsx)("div",{className:"result-header",children:(0,yn.jsx)("span",{className:"result-status status-success",children:e.edit_mode==="delete"?`Deleted cell ${e.cell_number}`:`${e.edit_mode==="insert"?"Inserted":"Updated"} cell ${e.cell_number}`})}),(0,yn.jsx)("pre",{className:"code-block",children:(0,yn.jsx)("code",{children:e.new_source})})]})}var Zn=v(y(),1);function Pb({data:e}){return(0,Zn.jsxs)("div",{className:"tool-result-detail tool-result-websearch",children:[(0,Zn.jsx)("div",{className:"result-header",children:(0,Zn.jsxs)("span",{className:"result-status status-success",children:["Found ",e.results.length," ",e.results.length===1?"result":"results"]})}),e.summaryText&&(0,Zn.jsx)("div",{className:"result-summary markdown-body",children:e.summaryText}),e.results.length>0&&(0,Zn.jsx)("ul",{className:"result-list",children:e.results.map((t,n)=>(0,Zn.jsx)("li",{children:(0,Zn.jsx)("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.title})},n))})]})}var Wb=v($(),1),Rl=v(y(),1);function Ib({data:e}){let[t,n]=(0,Wb.useState)(!1),l=e.aiAnalysis||"No content could be analyzed",a=l.length>400,s=t||!a?l:l.slice(0,400)+"...";return(0,Rl.jsxs)("div",{className:"tool-result-detail tool-result-webfetch",children:[(0,Rl.jsxs)("div",{className:"result-header",children:[(0,Rl.jsxs)("span",{className:"result-status status-success",children:["Content ",e.fromCache?"from cache":"fetched"," and analyzed"]}),(0,Rl.jsx)("span",{className:"tool-meta",children:e.url})]}),(0,Rl.jsx)("div",{className:"result-content markdown-body",style:{whiteSpace:"pre-wrap"},children:s}),a&&!t&&(0,Rl.jsx)("div",{className:"expand-toggle",onClick:()=>n(!0),children:"click to expand"})]})}var ds=v(y(),1);function Fb({data:e}){return(0,ds.jsx)("div",{className:"tool-result-detail tool-result-taskstop",children:(0,ds.jsxs)("div",{className:"result-header",children:[(0,ds.jsx)("span",{className:`result-status ${e.stopped?"status-success":"status-error"}`,children:e.message}),(0,ds.jsxs)("span",{className:"tool-meta",children:[e.task_id," (",e.task_type,")"]})]})})}var Xn=v(y(),1);function QE(e){return e==="completed"?"\u2612":"\u2610"}function e0({data:e}){let t=e.todos||[];return t.length===0?(0,Xn.jsx)("div",{className:"tool-result-detail tool-result-todowrite",children:(0,Xn.jsx)("div",{className:"result-header",children:(0,Xn.jsx)("span",{className:"result-status status-info",children:"No todos currently"})})}):(0,Xn.jsx)("div",{className:"tool-result-detail tool-result-todowrite",children:t.map((n,l)=>{let a=n.status==="completed",s=n.status==="in_progress";return(0,Xn.jsxs)("div",{className:"todo-item",children:[(0,Xn.jsx)("span",{className:`todo-checkbox ${a?"completed":""}`,children:QE(n.status)}),(0,Xn.jsx)("span",{className:`todo-content ${a?"completed":""} ${s?"in-progress":""}`,children:n.content})]},l)})})}var ps=v(y(),1);function t0({data:e}){return(0,ps.jsxs)("div",{className:"tool-result-detail tool-result-think",children:[(0,ps.jsx)("div",{className:"result-header",children:(0,ps.jsx)("span",{className:"result-status status-success",children:"Thought logged"})}),(0,ps.jsx)("div",{className:"result-content",children:e.thought})]})}var Fe=v(y(),1);function n0({data:e}){if(e.error)return(0,Fe.jsx)("div",{className:"tool-result-detail tool-result-askuserquestion",children:(0,Fe.jsx)("div",{className:"result-header",children:(0,Fe.jsx)("span",{className:"result-status status-error",children:e.error})})});if(e.cancelled)return(0,Fe.jsx)("div",{className:"tool-result-detail tool-result-askuserquestion",children:(0,Fe.jsx)("div",{className:"result-header",children:(0,Fe.jsx)("span",{className:"result-status status-warn",children:"Question asking was cancelled"})})});let t=Object.entries(e.answers||{});return t.length===0?(0,Fe.jsx)("div",{className:"tool-result-detail tool-result-askuserquestion",children:(0,Fe.jsx)("div",{className:"result-header",children:(0,Fe.jsx)("span",{className:"result-status status-info",children:"No answers provided by user"})})}):(0,Fe.jsxs)("div",{className:"tool-result-detail tool-result-askuserquestion",children:[(0,Fe.jsx)("div",{className:"result-header",children:(0,Fe.jsx)("span",{className:"result-status status-success",children:"User answered questions"})}),(0,Fe.jsx)("ul",{className:"result-list",children:t.map(([n,l],a)=>(0,Fe.jsxs)("li",{children:[(0,Fe.jsx)("strong",{children:n})," \u2192 ",l]},a))})]})}var oa=v(y(),1);function l0({data:e}){return e.error?(0,oa.jsx)("div",{className:"tool-result-detail tool-result-enterplanmode",children:(0,oa.jsx)("div",{className:"result-header",children:(0,oa.jsx)("span",{className:"result-status status-error",children:e.error})})}):(0,oa.jsx)("div",{className:"tool-result-detail tool-result-enterplanmode",children:(0,oa.jsx)("div",{className:"result-header",children:(0,oa.jsx)("span",{className:`result-status ${e.approved?"status-success":"status-warn"}`,children:e.approved?"Entered plan mode":"User declined to enter plan mode"})})})}var Mt=v(y(),1);function a0({data:e}){return e.error?(0,Mt.jsx)("div",{className:"tool-result-detail tool-result-exitplanmode",children:(0,Mt.jsx)("div",{className:"result-header",children:(0,Mt.jsx)("span",{className:"result-status status-error",children:e.error})})}):e.cancelled||!e.approved?(0,Mt.jsx)("div",{className:"tool-result-detail tool-result-exitplanmode",children:(0,Mt.jsx)("div",{className:"result-header",children:(0,Mt.jsx)("span",{className:"result-status status-warn",children:"Keep planning"})})}):(0,Mt.jsxs)("div",{className:"tool-result-detail tool-result-exitplanmode",children:[(0,Mt.jsx)("div",{className:"result-header",children:(0,Mt.jsxs)("span",{className:"result-status status-success",children:["User approved ",e.manualApproval?"manual approval":"auto-accept"," plan"]})}),e.plan&&(0,Mt.jsx)("div",{className:"result-content markdown-body",children:e.plan}),e.planFilePath&&(0,Mt.jsxs)("div",{className:"tool-meta",children:["Plan saved to: ",e.planFilePath]})]})}var ms=v(y(),1);function s0({data:e}){let t=e.message?.startsWith("Failed")||!e.worktreePath;return(0,ms.jsxs)("div",{className:"tool-result-detail tool-result-enterworktree",children:[(0,ms.jsx)("div",{className:"result-header",children:(0,ms.jsx)("span",{className:`result-status ${t?"status-error":"status-success"}`,children:t?"Failed":"Created worktree"})}),(0,ms.jsx)("div",{className:"result-content",children:e.message})]})}var ua=v(y(),1);function i0({data:e}){let t=e.message?.startsWith("Error")||e.message?.startsWith("Cancelled");return(0,ua.jsxs)("div",{className:"tool-result-detail tool-result-exitworktree",children:[(0,ua.jsxs)("div",{className:"result-header",children:[(0,ua.jsx)("span",{className:`result-status ${t?"status-error":"status-success"}`,children:t?"Failed":"Exited worktree"}),(0,ua.jsx)("span",{className:"tool-meta",children:e.action})]}),(0,ua.jsx)("div",{className:"result-content",children:e.message})]})}var gs=v(y(),1);function o0({data:e}){let t=e.message?.startsWith("<error>");return(0,gs.jsxs)("div",{className:"tool-result-detail tool-result-slashcommand",children:[(0,gs.jsx)("div",{className:"result-header",children:(0,gs.jsxs)("span",{className:`result-status ${t?"status-error":"status-info"}`,children:['The "',e.commandWithArgs?.split(" ")[0],'" slash command is running']})}),t&&(0,gs.jsx)("div",{className:"result-content",children:e.message})]})}var kl=v(y(),1);function u0({data:e}){let t=e.message?.startsWith("<error>");return(0,kl.jsxs)("div",{className:"tool-result-detail tool-result-skill",children:[(0,kl.jsxs)("div",{className:"result-header",children:[(0,kl.jsx)("span",{className:`result-status ${t?"status-error":"status-success"}`,children:t?"Skill error":e.fork?"Skill completed":"Successfully loaded skill"}),(0,kl.jsx)("span",{className:"tool-meta",children:e.skillName})]}),!t&&e.baseDirectory&&(0,kl.jsxs)("div",{className:"tool-meta",children:["Base directory: ",e.baseDirectory]}),t&&(0,kl.jsx)("div",{className:"result-content",children:e.message})]})}var sr=v(y(),1);function r0({data:e}){let t=e.message?.startsWith("Error");return(0,sr.jsx)("div",{className:"tool-result-detail tool-result-croncreate",children:(0,sr.jsx)("div",{className:"result-header",children:(0,sr.jsx)("span",{className:`result-status ${t?"status-error":"status-success"}`,children:t?e.message:`Scheduled ${e.jobId} ${e.description}`})})})}var ir=v(y(),1);function c0({data:e}){return(0,ir.jsx)("div",{className:"tool-result-detail tool-result-crondelete",children:(0,ir.jsx)("div",{className:"result-header",children:(0,ir.jsx)("span",{className:`result-status ${e.success?"status-success":"status-warn"}`,children:e.message})})})}var Kt=v(y(),1);function f0({data:e}){return!e.jobs||e.jobs.length===0?(0,Kt.jsx)("div",{className:"tool-result-detail tool-result-cronlist",children:(0,Kt.jsx)("div",{className:"result-header",children:(0,Kt.jsx)("span",{className:"result-status status-info",children:"No cron jobs scheduled"})})}):(0,Kt.jsxs)("div",{className:"tool-result-detail tool-result-cronlist",children:[(0,Kt.jsx)("div",{className:"result-header",children:(0,Kt.jsx)("span",{className:"result-status status-success",children:"Scheduled cron jobs"})}),(0,Kt.jsx)("ul",{className:"result-list",children:e.jobs.map(t=>{let n=t.prompt.length>50?t.prompt.slice(0,50)+"...":t.prompt;return(0,Kt.jsxs)("li",{children:[(0,Kt.jsx)("code",{children:t.id}),": ",n," ",(0,Kt.jsxs)("span",{className:"tool-meta",children:["(",t.recurring?"recurring":"one-shot"," \xB7 ",t.description,")"]})]},t.id)})})]})}var Vn=v(y(),1);function d0({data:e}){return(0,Vn.jsxs)("div",{className:"tool-result-detail tool-result-teamcreate",children:[(0,Vn.jsx)("div",{className:"result-header",children:(0,Vn.jsxs)("span",{className:"result-status status-success",children:["Created team: ",e.name]})}),(0,Vn.jsxs)("div",{className:"result-content",children:[e.description&&(0,Vn.jsxs)("div",{children:["Description: ",e.description]}),(0,Vn.jsxs)("div",{children:["Lead: ",e.leadAgentId]}),(0,Vn.jsxs)("div",{children:["Members: ",e.members?.length||0]})]})]})}var hs=v(y(),1);function p0({data:e}){return(0,hs.jsxs)("div",{className:"tool-result-detail tool-result-teamdelete",children:[(0,hs.jsx)("div",{className:"result-header",children:(0,hs.jsx)("span",{className:`result-status ${e.success?"status-success":"status-error"}`,children:e.success?`Deleted team: ${e.teamName}`:`Failed to delete team: ${e.teamName}`})}),!e.success&&(0,hs.jsx)("div",{className:"result-content",children:e.message})]})}var vs=v(y(),1);function m0({data:e}){return(0,vs.jsxs)("div",{className:"tool-result-detail tool-result-sendmessage",children:[(0,vs.jsx)("div",{className:"result-header",children:(0,vs.jsx)("span",{className:`result-status ${e.success?"status-success":"status-error"}`,children:e.success?e.message:"Failed to send message"})}),!e.success&&(0,vs.jsx)("div",{className:"result-content",children:e.message})]})}var Kn=v(y(),1);function jE(e){let t=!1,n=!1;for(let l of Object.values(e))for(let a of l)a==="__tool_result__"?t=!0:n=!0;return{hasToolResult:t,hasInputFields:n}}function ZE(e){return e==="__tool_result__"?"tool result":`input field "${e}"`}function g0({data:e}){let t=e.action==="archive"?"Archived":"Unarchived",n=e.action==="archive"?e.archivedToolUseInputFields??{}:e.unarchivedToolUseInputFields??{},l=Object.keys(n).length,{hasToolResult:a,hasInputFields:s}=jE(n),i="tool result(s)";return a&&s?i="tool result(s) and input field(s)":s&&(i="input field(s)"),(0,Kn.jsxs)("div",{className:"tool-result-detail tool-result-messagearchiving",children:[(0,Kn.jsx)("div",{className:"result-header",children:(0,Kn.jsxs)("span",{className:"result-status status-success",children:[t," ",i," for ",l," tool use(s)"]})}),Object.entries(n).map(([o,u])=>(0,Kn.jsxs)("div",{className:"result-fields",children:[(0,Kn.jsxs)("span",{className:"result-tool-use-id",children:[o,":"]}),u.map((f,r)=>(0,Kn.jsxs)("span",{className:"result-field",children:[r>0?", ":"",ZE(f)]},`${f}-${r}`))]},o)),e.action==="archive"&&e.summary&&(0,Kn.jsx)("div",{className:"result-summary",children:e.summary})]})}var I=v(y(),1);function h0({data:e}){return(0,I.jsx)("div",{className:"tool-result-detail tool-result-memo",children:(()=>{switch(e.action){case"write":{let{result:n}=e;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)("div",{className:"result-header",children:[(0,I.jsxs)("span",{className:`result-status ${n.success?"status-success":"status-error"}`,children:["\u23BF Memo ",n.success?"saved":"failed",": ",n.key]}),n.success&&n.savedChars!==void 0&&(0,I.jsxs)("span",{className:"result-meta",children:["(",n.savedChars," chars)"]})]}),!n.success&&n.error&&(0,I.jsx)("div",{className:"memo-error",children:n.error})]})}case"read":{let{note:n}=e;return n?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)("div",{className:"result-header",children:[(0,I.jsxs)("span",{className:"result-status status-success",children:["\u23BF Memo read: ",n.key]}),(0,I.jsx)("span",{className:"result-meta",children:n.summary})]}),(0,I.jsx)("div",{className:"memo-content",children:n.content})]}):(0,I.jsx)("div",{className:"result-header",children:(0,I.jsx)("span",{className:"result-status status-warn",children:"\u23BF Memo not found"})})}case"list":{let{notes:n}=e;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)("div",{className:"result-header",children:(0,I.jsxs)("span",{className:"result-status status-info",children:["\u23BF Memo list (",n.length," memos)"]})}),n.length>0&&(0,I.jsxs)("table",{className:"memo-table",children:[(0,I.jsx)("thead",{children:(0,I.jsxs)("tr",{children:[(0,I.jsx)("th",{children:"#"}),(0,I.jsx)("th",{children:"Key"}),(0,I.jsx)("th",{children:"Summary"}),(0,I.jsx)("th",{children:"Updated"})]})}),(0,I.jsx)("tbody",{children:n.map((l,a)=>(0,I.jsxs)("tr",{children:[(0,I.jsx)("td",{children:a+1}),(0,I.jsx)("td",{className:"memo-key",children:l.key}),(0,I.jsx)("td",{children:l.summary}),(0,I.jsx)("td",{className:"memo-date",children:l.updatedAt})]},l.key))})]})]})}case"delete":{let{success:n,key:l}=e;return(0,I.jsx)("div",{className:"result-header",children:(0,I.jsxs)("span",{className:`result-status ${n?"status-success":"status-warn"}`,children:["\u23BF Memo ",n?"deleted":"not found",": ",l]})})}default:return null}})()})}var or=v(y(),1);function zd({data:e,isLoad:t}){let n=t?e?.error?e?.name??e?.message??"":`tool loaded: ${e?.name??""}`:e?.message??"";return(0,or.jsx)("div",{className:"tool-result-detail tool-result-proxy",children:(0,or.jsx)("div",{className:"result-header",children:(0,or.jsx)("span",{className:"result-status status-success",children:n})})})}var v0=v($(),1),$t=v(y(),1);function y0({data:e}){let[t,n]=(0,v0.useState)(!1);if(e?.error)return(0,$t.jsx)("div",{className:"tool-result-detail tool-result-codemode",children:(0,$t.jsx)("div",{className:"result-header",children:(0,$t.jsxs)("span",{className:"result-status status-error",children:["Error: ",e.error]})})});let a=((typeof e?.result=="string"?e.result:JSON.stringify(e?.result,null,2))??"").split(`
93
93
  `),s=a.length>30,i=t?a:a.slice(0,30);return(0,$t.jsxs)("div",{className:"tool-result-detail tool-result-codemode",children:[(0,$t.jsxs)("div",{className:"result-header",children:[(0,$t.jsx)("span",{className:"result-status status-success",children:"Result"}),a.length>1&&(0,$t.jsxs)("span",{className:"tool-meta",children:[a.length," lines"]})]}),(0,$t.jsx)("pre",{className:"code-block",children:(0,$t.jsx)("code",{children:i.join(`
94
- `)})}),s&&!t&&(0,$t.jsxs)("div",{className:"expand-toggle",onClick:()=>n(!0),children:["... ",a.length-30," more lines (click to expand)"]})]})}var Z=v(y(),1);function b0({message:e}){let{toolName:t,toolData:n,isError:l,isRemote:a}=e.metadata||{},[s,i]=(0,ur.useState)(!1),o=e.content,u=o.length>200,f=s||!u?o:o.substring(0,200)+"... (click to expand)",r=(0,ur.useMemo)(()=>{try{return ne.parse(f)}catch{return f}},[f]);if(l||!n)return(0,Z.jsx)("div",{className:`message-item message-tool-result ${l?"error":""}`,children:(0,Z.jsx)("div",{className:"result-content markdown-body custom-scrollbar",onClick:()=>u&&i(!s),style:{cursor:u?"pointer":"default"},dangerouslySetInnerHTML:{__html:r}})});let d=n;return d?.type==="mcp"?(0,Z.jsx)("div",{className:`message-item message-tool-result${a?" remote":""}`,children:(0,Z.jsx)(Qb,{data:d})}):(0,Z.jsx)("div",{className:`message-item message-tool-result${a?" remote":""}`,children:(()=>{switch(t){case"Read":return(0,Z.jsx)(Eb,{data:d});case"Edit":return(0,Z.jsx)(kb,{data:d});case"Write":return(0,Z.jsx)(Ab,{data:d});case"Bash":return(0,Z.jsx)(Cb,{data:d});case"Grep":return(0,Z.jsx)(wb,{data:d});case"Glob":return(0,Z.jsx)(Ub,{data:d});case"LS":return(0,Z.jsx)(Lb,{data:d});case"Agent":return(0,Z.jsx)(Hb,{data:d});case"LSP":return(0,Z.jsx)(qb,{data:d});case"Cwd":return(0,Z.jsx)(Gb,{data:d});case"TaskOutput":return(0,Z.jsx)(Zb,{data:d});case"PowerShell":return(0,Z.jsx)(Vb,{data:d});case"ToolLoader":return(0,Z.jsx)(Kb,{data:d});case"ToolUnLoader":return(0,Z.jsx)($b,{data:d});case"NotebookEdit":return(0,Z.jsx)(Jb,{data:d});case"WebSearch":return(0,Z.jsx)(Pb,{data:d});case"WebFetch":return(0,Z.jsx)(Ib,{data:d});case"TaskStop":return(0,Z.jsx)(Fb,{data:d});case"TodoWrite":return(0,Z.jsx)(e0,{data:d});case"Think":return(0,Z.jsx)(t0,{data:d});case"AskUserQuestion":return(0,Z.jsx)(n0,{data:d});case"EnterPlanMode":return(0,Z.jsx)(l0,{data:d});case"ExitPlanMode":return(0,Z.jsx)(a0,{data:d});case"EnterWorktreeTool":return(0,Z.jsx)(s0,{data:d});case"ExitWorktreeTool":return(0,Z.jsx)(i0,{data:d});case"SlashCommand":return(0,Z.jsx)(o0,{data:d});case"Skill":return(0,Z.jsx)(u0,{data:d});case"CronCreate":return(0,Z.jsx)(r0,{data:d});case"CronDelete":return(0,Z.jsx)(c0,{data:d});case"CronList":return(0,Z.jsx)(f0,{data:d});case"TeamCreate":return(0,Z.jsx)(d0,{data:d});case"TeamDelete":return(0,Z.jsx)(p0,{data:d});case"SendMessage":return(0,Z.jsx)(m0,{data:d});case"MessageArchiving":return(0,Z.jsx)(g0,{data:d});case"Memo":return(0,Z.jsx)(h0,{data:d});case"ProxyToolLoad":return(0,Z.jsx)(zd,{data:d,isLoad:!0});case"ProxyToolCall":return(0,Z.jsx)(zd,{data:d,isLoad:!1});case"codemode":return(0,Z.jsx)(y0,{data:d});default:return(0,Z.jsx)("pre",{className:"tool-result-text",children:e.content})}})()})}var He=v(y(),1);ne.setOptions({breaks:!0,gfm:!0});function S0({message:e,pendingUserResponses:t,sendUserResponse:n}){switch(e.messageType){case"user_text":return(0,He.jsx)(XE,{content:e.content});case"assistant_text":return(0,He.jsx)(VE,{content:e.content,metadata:e.metadata});case"assistant_thinking":return(0,He.jsx)(KE,{content:e.content});case"tool_use":return(0,He.jsx)(Nb,{message:e,pendingUserResponses:t,sendUserResponse:n});case"tool_result":return(0,He.jsx)(b0,{message:e});case"progress":return(0,He.jsx)($E,{content:e.content});case"error":return(0,He.jsx)(JE,{content:e.content});default:return null}}function cr(e){return(0,rr.useMemo)(()=>{try{return ne.parse(e)}catch{return e}},[e])}function XE({content:e}){let t=cr(e);return(0,He.jsx)("div",{className:"message-item message-user",children:(0,He.jsx)("div",{className:"message-content markdown-body",dangerouslySetInnerHTML:{__html:t}})})}function VE({content:e,metadata:t}){let n=cr(e);return(0,He.jsx)("div",{className:"message-item message-assistant",children:(0,He.jsx)("div",{className:"message-content markdown-body",dangerouslySetInnerHTML:{__html:n}})})}function KE({content:e}){let[t,n]=(0,rr.useState)(!1),l=cr(e);return(0,He.jsx)("div",{className:"message-item message-thinking",children:(0,He.jsxs)("details",{open:t,onToggle:a=>n(a.target.open),children:[(0,He.jsx)("summary",{children:"Thinking..."}),t&&(0,He.jsx)("div",{className:"message-content markdown-body",style:{marginTop:4},dangerouslySetInnerHTML:{__html:l}})]})})}function $E({content:e}){let t=cr(e);return(0,He.jsx)("div",{className:"message-item message-progress",children:(0,He.jsx)("div",{className:"markdown-body",dangerouslySetInnerHTML:{__html:t}})})}function JE({content:e}){return(0,He.jsx)("div",{className:"message-item message-error",children:e})}var PE=new Set(["TaskCreate","TaskGet","TaskList","TaskUpdate","TodoWrite","TeamCreate"]),WE=new Set(["ToolLoader","ToolUnLoader","MessageArchiving"]);function IE(e,t){return!!(PE.has(e)||t!=="DAHAWA_DEBUG"&&WE.has(e))}var N0="*-* ",T0="<system-notification>";function k0(e,t={}){let{userType:n}=t,l=[],a=0,s=new Map;for(let i of e)if(i.type==="user"&&i.message?.content){let o=i.message.content;if(Array.isArray(o))for(let u of o)u.type==="tool_result"&&u.tool_use_id&&s.set(u.tool_use_id,u)}for(let i of e)if(!(!i||!i.type))switch(i.type){case"user":FE(i,s,l,()=>`msg_${a++}`);break;case"assistant":e_(i,s,e,l,()=>`msg_${a++}`,n);break;case"progress":t_(i,l,()=>`msg_${a++}`);break}return l}function FE(e,t,n,l){let a=e.message?.content;if(a){if(typeof a=="string"){if(!a.trim())return;let s=a.trim();if(s.startsWith(N0)||s.startsWith(T0)||/<system-reminder>.*?<\/system-reminder>/s.test(s))return;let i=E0(s);n.push({id:l(),messageType:"user_text",content:i??s});return}if(Array.isArray(a)){for(let s of a)if(s.type==="text"){if(!s.text||s.text.trim()==="")continue;let i=s.text.trim();if(i.startsWith(N0)||i.startsWith(T0)||/<system-reminder>.*?<\/system-reminder>/s.test(i))continue;let o=E0(s.text);n.push({id:l(),messageType:"user_text",content:o??s.text})}}}}function E0(e){let t=_0(e,"command-message");if(!t)return null;let n=_0(e,"command-args");return`> /${t}${n?" "+n:""}`}function _0(e,t){if(!e.trim()||!t.trim())return null;let n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`<${n}(?:\\s+[^>]*)?>([\\s\\S]*?)<\\/${n}>`,"i").exec(e)?.[1]??null}function e_(e,t,n,l,a,s){let i=e.message?.content;if(!(!i||!Array.isArray(i)))for(let o of i)switch(o.type){case"text":if(o.text&&o.text.trim()){if(o.text.trim()==="No response requested.")break;l.push({id:a(),messageType:"assistant_text",content:o.text,metadata:{costUSD:e.costUSD,durationMs:e.durationMs}})}break;case"thinking":o.thinking&&o.thinking.trim()&&l.push({id:a(),messageType:"assistant_thinking",content:o.thinking,metadata:{isCollapsed:!0}});break;case"tool_use":{let u=o.id,f=o.name||"unknown_tool",r=f,d=o.input,c=!1;if(f==="ProxyToolCall"||f==="ProxyTool"&&(o.input?.proxyToolAction??"call")==="call"){let h=o.input;h&&h.toolName&&(r=h.toolName,d=h.arguments??{},c=!0)}if(IE(r,s))break;let{name:b,isRemote:S,displayName:T}=n_(r),m=T??b,g=u?t.has(u):!1;if(l.push({id:a(),messageType:"tool_use",content:b,metadata:{toolName:b,toolDisplayName:m,toolInput:i_(d),toolUseId:u,toolInputRaw:d,isRemote:S,isInProgress:!g,isProxyCall:c}}),u&&t.has(u)){let h=t.get(u),N=s_(h),x=a_(n,u),k=r.startsWith("mcp_")&&!r.startsWith("mcp_hands_")?l_(h,m):x;l.push({id:a(),messageType:"tool_result",content:N,metadata:{toolName:b,toolDisplayName:m,toolUseId:u,isError:h.is_error||!1,toolData:k,isRemote:S,isProxyCall:c}})}break}}}function t_(e,t,n){let l=e.content?.message?.content;if(!(!l||!Array.isArray(l)))for(let a of l)a.type==="text"&&a.text&&a.text.trim()&&t.push({id:n(),messageType:"progress",content:a.text})}var R0={mcp_hands_Read:"Read",mcp_hands_Edit:"Edit",mcp_hands_Write:"Write",mcp_hands_Bash:"Bash",mcp_hands_Grep:"Grep",mcp_hands_Glob:"Glob",mcp_hands_LSP:"LSP",mcp_hands_NotebookEdit:"NotebookEdit",mcp_hands_TaskOutput:"TaskOutput",mcp_hands_TaskStop:"TaskStop",mcp_hands_PowerShell:"PowerShell"};function n_(e){if(R0[e]){let t=R0[e];return{name:t,isRemote:!0,displayName:`\u2601 ${t}`}}if(e.startsWith("mcp_hands_")){let t=e.slice(10);return{name:t,isRemote:!0,displayName:`\u2601 ${t}`}}if(e.startsWith("mcp_")){let t=e.slice(4),n=t.indexOf("_");if(n!==-1){let l=t.slice(0,n),a=t.slice(n+1);return{name:e,isRemote:!1,displayName:`${l}:${a}`}}}return{name:e,isRemote:!1}}function l_(e,t){return e?{type:"mcp",displayName:t,content:e.content??"",isError:e.is_error||!1}:{type:"mcp",displayName:t,content:"",isError:!1}}function a_(e,t){for(let n of e){if(!n.toolUseResult?.data)continue;let l=n.message?.content;if(!Array.isArray(l))continue;if(l.some(s=>s.type==="tool_result"&&s.tool_use_id===t))return n.toolUseResult.data}}function s_(e){if(!e)return"";let t=e.content;return t?typeof t=="string"?t:Array.isArray(t)?t.filter(n=>n.type==="text").map(n=>n.text||"").join(`
94
+ `)})}),s&&!t&&(0,$t.jsxs)("div",{className:"expand-toggle",onClick:()=>n(!0),children:["... ",a.length-30," more lines (click to expand)"]})]})}var Z=v(y(),1);function b0({message:e}){let{toolName:t,toolData:n,isError:l,isRemote:a}=e.metadata||{},[s,i]=(0,ur.useState)(!1),o=e.content,u=o.length>200,f=s||!u?o:o.substring(0,200)+"... (click to expand)",r=(0,ur.useMemo)(()=>{try{return ne.parse(f)}catch{return f}},[f]);if(l||!n)return(0,Z.jsx)("div",{className:`message-item message-tool-result ${l?"error":""}`,children:(0,Z.jsx)("div",{className:"result-content markdown-body custom-scrollbar",onClick:()=>u&&i(!s),style:{cursor:u?"pointer":"default"},dangerouslySetInnerHTML:{__html:r}})});let d=n;return d?.type==="mcp"?(0,Z.jsx)("div",{className:`message-item message-tool-result${a?" remote":""}`,children:(0,Z.jsx)(Qb,{data:d})}):(0,Z.jsx)("div",{className:`message-item message-tool-result${a?" remote":""}`,children:(()=>{switch(t){case"Read":return(0,Z.jsx)(Eb,{data:d});case"Edit":return(0,Z.jsx)(kb,{data:d});case"Write":return(0,Z.jsx)(Ab,{data:d});case"Bash":return(0,Z.jsx)(Cb,{data:d});case"Grep":return(0,Z.jsx)(wb,{data:d});case"Glob":return(0,Z.jsx)(Ub,{data:d});case"LS":return(0,Z.jsx)(Lb,{data:d});case"Agent":return(0,Z.jsx)(Hb,{data:d});case"LSP":return(0,Z.jsx)(qb,{data:d});case"Cwd":return(0,Z.jsx)(Gb,{data:d});case"TaskOutput":return(0,Z.jsx)(Zb,{data:d});case"PowerShell":return(0,Z.jsx)(Vb,{data:d});case"ToolLoader":return(0,Z.jsx)(Kb,{data:d});case"ToolUnLoader":return(0,Z.jsx)($b,{data:d});case"NotebookEdit":return(0,Z.jsx)(Jb,{data:d});case"WebSearch":return(0,Z.jsx)(Pb,{data:d});case"WebFetch":return(0,Z.jsx)(Ib,{data:d});case"TaskStop":return(0,Z.jsx)(Fb,{data:d});case"TodoWrite":return(0,Z.jsx)(e0,{data:d});case"Think":return(0,Z.jsx)(t0,{data:d});case"AskUserQuestion":return(0,Z.jsx)(n0,{data:d});case"EnterPlanMode":return(0,Z.jsx)(l0,{data:d});case"ExitPlanMode":return(0,Z.jsx)(a0,{data:d});case"EnterWorktreeTool":return(0,Z.jsx)(s0,{data:d});case"ExitWorktreeTool":return(0,Z.jsx)(i0,{data:d});case"SlashCommand":return(0,Z.jsx)(o0,{data:d});case"Skill":return(0,Z.jsx)(u0,{data:d});case"CronCreate":return(0,Z.jsx)(r0,{data:d});case"CronDelete":return(0,Z.jsx)(c0,{data:d});case"CronList":return(0,Z.jsx)(f0,{data:d});case"TeamCreate":return(0,Z.jsx)(d0,{data:d});case"TeamDelete":return(0,Z.jsx)(p0,{data:d});case"SendMessage":return(0,Z.jsx)(m0,{data:d});case"MessageArchiving":return(0,Z.jsx)(g0,{data:d});case"Memo":return(0,Z.jsx)(h0,{data:d});case"ProxyToolLoad":return(0,Z.jsx)(zd,{data:d,isLoad:!0});case"ProxyToolCall":return(0,Z.jsx)(zd,{data:d,isLoad:!1});case"CodeMode":return(0,Z.jsx)(y0,{data:d});default:return(0,Z.jsx)("pre",{className:"tool-result-text",children:e.content})}})()})}var He=v(y(),1);ne.setOptions({breaks:!0,gfm:!0});function S0({message:e,pendingUserResponses:t,sendUserResponse:n}){switch(e.messageType){case"user_text":return(0,He.jsx)(XE,{content:e.content});case"assistant_text":return(0,He.jsx)(VE,{content:e.content,metadata:e.metadata});case"assistant_thinking":return(0,He.jsx)(KE,{content:e.content});case"tool_use":return(0,He.jsx)(Nb,{message:e,pendingUserResponses:t,sendUserResponse:n});case"tool_result":return(0,He.jsx)(b0,{message:e});case"progress":return(0,He.jsx)($E,{content:e.content});case"error":return(0,He.jsx)(JE,{content:e.content});default:return null}}function cr(e){return(0,rr.useMemo)(()=>{try{return ne.parse(e)}catch{return e}},[e])}function XE({content:e}){let t=cr(e);return(0,He.jsx)("div",{className:"message-item message-user",children:(0,He.jsx)("div",{className:"message-content markdown-body",dangerouslySetInnerHTML:{__html:t}})})}function VE({content:e,metadata:t}){let n=cr(e);return(0,He.jsx)("div",{className:"message-item message-assistant",children:(0,He.jsx)("div",{className:"message-content markdown-body",dangerouslySetInnerHTML:{__html:n}})})}function KE({content:e}){let[t,n]=(0,rr.useState)(!1),l=cr(e);return(0,He.jsx)("div",{className:"message-item message-thinking",children:(0,He.jsxs)("details",{open:t,onToggle:a=>n(a.target.open),children:[(0,He.jsx)("summary",{children:"Thinking..."}),t&&(0,He.jsx)("div",{className:"message-content markdown-body",style:{marginTop:4},dangerouslySetInnerHTML:{__html:l}})]})})}function $E({content:e}){let t=cr(e);return(0,He.jsx)("div",{className:"message-item message-progress",children:(0,He.jsx)("div",{className:"markdown-body",dangerouslySetInnerHTML:{__html:t}})})}function JE({content:e}){return(0,He.jsx)("div",{className:"message-item message-error",children:e})}var PE=new Set(["TaskCreate","TaskGet","TaskList","TaskUpdate","TodoWrite","TeamCreate"]),WE=new Set(["ToolLoader","ToolUnLoader","MessageArchiving"]);function IE(e,t){return!!(PE.has(e)||t!=="DAHAWA_DEBUG"&&WE.has(e))}var N0="*-* ",T0="<system-notification>";function k0(e,t={}){let{userType:n}=t,l=[],a=0,s=new Map;for(let i of e)if(i.type==="user"&&i.message?.content){let o=i.message.content;if(Array.isArray(o))for(let u of o)u.type==="tool_result"&&u.tool_use_id&&s.set(u.tool_use_id,u)}for(let i of e)if(!(!i||!i.type))switch(i.type){case"user":FE(i,s,l,()=>`msg_${a++}`);break;case"assistant":e_(i,s,e,l,()=>`msg_${a++}`,n);break;case"progress":t_(i,l,()=>`msg_${a++}`);break}return l}function FE(e,t,n,l){let a=e.message?.content;if(a){if(typeof a=="string"){if(!a.trim())return;let s=a.trim();if(s.startsWith(N0)||s.startsWith(T0)||/<system-reminder>.*?<\/system-reminder>/s.test(s))return;let i=E0(s);n.push({id:l(),messageType:"user_text",content:i??s});return}if(Array.isArray(a)){for(let s of a)if(s.type==="text"){if(!s.text||s.text.trim()==="")continue;let i=s.text.trim();if(i.startsWith(N0)||i.startsWith(T0)||/<system-reminder>.*?<\/system-reminder>/s.test(i))continue;let o=E0(s.text);n.push({id:l(),messageType:"user_text",content:o??s.text})}}}}function E0(e){let t=_0(e,"command-message");if(!t)return null;let n=_0(e,"command-args");return`> /${t}${n?" "+n:""}`}function _0(e,t){if(!e.trim()||!t.trim())return null;let n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`<${n}(?:\\s+[^>]*)?>([\\s\\S]*?)<\\/${n}>`,"i").exec(e)?.[1]??null}function e_(e,t,n,l,a,s){let i=e.message?.content;if(!(!i||!Array.isArray(i)))for(let o of i)switch(o.type){case"text":if(o.text&&o.text.trim()){if(o.text.trim()==="No response requested.")break;l.push({id:a(),messageType:"assistant_text",content:o.text,metadata:{costUSD:e.costUSD,durationMs:e.durationMs}})}break;case"thinking":o.thinking&&o.thinking.trim()&&l.push({id:a(),messageType:"assistant_thinking",content:o.thinking,metadata:{isCollapsed:!0}});break;case"tool_use":{let u=o.id,f=o.name||"unknown_tool",r=f,d=o.input,c=!1;if(f==="ProxyToolCall"||f==="ProxyTool"&&(o.input?.proxyToolAction??"call")==="call"){let h=o.input;h&&h.toolName&&(r=h.toolName,d=h.arguments??{},c=!0)}if(IE(r,s))break;let{name:b,isRemote:S,displayName:T}=n_(r),m=T??b,g=u?t.has(u):!1;if(l.push({id:a(),messageType:"tool_use",content:b,metadata:{toolName:b,toolDisplayName:m,toolInput:i_(d),toolUseId:u,toolInputRaw:d,isRemote:S,isInProgress:!g,isProxyCall:c}}),u&&t.has(u)){let h=t.get(u),N=s_(h),x=a_(n,u),k=r.startsWith("mcp_")&&!r.startsWith("mcp_hands_")?l_(h,m):x;l.push({id:a(),messageType:"tool_result",content:N,metadata:{toolName:b,toolDisplayName:m,toolUseId:u,isError:h.is_error||!1,toolData:k,isRemote:S,isProxyCall:c}})}break}}}function t_(e,t,n){let l=e.content?.message?.content;if(!(!l||!Array.isArray(l)))for(let a of l)a.type==="text"&&a.text&&a.text.trim()&&t.push({id:n(),messageType:"progress",content:a.text})}var R0={mcp_hands_Read:"Read",mcp_hands_Edit:"Edit",mcp_hands_Write:"Write",mcp_hands_Bash:"Bash",mcp_hands_Grep:"Grep",mcp_hands_Glob:"Glob",mcp_hands_LSP:"LSP",mcp_hands_NotebookEdit:"NotebookEdit",mcp_hands_TaskOutput:"TaskOutput",mcp_hands_TaskStop:"TaskStop",mcp_hands_PowerShell:"PowerShell"};function n_(e){if(R0[e]){let t=R0[e];return{name:t,isRemote:!0,displayName:`\u2601 ${t}`}}if(e.startsWith("mcp_hands_")){let t=e.slice(10);return{name:t,isRemote:!0,displayName:`\u2601 ${t}`}}if(e.startsWith("mcp_")){let t=e.slice(4),n=t.indexOf("_");if(n!==-1){let l=t.slice(0,n),a=t.slice(n+1);return{name:e,isRemote:!1,displayName:`${l}:${a}`}}}return{name:e,isRemote:!1}}function l_(e,t){return e?{type:"mcp",displayName:t,content:e.content??"",isError:e.is_error||!1}:{type:"mcp",displayName:t,content:"",isError:!1}}function a_(e,t){for(let n of e){if(!n.toolUseResult?.data)continue;let l=n.message?.content;if(!Array.isArray(l))continue;if(l.some(s=>s.type==="tool_result"&&s.tool_use_id===t))return n.toolUseResult.data}}function s_(e){if(!e)return"";let t=e.content;return t?typeof t=="string"?t:Array.isArray(t)?t.filter(n=>n.type==="text").map(n=>n.text||"").join(`
95
95
  `):JSON.stringify(t):e.is_error?"[Error]":"[Empty result]"}function i_(e){if(!e)return"";let t=typeof e=="string"?e:JSON.stringify(e,null,2);return t.length>800?t.substring(0,800)+"...":t}var Fi=v(y(),1);function x0({rawMessages:e,autoScroll:t,userType:n,pendingUserResponses:l,sendUserResponse:a}){let s=(0,ra.useRef)(null),i=(0,ra.useRef)(!1),o=(0,ra.useMemo)(()=>k0(e,{userType:n}),[e,n]);(0,ra.useEffect)(()=>{t&&s.current&&!i.current&&(s.current.scrollTop=s.current.scrollHeight)},[o,t]);let u=()=>{if(!s.current)return;let{scrollTop:f,scrollHeight:r,clientHeight:d}=s.current,c=r-f-d<50;i.current=!c};return o.length===0?(0,Fi.jsx)("div",{className:"message-list",children:(0,Fi.jsx)("div",{className:"empty-state",children:"Waiting for messages..."})}):(0,Fi.jsx)("div",{className:"message-list",ref:s,onScroll:u,children:o.map(f=>(0,Fi.jsx)(S0,{message:f,pendingUserResponses:l,sendUserResponse:a},f.id))})}var xl=v($(),1),bn=v(y(),1);function A0({activeAgent:e,isLoading:t=!1,promptStatus:n,onSubmit:l,onInterrupt:a}){let[s,i]=(0,xl.useState)(""),o=(0,xl.useRef)(null),u=e==="main",f=u&&s.trim()!=="",r=u&&t,d=(0,xl.useCallback)(()=>{let S=o.current;if(!S)return;S.style.height="auto";let T=parseFloat(getComputedStyle(S).minHeight)||0;S.style.height=`${Math.min(Math.max(S.scrollHeight,T),200)}px`},[]);(0,xl.useEffect)(()=>{d()},[s,d]);let c=S=>{S.key==="Enter"&&!S.shiftKey&&!S.nativeEvent.isComposing&&(S.preventDefault(),f&&(l(s),i("")))},p=()=>{f&&(l(s),i(""))},b=s.startsWith("!")?"bash":s.startsWith("/")?"command":"text";return(0,bn.jsx)("div",{className:"prompt-input-bar",children:(0,bn.jsxs)("div",{className:"prompt-input-inner",children:[(0,bn.jsx)("span",{className:`prompt-input-mode ${b}`,children:b==="bash"?"!":b==="command"?"/":null}),(0,bn.jsx)("textarea",{ref:o,className:"prompt-input-field",value:s,onChange:S=>i(S.target.value),onKeyDown:c,placeholder:u?t?"Agent is busy; your prompt will be queued...":"Type a prompt and press Enter...":"Switch to Main agent to type a prompt",disabled:!u,rows:3}),r?(0,bn.jsx)("button",{className:"prompt-input-interrupt",onClick:a,type:"button",title:"Interrupt",children:(0,bn.jsx)("span",{className:"interrupt-icon"})}):(0,bn.jsx)("button",{className:"prompt-input-send",onClick:p,disabled:!f,type:"button",title:"Send",children:(0,bn.jsx)("span",{className:"send-icon"})})]})})}var Sn=v($(),1);var Ct=v($(),1);function M0(){let[e,t]=(0,Ct.useState)(null),[n,l]=(0,Ct.useState)(null),[a,s]=(0,Ct.useState)(null),[i,o]=(0,Ct.useState)(!0),[u,f]=(0,Ct.useState)(null),r=(0,Ct.useCallback)(async()=>{try{let[b,S,T]=await Promise.all([fetch("/api/settings"),fetch("/api/settings/sources"),fetch("/api/model-config")]);if(!b.ok)throw new Error(`Failed to load settings: ${b.status}`);if(!S.ok)throw new Error(`Failed to load settings sources: ${S.status}`);if(!T.ok)throw new Error(`Failed to load model config: ${T.status}`);let m=await b.json(),g=await S.json(),h=await T.json();t(m),l({user:g.user||{},project:g.project||{}}),s(h),f(null)}catch(b){f(b instanceof Error?b.message:"Failed to load settings")}finally{o(!1)}},[]);(0,Ct.useEffect)(()=>{r();let b=()=>{r()};return window.addEventListener("settings:changed",b),()=>{window.removeEventListener("settings:changed",b)}},[r]);let d=(0,Ct.useCallback)(async(b,S,T)=>{let m=await fetch(`/api/settings/${b}/${S}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:T})});if(!m.ok){let g=await m.json().catch(()=>({error:"Update failed"}));throw new Error(g.error||"Update failed")}await r()},[r]),c=(0,Ct.useCallback)(async(b,S)=>{let T=await fetch(`/api/settings/${b}/${S}`,{method:"DELETE"});if(!T.ok){let m=await T.json().catch(()=>({error:"Reset failed"}));throw new Error(m.error||"Reset failed")}await r()},[r]),p=(0,Ct.useCallback)(async b=>{let S=await fetch("/api/model-config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!S.ok){let T=await S.json().catch(()=>({error:"Update model config failed",details:[]})),m=[T.error,...T.details||[]].filter(Boolean).join(`
96
96
  `);throw new Error(m||"Update model config failed")}await r()},[r]);return{settings:e,sources:n,modelConfig:a,loading:i,error:u,updateSetting:d,resetSetting:c,updateModelConfig:p,refresh:r}}var G0=v($(),1);var eo=v(y(),1);function fr({label:e,value:t,onChange:n}){return(0,eo.jsxs)("div",{className:"setting-row",children:[(0,eo.jsx)("span",{className:"setting-label",children:e}),(0,eo.jsx)("button",{className:`setting-toggle ${t?"on":"off"}`,onClick:()=>n(!t),children:t?"On":"Off"})]})}var ys=v(y(),1);function Ud({label:e,value:t,options:n,onChange:l}){return(0,ys.jsxs)("div",{className:"setting-row",children:[(0,ys.jsx)("span",{className:"setting-label",children:e}),(0,ys.jsx)("select",{className:"setting-select",value:t,onChange:a=>l(a.target.value),children:n.map(a=>(0,ys.jsx)("option",{value:a,children:a},a))})]})}var to=v(y(),1);function dr({label:e,value:t,onChange:n,placeholder:l}){return(0,to.jsxs)("div",{className:"setting-row",children:[(0,to.jsx)("span",{className:"setting-label",children:e}),(0,to.jsx)("input",{className:"setting-input",type:"text",value:t,placeholder:l,onChange:a=>n(a.target.value)})]})}var no=v(y(),1);function pr({label:e,value:t,onChange:n,min:l,max:a}){return(0,no.jsxs)("div",{className:"setting-row",children:[(0,no.jsx)("span",{className:"setting-label",children:e}),(0,no.jsx)("input",{className:"setting-input",type:"number",value:t,min:l,max:a,onChange:s=>n(parseInt(s.target.value,10)||0)})]})}var Al=v(y(),1);function ca({label:e,value:t,fields:n,onChange:l}){let a=t||{},s=(i,o)=>{l({...a,[i]:o})};return(0,Al.jsxs)("div",{className:"setting-object",children:[(0,Al.jsx)("h4",{className:"setting-object-title",children:e}),(0,Al.jsx)("div",{className:"setting-object-fields",children:n.map(i=>{let o=a[i.key];switch(i.type){case"boolean":return(0,Al.jsx)(fr,{label:i.label,value:!!o,onChange:u=>s(i.key,u)},i.key);case"number":return(0,Al.jsx)(pr,{label:i.label,value:typeof o=="number"?o:0,min:i.min,max:i.max,onChange:u=>s(i.key,u)},i.key);case"string":return(0,Al.jsx)(dr,{label:i.label,value:typeof o=="string"?o:"",placeholder:i.placeholder,onChange:u=>s(i.key,u)},i.key);default:return null}})})]})}var lo=v($(),1),bs=v(y(),1);function C0(e){return JSON.stringify(e??{},null,2)}function mr({label:e,value:t,onChange:n,rows:l=8,className:a}){let[s,i]=(0,lo.useState)(()=>C0(t)),[o,u]=(0,lo.useState)(null);(0,lo.useEffect)(()=>{i(C0(t)),u(null)},[t]);let f=()=>{try{let r=JSON.parse(s);u(null),n(r)}catch(r){u(r instanceof Error?r.message:"Invalid JSON")}};return(0,bs.jsxs)("div",{className:`setting-json-editor ${a||""}`,children:[(0,bs.jsx)("label",{className:"setting-json-label",children:e}),(0,bs.jsx)("textarea",{className:"setting-json-textarea",value:s,onChange:r=>i(r.target.value),onBlur:f,rows:l,spellCheck:!1}),o&&(0,bs.jsx)("div",{className:"setting-json-error",children:o})]})}var gr=v($(),1),tn=v(y(),1);function O0(e){return Object.entries(e??{}).map(([t,n])=>({key:t,value:String(n??"")}))}function w0(e){let t={};for(let n of e){let l=n.key.trim();l&&(t[l]=n.value)}return t}function o_(e,t){let n=Object.keys(e),l=Object.keys(t);return n.length!==l.length?!1:n.every(a=>e[a]===t[a])}function z0({label:e,value:t,onChange:n}){let[l,a]=(0,gr.useState)(()=>O0(t));(0,gr.useEffect)(()=>{a(O0(t))},[t]);let s=w0(l),i=d=>{let c=w0(d);o_(s,c)||n(c),a(d)},o=(d,c)=>{let p=l.map((b,S)=>S===d?{...b,key:c}:b);i(p)},u=(d,c)=>{let p=l.map((b,S)=>S===d?{...b,value:c}:b);i(p)},f=()=>{a([...l,{key:"",value:""}])},r=d=>{let c=l.filter((p,b)=>b!==d);i(c)};return(0,tn.jsxs)("div",{className:"setting-key-value",children:[(0,tn.jsx)("h4",{className:"setting-key-value-title",children:e}),(0,tn.jsx)("div",{className:"setting-key-value-list",children:l.map((d,c)=>(0,tn.jsxs)("div",{className:"setting-key-value-row",children:[(0,tn.jsx)("input",{className:"setting-input setting-key-value-key",type:"text",value:d.key,placeholder:"KEY",onChange:p=>o(c,p.target.value)}),(0,tn.jsx)("span",{className:"setting-key-value-separator",children:"="}),(0,tn.jsx)("input",{className:"setting-input setting-key-value-value",type:"text",value:d.value,placeholder:"value",onChange:p=>u(c,p.target.value)}),(0,tn.jsx)("button",{className:"setting-key-value-remove",onClick:()=>r(c),title:"Remove",children:"\xD7"})]},c))}),(0,tn.jsx)("button",{className:"setting-key-value-add",onClick:f,children:"+ Add"})]})}var ao=v($(),1);var Y=v(y(),1);function Ml(e){return JSON.parse(JSON.stringify(e))}function U0(e){return!e||typeof e!="object"||Array.isArray(e)?{sources:{},routing:{}}:{sources:typeof e.sources=="object"&&!Array.isArray(e.sources)?e.sources:{},routing:typeof e.routing=="object"&&!Array.isArray(e.routing)?e.routing:{}}}function D0(e){return Array.isArray(e)?e.join(", "):""}function u_(e){return e.split(",").map(t=>t.trim()).filter(Boolean)}var r_=["anthropic","openai","openai-responses","gemini"];function Ss({label:e,children:t}){return(0,Y.jsxs)("div",{className:"model-config-field",children:[(0,Y.jsx)("label",{className:"model-config-field-label",children:e}),(0,Y.jsx)("div",{className:"model-config-field-input",children:t})]})}function Dd({label:e,value:t,onChange:n,placeholder:l}){return(0,Y.jsx)(Ss,{label:e,children:(0,Y.jsx)("input",{className:"model-config-input",type:"text",value:t,placeholder:l,onChange:a=>n(a.target.value)})})}function c_({models:e,onChange:t}){let[n,l]=(0,ao.useState)(D0(e));return(0,ao.useEffect)(()=>{l(D0(e))},[e]),(0,Y.jsx)(Ss,{label:"Models (comma separated)",children:(0,Y.jsx)("input",{className:"model-config-input",type:"text",value:n,placeholder:"model-a, model-b",onChange:a=>l(a.target.value),onBlur:a=>t(u_(a.target.value))})})}function f_({label:e,value:t,onChange:n,min:l}){return(0,Y.jsx)(Ss,{label:e,children:(0,Y.jsx)("input",{className:"model-config-input",type:"number",value:t,min:l,onChange:a=>n(parseInt(a.target.value,10)||0)})})}function L0({value:e,onChange:t}){let[n,l]=(0,ao.useState)("form"),a=U0(e),s=(c,p,b)=>{let S=Ml(a);S.sources[c]||(S.sources[c]={base_url:"",auth_token:"",api_type:"anthropic",models:[]}),S.sources[c][p]=b,t(S)},i=()=>{let c=Ml(a),p=1;for(;c.sources[`source${p}`];)p++;c.sources[`source${p}`]={base_url:"",auth_token:"",api_type:"anthropic",models:[]},t(c)},o=c=>{let p=Ml(a);delete p.sources[c];for(let b of Object.keys(p.routing)){let S=b;p.routing[S]=(p.routing[S]||[]).filter(T=>T.source!==c)}t(p)},u=(c,p,b,S)=>{let T=Ml(a);T.routing[c]||(T.routing[c]=[]);let m=T.routing[c];m[p]||(m[p]={source:"",model:""}),m[p][b]=S,t(T)},f=c=>{let p=Ml(a);p.routing[c]||(p.routing[c]=[]),p.routing[c].push({source:"",model:"",weight:100}),t(p)},r=(c,p)=>{let b=Ml(a);b.routing[c]&&b.routing[c].splice(p,1),t(b)};return(0,Y.jsxs)("div",{className:"model-config-setting",children:[(0,Y.jsxs)("div",{className:"model-config-tabs",children:[(0,Y.jsx)("button",{className:`model-config-tab ${n==="form"?"active":""}`,onClick:()=>l("form"),children:"Form"}),(0,Y.jsx)("button",{className:`model-config-tab ${n==="json"?"active":""}`,onClick:()=>l("json"),children:"JSON"})]}),n==="form"?(0,Y.jsxs)("div",{className:"model-config-form",children:[(0,Y.jsxs)("div",{className:"model-config-section",children:[(0,Y.jsx)("h4",{className:"model-config-section-title",children:"Sources"}),Object.keys(a.sources).length===0&&(0,Y.jsx)("div",{className:"model-config-empty",children:"No sources configured"}),Object.entries(a.sources).map(([c,p])=>(0,Y.jsxs)("div",{className:"model-config-card",children:[(0,Y.jsxs)("div",{className:"model-config-card-header",children:[(0,Y.jsx)(Dd,{label:"Source Name",value:c,onChange:b=>{if(b===c||!b.trim())return;let S=Ml(a);S.sources[b]=S.sources[c],delete S.sources[c];for(let T of Object.keys(S.routing)){let m=T;S.routing[m]=(S.routing[m]||[]).map(g=>g.source===c?{...g,source:b}:g)}t(S)}}),(0,Y.jsx)("button",{className:"model-config-remove-button",onClick:()=>o(c),children:"Remove"})]}),(0,Y.jsx)(Dd,{label:"Base URL",value:p.base_url||"",onChange:b=>s(c,"base_url",b),placeholder:"https://api.example.com"}),(0,Y.jsx)(Dd,{label:"Auth Token",value:p.auth_token||"",onChange:b=>s(c,"auth_token",b),placeholder:"sk-..."}),(0,Y.jsx)(Ss,{label:"API Type",children:(0,Y.jsx)("select",{className:"model-config-select",value:p.api_type||"anthropic",onChange:b=>s(c,"api_type",b.target.value),children:r_.map(b=>(0,Y.jsx)("option",{value:b,children:b},b))})}),(0,Y.jsx)(c_,{models:p.models,onChange:b=>s(c,"models",b)})]},c)),(0,Y.jsx)("button",{className:"model-config-add-button",onClick:i,children:"Add Source"})]}),(0,Y.jsxs)("div",{className:"model-config-section",children:[(0,Y.jsx)("h4",{className:"model-config-section-title",children:"Routing"}),["MODEL","SMALL_FAST_MODEL"].map(c=>(0,Y.jsxs)("div",{className:"model-config-routing-group",children:[(0,Y.jsx)("h5",{className:"model-config-routing-type",children:c}),(a.routing[c]||[]).length===0&&(0,Y.jsx)("div",{className:"model-config-empty",children:"No routing items"}),(a.routing[c]||[]).map((p,b)=>(0,Y.jsx)("div",{className:"model-config-card",children:(0,Y.jsxs)("div",{className:"model-config-card-row",children:[(0,Y.jsx)(Ss,{label:"Source",children:(0,Y.jsxs)("select",{className:"model-config-select",value:p.source||"",onChange:S=>{let T=S.target.value,m=Ml(a);m.routing[c]||(m.routing[c]=[]);let g=m.routing[c];if(!g[b])g[b]={source:T,model:""};else{g[b].source=T;let h=m.sources[T]?.models||[];h.length>0&&!h.includes(g[b].model)?g[b].model=h[0]:h.length===0&&(g[b].model="")}t(m)},children:[(0,Y.jsx)("option",{value:"",children:"Select source"}),Object.keys(a.sources).map(S=>(0,Y.jsx)("option",{value:S,children:S},S))]})}),(0,Y.jsx)(Ss,{label:"Model",children:(0,Y.jsxs)("select",{className:"model-config-select",value:p.model||"",onChange:S=>u(c,b,"model",S.target.value),disabled:!p.source||!a.sources[p.source]?.models?.length,children:[(0,Y.jsx)("option",{value:"",children:p.source?a.sources[p.source]?.models?.length?"Select model":"No models available":"Select source first"}),(a.sources[p.source]?.models||[]).map(S=>(0,Y.jsx)("option",{value:S,children:S},S))]})}),(0,Y.jsx)(f_,{label:"Weight",value:typeof p.weight=="number"?p.weight:100,min:0,onChange:S=>u(c,b,"weight",S)}),(0,Y.jsx)("button",{className:"model-config-remove-button",onClick:()=>r(c,b),children:"Remove"})]})},b)),(0,Y.jsxs)("button",{className:"model-config-add-button",onClick:()=>f(c),children:["Add ",c," Route"]})]},c))]})]}):(0,Y.jsx)("div",{className:"model-config-json-wrapper",children:(0,Y.jsx)(mr,{label:"Model Config (config.json)",value:a,onChange:c=>t(U0(c)),className:"model-config-json-editor"})})]})}var so=v($(),1);var Ze=v($(),1);async function fa(e,t){let n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),l=await n.json().catch(()=>({error:"Request failed"}));if(!n.ok)throw new Error(l.error||`Request failed: ${n.status}`);return l}async function d_(e){let t=await fetch(e,{method:"DELETE"}),n=await t.json().catch(()=>({error:"Request failed"}));if(!t.ok)throw new Error(n.error||`Request failed: ${t.status}`);return n}function B0(){let[e,t]=(0,Ze.useState)([]),[n,l]=(0,Ze.useState)([]),[a,s]=(0,Ze.useState)([]),[i,o]=(0,Ze.useState)(!0),[u,f]=(0,Ze.useState)(null),r=(0,Ze.useCallback)(async()=>{try{o(!0);let[h,N,x]=await Promise.all([fetch("/api/marketplaces"),fetch("/api/plugins"),fetch("/api/plugins/available")]);if(!h.ok)throw new Error(`Failed to load marketplaces: ${h.status}`);if(!N.ok)throw new Error(`Failed to load plugins: ${N.status}`);if(!x.ok)throw new Error(`Failed to load available plugins: ${x.status}`);let U=await h.json(),k=await N.json(),O=await x.json();t(U.marketplaces||[]),l(k.plugins||[]),s(O.available||[]),f(null)}catch(h){f(h instanceof Error?h.message:"Failed to load plugins")}finally{o(!1)}},[]);(0,Ze.useEffect)(()=>{r()},[r]);let d=(0,Ze.useCallback)(async h=>{let N=await fa("/api/marketplaces",{source:h});return await r(),N.name},[r]),c=(0,Ze.useCallback)(async h=>{await d_(`/api/marketplaces/${encodeURIComponent(h)}`),await r()},[r]),p=(0,Ze.useCallback)(async h=>{let N=await fa(`/api/marketplaces/${encodeURIComponent(h)}/update`,{});return await r(),{updated:N.updated||[],errors:N.errors||[]}},[r]),b=(0,Ze.useCallback)(async h=>{let N=await fa("/api/plugins/install",{spec:h});return await r(),N.id},[r]),S=(0,Ze.useCallback)(async h=>{await fa("/api/plugins/uninstall",{spec:h}),await r()},[r]),T=(0,Ze.useCallback)(async h=>{let N=await fa("/api/plugins/update",{spec:h});return await r(),{updated:N.updated||[],errors:N.errors||[]}},[r]),m=(0,Ze.useCallback)(async h=>{await fa("/api/plugins/enable",{spec:h}),await r()},[r]),g=(0,Ze.useCallback)(async h=>{await fa("/api/plugins/disable",{spec:h}),await r()},[r]);return{marketplaces:e,plugins:n,available:a,loading:i,error:u,refresh:r,addMarketplace:d,removeMarketplace:c,updateMarketplace:p,installPlugin:b,uninstallPlugin:S,updatePlugin:T,enablePlugin:m,disablePlugin:g}}var G=v(y(),1);function H0({value:e,onChange:t}){let{marketplaces:n,plugins:l,available:a,loading:s,error:i,addMarketplace:o,removeMarketplace:u,updateMarketplace:f,installPlugin:r,uninstallPlugin:d,updatePlugin:c,enablePlugin:p,disablePlugin:b}=B0(),[S,T]=(0,so.useState)(""),[m,g]=(0,so.useState)(""),[h,N]=(0,so.useState)(null),[x,U]=(0,so.useState)(null),k=M=>{N(M),U(null)},O=M=>{U(M),N(null)},R=async()=>{if(S.trim())try{let M=await o(S.trim());T(""),O(M?`Added marketplace "${M}"`:"Marketplace added")}catch(M){k(M instanceof Error?M.message:"Failed to add marketplace")}},A=async M=>{try{await u(M),O(`Removed marketplace "${M}"`)}catch(E){k(E instanceof Error?E.message:"Failed to remove marketplace")}},H=async M=>{try{let E=await f(M);E.errors.length>0?k(E.errors.join(`
97
97
  `)):O(`Updated marketplace "${M}"`)}catch(E){k(E instanceof Error?E.message:"Failed to update marketplace")}},j=async M=>{let E=M??m;if(E.trim())try{let z=await r(E.trim());M||g(""),O(z?`Installed plugin "${z}"`:"Plugin installed")}catch(z){k(z instanceof Error?z.message:"Failed to install plugin")}},w=async M=>{try{await d(M),O(`Uninstalled plugin "${M}"`)}catch(E){k(E instanceof Error?E.message:"Failed to uninstall plugin")}},B=async M=>{try{let E=await c(M);E.errors.length>0?k(E.errors.join(`
98
- `)):O(`Updated ${E.updated.length} plugin(s)`)}catch(E){k(E instanceof Error?E.message:"Failed to update plugin")}};return(0,G.jsxs)("div",{className:"plugins-setting",children:[s&&(0,G.jsx)("div",{className:"setting-loading",children:"Loading plugins..."}),i&&(0,G.jsx)("div",{className:"setting-error",children:i}),h&&(0,G.jsx)("div",{className:"setting-error",children:h}),x&&(0,G.jsx)("div",{className:"setting-success",children:x}),(0,G.jsx)("div",{className:"plugins-section",children:(0,G.jsx)(ca,{label:"Plugin Settings",value:e||{},fields:[{key:"pluginClaudeCompat",label:"Claude Code plugin compatibility",type:"boolean"},{key:"pluginAutoUpdate",label:"Auto update plugins",type:"boolean"},{key:"pluginAutoUpdateInterval",label:"Auto update interval (minutes)",type:"number",min:1},{key:"pluginSandboxHooks",label:"Sandbox plugin hooks",type:"boolean"}],onChange:t})}),(0,G.jsxs)("div",{className:"plugins-section",children:[(0,G.jsx)("h4",{className:"setting-section-subtitle",children:"Marketplaces"}),(0,G.jsx)("div",{className:"plugin-input-row",children:(0,G.jsx)("input",{className:"setting-input plugin-input",type:"text",value:S,placeholder:"marketplace source (path, URL, or owner/repo)",onChange:M=>T(M.target.value),onKeyDown:M=>{M.key==="Enter"&&R()}})}),(0,G.jsx)("div",{className:"plugin-actions-row",children:(0,G.jsx)("button",{className:"setting-button-small",onClick:R,disabled:!S.trim(),children:"Add Marketplace"})}),(0,G.jsxs)("div",{className:"plugins-list",children:[n.length===0&&!s&&(0,G.jsx)("div",{className:"setting-empty",children:"No marketplaces registered."}),n.map(M=>(0,G.jsxs)("div",{className:"plugin-row",children:[(0,G.jsxs)("div",{className:"plugin-info",children:[(0,G.jsx)("div",{className:"plugin-name",children:M.name}),(0,G.jsxs)("div",{className:"plugin-meta",children:[M.type," \u2014 ",M.source]})]}),(0,G.jsxs)("div",{className:"plugin-actions",children:[(0,G.jsx)("button",{className:"setting-button-small",onClick:()=>H(M.name),children:"Update"}),(0,G.jsx)("button",{className:"setting-button-small",onClick:()=>A(M.name),children:"Remove"})]})]},M.name))]})]}),(0,G.jsxs)("div",{className:"plugins-section",children:[(0,G.jsx)("h4",{className:"setting-section-subtitle",children:"Available Plugins"}),(0,G.jsxs)("div",{className:"plugins-list",children:[a.length===0&&!s&&(0,G.jsx)("div",{className:"setting-empty",children:"No available plugins."}),a.map(M=>(0,G.jsxs)("div",{className:"plugin-row",children:[(0,G.jsxs)("div",{className:"plugin-info",children:[(0,G.jsx)("div",{className:"plugin-name",children:M.plugin}),(0,G.jsxs)("div",{className:"plugin-meta",children:[M.marketplace," \u2014 ",M.description||"No description"]})]}),(0,G.jsx)("div",{className:"plugin-actions",children:(0,G.jsx)("button",{className:"setting-button-small",onClick:()=>j(`${M.plugin}@${M.marketplace}`),children:"Install"})})]},`${M.plugin}@${M.marketplace}`))]})]}),(0,G.jsxs)("div",{className:"plugins-section",children:[(0,G.jsx)("h4",{className:"setting-section-subtitle",children:"Installed Plugins"}),(0,G.jsx)("div",{className:"plugin-input-row",children:(0,G.jsx)("input",{className:"setting-input plugin-input",type:"text",value:m,placeholder:"plugin[@marketplace]",onChange:M=>g(M.target.value),onKeyDown:M=>{M.key==="Enter"&&j()}})}),(0,G.jsxs)("div",{className:"plugin-actions-row",children:[(0,G.jsx)("button",{className:"setting-button-small",onClick:j,disabled:!m.trim(),children:"Install"}),(0,G.jsx)("button",{className:"setting-button-small",onClick:()=>B(),children:"Update All"})]}),(0,G.jsxs)("div",{className:"plugins-list",children:[l.length===0&&!s&&(0,G.jsx)("div",{className:"setting-empty",children:"No plugins installed."}),l.map(M=>(0,G.jsxs)("div",{className:"plugin-row",children:[(0,G.jsxs)("div",{className:"plugin-info",children:[(0,G.jsx)("div",{className:"plugin-name",children:M.plugin}),(0,G.jsxs)("div",{className:"plugin-meta",children:[M.marketplace," \u2014 ",M.version," \u2014 ",M.enabled?"enabled":"disabled"]})]}),(0,G.jsxs)("div",{className:"plugin-actions",children:[M.enabled?(0,G.jsx)("button",{className:"setting-button-small",onClick:()=>b(M.id),children:"Disable"}):(0,G.jsx)("button",{className:"setting-button-small",onClick:()=>p(M.id),children:"Enable"}),(0,G.jsx)("button",{className:"setting-button-small",onClick:()=>B(M.id),children:"Update"}),(0,G.jsx)("button",{className:"setting-button-small",onClick:()=>w(M.id),children:"Uninstall"})]})]},M.id))]})]})]})}var me=v(y(),1);function q0(e){return e===void 0?"undefined":e===null?"null":typeof e=="boolean"?e?"true":"false":typeof e=="string"?e:JSON.stringify(e,null,2)}function Y0({label:e,keys:t,settings:n,modelConfig:l,onUpdate:a,onModelConfigUpdate:s}){let[i,o]=(0,G0.useState)(new Set),u=r=>{o(d=>{let c=new Set(d);return c.has(r)?c.delete(r):c.add(r),c})},f=r=>{let d=n[r];switch(r){case"proxy":case"disableSuggestion":case"memo":case"messageArchiving":case"archiveToolUseInputs":return(0,me.jsx)(fr,{label:r==="archiveToolUseInputs"?"Archive Tool Use Inputs":r,value:!!d,onChange:c=>a(r,c)});case"lazyTool":return(0,me.jsx)(Ud,{label:r,value:d==="off"||d==="loading"||d==="proxy"?d:d===!0?"loading":d===!1?"off":"loading",options:["off","loading","proxy"],onChange:c=>a(r,c)});case"plugins":return(0,me.jsx)(H0,{value:d||{},onChange:c=>a(r,c)});case"thinking":return(0,me.jsx)(Ud,{label:r,value:d||"medium",options:["off","low","medium","high"],onChange:c=>a(r,c)});case"language":case"planDirectory":return(0,me.jsx)(dr,{label:r,value:d||"",placeholder:r==="planDirectory"?"/path/to/plan/directory":"auto",onChange:c=>a(r,c)});case"agentDepth":return(0,me.jsx)(pr,{label:r,value:typeof d=="number"?d:1,min:1,max:5,onChange:c=>a(r,c)});case"webServer":return(0,me.jsx)(ca,{label:"Web Server",value:d||{},fields:[{key:"enabled",label:"Enabled",type:"boolean"},{key:"port",label:"Port",type:"number",min:1,max:65535},{key:"host",label:"Host",type:"string"}],onChange:c=>a(r,c)});case"autoMode":return(0,me.jsx)(ca,{label:"Auto Mode",value:d||{},fields:[{key:"enabled",label:"Enabled",type:"boolean"},{key:"model",label:"Model",type:"string"},{key:"maxConsecutiveDenials",label:"Max Consecutive Denials",type:"number",min:0},{key:"maxTotalDenials",label:"Max Total Denials",type:"number",min:0}],onChange:c=>a(r,c)});case"autoMemory":return(0,me.jsx)(ca,{label:"Auto Memory",value:d||{},fields:[{key:"enabled",label:"Enabled",type:"boolean"},{key:"minTokens",label:"Min Tokens",type:"number",min:0},{key:"minTurns",label:"Min Turns",type:"number",min:0},{key:"teamMemoryEnabled",label:"Team Memory Enabled",type:"boolean"}],onChange:c=>a(r,c)});case"autoDream":return(0,me.jsx)(ca,{label:"Auto Dream",value:d||{},fields:[{key:"enabled",label:"Enabled",type:"boolean"},{key:"minHours",label:"Min Hours",type:"number",min:0},{key:"minSessions",label:"Min Sessions",type:"number",min:0}],onChange:c=>a(r,c)});case"modelConfig":return(0,me.jsx)(L0,{value:l||{sources:{},routing:{}},onChange:c=>s?.(c)});case"sandbox":case"sessionSummary":case"permissions":return(0,me.jsx)(mr,{label:r,value:d,onChange:c=>a(r,c)});case"env":return(0,me.jsx)(z0,{label:r,value:d||{},onChange:c=>a(r,c)});default:{let c=d!==null&&typeof d=="object",p=i.has(r);return(0,me.jsxs)(me.Fragment,{children:[(0,me.jsxs)("div",{className:"setting-row",children:[(0,me.jsx)("span",{className:"setting-key",children:r}),c?(0,me.jsx)("button",{className:"setting-expand-button",onClick:()=>u(r),children:p?"Collapse":"Expand"}):(0,me.jsx)("span",{className:"setting-value",children:q0(d)})]}),c&&p&&(0,me.jsx)("pre",{className:"setting-json",children:q0(d)})]})}}};return(0,me.jsxs)("div",{className:"setting-section",children:[(0,me.jsx)("h3",{className:"setting-section-title",children:e}),(0,me.jsx)("div",{className:"setting-list",children:t.map(r=>(0,me.jsx)("div",{className:"setting-item",children:f(r)},r))})]})}var xe=v(y(),1),Q0=[{id:"general",label:"General",keys:["proxy","lazyTool","thinking","language","disableSuggestion","memo","messageArchiving","archiveToolUseInputs","planDirectory","agentDepth"]},{id:"plugins",label:"Plugins",keys:["plugins"]},{id:"webServer",label:"Web Server",keys:["webServer"]},{id:"auto",label:"Auto Mode",keys:["autoMode"]},{id:"memory",label:"Memory",keys:["autoMemory","autoDream"]},{id:"model",label:"Model Config",keys:["modelConfig"]},{id:"advanced",label:"Advanced",keys:["env","permissions","sandbox","sessionSummary"]}];function hr(e){return JSON.parse(JSON.stringify(e))}function Ld(e,t){return e===t?!0:typeof e!=typeof t||e===null||t===null?!1:typeof e=="object"?JSON.stringify(e)===JSON.stringify(t):!1}function j0(e,t){let n=new Set([...Object.keys(e),...Object.keys(t)]);return Array.from(n).filter(l=>!Ld(e[l],t[l]))}function Z0({onClose:e}){let{settings:t,modelConfig:n,loading:l,error:a,updateSetting:s,updateModelConfig:i,refresh:o}=M0(),[u,f]=(0,Sn.useState)("general"),[r,d]=(0,Sn.useState)(null),[c,p]=(0,Sn.useState)(null),[b,S]=(0,Sn.useState)(!1),[T,m]=(0,Sn.useState)(null),[g,h]=(0,Sn.useState)(!1);(0,Sn.useEffect)(()=>{t&&r===null&&d(hr(t))},[t,r]),(0,Sn.useEffect)(()=>{n&&c===null&&p(hr(n))},[n,c]);let N=(j,w)=>{d(B=>B&&{...B,[j]:w}),h(!1)},x=j=>{p(j),h(!1)},U=async()=>{if(!t||!r)return;let j=j0(t,r),w=n&&c&&!Ld(n,c);if(!(j.length===0&&!w)){S(!0),m(null),h(!1);try{for(let B of j)await s("project",B,r[B]);w&&c&&await i(c),await o(),d(null),p(null),h(!0)}catch(B){m(B instanceof Error?B.message:"Save failed")}finally{S(!1)}}},k=()=>{t&&d(hr(t)),n&&p(hr(n)),m(null),h(!1)};if(l)return(0,xe.jsx)("div",{className:"settings-panel",children:(0,xe.jsx)("div",{className:"empty-state",children:"Loading settings..."})});if(a)return(0,xe.jsx)("div",{className:"settings-panel",children:(0,xe.jsxs)("div",{className:"settings-error",children:[(0,xe.jsx)("div",{className:"settings-error-message",children:a}),(0,xe.jsx)("button",{className:"settings-close-button",onClick:e,children:"Close"})]})});if(!t||!r||!n||!c)return null;let O=Q0.find(j=>j.id===u),R=j0(t,r),A=n&&c&&!Ld(n,c),H=R.length>0||A;return(0,xe.jsxs)("div",{className:"settings-panel",children:[(0,xe.jsxs)("div",{className:"settings-header",children:[(0,xe.jsx)("h2",{className:"settings-title",children:"Settings"}),(0,xe.jsxs)("div",{className:"settings-header-actions",children:[H&&(0,xe.jsx)("button",{className:"settings-reset-button",onClick:k,disabled:b,children:"Reset"}),(0,xe.jsx)("button",{className:"settings-save-button",onClick:U,disabled:!H||b,children:b?"Saving...":"Save"}),(0,xe.jsx)("button",{className:"settings-close-button",onClick:e,children:"Close"})]})]}),T&&(0,xe.jsx)("div",{className:"settings-save-error",children:T.split(`
98
+ `)):O(`Updated ${E.updated.length} plugin(s)`)}catch(E){k(E instanceof Error?E.message:"Failed to update plugin")}};return(0,G.jsxs)("div",{className:"plugins-setting",children:[s&&(0,G.jsx)("div",{className:"setting-loading",children:"Loading plugins..."}),i&&(0,G.jsx)("div",{className:"setting-error",children:i}),h&&(0,G.jsx)("div",{className:"setting-error",children:h}),x&&(0,G.jsx)("div",{className:"setting-success",children:x}),(0,G.jsx)("div",{className:"plugins-section",children:(0,G.jsx)(ca,{label:"Plugin Settings",value:e||{},fields:[{key:"pluginClaudeCompat",label:"Claude Code plugin compatibility",type:"boolean"},{key:"pluginAutoUpdate",label:"Auto update plugins",type:"boolean"},{key:"pluginAutoUpdateInterval",label:"Auto update interval (minutes)",type:"number",min:1},{key:"pluginSandboxHooks",label:"Sandbox plugin hooks",type:"boolean"}],onChange:t})}),(0,G.jsxs)("div",{className:"plugins-section",children:[(0,G.jsx)("h4",{className:"setting-section-subtitle",children:"Marketplaces"}),(0,G.jsx)("div",{className:"plugin-input-row",children:(0,G.jsx)("input",{className:"setting-input plugin-input",type:"text",value:S,placeholder:"marketplace source (path, URL, or owner/repo)",onChange:M=>T(M.target.value),onKeyDown:M=>{M.key==="Enter"&&R()}})}),(0,G.jsx)("div",{className:"plugin-actions-row",children:(0,G.jsx)("button",{className:"setting-button-small",onClick:R,disabled:!S.trim(),children:"Add Marketplace"})}),(0,G.jsxs)("div",{className:"plugins-list",children:[n.length===0&&!s&&(0,G.jsx)("div",{className:"setting-empty",children:"No marketplaces registered."}),n.map(M=>(0,G.jsxs)("div",{className:"plugin-row",children:[(0,G.jsxs)("div",{className:"plugin-info",children:[(0,G.jsx)("div",{className:"plugin-name",children:M.name}),(0,G.jsxs)("div",{className:"plugin-meta",children:[M.type," \u2014 ",M.source]})]}),(0,G.jsxs)("div",{className:"plugin-actions",children:[(0,G.jsx)("button",{className:"setting-button-small",onClick:()=>H(M.name),children:"Update"}),(0,G.jsx)("button",{className:"setting-button-small",onClick:()=>A(M.name),children:"Remove"})]})]},M.name))]})]}),(0,G.jsxs)("div",{className:"plugins-section",children:[(0,G.jsx)("h4",{className:"setting-section-subtitle",children:"Available Plugins"}),(0,G.jsxs)("div",{className:"plugins-list",children:[a.length===0&&!s&&(0,G.jsx)("div",{className:"setting-empty",children:"No available plugins."}),a.map(M=>(0,G.jsxs)("div",{className:"plugin-row",children:[(0,G.jsxs)("div",{className:"plugin-info",children:[(0,G.jsx)("div",{className:"plugin-name",children:M.plugin}),(0,G.jsxs)("div",{className:"plugin-meta",children:[M.marketplace," \u2014 ",M.description||"No description"]})]}),(0,G.jsx)("div",{className:"plugin-actions",children:(0,G.jsx)("button",{className:"setting-button-small",onClick:()=>j(`${M.plugin}@${M.marketplace}`),children:"Install"})})]},`${M.plugin}@${M.marketplace}`))]})]}),(0,G.jsxs)("div",{className:"plugins-section",children:[(0,G.jsx)("h4",{className:"setting-section-subtitle",children:"Installed Plugins"}),(0,G.jsx)("div",{className:"plugin-input-row",children:(0,G.jsx)("input",{className:"setting-input plugin-input",type:"text",value:m,placeholder:"plugin[@marketplace]",onChange:M=>g(M.target.value),onKeyDown:M=>{M.key==="Enter"&&j()}})}),(0,G.jsxs)("div",{className:"plugin-actions-row",children:[(0,G.jsx)("button",{className:"setting-button-small",onClick:()=>j(),disabled:!m.trim(),children:"Install"}),(0,G.jsx)("button",{className:"setting-button-small",onClick:()=>B(),children:"Update All"})]}),(0,G.jsxs)("div",{className:"plugins-list",children:[l.length===0&&!s&&(0,G.jsx)("div",{className:"setting-empty",children:"No plugins installed."}),l.map(M=>(0,G.jsxs)("div",{className:"plugin-row",children:[(0,G.jsxs)("div",{className:"plugin-info",children:[(0,G.jsx)("div",{className:"plugin-name",children:M.plugin}),(0,G.jsxs)("div",{className:"plugin-meta",children:[M.marketplace," \u2014 ",M.version," \u2014 ",M.enabled?"enabled":"disabled"]})]}),(0,G.jsxs)("div",{className:"plugin-actions",children:[M.enabled?(0,G.jsx)("button",{className:"setting-button-small",onClick:()=>b(M.id),children:"Disable"}):(0,G.jsx)("button",{className:"setting-button-small",onClick:()=>p(M.id),children:"Enable"}),(0,G.jsx)("button",{className:"setting-button-small",onClick:()=>B(M.id),children:"Update"}),(0,G.jsx)("button",{className:"setting-button-small",onClick:()=>w(M.id),children:"Uninstall"})]})]},M.id))]})]})]})}var me=v(y(),1);function q0(e){return e===void 0?"undefined":e===null?"null":typeof e=="boolean"?e?"true":"false":typeof e=="string"?e:JSON.stringify(e,null,2)}function Y0({label:e,keys:t,settings:n,modelConfig:l,onUpdate:a,onModelConfigUpdate:s}){let[i,o]=(0,G0.useState)(new Set),u=r=>{o(d=>{let c=new Set(d);return c.has(r)?c.delete(r):c.add(r),c})},f=r=>{let d=n[r];switch(r){case"proxy":case"disableSuggestion":case"memo":case"messageArchiving":case"archiveToolUseInputs":return(0,me.jsx)(fr,{label:r==="archiveToolUseInputs"?"Archive Tool Use Inputs":r,value:!!d,onChange:c=>a(r,c)});case"lazyTool":return(0,me.jsx)(Ud,{label:r,value:d==="off"||d==="loading"||d==="proxy"?d:d===!0?"loading":d===!1?"off":"loading",options:["off","loading","proxy"],onChange:c=>a(r,c)});case"plugins":return(0,me.jsx)(H0,{value:d||{},onChange:c=>a(r,c)});case"thinking":return(0,me.jsx)(Ud,{label:r,value:d||"medium",options:["off","low","medium","high"],onChange:c=>a(r,c)});case"language":case"planDirectory":return(0,me.jsx)(dr,{label:r,value:d||"",placeholder:r==="planDirectory"?"/path/to/plan/directory":"auto",onChange:c=>a(r,c)});case"agentDepth":return(0,me.jsx)(pr,{label:r,value:typeof d=="number"?d:1,min:1,max:5,onChange:c=>a(r,c)});case"webServer":return(0,me.jsx)(ca,{label:"Web Server",value:d||{},fields:[{key:"enabled",label:"Enabled",type:"boolean"},{key:"port",label:"Port",type:"number",min:1,max:65535},{key:"host",label:"Host",type:"string"}],onChange:c=>a(r,c)});case"autoMode":return(0,me.jsx)(ca,{label:"Auto Mode",value:d||{},fields:[{key:"enabled",label:"Enabled",type:"boolean"},{key:"model",label:"Model",type:"string"},{key:"maxConsecutiveDenials",label:"Max Consecutive Denials",type:"number",min:0},{key:"maxTotalDenials",label:"Max Total Denials",type:"number",min:0}],onChange:c=>a(r,c)});case"autoMemory":return(0,me.jsx)(ca,{label:"Auto Memory",value:d||{},fields:[{key:"enabled",label:"Enabled",type:"boolean"},{key:"minTokens",label:"Min Tokens",type:"number",min:0},{key:"minTurns",label:"Min Turns",type:"number",min:0},{key:"teamMemoryEnabled",label:"Team Memory Enabled",type:"boolean"}],onChange:c=>a(r,c)});case"autoDream":return(0,me.jsx)(ca,{label:"Auto Dream",value:d||{},fields:[{key:"enabled",label:"Enabled",type:"boolean"},{key:"minHours",label:"Min Hours",type:"number",min:0},{key:"minSessions",label:"Min Sessions",type:"number",min:0}],onChange:c=>a(r,c)});case"modelConfig":return(0,me.jsx)(L0,{value:l||{sources:{},routing:{}},onChange:c=>s?.(c)});case"sandbox":case"sessionSummary":case"permissions":return(0,me.jsx)(mr,{label:r,value:d,onChange:c=>a(r,c)});case"env":return(0,me.jsx)(z0,{label:r,value:d||{},onChange:c=>a(r,c)});default:{let c=d!==null&&typeof d=="object",p=i.has(r);return(0,me.jsxs)(me.Fragment,{children:[(0,me.jsxs)("div",{className:"setting-row",children:[(0,me.jsx)("span",{className:"setting-key",children:r}),c?(0,me.jsx)("button",{className:"setting-expand-button",onClick:()=>u(r),children:p?"Collapse":"Expand"}):(0,me.jsx)("span",{className:"setting-value",children:q0(d)})]}),c&&p&&(0,me.jsx)("pre",{className:"setting-json",children:q0(d)})]})}}};return(0,me.jsxs)("div",{className:"setting-section",children:[(0,me.jsx)("h3",{className:"setting-section-title",children:e}),(0,me.jsx)("div",{className:"setting-list",children:t.map(r=>(0,me.jsx)("div",{className:"setting-item",children:f(r)},r))})]})}var xe=v(y(),1),Q0=[{id:"general",label:"General",keys:["proxy","lazyTool","thinking","language","disableSuggestion","memo","messageArchiving","archiveToolUseInputs","planDirectory","agentDepth"]},{id:"plugins",label:"Plugins",keys:["plugins"]},{id:"webServer",label:"Web Server",keys:["webServer"]},{id:"auto",label:"Auto Mode",keys:["autoMode"]},{id:"memory",label:"Memory",keys:["autoMemory","autoDream"]},{id:"model",label:"Model Config",keys:["modelConfig"]},{id:"advanced",label:"Advanced",keys:["env","permissions","sandbox","sessionSummary"]}];function hr(e){return JSON.parse(JSON.stringify(e))}function Ld(e,t){return e===t?!0:typeof e!=typeof t||e===null||t===null?!1:typeof e=="object"?JSON.stringify(e)===JSON.stringify(t):!1}function j0(e,t){let n=new Set([...Object.keys(e),...Object.keys(t)]);return Array.from(n).filter(l=>!Ld(e[l],t[l]))}function Z0({onClose:e}){let{settings:t,modelConfig:n,loading:l,error:a,updateSetting:s,updateModelConfig:i,refresh:o}=M0(),[u,f]=(0,Sn.useState)("general"),[r,d]=(0,Sn.useState)(null),[c,p]=(0,Sn.useState)(null),[b,S]=(0,Sn.useState)(!1),[T,m]=(0,Sn.useState)(null),[g,h]=(0,Sn.useState)(!1);(0,Sn.useEffect)(()=>{t&&r===null&&d(hr(t))},[t,r]),(0,Sn.useEffect)(()=>{n&&c===null&&p(hr(n))},[n,c]);let N=(j,w)=>{d(B=>B&&{...B,[j]:w}),h(!1)},x=j=>{p(j),h(!1)},U=async()=>{if(!t||!r)return;let j=j0(t,r),w=n&&c&&!Ld(n,c);if(!(j.length===0&&!w)){S(!0),m(null),h(!1);try{for(let B of j)await s("project",B,r[B]);w&&c&&await i(c),await o(),d(null),p(null),h(!0)}catch(B){m(B instanceof Error?B.message:"Save failed")}finally{S(!1)}}},k=()=>{t&&d(hr(t)),n&&p(hr(n)),m(null),h(!1)};if(l)return(0,xe.jsx)("div",{className:"settings-panel",children:(0,xe.jsx)("div",{className:"empty-state",children:"Loading settings..."})});if(a)return(0,xe.jsx)("div",{className:"settings-panel",children:(0,xe.jsxs)("div",{className:"settings-error",children:[(0,xe.jsx)("div",{className:"settings-error-message",children:a}),(0,xe.jsx)("button",{className:"settings-close-button",onClick:e,children:"Close"})]})});if(!t||!r||!n||!c)return null;let O=Q0.find(j=>j.id===u),R=j0(t,r),A=n&&c&&!Ld(n,c),H=R.length>0||A;return(0,xe.jsxs)("div",{className:"settings-panel",children:[(0,xe.jsxs)("div",{className:"settings-header",children:[(0,xe.jsx)("h2",{className:"settings-title",children:"Settings"}),(0,xe.jsxs)("div",{className:"settings-header-actions",children:[H&&(0,xe.jsx)("button",{className:"settings-reset-button",onClick:k,disabled:b,children:"Reset"}),(0,xe.jsx)("button",{className:"settings-save-button",onClick:U,disabled:!H||b,children:b?"Saving...":"Save"}),(0,xe.jsx)("button",{className:"settings-close-button",onClick:e,children:"Close"})]})]}),T&&(0,xe.jsx)("div",{className:"settings-save-error",children:T.split(`
99
99
  `).map((j,w)=>(0,xe.jsx)("div",{children:j},w))}),g&&(0,xe.jsx)("div",{className:"settings-save-success",children:"Settings saved successfully"}),(0,xe.jsxs)("div",{className:"settings-layout",children:[(0,xe.jsx)("div",{className:"settings-sidebar",children:Q0.map(j=>(0,xe.jsx)("button",{className:`settings-sidebar-item ${u===j.id?"active":""}`,onClick:()=>f(j.id),children:j.label},j.id))}),(0,xe.jsx)("div",{className:"settings-content",children:(0,xe.jsx)(Y0,{label:O.label,keys:O.keys,settings:r,modelConfig:c,onUpdate:N,onModelConfigUpdate:x})})]})]})}var Ns=v($(),1),ge=v(y(),1),p_="Hawa Code";function X0(){return typeof Notification>"u"?"unsupported":Notification.permission}function V0(e){return e>=70?"high":e>=30?"moderate":"low"}function m_(e){switch(e.toolName){case"Bash":return"Bash command";case"PowerShell":return"PowerShell command";case"Read":return"Read file";case"Write":return"Write file";case"Edit":return"Edit file";case"Glob":case"Grep":return"Read files";case"NotebookEdit":return"Edit notebook";case"Cwd":return"Current directory";default:return"Tool use"}}function Bd(e){switch(e){case"Read":case"Write":case"Edit":return"file_path";case"Glob":case"Grep":return"path";case"NotebookEdit":return"notebook_path";default:return null}}function g_(e){return Bd(e)!==null}function h_(e){let{toolName:t,input:n}=e;if(t==="Bash"||t==="PowerShell"){let a=n.command;if(typeof a=="string")return(0,ge.jsx)("code",{className:"tool-confirm-command",children:a})}let l=Bd(t);if(l){let a=n[l];if(typeof a=="string")return(0,ge.jsxs)("span",{className:"tool-confirm-call",children:[t,"(",(0,ge.jsx)("span",{className:"tool-confirm-path",children:a}),")"]})}return(0,ge.jsx)("pre",{className:"tool-confirm-input",children:JSON.stringify(n,null,2)})}function v_(e){let{toolName:t,input:n,commandPrefix:l,cwd:a,isReadOnly:s}=e,i=[{label:"Yes",decision:"allow"}],o="",u=!1;if(t==="Bash"||t==="PowerShell"){let f=typeof n.command=="string"?n.command:"",r=l||f;r&&(u=!0,o=`Yes, and don't ask again for ${r} commands in ${a}`)}else if(g_(t))if(t==="Read")u=!0,o="Yes, and don't ask again for file reads this session";else if(t==="Glob"||t==="Grep")u=!1;else{let f=Bd(t);(typeof n[f]=="string"?n[f]:"").startsWith(a)&&(u=!0,o="Yes, and don't ask again for file edits this session")}else s||(u=!0,o=`Yes, and don't ask again for ${t} commands in ${a}`);return u&&i.push({label:o,decision:"allow_permanent"}),i.push({label:`No, and tell ${p_} what to do differently (esc)`,decision:"reject"}),i}function K0({queue:e,onDecision:t}){let[n,l]=(0,Ns.useState)(X0),[a,s]=(0,Ns.useState)(!1),[i,o]=(0,Ns.useState)(null);(0,Ns.useEffect)(()=>{let T=setInterval(()=>{l(X0())},1e3);return()=>clearInterval(T)},[]);let u=async T=>{if(T.preventDefault(),T.stopPropagation(),console.log("[ToolConfirmQueue] Enable notifications clicked"),typeof Notification>"u"){console.warn("[ToolConfirmQueue] Notification API not available"),o("Notifications are not supported in this browser.");return}if(!window.isSecureContext){console.warn("[ToolConfirmQueue] Not a secure context"),o("Notifications require a secure context (HTTPS or localhost).");return}if(window.self!==window.top){console.warn("[ToolConfirmQueue] Running in iframe"),o("Please allow notifications in the top-level browser window.");return}s(!0),o(null);let m=5e3,g=new Promise((h,N)=>{setTimeout(()=>N(new Error("timeout")),m)});try{console.log("[ToolConfirmQueue] Requesting notification permission...");let h=await Promise.race([Notification.requestPermission(),g]);console.log("[ToolConfirmQueue] Notification permission result:",h),l(h),o(h==="granted"?"Notifications enabled.":h==="denied"?"Notifications blocked in browser settings.":"Permission prompt was dismissed. Check browser notification settings.")}catch(h){h instanceof Error&&h.message==="timeout"?(console.warn("[ToolConfirmQueue] Notification permission request timed out"),o("Browser did not respond. Please allow notifications manually in site settings.")):(console.error("[ToolConfirmQueue] Failed to request notification permission:",h),o(`Failed to request notifications: ${h instanceof Error?h.message:String(h)}`))}finally{s(!1)}};if(e.length===0)return null;let f=e[0],{toolUseID:r,description:d,hookWarning:c,riskScore:p}=f,b=m_(f),S=v_(f);return(0,ge.jsx)("div",{className:"tool-confirm-overlay",children:(0,ge.jsxs)("div",{className:"tool-confirm-card",children:[(0,ge.jsxs)("div",{className:"tool-confirm-header",children:[(0,ge.jsx)("h3",{className:"tool-confirm-title",children:b}),e.length>1&&(0,ge.jsxs)("span",{className:"tool-confirm-queue-count",children:[e.length," pending"]})]}),(0,ge.jsxs)("div",{className:"tool-confirm-body",children:[(0,ge.jsx)("div",{className:"tool-confirm-section",children:h_(f)}),d&&(0,ge.jsx)("div",{className:"tool-confirm-section",children:(0,ge.jsx)("p",{className:"tool-confirm-description",children:d})}),c&&(0,ge.jsx)("div",{className:"tool-confirm-warning",children:c}),p!=null&&(0,ge.jsxs)("div",{className:`tool-confirm-risk tool-confirm-risk-${V0(p)}`,children:["Risk: ",V0(p)]}),(0,ge.jsx)("div",{className:"tool-confirm-question",children:"Do you want to proceed?"})]}),(0,ge.jsx)("div",{className:"tool-confirm-actions",children:S.map(T=>{let m="tool-confirm-btn";return T.decision==="allow"?m+=" tool-confirm-allow":T.decision==="allow_permanent"?m+=" tool-confirm-allow-permanent":T.decision==="reject"&&(m+=" tool-confirm-reject"),(0,ge.jsx)("button",{className:m,onClick:()=>t(r,T.decision),children:T.label},T.decision)})}),n==="default"&&(0,ge.jsxs)("div",{className:"tool-confirm-notification-banner",children:[(0,ge.jsx)("span",{children:"You may miss confirmation alerts when the page is hidden. Enable background notifications."}),(0,ge.jsx)("button",{type:"button",onClick:u,disabled:a,children:a?"Requesting\u2026":"Enable notifications"})]}),i&&(0,ge.jsx)("div",{className:`tool-confirm-notification-banner ${n==="granted"?"tool-confirm-notification-granted":n==="denied"?"tool-confirm-notification-denied":"tool-confirm-notification-info"}`,children:(0,ge.jsx)("span",{children:i})}),n==="denied"&&!i&&(0,ge.jsx)("div",{className:"tool-confirm-notification-banner tool-confirm-notification-denied",children:(0,ge.jsx)("span",{children:"Browser notifications are blocked. Please allow them in your browser settings."})})]})})}var de=v(y(),1);function $0(){let t=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`,{rawMessages:n,agents:l,status:a,confirmQueue:s,sendConfirmResponse:i,sendPrompt:o,sendInterrupt:u,promptStatus:f,pendingUserResponses:r,sendUserResponse:d}=zv(t),{userType:c}=Uv(),[p,b]=(0,Cl.useState)("main"),[S,T]=(0,Cl.useState)(!0),[m,g]=(0,Cl.useState)(!1),[h,N]=(0,Cl.useState)(()=>{try{return localStorage.getItem("hawa.sidebarCollapsed")==="true"}catch{return!1}});(0,Cl.useEffect)(()=>{try{localStorage.setItem("hawa.sidebarCollapsed",String(h))}catch{}},[h]),(0,Cl.useEffect)(()=>{l.length>0&&p&&!l.find(w=>w.id===p)&&b(l[0].id)},[l,p]);let x=n[p]||[],U=l.find(w=>w.id===p),k=p==="main"&&(U?.status==="running"||U?.status==="started"),O=l.filter(w=>w.status==="running"||w.status==="started"),R=p!=="main"&&U?.status==="ended",A=w=>{o(p,w)},H=()=>{u(p)},j=r.size>0;return(0,de.jsxs)("div",{className:"app",children:[(0,de.jsxs)("div",{className:`left-sidebar ${h?"collapsed":""}`,children:[(0,de.jsxs)("div",{className:"sidebar-header",children:[(0,de.jsx)("button",{className:"collapse-button",onClick:()=>N(!h),title:h?"Expand sidebar":"Collapse sidebar",children:h?"\u226B":"\u2261"}),!h&&(0,de.jsx)("span",{className:"sidebar-title",children:"Hawa Code"})]}),(0,de.jsx)(Hv,{agents:l,activeAgent:p,onSelect:w=>{g(!1),b(w)},collapsed:h}),(0,de.jsxs)("div",{className:"sidebar-footer",children:[!h&&(0,de.jsxs)("div",{className:"sidebar-stats",children:["Agents: ",l.length||1," (",l.length>0?O.length:1," active)"]}),(0,de.jsxs)("button",{className:`sidebar-button ${m?"active":""}`,onClick:()=>{m||b(""),g(!m)},title:"Settings",children:[(0,de.jsx)("span",{className:"sidebar-button-icon",children:"\u2699"}),!h&&(0,de.jsx)("span",{className:"sidebar-button-text",children:"Settings"})]})]})]}),(0,de.jsxs)("div",{className:"main-content",children:[(0,de.jsxs)("div",{className:"header",children:[(0,de.jsx)("span",{className:"header-title",children:m?"Settings":"Agent Viewer"}),(0,de.jsxs)("div",{className:"header-status",children:[(0,de.jsxs)("span",{children:["Messages: ",x.length]}),(0,de.jsx)("span",{className:`status-dot ${a}`}),(0,de.jsx)("span",{children:a==="connected"?"Connected":a==="connecting"?"Connecting...":"Disconnected"})]})]}),m?(0,de.jsx)(Z0,{onClose:()=>g(!1)}):(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)(x0,{rawMessages:x,autoScroll:S,userType:c,pendingUserResponses:r,sendUserResponse:d}),!S&&(0,de.jsx)("button",{className:"auto-scroll-toggle",onClick:()=>T(!0),children:"Resume auto-scroll"}),!j&&!R&&(0,de.jsx)(A0,{activeAgent:p,isLoading:k,promptStatus:f,onSubmit:A,onInterrupt:H})]})]}),(0,de.jsx)(K0,{queue:s,onDecision:i})]})}var W0=v(y(),1),J0=document.getElementById("root");J0&&(0,P0.createRoot)(J0).render((0,W0.jsx)($0,{}));
100
100
  /*! Bundled license information:
101
101