@hermenics/deepseek-code 0.6.22 → 0.6.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/LICENSE +1 -1
  2. package/dist/cli.mjs +3 -3
  3. package/package.json +1 -1
package/LICENSE CHANGED
@@ -175,7 +175,7 @@
175
175
 
176
176
  END OF TERMS AND CONDITIONS
177
177
 
178
- Copyright 2026 Marcelo Henry
178
+ Copyright 2026 Hermenics
179
179
 
180
180
  Licensed under the Apache License, Version 2.0 (the "License");
181
181
  you may not use this file except in compliance with the License.
package/dist/cli.mjs CHANGED
@@ -910,7 +910,7 @@ For each issue found, show the problematic snippet and the suggested fix. Be dir
910
910
  `),i=0,_="";if(h[0]?.trim()==="---"){let w=h.findIndex((D,$)=>$>0&&D.trim()==="---");if(w<0)return null;for(let D of h.slice(1,w)){let $=/^description\s*:\s*(.*)$/i.exec(D.trim());if($)_=ojh($[1].trim())}i=w+1}let f=h.slice(i).join(`
911
911
  `).trim();if(!f)return null;return{description:_||"Custom prompt command",prompt:f}}async function eEt(t,h){let i;try{if((await og(t)).isSymbolicLink())return[];i=await kEt(t)}catch{return[]}let _=(await Bjh(t,{withFileTypes:!0}).catch(()=>[])).filter((f)=>f.name.endsWith(".md")&&(f.isFile()||f.isSymbolicLink())).slice(0,yjh);return(await Promise.all(_.map(async(f)=>{let w=f.name.slice(0,-3);if(!Ijh.test(w))return;let D=bN(t,f.name);try{let $=await kEt(D);if(!gjh(i,$))return;if((await ljh($)).size>Ujh)return;let n=xjh(await Fjh($,"utf8"));return n?{name:w,...n,path:D,source:h}:void 0}catch{return}}))).filter((f)=>Boolean(f))}async function sjh(t){let h=await mjh(t),i=[...await Promise.all(h.map((f)=>eEt(f,"project"))),await eEt(bN(cjh(),".deepseek","commands"),"user")],_=new Map;for(let f of i.flat())if(!_.has(f.name))_.set(f.name,f);return[..._.values()]}async function B7(t){cN=new Map((await sjh(t)).map((h)=>[h.name,h]))}function VEt(){return[...cN.keys()].map((t)=>`/${t}`)}function jEt(){return Object.fromEntries([...cN.values()].map((t)=>[`/${t.name}`,t.description]))}function djh(t,h){let i=h?h.split(/\s+/):[],_=t.replace(/\$ARGUMENTS\b/g,h);return _=_.replace(/\$(\d+)/g,(f,w)=>i[Number(w)-1]??""),h&&!t.includes("$ARGUMENTS")&&!/\$\d+/.test(t)?`${_}
912
912
 
913
- Arguments: ${h}`:_}async function BEt(t,h){let i=/^\/([a-z0-9][a-z0-9-]{0,63})(?:\s+([\s\S]*))?$/.exec(t.trim());if(!i)return null;await B7(h);let _=cN.get(i[1]);if(!_)return null;return{type:"custom",name:_.name,prompt:djh(_.prompt,i[2]?.trim()??"")}}var yjh=256,Ujh=131072,Ijh,cN;var kA=L(()=>{Ijh=/^[a-z0-9][a-z0-9-]{0,63}$/,cN=new Map});import{homedir as pjh}from"os";import{isAbsolute as ajh,join as kN,relative as tBh,resolve as hBh,dirname as iBh}from"path";import{lstat as xg,readdir as _Bh,readFile as fBh,realpath as FEt}from"fs/promises";async function DBh(t){try{return await xg(t),!0}catch{return!1}}function rBh(t,h){let i=tBh(t,h);return i===""||!i.startsWith("..")&&!ajh(i)}async function $Bh(t){let h=[],i=hBh(t);while(!0){let _=kN(i,".deepseek","workflows");try{if((await xg(_)).isDirectory())h.push(_)}catch{}if(await DBh(kN(i,".git")))break;let f=iBh(i);if(f===i)break;i=f}return h}async function lEt(t,h){let i;try{if((await xg(t)).isSymbolicLink())return[];i=await FEt(t)}catch{return[]}let _=(await _Bh(t,{withFileTypes:!0}).catch(()=>[])).filter((f)=>f.name.endsWith(".js")&&(f.isFile()||f.isSymbolicLink())).slice(0,wBh);return(await Promise.all(_.map(async(f)=>{let w=kN(t,f.name);try{let D=await FEt(w);if(!rBh(i,D))return;return{meta:X5(await fBh(D,"utf8")).meta,path:w,source:h}}catch{return}}))).filter((f)=>Boolean(f))}async function eN(t,h={}){let i=await $Bh(t),_=h.globalDirectory??kN(pjh(),".deepseek","workflows"),f=[...await Promise.all(i.map((D)=>lEt(D,"project"))),await lEt(_,"user")],w=new Map;for(let D of f.flat())if(!w.has(D.meta.name))w.set(D.meta.name,D);return[...w.values()]}var wBh=256;var sg=L(()=>{WA()});import{readFile as KBh}from"fs/promises";async function F7(t){eA=new Map((await eN(t)).map((h)=>[h.meta.name,h]))}function yEt(){return[...eA.keys()].map((t)=>`/${t}`)}function UEt(){return Object.fromEntries([...eA.values()].map((t)=>[`/${t.meta.name}`,t.meta.description??"Saved Dynamic Workflow"]))}async function IEt(t,h){let i=/^\/([a-z0-9][a-z0-9-]{0,63})(?:\s+([\s\S]*))?$/.exec(t.trim());if(!i)return null;if(await F7(h),!eA.has(i[1]))return null;return{type:"workflow",action:"run",name:i[1],args:i[2]}}async function VN(t,h){await F7(h);let i=eA.get(t);if(!i)throw Error(`Workflow '${t}' not found`);return KBh(i.path,"utf8")}var eA;var su=L(()=>{sg();eA=new Map});var nBh,gEt;var QEt=L(()=>{nBh={name:"goal",aliases:[],description:"Set, view, or manage a persistent goal. Usage: /goal [<objective> [--turns <n>]]",parse(t){if(t.length===0)return{type:"goal",action:"show"};let h=t[0].toLowerCase();if(h==="edit")return{type:"goal",action:"edit"};if(h==="pause")return{type:"goal",action:"pause"};if(h==="resume")return{type:"goal",action:"resume"};if(h==="clear")return{type:"goal",action:"clear"};let i=t.indexOf("--turns"),_;if(i!==-1&&i+1<t.length){if(_=parseInt(t[i+1],10),isNaN(_)||_<=0)_=void 0}return{type:"goal",action:"set",objective:i===-1?t.join(" ").trim():t.filter((w,D)=>D!==i&&D!==i+1).join(" ").trim(),maxContinuations:_}}},gEt=nBh});var uBh,zBh,mEt;var oEt=L(()=>{uBh=new Set(["pause","resume","stop","restart"]),zBh={name:"workflow",aliases:[],description:"Run or control a Dynamic Workflow",parse(t){let[h,i,..._]=t;if(h==="run"&&i)return{type:"workflow",action:"run",name:i,args:_.join(" ")||void 0};if(h==="save"&&i&&_[0])return{type:"workflow",action:"save",id:i,name:_[0]};if(h&&uBh.has(h)&&i)return{type:"workflow",action:h,id:i};return{type:"unknown",input:"Usage: /workflow run <name> [args-json] | pause|resume|stop|restart <run-id> | save <run-id> <name>"}}},mEt=zBh});var qBh,xEt;var sEt=L(()=>{qBh={name:"workflows",aliases:[],description:"Monitor Dynamic Workflow runs",parse(){return{type:"workflows"}}},xEt=qBh});function pg(t){let h=t.trim();if(!h.startsWith("/"))return null;let[i,..._]=h.slice(1).split(/\s+/);for(let f of dg)if(f.name===i||f.aliases.includes(i))return f.parse(_);return{type:"unknown",input:`Unknown command: /${i}. Use /help to see available commands.`}}async function jN(t,h){let i=pg(t);if(i?.type!=="unknown")return i;let _=t.trim().slice(1).split(/\s+/,1)[0];if(VA.includes(`/${_}`))return i;return await IEt(t,h)??await BEt(t,h)??i}var dg,VA,BN;var jA=L(()=>{Ig();nSt();zSt();OSt();HSt();Qg();YSt();XSt();LSt();CSt();ESt();ZSt();vSt();bSt();kSt();VSt();BSt();lSt();USt();gSt();mSt();xSt();dSt();aSt();hEt();_Et();wEt();$Et();nEt();zEt();OEt();HEt();WEt();JEt();PEt();TEt();SEt();cEt();kA();su();QEt();oEt();sEt();Ig();Qg();dg=[$St,KSt,uSt,qSt,MSt,ASt,WSt,JSt,PSt,TSt,SSt,NSt,GSt,RSt,cSt,eSt,jSt,FSt,ySt,ISt,QSt,oSt,sSt,pSt,tEt,iEt,fEt,rEt,KEt,uEt,qEt,MEt,AEt,YEt,XEt,LEt,CEt,gEt,mEt,xEt,bEt];VA=dg.flatMap((t)=>[`/${t.name}`,...t.aliases.map((h)=>`/${h}`)]),BN=Object.fromEntries(dg.flatMap((t)=>[[`/${t.name}`,t.description],...t.aliases.map((h)=>[`/${h}`,t.description])]))});var d_;var f$=L(()=>{d_={name:"@hermenics/deepseek-code",version:"0.6.22",description:"An AI-powered coding assistant that lives in your terminal",keywords:["ai","cli","deepseek","coding-assistant","terminal","tui"],license:"Apache-2.0",type:"module",bin:{deepseek:"dist/deepseek.mjs"},files:["dist/","README.md","LICENSE"],repository:{type:"git",url:"git+https://github.com/Hermenics/deepseek-code.git"},bugs:{url:"https://github.com/Hermenics/deepseek-code/issues"},homepage:"https://github.com/Hermenics/deepseek-code#readme",publishConfig:{access:"public"},engines:{bun:">=1.1"},scripts:{start:"NODE_ENV=development bun src/index.tsx",dev:"NODE_ENV=development bun --watch src/index.tsx",build:"bun run build.ts",typecheck:"bunx tsc --noEmit",test:"bun test tests","test:coverage":"bun test tests --coverage --coverage-reporter=lcov --coverage-dir=coverage","test:ink":"bun test tests/ink","test:plugins":"bun test tests/plugins","pack:check":"./scripts/verify-package.sh"},dependencies:{"@alcalzone/ansi-tokenize":"^0.3.0","@aws-crypto/sha256-js":"^5.2.0","@aws-sdk/client-bedrock":"^3.1048.0","@aws-sdk/credential-providers":"^3.1048.0","@modelcontextprotocol/sdk":"^1.29.0","@smithy/protocol-http":"^5.3.14","@smithy/signature-v4":"^5.3.14","@types/semver":"^7.7.1","@xterm/xterm":"^6.0.0",ajv:"^8.20.0","auto-bind":"^5.0.1","bidi-js":"^1.0.3",chalk:"^5.6.2","cli-boxes":"^4.0.1","code-excerpt":"^4.0.0","emoji-regex":"^10.6.0",execa:"^9.6.1","fast-glob":"^3.3.3","fuse.js":"^7.0.0","get-east-asian-width":"^1.6.0","google-auth-library":"^10.6.2",ignore:"^7.0.6","indent-string":"^5.0.0","lodash-es":"^4.18.1",openai:"^6.34.0",qrcode:"^1.5.4",react:"^19.2.0","react-reconciler":"^0.33.0",semver:"^7.8.1","signal-exit":"^4.1.0","stack-utils":"^2.0.6","strip-ansi":"^7.2.0","supports-hyperlinks":"^4.4.0","type-fest":"^5.6.0","usehooks-ts":"^3.1.1","wrap-ansi":"^10.0.0"},overrides:{"node-fetch":"npm:undici@^7.29.0",undici:"^7.29.0","fast-uri":"^3.1.5",hono:"^4.13.1","ip-address":"^10.5.0"},devDependencies:{"@types/bun":"^1.3.12","@types/qrcode":"^1.5.6","@types/react":"^19.2.0","@types/stack-utils":"^2.0.3","react-devtools-core":"^7.0.1",typescript:"^5.9.3"}}});var MBh,dEt;var pEt=L(()=>{jA();f$();MBh=`
913
+ Arguments: ${h}`:_}async function BEt(t,h){let i=/^\/([a-z0-9][a-z0-9-]{0,63})(?:\s+([\s\S]*))?$/.exec(t.trim());if(!i)return null;await B7(h);let _=cN.get(i[1]);if(!_)return null;return{type:"custom",name:_.name,prompt:djh(_.prompt,i[2]?.trim()??"")}}var yjh=256,Ujh=131072,Ijh,cN;var kA=L(()=>{Ijh=/^[a-z0-9][a-z0-9-]{0,63}$/,cN=new Map});import{homedir as pjh}from"os";import{isAbsolute as ajh,join as kN,relative as tBh,resolve as hBh,dirname as iBh}from"path";import{lstat as xg,readdir as _Bh,readFile as fBh,realpath as FEt}from"fs/promises";async function DBh(t){try{return await xg(t),!0}catch{return!1}}function rBh(t,h){let i=tBh(t,h);return i===""||!i.startsWith("..")&&!ajh(i)}async function $Bh(t){let h=[],i=hBh(t);while(!0){let _=kN(i,".deepseek","workflows");try{if((await xg(_)).isDirectory())h.push(_)}catch{}if(await DBh(kN(i,".git")))break;let f=iBh(i);if(f===i)break;i=f}return h}async function lEt(t,h){let i;try{if((await xg(t)).isSymbolicLink())return[];i=await FEt(t)}catch{return[]}let _=(await _Bh(t,{withFileTypes:!0}).catch(()=>[])).filter((f)=>f.name.endsWith(".js")&&(f.isFile()||f.isSymbolicLink())).slice(0,wBh);return(await Promise.all(_.map(async(f)=>{let w=kN(t,f.name);try{let D=await FEt(w);if(!rBh(i,D))return;return{meta:X5(await fBh(D,"utf8")).meta,path:w,source:h}}catch{return}}))).filter((f)=>Boolean(f))}async function eN(t,h={}){let i=await $Bh(t),_=h.globalDirectory??kN(pjh(),".deepseek","workflows"),f=[...await Promise.all(i.map((D)=>lEt(D,"project"))),await lEt(_,"user")],w=new Map;for(let D of f.flat())if(!w.has(D.meta.name))w.set(D.meta.name,D);return[...w.values()]}var wBh=256;var sg=L(()=>{WA()});import{readFile as KBh}from"fs/promises";async function F7(t){eA=new Map((await eN(t)).map((h)=>[h.meta.name,h]))}function yEt(){return[...eA.keys()].map((t)=>`/${t}`)}function UEt(){return Object.fromEntries([...eA.values()].map((t)=>[`/${t.meta.name}`,t.meta.description??"Saved Dynamic Workflow"]))}async function IEt(t,h){let i=/^\/([a-z0-9][a-z0-9-]{0,63})(?:\s+([\s\S]*))?$/.exec(t.trim());if(!i)return null;if(await F7(h),!eA.has(i[1]))return null;return{type:"workflow",action:"run",name:i[1],args:i[2]}}async function VN(t,h){await F7(h);let i=eA.get(t);if(!i)throw Error(`Workflow '${t}' not found`);return KBh(i.path,"utf8")}var eA;var su=L(()=>{sg();eA=new Map});var nBh,gEt;var QEt=L(()=>{nBh={name:"goal",aliases:[],description:"Set, view, or manage a persistent goal. Usage: /goal [<objective> [--turns <n>]]",parse(t){if(t.length===0)return{type:"goal",action:"show"};let h=t[0].toLowerCase();if(h==="edit")return{type:"goal",action:"edit"};if(h==="pause")return{type:"goal",action:"pause"};if(h==="resume")return{type:"goal",action:"resume"};if(h==="clear")return{type:"goal",action:"clear"};let i=t.indexOf("--turns"),_;if(i!==-1&&i+1<t.length){if(_=parseInt(t[i+1],10),isNaN(_)||_<=0)_=void 0}return{type:"goal",action:"set",objective:i===-1?t.join(" ").trim():t.filter((w,D)=>D!==i&&D!==i+1).join(" ").trim(),maxContinuations:_}}},gEt=nBh});var uBh,zBh,mEt;var oEt=L(()=>{uBh=new Set(["pause","resume","stop","restart"]),zBh={name:"workflow",aliases:[],description:"Run or control a Dynamic Workflow",parse(t){let[h,i,..._]=t;if(h==="run"&&i)return{type:"workflow",action:"run",name:i,args:_.join(" ")||void 0};if(h==="save"&&i&&_[0])return{type:"workflow",action:"save",id:i,name:_[0]};if(h&&uBh.has(h)&&i)return{type:"workflow",action:h,id:i};return{type:"unknown",input:"Usage: /workflow run <name> [args-json] | pause|resume|stop|restart <run-id> | save <run-id> <name>"}}},mEt=zBh});var qBh,xEt;var sEt=L(()=>{qBh={name:"workflows",aliases:[],description:"Monitor Dynamic Workflow runs",parse(){return{type:"workflows"}}},xEt=qBh});function pg(t){let h=t.trim();if(!h.startsWith("/"))return null;let[i,..._]=h.slice(1).split(/\s+/);for(let f of dg)if(f.name===i||f.aliases.includes(i))return f.parse(_);return{type:"unknown",input:`Unknown command: /${i}. Use /help to see available commands.`}}async function jN(t,h){let i=pg(t);if(i?.type!=="unknown")return i;let _=t.trim().slice(1).split(/\s+/,1)[0];if(VA.includes(`/${_}`))return i;return await IEt(t,h)??await BEt(t,h)??i}var dg,VA,BN;var jA=L(()=>{Ig();nSt();zSt();OSt();HSt();Qg();YSt();XSt();LSt();CSt();ESt();ZSt();vSt();bSt();kSt();VSt();BSt();lSt();USt();gSt();mSt();xSt();dSt();aSt();hEt();_Et();wEt();$Et();nEt();zEt();OEt();HEt();WEt();JEt();PEt();TEt();SEt();cEt();kA();su();QEt();oEt();sEt();Ig();Qg();dg=[$St,KSt,uSt,qSt,MSt,ASt,WSt,JSt,PSt,TSt,SSt,NSt,GSt,RSt,cSt,eSt,jSt,FSt,ySt,ISt,QSt,oSt,sSt,pSt,tEt,iEt,fEt,rEt,KEt,uEt,qEt,MEt,AEt,YEt,XEt,LEt,CEt,gEt,mEt,xEt,bEt];VA=dg.flatMap((t)=>[`/${t.name}`,...t.aliases.map((h)=>`/${h}`)]),BN=Object.fromEntries(dg.flatMap((t)=>[[`/${t.name}`,t.description],...t.aliases.map((h)=>[`/${h}`,t.description])]))});var d_;var f$=L(()=>{d_={name:"@hermenics/deepseek-code",version:"0.6.23",description:"An AI-powered coding assistant that lives in your terminal",keywords:["ai","cli","deepseek","coding-assistant","terminal","tui"],license:"Apache-2.0",type:"module",bin:{deepseek:"dist/deepseek.mjs"},files:["dist/","README.md","LICENSE"],repository:{type:"git",url:"git+https://github.com/Hermenics/deepseek-code.git"},bugs:{url:"https://github.com/Hermenics/deepseek-code/issues"},homepage:"https://github.com/Hermenics/deepseek-code#readme",publishConfig:{access:"public"},engines:{bun:">=1.1"},scripts:{start:"NODE_ENV=development bun src/index.tsx",dev:"NODE_ENV=development bun --watch src/index.tsx",build:"bun run build.ts",typecheck:"bunx tsc --noEmit",test:"bun test tests","test:coverage":"bun test tests --coverage --coverage-reporter=lcov --coverage-dir=coverage","test:ink":"bun test tests/ink","test:plugins":"bun test tests/plugins","pack:check":"./scripts/verify-package.sh"},dependencies:{"@alcalzone/ansi-tokenize":"^0.3.0","@aws-crypto/sha256-js":"^5.2.0","@aws-sdk/client-bedrock":"^3.1048.0","@aws-sdk/credential-providers":"^3.1048.0","@modelcontextprotocol/sdk":"^1.29.0","@smithy/protocol-http":"^5.3.14","@smithy/signature-v4":"^5.3.14","@types/semver":"^7.7.1","@xterm/xterm":"^6.0.0",ajv:"^8.20.0","auto-bind":"^5.0.1","bidi-js":"^1.0.3",chalk:"^5.6.2","cli-boxes":"^4.0.1","code-excerpt":"^4.0.0","emoji-regex":"^10.6.0",execa:"^9.6.1","fast-glob":"^3.3.3","fuse.js":"^7.0.0","get-east-asian-width":"^1.6.0","google-auth-library":"^10.6.2",ignore:"^7.0.6","indent-string":"^5.0.0","lodash-es":"^4.18.1",openai:"^6.34.0",qrcode:"^1.5.4",react:"^19.2.0","react-reconciler":"^0.33.0",semver:"^7.8.1","signal-exit":"^4.1.0","stack-utils":"^2.0.6","strip-ansi":"^7.2.0","supports-hyperlinks":"^4.4.0","type-fest":"^5.6.0","usehooks-ts":"^3.1.1","wrap-ansi":"^10.0.0"},overrides:{"node-fetch":"npm:undici@^7.29.0",undici:"^7.29.0","fast-uri":"^3.1.5",hono:"^4.13.1","ip-address":"^10.5.0"},devDependencies:{"@types/bun":"^1.3.12","@types/qrcode":"^1.5.6","@types/react":"^19.2.0","@types/stack-utils":"^2.0.3","react-devtools-core":"^7.0.1",typescript:"^5.9.3"}}});var MBh,dEt;var pEt=L(()=>{jA();f$();MBh=`
914
914
  # DeepSeek Code \u2014 Documentation
915
915
 
916
916
  ## What is DeepSeek Code?
@@ -1621,7 +1621,7 @@ ${w.trim()}`)}catch{}return _.join(`
1621
1621
  ${String(l7(t.content))}`}function H2h(t,h){let i=l7(t);if(h==="json")return`${JSON.stringify(i,null,2)}
1622
1622
  `;return["# DeepSeek Code session","",`- ID: ${i.id}`,`- Updated: ${i.updatedAt}`,`- Workspace: ${i.cwd}`,`- Provider/model: ${i.provider} / ${i.model}`,"",...i.uiMessages.map(dRi),""].join(`
1623
1623
  `)}async function pRi(t,h,i=process.cwd()){if(!sRi.test(t))throw Error("Invalid session ID.");let _=await LP(t,i);if(!_)throw Error(`Session ${t} not found.`);let f=V8(i,".deepseek"),w=V8(f,`session-${t}.sanitized.${h}`);return await R6t(f,{recursive:!0}),await gRi(w,H2h(_,h),{encoding:"utf8",mode:384}),w}var v6t=50,sRi;var n2=L(()=>{z3();du();sRi=/^[a-f0-9]{12}$/i});var W2h={};Ui(W2h,{saveUserSettings:()=>V6t,saveSettings:()=>pk,saveProjectSettings:()=>aRi,saveLocalSettings:()=>tbi});function A2h(t,h=""){return Object.entries(t).flatMap(([i,_])=>{let f=h?`${h}.${i}`:i;if(_!==null&&typeof _==="object"&&!Array.isArray(_))return A2h(_,f);return[[f,_]]})}async function pk(t,h){await new U7().setMany(t,A2h(h))}async function V6t(t){return pk("user",t)}async function aRi(t){return pk("project",t)}async function tbi(t){return pk("local",t)}var j6t=L(()=>{M$()});var ak=L(()=>{XD();j6t();M$()});import{dirname as hbi,join as ibi}from"path";import{homedir as _bi}from"os";import{mkdir as fbi}from"fs/promises";function wbi(){return process.env.DEEPSEEK_HISTORY_PATH?.trim()||ibi(_bi(),".deepseek","history.json")}async function W3(t){let h=wbi();await fbi(hbi(h),{recursive:!0});let i=t.length>Y2h?[t[0],...t.slice(-(Y2h-1))]:t;await Rc(h,JSON.stringify(i,null,2))}var Y2h=500;var J2h=L(()=>{z3()});import{join as CP}from"path";import{homedir as Dbi}from"os";import{mkdir as rbi,readdir as X2h,unlink as $bi}from"fs/promises";import{randomBytes as Kbi}from"crypto";function te(){return CP(process.env.HOME||Dbi(),".deepseek","checkpoints")}async function P2h(t,h,i){let _=te();await rbi(_,{recursive:!0});let f=`${Date.now()}-${Kbi(3).toString("hex")}`,w={id:f,timestamp:new Date().toISOString(),label:i??new Date().toLocaleString(),messages:t,filesModified:h};return await fO(CP(_,`${f}.json`),w),await ubi(),f}async function L2h(){try{let t=te(),h=(await X2h(t)).filter((_)=>_.endsWith(".json")).sort().reverse(),i=[];for(let _ of h)try{i.push(await n6(CP(t,_)))}catch{}return i}catch{return[]}}async function T2h(t){if(!nbi.test(t))return null;try{return await n6(CP(te(),`${t}.json`))}catch{return null}}async function ubi(){try{let t=te(),h=(await X2h(t)).filter((i)=>i.endsWith(".json")).sort();for(let i of h.slice(0,Math.max(0,h.length-AXt)))await $bi(CP(t,i)).catch(()=>{})}catch{}}var nbi;var C2h=L(()=>{z3();uD();nbi=/^\d+-[a-f0-9]{6}$/i});import{join as vK}from"path";import{homedir as zbi}from"os";import{mkdir as qbi,readFile as E2h,writeFile as B6t,unlink as S2h}from"fs/promises";import{randomBytes as Obi,createHash as Mbi}from"crypto";function N2h(t){Hbi=t}function Abi(){return vK(process.env.HOME||zbi(),".deepseek-code","checkpoints")}function Z2h(t){return vK(Abi(),t)}function G2h(t){return vK(Z2h(t),"files")}function v2h(t){return vK(Z2h(t),"manifest.json")}function Wbi(t,h){return`${Mbi("sha256").update(`${t}:${h}`).digest("hex").slice(0,8)}.bak`}async function F6t(t){try{return await n6(v2h(t))}catch{return{sessionId:t,entries:[]}}}async function R2h(t){await fO(v2h(t.sessionId),t)}async function b2h(t,h,i){let _=G2h(t);await qbi(_,{recursive:!0});let f=Date.now(),w=Wbi(h,f),D=`${f}-${Obi(3).toString("hex")}`;try{let n=await E2h(h,"utf-8");await B6t(vK(_,w),n,{encoding:"utf8",mode:384})}catch{await B6t(vK(_,w),"",{encoding:"utf8",mode:384})}let $=await F6t(t);$.entries.push({id:D,timestamp:f,path:h,backupFile:w,toolName:i}),await R2h($)}async function c2h(t){let h=await F6t(t);if(h.entries.length===0)return"Nothing to rollback.";let i=[],_=[],f=[...h.entries].reverse();for(let D of f){let $=vK(G2h(t),D.backupFile);try{let n=await E2h($,"utf-8");if(n==="")await S2h(D.path).catch(()=>{});else await B6t(D.path,n,"utf-8");await S2h($).catch(()=>{}),i.push(D.path)}catch(n){_.push(`${D.path}: ${n.message}`)}}h.entries=[],await R2h(h);let w=[`Restored ${i.length} file(s).`];if(_.length)w.push(`Errors: ${_.join(", ")}`);return w.join(`
1624
- `)}async function k2h(t){return[...(await F6t(t)).entries].reverse()}var Hbi=null;var e2h=L(()=>{z3()});function V2h(){return{role:"__compact_boundary__"}}function t7(t){return t.role==="__compact_boundary__"}function he(t){if(t.length===0)return[];let h=-1;for(let w=t.length-1;w>=0;w--)if(t7(t[w])){h=w;break}if(h===-1)return t.filter((w)=>!t7(w));let i=t[0],_=t.slice(h+1).filter((w)=>!t7(w));return i&&!t7(i)&&i.role==="system"?[i,..._]:_}function SP(t,h){if(t==="vertex")return 128000;if(t==="bedrock")return 128000;return Ybi[h]??128000}function ie(t,h){let i=j2h[t]??j2h["deepseek-v4-flash"];return Math.max(0,h.promptTokens-h.cachedTokens)/1e6*i.input+h.cachedTokens/1e6*i.cachedInput+h.completionTokens/1e6*i.output}function l6t(t){if(t<0.0001)return"<$0.0001";return`$${t.toFixed(4)}`}var j2h,Ybi;var B2h=L(()=>{j2h={"deepseek-v4-flash":{input:0.14,cachedInput:0.0028,output:0.28},"deepseek-v4-pro":{input:0.435,cachedInput:0.003625,output:0.87},"deepseek-chat":{input:0.14,cachedInput:0.0028,output:0.28},"deepseek-reasoner":{input:0.14,cachedInput:0.0028,output:0.28}},Ybi={"deepseek-v4-flash":1e6,"deepseek-v4-pro":1e6,"deepseek-chat":1e6,"deepseek-reasoner":1e6}});function F2h(){return{consecutiveFailures:0,lastCompactTimestamp:0}}function _e(t,h){return{enabled:t.compaction?.enabled??t.autoCompact??!0,threshold:t.compaction?.threshold??t.autoCompactThreshold??h,bufferTokens:13000,maxConsecutiveFailures:3}}function l2h(t,h,i,_){if(!i.enabled)return!1;if(_.consecutiveFailures>=i.maxConsecutiveFailures)return!1;if(t<=0||h<=0)return!1;return t/h>i.threshold}var y2h=()=>{};function U2h(t,h={}){let{keepLastN:i=8,maxContentLength:_=200,compactableTools:f=Jbi}=h,w=[...t],D=0,$=new Map;for(let z of w){if(t7(z))continue;let O=z;if(O.role!=="assistant")continue;for(let M of O.tool_calls??[])if(M.function?.name)$.set(M.id,M.function.name)}let n=[];for(let z=0;z<w.length;z++){let O=w[z];if(t7(O))continue;let M=O;if(M.role!=="tool")continue;if(typeof M.content!=="string")continue;if(M.content.length<=_)continue;let A=M.name??$.get(M.tool_call_id??"")??"";if(!f.has(A))continue;n.push({index:z,toolName:A,contentLength:M.content.length})}let u=n.slice(0,Math.max(0,n.length-i));for(let{index:z}of u){let O=w[z],M=O.content?.length??0,A=O.name??$.get(O.tool_call_id??"")??"unknown";w[z]={...O,content:`${Xbi}
1624
+ `)}async function k2h(t){return[...(await F6t(t)).entries].reverse()}var Hbi=null;var e2h=L(()=>{z3()});function V2h(){return{role:"__compact_boundary__"}}function t7(t){return t.role==="__compact_boundary__"}function he(t){if(t.length===0)return[];let h=-1;for(let w=t.length-1;w>=0;w--)if(t7(t[w])){h=w;break}if(h===-1)return t.filter((w)=>!t7(w));let i=t[0],_=t.slice(h+1).filter((w)=>!t7(w));return i&&!t7(i)&&i.role==="system"?[i,..._]:_}function SP(t,h){if(t==="vertex")return 128000;if(t==="bedrock")return 128000;return Ybi[h]??128000}function ie(t,h){let i=j2h[t]??j2h["deepseek-v4-flash"];return Math.max(0,h.promptTokens-h.cachedTokens)/1e6*i.input+h.cachedTokens/1e6*i.cachedInput+h.completionTokens/1e6*i.output}function l6t(t){if(t<0.0001)return"<$0.0001";return`$${t.toFixed(4)}`}var j2h,Ybi;var B2h=L(()=>{j2h={"deepseek-v4-flash":{input:0.14,cachedInput:0.0028,output:0.28},"deepseek-v4-pro":{input:0.435,cachedInput:0.003625,output:0.87},"deepseek-v4-flash-vision-exp":{input:0.14,cachedInput:0.0028,output:0.28},"deepseek-chat":{input:0.14,cachedInput:0.0028,output:0.28},"deepseek-reasoner":{input:0.14,cachedInput:0.0028,output:0.28}},Ybi={"deepseek-v4-flash":1e6,"deepseek-v4-pro":1e6,"deepseek-v4-flash-vision-exp":1e6,"deepseek-chat":1e6,"deepseek-reasoner":1e6}});function F2h(){return{consecutiveFailures:0,lastCompactTimestamp:0}}function _e(t,h){return{enabled:t.compaction?.enabled??t.autoCompact??!0,threshold:t.compaction?.threshold??t.autoCompactThreshold??h,bufferTokens:13000,maxConsecutiveFailures:3}}function l2h(t,h,i,_){if(!i.enabled)return!1;if(_.consecutiveFailures>=i.maxConsecutiveFailures)return!1;if(t<=0||h<=0)return!1;return t/h>i.threshold}var y2h=()=>{};function U2h(t,h={}){let{keepLastN:i=8,maxContentLength:_=200,compactableTools:f=Jbi}=h,w=[...t],D=0,$=new Map;for(let z of w){if(t7(z))continue;let O=z;if(O.role!=="assistant")continue;for(let M of O.tool_calls??[])if(M.function?.name)$.set(M.id,M.function.name)}let n=[];for(let z=0;z<w.length;z++){let O=w[z];if(t7(O))continue;let M=O;if(M.role!=="tool")continue;if(typeof M.content!=="string")continue;if(M.content.length<=_)continue;let A=M.name??$.get(M.tool_call_id??"")??"";if(!f.has(A))continue;n.push({index:z,toolName:A,contentLength:M.content.length})}let u=n.slice(0,Math.max(0,n.length-i));for(let{index:z}of u){let O=w[z],M=O.content?.length??0,A=O.name??$.get(O.tool_call_id??"")??"unknown";w[z]={...O,content:`${Xbi}
1625
1625
  [original tool: ${A}, ${M} chars]`},D+=M-80}return{messages:w,freedTokensEstimate:Math.floor(D/4)}}var Jbi,Xbi="[content cleared by micro-compaction to reduce context usage]";var I2h=L(()=>{Jbi=new Set(["read_file","grep","glob","list_files","web_search","web_fetch","file_search","directory_tree"])});function g2h(t={}){let{onSystemPromptRefresh:h,onClearFileCache:i,onLog:_}=t,f={systemPromptRefreshed:!1,fileCacheCleared:!1};if(i)i(),f.fileCacheCleared=!0,_?.("Post-compact: file cache cleared");if(h){let w=h();if(w)f.systemPromptRefreshed=!0,f.refreshedPrompt=w,_?.("Post-compact: system prompt refreshed")}return f}var U6t={};Ui(U6t,{formatContextBreakdown:()=>Lbi,estimateContextBreakdown:()=>y6t});function Pbi(t){let h=t.indexOf("--- MEMORY ---");if(h===-1)return{memory:"",promptWithoutMemory:t};let i=t.indexOf("--- END MEMORY ---",h),_=i===-1?t.length:i+18,f=t.slice(h,_),w=t.slice(0,h)+t.slice(_);return{memory:f,promptWithoutMemory:w}}function y6t(t){let{systemPrompt:h,toolsPayload:i,messages:_,contextUsage:f,contextLimit:w}=t;if(f===0)return{categories:[],total:0,limit:w,usagePercent:0,suggestions:[],stale:!0};let{memory:D,promptWithoutMemory:$}=Pbi(h),n=$.length,u=D.length,z=i.length,O=0,M=0;for(let l of _){let B=typeof l.content==="string"?l.content.length:0,o=l.tool_calls?JSON.stringify(l.tool_calls).length:0,R=typeof l.reasoning_content==="string"?l.reasoning_content.length:0,F=B+o+R;if(l.role==="tool")M+=F;else if(l.role==="user"&&typeof l.content==="string"&&l.content.includes("<tool_result>"))M+=F;else O+=F}let A=n+u+z+O+M;if(A===0)return{categories:[{name:"Free",tokens:Math.max(0,w-f),percent:0,color:"dim"}],total:f,limit:w,usagePercent:f/w*100,suggestions:[],stale:!1};let W=(l)=>Math.round(l/A*f),J=W(n),P=W(u),T=W(z),C=W(M),E=f-J-P-T-C,v=[];if(J>0)v.push({name:"System Prompt",tokens:J,percent:J/f*100,color:"cyan"});if(P>0)v.push({name:"Memory",tokens:P,percent:P/f*100,color:"green"});if(T>0)v.push({name:"Tools",tokens:T,percent:T/f*100,color:"blue"});if(E>0)v.push({name:"Messages",tokens:E,percent:E/f*100,color:"yellow"});if(C>0)v.push({name:"Tool Results",tokens:C,percent:C/f*100,color:"magenta"});let G=Math.max(0,w-f);v.push({name:"Free",tokens:G,percent:G/w*100,color:"dim"});let k=[],I=f/w;if(I>=0.85)k.push("\u26A0\uFE0F Context nearly full. Run /compact to free up space.");if(C/f>0.4)k.push("\uD83D\uDCA1 Tool results consuming >40% of used context. Consider /compact.");if(E/f>0.6)k.push("\uD83D\uDCA1 Message history consuming >60%. Use /compact or /clear.");return{categories:v,total:f,limit:w,usagePercent:I*100,suggestions:k,stale:!1}}function Lbi(t){if(t.stale)return"\u23F3 Waiting for first API response; breakdown unavailable.";let h=20,i=[],_=t.total.toLocaleString(),f=t.limit.toLocaleString();i.push(`Context: ${t.usagePercent.toFixed(1)}% (${_} / ${f} tokens)`),i.push(""),i.push(" (proportional estimates \u2014 total is exact from provider)"),i.push("");for(let w of t.categories){let D=w.name==="Free"?Math.round(w.tokens/t.limit*h):Math.round(w.tokens/t.limit*h),$=Math.min(D,h),n=h-$,u="\u2588".repeat($)+"\u2591".repeat(n),z=w.name==="Free"?`${(w.tokens/t.limit*100).toFixed(0)}%`:`${w.percent.toFixed(0)}%`,O=w.tokens.toLocaleString().padStart(10),M=w.name.padEnd(14);i.push(` ${M} ${u} ${z.padStart(4)} ${O}`)}if(t.suggestions.length>0){i.push("");for(let w of t.suggestions)i.push(` ${w}`)}return i.join(`
1626
1626
  `)}var Q2h=`You are summarizing a coding conversation to preserve context while reducing token usage.
1627
1627
 
@@ -3244,7 +3244,7 @@ body { background: var(--canvas); color: var(--text); }
3244
3244
  \u2026 Diff truncated at ${b7t.toLocaleString()} characters.`:t}async function _uh(t,h,i){let _=["diff","--no-ext-diff","--unified=3"];if(i)_.push("--cached");_.push("--",h);let f=await oK(t,_);if(f.stdout||i)return f.stdout;let w=await oK(t,["diff","--no-index","--unified=3","--",sf?"NUL":"/dev/null",h]);return w.exitCode===1?w.stdout:""}async function wuh(t,h){let i=await oK(t,["status","--porcelain=v1","--untracked-files=all","--branch","-z"]);if(i.exitCode!==0)return{repository:!1,branch:null,upstream:null,ahead:0,behind:0,files:[],diff:"",stagedDiff:""};let _=fuh(i.stdout),f=h&&_.files.some(($)=>$.path===h)?h:_.files[0]?.path;if(!f)return{repository:!0,..._,diff:"",stagedDiff:""};let[w,D]=await Promise.all([_uh(t,f,!1),_uh(t,f,!0)]);return{repository:!0,..._,selectedPath:f,diff:iuh(w),stagedDiff:iuh(D)}}async function Duh(t,h,i){let _=i.filter(($)=>$&&Byi(t,$));if(_.length!==i.length)throw Error("A requested file is outside the workspace");let f=_;if(h==="unstage"){let $=await oK(t,["status","--porcelain=v1","--untracked-files=all","-z"]);if($.exitCode!==0)throw Error($.stdout||"Could not read file status");let n=fuh($.stdout).files.filter((u)=>u.indexStatus!==" "&&u.indexStatus!=="?").map((u)=>u.path);if(f=_.filter((u)=>n.includes(u)),!f.length)return}let w=h==="stage"?["add","--",...f]:["restore","--staged","--",...f],D=await oK(t,w);if(D.exitCode!==0)throw Error(D.stdout||`Could not ${h} files`)}async function ruh(t,h){let i=h.trim();if(!i||i.length>500)throw Error("Commit message must be between 1 and 500 characters");if((await oK(t,["diff","--cached","--quiet"])).exitCode===0)throw Error("No staged changes to commit");let f=await oK(t,["commit","-m",i]);if(f.exitCode!==0)throw Error(f.stdout||"Could not create commit");return f.stdout}var b7t=300000;var $uh=L(()=>{Pf();T5()});class aO{cwd;send;static MAX_TRANSCRIPT=65536;static FLUSH_DELAY_MS=12;static FLUSH_MAX_BUFFER=32768;terminal=null;process=null;decoder=new TextDecoder;transcript="";pendingOutput="";flushTimer=null;constructor(t,h){this.cwd=t;this.send=h}open(t=100,h=28){if(this.terminal&&!this.terminal.closed){this.resize(t,h);return}this.decoder=new TextDecoder,this.terminal=new Bun.Terminal({cols:t,rows:h,name:"xterm-256color",data:(w,D)=>this.emit(this.decoder.decode(D,{stream:!0}))});let i=this.terminal,_=sf?process.env.COMSPEC||"cmd.exe":process.env.SHELL||"/bin/bash",f=sf?[]:["--noprofile","--norc"];this.process=Bun.spawn([_,...f],{cwd:this.cwd,env:{...process.env,TERM:"xterm-256color",...sf?{}:{PS1:"\\[\\e[38;5;80m\\]deepseek\\[\\e[0m\\]:\\[\\e[38;5;110m\\]\\W\\[\\e[0m\\] \\$ "}},terminal:i}),this.process.exited.then((w)=>{if(this.terminal===i){let D=this.decoder.decode();if(D)this.emit(D);this.flush(),this.send({type:"terminal_exit",code:w}),this.terminal=null,this.process=null}})}input(t){if(!this.terminal||this.terminal.closed)return;this.terminal.write(t)}resize(t,h){if(!this.terminal||this.terminal.closed)return;this.terminal.resize(t,h)}reset(t,h){this.stop(),this.transcript="",this.pendingOutput="",this.open(t,h)}snapshot(){return this.transcript}stop(){if(this.flushTimer!==null)clearTimeout(this.flushTimer),this.flushTimer=null;this.flush(),this.process?.kill("SIGTERM"),this.terminal?.close(),this.process=null,this.terminal=null}emit(t){if(!t)return;if(this.transcript=(this.transcript+t).slice(-aO.MAX_TRANSCRIPT),this.pendingOutput+=t,this.pendingOutput.length>=aO.FLUSH_MAX_BUFFER){this.flush();return}if(this.flushTimer===null)this.flushTimer=setTimeout(()=>{this.flushTimer=null,this.flush()},aO.FLUSH_DELAY_MS)}flush(){if(this.flushTimer!==null)clearTimeout(this.flushTimer),this.flushTimer=null;let t=this.pendingOutput;if(!t)return;this.pendingOutput="",this.send({type:"terminal_data",data:t})}}var Kuh=L(()=>{T5()});import{createHash as nuh,randomUUID as lyi,timingSafeEqual as yyi}from"crypto";function myi(t){let h=encodeURIComponent(t);return`<!doctype html>
3245
3245
  <html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="color-scheme" content="dark"><title>DeepSeek Code</title><link rel="icon" type="image/png" href="/dsc-logo.png?token=${h}"><link rel="stylesheet" href="/xterm.css?token=${h}"><link rel="stylesheet" href="/app.css?token=${h}"></head><body><div id="app"></div><script src="/xterm.js?token=${h}"></script><script src="/app.js?token=${h}"></script></body></html>`}function oyi(t,h){if(!t)return!1;let i=nuh("sha256").update(t).digest(),_=nuh("sha256").update(h).digest();return yyi(i,_)}function xyi(t,h){if(!t)return!1;let i=t.toLowerCase();return i===`127.0.0.1:${h}`||i===`localhost:${h}`||i===`[::1]:${h}`}function syi(){return{repository:!1,branch:null,upstream:null,ahead:0,behind:0,files:[],diff:"",stagedDiff:""}}function dyi(){return{tokenCount:0,promptTokens:0,completionTokens:0,cachedTokens:0,contextUsage:0,contextLimit:0,toolCalls:0,filesModified:0,costUsd:0}}function uuh(t){let h=t.port??Number(process.env.DEEPSEEK_WEB_PORT??4321),i=Number.isInteger(h)&&h>=0&&h<=65535?h:4321,_=t.hostname??"127.0.0.1",f=lyi(),w=new Set,D=new Set,$=new Map,n=[],u=0,z=300,O=(R)=>R.type!=="terminal_data"&&R.type!=="terminal_exit"&&R.type!=="heartbeat",M=(R)=>{let F={...R,seq:++u};if(O(F)){if(n.push(F),n.length>z)n.splice(0,n.length-z)}return F},A=(R,F)=>{if(R.readyState===tM)R.send(JSON.stringify(F))},W=(R)=>{let F=M(R),a=JSON.stringify(F);for(let _t of w)if(_t.readyState===tM)_t.send(a)},J,P=async(R=J)=>{try{return await wuh(t.cwd,R)}catch{return syi()}},T=async(R)=>{if(R!==void 0)J=R;W({type:"source_control",snapshot:await P()})},C=new aO(t.cwd,W),E=new R7t(t.agent,{send:W},{onWorkspaceChanged:()=>{T()},sessionId:t.sessionId}),v=setInterval(()=>{W({type:"heartbeat",at:Date.now()}),E.sendStats()},5000),G=(R,F)=>{if(typeof F!=="string"&&!(F instanceof ArrayBuffer)&&!ArrayBuffer.isView(F))return;let a=typeof F==="string"?F:new TextDecoder().decode(F);if(a.length>Iyi)return;let _t;try{_t=JSON.parse(a)}catch{return}let g=tuh(_t);if(!g)return;if(!D.has(R)){$.set(R,[...$.get(R)??[],g]);return}k(R,g)},k=(R,F)=>{switch(F.type){case"refresh_source_control":if(F.path!==void 0)J=F.path;(async()=>R.send(JSON.stringify({type:"source_control",snapshot:await P()})))();return;case"stage_files":case"unstage_files":(async()=>{try{await Duh(t.cwd,F.type==="stage_files"?"stage":"unstage",F.paths),await T()}catch(_t){if(R.readyState===tM)R.send(JSON.stringify({type:"error",message:_t instanceof Error?_t.message:String(_t)}))}})();return;case"commit":(async()=>{try{let _t=await ruh(t.cwd,F.message);W({type:"commit_result",message:F.message,output:_t}),await T()}catch(_t){if(R.readyState===tM)R.send(JSON.stringify({type:"error",message:_t instanceof Error?_t.message:String(_t)}))}})();return;case"terminal_open":C.open(F.cols,F.rows);return;case"terminal_input":C.input(F.data);return;case"terminal_resize":C.resize(F.cols,F.rows);return;case"terminal_reset":C.reset(F.cols,F.rows);return;case"terminal_replay":if(R.readyState===tM)R.send(JSON.stringify({type:"terminal_data",data:C.snapshot()}));return;case"resume":let a=n[0]?.seq;if(a!==void 0&&F.since<a-1)A(R,M({type:"session_gap",from:F.since+1,to:a-1}));for(let _t of n)if((_t.seq??0)>F.since)A(R,_t);return;default:E.handleCommand(F);return}},I=async(R)=>{let F=await P();if(R.readyState!==tM)return;let a=t.agent.getToolInfo?.()??[];R.send(JSON.stringify({type:"hello",sessionId:t.sessionId,model:t.model,cwd:t.cwd,mode:t.agent.interactionMode??"build",tools:a,sourceControl:F,latestSeq:u,stats:t.agent.getSessionStats?.()??dyi(),todos:E.todos()}));for(let g of E.pendingEvents()){let V="requestId"in g?g.requestId:void 0,Vt=V?n.findLast((Rt)=>("requestId"in Rt)&&Rt.requestId===V):void 0;A(R,Vt??M(g))}D.add(R);let _t=$.get(R)??[];$.delete(R);for(let g of _t)k(R,g)},l=(R)=>Bun.serve({hostname:_,port:R,websocket:{open(F){w.add(F),I(F)},close(F){w.delete(F),D.delete(F),$.delete(F)},message(F,a){G(F,a)}},fetch(F,a){let _t=new URL(F.url);if(!xyi(F.headers.get("host"),a.port??R))return new Response("Forbidden",{status:403,headers:r7});if(!oyi(_t.searchParams.get("token"),f))return new Response("Forbidden",{status:403,headers:r7});if(_t.pathname==="/ws"){if(a.upgrade(F))return;return new Response("Upgrade failed",{status:426,headers:r7})}if(_t.pathname==="/favicon.svg")return new Response(Qyi,{headers:{...r7,...xK,"Content-Type":"image/svg+xml"}});if(_t.pathname==="/dsc-logo.png")return new Response(gyi,{headers:{...r7,...xK,"Content-Type":"image/png"}});if(_t.pathname==="/")return new Response(myi(f),{headers:{...r7,...xK,...Uyi,"Content-Type":"text/html; charset=utf-8"}});if(_t.pathname==="/xterm.css")return new Response(Unh,{headers:{...r7,...xK,"Content-Type":"text/css; charset=utf-8"}});if(_t.pathname==="/xterm.js")return new Response(gnh,{headers:{...r7,...xK,"Content-Type":"application/javascript; charset=utf-8"}});if(_t.pathname==="/app.css")return new Response(snh,{headers:{...r7,...xK,"Content-Type":"text/css; charset=utf-8"}});if(_t.pathname==="/app.js")return new Response(onh,{headers:{...r7,...xK,"Content-Type":"application/javascript; charset=utf-8"}});return new Response("Not found",{status:404,headers:r7})}}),B;if(i!==0)B=l(i);else B=l(0);if(!B||B.port===void 0)throw Error("Web server did not expose its listening port");let o=B.port;return{url:`http://${_}:${o}/?token=${f}`,port:o,token:f,stop(){clearInterval(v),E.stop(),C.stop();for(let R of w)R.close();w.clear(),B.stop(!0)}}}var tM=1,r7,Uyi,xK,Iyi=1e6,gyi,Qyi='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="#4d6bfe" d="M23.748 4.482c-.254-.124-.364.113-.512.234-.051.039-.094.09-.137.136-.372.397-.806.657-1.373.626-.829-.046-1.537.214-2.163.848-.133-.782-.575-1.248-1.247-1.548-.352-.156-.708-.311-.955-.65-.172-.241-.219-.51-.305-.774-.055-.16-.11-.323-.293-.35-.2-.031-.278.136-.356.276-.313.572-.434 1.202-.422 1.84.027 1.436.633 2.58 1.838 3.393.137.093.172.187.129.323-.082.28-.18.552-.266.833-.055.179-.137.217-.329.14a5.365 5.365 0 0 1-1.736-1.18c-.857-.828-1.631-1.742-2.597-2.458a11.365 11.365 0 0 0-.689-.471c-.985-.957.13-1.743.388-1.836.27-.098.093-.432-.779-.428-.872.004-1.67.295-2.687.684a3.055 3.055 0 0 1-.465.137 9.597 9.597 0 0 0-2.883-.102c-1.885.21-3.39 1.102-4.497 2.623C.082 8.606-.231 10.684.152 12.85c.403 2.284 1.569 4.175 3.36 5.653 1.858 1.533 3.997 2.284 6.438 2.14 1.482-.085 3.133-.284 4.994-1.86.47.234.962.327 1.78.397.63.059 1.236-.03 1.705-.128.735-.156.684-.837.419-.961-2.155-1.004-1.682-.595-2.113-.926 1.096-1.296 2.746-2.642 3.392-7.003.05-.347.007-.565 0-.845-.004-.17.035-.237.23-.256a4.173 4.173 0 0 0 1.545-.475c1.396-.763 1.96-2.015 2.093-3.517.02-.23-.004-.467-.247-.588zM11.581 18c-2.089-1.642-3.102-2.183-3.52-2.16-.392.024-.321.471-.235.763.09.288.207.486.371.739.114.167.192.416-.113.603-.673.416-1.842-.14-1.897-.167-1.361-.802-2.5-1.86-3.301-3.307-.774-1.393-1.224-2.887-1.298-4.482-.02-.386.093-.522.477-.592a4.696 4.696 0 0 1 1.529-.039c2.132.312 3.946 1.265 5.468 2.774.868.86 1.525 1.887 2.202 2.891.72 1.066 1.494 2.082 2.48 2.914.348.292.625.514.891.677-.802.09-2.14.11-3.054-.614zm1-6.44a.306.306 0 0 1 .415-.287.302.302 0 0 1 .2.288.306.306 0 0 1-.31.307.303.303 0 0 1-.304-.308zm3.11 1.596c-.2.081-.399.151-.59.16a1.245 1.245 0 0 1-.798-.254c-.274-.23-.47-.358-.552-.758a1.73 1.73 0 0 1 .016-.588c.07-.327-.008-.537-.239-.727-.187-.156-.426-.199-.688-.199a.559.559 0 0 1-.254-.078.253.253 0 0 1-.114-.358c.028-.054.16-.186.192-.21.356-.202.767-.136 1.146.016.352.144.618.408 1.001.782.391.451.462.576.685.914.176.265.336.537.445.848.067.195-.019.354-.25.452z"/></svg>';var zuh=L(()=>{ynh();Inh();mnh();xnh();dnh();huh();$uh();Kuh();r7={"Cache-Control":"no-store"},Uyi={"Content-Security-Policy":"default-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; connect-src 'self' ws: wss:; img-src 'self' data:; font-src 'self'; base-uri 'none'; form-action 'none'"},xK={"X-Content-Type-Options":"nosniff"},gyi=Bun.file(new URL("../../website/public/dsc-logo.png",import.meta.url))});var Ouh={};Ui(Ouh,{default:()=>quh});import{randomUUID as pyi}from"crypto";function ayi(t){let h=process.platform==="darwin"?"open":process.platform==="win32"?"cmd":"xdg-open",i=process.platform==="win32"?["/c","start","",t]:[t];try{Bun.spawn([h,...i],{stdin:"ignore",stdout:"ignore",stderr:"ignore",detached:!0}).unref()}catch{}}function tUi(t=process.argv.slice(2)){let h=t.indexOf("--port");if(h===-1)return;let i=t[h+1];if(!i)return;let _=Number(i);return Number.isInteger(_)&&_>=0&&_<=65535?_:void 0}async function quh(){await FK();let{providerConfig:t,language:h,enchant:i}=await pO();if(!t){console.error("No provider configured. Run `deepseek` once to configure a provider."),process.exitCode=1;return}let _=pyi(),f=new bK(t,{sessionId:_,projectRoot:process.cwd()});if(await f.readyPromise.catch(()=>{}),h)f.setLanguage(h);if(!i)f.setPromptRefinerEnabled(!1);let w=uuh({agent:f,sessionId:_,model:f.model,cwd:f.getWorkingDirectory(),port:tUi()});console.log(""),console.log(" DeepSeek Code \u2014 web UI"),console.log(` ${w.url}`),console.log(""),console.log(" Press Ctrl+C to stop."),console.log(""),ayi(w.url);let D=!1,$=()=>{if(D)return;D=!0,w.stop(),Promise.race([f.shutdown().catch(()=>{}),new Promise((n)=>setTimeout(n,1500))]).then(()=>process.exit(0))};process.on("SIGINT",$),process.on("SIGTERM",$),await new Promise(()=>{})}var Muh=L(()=>{ue();qV();C9();zuh()});var V7t={};Ui(V7t,{isDismissed:()=>DUi,dismissVersion:()=>wUi,checkForUpdate:()=>fUi,_getVersion:()=>Yuh,RETRY_AFTER_FAILURE_MS:()=>k7t,COOLDOWN_MS:()=>Juh});import{readFileSync as Huh,writeFileSync as Auh,mkdirSync as Wuh}from"fs";import{join as e7t}from"path";import{homedir as hUi}from"os";function _Ui(t,h){let i=(w)=>{let[D,$]=w.split("-",2);return{parts:(D??"").split(".").map(Number),pre:$??null}},_=i(t),f=i(h);for(let w=0;w<3;w++){if((_.parts[w]??0)>(f.parts[w]??0))return!0;if((_.parts[w]??0)<(f.parts[w]??0))return!1}if(f.pre!==null&&_.pre===null)return!0;return!1}async function fUi(){try{let t=Huh(Xuh,"utf-8").trim(),h=Number(t);if(Number.isSafeInteger(h)&&Date.now()<h)return null}catch{}try{let t=new AbortController,h=setTimeout(()=>t.abort(),iUi),i;try{i=await fetch(`https://registry.npmjs.org/${d_.name}/latest`,{signal:t.signal})}finally{clearTimeout(h)}if(!i.ok)return c7t(k7t),null;let _=await i.json();c7t(Juh);let f=Yuh();if(!_Ui(_.version,f))return null;return{current:f,latest:_.version}}catch{return c7t(k7t),null}}function c7t(t){try{Wuh(AV,{recursive:!0}),Auh(Xuh,String(Date.now()+t))}catch{}}function wUi(t){try{Wuh(AV,{recursive:!0}),Auh(Puh,t)}catch{}}function DUi(t){try{return Huh(Puh,"utf-8").trim()===t}catch{return!1}}var Yuh=()=>d_.version,Juh=3600000,k7t=600000,iUi=5000,AV,Xuh,Puh;var j7t=L(()=>{f$();AV=e7t(hUi(),".deepseek"),Xuh=e7t(AV,"update-cooldown"),Puh=e7t(AV,"dismissed-update-version")});var Tuh={};Ui(Tuh,{UpdatePrompt:()=>rUi});function rUi({current:t,latest:h,packageManagers:i,onChoice:_}){let[f,w]=Luh.useState(0);h0(($,n)=>{if(n.upArrow){w((u)=>(u-1+rL.length)%rL.length);return}if(n.downArrow){w((u)=>(u+1)%rL.length);return}if(n.return){_(rL[f]);return}if(n.escape||n.ctrl&&$==="c"){_("skip");return}});let D={update:i.length===2?"Update now (updates the npm and Bun global packages in parallel)":`Update now (runs \`${i[0]} ${i[0]==="bun"?"add":"install"} -g @hermenics/deepseek-code@${h}\`)`,skip:"Skip",dismiss:"Don't ask again for this version"};return H2.jsxDEV(ht,{flexDirection:"column",marginTop:1,children:[H2.jsxDEV(j,{children:[" \u2728 Update available! ",t," -",">"," ",h]},void 0,!0,void 0,this),i.length===2&&H2.jsxDEV(j,{color:"yellow",children:" \u26A0 Installed globally with npm and Bun; both will be updated."},void 0,!1,void 0,this),H2.jsxDEV(ht,{flexDirection:"column",marginTop:1,children:rL.map(($,n)=>H2.jsxDEV(ht,{children:H2.jsxDEV(j,{color:n===f?"cyan":void 0,children:[n===f?"\u276F ":" ",D[$]]},void 0,!0,void 0,this)},$,!1,void 0,this))},void 0,!1,void 0,this),H2.jsxDEV(ht,{marginTop:1,children:H2.jsxDEV(j,{color:"#888888",children:"\u2191\u2193 navigate \xB7 Enter select \xB7 Esc/Ctrl+C skip"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var Luh,H2,rL;var Cuh=L(()=>{ff();ci();Ii();Luh=b(Li(),1),H2=b(Oh(),1),rL=["update","skip","dismiss"]});Hu();var K8=b(Li(),1);import{writeSync as nUi}from"fs";ff();Pf();ue();var Yh=b(Li(),1);import{existsSync as Tnh}from"fs";import{resolve as tyi}from"path";u1();u1();uD();ci();Ii();var Awt=b(Li(),1);function cDh(t){return t.split(/(\s+)/).filter((h)=>h.length>0)}function Pci(t,h){let i=t.length,_=h.length,f=Array.from({length:i+1},()=>Array(_+1).fill(0));for(let w=1;w<=i;w++)for(let D=1;D<=_;D++)f[w][D]=t[w-1]===h[D-1]?f[w-1][D-1]+1:Math.max(f[w-1][D],f[w][D-1]);return f}function CO(t,h,i,_,f){if(_===0&&f===0)return{removed:[],added:[]};if(_===0){let D=CO(t,h,i,0,f-1);return D.added.push({text:i[f-1],type:"added"}),D}if(f===0){let D=CO(t,h,i,_-1,0);return D.removed.push({text:h[_-1],type:"removed"}),D}if(h[_-1]===i[f-1]){let D=CO(t,h,i,_-1,f-1);return D.removed.push({text:h[_-1],type:"same"}),D.added.push({text:i[f-1],type:"same"}),D}if(t[_-1][f]>=t[_][f-1]){let D=CO(t,h,i,_-1,f);return D.removed.push({text:h[_-1],type:"removed"}),D}let w=CO(t,h,i,_,f-1);return w.added.push({text:i[f-1],type:"added"}),w}function kDh(t,h){let i=cDh(t),_=cDh(h);if(i.length===0&&_.length===0)return{removed:[],added:[]};if(i.length===0)return{removed:[],added:_.map((w)=>({text:w,type:"added"}))};if(_.length===0)return{removed:i.map((w)=>({text:w,type:"removed"})),added:[]};let f=Pci(i,_);return CO(f,i,_,i.length,_.length)}var S1=b(Oh(),1);function Hwt(t){return t.startsWith("+")||t.startsWith("-")||t.startsWith(" ")?t.slice(1):t}function eDh({path:t,added:h,removed:i,firstChanged:_,lines:f,theme:w,onOpen:D,showWordDiff:$=!0}){let n=Fi(w),u=process.stdout.columns??80,z=t.split("/").pop()??t,O=Awt.useMemo(()=>f.slice(0,KN),[f]),M=O.reduce((T,C)=>Math.max(T,C.lineNo),0),A=Math.max(String(M).length,2),W=A+3,J=Math.max(1,u-W-4),P=Awt.useMemo(()=>{let T=new Map;for(let C=0;C<O.length-1;C++)if(O[C].type==="removed"&&O[C+1].type==="added")T.set(C,C+1),T.set(C+1,C);return T},[O]);return S1.jsxDEV(ht,{flexDirection:"column",marginTop:1,children:[S1.jsxDEV(ht,{flexDirection:"row",gap:1,paddingLeft:2,onClick:D,children:[S1.jsxDEV(j,{color:n.success,children:K_.assistant},void 0,!1,void 0,this),S1.jsxDEV(j,{color:n.textDim,children:"Write"},void 0,!1,void 0,this),S1.jsxDEV(j,{color:"cyan",children:t},void 0,!1,void 0,this)]},void 0,!0,void 0,this),S1.jsxDEV(ht,{paddingLeft:4,children:[S1.jsxDEV(j,{color:n.diffAddedWord,children:"+"+h},void 0,!1,void 0,this),S1.jsxDEV(j,{color:n.textDim,children:" / "},void 0,!1,void 0,this),S1.jsxDEV(j,{color:n.diffRemovedWord,children:"-"+i},void 0,!1,void 0,this),S1.jsxDEV(j,{color:n.textDim,children:" at L"+_+" in "+z},void 0,!1,void 0,this)]},void 0,!0,void 0,this),S1.jsxDEV(ht,{flexDirection:"column",marginTop:1,children:[O.map((T,C)=>{let E=T.type==="added",v=T.type==="removed",G=E?"+":v?"-":" ",k=E?n.diffAdded:v?n.diffRemoved:void 0,I=E?n.diffAddedWord:v?n.diffRemovedWord:n.textDim,l=Hwt(T.text),B=l.length>J?l.slice(0,J-1)+"\u2026":l,o=" ".repeat(Math.max(0,J-B.length)),R=E||T.type==="context"?String(T.lineNo).padStart(A):" ".repeat(A),F=P.get(C),a=F!==void 0,_t=null;if($&&a&&(E||v)){let V=v?T:O[F],Vt=E?T:O[F],Rt=Hwt(V.text).slice(0,J),Dh=Hwt(Vt.text).slice(0,J);_t=kDh(Rt,Dh)}let g=_t?v?_t.removed:_t.added:null;return S1.jsxDEV(ht,{flexDirection:"row",children:[S1.jsxDEV(j,{backgroundColor:k,color:n.textSubtle,dimColor:!E&&!v,children:" "+R+" "+G+" "},void 0,!1,void 0,this),g?S1.jsxDEV(ht,{flexDirection:"row",children:[g.map((V,Vt)=>{let Rt=v&&V.type==="removed"||E&&V.type==="added";return S1.jsxDEV(j,{backgroundColor:k,color:Rt?v?n.diffRemovedWord:n.diffAddedWord:I,bold:Rt,children:V.text},Vt,!1,void 0,this)}),S1.jsxDEV(j,{backgroundColor:k,color:I,children:o},void 0,!1,void 0,this)]},void 0,!0,void 0,this):S1.jsxDEV(j,{backgroundColor:k,color:I,children:B+o},void 0,!1,void 0,this)]},C,!0,void 0,this)}),f.length>KN&&S1.jsxDEV(ht,{paddingLeft:2,children:S1.jsxDEV(j,{color:n.textDim,children:"\u2026 "+(f.length-KN)+" more lines"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}u1();ci();Ii();var SO=b(Oh(),1);function VDh({files:t,theme:h}){let i=Fi(h),_=process.stdout.columns??80;return SO.jsxDEV(ht,{flexDirection:"column",children:t.map((f,w)=>{let $=`+${f.added} -${f.removed}`.length+3,n=Math.max(1,_-$-4),u=f.path.length>n?n<=1?"\u2026":"\u2026"+f.path.slice(-(n-1)):f.path;return SO.jsxDEV(ht,{flexDirection:"row",gap:1,children:[SO.jsxDEV(j,{color:i.diffAddedWord,children:"+"+f.added},void 0,!1,void 0,this),SO.jsxDEV(j,{color:i.diffRemovedWord,children:"-"+f.removed},void 0,!1,void 0,this),SO.jsxDEV(j,{color:i.textDim,children:u},void 0,!1,void 0,this)]},w,!0,void 0,this)})},void 0,!1,void 0,this)}var qe={read_file:"Read",write_file:"Write",patch_file:"Edit",read_folder:"List",shell:"Bash",grep:"Grep",glob:"Glob",web_fetch:"WebFetch",subagent:"Agent",git:"Git",introspect:"Introspect",update_knowledge:"UpdateKnowledge",todo:"TodoWrite",ask_user_questions:"AskUser"};function cK(t,h=60){if(t.length<=h)return t;if(h<=1)return"\u2026".slice(0,h);return t.slice(0,h-1)+"\u2026"}function Lci(t){let h=t.find((w)=>!!w&&typeof w==="object"&&typeof w.question==="string"),i=typeof h?.question==="string"?h.question:"";if(!i)return`${t.length} question${t.length===1?"":"s"}`;let _=t.length>1?` \xB7 ${t.length} questions`:"",f=Math.max(0,60-_.length);return cK(i,f)+_}function Oe(t){try{let h=JSON.parse(t);if(!h||typeof h!=="object"||Array.isArray(h))return cK(t);let i=h;if(Array.isArray(i.questions))return Lci(i.questions);if(i.cancelled===!0)return"cancelled";if(i.answers&&typeof i.answers==="object"&&!Array.isArray(i.answers)){let _=Object.keys(i.answers).length;return`${_} answer${_===1?"":"s"}`}}catch{}return cK(t)}function Tci(t){try{let h=JSON.parse(t);if(Array.isArray(h))return`${h.length} item${h.length===1?"":"s"}`;if(h&&typeof h==="object"){let i=h;if(typeof i.error==="string")return cK(`Error: ${i.error}`);if(typeof i.path==="string")return cK(i.path);let _=Object.keys(i).length;return`${_} field${_===1?"":"s"}`}}catch{}return cK(t)}function kP(t,h){return t==="ask_user_questions"?Oe(h):Tci(h)}function Me(t,h){if(t==="ask_user_questions")return Oe(JSON.stringify(h));let i=JSON.stringify(h),_=Wwt(i);if(_)return _;let f=Object.values(h).find((D)=>typeof D==="string"&&D.trim().length>0);if(f)return cK(f);let w=Object.keys(h).length;return w>0?`${w} argument${w===1?"":"s"}`:""}function BDh(t,h){return kP(t,h)}var jDh=/"(path|file_path|command|pattern|query|url|action|task|description)"\s*:\s*"((?:\\.|[^"\\])*)"/g,Cci=65536;function Wwt(t){let h=t.slice(0,Cci),i=jDh.exec(h);jDh.lastIndex=0;let _=i?.[2];if(!_)return"";let f=_.replace(/\\n/g," ").replace(/\\(.)/g,"$1");return f.length>60?f.slice(0,60)+"\u2026":f}var He={Read:{icon:"\u25B8",color:"#5599ff"},Write:{icon:"\u25B8",color:"#44cc44"},Edit:{icon:"\u25B8",color:"#44cc44"},List:{icon:"\u25B8",color:"#5599ff"},Bash:{icon:"$",color:"#cc66ff"},Grep:{icon:"\u2315",color:"#cccc44"},Glob:{icon:"\u2315",color:"#cccc44"},WebFetch:{icon:"\u2197",color:"#44cccc"},Agent:{icon:"\u25C8",color:"#44cccc"},Git:{icon:"\u2387",color:"#ff8844"},Introspect:{icon:"\u25CE",color:"#888888"},UpdateKnowledge:{icon:"\u25CE",color:"#888888"},TodoWrite:{icon:"\u2610",color:"#cccc44"}};u1();ci();Ii();var n_=b(Oh(),1);function Ae(t,h,i){let _=[],f=0,w="",D=0,$=()=>{if(w)_.push(w),w=""};while(f<t.length){if(t.startsWith("**__",f)){let n=t.indexOf("__**",f+4);if(n!==-1){$(),_.push(n_.jsxDEV(j,{bold:!0,italic:!0,children:t.slice(f+4,n)},`${h}-bi-${D++}`,!1,void 0,this)),f=n+4;continue}}if(t.startsWith("**",f)){let n=t.indexOf("**",f+2);if(n!==-1){$(),_.push(n_.jsxDEV(j,{bold:!0,children:t.slice(f+2,n)},`${h}-b-${D++}`,!1,void 0,this)),f=n+2;continue}}if(t.startsWith("__",f)){let n=t.indexOf("__",f+2);if(n!==-1){$(),_.push(n_.jsxDEV(j,{italic:!0,children:t.slice(f+2,n)},`${h}-i-${D++}`,!1,void 0,this)),f=n+2;continue}}if(t[f]==="`"){let n=t.indexOf("`",f+1);if(n!==-1){$(),_.push(n_.jsxDEV(j,{color:i,children:t.slice(f+1,n)},`${h}-c-${D++}`,!1,void 0,this)),f=n+1;continue}}w+=t[f],f++}if($(),_.length===0)return"";if(_.length===1)return _[0];return n_.jsxDEV(n_.Fragment,{children:_},void 0,!1,void 0,this)}function u2({content:t,dimmed:h,theme:i="dark"}){let _=Fi(i),f=_.codeBlock,w=_.h1,D=_.h2,$=_.h3,n=_.bullet,u=_.textDim,z=_.rule,O=_.textSubtle;function M(P,T){let C=`line-${T}`,E=P.match(/^(#{1,6})\s+(.*)$/);if(E){let k=E[1].length;return n_.jsxDEV(j,{color:k===1?w:k===2?D:$,bold:!0,children:E[2]},C,!1,void 0,this)}if(/^(-{3,}|\*{3,}|_{3,})$/.test(P.trim()))return n_.jsxDEV(j,{color:z,children:"\u2500".repeat(60)},C,!1,void 0,this);if(P.startsWith("> "))return n_.jsxDEV(ht,{flexDirection:"row",children:[n_.jsxDEV(j,{color:u,children:"\u2502 "},void 0,!1,void 0,this),n_.jsxDEV(j,{color:u,children:Ae(P.slice(2),C,f)},void 0,!1,void 0,this)]},C,!0,void 0,this);let v=P.match(/^(\s*)([-*+])\s+(.*)$/);if(v){let k=" ".repeat(Math.floor((v[1]?.length??0)/2)*2);return n_.jsxDEV(ht,{flexDirection:"row",children:[n_.jsxDEV(j,{color:h?O:void 0,children:k},void 0,!1,void 0,this),n_.jsxDEV(j,{color:h?O:n,children:"\u2022 "},void 0,!1,void 0,this),n_.jsxDEV(j,{color:h?O:void 0,children:Ae(v[3],C,f)},void 0,!1,void 0,this)]},C,!0,void 0,this)}let G=P.match(/^(\s*)(\d+)\.\s+(.*)$/);if(G){let k=" ".repeat(Math.floor((G[1]?.length??0)/2)*2);return n_.jsxDEV(ht,{flexDirection:"row",children:[n_.jsxDEV(j,{color:h?O:void 0,children:k},void 0,!1,void 0,this),n_.jsxDEV(j,{color:h?O:n,children:[G[2],". "]},void 0,!0,void 0,this),n_.jsxDEV(j,{color:h?O:void 0,children:Ae(G[3],C,f)},void 0,!1,void 0,this)]},C,!0,void 0,this)}return n_.jsxDEV(j,{color:h?O:void 0,children:Ae(P,C,f)},C,!1,void 0,this)}let A=t.split(`
3246
3246
  `),W=[],J=0;while(J<A.length){let P=A[J];if(P.startsWith("```")){let T=P.slice(3).trim(),C=[];J++;while(J<A.length&&!A[J].startsWith("```"))C.push(A[J]),J++;if(T)W.push(n_.jsxDEV(j,{color:h?O:u,children:T},`lang-${J}`,!1,void 0,this));for(let E=0;E<C.length;E++)W.push(n_.jsxDEV(j,{color:h?O:f,children:" "+(C[E]||" ")},`code-${J}-${E}`,!1,void 0,this));if(J<A.length)J++;continue}if(P.trim()===""){W.push(n_.jsxDEV(j,{children:" "},`empty-${J}`,!1,void 0,this)),J++;continue}W.push(M(P,J)),J++}return n_.jsxDEV(ht,{flexDirection:"column",children:W},void 0,!1,void 0,this)}u1();f$();ci();Ii();var Ye=b(Li(),1),We=new Set,eP=null;function Sci(){if(eP)return;eP=setInterval(()=>{for(let t of We)t()},80)}function Eci(){if(eP&&We.size===0)clearInterval(eP),eP=null}function _7(){let[t,h]=Ye.useState(0);return Ye.useEffect(()=>{let i=()=>h((_)=>_+1);return We.add(i),Sci(),()=>{We.delete(i),Eci()}},[]),t}var nh=b(Oh(),1);function Nci(t,h,i=!1){let _=qe[t]??t;if(t==="ask_user_questions")return{display:_,arg:Oe(h),output:""};let f="",w="",D=($)=>!i&&$.length>60?$.slice(0,60)+"...":$;try{let $=JSON.parse(h);if($&&typeof $==="object"&&"arg"in $)f=D(String($.arg??"")),w=String($.output??"");else if($&&typeof $==="object")f=kP(t,h);else f=D(h)}catch{f=D(h)}return{display:_,arg:f,output:w}}function Zci(t,h){if(t[h]?.role!=="assistant")return!1;for(let i=h-1;i>=0;i--){let _=t[i].role;if(_==="tool")return!0;if(_==="user"||_==="assistant")return!1}return!1}var Gci="Work truncated (ctrl+o to expand)";function vci(t){let h=Math.max(0,Math.round(t/1000)),i=Math.floor(h/3600),_=Math.floor(h%3600/60),f=h%60;if(i>0)return`${i}h ${_}m ${f}s`;if(_>0)return`${_}m ${f}s`;return`${f}s`}function Rci(t,h=process.stdout.columns??80){let i=Math.max(1,h-1),_=`
3247
- \u2500 Worked for ${vci(t)} `;return _+"\u2500".repeat(Math.max(1,i-_.length))}function Ywt(t="",h=process.stdout.columns??80){let i=Math.max(1,h-1),_=t.slice(0,i);if(!_)return J9.repeat(i);let f=Math.max(0,i-_.length),w=Math.ceil(f/2);return`${J9.repeat(w)}${_}${J9.repeat(f-w)}`}function bci(t){return t.role==="tool"||t.role==="terminal"||t.role==="thinking"}function cci(t){let h=[],i=0;while(i<t.length){if(t[i].role!=="user"){h.push({kind:"message",message:t[i],index:i++});continue}let _=t.findIndex(($,n)=>n>i&&$.role==="user"),f=_<0?t.length:_,w=t.slice(i+1,f).reduce(($,n,u)=>n.role==="assistant"?i+1+u:$,-1),D=t.slice(i+1,f).some(bci);if(h.push({kind:"message",message:t[i],index:i}),D&&w>i&&t[w].workedMs!=null)h.push({kind:"truncated",index:w}),h.push({kind:"message",message:t[w],index:w}),i=f;else{for(let $=i+1;$<f;$++)h.push({kind:"message",message:t[$],index:$});i=f}}return h}function kci({theme:t}){let h=Fi(t);return nh.jsxDEV(ht,{marginTop:1,children:nh.jsxDEV(j,{color:h.textSubtle,children:Ywt()},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function Je(t){let h=t.startsWith("\u2713 write_file \u2192")?"\u2713 write_file \u2192 ":t.startsWith("\u2713 patch_file \u2192")?"\u2713 patch_file \u2192 ":null;if(!h)return null;try{let i=JSON.parse(t.slice(h.length));if(!i||typeof i!=="object")return null;let _=i,f=(D)=>typeof D==="number"&&Number.isFinite(D),w=(D)=>{if(!D||typeof D!=="object")return!1;let $=D;return($.type==="added"||$.type==="removed"||$.type==="context")&&typeof $.text==="string"&&f($.lineNo)};if(_.__diff!==!0||typeof _.path!=="string"||!f(_.added)||!f(_.removed)||!f(_.firstChanged)||!Array.isArray(_.lines)||!_.lines.every(w))return null;return _}catch{return null}}function eci({message:t,theme:h,agentLabel:i,showDiffs:_=!0,showWordDiff:f=!0,compact:w=!1,fullMode:D=!1,onOpenDiff:$}){let n=Fi(h),u=w?0:1;if(t.role==="user")return nh.jsxDEV(ht,{flexDirection:"column",marginTop:u,children:nh.jsxDEV(ht,{flexDirection:"row",gap:1,children:[nh.jsxDEV(j,{color:n.primary,children:K_.user},void 0,!1,void 0,this),nh.jsxDEV(j,{color:n.text,children:t.content},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this);if(t.role==="tool"){let z=Je(t.content);if(z){if(!_)return nh.jsxDEV(ht,{flexDirection:"row",paddingLeft:2,gap:1,children:[nh.jsxDEV(j,{color:n.success,children:K_.assistant},void 0,!1,void 0,this),nh.jsxDEV(j,{color:n.textDim,children:[t.content.startsWith("\u2713 patch_file")?"patch":"write"," ",z.path," (+",z.added," \u2212",z.removed,") \xB7 diff hidden"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this);return nh.jsxDEV(eDh,{...z,theme:h,showWordDiff:f,onOpen:()=>$?.(z)},void 0,!1,void 0,this)}if(t.content.startsWith("\u2713 subagent \u2192")||t.content.startsWith("\u2699 subagent")){let I=t.content.startsWith("\u2713"),l=I?t.content.slice(13):t.content.slice(11,-1),B=l.length>60?l.slice(0,60)+"...":l;return nh.jsxDEV(ht,{flexDirection:"row",paddingLeft:2,gap:1,children:[nh.jsxDEV(j,{color:I?n.success:n.warning,children:K_.assistant},void 0,!1,void 0,this),nh.jsxDEV(j,{color:I?n.textDim:n.warning,children:[B||"Agent",!I?" working...":""]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}let O=t.content.slice(2),M=O.indexOf(" \u2192 "),A=M>=0?O.slice(0,M):O,W=M>=0?O.slice(M+3):"",{display:J,arg:P,output:T}=Nci(A,W,D),C=T?T.split(/\r?\n/).filter(Boolean):[],E=5,v=D?C:C.slice(0,E),G=!D&&C.length>E,k=He[J]||{icon:"\u25B8",color:n.textDim};return nh.jsxDEV(ht,{flexDirection:"column",paddingLeft:2,children:[nh.jsxDEV(ht,{flexDirection:"row",gap:1,children:[nh.jsxDEV(j,{color:n.success,children:K_.assistant},void 0,!1,void 0,this),nh.jsxDEV(j,{color:k.color,children:J},void 0,!1,void 0,this),P?nh.jsxDEV(j,{color:n.textSubtle,children:P},void 0,!1,void 0,this):null]},void 0,!0,void 0,this),v.map((I,l)=>nh.jsxDEV(ht,{paddingLeft:3,children:nh.jsxDEV(j,{color:n.textSubtle,children:I},void 0,!1,void 0,this)},l,!1,void 0,this)),G&&nh.jsxDEV(ht,{paddingLeft:3,children:nh.jsxDEV(j,{color:n.textSubtle,children:"\u2026 "+(C.length-E)+" more lines"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}if(t.role==="terminal")return nh.jsxDEV(ht,{flexDirection:"column",marginTop:u,children:[nh.jsxDEV(ht,{flexDirection:"row",gap:1,children:[nh.jsxDEV(j,{color:n.bashBorder,children:K_.terminal},void 0,!1,void 0,this),nh.jsxDEV(j,{color:n.bashBorder,children:"terminal"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),nh.jsxDEV(ht,{marginLeft:2,children:nh.jsxDEV(j,{color:n.text,children:t.content},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(t.role==="thinking"){if(!D)return nh.jsxDEV(ht,{flexDirection:"row",marginTop:u,marginLeft:2,gap:1,children:[nh.jsxDEV(j,{color:n.textSubtle,children:K_.thinking},void 0,!1,void 0,this),nh.jsxDEV(j,{color:n.textSubtle,children:t.thinkingMs!=null?"Thought for "+Math.round(t.thinkingMs/1000)+" seconds (ctrl+o to expand)":"Thought (ctrl+o to expand)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return nh.jsxDEV(ht,{flexDirection:"column",marginTop:u,marginLeft:2,children:[nh.jsxDEV(ht,{flexDirection:"row",gap:1,children:[nh.jsxDEV(j,{color:n.textSubtle,children:K_.thinking},void 0,!1,void 0,this),nh.jsxDEV(j,{color:n.textSubtle,italic:!0,children:"Thinking"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),nh.jsxDEV(ht,{marginLeft:1,paddingLeft:1,paddingRight:1,paddingTop:1,paddingBottom:1,backgroundColor:n.thinkingBg,children:nh.jsxDEV(ht,{flexShrink:1,children:nh.jsxDEV(u2,{content:t.content,dimmed:!0,theme:h},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}return nh.jsxDEV(ht,{flexDirection:"column",marginTop:u,children:nh.jsxDEV(ht,{flexDirection:"row",gap:1,children:[nh.jsxDEV(j,{color:n.suggestion,children:K_.assistant},void 0,!1,void 0,this),nh.jsxDEV(ht,{flexDirection:"column",flexShrink:1,children:nh.jsxDEV(u2,{content:t.content,theme:h},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function Vci({provider:t,agentName:h,theme:i="dark"}){let _=Fi(i);if((process.stdout.columns??80)<60)return nh.jsxDEV(ht,{flexDirection:"column",marginLeft:1,marginTop:1,children:[nh.jsxDEV(ht,{flexDirection:"row",gap:1,children:[nh.jsxDEV(j,{color:_.primary,children:K_.agent+" DeepSeek Code"},void 0,!1,void 0,this),nh.jsxDEV(j,{color:_.textDim,children:"v"+d_.version},void 0,!1,void 0,this)]},void 0,!0,void 0,this),h&&nh.jsxDEV(j,{color:_.primary,children:"["+h+"]"},void 0,!1,void 0,this),nh.jsxDEV(j,{color:_.textDim,children:"/help \xB7 /quit to exit"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return nh.jsxDEV(ht,{flexDirection:"row",gap:2,marginLeft:1,marginTop:1,children:[nh.jsxDEV(ht,{flexDirection:"column",children:[nh.jsxDEV(j,{color:_.primary,children:" \u2584\u2584\u2588\u2588\u2588\u2584\u2584"},void 0,!1,void 0,this),nh.jsxDEV(j,{color:_.primary,children:" \u2584\u2588 \u25C9 \u2588\u2588\u2584"},void 0,!1,void 0,this),nh.jsxDEV(j,{color:_.primary,children:"\u2588 ~~\u2588"},void 0,!1,void 0,this),nh.jsxDEV(j,{color:_.primary,children:" \u2580\u2584\u2584\u2588\u2584\u2584\u2584\u2584\u2588\u2580"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),nh.jsxDEV(ht,{flexDirection:"column",children:[nh.jsxDEV(ht,{flexDirection:"row",gap:1,children:[nh.jsxDEV(j,{color:_.primary,children:K_.agent+" DeepSeek Code"},void 0,!1,void 0,this),nh.jsxDEV(j,{color:_.textDim,children:"v"+d_.version},void 0,!1,void 0,this),nh.jsxDEV(j,{color:_.textDim,children:"\xB7"},void 0,!1,void 0,this),nh.jsxDEV(j,{color:_.textDim,children:t},void 0,!1,void 0,this),h&&nh.jsxDEV(nh.Fragment,{children:[nh.jsxDEV(j,{color:_.textDim,children:"\xB7"},void 0,!1,void 0,this),nh.jsxDEV(j,{color:_.primary,children:"["+h+"]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),nh.jsxDEV(ht,{flexDirection:"row",gap:1,children:[nh.jsxDEV(j,{color:_.textDim,children:"cwd:"},void 0,!1,void 0,this),nh.jsxDEV(j,{color:_.primary,children:process.cwd()},void 0,!1,void 0,this)]},void 0,!0,void 0,this),nh.jsxDEV(j,{color:_.textDim,children:"/help for commands \xB7 /quit to exit"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function FDh({messages:t,streamText:h,thinkingText:i,streamRole:_="assistant",theme:f,activeAgent:w,headerProvider:D,headerAgent:$,showToolCalls:n=!0,showDiffs:u=!0,showWordDiff:z=!0,density:O="comfortable",fullMode:M=!1,thinkingStartedAt:A=null,onOpenDiff:W}){let J=Fi(f),P=w??"deepseek",T=new Map;for(let E of t){if(E.role!=="tool")continue;let v=Je(E.content);if(!v)continue;let G=T.get(v.path)??{path:v.path,added:0,removed:0};G.added+=v.added,G.removed+=v.removed,T.set(v.path,G)}let C=M?t.map((E,v)=>({kind:"message",message:E,index:v})):cci(t);return nh.jsxDEV(ht,{flexDirection:"column",marginBottom:O==="compact"?0:1,children:[nh.jsxDEV(Vci,{provider:D??"deepseek",agentName:$??null,theme:f},void 0,!1,void 0,this),C.map((E)=>{if(E.kind==="truncated")return nh.jsxDEV(ht,{marginTop:1,children:nh.jsxDEV(j,{color:J.textSubtle,children:Ywt(Gci)},void 0,!1,void 0,this)},`truncated-${E.index}`,!1,void 0,this);let{message:v,index:G}=E;if(v.role==="tool"&&!n)return null;let k=M&&n&&Zci(t,G);return nh.jsxDEV(ht,{flexDirection:"column",children:[k&&nh.jsxDEV(kci,{theme:f},void 0,!1,void 0,this),nh.jsxDEV(eci,{message:v,theme:f,agentLabel:P,showDiffs:u,showWordDiff:z,compact:k||O==="compact",fullMode:M,onOpenDiff:W},void 0,!1,void 0,this),v.role==="assistant"&&v.workedMs!=null&&nh.jsxDEV(j,{color:J.textSubtle,children:Rci(v.workedMs)},void 0,!1,void 0,this)]},`${v.role}-${G}`,!0,void 0,this)}),T.size>0&&nh.jsxDEV(ht,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[nh.jsxDEV(j,{color:J.textDim,children:"Changed files \xB7 Ctrl+D opens the latest diff"},void 0,!1,void 0,this),nh.jsxDEV(VDh,{files:[...T.values()],theme:f},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i?nh.jsxDEV(jci,{content:i,fullMode:M,startedAt:A,theme:f},void 0,!1,void 0,this):null,h?nh.jsxDEV(ht,{flexDirection:"column",marginTop:1,children:_==="terminal"?nh.jsxDEV(nh.Fragment,{children:[nh.jsxDEV(ht,{flexDirection:"row",gap:1,children:[nh.jsxDEV(j,{color:J.bashBorder,children:K_.terminal},void 0,!1,void 0,this),nh.jsxDEV(j,{color:J.bashBorder,children:"terminal"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),nh.jsxDEV(ht,{marginLeft:2,children:nh.jsxDEV(j,{color:J.text,children:h},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):nh.jsxDEV(ht,{flexDirection:"row",gap:1,children:[nh.jsxDEV(j,{color:J.suggestion,children:K_.assistant},void 0,!1,void 0,this),nh.jsxDEV(ht,{flexDirection:"column",flexShrink:1,children:nh.jsxDEV(u2,{content:h,streaming:!0,theme:f},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this):null,M&&nh.jsxDEV(ht,{flexDirection:"column",marginTop:1,children:[nh.jsxDEV(j,{color:J.textSubtle,children:Ywt()},void 0,!1,void 0,this),nh.jsxDEV(ht,{flexDirection:"row",justifyContent:"space-between",paddingLeft:1,paddingRight:1,children:[nh.jsxDEV(j,{color:J.textSubtle,children:"Full mode \xB7 ctrl+o to toggle"},void 0,!1,void 0,this),nh.jsxDEV(j,{color:J.textSubtle,children:"verbose"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function jci({content:t,fullMode:h,startedAt:i,theme:_}){let f=Fi(_);if(_7(),h)return nh.jsxDEV(ht,{flexDirection:"column",marginTop:1,marginLeft:2,children:[nh.jsxDEV(ht,{flexDirection:"row",gap:1,children:[nh.jsxDEV(j,{color:f.textSubtle,children:K_.thinking},void 0,!1,void 0,this),nh.jsxDEV(j,{color:f.textSubtle,italic:!0,children:"Thinking"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),nh.jsxDEV(ht,{marginLeft:1,paddingLeft:1,paddingRight:1,paddingTop:1,paddingBottom:1,backgroundColor:f.thinkingBg,children:nh.jsxDEV(ht,{flexShrink:1,children:nh.jsxDEV(u2,{content:t,dimmed:!0,theme:_},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(i==null)return nh.jsxDEV(ht,{flexDirection:"row",marginTop:1,marginLeft:2,gap:1,children:[nh.jsxDEV(j,{color:f.textSubtle,children:K_.thinking},void 0,!1,void 0,this),nh.jsxDEV(j,{color:f.textSubtle,children:"Thinking..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let w=Math.floor((Date.now()-i)/1000);return nh.jsxDEV(ht,{flexDirection:"row",marginTop:1,marginLeft:2,gap:1,children:[nh.jsxDEV(j,{color:f.textSubtle,children:K_.thinking},void 0,!1,void 0,this),nh.jsxDEV(j,{color:f.textSubtle,children:"Thinking for "+w+" seconds..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}ci();Ii();u1();var Xe=b(Li(),1),yDh=b(Oh(),1),lDh=Xe.createContext("dark");function EO({value:t,children:h}){return yDh.jsxDEV(lDh.Provider,{value:t,children:h},void 0,!1,void 0,this)}function kK(){return Fi(Xe.useContext(lDh))}ci();var Bci=b(Oh(),1);Ii();var Fci=b(Oh(),1);ci();Ii();var UDh=b(Oh(),1);ci();Ii();ff();var IDh=b(Li(),1);var X9=b(Oh(),1);function Jwt({title:t,subtitle:h,onConfirm:i,onCancel:_,confirmLabel:f="Yes",cancelLabel:w="No",children:D}){let $=kK();return h0(IDh.useCallback((n,u)=>{if(u.escape)_();if(u.return)i()},[i,_])),X9.jsxDEV(ht,{flexDirection:"column",borderStyle:"round",borderColor:$.primary,paddingLeft:1,paddingRight:1,children:[X9.jsxDEV(j,{color:$.primary,bold:!0,children:t},void 0,!1,void 0,this),h&&X9.jsxDEV(j,{color:$.textDim,children:h},void 0,!1,void 0,this),X9.jsxDEV(ht,{flexDirection:"column",marginTop:1,children:D},void 0,!1,void 0,this),X9.jsxDEV(ht,{marginTop:1,gap:2,children:[X9.jsxDEV(j,{color:$.textDim,children:["Enter: ",f]},void 0,!0,void 0,this),X9.jsxDEV(j,{color:$.textDim,children:["Esc: ",w]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}Ii();var lci=b(Oh(),1);u1();var NO=b(Oh(),1);function gDh({path:t,lines:h,onClose:i,theme:_}){let f=Fi(_),w=process.stdout.columns??80,D=h.reduce((z,O)=>Math.max(z,O.lineNo),0),$=Math.max(String(D).length,2),n=$+3,u=Math.max(1,w-n-6);return NO.jsxDEV(Jwt,{title:t,onConfirm:i,onCancel:i,confirmLabel:"close",cancelLabel:"close",children:NO.jsxDEV(ht,{flexDirection:"column",children:h.map((z,O)=>{let M=z.type==="added",A=z.type==="removed",W=M?"+":A?"-":" ",J=M?f.diffAdded:A?f.diffRemoved:void 0,P=M?f.diffAddedWord:A?f.diffRemovedWord:f.textDim,T=z.text.startsWith("+")||z.text.startsWith("-")||z.text.startsWith(" ")?z.text.slice(1):z.text,C=T.length>u?T.slice(0,u-1)+"\u2026":T,E=" ".repeat(Math.max(0,u-C.length)),v=M||z.type==="context"?String(z.lineNo).padStart($):" ".repeat($);return NO.jsxDEV(ht,{flexDirection:"row",children:[NO.jsxDEV(j,{backgroundColor:J,color:f.textSubtle,dimColor:!M&&!A,children:" "+v+" "+W+" "},void 0,!1,void 0,this),NO.jsxDEV(j,{backgroundColor:J,color:P,children:C+E},void 0,!1,void 0,this)]},O,!0,void 0,this)})},void 0,!1,void 0,this)},void 0,!1,void 0,this)}Fc();ci();Ii();var Pe=b(Li(),1),ZO=b(Oh(),1),yci={pending:"\u25CB",in_progress:"\u25C9",done:"\u25CF"},Uci={pending:"#888888",in_progress:"yellow",done:"green"};function QDh(){let[t,h]=Pe.useState(XK);if(Pe.useEffect(()=>{return Bc(()=>h(XK()))},[]),!t.length)return null;return ZO.jsxDEV(ht,{flexDirection:"column",border:!0,borderStyle:"rounded",borderColor:"cyan",paddingLeft:1,paddingRight:1,marginBottom:1,children:[ZO.jsxDEV(j,{color:"cyan",children:"\u25C6 TODO ("+t.length+")"},void 0,!1,void 0,this),t.map((i)=>ZO.jsxDEV(ht,{flexDirection:"row",gap:1,children:[ZO.jsxDEV(j,{color:Uci[i.status],children:yci[i.status]},void 0,!1,void 0,this),ZO.jsxDEV(j,{color:i.status==="done"?"#888888":void 0,children:i.title},void 0,!1,void 0,this)]},i.id,!0,void 0,this))]},void 0,!0,void 0,this)}var Le=b(Li(),1);u1();ci();Ii();var GO=b(Oh(),1),mDh=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function oDh({tool:t,theme:h="dark"}){let i=Fi(h),_=qe[t.name]??t.name,f=t.done?t.result??"":t.args??"",w;if(t.name==="subagent"&&!t.done&&t.args)try{let M=JSON.parse(t.args),A=typeof M.task==="string"?M.task:f,W=A.split(`
3247
+ \u2500 Worked for ${vci(t)} `;return _+"\u2500".repeat(Math.max(1,i-_.length))}function Ywt(t="",h=process.stdout.columns??80){let i=Math.max(1,h-1),_=t.slice(0,i);if(!_)return J9.repeat(i);let f=Math.max(0,i-_.length),w=Math.ceil(f/2);return`${J9.repeat(w)}${_}${J9.repeat(f-w)}`}function bci(t){return t.role==="tool"||t.role==="terminal"}function cci(t){let h=[],i=0;while(i<t.length){if(t[i].role!=="user"){h.push({kind:"message",message:t[i],index:i++});continue}let _=t.findIndex(($,n)=>n>i&&$.role==="user"),f=_<0?t.length:_,w=t.slice(i+1,f).reduce(($,n,u)=>n.role==="assistant"?i+1+u:$,-1),D=t.slice(i+1,f).some(bci);if(h.push({kind:"message",message:t[i],index:i}),D&&w>i&&t[w].workedMs!=null)h.push({kind:"truncated",index:w}),h.push({kind:"message",message:t[w],index:w}),i=f;else{for(let $=i+1;$<f;$++)h.push({kind:"message",message:t[$],index:$});i=f}}return h}function kci({theme:t}){let h=Fi(t);return nh.jsxDEV(ht,{marginTop:1,children:nh.jsxDEV(j,{color:h.textSubtle,children:Ywt()},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function Je(t){let h=t.startsWith("\u2713 write_file \u2192")?"\u2713 write_file \u2192 ":t.startsWith("\u2713 patch_file \u2192")?"\u2713 patch_file \u2192 ":null;if(!h)return null;try{let i=JSON.parse(t.slice(h.length));if(!i||typeof i!=="object")return null;let _=i,f=(D)=>typeof D==="number"&&Number.isFinite(D),w=(D)=>{if(!D||typeof D!=="object")return!1;let $=D;return($.type==="added"||$.type==="removed"||$.type==="context")&&typeof $.text==="string"&&f($.lineNo)};if(_.__diff!==!0||typeof _.path!=="string"||!f(_.added)||!f(_.removed)||!f(_.firstChanged)||!Array.isArray(_.lines)||!_.lines.every(w))return null;return _}catch{return null}}function eci({message:t,theme:h,agentLabel:i,showDiffs:_=!0,showWordDiff:f=!0,compact:w=!1,fullMode:D=!1,onOpenDiff:$}){let n=Fi(h),u=w?0:1;if(t.role==="user")return nh.jsxDEV(ht,{flexDirection:"column",marginTop:u,children:nh.jsxDEV(ht,{flexDirection:"row",gap:1,children:[nh.jsxDEV(j,{color:n.primary,children:K_.user},void 0,!1,void 0,this),nh.jsxDEV(j,{color:n.text,children:t.content},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this);if(t.role==="tool"){let z=Je(t.content);if(z){if(!_)return nh.jsxDEV(ht,{flexDirection:"row",paddingLeft:2,gap:1,children:[nh.jsxDEV(j,{color:n.success,children:K_.assistant},void 0,!1,void 0,this),nh.jsxDEV(j,{color:n.textDim,children:[t.content.startsWith("\u2713 patch_file")?"patch":"write"," ",z.path," (+",z.added," \u2212",z.removed,") \xB7 diff hidden"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this);return nh.jsxDEV(eDh,{...z,theme:h,showWordDiff:f,onOpen:()=>$?.(z)},void 0,!1,void 0,this)}if(t.content.startsWith("\u2713 subagent \u2192")||t.content.startsWith("\u2699 subagent")){let I=t.content.startsWith("\u2713"),l=I?t.content.slice(13):t.content.slice(11,-1),B=l.length>60?l.slice(0,60)+"...":l;return nh.jsxDEV(ht,{flexDirection:"row",paddingLeft:2,gap:1,children:[nh.jsxDEV(j,{color:I?n.success:n.warning,children:K_.assistant},void 0,!1,void 0,this),nh.jsxDEV(j,{color:I?n.textDim:n.warning,children:[B||"Agent",!I?" working...":""]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}let O=t.content.slice(2),M=O.indexOf(" \u2192 "),A=M>=0?O.slice(0,M):O,W=M>=0?O.slice(M+3):"",{display:J,arg:P,output:T}=Nci(A,W,D),C=T?T.split(/\r?\n/).filter(Boolean):[],E=5,v=D?C:C.slice(0,E),G=!D&&C.length>E,k=He[J]||{icon:"\u25B8",color:n.textDim};return nh.jsxDEV(ht,{flexDirection:"column",paddingLeft:2,children:[nh.jsxDEV(ht,{flexDirection:"row",gap:1,children:[nh.jsxDEV(j,{color:n.success,children:K_.assistant},void 0,!1,void 0,this),nh.jsxDEV(j,{color:k.color,children:J},void 0,!1,void 0,this),P?nh.jsxDEV(j,{color:n.textSubtle,children:P},void 0,!1,void 0,this):null]},void 0,!0,void 0,this),v.map((I,l)=>nh.jsxDEV(ht,{paddingLeft:3,children:nh.jsxDEV(j,{color:n.textSubtle,children:I},void 0,!1,void 0,this)},l,!1,void 0,this)),G&&nh.jsxDEV(ht,{paddingLeft:3,children:nh.jsxDEV(j,{color:n.textSubtle,children:"\u2026 "+(C.length-E)+" more lines"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}if(t.role==="terminal")return nh.jsxDEV(ht,{flexDirection:"column",marginTop:u,children:[nh.jsxDEV(ht,{flexDirection:"row",gap:1,children:[nh.jsxDEV(j,{color:n.bashBorder,children:K_.terminal},void 0,!1,void 0,this),nh.jsxDEV(j,{color:n.bashBorder,children:"terminal"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),nh.jsxDEV(ht,{marginLeft:2,children:nh.jsxDEV(j,{color:n.text,children:t.content},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(t.role==="thinking"){if(!D)return nh.jsxDEV(ht,{flexDirection:"row",marginTop:u,marginLeft:2,gap:1,children:[nh.jsxDEV(j,{color:n.textSubtle,children:K_.thinking},void 0,!1,void 0,this),nh.jsxDEV(j,{color:n.textSubtle,children:t.thinkingMs!=null?"Thought for "+Math.round(t.thinkingMs/1000)+" seconds (ctrl+o to expand)":"Thought (ctrl+o to expand)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return nh.jsxDEV(ht,{flexDirection:"column",marginTop:u,marginLeft:2,children:[nh.jsxDEV(ht,{flexDirection:"row",gap:1,children:[nh.jsxDEV(j,{color:n.textSubtle,children:K_.thinking},void 0,!1,void 0,this),nh.jsxDEV(j,{color:n.textSubtle,italic:!0,children:"Thinking"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),nh.jsxDEV(ht,{marginLeft:1,paddingLeft:1,paddingRight:1,paddingTop:1,paddingBottom:1,backgroundColor:n.thinkingBg,children:nh.jsxDEV(ht,{flexShrink:1,children:nh.jsxDEV(u2,{content:t.content,dimmed:!0,theme:h},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}return nh.jsxDEV(ht,{flexDirection:"column",marginTop:u,children:nh.jsxDEV(ht,{flexDirection:"row",gap:1,children:[nh.jsxDEV(j,{color:n.suggestion,children:K_.assistant},void 0,!1,void 0,this),nh.jsxDEV(ht,{flexDirection:"column",flexShrink:1,children:nh.jsxDEV(u2,{content:t.content,theme:h},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function Vci({provider:t,agentName:h,theme:i="dark"}){let _=Fi(i);if((process.stdout.columns??80)<60)return nh.jsxDEV(ht,{flexDirection:"column",marginLeft:1,marginTop:1,children:[nh.jsxDEV(ht,{flexDirection:"row",gap:1,children:[nh.jsxDEV(j,{color:_.primary,children:K_.agent+" DeepSeek Code"},void 0,!1,void 0,this),nh.jsxDEV(j,{color:_.textDim,children:"v"+d_.version},void 0,!1,void 0,this)]},void 0,!0,void 0,this),h&&nh.jsxDEV(j,{color:_.primary,children:"["+h+"]"},void 0,!1,void 0,this),nh.jsxDEV(j,{color:_.textDim,children:"/help \xB7 /quit to exit"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return nh.jsxDEV(ht,{flexDirection:"row",gap:2,marginLeft:1,marginTop:1,children:[nh.jsxDEV(ht,{flexDirection:"column",children:[nh.jsxDEV(j,{color:_.primary,children:" \u2584\u2584\u2588\u2588\u2588\u2584\u2584"},void 0,!1,void 0,this),nh.jsxDEV(j,{color:_.primary,children:" \u2584\u2588 \u25C9 \u2588\u2588\u2584"},void 0,!1,void 0,this),nh.jsxDEV(j,{color:_.primary,children:"\u2588 ~~\u2588"},void 0,!1,void 0,this),nh.jsxDEV(j,{color:_.primary,children:" \u2580\u2584\u2584\u2588\u2584\u2584\u2584\u2584\u2588\u2580"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),nh.jsxDEV(ht,{flexDirection:"column",children:[nh.jsxDEV(ht,{flexDirection:"row",gap:1,children:[nh.jsxDEV(j,{color:_.primary,children:K_.agent+" DeepSeek Code"},void 0,!1,void 0,this),nh.jsxDEV(j,{color:_.textDim,children:"v"+d_.version},void 0,!1,void 0,this),nh.jsxDEV(j,{color:_.textDim,children:"\xB7"},void 0,!1,void 0,this),nh.jsxDEV(j,{color:_.textDim,children:t},void 0,!1,void 0,this),h&&nh.jsxDEV(nh.Fragment,{children:[nh.jsxDEV(j,{color:_.textDim,children:"\xB7"},void 0,!1,void 0,this),nh.jsxDEV(j,{color:_.primary,children:"["+h+"]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),nh.jsxDEV(ht,{flexDirection:"row",gap:1,children:[nh.jsxDEV(j,{color:_.textDim,children:"cwd:"},void 0,!1,void 0,this),nh.jsxDEV(j,{color:_.primary,children:process.cwd()},void 0,!1,void 0,this)]},void 0,!0,void 0,this),nh.jsxDEV(j,{color:_.textDim,children:"/help for commands \xB7 /quit to exit"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function FDh({messages:t,streamText:h,thinkingText:i,streamRole:_="assistant",theme:f,activeAgent:w,headerProvider:D,headerAgent:$,showToolCalls:n=!0,showDiffs:u=!0,showWordDiff:z=!0,density:O="comfortable",fullMode:M=!1,thinkingStartedAt:A=null,onOpenDiff:W}){let J=Fi(f),P=w??"deepseek",T=new Map;for(let E of t){if(E.role!=="tool")continue;let v=Je(E.content);if(!v)continue;let G=T.get(v.path)??{path:v.path,added:0,removed:0};G.added+=v.added,G.removed+=v.removed,T.set(v.path,G)}let C=M?t.map((E,v)=>({kind:"message",message:E,index:v})):cci(t);return nh.jsxDEV(ht,{flexDirection:"column",marginBottom:O==="compact"?0:1,children:[nh.jsxDEV(Vci,{provider:D??"deepseek",agentName:$??null,theme:f},void 0,!1,void 0,this),C.map((E)=>{if(E.kind==="truncated")return nh.jsxDEV(ht,{marginTop:1,children:nh.jsxDEV(j,{color:J.textSubtle,children:Ywt(Gci)},void 0,!1,void 0,this)},`truncated-${E.index}`,!1,void 0,this);let{message:v,index:G}=E;if(v.role==="tool"&&!n)return null;let k=M&&n&&Zci(t,G);return nh.jsxDEV(ht,{flexDirection:"column",children:[k&&nh.jsxDEV(kci,{theme:f},void 0,!1,void 0,this),nh.jsxDEV(eci,{message:v,theme:f,agentLabel:P,showDiffs:u,showWordDiff:z,compact:k||O==="compact",fullMode:M,onOpenDiff:W},void 0,!1,void 0,this),v.role==="assistant"&&v.workedMs!=null&&nh.jsxDEV(j,{color:J.textSubtle,children:Rci(v.workedMs)},void 0,!1,void 0,this)]},`${v.role}-${G}`,!0,void 0,this)}),T.size>0&&nh.jsxDEV(ht,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[nh.jsxDEV(j,{color:J.textDim,children:"Changed files \xB7 Ctrl+D opens the latest diff"},void 0,!1,void 0,this),nh.jsxDEV(VDh,{files:[...T.values()],theme:f},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i?nh.jsxDEV(jci,{content:i,fullMode:M,startedAt:A,theme:f},void 0,!1,void 0,this):null,h?nh.jsxDEV(ht,{flexDirection:"column",marginTop:1,children:_==="terminal"?nh.jsxDEV(nh.Fragment,{children:[nh.jsxDEV(ht,{flexDirection:"row",gap:1,children:[nh.jsxDEV(j,{color:J.bashBorder,children:K_.terminal},void 0,!1,void 0,this),nh.jsxDEV(j,{color:J.bashBorder,children:"terminal"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),nh.jsxDEV(ht,{marginLeft:2,children:nh.jsxDEV(j,{color:J.text,children:h},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):nh.jsxDEV(ht,{flexDirection:"row",gap:1,children:[nh.jsxDEV(j,{color:J.suggestion,children:K_.assistant},void 0,!1,void 0,this),nh.jsxDEV(ht,{flexDirection:"column",flexShrink:1,children:nh.jsxDEV(u2,{content:h,streaming:!0,theme:f},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this):null,M&&nh.jsxDEV(ht,{flexDirection:"column",marginTop:1,children:[nh.jsxDEV(j,{color:J.textSubtle,children:Ywt()},void 0,!1,void 0,this),nh.jsxDEV(ht,{flexDirection:"row",justifyContent:"space-between",paddingLeft:1,paddingRight:1,children:[nh.jsxDEV(j,{color:J.textSubtle,children:"Full mode \xB7 ctrl+o to toggle"},void 0,!1,void 0,this),nh.jsxDEV(j,{color:J.textSubtle,children:"verbose"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function jci({content:t,fullMode:h,startedAt:i,theme:_}){let f=Fi(_);if(_7(),h)return nh.jsxDEV(ht,{flexDirection:"column",marginTop:1,marginLeft:2,children:[nh.jsxDEV(ht,{flexDirection:"row",gap:1,children:[nh.jsxDEV(j,{color:f.textSubtle,children:K_.thinking},void 0,!1,void 0,this),nh.jsxDEV(j,{color:f.textSubtle,italic:!0,children:"Thinking"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),nh.jsxDEV(ht,{marginLeft:1,paddingLeft:1,paddingRight:1,paddingTop:1,paddingBottom:1,backgroundColor:f.thinkingBg,children:nh.jsxDEV(ht,{flexShrink:1,children:nh.jsxDEV(u2,{content:t,dimmed:!0,theme:_},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(i==null)return nh.jsxDEV(ht,{flexDirection:"row",marginTop:1,marginLeft:2,gap:1,children:[nh.jsxDEV(j,{color:f.textSubtle,children:K_.thinking},void 0,!1,void 0,this),nh.jsxDEV(j,{color:f.textSubtle,children:"Thinking..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let w=Math.floor((Date.now()-i)/1000);return nh.jsxDEV(ht,{flexDirection:"row",marginTop:1,marginLeft:2,gap:1,children:[nh.jsxDEV(j,{color:f.textSubtle,children:K_.thinking},void 0,!1,void 0,this),nh.jsxDEV(j,{color:f.textSubtle,children:"Thinking for "+w+" seconds..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}ci();Ii();u1();var Xe=b(Li(),1),yDh=b(Oh(),1),lDh=Xe.createContext("dark");function EO({value:t,children:h}){return yDh.jsxDEV(lDh.Provider,{value:t,children:h},void 0,!1,void 0,this)}function kK(){return Fi(Xe.useContext(lDh))}ci();var Bci=b(Oh(),1);Ii();var Fci=b(Oh(),1);ci();Ii();var UDh=b(Oh(),1);ci();Ii();ff();var IDh=b(Li(),1);var X9=b(Oh(),1);function Jwt({title:t,subtitle:h,onConfirm:i,onCancel:_,confirmLabel:f="Yes",cancelLabel:w="No",children:D}){let $=kK();return h0(IDh.useCallback((n,u)=>{if(u.escape)_();if(u.return)i()},[i,_])),X9.jsxDEV(ht,{flexDirection:"column",borderStyle:"round",borderColor:$.primary,paddingLeft:1,paddingRight:1,children:[X9.jsxDEV(j,{color:$.primary,bold:!0,children:t},void 0,!1,void 0,this),h&&X9.jsxDEV(j,{color:$.textDim,children:h},void 0,!1,void 0,this),X9.jsxDEV(ht,{flexDirection:"column",marginTop:1,children:D},void 0,!1,void 0,this),X9.jsxDEV(ht,{marginTop:1,gap:2,children:[X9.jsxDEV(j,{color:$.textDim,children:["Enter: ",f]},void 0,!0,void 0,this),X9.jsxDEV(j,{color:$.textDim,children:["Esc: ",w]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}Ii();var lci=b(Oh(),1);u1();var NO=b(Oh(),1);function gDh({path:t,lines:h,onClose:i,theme:_}){let f=Fi(_),w=process.stdout.columns??80,D=h.reduce((z,O)=>Math.max(z,O.lineNo),0),$=Math.max(String(D).length,2),n=$+3,u=Math.max(1,w-n-6);return NO.jsxDEV(Jwt,{title:t,onConfirm:i,onCancel:i,confirmLabel:"close",cancelLabel:"close",children:NO.jsxDEV(ht,{flexDirection:"column",children:h.map((z,O)=>{let M=z.type==="added",A=z.type==="removed",W=M?"+":A?"-":" ",J=M?f.diffAdded:A?f.diffRemoved:void 0,P=M?f.diffAddedWord:A?f.diffRemovedWord:f.textDim,T=z.text.startsWith("+")||z.text.startsWith("-")||z.text.startsWith(" ")?z.text.slice(1):z.text,C=T.length>u?T.slice(0,u-1)+"\u2026":T,E=" ".repeat(Math.max(0,u-C.length)),v=M||z.type==="context"?String(z.lineNo).padStart($):" ".repeat($);return NO.jsxDEV(ht,{flexDirection:"row",children:[NO.jsxDEV(j,{backgroundColor:J,color:f.textSubtle,dimColor:!M&&!A,children:" "+v+" "+W+" "},void 0,!1,void 0,this),NO.jsxDEV(j,{backgroundColor:J,color:P,children:C+E},void 0,!1,void 0,this)]},O,!0,void 0,this)})},void 0,!1,void 0,this)},void 0,!1,void 0,this)}Fc();ci();Ii();var Pe=b(Li(),1),ZO=b(Oh(),1),yci={pending:"\u25CB",in_progress:"\u25C9",done:"\u25CF"},Uci={pending:"#888888",in_progress:"yellow",done:"green"};function QDh(){let[t,h]=Pe.useState(XK);if(Pe.useEffect(()=>{return Bc(()=>h(XK()))},[]),!t.length)return null;return ZO.jsxDEV(ht,{flexDirection:"column",border:!0,borderStyle:"rounded",borderColor:"cyan",paddingLeft:1,paddingRight:1,marginBottom:1,children:[ZO.jsxDEV(j,{color:"cyan",children:"\u25C6 TODO ("+t.length+")"},void 0,!1,void 0,this),t.map((i)=>ZO.jsxDEV(ht,{flexDirection:"row",gap:1,children:[ZO.jsxDEV(j,{color:Uci[i.status],children:yci[i.status]},void 0,!1,void 0,this),ZO.jsxDEV(j,{color:i.status==="done"?"#888888":void 0,children:i.title},void 0,!1,void 0,this)]},i.id,!0,void 0,this))]},void 0,!0,void 0,this)}var Le=b(Li(),1);u1();ci();Ii();var GO=b(Oh(),1),mDh=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function oDh({tool:t,theme:h="dark"}){let i=Fi(h),_=qe[t.name]??t.name,f=t.done?t.result??"":t.args??"",w;if(t.name==="subagent"&&!t.done&&t.args)try{let M=JSON.parse(t.args),A=typeof M.task==="string"?M.task:f,W=A.split(`
3248
3248
  `).map((J)=>J.replace(/^#+\s*/,"").trim()).find((J)=>J.length>0)??A;w=W.length>60?W.slice(0,60)+"\u2026":W}catch{w=f.length>60?f.slice(0,60)+"\u2026":f}else if(w=f.length>60?f.slice(0,60)+"\u2026":f,t.done&&t.result)w=kP(t.name,t.result);else if(!t.done&&t.args)try{let M=JSON.parse(t.args);if(M&&typeof M==="object"&&!Array.isArray(M))w=Me(t.name,M)}catch{}let D=_7(),[$,n]=Le.useState(0);Le.useEffect(()=>{if(n(0),t.done)return;let M=setInterval(()=>n((A)=>A+1),1000);return()=>clearInterval(M)},[t.name,t.done]);let u=He[_]||{icon:"\u25B8",color:i.textDim},z=t.done?K_.assistant:mDh[D%mDh.length],O=t.done?"error"in t&&t.error?i.error:i.success:i.primary;return GO.jsxDEV(ht,{flexDirection:"row",paddingLeft:2,gap:1,children:[GO.jsxDEV(j,{color:O,children:z},void 0,!1,void 0,this),GO.jsxDEV(j,{color:u.color,children:_},void 0,!1,void 0,this),w?GO.jsxDEV(j,{color:i.textSubtle,children:w},void 0,!1,void 0,this):null,!t.done&&$>0&&GO.jsxDEV(j,{color:i.textDim,children:$+"s"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}KD();ci();Ii();u1();var xDh=b(Li(),1);var sDh=b(Oh(),1);ci();var Qci=b(Oh(),1);function Xwt(){let t={agents:[],onSubagentStart({id:h,task:i,role:_,agentName:f,mode:w,model:D,workspace:$,workflowRunId:n,workflowPhase:u,prompt:z}){let O=t.agents.find((A)=>A.id===h);if(O){O.task=i,O.status="running",O.role=_??O.role,O.agentName=f??O.agentName,O.mode=w??O.mode,O.model=D??O.model,O.workspace=$??O.workspace,O.workflowRunId=n??O.workflowRunId,O.workflowPhase=u??O.workflowPhase,O.prompt=z??O.prompt;return}let M={id:h,task:i,status:"running",colorIndex:t.agents.length,toolCount:0,lastToolInfo:null,startedAt:Date.now(),durationMs:null,result:null,error:null,tokens:null,costUsd:null,role:_??null,confidence:null,verified:null,agentName:f??null,mode:w,messages:[{role:"user",content:z??i}],model:D??null,workspace:$??null,workflowRunId:n??null,workflowPhase:u??null,prompt:z??null};t.agents.push(M)},onSubagentProgress({id:h,info:i}){let _=t.agents.find((f)=>f.id===h);if(_)_.lastToolInfo=i},onSubagentToolUse({id:h,tool:i,info:_}){let f=t.agents.find((w)=>w.id===h);if(f)f.toolCount++,f.lastToolInfo=_??i},onSubagentDone({id:h,result:i,tokens:_,costUsd:f,structured:w,confidence:D,verified:$}){let n=t.agents.find((u)=>u.id===h);if(n){if(n.status="done",n.result=i,n.durationMs=Date.now()-n.startedAt,_!=null)n.tokens=_;if(f!=null)n.costUsd=f;if(w)n.confidence=w.confidence;if(D!=null)n.confidence=D;if($!=null)n.verified=$}},onSubagentError({id:h,error:i}){let _=t.agents.find((f)=>f.id===h);if(_)_.status="error",_.error=i,_.durationMs=Date.now()-_.startedAt},onSubagentState({id:h,status:i,task:_,role:f,agentName:w,mode:D,model:$,workspace:n,workflowRunId:u,workflowPhase:z,prompt:O,error:M,tokens:A}){let W=t.agents.find((J)=>J.id===h);if(!W)t.onSubagentStart({id:h,task:_??h,role:f,agentName:w,mode:D,model:$,workspace:n,workflowRunId:u,workflowPhase:z,prompt:O}),W=t.agents.find((J)=>J.id===h);if(i!==void 0)W.status=i;if(D)W.mode=D;if($!=null)W.model=$;if(n!=null)W.workspace=n;if(u!=null)W.workflowRunId=u;if(z!=null)W.workflowPhase=z;if(O!=null)W.prompt=O;if(A!=null)W.tokens=A;if(M)W.error=M;if(i!==void 0&&["done","failed","error","cancelled","timed_out"].includes(i))W.durationMs=Date.now()-W.startedAt},onSubagentMessage({id:h,role:i,content:_}){let f=t.agents.find((D)=>D.id===h);if(!f)return;if(!f.messages)f.messages=[];let w=f.messages[f.messages.length-1];if(w&&w.role===i)w.content+=_;else f.messages.push({role:i,content:_})},clearResolved(){t.agents=t.agents.filter((h)=>h.workflowRunId||["queued","running","blocked"].includes(h.status))}};return t}ci();Ii();var Te=b(Li(),1),mci=b(Oh(),1);function dDh(t){let[h,i]=Te.useState([]);return Te.useEffect(()=>{let _=!0;t.list().then((w)=>{if(!_)return;i((D)=>D.length?[...D,...w.filter(($)=>!D.some((n)=>n.runId===$.runId))]:w)});let f=t.subscribe((w)=>{i((D)=>{let $=D.filter((n)=>n.runId!==w.run.runId);return[w.run,...$]})});return()=>{_=!1,f()}},[t]),h}ff();ci();Ii();u1();var a6=b(Li(),1);var oci={queued:"\u27F3",running:"\u27F3",paused:"\u23F8",completed:"\u2714",failed:"\u2718",cancelled:"\u2718",timed_out:"\u231B",budget_exhausted:"\u231B"},xci={queued:"\u25CC",running:"\u25CF",blocked:"\u2161",done:"\u2714",failed:"\u2718",error:"\u2718",cancelled:"\u2718",timed_out:"\u231B"},sci=new Set(["queued","running","paused"]),dci=new Set(["queued","running","blocked"]),pci=[{label:"running",statuses:["queued","running"]},{label:"paused",statuses:["paused"]},{label:"completed",statuses:["completed"]},{label:"stopped",statuses:["cancelled"]},{label:"failed",statuses:["failed","timed_out","budget_exhausted"]}];function pDh(t){return oci[t]??"\u2022"}function Ce(t){return xci[t]??"\u2022"}function vO(t){return sci.has(t)}function Se(t){return dci.has(t)}function M6(t,h){if(h<=0)return"";return t.length<=h?t:`${t.slice(0,Math.max(0,h-1))}\u2026`}function Ee(t){let h=Math.max(0,Math.floor(t/1000));return h<60?`${h}s`:`${Math.floor(h/60)}m ${h%60}s`}function aDh(t){let h=Math.max(0,Math.floor(t/1000));return h<60?`${h}s`:`${Math.floor(h/60)}m${h%60}s`}function Ne(t){if(t>=1e6)return`${(t/1e6).toFixed(1)}m`;if(t>=1000){let h=t/1000;return Number.isInteger(h)?`${h}k`:`${h.toFixed(1)}k`}return`${t}`}function Pwt(t,h=Date.now()){let i=Date.parse(t.startedAt??t.createdAt),_=t.completedAt?Date.parse(t.completedAt):h;return Number.isFinite(i)&&Number.isFinite(_)?Math.max(0,_-i):0}function t9h(t){return pci.map((h)=>({label:h.label,count:t.filter((i)=>h.statuses.includes(i.status)).length})).filter((h)=>h.count>0).map((h)=>`${h.count} ${h.label}`).join(" \xB7 ")}function h9h(t,h,i=Date.now()){let _=`${t.usage.agents} agent${t.usage.agents===1?"":"s"} \xB7 ${Ne(t.usage.tokens)} tok \xB7 ${Ee(Pwt(t,i))}`;return M6(`${pDh(t.status)} ${t.meta.name} ${_}`,h)}function i9h(t,h,i=Date.now()){let _=h.filter((D)=>!Se(D.status)).length,f=Math.max(t.usage.agents,h.length),w=`${_}/${f} agents \xB7 ${aDh(Pwt(t,i))}`;if(vO(t.status))return w;return`${w} \xB7 ${t.status==="completed"?"done":t.status}`}function _9h(t,h,i,_,f,w){let $=`${i==="done"?"\u2714":`${h+1}`} ${t}`;if(i==="pending")return M6($,w);let n=`${_}/${f}`,u=Math.max(1,w-$.length-n.length);return M6(`${$}${" ".repeat(u)}${n}`,w)}function f9h(t,h,i=Date.now(),_=0){let f=Ee(t.durationMs??Math.max(0,i-t.startedAt)),w=M6(t.task||"agent",Math.max(8,_)).padEnd(_),D=t.status==="queued"?[t.model,"queued"].filter(Boolean).join(" \xB7 "):[t.model,t.tokens==null?void 0:`${Ne(t.tokens)} tok`].filter(Boolean).join(" \xB7 "),$=`${Ce(t.status)} ${w} ${D}`,n=Math.max(1,h-$.length-f.length);return M6(`${$}${" ".repeat(n)}${f}`,h)}function w9h(t){let h=["\u2191/\u2193 to select","Enter to view"];if(t&&vO(t))h.push("x to stop");return h.push("s to save","Esc to close"),h.join(" \xB7 ")}function Lwt(t,h,i){let _=Math.max(1,i),f=Math.min(Math.max(0,h-_+1),Math.max(0,t.length-_));return{rows:t.slice(f,f+_),start:f}}function D9h(t){return[...new Set([...(t.meta.phases??[]).map((h)=>h.title),...t.phaseHistory??[],...t.phase?[t.phase]:[]])]}function Twt(t,h,i,_){let f=t.filter((w)=>w.workflowPhase===h);if(f.length)return f;if(t.some((w)=>w.workflowPhase))return[];return i.length<=1||h===_?t:[]}function r9h(t){let h=Math.max(0,...t.map((i)=>`${i.index+1} ${i.phase}`.length+(i.counter?i.counter.length+1:0)));return Math.min(30,Math.max(11,h))}function $9h(t,h,i){if(i.length)return i.every((f)=>!Se(f.status))?"done":"active";if(!(h.phase===t||(h.phaseHistory?.includes(t)??!1)))return"pending";return vO(h.status)&&h.phase===t?"active":"done"}var F0=b(Oh(),1);function aci(t,h,i,_){let f=(w,D)=>{let $=M6(w,Math.max(1,D-2));return` ${$} ${"\u2500".repeat(Math.max(0,D-$.length-2))}`};return`\u256D${f(t,h)}\u252C${f(i,_)}\u256E`}function tki(t,h,i){let _=i?`${"\u2500".repeat(Math.max(0,h-i.length-3))} ${i} `:"\u2500".repeat(h);return`\u2570${"\u2500".repeat(t)}\u2534${_}\u256F`}function hki(t,h,i,_){let f=(w,D)=>M6(w,D).padEnd(D);return`\u2502 ${f(t,Math.max(0,h-2))} \u2502${f(i,_)}\u2502`}function K9h(t,h){if(h<=0)return[];let i=[];for(let _ of t.split(`
3249
3249
  `)){if(!_.length){i.push("");continue}for(let f=0;f<_.length;f+=h)i.push(_.slice(f,f+h))}return i}function iki(t,h,i){let _=Ee(t.durationMs??Math.max(0,i-t.startedAt)),f=t.status==="done"?"Completed":t.status.charAt(0).toUpperCase()+t.status.slice(1),w=[t.tokens==null?void 0:`${Ne(t.tokens)} tok`,_].filter(Boolean).join(" \xB7 ");return[`${Ce(t.status)} ${f}${t.model?` \xB7 ${t.model}`:""}`,w,"","Prompt",...K9h(t.prompt??t.task,Math.max(8,h-2)).map((D)=>` ${D}`),...t.result?["",...K9h(t.result,h)]:[],...t.error?["",`\u2718 ${M6(t.error,h-2)}`]:[]]}function n9h({runs:t,agents:h=[],initialRunId:i,theme:_="dark",onClose:f,onPause:w,onResume:D,onStop:$,onRestart:n,onSave:u}){let z=Fi(_);_7();let[O,M]=a6.useState(i?"run":"list"),[A,W]=a6.useState(()=>i??t[0]?.runId),[J,P]=a6.useState(0),[T,C]=a6.useState(0),[E,v]=a6.useState(0),[G,k]=a6.useState(null),[I,l]=a6.useState(""),B=a6.useRef(void 0),o=Math.max(30,(process.stdout.columns??80)-6),R=process.stdout.rows??24,F=Date.now(),a=Math.max(0,t.findIndex((Nt)=>Nt.runId===A)),_t=t[a],g=_t?h.filter((Nt)=>Nt.workflowRunId===_t.runId):[],V=_t?D9h(_t):[],Vt=V[Math.min(J,Math.max(0,V.length-1))],Rt=_t&&Vt?Twt(g,Vt,V,_t.phase):g,Dh=Rt[Math.min(T,Math.max(0,Rt.length-1))];if(a6.useEffect(()=>{if(!t.length){W(void 0);return}if(!t.some((Nt)=>Nt.runId===A))W(t[0].runId)},[t,A]),a6.useEffect(()=>{if(!i||B.current===i)return;if(!t.some((Nt)=>Nt.runId===i))return;B.current=i,W(i),M("run")},[i,t]),h0((Nt,$h,Jt)=>{if(Jt.stopImmediatePropagation(),G!==null){if($h.escape){k(null);return}if($h.backspace||$h.delete){k((bt)=>bt.slice(0,-1));return}if($h.return){if(!_t||!G.trim())return;u(_t.runId,G.trim()).then((bt)=>{l(`Saved to ${bt}`),k(null)}).catch((bt)=>l(bt.message));return}if(!$h.ctrl&&!$h.meta&&Nt&&!Nt.startsWith("\x1B"))k((bt)=>bt+Nt);return}if($h.escape){if(O==="agent")M("run"),v(0);else if(O==="run")M("list"),l("");else f();return}if(!t.length||!_t)return;if(Nt==="s"){k(_t.meta.name);return}if(O==="list"){if($h.upArrow){W(t[(a-1+t.length)%t.length].runId);return}if($h.downArrow){W(t[(a+1)%t.length].runId);return}if($h.return){M("run"),P(0);return}if(Nt==="x"&&vO(_t.status))$(_t.runId).then((bt)=>l(bt?"Workflow stopping.":"Workflow is not active.")).catch((bt)=>l(bt.message));else if(Nt==="p"&&_t.status==="running")w(_t.runId).then((bt)=>l(bt?"Workflow paused.":"Workflow is not running.")).catch((bt)=>l(bt.message));else if(Nt==="p"&&_t.status==="paused")D(_t.runId).then((bt)=>l(bt?"Workflow resumed.":"Workflow is not paused.")).catch((bt)=>l(bt.message));else if(Nt==="r"&&!vO(_t.status))n(_t.runId).catch((bt)=>l(bt.message));return}if(O==="run"){if($h.upArrow&&V.length){P((J-1+V.length)%V.length);return}if($h.downArrow&&V.length){P((J+1)%V.length);return}if($h.return&&Rt.length)M("agent"),C(0),v(0);return}if($h.upArrow&&Rt.length){C((T-1+Rt.length)%Rt.length),v(0);return}if($h.downArrow&&Rt.length){C((T+1)%Rt.length),v(0);return}if(Nt==="j")v((bt)=>bt+1);else if(Nt==="k")v((bt)=>Math.max(0,bt-1))}),G!==null)return F0.jsxDEV(ht,{flexDirection:"column",paddingX:2,children:[F0.jsxDEV(j,{color:z.primary,children:`Save workflow ${_t?.runId.slice(0,8)??""}`},void 0,!1,void 0,this),F0.jsxDEV(j,{children:`Name: ${G}\u2588`},void 0,!1,void 0,this),I&&F0.jsxDEV(j,{color:z.error,children:M6(I,o)},void 0,!1,void 0,this),F0.jsxDEV(j,{color:z.textSubtle,children:"Enter save \xB7 Esc cancel"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(O!=="list"&&_t){let Nt=Math.max(6,R-9),$h=O==="agent",Jt=$h?Rt.map((nt,it)=>`${it===T?"\u276F":" "} ${Ce(nt.status)} ${nt.task}`):(()=>{let nt=V.map((Ot,ft)=>{let Kt=Twt(g,Ot,V,_t.phase),Ct=Kt.filter((uh)=>!Se(uh.status)).length,vt=Kt.length||(_t.phase===Ot?Math.max(1,_t.usage.agents):0),rh=$9h(Ot,_t,Kt);return{phase:Ot,index:ft,state:rh,done:Ct,total:vt,counter:rh==="pending"?"":`${Ct}/${vt}`}}),it=r9h(nt);return nt.map((Ot)=>`${Ot.index===J?"\u276F":" "} ${_9h(Ot.phase,Ot.index,Ot.state,Ot.done,Ot.total,it)}`)})(),bt=Math.min(34,Math.max(12,Math.max(0,...Jt.map((nt)=>nt.length))+2)),Xh=Math.max(12,o-bt-3),Qt=Math.min(20,Math.max(0,...Rt.map((nt)=>nt.task.length))),Th=$h&&Dh?iki(Dh,Xh-2,F).map((nt)=>` ${nt}`):Rt.map((nt)=>` ${f9h(nt,Xh-3,F,Qt)}`),Ch=$h?T:J,U=Lwt(Jt,Ch,Nt),s=Math.min(E,Math.max(0,Th.length-Nt)),d=Th.slice(s,s+Nt),$t=$h&&Th.length>Nt?`${s+1}\u2013${Math.min(Th.length,s+Nt)} of ${Th.length} \u2193`:void 0,rt=$h?Dh?.task??"Agent":`${Vt??"Waiting"} \xB7 ${Rt.length} agent${Rt.length===1?"":"s"}`,qt=$h?`${Vt??"Phase"} \xB7 ${Rt.length} agents`:"Phases";return F0.jsxDEV(ht,{flexDirection:"column",children:[F0.jsxDEV(j,{color:z.textDim,children:` ${"\u2500".repeat(o)}`},void 0,!1,void 0,this),F0.jsxDEV(j,{color:z.primary,bold:!0,children:` ${M6(_t.meta.name,o)}`},void 0,!1,void 0,this),F0.jsxDEV(j,{color:z.textDim,children:` ${M6(_t.meta.description??"Dynamic Workflow",Math.max(12,o-30)).padEnd(Math.max(12,o-28))}${i9h(_t,g,F)}`},void 0,!1,void 0,this),F0.jsxDEV(j,{children:" "},void 0,!1,void 0,this),F0.jsxDEV(j,{color:z.textDim,children:` ${aci(qt,bt,rt,Xh)}`},void 0,!1,void 0,this),Array.from({length:Nt},(nt,it)=>{let Ot=U.rows[it]??"",ft=d[it]??"",Kt=U.start+it===Ch;return F0.jsxDEV(j,{color:it<U.rows.length&&Kt?z.primary:z.textDim,children:` ${hki(Ot,bt,ft,Xh)}`},it,!1,void 0,this)}),F0.jsxDEV(j,{color:z.textDim,children:` ${tki(bt,Xh,$t)}`},void 0,!1,void 0,this),I&&F0.jsxDEV(j,{color:z.warning,children:` ${M6(I,o)}`},void 0,!1,void 0,this),F0.jsxDEV(j,{color:z.textSubtle,children:$h?" \u2191\u2193 agent \xB7 j/k scroll \xB7 esc back \xB7 s save":" \u2191\u2193 select \xB7 esc back \xB7 s save"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}let Tt=Lwt(t,a,Math.max(3,R-8));return F0.jsxDEV(ht,{flexDirection:"column",children:[F0.jsxDEV(j,{color:z.text,bold:!0,children:" Dynamic workflows"},void 0,!1,void 0,this),t.length>0&&F0.jsxDEV(j,{color:z.textSubtle,children:` ${t9h(t)}`},void 0,!1,void 0,this),F0.jsxDEV(j,{children:" "},void 0,!1,void 0,this),t.length===0?F0.jsxDEV(j,{color:z.textDim,children:" No dynamic workflows in this session."},void 0,!1,void 0,this):F0.jsxDEV(F0.Fragment,{children:[Tt.start>0&&F0.jsxDEV(j,{color:z.textSubtle,children:` \u2191 ${Tt.start} earlier runs`},void 0,!1,void 0,this),Tt.rows.map((Nt,$h)=>{let Jt=Tt.start+$h===a;return F0.jsxDEV(j,{color:["failed","cancelled"].includes(Nt.status)?z.error:Jt?z.primary:z.textDim,children:` ${Jt?"\u276F ":" "}${h9h(Nt,o-5,F)}`},Nt.runId,!1,void 0,this)}),Tt.start+Tt.rows.length<t.length&&F0.jsxDEV(j,{color:z.textSubtle,children:` \u2193 ${t.length-Tt.start-Tt.rows.length} later runs`},void 0,!1,void 0,this)]},void 0,!0,void 0,this),F0.jsxDEV(j,{children:" "},void 0,!1,void 0,this),I&&F0.jsxDEV(j,{color:z.warning,children:` ${M6(I,o)}`},void 0,!1,void 0,this),F0.jsxDEV(j,{color:z.textSubtle,children:` ${t.length?w9h(_t?.status):"Esc to close"}`},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}ff();ci();Ii();C1t();u1();var RO=b(Li(),1);var Y3=b(Oh(),1),_ki=new Set(["queued","running"]),O9h=new Set(["queued","running","blocked"]),Cwt=new Set(["blocked","failed","error","cancelled","timed_out"]),u9h={queued:"\u25CC",running:"\u25EF",blocked:"\u2161",done:"\u2713",completed:"\u2713",failed:"\u2718",error:"\u2718",cancelled:"\u2718",timed_out:"\u231B"};function VP(t,h){if(h<=0)return"";return t.length<=h?t:`${t.slice(0,Math.max(0,h-1))}\u2026`}function Swt(t){let h=Math.max(0,Math.floor(t/1000));if(h<60)return`${h}s`;return`${Math.floor(h/60)}m ${h%60}s`}function z9h(t){if(t==null)return;if(t>=1e6)return`${(t/1e6).toFixed(1)}m tok`;if(t>=1000)return`${(t/1000).toFixed(1)}k tok`;return`${t} tok`}function q9h(t){if(t==null)return;if(t>=1e6)return`${(t/1e6).toFixed(1)}m tokens`;if(t>=1000)return`${(t/1000).toFixed(1)}k tokens`;return`${t} tokens`}function fki(t,h){return`${h.filter((_)=>!O9h.has(_.status)).length}/${t.usage.agents} agents done`}function wki(t){let h=t.agentName;if(h&&Tfh(h))return{label:Cfh(h).displayName,fixed:!0};return{label:h||"Subagent",fixed:!1}}function Dki(t,h){let i=t.filter((f)=>!f.workflowRunId).map((f)=>{let w=wki(f);return{kind:"agent",id:f.id,...w,description:f.task,status:f.status,active:O9h.has(f.status),startedAt:f.startedAt,agent:f}}),_=h.filter((f)=>_ki.has(f.status)).map((f)=>({kind:"workflow",id:f.runId,label:f.meta.name,description:f.meta.description??f.phase??"Dynamic Workflow",status:f.status,fixed:!1,active:!0,startedAt:Date.parse(f.startedAt??f.createdAt)||Date.now(),run:f,agents:t.filter((w)=>w.workflowRunId===f.runId)}));return[...i,..._].sort((f,w)=>f.startedAt-w.startedAt)}function rki(t,h=5){let i=t.slice(0,Math.max(0,h));return{rows:i,overflow:Math.max(0,t.length-i.length)}}function $ki(t){if(!t)return"\u2191/\u2193 to select";let h="\u2191/\u2193 to select \xB7 Enter to view",i=[];if(t.kind==="workflow"){if(i.push("x stop"),t.run.status==="running")i.push("p pause")}else if(t.active)i.push("x stop");if(t.kind==="agent"&&Cwt.has(t.agent.status))i.push("r resume");return i.length?`${h} \xB7 ${i.join(" \xB7 ")}`:h}function Kki(t,h,i=Date.now(),_){let f=_??"\u25EF",w=t.kind==="agent"&&t.agent.durationMs!=null?t.agent.durationMs:t.kind==="workflow"&&t.run.completedAt?Date.parse(t.run.completedAt)-t.startedAt:i-t.startedAt,D=[];if(t.kind==="agent")if(t.active){D.push(Swt(w));let z=q9h(t.agent.tokens);if(z)D.push(`\u2193 ${z}`)}else D.push("idle");else{D.push(fki(t.run,t.agents),Swt(w));let z=q9h(t.run.usage.tokens);if(z)D.push(`\u2193 ${z}`)}let $=`${f} ${t.label}`;if(h<55)return VP(`${$} \xB7 ${D[0]}`,h);let n=D.join(" \xB7 "),u=Math.max(8,h-$.length-n.length-6);return VP(`${$} ${VP(t.description,u)} ${n}`,h)}function nki(t,h){if(t.kind==="workflow"){let f=t.run;return[`${u9h[f.status]??"\u2022"} workflow ${f.meta.name} \xB7 ${f.status}${f.phase?` \xB7 ${f.phase}`:""}`,f.meta.description??"Dynamic Workflow",`${f.usage.agents} agents \xB7 ${z9h(f.usage.tokens)??"0 tok"} \xB7 $${f.usage.costUsd.toFixed(4)}`,...f.error?[`Error: ${f.error}`]:[]]}let i=t.agent,_=i.durationMs??Math.max(0,h-i.startedAt);return[`${u9h[i.status]??"\u2022"} ${t.label} \xB7 ${t.fixed?"fixed":"temporary"} \xB7 ${i.status}${i.mode?` \xB7 ${i.mode}`:""}`,i.task,`${i.role??"unclassified"} \xB7 ${Swt(_)} \xB7 ${i.toolCount} tools${i.tokens!=null?` \xB7 ${z9h(i.tokens)}`:""}`,...i.lastToolInfo?[`Latest: ${i.lastToolInfo}`]:[],...i.model?[`Model: ${i.model}`]:[],...i.workspace?[`Workspace: ${i.workspace}`]:[],...i.result?[`Result: ${i.result}`]:[],...i.error?[`Error: ${i.error}`]:[]]}function M9h({agents:t,workflows:h,open:i,onClose:_,onOpenWorkflow:f,onOpenSubagent:w,onSelectMain:D,onTaskAction:$,onWorkflowAction:n,theme:u="dark",mainLabel:z="main"}){let O=Fi(u);_7();let M=Date.now(),A=Dki(t,h),[W,J]=RO.useState(-1),[P,T]=RO.useState(!1),[C,E]=RO.useState(""),v=Math.max(20,(process.stdout.columns??80)-4),G=(R)=>void R.then(E).catch((F)=>E(F.message));if(RO.useEffect(()=>{if(!i){J(-1),T(!1),E("");return}if(!A.length)_();else if(W>=A.length)J(A.length-1)},[A.length,_,i,W]),h0((R,F,a)=>{if(a.stopImmediatePropagation(),F.escape){if(P)T(!1),E("");else _();return}if(P){if(F.upArrow||F.downArrow||F.return)return}else{if(F.upArrow){if(W===-1){_();return}J((g)=>g-1);return}if(F.downArrow){if(A.length===0)return;J((g)=>g===A.length-1?-1:g+1);return}}let _t=A[W];if(!_t){if(F.return)D?.();return}if(F.return){if(!P)if(_t.kind==="workflow")f(_t.run.runId);else if(w)w(_t.agent.id);else T(!0);return}if(R==="v"&&_t.kind==="agent"){T(!0);return}if(R==="x"&&_t.active){let g=_t.kind==="workflow"?n(_t.id,"stop"):$(_t.id,"cancel");G(g);return}if(R==="p"&&_t.kind==="workflow"&&_t.run.status==="running"){G(n(_t.id,"pause"));return}if(R==="r"&&_t.kind==="agent"&&Cwt.has(_t.agent.status))G($(_t.id,"resume"))},{isActive:i}),!A.length)return null;if(i&&P){let R=Math.min(W,A.length-1),F=A[R];return Y3.jsxDEV(ht,{flexDirection:"column",paddingLeft:2,children:[nki(F,M).map((a,_t)=>Y3.jsxDEV(j,{color:_t===0?O.primary:O.textDim,children:VP(a,v)},`${F.id}-${_t}`,!1,void 0,this)),C&&Y3.jsxDEV(j,{color:O.warning,children:VP(C,v)},void 0,!1,void 0,this),Y3.jsxDEV(j,{color:O.textSubtle,children:F.kind==="workflow"?F.run.status==="running"?"Esc back \xB7 x stop \xB7 p pause":"Esc back \xB7 x stop":Cwt.has(F.agent.status)?`Esc back${F.active?" \xB7 x stop":""} \xB7 r resume`:F.active?"Esc back \xB7 x stop":"Esc back"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}let k=i?8:5,I=i?Math.min(Math.max(0,W-k+1),Math.max(0,A.length-k)):0,l=rki(A.slice(I),k),B=i&&W===-1?"\u276F ":" ",o=i&&W!==-1?"\u25EF":"\u25CF";return Y3.jsxDEV(ht,{flexDirection:"column",paddingLeft:2,children:[Y3.jsxDEV(j,{color:W===-1?O.primary:O.textDim,children:`${B}${o} ${z}`},void 0,!1,void 0,this),l.rows.map((R,F)=>{let a=i&&I+F===W;return Y3.jsxDEV(j,{color:R.active?O.text:O.textDim,children:`${a?"\u276F ":" "}${Kki(R,i?v-4:v-2,M,a?"\u25CF":void 0)}`},`${R.kind}-${R.id}`,!1,void 0,this)}),l.overflow>0&&Y3.jsxDEV(j,{color:O.textSubtle,children:` \u2026 +${l.overflow} activities`},void 0,!1,void 0,this),i&&Y3.jsxDEV(j,{color:O.textSubtle,children:C||$ki(A[W])},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}ff();var Vf=b(Li(),1);z3();import{join as H9h}from"path";import{homedir as A9h}from"os";import{mkdir as uki}from"fs/promises";function W9h(){return H9h(process.env.HOME||A9h(),".deepseek","input_history.json")}var zki=200;async function Ewt(){try{return await n6(W9h())}catch{return[]}}async function Y9h(t){let h=t.trim();if(h.startsWith("/")||h.startsWith("!"))return;let i=await Ewt();if(i[i.length-1]===h)return;i.push(h);let _=W9h();await uki(H9h(process.env.HOME||A9h(),".deepseek"),{recursive:!0}),await fO(_,i.slice(-zki))}QF();class P9{text;columns;graphemeBoundaries;wordBoundaries;wrappedTextCache=null;static graphemeSegmenter=new Intl.Segmenter(void 0,{granularity:"grapheme"});static wordSegmenter=new Intl.Segmenter(void 0,{granularity:"word"});constructor(t,h){this.text=t.normalize("NFC"),this.columns=Math.max(1,h);let i=[0];for(let{index:f,segment:w}of P9.graphemeSegmenter.segment(this.text)){let D=f+w.length;if(D>i[i.length-1])i.push(D)}if(i[i.length-1]!==this.text.length)i.push(this.text.length);this.graphemeBoundaries=i;let _=[];for(let f of P9.wordSegmenter.segment(this.text))_.push({start:f.index,end:f.index+f.segment.length,isWordLike:Boolean(f.isWordLike)});this.wordBoundaries=_}nextOffset(t){let h=this.snapToGraphemeBoundary(t),i=0,_=this.graphemeBoundaries.length-1;while(i<=_){let f=i+_>>1;if(this.graphemeBoundaries[f]<=h)i=f+1;else _=f-1}return this.graphemeBoundaries[Math.min(i,this.graphemeBoundaries.length-1)]??this.text.length}prevOffset(t){let h=this.snapToGraphemeBoundary(t),i=0,_=this.graphemeBoundaries.length-1;while(i<=_){let f=i+_>>1;if(this.graphemeBoundaries[f]<h)i=f+1;else _=f-1}return this.graphemeBoundaries[Math.max(0,_)]??0}snapToGraphemeBoundary(t){if(t<=0)return 0;if(t>=this.text.length)return this.text.length;let h=0;for(let i of this.graphemeBoundaries){if(i>t)break;h=i}return h}getGraphemeBoundaries(){return[...this.graphemeBoundaries]}getWordBoundaries(){return[...this.wordBoundaries]}stringIndexToDisplayWidth(t,h){let i=Math.max(0,Math.min(h,t.length));return Q8(t.slice(0,i))}displayWidthToStringIndex(t,h){if(h<=0)return 0;let i=0,_=0;for(let{index:f,segment:w}of P9.graphemeSegmenter.segment(t)){let D=i+Q8(w);if(D>h)break;i=D,_=f+w.length}return _}getWrappedText(){if(this.wrappedTextCache)return this.wrappedTextCache;let t=[],h=this.text.split(`
3250
3250
  `);for(let i of h){if(i.length===0){t.push("");continue}let _="",f=0;for(let{segment:w}of P9.graphemeSegmenter.segment(i)){let D=Q8(w);if(_.length>0&&f+D>this.columns)t.push(_),_=w,f=D;else _+=w,f+=D}t.push(_)}return this.wrappedTextCache=t.length>0?t:[""],this.wrappedTextCache}get lineCount(){return this.getWrappedText().length}getPositionFromOffset(t){let h=Math.max(0,Math.min(t,this.text.length)),_=this.text.slice(0,h).split(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hermenics/deepseek-code",
3
- "version": "0.6.22",
3
+ "version": "0.6.23",
4
4
  "description": "An AI-powered coding assistant that lives in your terminal",
5
5
  "keywords": [
6
6
  "ai",