blade-code 0.10.9 → 0.10.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blade.js +2 -2
- package/dist/{chunk-2c9ssx8y.js → chunk-1qz9qfzc.js} +2 -2
- package/dist/{chunk-wr9p5hk3.js → chunk-230xac12.js} +1 -1
- package/dist/{chunk-4gkn11cb.js → chunk-2mzcxq6c.js} +1 -1
- package/dist/{chunk-vtwvwcz9.js → chunk-363pgv1e.js} +2 -2
- package/dist/{chunk-amp9a6rq.js → chunk-3aqdjrtm.js} +1 -1
- package/dist/{chunk-2zwyvfbm.js → chunk-3wms95qc.js} +1 -1
- package/dist/{chunk-st9vr8w3.js → chunk-4dq9y7zn.js} +2 -2
- package/dist/chunk-4hawehmd.js +114 -0
- package/dist/{chunk-686at39n.js → chunk-4vjx9ft1.js} +1 -1
- package/dist/{chunk-4gptj397.js → chunk-4zs5r4n4.js} +1 -1
- package/dist/chunk-5b7xhvd1.js +1 -0
- package/dist/{chunk-y9d70cks.js → chunk-5df4x6ec.js} +54 -20
- package/dist/{chunk-7by8mhzq.js → chunk-5s123nbs.js} +1 -1
- package/dist/{chunk-3e5etzj8.js → chunk-632rgzcf.js} +1 -1
- package/dist/{chunk-jxhpwm5k.js → chunk-732n8xj6.js} +1 -1
- package/dist/{chunk-484ve631.js → chunk-74shfpve.js} +1 -1
- package/dist/{chunk-2wmnzxfz.js → chunk-7wjy6kgt.js} +1 -1
- package/dist/chunk-7ysw82r9.js +1 -0
- package/dist/{chunk-8g4n4578.js → chunk-82tsyr4f.js} +1 -1
- package/dist/{chunk-afbky4f9.js → chunk-93pn0vhs.js} +1 -1
- package/dist/chunk-9cnm1hgp.js +1 -0
- package/dist/chunk-9tnaads5.js +2 -0
- package/dist/{chunk-ncxavkjp.js → chunk-afkhzdfc.js} +1 -1
- package/dist/{chunk-60764481.js → chunk-ah97bmns.js} +1 -1
- package/dist/chunk-ajg3q7e4.js +10 -0
- package/dist/{chunk-gk1wq9rv.js → chunk-amx33f28.js} +1 -1
- package/dist/chunk-b692dgxx.js +1 -0
- package/dist/{chunk-bzvwcyma.js → chunk-brwths02.js} +3 -3
- package/dist/chunk-bzwa0td4.js +6 -0
- package/dist/chunk-cskpqe1m.js +1 -0
- package/dist/{chunk-zns1crmz.js → chunk-dpt56hah.js} +1 -1
- package/dist/{chunk-5ehe3xra.js → chunk-dsj62dcg.js} +1 -1
- package/dist/chunk-efqa79kw.js +1 -0
- package/dist/chunk-f4z3gkbs.js +2 -0
- package/dist/{chunk-cr7ncgsh.js → chunk-fm913p7k.js} +1 -1
- package/dist/chunk-fvrmjhz5.js +1 -0
- package/dist/{chunk-e0vwbx8b.js → chunk-g11hq0e5.js} +1 -1
- package/dist/{chunk-jzn1qtrc.js → chunk-gav4hxcv.js} +2 -2
- package/dist/{chunk-n2hn6tn2.js → chunk-gqrrheb3.js} +1 -1
- package/dist/{chunk-smpky1s8.js → chunk-h6w3ggx9.js} +1 -1
- package/dist/{chunk-6rcwvrd1.js → chunk-h9k52syw.js} +1 -1
- package/dist/{chunk-mzgwy44f.js → chunk-heqs3xan.js} +1 -1
- package/dist/chunk-hxp5qs1x.js +1 -0
- package/dist/chunk-jvfzm6gn.js +2 -0
- package/dist/{chunk-17g172md.js → chunk-k1my44xn.js} +1 -1
- package/dist/chunk-kqgtrnm6.js +4 -0
- package/dist/{chunk-r7mhhrp6.js → chunk-ktf3bpmw.js} +1 -1
- package/dist/{chunk-n4e454dw.js → chunk-kvx3sb3z.js} +1 -1
- package/dist/{chunk-c23vgww8.js → chunk-mtk2tf9n.js} +1 -1
- package/dist/chunk-p4zt7ts9.js +2 -0
- package/dist/{chunk-qtypjqb8.js → chunk-qdf7sb0k.js} +1 -1
- package/dist/{chunk-k0n4prs1.js → chunk-r76wc1cn.js} +1 -1
- package/dist/{chunk-41wym9fn.js → chunk-s5666ta0.js} +2 -2
- package/dist/chunk-s6v7kg40.js +1 -0
- package/dist/chunk-sa572750.js +1 -0
- package/dist/chunk-sxcm8ryt.js +1 -0
- package/dist/{chunk-gv15jmxf.js → chunk-tgtj3bj1.js} +1 -1
- package/dist/{chunk-kg4xd3yf.js → chunk-vmq248m7.js} +1 -1
- package/dist/{chunk-f8nw8dcq.js → chunk-wpjb7918.js} +310 -304
- package/dist/{chunk-9dd2qmky.js → chunk-xe0z59h2.js} +12 -12
- package/dist/chunk-xm9katxj.js +1 -0
- package/dist/{chunk-6c1qjy1v.js → chunk-xx1d9kfd.js} +1 -1
- package/dist/chunk-yg2bd4w2.js +200 -0
- package/dist/{chunk-ns9emet3.js → chunk-z18bbtg9.js} +1 -1
- package/dist/chunk-z5zcwwfm.js +1 -0
- package/dist/{chunk-h7szqxtg.js → chunk-z8c5rhdh.js} +1 -1
- package/dist/{chunk-p839x5dd.js → chunk-ze1hqsbs.js} +2 -2
- package/dist/web/assets/ChatView-DG6MMrFK.js +7 -0
- package/dist/web/assets/{CodeBlockHighlighter-7DiEw-B3.js → CodeBlockHighlighter-Cf3DBUGk.js} +1 -1
- package/dist/web/assets/{FilePreview-5FjwAe93.js → FilePreview-LvuYnyjv.js} +1 -1
- package/dist/web/assets/{MarkdownRenderer-CjsMv0q1.js → MarkdownRenderer-CkSbe36j.js} +3 -3
- package/dist/web/assets/{SettingsModal-EPwoV6vp.js → SettingsModal-DBsb7E9J.js} +1 -1
- package/dist/web/assets/{TaskSwitcher-BOKaxmnf.js → TaskSwitcher-Z0KWY8g9.js} +1 -1
- package/dist/web/assets/{TerminalPanel-CZJYrbjQ.js → TerminalPanel-DVWTlxtd.js} +1 -1
- package/dist/web/assets/index-BC7ygRH_.css +1 -0
- package/dist/web/assets/{index-I_DKONsY.js → index-DWtXGF3o.js} +27 -27
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/chunk-25cqav2f.js +0 -4
- package/dist/chunk-27dr7bz0.js +0 -2
- package/dist/chunk-39xzkky9.js +0 -1
- package/dist/chunk-469ht1ty.js +0 -194
- package/dist/chunk-4gegd63m.js +0 -1
- package/dist/chunk-4v7h259s.js +0 -2
- package/dist/chunk-4xsqe5sn.js +0 -2
- package/dist/chunk-4yh4yeep.js +0 -1
- package/dist/chunk-5410er6c.js +0 -1
- package/dist/chunk-b3qwhhpy.js +0 -114
- package/dist/chunk-cgk8cft8.js +0 -1
- package/dist/chunk-dg6abzwy.js +0 -1
- package/dist/chunk-e2f1kgt4.js +0 -1
- package/dist/chunk-h4azdqke.js +0 -10
- package/dist/chunk-jdy3ceqv.js +0 -6
- package/dist/chunk-m4b00d6v.js +0 -1
- package/dist/chunk-nezwz71s.js +0 -1
- package/dist/chunk-p7s0rwk3.js +0 -1
- package/dist/chunk-racbf4zb.js +0 -1
- package/dist/chunk-tfefpqz1.js +0 -2
- package/dist/chunk-wc7dt3vm.js +0 -1
- package/dist/chunk-xnb07jbj.js +0 -1
- package/dist/web/assets/ChatView-BPzsdviX.js +0 -7
- package/dist/web/assets/index-CU-jckjp.css +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{rb as jt,sb as Xt,tb as bn,ub as Tn,vb as fn}from"./chunk-095x2ykj.js";import{
|
|
1
|
+
import{rb as jt,sb as Xt,tb as bn,ub as Tn,vb as fn}from"./chunk-095x2ykj.js";import{$d as Ut}from"./chunk-brwths02.js";import{Ae as S,De as yn,Ee as Ht,Fe as Bt,Ge as R,He as qt,ge as xt,he as tn,ie as en,je as zt,ke as B,le as rn,me as gt,ne as mt,pe as dn,qe as En,re as U,se as on,te as pn,ue as cn,ve as lt,we as un,xe as Mn,ye as wn}from"./chunk-1qz9qfzc.js";import{Ye as X,_e as x}from"./chunk-kvx3sb3z.js";import{if as vt}from"./chunk-5s123nbs.js";import{vf as nn,wf as sn}from"./chunk-jvfzm6gn.js";import{Mf as ss}from"./chunk-g11hq0e5.js";import{EventEmitter as hs}from"events";import Un from"node:path";function An(t){if(t===void 0)return"undefined";if(typeof t==="string")return t;try{let i=JSON.stringify(t);return i===void 0?String(t):i}catch{return String(t)}}function _n(t){let i=t;switch(t.code){case"type":return`类型错误:${t.message}`;case"required":return"缺少必需参数";case"minLength":return`字符串过短:${t.message}`;case"maxLength":return`字符串过长:${t.message}`;case"minimum":case"exclusiveMinimum":return`数值太小:${t.message}`;case"maximum":case"exclusiveMaximum":return`数值太大:${t.message}`;case"minItems":return`数组元素过少:${t.message}`;case"maxItems":return`数组元素过多:${t.message}`;case"format":return`格式错误:${t.message}`;case"enum":return`必须是枚举允许的值之一:${t.message}`;case"const":return`必须是指定的字面量值:${t.message}`;case"additionalProperties":case"unevaluatedProperties":return`包含未知参数:${t.message}`;case"anyOf":case"oneOf":return"不符合任何有效的类型定义";case"~refine":return t.message||"自定义验证失败";default:return t.message||`验证失败:${An(i)}`}}class Jt extends Error{issues;type;constructor(t,i,n="validation_error"){super(t);this.issues=i;this.type=n;this.name="ToolValidationError"}}function Vt(t,i){let n=X(t,i);if(n.success)return n.data;let s=n.error.issues.map((r)=>({field:r.path.length>0?r.path.join("."):"root",message:_n(r),value:r.value})),e=s.length===1?`参数验证失败 [${s[0].field}]: ${s[0].message}`:`参数验证失败 (${s.length} 个错误):
|
|
2
2
|
${s.map((r)=>` - ${r.field}: ${r.message}`).join(`
|
|
3
3
|
`)}`;throw new Jt(e,s)}function st(t){if(!t||typeof t!=="object")return;let i=t;if(i.type==="object"&&i.properties)i.required??=[],i.additionalProperties??=!1;for(let n of Object.values(i))if(Array.isArray(n))for(let s of n)st(s);else st(n)}function et(t){let i=JSON.parse(JSON.stringify(t,(n,s)=>n.startsWith("~")?void 0:s));return st(i),i}class rt{toolName;params;executeFn;descriptionFn;affectedPathsFn;constructor(t,i,n,s,e){this.toolName=t;this.params=i;this.executeFn=n;this.descriptionFn=s;this.affectedPathsFn=e}getDescription(){if(this.descriptionFn)return this.descriptionFn(this.params);return`执行工具: ${this.toolName}`}getAffectedPaths(){if(this.affectedPathsFn)return this.affectedPathsFn(this.params);return[]}async execute(t,i,n){let s={signal:t,updateOutput:i,...n};return this.executeFn(this.params,s)}}function Gt(t){return{name:t.name,displayName:t.displayName,kind:t.kind,isReadOnly:t.isReadOnly??jt(t.kind),isConcurrencySafe:t.isConcurrencySafe??!1,parallelism:t.parallelism??(t.isConcurrencySafe?"shared":"exclusive"),strict:t.strict??!1,description:t.description,version:t.version||"1.0.0",category:t.category,tags:t.tags||[],getFunctionDeclaration(){let i=et(t.schema),n=t.description.short;if(t.description.long)n+=`
|
|
4
4
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ld as a,md as b,nd as c}from"./chunk-2mzcxq6c.js";import"./chunk-8j01ssaf.js";import"./chunk-s5666ta0.js";import"./chunk-dsj62dcg.js";import"./chunk-363pgv1e.js";import"./chunk-g11hq0e5.js";export{b as resolveModelConfig,c as getModelDisplayName,a as getModelApiKeyEnvironmentVariable};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Jf as $,Kf as F}from"./chunk-363pgv1e.js";import{promises as J}from"node:fs";import Q from"node:path";import{Mutex as U}from"async-mutex";import w from"write-file-atomic";var X=1;function D(k){if(!k||typeof k!=="object"||Array.isArray(k))return!1;let q=k;return typeof q.path==="string"&&Q.isAbsolute(q.path)&&typeof q.boundAt==="string"}async function Z(k){if(!Q.isAbsolute(k))throw Error("Project path must be absolute");let q=await J.realpath(k);if(!(await J.stat(q)).isDirectory())throw Error("Project path must be a directory");return q}class K{filePath;mutex=new U;constructor(k=Q.join(F(),"bound-projects.json")){this.filePath=k}async list(k){let q=await this.read(),z=await Z(k),H=new Map;for(let C of q.projects)H.set(C.path,C);if(!H.has(z))H.set(z,{path:z,boundAt:new Date(0).toISOString()});return(await Promise.all([...H.values()].map(async(C)=>{let L=!1;try{L=(await J.stat(C.path)).isDirectory()}catch{}return{path:C.path,name:Q.basename(C.path)||C.path,...L?{gitBranch:$(C.path)}:{},available:L,isCurrent:C.path===z,boundAt:C.boundAt}}))).sort((C,L)=>{if(C.isCurrent!==L.isCurrent)return C.isCurrent?-1:1;return C.name.localeCompare(L.name)})}async bind(k,q){return this.mutex.runExclusive(async()=>{let z=await Z(k),H=await this.read(),W=H.projects.find((M)=>M.path===z),C=W??{path:z,boundAt:new Date().toISOString()};if(!W)H.projects.push(C),await this.write(H);let L=await Z(q),A=$(z);return{path:z,name:Q.basename(z)||z,...A?{gitBranch:A}:{},available:!0,isCurrent:z===L,boundAt:C.boundAt}})}async unbind(k){return this.mutex.runExclusive(async()=>{if(!Q.isAbsolute(k))throw Error("Project path must be absolute");let q=await J.realpath(k).catch(()=>Q.resolve(k)),z=await this.read(),H=z.projects.filter((W)=>W.path!==q);if(H.length===z.projects.length)return!1;return z.projects=H,await this.write(z),!0})}async read(){try{let k=await J.readFile(this.filePath,"utf8"),q=JSON.parse(k);if(q.version!==X||!Array.isArray(q.projects))return{version:X,projects:[]};return{version:X,projects:q.projects.filter(D)}}catch(k){if(k.code==="ENOENT"||k instanceof SyntaxError)return{version:X,projects:[]};throw k}}async write(k){let q=Q.dirname(this.filePath);await J.mkdir(q,{recursive:!0,mode:448}),await J.chmod(q,448),await w(this.filePath,`${JSON.stringify(k,null,2)}
|
|
2
2
|
`,{mode:384}),await J.chmod(this.filePath,384)}}var _=new K;
|
|
3
3
|
export{_ as l};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as cJ,c as xJ,d as uJ}from"./chunk-
|
|
1
|
+
import{b as cJ,c as xJ,d as uJ}from"./chunk-732n8xj6.js";import{j as t9,k as s9}from"./chunk-r76wc1cn.js";import{r as p8}from"./chunk-tgtj3bj1.js";import{$ as h4,F as O$,H as R4,I as M4,L as $8,M as FJ,N as HJ,Q as WJ,R as LJ,W as L6,X as B6,Y as JY,Z as j4,ba as K6,t as G6,w as s2,x as a2,y as t4,z as QY}from"./chunk-wpjb7918.js";import{fa as M9,ga as C9,ha as I9,ka as $Y}from"./chunk-z18bbtg9.js";import"./chunk-p4zt7ts9.js";import{Va as x4,hb as u2}from"./chunk-yg2bd4w2.js";import{sb as Y8}from"./chunk-095x2ykj.js";import{$b as M0,Fb as E4,Kb as D8,Sb as T4,Tb as x2,Ub as v4,Yb as e$}from"./chunk-93pn0vhs.js";import"./chunk-4hawehmd.js";import{xc as mJ}from"./chunk-632rgzcf.js";import{Bc as I1,yc as Z8,zc as c8}from"./chunk-amx33f28.js";import"./chunk-ktf3bpmw.js";import{Fc as M$,Gc as d0,Hc as t1,Ic as RQ,Jc as k$,Kc as V8,Lc as a6,Mc as uQ,Nc as u9,Oc as i6,Pc as T$,Qc as Q1,Rc as sJ,Sc as r0,Tc as gJ,Uc as b2,Vc as Q8,Yc as D4,dd as m0}from"./chunk-gqrrheb3.js";import"./chunk-vmq248m7.js";import"./chunk-ybvdac8k.js";import"./chunk-ah97bmns.js";import{nd as lQ}from"./chunk-2mzcxq6c.js";import"./chunk-8j01ssaf.js";import"./chunk-230xac12.js";import{Fd as NJ,Ld as eJ,wd as F6,zd as TJ}from"./chunk-5df4x6ec.js";import"./chunk-9tnaads5.js";import"./chunk-heqs3xan.js";import"./chunk-dpt56hah.js";import{$d as U1,Zd as IQ}from"./chunk-brwths02.js";import"./chunk-7wjy6kgt.js";import{be as oJ,ee as o1}from"./chunk-4dq9y7zn.js";import{Ie as nJ,Se as _J,Te as tJ}from"./chunk-1qz9qfzc.js";import"./chunk-3aqdjrtm.js";import"./chunk-kvx3sb3z.js";import{cf as S$,df as j8,ef as TQ}from"./chunk-f4z3gkbs.js";import{if as u0}from"./chunk-5s123nbs.js";import{jf as i9,kf as o9,nf as D1}from"./chunk-s5666ta0.js";import"./chunk-dsj62dcg.js";import{zf as h9}from"./chunk-jvfzm6gn.js";import{Af as sQ}from"./chunk-gav4hxcv.js";import"./chunk-afkhzdfc.js";import"./chunk-363pgv1e.js";import{Mf as CQ}from"./chunk-g11hq0e5.js";import{useMemoizedFn as f2}from"ahooks";import{useEffect as DX,useState as k2}from"react";import{useMemoizedFn as t0}from"ahooks";import{Box as K$}from"ink";import{useEffect as q$,useMemo as CX,useRef as I2}from"react";import{useShallow as ZY}from"zustand/react/shallow";import{useStore as YY}from"zustand";function Q0($){return YY(T$,$)}var XY=[],v$=()=>Q0(($)=>$.session.sessionId),C1=()=>Q0(($)=>$.session.workspaceRoot),eQ=()=>Q0(($)=>$.session.messages),$4=()=>Q0(($)=>$.session.clearCount),Q4=()=>Q0(($)=>$.session.isCompacting),J4=()=>Q0(($)=>$.session.tokenUsage.estimatedCostUsd),r1=()=>Q0(($)=>$.session.actions),Y4=()=>Q0(($)=>{let{inputTokens:Q,maxContextTokens:Y}=$.session.tokenUsage;if(Y<=0)return 100;let J=Math.max(0,100-Q/Y*100);return Math.round(J)}),Z4=()=>Q0(($)=>$.app.initializationStatus),X4=()=>Q0(($)=>$.app.initializationError),P8=()=>Q0(($)=>$.app.activeModal),G4=()=>Q0(($)=>$.app.tasks),K4=()=>Q0(($)=>$.app.modelEditorTarget),q4=()=>Q0(($)=>$.app.sessionSelectorData),U4=()=>Q0(($)=>$.app.awaitingSecondCtrlC),a1=()=>Q0(($)=>$.app.actions),y8=()=>Q0(($)=>$.app.initializationStatus==="ready"),z4=()=>Q0(($)=>$.app.tasks.length>0),f$=()=>Q0(($)=>$.config.config?.permissionMode||"default"),O4=()=>Q0(($)=>$.config.config?.models??XY),R8=()=>Q0(($)=>{let Q=$.config.config;if(!Q)return;let Y=Q.currentModelId;return Q.models.find((Z)=>Z.id===Y)??Q.models[0]}),M8=()=>Q0(($)=>$.config.config?.currentModelId),A0=()=>Q0(($)=>{return d0.getTheme()}),_4=()=>Q0(($)=>$.config.config?.theme??"default"),$1=()=>Q0(($)=>$.focus.currentFocus),N4=()=>Q0(($)=>$.focus.actions),i1=()=>Q0(($)=>$.command.isProcessing),F4=()=>Q0(($)=>$.command.actions),C8=()=>Q0(($)=>$.command.pendingCommands),H4=()=>Q0(($)=>$.command.recoveredSteeringCount),I8=()=>Q0(($)=>$.app.thinkingModeEnabled),T8=()=>Q0(($)=>$.app.reasoningEffort),v8=()=>Q0(($)=>$.app.serviceTier),f8=()=>Q0(($)=>$.app.responseVerbosity),k8=()=>Q0(($)=>$.app.communicationStyle),W4=()=>Q0(($)=>$.session.currentThinkingContent),L4=()=>Q0(($)=>$.session.thinkingExpanded),B4=()=>Q0(($)=>$.session.currentStreamingMessageId),w4=()=>Q0(ZY(($)=>({lines:$.session.currentStreamingLines,tail:$.session.currentStreamingTail,lineCount:$.session.currentStreamingLineCount,version:$.session.currentStreamingVersion}))),b4=()=>Q0(($)=>$.session.finalizingStreamingMessageId),A4=()=>Q0(($)=>$.session.historyExpanded),P4=()=>Q0(($)=>$.session.expandedMessageCount);import{useMemoizedFn as V$}from"ahooks";import{useEffect as p2,useRef as c4}from"react";function GY($){if(!($ instanceof Error))return"未知错误";let J=$.lastError??$;if(J.responseBody)try{let G=JSON.parse(J.responseBody)?.error?.message;if(G){let K=J.statusCode?` (HTTP ${J.statusCode})`:"";return`${G}${K}`}}catch{}let Z=$.message.match(/Last error:\s*(.+)$/);if(Z)return Z[1];return $.message}function KY($){if(!($ instanceof Error))return!1;return $.name==="AbortError"||$.message.includes("aborted")}function qY($){if(!($ instanceof Error))return!1;let Q=$.message;return Q.includes("can only concatenate str")||Q.includes("image_url")||Q.includes("multimodal")||Q.includes("vision")||Q.includes("does not support images")}function S8($){let Q=KY($),Y=qY($),J;if(Y)J="当前模型不支持图片理解功能。请切换到支持视觉能力的模型(如 Claude 4.5、GPT-5.2、Gemini 3 Pro、Qwen3-VL-Plus 等)后重试。";else J=GY($);return{displayMessage:J,isAbort:Q,isVisionNotSupported:Y}}import{appendFileSync as UY,mkdirSync as zY,writeFileSync as OY}from"node:fs";import _Y from"node:os";import j2 from"node:path";var y4=null;function NY(){let $=process.env.BLADE_STORAGE_ROOT||j2.join(_Y.homedir(),".blade");return j2.join($,"logs","stream-debug.log")}function FY($){if(y4===$)return;let Q=j2.dirname($);zY(Q,{recursive:!0,mode:493}),OY($,`=== Stream Debug Log Started: ${new Date().toISOString()} ===
|
|
2
2
|
`),y4=$}function h2($,Q,Y){try{let J=NY();FY(J);let Z=new Date().toISOString(),X=Y?` | ${JSON.stringify(Y)}`:"",G=`[${Z}] [${$}] ${Q}${X}
|
|
3
3
|
`;UY(J,G)}catch{}}var s$=o1("UI");function C4($,Q){let Y=!1;return(J)=>{switch(J.kind){case"content_delta":if(Y||$.signal.aborted)break;Q.contentDeltaCount++,Q.contentDeltaTotalLen+=J.delta.length,h2("loopEventHandler","onContentDelta",{callCount:Q.contentDeltaCount,deltaLen:J.delta.length,totalLen:Q.contentDeltaTotalLen}),$.streamingBuffer.batchAppendContent(J.delta);break;case"thinking_delta":if(Y||$.signal.aborted)break;if($.thinkingModeEnabled)$.streamingBuffer.batchAppendThinking(J.delta);break;case"stream_end":{if(s$.debug("[loopEventHandler] stream_end",{contentDeltaCount:Q.contentDeltaCount,contentDeltaTotalLen:Q.contentDeltaTotalLen,streamFinalized:Y,signalAborted:$.signal.aborted}),h2("loopEventHandler","onStreamEnd",{contentDeltaCallCount:Q.contentDeltaCount,contentDeltaTotalLen:Q.contentDeltaTotalLen,streamFinalized:Y,signalAborted:$.signal.aborted}),Y||$.signal.aborted){Y=!0;break}let{extraContent:Z,extraThinking:X}=$.streamingBuffer.drainPendingBuffers(),G=$.getStreamingMessageId();if(G){if(Z)k$(G,Z);V8(G)}$.sessionActions.finalizeStreamingMessage(Z,X),Y=!0;break}case"model_fallback":Y=!0,$.streamingBuffer.resetStreamingBuffers(),$.sessionActions.discardStreamingMessage(),$.sessionActions.setCurrentThinkingContent(null);break;case"tool_start":{let Z=J.toolCall;if(!("function"in Z))break;if(Z.function.name===D8)break;if(s$.debug("[loopEventHandler] tool_start",{toolName:Z.function.name,toolKind:J.toolKind}),["TaskCreate","TaskUpdate","TaskList"].includes(Z.function.name))break;try{let X=JSON.parse(Z.function.arguments),G=R4(Z.function.name,X);$.sessionActions.addToolMessage(G,{toolCallId:Z.id,toolName:Z.function.name,phase:"start",summary:G,params:X})}catch(X){s$.error("[loopEventHandler] onToolStart error:",X)}break}case"tool_progress":{let Z=J.toolCall;if(!("function"in Z))break;if(Z.function.name===D8)break;let X=J.update.total!==void 0?` ${Math.max(0,Math.min(100,Math.round((J.update.progress??0)/J.update.total*100)))}%`:"",G=`${Z.function.name}${X}: ${J.update.message}`;$.sessionActions.addToolMessage(G,{toolCallId:Z.id,toolName:Z.function.name,phase:"progress",summary:G});break}case"tool_result":{let Z=J.toolCall;if(!("function"in Z))break;if(Z.function.name===D8)break;s$.debug("[loopEventHandler] tool_result",{toolName:Z.function.name,success:J.result.success});let X=M4(Z.function.name,J.result);$.sessionActions.addToolMessage(X.summary,{toolCallId:Z.id,toolName:Z.function.name,phase:"complete",summary:X.summary,detail:X.detail});break}case"structured_output":$.sessionActions.replaceLastAssistantMessage(JSON.stringify(J.output,null,2));break;case"token_usage":$.sessionActions.updateTokenUsage(J.usage);break;case"compaction":if($.sessionActions.setCompacting(J.phase==="start"),J.phase==="end")$.sessionActions.resetContextUsage();break;case"turn_start":s$.debug("[loopEventHandler] turn_start",{turn:J.turn,maxTurns:J.maxTurns}),$.sessionActions.updateTokenUsage({turnCount:J.turn}),Y=!1;break;case"task_update":$.appActions.setTasks(J.tasks);break;case"mcp_catalog_changed":{let Z=`MCP catalog r${J.revision}: +${J.added.length} -${J.removed.length} ~${J.updated.length}`;$.sessionActions.addToolMessage(Z,{toolName:"MCP Catalog",phase:"complete",summary:Z,detail:[J.added.length>0?`Added: ${J.added.join(", ")}`:"",J.removed.length>0?`Removed: ${J.removed.join(", ")}`:"",J.updated.length>0?`Updated: ${J.updated.join(", ")}`:""].filter(Boolean).join(`
|
|
4
4
|
`)});break}case"mcp_content_changed":{let Z=`MCP ${J.contentKind} r${J.revision}: +${J.added.length} -${J.removed.length} ~${J.updated.length}`;$.sessionActions.addToolMessage(Z,{toolName:"MCP Content",phase:"complete",summary:Z,detail:[J.added.length>0?`Added: ${J.added.join(", ")}`:"",J.removed.length>0?`Removed: ${J.removed.join(", ")}`:"",J.updated.length>0?`Updated: ${J.updated.join(", ")}`:""].filter(Boolean).join(`
|
|
@@ -115,7 +115,7 @@ ${h0}`}]}}let x0=g2(_0),i0=await P(x0);if(!i0.accepted){let h0=i0.reason==="queu
|
|
|
115
115
|
|
|
116
116
|
**重要**:请直接返回 JSON,不要添加任何额外的解释或文字。`,K)).trim(),L=R.match(/```(?:json)?\s*\n([\s\S]*?)\n```/);if(L)R=L[1];let f=JSON.parse(R);if(!f.name||!f.description||!f.systemPrompt)throw Error("Missing required fields: name, description, or systemPrompt");if(!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(f.name))throw Error("Invalid name format. Must be kebab-case (lowercase, numbers, hyphens only)");G({name:f.name,description:f.description,tools:Array.isArray(f.tools)?f.tools:[],color:f.color||"blue",location:"project",systemPrompt:f.systemPrompt}),Z("confirm")}catch(P){F(P instanceof Error?P.message:String(P))}finally{H(!1)}});O6(()=>{if(J==="aiGenerating"&&!U&&!z)C()},[J,U,z,C]);let w=o8(async()=>{try{let P=X.location==="project"?o2.join(u0(),".blade","agents"):o2.join(iY.homedir(),".blade","agents");await z6.promises.mkdir(P,{recursive:!0});let A=["---",`name: ${X.name}`,`description: ${X.description}`];if(X.tools.length>0&&!X.tools.includes("all")){A.push("tools:");for(let L of X.tools)A.push(` - ${L}`)}if(X.color)A.push(`color: ${X.color}`);A.push("---");let T=[A.join(`
|
|
117
117
|
`),"",`# ${X.name} Subagent`,"",X.systemPrompt||"你是一个专门的代理,负责执行特定任务。",""].join(`
|
|
118
|
-
`),R=o2.join(P,`${X.name}.md`);await z6.promises.writeFile(R,T,"utf-8"),$()}catch(P){console.error("保存配置失败:",P)}}),v=k0(!1,Q);if(_6((P,A)=>{if(A.escape)k();else if(A.ctrl&&P==="c"||A.meta&&P==="c")v()},{isActive:J!=="tools"}),J==="mode")return j(Y0,{flexDirection:"column",paddingY:1,children:[j(Y0,{marginBottom:1,children:j(n,{bold:!0,color:"cyan",children:"选择创建方式"},void 0,!1,void 0,this)},void 0,!1,void 0,this),j(Y0,{marginBottom:1,children:j(n,{dimColor:!0,children:"你可以手动配置每个细节,或让 AI 根据你的描述自动生成配置"},void 0,!1,void 0,this)},void 0,!1,void 0,this),j(n8,{items:[{label:"AI 智能生成 - 根据描述自动生成完整配置",value:"ai"},{label:"手动配置 - 逐步配置每个选项",value:"manual"}],onSelect:(P)=>{if(P.value==="ai")B("ai"),Z("aiPrompt");else B("manual"),Z("name")}},void 0,!1,void 0,this),j(Y0,{marginTop:1,children:j(n,{dimColor:!0,children:"使用方向键选择 | Enter 确认 | ESC 取消"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(J==="aiPrompt")return j(Y0,{flexDirection:"column",paddingY:1,children:[j(Y0,{marginBottom:1,children:j(n,{bold:!0,color:"cyan",children:"AI 智能生成"},void 0,!1,void 0,this)},void 0,!1,void 0,this),j(Y0,{marginBottom:1,children:j(n,{dimColor:!0,children:'描述你想要创建的 Agent(例如:"一个专门用于代码审查的 agent,能够分析代码质量和潜在bug")'},void 0,!1,void 0,this)},void 0,!1,void 0,this),j(Y0,{marginBottom:1,children:[j(n,{color:"green",children:"描述: "},void 0,!1,void 0,this),j(X8,{value:K,onChange:q,onSubmit:(P)=>{if(!P.trim())return;Z("aiGenerating")}},void 0,!1,void 0,this)]},void 0,!0,void 0,this),j(Y0,{children:j(n,{dimColor:!0,children:"按 Enter 开始生成 | ESC 返回"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(J==="aiGenerating"){if(z)return j(Y0,{flexDirection:"column",paddingY:1,children:[j(Y0,{marginBottom:1,children:j(n,{bold:!0,color:"red",children:"AI 生成失败"},void 0,!1,void 0,this)},void 0,!1,void 0,this),j(Y0,{marginBottom:1,children:j(n,{color:"red",children:z},void 0,!1,void 0,this)},void 0,!1,void 0,this),j(Y0,{marginBottom:1,children:j(n,{dimColor:!0,children:"按 ESC 返回修改描述"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return j(Y0,{flexDirection:"column",paddingY:1,children:[j(Y0,{marginBottom:1,children:j(n,{bold:!0,color:"yellow",children:[j(sY,{type:"dots"},void 0,!1,void 0,this)," AI 正在生成配置..."]},void 0,!0,void 0,this)},void 0,!1,void 0,this),j(Y0,{marginBottom:1,children:j(n,{dimColor:!0,children:['根据你的描述:"',K,'"']},void 0,!0,void 0,this)},void 0,!1,void 0,this),j(Y0,{marginBottom:1,children:j(n,{color:"gray",children:"正在调用 LLM 生成 agent 配置,请稍候..."},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}if(J==="name"){let P=O==="edit";return j(Y0,{flexDirection:"column",paddingY:1,children:[j(Y0,{marginBottom:1,children:j(n,{bold:!0,color:"cyan",children:["Step 1/7: ",P?"Agent 名称(不可修改)":"输入 Agent 名称"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),j(Y0,{marginBottom:1,children:j(n,{dimColor:!0,children:P?"编辑模式下名称不可修改(修改名称相当于创建新 Agent)":"名称只能包含小写字母、数字和连字符(例如:code-reviewer)"},void 0,!1,void 0,this)},void 0,!1,void 0,this),j(Y0,{marginBottom:1,children:[j(n,{color:"green",children:"名称: "},void 0,!1,void 0,this),P?j(n,{children:X.name},void 0,!1,void 0,this):j(X8,{value:X.name,onChange:(A)=>G({...X,name:A}),onSubmit:(A)=>{if(Q3(A))return;N()}},void 0,!1,void 0,this)]},void 0,!0,void 0,this),j(Y0,{children:j(n,{dimColor:!0,children:P?"按 Enter 继续 | ESC 返回":"按 Enter 继续 | ESC 返回"},void 0,!1,void 0,this)},void 0,!1,void 0,this),P&&j(X8,{value:"",onChange:()=>{},onSubmit:N,showCursor:!1},"edit-mode-dummy-input",!1,void 0,this)]},void 0,!0,void 0,this)}if(J==="description")return j(Y0,{flexDirection:"column",paddingY:1,children:[j(Y0,{marginBottom:1,children:j(n,{bold:!0,color:"cyan",children:"Step 2/7: 输入描述信息"},void 0,!1,void 0,this)},void 0,!1,void 0,this),j(Y0,{marginBottom:1,children:j(n,{dimColor:!0,children:"简短描述这个 Agent 的用途和使用场景(这将帮助主 Agent 决定何时使用它)"},void 0,!1,void 0,this)},void 0,!1,void 0,this),j(Y0,{marginBottom:1,children:[j(n,{color:"green",children:"描述: "},void 0,!1,void 0,this),j(X8,{value:X.description,onChange:(P)=>G({...X,description:P}),onSubmit:(P)=>{if(!P.trim())return;N()}},void 0,!1,void 0,this)]},void 0,!0,void 0,this),j(Y0,{children:j(n,{dimColor:!0,children:"按 Enter 继续 | ESC 返回"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(J==="tools")return j(J3,{config:X,setConfig:G,onNext:N,onPrev:k},void 0,!1,void 0,this);if(J==="color")return j(Y0,{flexDirection:"column",paddingY:1,children:[j(Y0,{marginBottom:1,children:j(n,{bold:!0,color:"cyan",children:"Step 4/7: 选择背景颜色"},void 0,!1,void 0,this)},void 0,!1,void 0,this),j(Y0,{marginBottom:1,children:j(n,{dimColor:!0,children:"为 Agent 选择一个颜色标识(用于在 UI 中区分不同的 Agents)"},void 0,!1,void 0,this)},void 0,!1,void 0,this),j(n8,{items:$3,onSelect:(P)=>{let A=P.value==="none"?void 0:P.value;G({...X,color:A}),N()}},void 0,!1,void 0,this),j(Y0,{marginTop:1,children:j(n,{dimColor:!0,children:"使用方向键选择 | Enter 确认 | ESC 返回"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(J==="location")return j(Y0,{flexDirection:"column",paddingY:1,children:[j(Y0,{marginBottom:1,children:j(n,{bold:!0,color:"cyan",children:"Step 5/7: 选择保存位置"},void 0,!1,void 0,this)},void 0,!1,void 0,this),j(Y0,{marginBottom:1,children:j(n,{dimColor:!0,children:"项目级配置仅在当前项目生效,用户级配置全局可用"},void 0,!1,void 0,this)},void 0,!1,void 0,this),j(n8,{items:[{label:"项目级 (.blade/agents/) - 仅当前项目",value:"project"},{label:"用户级 (~/.blade/agents/) - 全局可用",value:"user"}],onSelect:(P)=>{G({...X,location:P.value}),N()}},void 0,!1,void 0,this),j(Y0,{marginTop:1,children:j(n,{dimColor:!0,children:"使用方向键选择 | Enter 确认 | ESC 返回"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(J==="systemPrompt")return j(Y0,{flexDirection:"column",paddingY:1,children:[j(Y0,{marginBottom:1,children:j(n,{bold:!0,color:"cyan",children:"Step 6/7: 输入系统提示词"},void 0,!1,void 0,this)},void 0,!1,void 0,this),j(Y0,{marginBottom:1,children:j(n,{dimColor:!0,children:"定义 Agent 的行为和职责(可选,留空将使用默认提示)"},void 0,!1,void 0,this)},void 0,!1,void 0,this),j(Y0,{marginBottom:1,children:[j(n,{color:"green",children:"提示词: "},void 0,!1,void 0,this),j(X8,{value:X.systemPrompt,onChange:(P)=>G({...X,systemPrompt:P}),onSubmit:()=>N()},void 0,!1,void 0,this)]},void 0,!0,void 0,this),j(Y0,{children:j(n,{dimColor:!0,children:"按 Enter 继续 | ESC 返回"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(J==="confirm")return j(Y0,{flexDirection:"column",paddingY:1,children:[j(Y0,{marginBottom:1,children:j(n,{bold:!0,color:"cyan",children:"Step 7/7: 确认配置"},void 0,!1,void 0,this)},void 0,!1,void 0,this),j(Y0,{flexDirection:"column",paddingLeft:2,marginBottom:1,children:[j(n,{children:[j(n,{bold:!0,color:"green",children:["名称:"," "]},void 0,!0,void 0,this),j(n,{children:X.name},void 0,!1,void 0,this)]},void 0,!0,void 0,this),j(n,{children:[j(n,{bold:!0,color:"green",children:["描述:"," "]},void 0,!0,void 0,this),j(n,{children:X.description},void 0,!1,void 0,this)]},void 0,!0,void 0,this),j(n,{children:[j(n,{bold:!0,color:"green",children:["工具:"," "]},void 0,!0,void 0,this),j(n,{children:X.tools.includes("all")?"所有工具":X.tools.join(", ")||"所有工具"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),j(n,{children:[j(n,{bold:!0,color:"green",children:["颜色:"," "]},void 0,!0,void 0,this),j(n,{children:X.color||"默认"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),j(n,{children:[j(n,{bold:!0,color:"green",children:["位置:"," "]},void 0,!0,void 0,this),j(n,{children:X.location==="project"?"项目级":"用户级"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),j(n,{children:[j(n,{bold:!0,color:"green",children:["提示词:"," "]},void 0,!0,void 0,this),j(n,{children:X.systemPrompt||"(使用默认)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),j(n8,{items:[{label:"确认并保存",value:"save"},{label:"返回上一步",value:"back"},{label:"取消",value:"cancel"}],onSelect:(P)=>{if(P.value==="save")w();else if(P.value==="back")k();else Q()}},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return null}function J3({config:$,setConfig:Q,onNext:Y,onPrev:J}){let{isFocused:Z}=nY({id:"step-tools"});_6((G,K)=>{if(K.escape)J()},{isActive:Z});let X=(G)=>{if(G.includes("all"))Q({...$,tools:["all"]});else Q({...$,tools:G});Y()};return j(Y0,{flexDirection:"column",paddingY:1,children:[j(Y0,{marginBottom:1,children:j(n,{bold:!0,color:"cyan",children:"Step 3/7: 选择可用工具"},void 0,!1,void 0,this)},void 0,!1,void 0,this),j(Y0,{marginBottom:1,children:j(n,{dimColor:!0,children:"方向键导航,空格切换勾选,Enter 确认进入下一步 | ESC 返回上一步"},void 0,!1,void 0,this)},void 0,!1,void 0,this),j(oY,{options:eY,defaultValue:$.tools,onSubmit:X},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import Y3 from"node:fs";import{useMemoizedFn as N$}from"ahooks";import{Box as C0,Text as S0,useInput as Z3}from"ink";import n2 from"ink-select-input";import{useEffect as X3,useMemo as N6,useState as t8}from"react";import{jsxDEV as i}from"react/jsx-dev-runtime";var t2=10;function H6({workspaceRoot:$,initialMode:Q="menu",onComplete:Y,onCancel:J}){let Z=F6($),[X,G]=t8(Q),[K,q]=t8(null),[U,H]=t8(0),[z,F]=t8(0),O=N$(()=>{Z.clear(),Z.loadFromStandardLocations(),H((R)=>R+1)}),B=N6(()=>{return Z.getAllSubagents()},[U]),_=Math.ceil(B.length/t2)||1,W=N6(()=>{let R=z*t2;return B.slice(R,R+t2)},[B,z]);X3(()=>{let R=Math.max(0,_-1);if(z>R)F(R)},[_,z]);let M=N$(()=>{if(z<_-1)F((R)=>R+1)}),N=N$(()=>{if(z>0)F((R)=>R-1)}),k=[{key:"list",label:"查看所有 Agents",value:"list"},{key:"create",label:"创建新 Agent",value:"create"},{key:"edit",label:"编辑 Agent",value:"edit"},{key:"delete",label:"删除 Agent",value:"delete"},{key:"cancel",label:"取消",value:"cancel"}],C=N$((R)=>{if(R.value==="cancel"){J?.();return}G(R.value)}),w=N$((R)=>{if(q(R.value),X==="edit")G("editWizard");else if(X==="delete")G("deleteConfirm")}),v=N$(async()=>{if(!K?.configPath)return;try{await Y3.promises.unlink(K.configPath),O(),P()}catch(R){console.error("删除失败:",R)}}),P=N$(()=>{G("menu"),q(null)}),A=k0(!1,J);if(Z3((R,L)=>{if(L.escape){if(X==="menu")J?.();else if(X==="list"||X==="edit"||X==="delete")F(0),P();else if(X==="deleteConfirm")P()}else if(L.ctrl&&R==="c"||L.meta&&R==="c")A();else if(X==="list"){if(L.leftArrow||R==="h")N();else if(L.rightArrow||R==="l")M()}},{isActive:X!=="create"&&X!=="editWizard"}),X==="menu")return i(C0,{flexDirection:"column",paddingY:1,children:[i(C0,{marginBottom:1,children:i(S0,{bold:!0,color:"cyan",children:"Agents 管理"},void 0,!1,void 0,this)},void 0,!1,void 0,this),i(n2,{items:k,onSelect:C},void 0,!1,void 0,this),i(C0,{marginTop:1,children:i(S0,{dimColor:!0,children:"使用方向键选择 | Enter 确认 | ESC 退出"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(X==="list"){if(B.length===0)return i(C0,{flexDirection:"column",paddingY:1,children:[i(C0,{marginBottom:1,children:i(S0,{bold:!0,color:"cyan",children:"所有 Agents"},void 0,!1,void 0,this)},void 0,!1,void 0,this),i(C0,{paddingLeft:2,children:i(S0,{color:"gray",children:"没有找到任何 agent 配置"},void 0,!1,void 0,this)},void 0,!1,void 0,this),i(C0,{marginTop:1,paddingLeft:2,children:i(S0,{color:"gray",children:"配置文件位置: .blade/agents/ 或 ~/.blade/agents/"},void 0,!1,void 0,this)},void 0,!1,void 0,this),i(C0,{marginTop:1,paddingLeft:2,children:i(S0,{dimColor:!0,children:"按 ESC 返回菜单"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return i(C0,{flexDirection:"column",paddingY:1,children:[i(C0,{marginBottom:1,children:[i(S0,{bold:!0,color:"cyan",children:"所有 Agents"},void 0,!1,void 0,this),i(S0,{color:"gray",children:[" (共 ",B.length," 个)"]},void 0,!0,void 0,this),_>1&&i(S0,{color:"yellow",children:[" ","第 ",z+1,"/",_," 页"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),W.map((R)=>i(C0,{flexDirection:"column",paddingLeft:2,children:[i(C0,{children:i(S0,{children:[i(S0,{bold:!0,color:R.color||"white",children:["• ",R.name]},void 0,!0,void 0,this),i(S0,{color:"gray",children:[" - ",R.description]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),R.tools&&R.tools.length>0&&i(C0,{paddingLeft:2,children:i(S0,{color:"gray",children:["工具: ",R.tools.join(", ")]},void 0,!0,void 0,this)},void 0,!1,void 0,this),R.configPath&&i(C0,{paddingLeft:2,children:i(S0,{color:"gray",dimColor:!0,children:R.configPath},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},R.name,!0,void 0,this)),i(C0,{marginTop:1,paddingLeft:2,children:_>1?i(S0,{dimColor:!0,children:"Left/Right to page | ESC 返回菜单"},void 0,!1,void 0,this):i(S0,{dimColor:!0,children:"按 ESC 返回菜单"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}let T=(R)=>{if(B.length===0)return i(C0,{flexDirection:"column",paddingY:1,children:[i(C0,{marginBottom:1,children:i(S0,{bold:!0,color:"cyan",children:R},void 0,!1,void 0,this)},void 0,!1,void 0,this),i(C0,{paddingLeft:2,children:i(S0,{color:"gray",children:"没有找到任何 agent 配置"},void 0,!1,void 0,this)},void 0,!1,void 0,this),i(C0,{marginTop:1,paddingLeft:2,children:i(S0,{dimColor:!0,children:"按 ESC 返回菜单"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let L=B.map((f)=>({key:f.name,label:`${f.name} - ${f.description}`,value:f}));return i(C0,{flexDirection:"column",paddingY:1,children:[i(C0,{marginBottom:1,children:i(S0,{bold:!0,color:"cyan",children:R},void 0,!1,void 0,this)},void 0,!1,void 0,this),i(n2,{items:L,onSelect:w},void 0,!1,void 0,this),i(C0,{marginTop:1,children:i(S0,{dimColor:!0,children:"使用方向键选择 | Enter 确认 | ESC 返回"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)};if(X==="create")return i(G8,{onComplete:()=>{O(),P()},onCancel:P},void 0,!1,void 0,this);if(X==="edit")return T("编辑 Agent");if(X==="editWizard"&&K){let R={name:K.name,description:K.description,tools:K.tools||[],color:K.color,location:K.configPath?.includes(".blade/agents")?"project":"user",systemPrompt:K.systemPrompt||""};return i(G8,{initialConfig:R,onComplete:()=>{O(),P()},onCancel:P},void 0,!1,void 0,this)}if(X==="delete")return T("删除 Agent");if(X==="deleteConfirm"&&K)return i(C0,{flexDirection:"column",paddingY:1,children:[i(C0,{marginBottom:1,children:i(S0,{bold:!0,color:"red",children:"确认删除"},void 0,!1,void 0,this)},void 0,!1,void 0,this),i(C0,{marginBottom:1,paddingLeft:2,children:i(S0,{children:["你确定要删除 Agent"," ",i(S0,{bold:!0,color:"yellow",children:K.name},void 0,!1,void 0,this)," ","吗?"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),i(C0,{marginBottom:1,paddingLeft:2,children:i(S0,{dimColor:!0,children:["文件路径: ",K.configPath]},void 0,!0,void 0,this)},void 0,!1,void 0,this),i(C0,{marginBottom:1,paddingLeft:2,children:i(S0,{color:"red",children:"此操作无法撤销!"},void 0,!1,void 0,this)},void 0,!1,void 0,this),i(n2,{items:[{label:"确认删除",value:"confirm"},{label:"取消",value:"cancel"}],onSelect:(R)=>{if(R.value==="confirm")v();else P()}},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return null}import{Box as g$,Text as O0}from"ink";import K3,{useEffect as q3,useState as U3}from"react";import{useEffect as G3,useState as W6}from"react";function w6($=u0(),Q=5000){let[Y,J]=W6(null),[Z,X]=W6(!0);return G3(()=>{let G=!0,K=async()=>{try{let U=await L6($);if(!G)return;if(!U){J(null),X(!1);return}let H=await B6($);if(!G)return;J(H)}catch{if(G)J(null)}finally{if(G)X(!1)}};K();let q=null;if(Q>0)q=setInterval(K,Q);return()=>{if(G=!1,q)clearInterval(q)}},[$,Q]),{branch:Y,loading:Z}}import{jsxDEV as o,Fragment as b1}from"react/jsx-dev-runtime";var b6=K3.memo(()=>{let $=y8(),Q=f$(),J=P8()==="shortcuts",Z=U4(),X=C1(),{branch:G}=w6(X),K=R8(),q=Y4(),U=Q4(),H=I8(),z=T8(),F=v8(),O=f8(),B=k8(),_=J4(),W=C8(),M=H4(),N=v$(),[k,C]=U3(null);q3(()=>{let R=!1;new s2(X,N).get().then((E)=>{if(!R)C(E)}).catch(()=>{if(!R)C(null)});let f=s2.subscribe((E)=>{if(!R&&E.sessionId===N&&E.workspaceRoot===X)C(E.goal)});return()=>{R=!0,f()}},[N,X]);let w=K?a8(K):!1,P=(()=>{if(Q==="default")return null;if(Q==="autoEdit")return o(O0,{color:"magenta",children:[">> ","auto edit on ",o(O0,{color:"gray",children:"(shift+tab to cycle)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(Q==="plan")return o(O0,{color:"cyan",children:["‖ plan mode on ",o(O0,{color:"gray",children:"(shift+tab to cycle)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(Q==="yolo")return o(O0,{color:"red",children:["yolo mode on ",o(O0,{color:"gray",children:"(all tools auto-approved)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return null})(),A=P!==null,T=[["Enter:发送","Shift+Enter:换行","Esc:中止"],["Shift+Tab:切换模式","Up/Down:历史","Tab:补全"],["Ctrl+A:行首","Ctrl+E:行尾","Ctrl+K:删到尾"],["Ctrl+U:删到首","Ctrl+W:删单词","Ctrl+C:退出"]];return o(g$,{flexDirection:"row",justifyContent:"space-between",paddingX:2,paddingY:0,children:[J?o(g$,{flexDirection:"column",gap:0,children:T.map((R,L)=>o(g$,{flexDirection:"row",children:[R.map((f,E)=>{let[t,u]=f.split(":");return o(g$,{flexDirection:"row",width:20,children:[o(O0,{color:"yellow",children:t},void 0,!1,void 0,this),o(O0,{color:"gray",children:":"},void 0,!1,void 0,this),o(O0,{color:"white",children:u},void 0,!1,void 0,this)]},E,!0,void 0,this)}),L===T.length-1&&o(O0,{color:"cyan",children:" ? 关闭"},void 0,!1,void 0,this)]},L,!0,void 0,this))},void 0,!1,void 0,this):o(g$,{flexDirection:"row",gap:1,children:[G&&o(b1,{children:[o(O0,{color:"gray",children:[" ",G]},void 0,!0,void 0,this),o(O0,{color:"gray",children:"·"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),P,A&&o(O0,{color:"gray",children:"·"},void 0,!1,void 0,this),k&&o(b1,{children:[o(O0,{color:k.status==="active"?"green":k.status==="blocked"||k.status==="budget_limited"?"yellow":"gray",children:["goal:",k.status," ",k.objective.slice(0,32)]},void 0,!0,void 0,this),o(O0,{color:"gray",children:"·"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),o(O0,{color:"gray",children:"? for shortcuts"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),o(g$,{flexDirection:"row",gap:1,children:!$?o(O0,{color:"red",children:"[WARN] API 密钥未配置"},void 0,!1,void 0,this):o(b1,{children:[w&&o(b1,{children:[H?o(O0,{color:"cyan",children:["Effort ",z]},void 0,!0,void 0,this):o(O0,{color:"gray",children:"Tab:Effort"},void 0,!1,void 0,this),o(O0,{color:"gray",children:"·"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),F!=="auto"&&o(b1,{children:[o(O0,{color:F==="fast"?"yellow":"gray",children:["Speed ",F]},void 0,!0,void 0,this),o(O0,{color:"gray",children:"·"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),O!=="auto"&&o(b1,{children:[o(O0,{color:"gray",children:["Output ",O]},void 0,!0,void 0,this),o(O0,{color:"gray",children:"·"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),B!=="auto"&&o(b1,{children:[o(O0,{color:"gray",children:["Style ",B]},void 0,!0,void 0,this),o(O0,{color:"gray",children:"·"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),K&&o(O0,{color:"gray",children:K.model},void 0,!1,void 0,this),o(O0,{color:"gray",children:"·"},void 0,!1,void 0,this),U?o(O0,{color:"yellow",children:"压缩中..."},void 0,!1,void 0,this):o(O0,{color:q<20?"red":q<50?"yellow":"gray",children:[q,"%"]},void 0,!0,void 0,this),_>0.001&&o(b1,{children:[o(O0,{color:"gray",children:"·"},void 0,!1,void 0,this),o(O0,{color:"green",children:["$",_<0.01?_.toFixed(4):_.toFixed(3)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),W.length>0&&o(b1,{children:[o(O0,{color:"gray",children:"·"},void 0,!1,void 0,this),o(O0,{color:"yellow",children:["已排队 ",W.length]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),M>0&&o(b1,{children:[o(O0,{color:"gray",children:"·"},void 0,!1,void 0,this),o(O0,{color:"cyan",children:["已恢复 ",M," 条指令"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Z&&o(b1,{children:[o(O0,{color:"gray",children:"·"},void 0,!1,void 0,this),o(O0,{color:"yellow",children:"再按一次 Ctrl+C 退出"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)});import{Box as e2,Text as $Q}from"ink";import z3 from"react";import{jsxDEV as m$}from"react/jsx-dev-runtime";var A6=z3.memo(({suggestions:$,selectedIndex:Q,visible:Y,maxDisplay:J=8})=>{if(!Y||$.length===0)return null;let Z=0,X=Math.min(J,$.length),G=Q>=$.length;if(Q>=J&&!G)Z=Q-J+1,X=Q+1;let K=$.slice(Z,X),q=$.length>J;return m$(e2,{flexDirection:"column",paddingX:2,paddingY:0,children:[K.map((U,H)=>{let F=Z+H===Q;return m$(e2,{flexDirection:"row",paddingX:1,gap:2,children:[m$($Q,{color:F?"cyan":"white",bold:F,children:U.command},void 0,!1,void 0,this),m$($Q,{color:F?"cyan":"gray",dimColor:!F,children:["- ",U.description]},void 0,!0,void 0,this)]},U.command,!0,void 0,this)}),q&&m$(e2,{paddingX:1,children:m$($Q,{color:G?"cyan":"gray",bold:G,dimColor:!G,children:["... and ",$.length-J," more"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)});import{Box as W1,Text as T1,useInput as JZ,useStdout as YZ}from"ink";import ZZ from"ink-select-input";import MQ,{useMemo as o6}from"react";import{Box as z0,Text as b0}from"ink";import W$,{useEffect as yQ,useMemo as H$,useRef as r6}from"react";import{Box as _Q,Text as D6}from"ink";import R3 from"react";import{Text as A1}from"ink";import A3 from"react";import f6 from"string-width";import K8 from"string-width";function QQ({onlyFirst:$=!1}={}){return new RegExp("(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]",$?void 0:"g")}var O3=QQ();function JQ($){if(typeof $!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof $}\``);if(!$.includes("\x1B")&&!$.includes(""))return $;return $.replace(O3,"")}var P6=($=0)=>(Q)=>`\x1B[${Q+$}m`,y6=($=0)=>(Q)=>`\x1B[${38+$};5;${Q}m`,R6=($=0)=>(Q,Y,J)=>`\x1B[${38+$};2;${Q};${Y};${J}m`,j0={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},VK=Object.keys(j0.modifier),_3=Object.keys(j0.color),N3=Object.keys(j0.bgColor),jK=[..._3,...N3];function F3(){let $=new Map;for(let[Q,Y]of Object.entries(j0)){for(let[J,Z]of Object.entries(Y))j0[J]={open:`\x1B[${Z[0]}m`,close:`\x1B[${Z[1]}m`},Y[J]=j0[J],$.set(Z[0],Z[1]);Object.defineProperty(j0,Q,{value:Y,enumerable:!1})}return Object.defineProperty(j0,"codes",{value:$,enumerable:!1}),j0.color.close="\x1B[39m",j0.bgColor.close="\x1B[49m",j0.color.ansi=P6(),j0.color.ansi256=y6(),j0.color.ansi16m=R6(),j0.bgColor.ansi=P6(10),j0.bgColor.ansi256=y6(10),j0.bgColor.ansi16m=R6(10),Object.defineProperties(j0,{rgbToAnsi256:{value(Q,Y,J){if(Q===Y&&Y===J){if(Q<8)return 16;if(Q>248)return 231;return Math.round((Q-8)/247*24)+232}return 16+36*Math.round(Q/255*5)+6*Math.round(Y/255*5)+Math.round(J/255*5)},enumerable:!1},hexToRgb:{value(Q){let Y=/[a-f\d]{6}|[a-f\d]{3}/i.exec(Q.toString(16));if(!Y)return[0,0,0];let[J]=Y;if(J.length===3)J=[...J].map((X)=>X+X).join("");let Z=Number.parseInt(J,16);return[Z>>16&255,Z>>8&255,Z&255]},enumerable:!1},hexToAnsi256:{value:(Q)=>j0.rgbToAnsi256(...j0.hexToRgb(Q)),enumerable:!1},ansi256ToAnsi:{value(Q){if(Q<8)return 30+Q;if(Q<16)return 90+(Q-8);let Y,J,Z;if(Q>=232)Y=((Q-232)*10+8)/255,J=Y,Z=Y;else{Q-=16;let K=Q%36;Y=Math.floor(Q/36)/5,J=Math.floor(K/6)/5,Z=K%6/5}let X=Math.max(Y,J,Z)*2;if(X===0)return 30;let G=30+(Math.round(Z)<<2|Math.round(J)<<1|Math.round(Y));if(X===2)G+=60;return G},enumerable:!1},rgbToAnsi:{value:(Q,Y,J)=>j0.ansi256ToAnsi(j0.rgbToAnsi256(Q,Y,J)),enumerable:!1},hexToAnsi:{value:(Q)=>j0.ansi256ToAnsi(j0.hexToAnsi256(Q)),enumerable:!1}}),j0}var H3=F3(),M6=H3;var e8=new Set(["\x1B",""]),W3=39,ZQ="\x07",T6="[",L3="]",v6="m",s8=`${L3}8;;`,C6=($)=>`${e8.values().next().value}${T6}${$}${v6}`,I6=($)=>`${e8.values().next().value}${s8}${$}${ZQ}`,B3=($)=>$.split(" ").map((Q)=>K8(Q)),YQ=($,Q,Y)=>{let J=[...Q],Z=!1,X=!1,G=K8(JQ($.at(-1)));for(let[K,q]of J.entries()){let U=K8(q);if(G+U<=Y)$[$.length-1]+=q;else $.push(q),G=0;if(e8.has(q))Z=!0,X=J.slice(K+1,K+1+s8.length).join("")===s8;if(Z){if(X){if(q===ZQ)Z=!1,X=!1}else if(q===v6)Z=!1;continue}if(G+=U,G===Y&&K<J.length-1)$.push(""),G=0}if(!G&&$.at(-1).length>0&&$.length>1)$[$.length-2]+=$.pop()},w3=($)=>{let Q=$.split(" "),Y=Q.length;while(Y>0){if(K8(Q[Y-1])>0)break;Y--}if(Y===Q.length)return $;return Q.slice(0,Y).join(" ")+Q.slice(Y).join("")},b3=($,Q,Y={})=>{if(Y.trim!==!1&&$.trim()==="")return"";let J="",Z,X,G=B3($),K=[""];for(let[z,F]of $.split(" ").entries()){if(Y.trim!==!1)K[K.length-1]=K.at(-1).trimStart();let O=K8(K.at(-1));if(z!==0){if(O>=Q&&(Y.wordWrap===!1||Y.trim===!1))K.push(""),O=0;if(O>0||Y.trim===!1)K[K.length-1]+=" ",O++}if(Y.hard&&G[z]>Q){let B=Q-O,_=1+Math.floor((G[z]-B-1)/Q);if(Math.floor((G[z]-1)/Q)<_)K.push("");YQ(K,F,Q);continue}if(O+G[z]>Q&&O>0&&G[z]>0){if(Y.wordWrap===!1&&O<Q){YQ(K,F,Q);continue}K.push("")}if(O+G[z]>Q&&Y.wordWrap===!1){YQ(K,F,Q);continue}K[K.length-1]+=F}if(Y.trim!==!1)K=K.map((z)=>w3(z));let q=K.join(`
|
|
118
|
+
`),R=o2.join(P,`${X.name}.md`);await z6.promises.writeFile(R,T,"utf-8"),$()}catch(P){console.error("保存配置失败:",P)}}),v=k0(!1,Q);if(_6((P,A)=>{if(A.escape)k();else if(A.ctrl&&P==="c"||A.meta&&P==="c")v()},{isActive:J!=="tools"}),J==="mode")return j(Y0,{flexDirection:"column",paddingY:1,children:[j(Y0,{marginBottom:1,children:j(n,{bold:!0,color:"cyan",children:"选择创建方式"},void 0,!1,void 0,this)},void 0,!1,void 0,this),j(Y0,{marginBottom:1,children:j(n,{dimColor:!0,children:"你可以手动配置每个细节,或让 AI 根据你的描述自动生成配置"},void 0,!1,void 0,this)},void 0,!1,void 0,this),j(n8,{items:[{label:"AI 智能生成 - 根据描述自动生成完整配置",value:"ai"},{label:"手动配置 - 逐步配置每个选项",value:"manual"}],onSelect:(P)=>{if(P.value==="ai")B("ai"),Z("aiPrompt");else B("manual"),Z("name")}},void 0,!1,void 0,this),j(Y0,{marginTop:1,children:j(n,{dimColor:!0,children:"使用方向键选择 | Enter 确认 | ESC 取消"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(J==="aiPrompt")return j(Y0,{flexDirection:"column",paddingY:1,children:[j(Y0,{marginBottom:1,children:j(n,{bold:!0,color:"cyan",children:"AI 智能生成"},void 0,!1,void 0,this)},void 0,!1,void 0,this),j(Y0,{marginBottom:1,children:j(n,{dimColor:!0,children:'描述你想要创建的 Agent(例如:"一个专门用于代码审查的 agent,能够分析代码质量和潜在bug")'},void 0,!1,void 0,this)},void 0,!1,void 0,this),j(Y0,{marginBottom:1,children:[j(n,{color:"green",children:"描述: "},void 0,!1,void 0,this),j(X8,{value:K,onChange:q,onSubmit:(P)=>{if(!P.trim())return;Z("aiGenerating")}},void 0,!1,void 0,this)]},void 0,!0,void 0,this),j(Y0,{children:j(n,{dimColor:!0,children:"按 Enter 开始生成 | ESC 返回"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(J==="aiGenerating"){if(z)return j(Y0,{flexDirection:"column",paddingY:1,children:[j(Y0,{marginBottom:1,children:j(n,{bold:!0,color:"red",children:"AI 生成失败"},void 0,!1,void 0,this)},void 0,!1,void 0,this),j(Y0,{marginBottom:1,children:j(n,{color:"red",children:z},void 0,!1,void 0,this)},void 0,!1,void 0,this),j(Y0,{marginBottom:1,children:j(n,{dimColor:!0,children:"按 ESC 返回修改描述"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return j(Y0,{flexDirection:"column",paddingY:1,children:[j(Y0,{marginBottom:1,children:j(n,{bold:!0,color:"yellow",children:[j(sY,{type:"dots"},void 0,!1,void 0,this)," AI 正在生成配置..."]},void 0,!0,void 0,this)},void 0,!1,void 0,this),j(Y0,{marginBottom:1,children:j(n,{dimColor:!0,children:['根据你的描述:"',K,'"']},void 0,!0,void 0,this)},void 0,!1,void 0,this),j(Y0,{marginBottom:1,children:j(n,{color:"gray",children:"正在调用 LLM 生成 agent 配置,请稍候..."},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}if(J==="name"){let P=O==="edit";return j(Y0,{flexDirection:"column",paddingY:1,children:[j(Y0,{marginBottom:1,children:j(n,{bold:!0,color:"cyan",children:["Step 1/7: ",P?"Agent 名称(不可修改)":"输入 Agent 名称"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),j(Y0,{marginBottom:1,children:j(n,{dimColor:!0,children:P?"编辑模式下名称不可修改(修改名称相当于创建新 Agent)":"名称只能包含小写字母、数字和连字符(例如:code-reviewer)"},void 0,!1,void 0,this)},void 0,!1,void 0,this),j(Y0,{marginBottom:1,children:[j(n,{color:"green",children:"名称: "},void 0,!1,void 0,this),P?j(n,{children:X.name},void 0,!1,void 0,this):j(X8,{value:X.name,onChange:(A)=>G({...X,name:A}),onSubmit:(A)=>{if(Q3(A))return;N()}},void 0,!1,void 0,this)]},void 0,!0,void 0,this),j(Y0,{children:j(n,{dimColor:!0,children:P?"按 Enter 继续 | ESC 返回":"按 Enter 继续 | ESC 返回"},void 0,!1,void 0,this)},void 0,!1,void 0,this),P&&j(X8,{value:"",onChange:()=>{},onSubmit:N,showCursor:!1},"edit-mode-dummy-input",!1,void 0,this)]},void 0,!0,void 0,this)}if(J==="description")return j(Y0,{flexDirection:"column",paddingY:1,children:[j(Y0,{marginBottom:1,children:j(n,{bold:!0,color:"cyan",children:"Step 2/7: 输入描述信息"},void 0,!1,void 0,this)},void 0,!1,void 0,this),j(Y0,{marginBottom:1,children:j(n,{dimColor:!0,children:"简短描述这个 Agent 的用途和使用场景(这将帮助主 Agent 决定何时使用它)"},void 0,!1,void 0,this)},void 0,!1,void 0,this),j(Y0,{marginBottom:1,children:[j(n,{color:"green",children:"描述: "},void 0,!1,void 0,this),j(X8,{value:X.description,onChange:(P)=>G({...X,description:P}),onSubmit:(P)=>{if(!P.trim())return;N()}},void 0,!1,void 0,this)]},void 0,!0,void 0,this),j(Y0,{children:j(n,{dimColor:!0,children:"按 Enter 继续 | ESC 返回"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(J==="tools")return j(J3,{config:X,setConfig:G,onNext:N,onPrev:k},void 0,!1,void 0,this);if(J==="color")return j(Y0,{flexDirection:"column",paddingY:1,children:[j(Y0,{marginBottom:1,children:j(n,{bold:!0,color:"cyan",children:"Step 4/7: 选择背景颜色"},void 0,!1,void 0,this)},void 0,!1,void 0,this),j(Y0,{marginBottom:1,children:j(n,{dimColor:!0,children:"为 Agent 选择一个颜色标识(用于在 UI 中区分不同的 Agents)"},void 0,!1,void 0,this)},void 0,!1,void 0,this),j(n8,{items:$3,onSelect:(P)=>{let A=P.value==="none"?void 0:P.value;G({...X,color:A}),N()}},void 0,!1,void 0,this),j(Y0,{marginTop:1,children:j(n,{dimColor:!0,children:"使用方向键选择 | Enter 确认 | ESC 返回"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(J==="location")return j(Y0,{flexDirection:"column",paddingY:1,children:[j(Y0,{marginBottom:1,children:j(n,{bold:!0,color:"cyan",children:"Step 5/7: 选择保存位置"},void 0,!1,void 0,this)},void 0,!1,void 0,this),j(Y0,{marginBottom:1,children:j(n,{dimColor:!0,children:"项目级配置仅在当前项目生效,用户级配置全局可用"},void 0,!1,void 0,this)},void 0,!1,void 0,this),j(n8,{items:[{label:"项目级 (.blade/agents/) - 仅当前项目",value:"project"},{label:"用户级 (~/.blade/agents/) - 全局可用",value:"user"}],onSelect:(P)=>{G({...X,location:P.value}),N()}},void 0,!1,void 0,this),j(Y0,{marginTop:1,children:j(n,{dimColor:!0,children:"使用方向键选择 | Enter 确认 | ESC 返回"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(J==="systemPrompt")return j(Y0,{flexDirection:"column",paddingY:1,children:[j(Y0,{marginBottom:1,children:j(n,{bold:!0,color:"cyan",children:"Step 6/7: 输入系统提示词"},void 0,!1,void 0,this)},void 0,!1,void 0,this),j(Y0,{marginBottom:1,children:j(n,{dimColor:!0,children:"定义 Agent 的行为和职责(可选,留空将使用默认提示)"},void 0,!1,void 0,this)},void 0,!1,void 0,this),j(Y0,{marginBottom:1,children:[j(n,{color:"green",children:"提示词: "},void 0,!1,void 0,this),j(X8,{value:X.systemPrompt,onChange:(P)=>G({...X,systemPrompt:P}),onSubmit:()=>N()},void 0,!1,void 0,this)]},void 0,!0,void 0,this),j(Y0,{children:j(n,{dimColor:!0,children:"按 Enter 继续 | ESC 返回"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(J==="confirm")return j(Y0,{flexDirection:"column",paddingY:1,children:[j(Y0,{marginBottom:1,children:j(n,{bold:!0,color:"cyan",children:"Step 7/7: 确认配置"},void 0,!1,void 0,this)},void 0,!1,void 0,this),j(Y0,{flexDirection:"column",paddingLeft:2,marginBottom:1,children:[j(n,{children:[j(n,{bold:!0,color:"green",children:["名称:"," "]},void 0,!0,void 0,this),j(n,{children:X.name},void 0,!1,void 0,this)]},void 0,!0,void 0,this),j(n,{children:[j(n,{bold:!0,color:"green",children:["描述:"," "]},void 0,!0,void 0,this),j(n,{children:X.description},void 0,!1,void 0,this)]},void 0,!0,void 0,this),j(n,{children:[j(n,{bold:!0,color:"green",children:["工具:"," "]},void 0,!0,void 0,this),j(n,{children:X.tools.includes("all")?"所有工具":X.tools.join(", ")||"所有工具"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),j(n,{children:[j(n,{bold:!0,color:"green",children:["颜色:"," "]},void 0,!0,void 0,this),j(n,{children:X.color||"默认"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),j(n,{children:[j(n,{bold:!0,color:"green",children:["位置:"," "]},void 0,!0,void 0,this),j(n,{children:X.location==="project"?"项目级":"用户级"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),j(n,{children:[j(n,{bold:!0,color:"green",children:["提示词:"," "]},void 0,!0,void 0,this),j(n,{children:X.systemPrompt||"(使用默认)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),j(n8,{items:[{label:"确认并保存",value:"save"},{label:"返回上一步",value:"back"},{label:"取消",value:"cancel"}],onSelect:(P)=>{if(P.value==="save")w();else if(P.value==="back")k();else Q()}},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return null}function J3({config:$,setConfig:Q,onNext:Y,onPrev:J}){let{isFocused:Z}=nY({id:"step-tools"});_6((G,K)=>{if(K.escape)J()},{isActive:Z});let X=(G)=>{if(G.includes("all"))Q({...$,tools:["all"]});else Q({...$,tools:G});Y()};return j(Y0,{flexDirection:"column",paddingY:1,children:[j(Y0,{marginBottom:1,children:j(n,{bold:!0,color:"cyan",children:"Step 3/7: 选择可用工具"},void 0,!1,void 0,this)},void 0,!1,void 0,this),j(Y0,{marginBottom:1,children:j(n,{dimColor:!0,children:"方向键导航,空格切换勾选,Enter 确认进入下一步 | ESC 返回上一步"},void 0,!1,void 0,this)},void 0,!1,void 0,this),j(oY,{options:eY,defaultValue:$.tools,onSubmit:X},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import Y3 from"node:fs";import{useMemoizedFn as N$}from"ahooks";import{Box as C0,Text as S0,useInput as Z3}from"ink";import n2 from"ink-select-input";import{useEffect as X3,useMemo as N6,useState as t8}from"react";import{jsxDEV as i}from"react/jsx-dev-runtime";var t2=10;function H6({workspaceRoot:$,initialMode:Q="menu",onComplete:Y,onCancel:J}){let Z=F6($),[X,G]=t8(Q),[K,q]=t8(null),[U,H]=t8(0),[z,F]=t8(0),O=N$(()=>{Z.clear(),Z.loadFromStandardLocations(),H((R)=>R+1)}),B=N6(()=>{return Z.getAllSubagents()},[U]),_=Math.ceil(B.length/t2)||1,W=N6(()=>{let R=z*t2;return B.slice(R,R+t2)},[B,z]);X3(()=>{let R=Math.max(0,_-1);if(z>R)F(R)},[_,z]);let M=N$(()=>{if(z<_-1)F((R)=>R+1)}),N=N$(()=>{if(z>0)F((R)=>R-1)}),k=[{key:"list",label:"查看所有 Agents",value:"list"},{key:"create",label:"创建新 Agent",value:"create"},{key:"edit",label:"编辑 Agent",value:"edit"},{key:"delete",label:"删除 Agent",value:"delete"},{key:"cancel",label:"取消",value:"cancel"}],C=N$((R)=>{if(R.value==="cancel"){J?.();return}G(R.value)}),w=N$((R)=>{if(q(R.value),X==="edit")G("editWizard");else if(X==="delete")G("deleteConfirm")}),v=N$(async()=>{if(!K?.configPath)return;try{await Y3.promises.unlink(K.configPath),O(),P()}catch(R){console.error("删除失败:",R)}}),P=N$(()=>{G("menu"),q(null)}),A=k0(!1,J);if(Z3((R,L)=>{if(L.escape){if(X==="menu")J?.();else if(X==="list"||X==="edit"||X==="delete")F(0),P();else if(X==="deleteConfirm")P()}else if(L.ctrl&&R==="c"||L.meta&&R==="c")A();else if(X==="list"){if(L.leftArrow||R==="h")N();else if(L.rightArrow||R==="l")M()}},{isActive:X!=="create"&&X!=="editWizard"}),X==="menu")return i(C0,{flexDirection:"column",paddingY:1,children:[i(C0,{marginBottom:1,children:i(S0,{bold:!0,color:"cyan",children:"Agents 管理"},void 0,!1,void 0,this)},void 0,!1,void 0,this),i(n2,{items:k,onSelect:C},void 0,!1,void 0,this),i(C0,{marginTop:1,children:i(S0,{dimColor:!0,children:"使用方向键选择 | Enter 确认 | ESC 退出"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(X==="list"){if(B.length===0)return i(C0,{flexDirection:"column",paddingY:1,children:[i(C0,{marginBottom:1,children:i(S0,{bold:!0,color:"cyan",children:"所有 Agents"},void 0,!1,void 0,this)},void 0,!1,void 0,this),i(C0,{paddingLeft:2,children:i(S0,{color:"gray",children:"没有找到任何 agent 配置"},void 0,!1,void 0,this)},void 0,!1,void 0,this),i(C0,{marginTop:1,paddingLeft:2,children:i(S0,{color:"gray",children:"配置文件位置: .blade/agents/ 或 ~/.blade/agents/"},void 0,!1,void 0,this)},void 0,!1,void 0,this),i(C0,{marginTop:1,paddingLeft:2,children:i(S0,{dimColor:!0,children:"按 ESC 返回菜单"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return i(C0,{flexDirection:"column",paddingY:1,children:[i(C0,{marginBottom:1,children:[i(S0,{bold:!0,color:"cyan",children:"所有 Agents"},void 0,!1,void 0,this),i(S0,{color:"gray",children:[" (共 ",B.length," 个)"]},void 0,!0,void 0,this),_>1&&i(S0,{color:"yellow",children:[" ","第 ",z+1,"/",_," 页"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),W.map((R)=>i(C0,{flexDirection:"column",paddingLeft:2,children:[i(C0,{children:i(S0,{children:[i(S0,{bold:!0,color:R.color||"white",children:["• ",R.name]},void 0,!0,void 0,this),i(S0,{color:"gray",children:[" - ",R.description]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),R.tools&&R.tools.length>0&&i(C0,{paddingLeft:2,children:i(S0,{color:"gray",children:["工具: ",R.tools.join(", ")]},void 0,!0,void 0,this)},void 0,!1,void 0,this),R.configPath&&i(C0,{paddingLeft:2,children:i(S0,{color:"gray",dimColor:!0,children:R.configPath},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},R.name,!0,void 0,this)),i(C0,{marginTop:1,paddingLeft:2,children:_>1?i(S0,{dimColor:!0,children:"Left/Right to page | ESC 返回菜单"},void 0,!1,void 0,this):i(S0,{dimColor:!0,children:"按 ESC 返回菜单"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}let T=(R)=>{if(B.length===0)return i(C0,{flexDirection:"column",paddingY:1,children:[i(C0,{marginBottom:1,children:i(S0,{bold:!0,color:"cyan",children:R},void 0,!1,void 0,this)},void 0,!1,void 0,this),i(C0,{paddingLeft:2,children:i(S0,{color:"gray",children:"没有找到任何 agent 配置"},void 0,!1,void 0,this)},void 0,!1,void 0,this),i(C0,{marginTop:1,paddingLeft:2,children:i(S0,{dimColor:!0,children:"按 ESC 返回菜单"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let L=B.map((f)=>({key:f.name,label:`${f.name} - ${f.description}`,value:f}));return i(C0,{flexDirection:"column",paddingY:1,children:[i(C0,{marginBottom:1,children:i(S0,{bold:!0,color:"cyan",children:R},void 0,!1,void 0,this)},void 0,!1,void 0,this),i(n2,{items:L,onSelect:w},void 0,!1,void 0,this),i(C0,{marginTop:1,children:i(S0,{dimColor:!0,children:"使用方向键选择 | Enter 确认 | ESC 返回"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)};if(X==="create")return i(G8,{onComplete:()=>{O(),P()},onCancel:P},void 0,!1,void 0,this);if(X==="edit")return T("编辑 Agent");if(X==="editWizard"&&K){let R={name:K.name,description:K.description,tools:K.tools||[],color:K.color,location:K.configPath?.includes(".blade/agents")?"project":"user",systemPrompt:K.systemPrompt||""};return i(G8,{initialConfig:R,onComplete:()=>{O(),P()},onCancel:P},void 0,!1,void 0,this)}if(X==="delete")return T("删除 Agent");if(X==="deleteConfirm"&&K)return i(C0,{flexDirection:"column",paddingY:1,children:[i(C0,{marginBottom:1,children:i(S0,{bold:!0,color:"red",children:"确认删除"},void 0,!1,void 0,this)},void 0,!1,void 0,this),i(C0,{marginBottom:1,paddingLeft:2,children:i(S0,{children:["你确定要删除 Agent"," ",i(S0,{bold:!0,color:"yellow",children:K.name},void 0,!1,void 0,this)," ","吗?"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),i(C0,{marginBottom:1,paddingLeft:2,children:i(S0,{dimColor:!0,children:["文件路径: ",K.configPath]},void 0,!0,void 0,this)},void 0,!1,void 0,this),i(C0,{marginBottom:1,paddingLeft:2,children:i(S0,{color:"red",children:"此操作无法撤销!"},void 0,!1,void 0,this)},void 0,!1,void 0,this),i(n2,{items:[{label:"确认删除",value:"confirm"},{label:"取消",value:"cancel"}],onSelect:(R)=>{if(R.value==="confirm")v();else P()}},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return null}import{Box as g$,Text as O0}from"ink";import K3,{useEffect as q3,useState as U3}from"react";import{useEffect as G3,useState as W6}from"react";function w6($=u0(),Q=5000){let[Y,J]=W6(null),[Z,X]=W6(!0);return G3(()=>{let G=!0,K=async()=>{try{let U=await L6($);if(!G)return;if(!U){J(null),X(!1);return}let H=await B6($);if(!G)return;J(H)}catch{if(G)J(null)}finally{if(G)X(!1)}};K();let q=null;if(Q>0)q=setInterval(K,Q);return()=>{if(G=!1,q)clearInterval(q)}},[$,Q]),{branch:Y,loading:Z}}import{jsxDEV as o,Fragment as b1}from"react/jsx-dev-runtime";var b6=K3.memo(()=>{let $=y8(),Q=f$(),J=P8()==="shortcuts",Z=U4(),X=C1(),{branch:G}=w6(X),K=R8(),q=Y4(),U=Q4(),H=I8(),z=T8(),F=v8(),O=f8(),B=k8(),_=J4(),W=C8(),M=H4(),N=v$(),[k,C]=U3(null);q3(()=>{let R=!1;new s2(X,N).get().then((E)=>{if(!R)C(E)}).catch(()=>{if(!R)C(null)});let f=s2.subscribe((E)=>{if(!R&&E.sessionId===N&&E.workspaceRoot===X)C(E.goal)});return()=>{R=!0,f()}},[N,X]);let w=K?a8(K):!1,P=(()=>{if(Q==="default")return null;if(Q==="autoEdit")return o(O0,{color:"magenta",children:[">> ","auto edit on ",o(O0,{color:"gray",children:"(shift+tab to cycle)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(Q==="plan")return o(O0,{color:"cyan",children:["‖ plan mode on ",o(O0,{color:"gray",children:"(shift+tab to cycle)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(Q==="yolo")return o(O0,{color:"red",children:["yolo mode on ",o(O0,{color:"gray",children:"(all tools auto-approved)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return null})(),A=P!==null,T=[["Enter:发送","Shift+Enter:换行","Esc:中止"],["Shift+Tab:切换模式","Up/Down:历史","Tab:补全"],["Ctrl+A:行首","Ctrl+E:行尾","Ctrl+K:删到尾"],["Ctrl+U:删到首","Ctrl+W:删单词","Ctrl+C:退出"]];return o(g$,{flexDirection:"row",justifyContent:"space-between",paddingX:2,paddingY:0,children:[J?o(g$,{flexDirection:"column",gap:0,children:T.map((R,L)=>o(g$,{flexDirection:"row",children:[R.map((f,E)=>{let[t,u]=f.split(":");return o(g$,{flexDirection:"row",width:20,children:[o(O0,{color:"yellow",children:t},void 0,!1,void 0,this),o(O0,{color:"gray",children:":"},void 0,!1,void 0,this),o(O0,{color:"white",children:u},void 0,!1,void 0,this)]},E,!0,void 0,this)}),L===T.length-1&&o(O0,{color:"cyan",children:" ? 关闭"},void 0,!1,void 0,this)]},L,!0,void 0,this))},void 0,!1,void 0,this):o(g$,{flexDirection:"row",gap:1,children:[G&&o(b1,{children:[o(O0,{color:"gray",children:[" ",G]},void 0,!0,void 0,this),o(O0,{color:"gray",children:"·"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),P,A&&o(O0,{color:"gray",children:"·"},void 0,!1,void 0,this),k&&o(b1,{children:[o(O0,{color:k.status==="active"?"green":k.status==="verifying"?"cyan":k.status==="blocked"||k.status==="budget_limited"?"yellow":"gray",children:["goal:",k.status," ",k.objective.slice(0,32)]},void 0,!0,void 0,this),o(O0,{color:"gray",children:"·"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),o(O0,{color:"gray",children:"? for shortcuts"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),o(g$,{flexDirection:"row",gap:1,children:!$?o(O0,{color:"red",children:"[WARN] API 密钥未配置"},void 0,!1,void 0,this):o(b1,{children:[w&&o(b1,{children:[H?o(O0,{color:"cyan",children:["Effort ",z]},void 0,!0,void 0,this):o(O0,{color:"gray",children:"Tab:Effort"},void 0,!1,void 0,this),o(O0,{color:"gray",children:"·"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),F!=="auto"&&o(b1,{children:[o(O0,{color:F==="fast"?"yellow":"gray",children:["Speed ",F]},void 0,!0,void 0,this),o(O0,{color:"gray",children:"·"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),O!=="auto"&&o(b1,{children:[o(O0,{color:"gray",children:["Output ",O]},void 0,!0,void 0,this),o(O0,{color:"gray",children:"·"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),B!=="auto"&&o(b1,{children:[o(O0,{color:"gray",children:["Style ",B]},void 0,!0,void 0,this),o(O0,{color:"gray",children:"·"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),K&&o(O0,{color:"gray",children:K.model},void 0,!1,void 0,this),o(O0,{color:"gray",children:"·"},void 0,!1,void 0,this),U?o(O0,{color:"yellow",children:"压缩中..."},void 0,!1,void 0,this):o(O0,{color:q<20?"red":q<50?"yellow":"gray",children:[q,"%"]},void 0,!0,void 0,this),_>0.001&&o(b1,{children:[o(O0,{color:"gray",children:"·"},void 0,!1,void 0,this),o(O0,{color:"green",children:["$",_<0.01?_.toFixed(4):_.toFixed(3)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),W.length>0&&o(b1,{children:[o(O0,{color:"gray",children:"·"},void 0,!1,void 0,this),o(O0,{color:"yellow",children:["已排队 ",W.length]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),M>0&&o(b1,{children:[o(O0,{color:"gray",children:"·"},void 0,!1,void 0,this),o(O0,{color:"cyan",children:["已恢复 ",M," 条指令"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Z&&o(b1,{children:[o(O0,{color:"gray",children:"·"},void 0,!1,void 0,this),o(O0,{color:"yellow",children:"再按一次 Ctrl+C 退出"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)});import{Box as e2,Text as $Q}from"ink";import z3 from"react";import{jsxDEV as m$}from"react/jsx-dev-runtime";var A6=z3.memo(({suggestions:$,selectedIndex:Q,visible:Y,maxDisplay:J=8})=>{if(!Y||$.length===0)return null;let Z=0,X=Math.min(J,$.length),G=Q>=$.length;if(Q>=J&&!G)Z=Q-J+1,X=Q+1;let K=$.slice(Z,X),q=$.length>J;return m$(e2,{flexDirection:"column",paddingX:2,paddingY:0,children:[K.map((U,H)=>{let F=Z+H===Q;return m$(e2,{flexDirection:"row",paddingX:1,gap:2,children:[m$($Q,{color:F?"cyan":"white",bold:F,children:U.command},void 0,!1,void 0,this),m$($Q,{color:F?"cyan":"gray",dimColor:!F,children:["- ",U.description]},void 0,!0,void 0,this)]},U.command,!0,void 0,this)}),q&&m$(e2,{paddingX:1,children:m$($Q,{color:G?"cyan":"gray",bold:G,dimColor:!G,children:["... and ",$.length-J," more"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)});import{Box as W1,Text as T1,useInput as JZ,useStdout as YZ}from"ink";import ZZ from"ink-select-input";import MQ,{useMemo as o6}from"react";import{Box as z0,Text as b0}from"ink";import W$,{useEffect as yQ,useMemo as H$,useRef as r6}from"react";import{Box as _Q,Text as D6}from"ink";import R3 from"react";import{Text as A1}from"ink";import A3 from"react";import f6 from"string-width";import K8 from"string-width";function QQ({onlyFirst:$=!1}={}){return new RegExp("(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]",$?void 0:"g")}var O3=QQ();function JQ($){if(typeof $!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof $}\``);if(!$.includes("\x1B")&&!$.includes(""))return $;return $.replace(O3,"")}var P6=($=0)=>(Q)=>`\x1B[${Q+$}m`,y6=($=0)=>(Q)=>`\x1B[${38+$};5;${Q}m`,R6=($=0)=>(Q,Y,J)=>`\x1B[${38+$};2;${Q};${Y};${J}m`,j0={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},VK=Object.keys(j0.modifier),_3=Object.keys(j0.color),N3=Object.keys(j0.bgColor),jK=[..._3,...N3];function F3(){let $=new Map;for(let[Q,Y]of Object.entries(j0)){for(let[J,Z]of Object.entries(Y))j0[J]={open:`\x1B[${Z[0]}m`,close:`\x1B[${Z[1]}m`},Y[J]=j0[J],$.set(Z[0],Z[1]);Object.defineProperty(j0,Q,{value:Y,enumerable:!1})}return Object.defineProperty(j0,"codes",{value:$,enumerable:!1}),j0.color.close="\x1B[39m",j0.bgColor.close="\x1B[49m",j0.color.ansi=P6(),j0.color.ansi256=y6(),j0.color.ansi16m=R6(),j0.bgColor.ansi=P6(10),j0.bgColor.ansi256=y6(10),j0.bgColor.ansi16m=R6(10),Object.defineProperties(j0,{rgbToAnsi256:{value(Q,Y,J){if(Q===Y&&Y===J){if(Q<8)return 16;if(Q>248)return 231;return Math.round((Q-8)/247*24)+232}return 16+36*Math.round(Q/255*5)+6*Math.round(Y/255*5)+Math.round(J/255*5)},enumerable:!1},hexToRgb:{value(Q){let Y=/[a-f\d]{6}|[a-f\d]{3}/i.exec(Q.toString(16));if(!Y)return[0,0,0];let[J]=Y;if(J.length===3)J=[...J].map((X)=>X+X).join("");let Z=Number.parseInt(J,16);return[Z>>16&255,Z>>8&255,Z&255]},enumerable:!1},hexToAnsi256:{value:(Q)=>j0.rgbToAnsi256(...j0.hexToRgb(Q)),enumerable:!1},ansi256ToAnsi:{value(Q){if(Q<8)return 30+Q;if(Q<16)return 90+(Q-8);let Y,J,Z;if(Q>=232)Y=((Q-232)*10+8)/255,J=Y,Z=Y;else{Q-=16;let K=Q%36;Y=Math.floor(Q/36)/5,J=Math.floor(K/6)/5,Z=K%6/5}let X=Math.max(Y,J,Z)*2;if(X===0)return 30;let G=30+(Math.round(Z)<<2|Math.round(J)<<1|Math.round(Y));if(X===2)G+=60;return G},enumerable:!1},rgbToAnsi:{value:(Q,Y,J)=>j0.ansi256ToAnsi(j0.rgbToAnsi256(Q,Y,J)),enumerable:!1},hexToAnsi:{value:(Q)=>j0.ansi256ToAnsi(j0.hexToAnsi256(Q)),enumerable:!1}}),j0}var H3=F3(),M6=H3;var e8=new Set(["\x1B",""]),W3=39,ZQ="\x07",T6="[",L3="]",v6="m",s8=`${L3}8;;`,C6=($)=>`${e8.values().next().value}${T6}${$}${v6}`,I6=($)=>`${e8.values().next().value}${s8}${$}${ZQ}`,B3=($)=>$.split(" ").map((Q)=>K8(Q)),YQ=($,Q,Y)=>{let J=[...Q],Z=!1,X=!1,G=K8(JQ($.at(-1)));for(let[K,q]of J.entries()){let U=K8(q);if(G+U<=Y)$[$.length-1]+=q;else $.push(q),G=0;if(e8.has(q))Z=!0,X=J.slice(K+1,K+1+s8.length).join("")===s8;if(Z){if(X){if(q===ZQ)Z=!1,X=!1}else if(q===v6)Z=!1;continue}if(G+=U,G===Y&&K<J.length-1)$.push(""),G=0}if(!G&&$.at(-1).length>0&&$.length>1)$[$.length-2]+=$.pop()},w3=($)=>{let Q=$.split(" "),Y=Q.length;while(Y>0){if(K8(Q[Y-1])>0)break;Y--}if(Y===Q.length)return $;return Q.slice(0,Y).join(" ")+Q.slice(Y).join("")},b3=($,Q,Y={})=>{if(Y.trim!==!1&&$.trim()==="")return"";let J="",Z,X,G=B3($),K=[""];for(let[z,F]of $.split(" ").entries()){if(Y.trim!==!1)K[K.length-1]=K.at(-1).trimStart();let O=K8(K.at(-1));if(z!==0){if(O>=Q&&(Y.wordWrap===!1||Y.trim===!1))K.push(""),O=0;if(O>0||Y.trim===!1)K[K.length-1]+=" ",O++}if(Y.hard&&G[z]>Q){let B=Q-O,_=1+Math.floor((G[z]-B-1)/Q);if(Math.floor((G[z]-1)/Q)<_)K.push("");YQ(K,F,Q);continue}if(O+G[z]>Q&&O>0&&G[z]>0){if(Y.wordWrap===!1&&O<Q){YQ(K,F,Q);continue}K.push("")}if(O+G[z]>Q&&Y.wordWrap===!1){YQ(K,F,Q);continue}K[K.length-1]+=F}if(Y.trim!==!1)K=K.map((z)=>w3(z));let q=K.join(`
|
|
119
119
|
`),U=[...q],H=0;for(let[z,F]of U.entries()){if(J+=F,e8.has(F)){let{groups:B}=new RegExp(`(?:\\${T6}(?<code>\\d+)m|\\${s8}(?<uri>.*)${ZQ})`).exec(q.slice(H))||{groups:{}};if(B.code!==void 0){let _=Number.parseFloat(B.code);Z=_===W3?void 0:_}else if(B.uri!==void 0)X=B.uri.length===0?void 0:B.uri}let O=M6.codes.get(Number(Z));if(U[z+1]===`
|
|
120
120
|
`){if(X)J+=I6("");if(Z&&O)J+=C6(O)}else if(F===`
|
|
121
121
|
`){if(Z&&O)J+=C6(Z);if(X)J+=I6(X)}H+=F.length}return J};function XQ($,Q,Y){return String($).normalize().replaceAll(`\r
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownRenderer-CkSbe36j.js","assets/index-DWtXGF3o.js","assets/vendor-react-DG5dkZ_t.js","assets/vendor-radix-DXRuAJHH.js","assets/vendor-icons-ICv1v-tf.js","assets/index-BC7ygRH_.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as f,j as e}from"./vendor-react-DG5dkZ_t.js";import{u as D,a as y,b as ie,s as ye,c as Pe,d as W,D as we,e as Ne,f as _e,g as Se,h as Ce,i as Ee,j as A,k as O,l as Ve,B as ne,m as Le,n as Oe,o as Ue,_ as He,S as Ke,p as qe,q as ze,t as Ge,r as We,C as Je,v as Qe}from"./index-DWtXGF3o.js";import{Q as he,O as Ye,G as Xe,Y as Ze,L as F,z as et,T as Y,C as Z,Z as tt,v as st,_ as rt,B as at,$ as Te,y as ee,m as oe,R as le,s as nt,H as it,a0 as Ae,U as ot,a1 as lt,a2 as ct,a3 as dt,P as Fe,a4 as ut,X as mt,a5 as xt,a6 as ht,f as De,a7 as pt,W as ft,a as bt}from"./vendor-icons-ICv1v-tf.js";import{j as gt,k as vt,l as kt,m as Re}from"./vendor-radix-DXRuAJHH.js";function pe(t){return t.split("/").filter(Boolean).at(-1)||t}function jt(){const t=D(),s=y(w=>w.sessions),r=y(w=>w.currentSessionRef),a=y(w=>w.taskDeliveryActions),c=y(w=>w.deliverTask),n=ie(w=>w.openFilePreview),[u,b]=f.useState(!1),l=s.find(w=>ye({sessionId:w.sessionId,projectPath:w.projectPath},r));if(!(l!=null&&l.taskIsolation))return null;const o=l.taskDiffStat,v=l.taskIsolation==="worktree",i=Pe(l),p=a[W(i)],h=l.taskDelivery,k=(h==null?void 0:h.status)==="conflicted",N=!!(o&&(o.changedFiles>0||o.commits>0)),x=!["queued","running"].includes(l.taskStatus),C=(h==null?void 0:h.status)==="applied"||(h==null?void 0:h.status)==="discarded",d=v&&N&&x&&!C,m=o?o.additions+o.deletions:0,j=m>0&&o?o.additions/m*100:0,S=w=>{c(i,w).catch(()=>{})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex min-h-10 flex-wrap items-center gap-x-3 gap-y-1.5 border-b border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))]/60 px-3 py-1.5 font-mono text-[10.5px] text-[hsl(var(--deck-ink-muted))] backdrop-blur-sm sm:px-5",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[e.jsx(he,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"truncate text-[hsl(var(--deck-ink))]",children:pe(l.taskSourceProjectPath||l.projectPath)})]}),e.jsx("span",{className:"text-[hsl(var(--deck-ink-faint))]/60",children:"/"}),e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[v?e.jsx(Ye,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-accent))]"}):e.jsx(he,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:v?"text-[hsl(var(--deck-accent))]":void 0,children:t(v?"artifact.env.isolated":"artifact.env.local")})]}),l.taskWorktreeBranch&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[hsl(var(--deck-ink-faint))]/60",children:"/"}),e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 truncate",title:l.taskWorktreeBranch,children:[e.jsx(Xe,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"truncate",children:l.taskWorktreeBranch})]})]})]}),o&&e.jsxs("div",{className:"ml-auto flex max-w-full items-center gap-2",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 text-[hsl(var(--deck-ink-muted))]",children:[e.jsx(Ze,{className:"h-3 w-3 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"tabular-nums",children:o.changedFiles})]}),m>0&&e.jsxs("span",{className:"relative hidden h-1.5 w-14 overflow-hidden rounded-sm border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] sm:inline-flex","aria-hidden":"true",children:[e.jsx("span",{className:"h-full bg-[hsl(var(--deck-accent))]",style:{width:`${j}%`}}),e.jsx("span",{className:"h-full bg-red-500/80",style:{width:`${100-j}%`}})]}),e.jsxs("span",{className:"tabular-nums text-[hsl(var(--deck-accent))]",children:["+",o.additions]}),e.jsxs("span",{className:"tabular-nums text-red-600 dark:text-red-400",children:["-",o.deletions]}),o.commits>0&&e.jsx("span",{className:"hidden tabular-nums text-[hsl(var(--deck-ink-faint))] sm:inline",children:t("artifact.commits",{count:o.commits})}),N&&(h==null?void 0:h.status)!=="discarded"&&e.jsx("button",{type:"button",onClick:()=>n({tab:"diff"}),className:"inline-flex items-center gap-1 rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-2 py-1 text-[hsl(var(--deck-ink))] transition hover:border-[hsl(var(--deck-accent)/0.55)] hover:text-[hsl(var(--deck-accent))]",children:t("artifact.review")}),d&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",disabled:!!p,onClick:()=>S("apply"),className:"inline-flex items-center gap-1 rounded-md bg-[hsl(var(--deck-accent))] px-2 py-1 font-semibold text-white transition hover:brightness-95 disabled:cursor-wait disabled:opacity-65",children:[p==="apply"?e.jsx(F,{className:"h-3 w-3 animate-spin"}):e.jsx(et,{className:"h-3 w-3"}),t(p==="apply"?"artifact.applying":k?"artifact.retryApply":"artifact.apply")]}),e.jsx("button",{type:"button",disabled:!!p,onClick:()=>b(!0),className:"inline-flex items-center gap-1 rounded-md px-1.5 py-1 text-[hsl(var(--deck-ink-faint))] transition hover:bg-red-500/10 hover:text-red-600 disabled:cursor-wait disabled:opacity-50 dark:hover:text-red-400","aria-label":t("artifact.discard"),title:t("artifact.discard"),children:p==="discard"?e.jsx(F,{className:"h-3 w-3 animate-spin"}):e.jsx(Y,{className:"h-3 w-3"})})]}),(h==null?void 0:h.status)==="applied"&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-emerald-500/10 px-2 py-1 font-semibold text-emerald-700 dark:text-emerald-300",children:[e.jsx(Z,{className:"h-3 w-3"}),t("artifact.applied")]}),(h==null?void 0:h.status)==="discarded"&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-[hsl(var(--deck-surface-2))] px-2 py-1 text-[hsl(var(--deck-ink-faint))]",children:[e.jsx(Y,{className:"h-3 w-3"}),t("artifact.discarded")]})]}),(h==null?void 0:h.status)==="conflicted"&&e.jsxs("div",{className:"flex w-full items-start gap-1.5 border-t border-amber-500/20 pt-1.5 text-amber-700 dark:text-amber-300",role:"alert",children:[e.jsx(tt,{className:"mt-0.5 h-3 w-3 shrink-0"}),e.jsxs("span",{className:"min-w-0 flex-1 space-y-0.5",children:[e.jsx("span",{className:"block",children:h.message||t("artifact.conflict")}),e.jsx("span",{className:"block text-[hsl(var(--deck-ink-faint))]",children:t("artifact.conflictHint")})]})]})]}),e.jsx(we,{open:u,onOpenChange:b,children:e.jsxs(Ne,{className:"w-[calc(100%_-_2rem)] max-w-md border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] text-[hsl(var(--deck-ink))]",children:[e.jsxs(_e,{children:[e.jsx(Se,{children:t("artifact.discardDialog.title")}),e.jsx(Ce,{className:"text-[hsl(var(--deck-ink-muted))]",children:t("artifact.discardDialog.description",{project:pe(l.taskSourceProjectPath||l.projectPath),count:(o==null?void 0:o.changedFiles)??0})})]}),e.jsx("div",{className:"rounded-lg border border-red-500/20 bg-red-500/5 px-3 py-2 text-xs leading-relaxed text-red-700 dark:text-red-300",children:t("artifact.discardDialog.warning")}),e.jsxs(Ee,{className:"gap-2 sm:space-x-0",children:[e.jsx("button",{type:"button",onClick:()=>b(!1),className:"rounded-md border border-[hsl(var(--deck-border))] px-3 py-2 text-sm hover:bg-[hsl(var(--deck-surface-2))]",children:t("artifact.discardDialog.cancel")}),e.jsxs("button",{type:"button",onClick:()=>{b(!1),S("discard")},className:"inline-flex items-center justify-center gap-1.5 rounded-md bg-red-600 px-3 py-2 text-sm font-semibold text-white hover:bg-red-700",children:[e.jsx(Y,{className:"h-3.5 w-3.5"}),t("artifact.discardDialog.confirm")]})]})]})})]})}const yt=new Set(["completed","stale","failed","aborted","interrupted"]),wt={completed:"chat.review.status.completed",stale:"chat.review.status.stale",failed:"chat.review.status.failed",aborted:"chat.review.status.aborted",interrupted:"chat.review.status.interrupted"},Nt={completed:"bg-emerald-500/10 text-emerald-700 dark:text-emerald-300 border-emerald-500/20",stale:"bg-amber-500/10 text-amber-700 dark:text-amber-300 border-amber-500/20",failed:"bg-red-500/10 text-red-700 dark:text-red-300 border-red-500/20",aborted:"bg-zinc-500/10 text-zinc-700 dark:text-zinc-300 border-zinc-500/20",interrupted:"bg-amber-500/10 text-amber-700 dark:text-amber-300 border-amber-500/20"};function X(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:void 0}function St(t){const s=X(t),r=X(s==null?void 0:s.codeLocation),a=s==null?void 0:s.priority,c=s==null?void 0:s.confidenceScore,n=r==null?void 0:r.lineStart,u=r==null?void 0:r.lineEnd;if(!(typeof(s==null?void 0:s.title)!="string"||typeof s.body!="string"||a!==0&&a!==1&&a!==2&&a!==3||typeof c!="number"||!Number.isFinite(c)||typeof(r==null?void 0:r.path)!="string"||!Number.isInteger(n)||!Number.isInteger(u)))return{title:s.title,body:s.body,priority:a,confidenceScore:c,codeLocation:{path:r.path,lineStart:n,lineEnd:u}}}function Ct(t){const s=X(t),r=X(s==null?void 0:s.target);if((s==null?void 0:s.phase)!=="completed"||typeof s.status!="string"||!yt.has(s.status)||typeof(r==null?void 0:r.label)!="string"||r.kind!=="uncommitted"&&r.kind!=="base"&&r.kind!=="commit"||typeof s.overallExplanation!="string"||!Array.isArray(s.findings))return;const a=s.findings.map(St);if(!a.some(c=>c===void 0))return{status:s.status,target:{kind:r.kind,label:r.label,...typeof r.reference=="string"?{reference:r.reference}:{}},overallExplanation:s.overallExplanation,findings:a,...typeof s.error=="string"?{error:s.error}:{}}}function Et(t){const{path:s,lineStart:r,lineEnd:a}=t.codeLocation;return r===a?`${s}:L${r}`:`${s}:L${r}-${a}`}function Tt({report:t}){const s=D(),r=t.target.kind==="uncommitted"?s("chat.review.target.uncommitted"):t.target.kind==="base"?s("chat.review.target.base",{ref:t.target.reference??t.target.label}):s("chat.review.target.commit",{ref:t.target.reference??t.target.label});return e.jsxs("section",{"data-code-review-report":!0,className:"overflow-hidden rounded-xl border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsxs("header",{className:"flex flex-wrap items-center justify-between gap-3 border-b border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-surface-2))]/60 px-4 py-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-[13px] font-semibold text-[hsl(var(--deck-ink))]",children:s("chat.review.title")}),e.jsxs("p",{className:"mt-0.5 font-mono text-[10.5px] text-[hsl(var(--deck-ink-faint))]",children:[s("chat.review.target"),": ",r]})]}),e.jsxs("span",{className:A("rounded-full border px-2.5 py-1 font-mono text-[10.5px] font-medium",Nt[t.status]),children:[s("chat.review.status"),": ",s(wt[t.status])]})]}),e.jsxs("div",{className:"space-y-4 px-4 py-3.5",children:[e.jsx("p",{className:"whitespace-pre-wrap text-[13px] leading-6 text-[hsl(var(--deck-ink-muted))]",children:t.overallExplanation}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("h4",{className:"deck-eyebrow text-[hsl(var(--deck-ink-faint))]",children:s("chat.review.findings")}),e.jsx("span",{className:"font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:t.findings.length})]}),t.findings.length===0?e.jsx("div",{className:"rounded-lg bg-[hsl(var(--deck-surface-2))] px-3 py-2.5 text-[12px] text-[hsl(var(--deck-ink-muted))]",children:s("chat.review.noFindings")}):e.jsx("ol",{className:"space-y-2",children:t.findings.map((a,c)=>e.jsxs("li",{className:"rounded-lg border border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))] px-3 py-2.5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[e.jsx("h5",{className:"text-[12.5px] font-medium leading-5 text-[hsl(var(--deck-ink))]",children:a.title}),e.jsx("span",{className:"shrink-0 font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:s("chat.review.confidence",{value:a.confidenceScore.toFixed(2)})})]}),e.jsx("code",{className:"mt-1 block text-[10.5px] text-[hsl(var(--deck-accent))]",children:Et(a)}),e.jsx("p",{className:"mt-1.5 whitespace-pre-wrap text-[12px] leading-5 text-[hsl(var(--deck-ink-muted))]",children:a.body})]},`${a.codeLocation.path}:${a.codeLocation.lineStart}:${c}`))})]}),t.error&&e.jsxs("div",{className:"rounded-lg border border-red-500/20 bg-red-500/5 px-3 py-2 text-[11px] text-red-700 dark:text-red-300",children:[e.jsxs("span",{className:"font-medium",children:[s("chat.review.error"),":"]})," ",t.error]})]})]})}function At({elicitation:t,messageId:s}){const r=D(),a=y(d=>d.currentSessionRef),c=y(d=>d.setElicitation),[n,u]=f.useState(()=>Dt(t.details.fields??[])),[b,l]=f.useState(()=>Rt(t.details.fields??[])),[o,v]=f.useState(!1),[i,p]=f.useState(),h=t.details.fields??[],k=f.useMemo(()=>h.every(d=>{var j;if(!d.required)return!0;if(te(d))return!!((j=b[d.name])!=null&&j.trim()||d.defaultValue!==void 0);const m=n[d.name]??d.defaultValue;return Array.isArray(m)?m.length>0:m!==void 0}),[h,b,n]);if(t.status!=="pending")return e.jsx("div",{className:"rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-3 py-2 font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:r(t.status==="cancelled"?"interaction.elicitation.cancelled":"interaction.elicitation.responded")});const N=async(d,m)=>{if(!(!a||o)){v(!0),p(void 0);try{await O.respondToElicitation(a,t.toolCallId,{action:d,...m?{content:m}:{}}),c(s,{...t,status:"responded"})}catch(j){p(j instanceof Error?j.message:r("interaction.elicitation.failed"))}finally{v(!1)}}},x=async()=>{try{await N("accept",Mt(h,n,b))}catch(d){p(d instanceof Error?d.message:String(d))}},C=()=>{const d=t.details.url;if(!d){p("MCP URL is unavailable");return}if(!window.open(d,"_blank","noopener,noreferrer")){p("The browser blocked the external window");return}N("accept")};return e.jsxs("div",{"data-pending-interaction":"elicitation",tabIndex:-1,role:"alert",className:"space-y-4 rounded-lg border border-amber-300/70 bg-amber-50/70 p-4 outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-800/70 dark:bg-amber-950/25",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(st,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400"}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("div",{className:"font-mono text-[12px] font-semibold text-[hsl(var(--deck-ink))]",children:[r("interaction.elicitation.title")," · ",t.details.serverName]}),e.jsx("div",{className:"font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:t.details.message}),e.jsx("div",{className:"font-mono text-[11px] text-amber-700 dark:text-amber-300",children:r("interaction.elicitation.warning")})]})]}),t.details.mode==="url"?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] p-3 font-mono text-[11px]",children:[e.jsx("div",{className:"text-[hsl(var(--deck-ink-muted))]",children:t.details.domain}),e.jsx("div",{className:"mt-1 break-all text-[hsl(var(--deck-ink))]",children:t.details.url})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(H,{onClick:C,disabled:o,primary:!0,label:r("interaction.elicitation.open"),icon:e.jsx(rt,{className:"h-3.5 w-3.5"})}),e.jsx(H,{onClick:()=>void N("decline"),disabled:o,label:r("interaction.elicitation.decline")}),e.jsx(H,{onClick:()=>void N("cancel"),disabled:o,label:r("interaction.elicitation.cancel")})]})]}):e.jsxs("div",{className:"space-y-4",children:[h.map(d=>e.jsx(Ft,{field:d,value:n[d.name],rawValue:b[d.name]??"",onValueChange:m=>u(j=>({...j,[d.name]:m})),onRawChange:m=>l(j=>({...j,[d.name]:m}))},d.name)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(H,{onClick:()=>void x(),disabled:o||!k,primary:!0,label:r("interaction.elicitation.submit"),icon:o?e.jsx(F,{className:"h-3.5 w-3.5 animate-spin"}):null}),e.jsx(H,{onClick:()=>void N("decline"),disabled:o,label:r("interaction.elicitation.decline")}),e.jsx(H,{onClick:()=>void N("cancel"),disabled:o,label:r("interaction.elicitation.cancel")})]})]}),i&&e.jsx("div",{className:"rounded-md border border-red-300/70 bg-red-50 px-2.5 py-2 font-mono text-[11px] text-red-700 dark:border-red-900/70 dark:bg-red-950/35 dark:text-red-300",children:i})]})}function Ft({field:t,value:s,rawValue:r,onValueChange:a,onRawChange:c}){return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{htmlFor:`mcp-elicitation-${t.name}`,className:"block font-mono text-[12px] font-medium text-[hsl(var(--deck-ink))]",children:[t.title,t.required?" *":""]}),t.description&&e.jsx("div",{className:"font-mono text-[11px] text-[hsl(var(--deck-ink-faint))]",children:t.description}),t.type==="select"||t.type==="multi-select"||t.type==="boolean"?e.jsx("div",{id:`mcp-elicitation-${t.name}`,className:"flex flex-wrap gap-2",children:It(t).map(n=>{const u=Array.isArray(s)?s.includes(n.value):s===n.typedValue;return e.jsx("button",{type:"button","aria-pressed":u,onClick:()=>{if(t.type==="multi-select"){const b=Array.isArray(s)?s:[];a(b.includes(n.value)?b.filter(l=>l!==n.value):[...b,n.value])}else a(n.typedValue)},className:A("rounded-md border px-3 py-2 font-mono text-[12px] transition-colors",u?"border-emerald-500 bg-emerald-50 text-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-200":"border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] text-[hsl(var(--deck-ink-muted))] hover:text-[hsl(var(--deck-ink))]"),children:n.label},n.value)})}):e.jsx("input",{id:`mcp-elicitation-${t.name}`,type:Bt(t),value:r,onChange:n=>c(n.target.value),min:t.minimum,max:t.maximum,minLength:t.minLength,maxLength:t.maxLength,required:t.required,placeholder:t.defaultValue===void 0?t.required?"Required":"Optional":String(t.defaultValue),className:"w-full rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-3 py-2 font-mono text-[12px] text-[hsl(var(--deck-ink))] outline-none transition-colors focus:border-amber-500 focus:ring-1 focus:ring-amber-500"})]})}function H({onClick:t,disabled:s,primary:r=!1,label:a,icon:c}){return e.jsxs("button",{type:"button",onClick:t,disabled:s,className:A("inline-flex min-h-8 items-center gap-1.5 rounded-md px-3 py-1.5 font-mono text-[12px] transition-colors disabled:cursor-wait disabled:opacity-50",r?"bg-amber-600 text-white hover:bg-amber-700":"border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] text-[hsl(var(--deck-ink-muted))] hover:text-[hsl(var(--deck-ink))]"),children:[c,a]})}function Dt(t){return Object.fromEntries(t.filter(s=>!te(s)&&s.defaultValue!==void 0).map(s=>[s.name,Array.isArray(s.defaultValue)?[...s.defaultValue]:s.defaultValue]))}function Rt(t){return Object.fromEntries(t.filter(s=>te(s)&&s.defaultValue!==void 0).map(s=>[s.name,String(s.defaultValue)]))}function Mt(t,s,r){var c;const a={};for(const n of t){if(te(n)){const b=((c=r[n.name])==null?void 0:c.trim())??"";if(!b){if(n.defaultValue!==void 0)a[n.name]=n.defaultValue;else if(n.required)throw new Error(`${n.title} is required`);continue}if(n.type==="number"||n.type==="integer"){const l=Number(b);if(!Number.isFinite(l))throw new Error(`${n.title} must be a finite number`);if(n.type==="integer"&&!Number.isSafeInteger(l))throw new Error(`${n.title} must be a safe integer`);a[n.name]=l}else a[n.name]=b;continue}const u=s[n.name]??n.defaultValue;if(u===void 0){if(n.required)throw new Error(`${n.title} is required`);continue}if(Array.isArray(u)){if(n.minItems!==void 0&&u.length<n.minItems)throw new Error(`${n.title} requires at least ${n.minItems} choices`);if(n.maxItems!==void 0&&u.length>n.maxItems)throw new Error(`${n.title} allows at most ${n.maxItems} choices`)}a[n.name]=u}return a}function It(t){return t.type==="boolean"?[{value:"true",label:"Yes",typedValue:!0},{value:"false",label:"No",typedValue:!1}]:(t.options??[]).map(s=>({...s,typedValue:s.value}))}function te(t){return t.type==="string"||t.type==="number"||t.type==="integer"}function Bt(t){return t.type==="number"||t.type==="integer"?"number":t.format==="email"?"email":t.format==="uri"?"url":t.format==="date"?"date":t.format==="date-time"?"datetime-local":"text"}function $t(t){if(!t||typeof t!="object"||Array.isArray(t))return;const s=t;if(!(!s.output||typeof s.output!="object"||Array.isArray(s.output)))return{output:s.output,...typeof s.schemaDigest=="string"?{schemaDigest:s.schemaDigest}:{}}}function Pt({report:t}){const s=D(),[r,a]=f.useState(!1),c=JSON.stringify(t.output,null,2),n=async()=>{try{await navigator.clipboard.writeText(c),a(!0),window.setTimeout(()=>a(!1),1400)}catch{}};return e.jsxs("section",{"data-structured-output":!0,className:"overflow-hidden rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsxs("header",{className:"flex min-h-9 items-center justify-between gap-3 border-b border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(at,{className:"h-3.5 w-3.5 shrink-0 text-[hsl(var(--deck-accent))]"}),e.jsx("span",{className:"font-mono text-[11px] font-semibold text-[hsl(var(--deck-ink))]",children:s("chat.structuredOutput.title")}),t.schemaDigest&&e.jsxs("span",{title:t.schemaDigest,className:"truncate font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:["sha256:",t.schemaDigest.slice(0,10)]})]}),e.jsx("button",{type:"button",onClick:n,"aria-label":s("chat.structuredOutput.copy"),title:s("chat.structuredOutput.copy"),className:"flex h-6 w-6 shrink-0 items-center justify-center rounded text-[hsl(var(--deck-ink-faint))] hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:r?e.jsx(Z,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}):e.jsx(Te,{className:"h-3.5 w-3.5"})})]}),e.jsx("pre",{className:"max-h-[440px] overflow-auto whitespace-pre p-3 font-mono text-[11px] leading-5 text-[hsl(var(--deck-ink))]",children:c})]})}const _t=f.lazy(()=>He(()=>import("./MarkdownRenderer-CkSbe36j.js").then(t=>t.M),__vite__mapDeps([0,1,2,3,4,5])).then(t=>({default:t.MarkdownRenderer})));function fe({text:t,label:s}){const[r,a]=f.useState(!1);if(!t.trim())return null;const c=async()=>{try{await navigator.clipboard.writeText(t),a(!0),window.setTimeout(()=>a(!1),1400)}catch{}};return e.jsx("button",{type:"button","aria-label":s,title:s,onClick:c,className:"flex h-6 w-6 items-center justify-center rounded-md text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:r?e.jsx(Z,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}):e.jsx(Te,{className:"h-3.5 w-3.5"})})}function Vt(){return e.jsx("div",{className:"flex h-8 w-8 shrink-0 select-none items-center justify-center rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] shadow-[0_1px_0_hsl(var(--deck-hairline))]",children:e.jsx(ne,{size:20,pulse:!1})})}function Lt(){return e.jsx("div",{className:"flex h-8 w-8 shrink-0 select-none items-center justify-center rounded-full border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-canvas-veil))]",children:e.jsx("span",{className:"font-mono text-[11px] font-medium text-[hsl(var(--deck-ink))]",children:"U"})})}function be(t){let s=t;return s=s.replace(/<system-reminder>[\s\S]*?<\/system-reminder>/g,""),s=s.replace(/<file path="[^"]*">[\s\S]*?<\/file>/g,""),s=s.replace(/<attached_files>[\s\S]*?<\/attached_files>/g,""),s=s.trim(),s}function Ot(t){if(typeof t=="string")return{text:be(t),images:[]};const s=t.filter(a=>a.type==="text").map(a=>a.text).join(`
|
|
3
|
+
`),r=t.filter(a=>a.type==="image_url").map(a=>a.image_url.url);return{text:be(s),images:r}}function ce(t){return typeof t=="string"?t:t.filter(s=>s.type==="text").map(s=>s.text).join(`
|
|
4
|
+
`)}function Ut(t){const s=t.agentContent;return s?Ve(s):ce(t.content)}function ge({content:t,syntaxHighlight:s=!0}){return e.jsx(f.Suspense,{fallback:e.jsx("pre",{className:"text-[14px] text-[hsl(var(--deck-ink))] font-mono whitespace-pre-wrap",children:t}),children:e.jsx(_t,{content:t,syntaxHighlight:s})})}function de({status:t}){if(!t)return null;const s={running:"bg-[#FEF3C7] text-[#92400E] dark:bg-[#F59E0B]/20 dark:text-[#FBBF24]",success:"bg-[#DCFCE7] text-[#15803D] dark:bg-[#22C55E]/20 dark:text-[#22C55E]",error:"bg-[#FEE2E2] text-[#b91c1c] dark:bg-[#EF4444]/20 dark:text-[#fca5a5]",pending:"bg-[#E5E7EB] text-[#6B7280] dark:bg-[#27272a] dark:text-[#a1a1aa]",info:"bg-[#DBEAFE] text-[#1D4ED8] dark:bg-[#3B82F6]/20 dark:text-[#60A5FA]"},r={running:"Running",success:"Success",error:"Error",pending:"Pending",info:"Info"};return e.jsx("span",{className:A("text-[11px] px-2 py-0.5 rounded-full font-mono",s[t]),children:r[t]})}function Ht(t){if(!t)return"";if(typeof t=="string")try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}return JSON.stringify(t,null,2)}function Kt({tool:t}){const[s,r]=f.useState(!1),a=Ht(t.arguments);return e.jsxs("div",{className:"bg-white dark:bg-[#18181b] border border-[hsl(var(--deck-border))] rounded-lg overflow-hidden",children:[e.jsxs("button",{type:"button","aria-expanded":s,"data-tool-call-id":t.toolCallId,onClick:()=>r(c=>!c),className:"w-full flex items-center justify-between px-3 py-2 bg-[hsl(var(--deck-surface-2))] hover:bg-[hsl(var(--deck-surface))] transition-colors",children:[e.jsxs("div",{className:"flex gap-2 items-center min-w-0",children:[s?e.jsx(ee,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))] shrink-0"}):e.jsx(oe,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))] shrink-0"}),e.jsx("span",{className:"text-[12px] text-[hsl(var(--deck-ink))] font-mono shrink-0",children:t.toolName}),t.summary&&e.jsx("span",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono truncate",children:t.summary})]}),e.jsx(de,{status:t.status})]}),t.status==="running"&&t.progressMessage&&e.jsxs("div",{className:"border-t border-[hsl(var(--deck-border))] px-3 py-2 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 font-mono text-[10px] text-[hsl(var(--deck-ink-muted))]",children:[e.jsx("span",{className:"truncate",children:t.progressMessage}),t.progressTotal!==void 0&&t.progress!==void 0&&e.jsxs("span",{className:"shrink-0",children:[Math.max(0,Math.min(100,Math.round(t.progress/t.progressTotal*100))),"%"]})]}),t.progressTotal!==void 0&&t.progress!==void 0&&e.jsx("div",{role:"progressbar","aria-label":`${t.toolName} progress`,"aria-valuemin":0,"aria-valuemax":t.progressTotal,"aria-valuenow":Math.min(t.progress,t.progressTotal),className:"h-1 overflow-hidden rounded-full bg-[hsl(var(--deck-border))]",children:e.jsx("div",{className:"h-full rounded-full bg-amber-500 transition-[width] duration-150",style:{width:`${Math.max(0,Math.min(100,t.progress/t.progressTotal*100))}%`}})})]}),s&&e.jsxs("div",{className:"px-3 py-2 space-y-2 border-t border-[hsl(var(--deck-border))]",children:[a&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono",children:"Arguments"}),e.jsx("pre",{className:"text-[11px] text-[hsl(var(--deck-ink))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[120px] overflow-y-auto",children:a})]}),t.output&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono",children:"Output"}),e.jsx("pre",{className:"text-[11px] text-[hsl(var(--deck-ink))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[120px] overflow-y-auto",children:t.output.length>500?t.output.slice(0,500)+"...":t.output})]})]})]})}function Me({toolCalls:t}){return t.length===0?null:e.jsx("div",{className:"space-y-2",children:t.map(s=>e.jsx(Kt,{tool:s},s.toolCallId))})}function qt({toolCalls:t,toolCallIds:s}){const r=D(),[a,c]=f.useState(!1),n=f.useMemo(()=>new Map(t.map(i=>[i.toolCallId,i])),[t]),u=s.flatMap(i=>{const p=n.get(i);return p?[p]:[]});if(u.length===0)return null;const b=u.filter(i=>i.status==="running").length,l=u.filter(i=>i.status==="error").length,o=[...u].reverse().find(i=>i.status==="running"&&!!i.progressMessage),v=b>0?r(u.length===1?"chat.timeline.tools.runningOne":"chat.timeline.tools.running",{count:u.length}):l>0?r(u.length===1?"chat.timeline.tools.completedOneWithError":"chat.timeline.tools.completedWithErrors",{count:u.length,errors:l}):r(u.length===1?"chat.timeline.tools.completedOne":"chat.timeline.tools.completed",{count:u.length});return e.jsxs("div",{"data-agent-tool-group":!0,className:"py-0.5",children:[e.jsxs("button",{type:"button","aria-expanded":a,onClick:()=>c(i=>!i),className:"group flex min-h-7 w-full items-center gap-1.5 rounded-md px-1.5 text-left font-mono text-[11.5px] text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-surface))]/65 hover:text-[hsl(var(--deck-ink-muted))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:[a?e.jsx(ee,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(oe,{className:"h-3.5 w-3.5 shrink-0"}),b>0&&e.jsx(F,{className:"h-3 w-3 shrink-0 animate-spin text-[hsl(var(--deck-accent))]"}),e.jsx("span",{children:v}),(o==null?void 0:o.progressMessage)&&e.jsxs("span",{className:"min-w-0 truncate text-[10.5px] text-[hsl(var(--deck-ink-muted))]",children:[o.progressMessage,o.progress!==void 0&&o.progressTotal!==void 0&&` · ${Math.max(0,Math.min(100,Math.round(o.progress/o.progressTotal*100)))}%`]})]}),(o==null?void 0:o.progress)!==void 0&&o.progressTotal!==void 0&&e.jsx("div",{role:"progressbar","aria-label":`${o.toolName} progress`,"aria-valuemin":0,"aria-valuemax":o.progressTotal,"aria-valuenow":Math.min(o.progress,o.progressTotal),className:"mx-1.5 h-0.5 overflow-hidden rounded-full bg-[hsl(var(--deck-border))]",children:e.jsx("div",{className:"h-full rounded-full bg-amber-500 transition-[width] duration-150",style:{width:`${Math.max(0,Math.min(100,o.progress/o.progressTotal*100))}%`}})}),a&&e.jsx("div",{"data-agent-tool-group-details":!0,className:"mt-2 space-y-2 pl-1",children:e.jsx(Me,{toolCalls:u})})]})}function zt({content:t}){const s=D(),[r,a]=f.useState(!1);return t?e.jsxs("div",{"data-agent-thinking":!0,className:"py-0.5",children:[e.jsxs("button",{type:"button","aria-expanded":r,onClick:()=>a(c=>!c),className:"flex min-h-7 w-full items-center gap-1.5 rounded-md px-1.5 text-left font-mono text-[11.5px] text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-surface))]/65 hover:text-[hsl(var(--deck-ink-muted))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:[r?e.jsx(ee,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))]"}):e.jsx(oe,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{children:s("chat.timeline.thinking")})]}),r&&e.jsx("div",{className:"ml-1 mt-1 border-l border-[hsl(var(--deck-border))] py-1 pl-3",children:e.jsx("pre",{className:"whitespace-pre-wrap font-mono text-[11px] leading-5 text-[hsl(var(--deck-ink-muted))]",children:t})})]}):null}function Gt({tasks:t}){if(t.length===0)return null;const s=t.filter(a=>a.status==="completed").length,r=s===t.length;return e.jsx("div",{className:"bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-lg px-3 py-2",children:e.jsx("div",{className:"flex gap-2 items-center",children:e.jsx("span",{className:"text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:r?"✓ All tasks done":`Tasks: ${s}/${t.length}`})})})}function Wt({toolCalls:t}){const s=ie(a=>a.openFilePreview),r=f.useMemo(()=>{const a=new Map,c=["Write","SearchReplace","Edit","ApplyPatch"];for(const n of t){if(n.status!=="success")continue;const u=n.metadata;if(n.toolName==="ApplyPatch"&&Array.isArray(u==null?void 0:u.changes)){for(const l of u.changes)l&&typeof l=="object"&&"path"in l&&typeof l.path=="string"&&a.set(l.path,{path:l.path,toolName:n.toolName});continue}const b=u==null?void 0:u.file_path;b&&c.includes(n.toolName)&&a.set(b,{path:b,toolName:n.toolName})}return Array.from(a.values())},[t]);return r.length===0?null:e.jsxs("div",{className:"bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-lg px-3 py-2",children:[e.jsxs("div",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono mb-1.5",children:["Changed files (",r.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:r.map(({path:a})=>{const c=a.split("/").pop()||a;return e.jsxs("button",{onClick:()=>s({tab:"diff",targetPath:a}),className:"flex items-center gap-1 px-2 py-1 text-[11px] font-mono bg-[#E5E7EB] dark:bg-[#27272a] text-[hsl(var(--deck-ink))] rounded hover:bg-[#D1D5DB] dark:hover:bg-[#3f3f46] transition-colors",title:a,children:[e.jsx(nt,{className:"w-3 h-3"}),c]},a)})})]})}function Jt({subagent:t}){var $,q;const s=D(),[r,a]=f.useState(null),[c,n]=f.useState(!1),[u,b]=f.useState(null),[l,o]=f.useState(!1),[v,i]=f.useState(""),[p,h]=f.useState(!1),[k,N]=f.useState(null),[x,C]=f.useState(null),d=y(T=>T.currentSessionRef),m=y(T=>T.isStreaming),j=y(T=>T.isTemporarySession);if(!t)return null;const S=t.status==="running",w=r!==null?r:S,R=t.toolCalls||u||[],K=t.output||t.thinking||R.length>0||t.sessionId,M=x&&x.status!=="running"?x.id:t.sessionId,U=!S&&!m&&!j&&(x==null?void 0:x.status)!=="running"&&!!(M&&d);f.useEffect(()=>{if(!w||S||!t.sessionId||!(d!=null&&d.projectPath)||u!==null||t.toolCalls&&t.toolCalls.length>0)return;let T=!0;return n(!0),O.getMessages({sessionId:t.sessionId,projectPath:d.projectPath}).then(V=>{var B,I;if(!T)return;const P=Ue(V),_=new Map;for(const L of P)if((I=(B=L.agentContent)==null?void 0:B.toolCalls)!=null&&I.length)for(const z of L.agentContent.toolCalls)_.has(z.toolCallId)||_.set(z.toolCallId,z);b(Array.from(_.values()))}).finally(()=>{T&&n(!1)}),()=>{T=!1}},[w,S,t.sessionId,t.toolCalls,u,d==null?void 0:d.projectPath]),f.useEffect(()=>{if(!t.sessionId||!d)return;let T=!0;const V=t.rootAgentId??t.sessionId,P=t.resumeDepth??0;return O.listSubagents(d).then(_=>{if(!T)return;const B=_.filter(I=>I.id!==t.sessionId&&I.rootAgentId===V&&I.resumeDepth>P).sort((I,L)=>L.resumeDepth-I.resumeDepth||L.lastActiveAt-I.lastActiveAt)[0];B&&C(B)}).catch(()=>{}),()=>{T=!1}},[d==null?void 0:d.sessionId,d==null?void 0:d.projectPath,t.sessionId,t.rootAgentId,t.resumeDepth]),f.useEffect(()=>{if(!x||x.status!=="running"||!d)return;let T=!0;const V=async()=>{try{const B=(await O.listSubagents(d)).find(I=>I.id===x.id);T&&B&&C(B)}catch{}},P=window.setInterval(()=>{V()},1e3);return()=>{T=!1,window.clearInterval(P)}},[d,x==null?void 0:x.id,x==null?void 0:x.status]);const E=async()=>{if(!(!d||!M||!v.trim()||p)){h(!0),N(null);try{const T=await O.resumeSubagent(d,M,v.trim());C(T.session),i(""),o(!1),a(!0)}catch(T){N(T instanceof Error?T.message:s("chat.subagent.resumeFailed"))}finally{h(!1)}}};return e.jsxs("div",{"data-subagent-id":t.id,className:"bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-lg px-3 py-2",children:[e.jsxs("button",{type:"button",onClick:()=>a(!w),className:"flex gap-2 justify-between items-center w-full transition-opacity cursor-pointer hover:opacity-80",children:[e.jsxs("div",{className:"flex gap-2 items-center",children:[S&&e.jsx(F,{className:"h-3 w-3 animate-spin text-[hsl(var(--deck-ink-muted))]"}),e.jsxs("span",{className:"text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:[t.type,": ",t.description]}),e.jsx(de,{status:t.status==="completed"?"success":t.status==="failed"?"error":"running"}),t.type==="verification"&&t.verificationVerdict&&e.jsx("span",{"data-verification-verdict":t.verificationVerdict,className:A("rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide",t.verificationVerdict==="pass"?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":t.verificationVerdict==="fail"?"bg-red-500/10 text-red-600 dark:text-red-400":"bg-amber-500/10 text-amber-600 dark:text-amber-400"),children:t.verificationVerdict}),t.resumedFrom&&e.jsx("span",{className:"rounded bg-[#EDE9FE] px-1.5 py-0.5 text-[10px] font-mono text-[#6D28D9] dark:bg-[#2E1065] dark:text-[#C4B5FD]",title:s("chat.subagent.resumedFromTitle",{id:t.resumedFrom}),children:s("chat.subagent.resumedDepth",{depth:t.resumeDepth??1})})]}),K&&e.jsx(ee,{className:A("h-3.5 w-3.5 text-[hsl(var(--deck-ink-muted))] transition-transform",w&&"rotate-180")})]}),w&&e.jsxs("div",{className:"mt-2 space-y-2",children:[(t.output||t.thinking)&&e.jsxs(e.Fragment,{children:[t.output&&e.jsx("pre",{className:"text-[11px] text-[hsl(var(--deck-ink))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[160px] overflow-y-auto",children:t.output}),t.thinking&&e.jsx("pre",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[120px] overflow-y-auto",children:t.thinking})]}),c&&e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono",children:[e.jsx(F,{className:"w-3 h-3 animate-spin"}),s("chat.subagent.loadingLogs")]}),!c&&R.length>0&&e.jsx(Me,{toolCalls:R}),x&&e.jsxs("div",{className:"rounded-md border border-[#DDD6FE] bg-[#F5F3FF] p-2 text-[11px] font-mono text-[#5B21B6] dark:border-[#4C1D95] dark:bg-[#1E1B4B] dark:text-[#C4B5FD]",children:[e.jsx("div",{children:s("chat.subagent.resumedAs",{id:x.id,status:x.status,depth:x.resumeDepth??1})}),((($=x.result)==null?void 0:$.message)||((q=x.result)==null?void 0:q.error))&&e.jsx("div",{className:"mt-1 whitespace-pre-wrap text-[hsl(var(--deck-ink))]",children:x.result.message||x.result.error})]}),U&&e.jsxs("div",{className:"space-y-2",children:[l?e.jsxs("div",{className:"space-y-2 rounded-md border border-[#E5E7EB] bg-white p-2 dark:border-[#27272a] dark:bg-[#111113]",children:[e.jsx("textarea",{"aria-label":s("chat.subagent.followUpAria"),value:v,onChange:T=>i(T.target.value),placeholder:s("chat.subagent.followUpPlaceholder"),rows:3,className:"w-full resize-y rounded border border-[#D1D5DB] bg-white p-2 text-[11px] text-[#111827] outline-none focus:border-[#8B5CF6] dark:border-[#3f3f46] dark:bg-[#18181b] dark:text-[#f4f4f5]"}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{type:"button",onClick:()=>{o(!1),N(null)},className:"rounded px-2 py-1 text-[11px] text-[#6B7280] hover:bg-[#F3F4F6] dark:hover:bg-[#27272a]",children:s("chat.subagent.cancel")}),e.jsxs("button",{type:"button",onClick:()=>void E(),disabled:!v.trim()||p,className:"flex items-center gap-1 rounded bg-[#7C3AED] px-2 py-1 text-[11px] font-medium text-white disabled:opacity-50",children:[p&&e.jsx(F,{className:"w-3 h-3 animate-spin"}),s("chat.subagent.resumeAgent")]})]})]}):e.jsxs("button",{type:"button","aria-label":s("chat.subagent.resumeAria"),onClick:()=>o(!0),className:"flex items-center gap-1.5 rounded-md border border-[#D1D5DB] px-2 py-1 text-[11px] font-medium text-[#374151] transition-colors hover:bg-[#F3F4F6] dark:border-[#3f3f46] dark:text-[#d4d4d8] dark:hover:bg-[#27272a]",children:[e.jsx(le,{className:"w-3 h-3"}),s("chat.subagent.resume")]}),k&&e.jsx("div",{role:"alert",className:"text-[11px] text-red-600",children:k})]})]})]})}function Qt({confirmation:t,messageId:s}){const r=D(),[a,c]=f.useState(!1),[n,u]=f.useState(null),b=y(v=>v.currentSessionRef),l=y(v=>v.setConfirmation);if(!t)return null;const o=async(v,i)=>{if(!(!b||a)){c(!0),u(null);try{await O.respondPermission(b,t.toolCallId,{approved:v,scope:i}),l(s,{...t,status:v?"approved":"denied"})}catch(p){u(p instanceof Error?p.message:r("interaction.permission.failed"))}finally{c(!1)}}};return t.status!=="pending"?null:e.jsxs("div",{"data-pending-interaction":"permission",tabIndex:-1,role:"alert",className:"space-y-3 rounded-lg border border-amber-300/70 bg-amber-50/70 p-4 outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-800/70 dark:bg-amber-950/25",children:[e.jsx("div",{className:"text-[13px] text-[hsl(var(--deck-ink))] font-mono",children:r("interaction.permission.title",{tool:t.toolName})}),e.jsx("div",{className:"text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:t.description}),t.diff&&e.jsx("pre",{className:"text-[11px] text-[hsl(var(--deck-ink))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[200px] overflow-y-auto",children:t.diff}),n&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-300/70 bg-red-50 px-2.5 py-2 font-mono text-[11px] text-red-700 dark:border-red-900/70 dark:bg-red-950/35 dark:text-red-300",children:n}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:()=>void o(!0,"once"),disabled:a,className:"min-h-8 px-3 py-1.5 text-[12px] font-mono bg-[#22C55E] text-white rounded-md hover:bg-[#16A34A] disabled:cursor-wait disabled:opacity-50",children:a?e.jsx(F,{className:"h-3.5 w-3.5 animate-spin"}):r("interaction.permission.once")}),t.allowRemember!==!1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>void o(!0,"session"),disabled:a,className:"min-h-8 px-3 py-1.5 text-[12px] font-mono bg-[#3B82F6] text-white rounded-md hover:bg-[#2563EB] disabled:cursor-wait disabled:opacity-50",children:r("interaction.permission.session")}),e.jsx("button",{type:"button",onClick:()=>void o(!0,"project"),disabled:a,className:"min-h-8 px-3 py-1.5 text-[12px] font-mono bg-[#6366F1] text-white rounded-md hover:bg-[#4F46E5] disabled:cursor-wait disabled:opacity-50",children:r("interaction.permission.project")})]}),e.jsx("button",{type:"button",onClick:()=>void o(!1),disabled:a,className:"min-h-8 px-3 py-1.5 text-[12px] font-mono bg-[#EF4444] text-white rounded-md hover:bg-[#DC2626] disabled:cursor-wait disabled:opacity-50",children:r("interaction.permission.deny")})]})]})}function Yt({question:t,messageId:s}){const r=D(),[a,c]=f.useState({}),[n,u]=f.useState({}),[b,l]=f.useState(!1),[o,v]=f.useState(null),i=y(x=>x.currentSessionRef),p=y(x=>x.setQuestion),h=f.useMemo(()=>t?t.questions.reduce((x,C)=>{var S;const d=(S=n[C.header])==null?void 0:S.trim(),m=a[C.header];if(C.multiSelect){const w=Array.isArray(m)?[...m]:[];return d&&w.push(d),w.length>0&&(x[C.header]=w),x}const j=d||(typeof m=="string"?m:"");return j&&(x[C.header]=j),x},{}):{},[a,n,t]),k=(t==null?void 0:t.questions.every(x=>x.header in h))??!1;if(!t)return null;const N=async()=>{if(!(!i||b||!k)){l(!0),v(null);try{await O.respondToQuestion(i,t.toolCallId,h),p(s,{...t,status:"answered",answers:h})}catch(x){v(x instanceof Error?x.message:r("interaction.question.failed"))}finally{l(!1)}}};return t.status!=="pending"?e.jsx("div",{className:"bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-lg px-3 py-2",children:e.jsx("div",{className:"text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:r("interaction.question.answered")})}):e.jsxs("div",{"data-pending-interaction":"question",tabIndex:-1,role:"alert",className:"space-y-4 rounded-lg border border-amber-300/70 bg-amber-50/70 p-4 outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-800/70 dark:bg-amber-950/25",children:[t.questions.map((x,C)=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-[13px] text-[hsl(var(--deck-ink))] font-mono",children:x.question}),e.jsxs("div",{className:"space-y-1",children:[x.options.map((d,m)=>e.jsxs("button",{type:"button",onClick:()=>{if(x.multiSelect){const j=a[x.header]||[],S=j.includes(d.label)?j.filter(w=>w!==d.label):[...j,d.label];c({...a,[x.header]:S})}else c({...a,[x.header]:d.label}),u({...n,[x.header]:""})},className:A("w-full text-left px-3 py-2 rounded-md border text-[12px] font-mono transition-colors","border-[hsl(var(--deck-border))]",(x.multiSelect?(a[x.header]||[]).includes(d.label):a[x.header]===d.label)?"bg-[#DCFCE7] text-[#166534] dark:bg-[#22C55E]/20 dark:text-[#E5E5E5]":"bg-[hsl(var(--deck-surface-2))] text-[hsl(var(--deck-ink-muted))]"),children:[e.jsx("div",{children:d.label}),e.jsx("div",{className:"text-[11px] text-[hsl(var(--deck-ink-faint))] mt-1",children:d.description})]},m)),e.jsx("input",{"aria-label":`${x.header} other response`,value:n[x.header]??"",onChange:d=>u({...n,[x.header]:d.target.value}),placeholder:r("interaction.question.other"),className:"w-full rounded-md border border-[#E5E7EB] bg-white px-3 py-2 text-[12px] text-[#111827] outline-none focus:border-[#22C55E] dark:border-[#27272a] dark:bg-[#111113] dark:text-[#E5E5E5]"})]})]},C)),o&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-300/70 bg-red-50 px-2.5 py-2 font-mono text-[11px] text-red-700 dark:border-red-900/70 dark:bg-red-950/35 dark:text-red-300",children:o}),e.jsxs("button",{type:"button",onClick:()=>void N(),disabled:b||!k,className:"inline-flex min-h-8 items-center gap-1.5 px-3 py-1.5 text-[12px] font-mono bg-[#22C55E] text-white rounded-md hover:bg-[#16A34A] disabled:cursor-wait disabled:opacity-50",children:[b&&e.jsx(F,{className:"h-3.5 w-3.5 animate-spin"}),r("interaction.question.submit")]})]})}function Xt({message:t}){const s=t.agentContent,r=y(k=>k.isStreaming&&k.currentAssistantMessageId===t.id);if(!s){const k=ce(t.content);return k?e.jsx(ge,{content:k}):null}const{toolCalls:a,tasks:c,confirmation:n,question:u,elicitation:b}=s,l=Le(s),o=Oe(s);if(!(o.length>0||c.length>0||l.length>0||n||u||b)&&r)return e.jsxs("div",{className:"flex items-center gap-2 text-[hsl(var(--deck-ink-muted))]",children:[e.jsx(F,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{className:"text-[12px] font-mono",children:"Thinking..."})]});const p=a.length>0&&a.every(k=>k.status==="success"||k.status==="error")&&!r,h=!r;return e.jsxs("div",{className:"space-y-3",children:[o.map(k=>k.type==="thinking"?e.jsx("div",{"data-agent-timeline-block":"thinking",children:e.jsx(zt,{content:k.content})},k.id):k.type==="text"?e.jsx("div",{"data-agent-timeline-block":"text",children:e.jsx(ge,{content:k.content,syntaxHighlight:h})},k.id):e.jsx("div",{"data-agent-timeline-block":"tool_group",children:e.jsx(qt,{toolCalls:a,toolCallIds:k.toolCallIds})},k.id)),c.length>0&&e.jsx(Gt,{tasks:c}),l.map(k=>e.jsx(Jt,{subagent:k},k.id)),n&&e.jsx(Qt,{confirmation:n,messageId:t.id}),u&&e.jsx(Yt,{question:u,messageId:t.id}),b&&e.jsx(At,{elicitation:b,messageId:t.id}),p&&e.jsx(Wt,{toolCalls:a})]})}function Zt({message:t,showAvatar:s=!0}){var b,l,o,v;const r=t.role==="user";if(t.role==="system"){const i=ce(t.content);return e.jsx("div",{"data-chat-message-id":t.id,className:"flex justify-center p-2 w-full",children:e.jsx("div",{className:"text-xs text-[hsl(var(--deck-ink-muted))] bg-[#F3F4F6] dark:bg-[#18181b] px-3 py-1 rounded-full font-mono",children:i})})}if(r){const i=(b=t.metadata)!=null&&b.userShellCommand&&typeof t.metadata.userShellCommand=="object"?t.metadata.userShellCommand:(l=t.metadata)!=null&&l.userShellExecution&&typeof t.metadata.userShellExecution=="object"?t.metadata.userShellExecution:void 0;if(i){const k=typeof i.command=="string"?i.command:"",N=i.status==="running"?"running":i.status==="completed"?"success":"error",x=typeof i.output=="string"?i.output:[typeof i.stdout=="string"?i.stdout:"",typeof i.stderr=="string"&&i.stderr?`stderr:
|
|
5
|
+
${i.stderr}`:""].filter(Boolean).join(`
|
|
6
|
+
`);return e.jsx("div",{"data-chat-message-id":t.id,"data-user-shell-command":!0,className:"flex w-full justify-end p-4",children:e.jsxs("div",{className:"w-full max-w-[85%] overflow-hidden rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-3 py-2",children:[e.jsxs("div",{className:"min-w-0 truncate font-mono text-[12px] text-[hsl(var(--deck-ink))]",children:[e.jsx("span",{className:"mr-2 text-amber-600 dark:text-amber-400",children:"$"}),k]}),e.jsx(de,{status:N})]}),e.jsx("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap px-3 py-2 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))]",children:x||"(no output)"}),typeof i.exitCode=="number"&&e.jsxs("div",{className:"border-t border-[hsl(var(--deck-border))] px-3 py-1.5 font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:["exit ",i.exitCode,typeof i.durationMs=="number"?` · ${(i.durationMs/1e3).toFixed(3)}s`:"",i.truncated===!0?" · truncated":""]})]})})}const{text:p,images:h}=Ot(t.content);return e.jsxs("div",{"data-chat-message-id":t.id,"data-chat-role":"user",className:"group flex gap-2 justify-end p-4 w-full items-start",children:[e.jsx("div",{className:"mt-1 flex shrink-0 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100",children:e.jsx(fe,{text:p,label:"Copy message"})}),e.jsxs("div",{className:"bg-[hsl(var(--deck-surface-2))] rounded-lg px-4 py-3 max-w-[85%]",children:[p&&e.jsx("p",{className:"text-[14px] text-[hsl(var(--deck-ink))] font-mono leading-relaxed whitespace-pre-wrap",children:p}),h.length>0&&e.jsx("div",{className:A("grid gap-2",h.length===1?"grid-cols-1 mt-0":"grid-cols-2 mt-3"),children:h.map((k,N)=>e.jsx("img",{src:k,alt:`attachment-${N+1}`,className:"object-cover w-full max-h-64 rounded-md"},`${k}-${N}`))})]}),e.jsx(Lt,{})]})}const c=Ut(t),n=Ct((o=t.metadata)==null?void 0:o.codeReview),u=$t((v=t.metadata)==null?void 0:v.structuredOutput);return e.jsxs("div",{"data-chat-message-id":t.id,className:A("group flex gap-4 justify-start w-full",s?"p-4":"px-4 pt-0 pb-3"),children:[s?e.jsx(Vt,{}):e.jsx("div",{className:"w-8 shrink-0"}),e.jsxs("div",{className:"overflow-hidden flex-1 min-w-0",children:[n?e.jsx(Tt,{report:n}):u?e.jsx(Pt,{report:u}):e.jsx(Xt,{message:t}),!u&&c.trim()&&e.jsx("div",{className:"mt-1.5 flex opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100",children:e.jsx(fe,{text:c,label:"Copy response"})})]})]})}const es=f.memo(Zt);function ts(t,s,r){return Math.max(0,t+(r-s))}function ss(t,s,r){return Math.min(s,Math.max(0,t)+Math.max(0,r))}function ve(t,s){return t?t.querySelector(`[data-chat-message-id="${CSS.escape(s)}"]`):null}function rs({turns:t,viewportRef:s,containerRef:r,onRevealTurn:a}){const c=D(),[n,u]=f.useState(null),[b,l]=f.useState(!1),o=f.useRef(null),v=f.useCallback(()=>{var x;const p=s.current,h=r.current;if(!p||!h||t.length===0)return;const k=p.getBoundingClientRect().top;let N=((x=t[0])==null?void 0:x.id)??null;for(const C of t){const d=ve(h,C.id);if(d)if(d.getBoundingClientRect().top-k<=24)N=C.id;else break}u(N)},[t,s,r]);f.useEffect(()=>{const p=s.current;if(!p)return;const h=()=>{o.current===null&&(o.current=window.requestAnimationFrame(()=>{o.current=null,v()}))};return v(),p.addEventListener("scroll",h,{passive:!0}),()=>{p.removeEventListener("scroll",h),o.current!==null&&(window.cancelAnimationFrame(o.current),o.current=null)}},[v,s]);const i=f.useCallback(p=>{const h=()=>{const N=ve(r.current,p.id);N&&(N.scrollIntoView({behavior:"smooth",block:"start"}),u(p.id))};a(p.index)?h():window.requestAnimationFrame(()=>window.requestAnimationFrame(h))},[r,a]);return t.length<2?null:e.jsx("nav",{"aria-label":c("chat.turns.aria"),className:"absolute right-1 top-1/2 z-20 hidden -translate-y-1/2 sm:block",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),onFocusCapture:()=>l(!0),onBlurCapture:p=>{p.currentTarget.contains(p.relatedTarget)||l(!1)},children:e.jsxs("div",{className:"relative flex items-center justify-end",children:[e.jsx("ul",{className:A("flex flex-col items-center gap-2 py-2 transition-opacity",b?"opacity-0":"opacity-100"),"aria-hidden":b,children:t.map(p=>e.jsx("li",{children:e.jsx("span",{className:A("block rounded-full transition-all",p.id===n?"h-2 w-2 bg-[hsl(var(--deck-accent))]":"h-1.5 w-1.5 bg-[hsl(var(--deck-ink-faint))]/40")})},p.id))}),e.jsx("div",{className:A("absolute right-0 max-h-[min(70vh,520px)] w-[280px] overflow-y-auto rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]/95 p-1 shadow-xl backdrop-blur transition-all",b?"pointer-events-auto translate-x-0 opacity-100":"pointer-events-none translate-x-2 opacity-0"),children:t.map((p,h)=>e.jsxs("button",{type:"button",onClick:()=>i(p),className:A("flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left transition-colors",p.id===n?"bg-[hsl(var(--deck-hairline))]/70 text-[hsl(var(--deck-ink))]":"text-[hsl(var(--deck-ink-muted))] hover:bg-[hsl(var(--deck-hairline))]/50 hover:text-[hsl(var(--deck-ink))]"),children:[e.jsx("span",{className:A("mt-1 h-1.5 w-1.5 shrink-0 rounded-full",p.id===n?"bg-[hsl(var(--deck-accent))]":"bg-[hsl(var(--deck-ink-faint))]/40")}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block font-mono text-[9.5px] uppercase tracking-[0.12em] text-[hsl(var(--deck-ink-faint))]",children:c("chat.turns.label",{n:h+1})}),e.jsx("span",{className:"line-clamp-2 text-[12px] leading-4",children:p.preview})]})]},p.id))})]})})}const ke=80;function as(t){return typeof t=="string"?t:Array.isArray(t)?t.filter(s=>s.type==="text").map(s=>s.text).join(" "):""}function ns(t){const s=as(t).replace(/\s+/g," ").trim();return s?s.length>ke?`${s.slice(0,ke-1)}…`:s:""}function is(t){const s=[];for(let r=0;r<t.length;r+=1){const a=t[r];if(a.role!=="user"||!a.id)continue;const c=ns(a.content);c&&s.push({id:a.id,index:r,preview:c})}return s}const re=120,ae=80,os=96;function G(t){return(t==null?void 0:t.querySelector("[data-radix-scroll-area-viewport]"))??null}function ls({messages:t,isLoading:s}){const r=D(),a=f.useRef(null),c=f.useRef(null),n=f.useRef(!0),u=f.useRef(t.length),b=f.useRef(null),[l,o]=f.useState(re),[v,i]=f.useState(!1);f.useEffect(()=>{const m=G(a.current);if(!m||!n.current)return;const j=window.requestAnimationFrame(()=>{m.scrollTop=m.scrollHeight});return()=>window.cancelAnimationFrame(j)},[t]),f.useEffect(()=>{const m=G(a.current);if(!m)return;c.current=m;const j=()=>{const w=m.scrollHeight-m.scrollTop-m.clientHeight<=os;n.current=w,i(!w)};return j(),m.addEventListener("scroll",j,{passive:!0}),()=>m.removeEventListener("scroll",j)},[]),f.useEffect(()=>{const m=u.current;u.current=t.length,o(j=>j>=m&&t.length>m?t.length:Math.min(Math.max(j,re),t.length||re))},[t.length]);const p=Math.max(t.length-l,0),h=p,k=f.useMemo(()=>t.slice(h),[t,h]),N=f.useMemo(()=>is(t),[t]);if(f.useLayoutEffect(()=>{var S;const m=b.current;if(!m)return;const j=G(a.current);if(b.current=null,!!j){if((S=m.element)!=null&&S.isConnected){const w=m.element.getBoundingClientRect().top-m.viewportTop;j.scrollTop+=w;return}j.scrollTop=ts(m.scrollTop,m.scrollHeight,j.scrollHeight)}},[l]),s)return e.jsx("div",{role:"status","aria-live":"polite","aria-busy":"true",className:"flex overflow-hidden flex-1 justify-center items-center px-5 py-8 min-h-0",children:e.jsxs("div",{className:"w-full max-w-[560px]",children:[e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 animate-pulse rounded-full bg-[hsl(var(--deck-accent-soft))] blur-xl"}),e.jsx(ne,{size:42,className:"relative"})]}),e.jsxs("div",{className:"mt-4 inline-flex items-center gap-1.5 font-mono text-[10px] uppercase tracking-[0.16em] text-[hsl(var(--deck-accent))]",children:[e.jsx(it,{className:"w-3 h-3"}),r("chat.list.loading.eyebrow")]}),e.jsx("h2",{className:"mt-2 text-[15px] font-medium text-[hsl(var(--deck-ink))]",children:r("chat.list.loading.title")}),e.jsx("p",{className:"mt-1 max-w-sm text-[11.5px] leading-5 text-[hsl(var(--deck-ink-faint))]",children:r("chat.list.loading.hint")})]}),e.jsx("div",{"aria-hidden":"true",className:"mt-7 space-y-4 rounded-xl border border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-surface))]/45 px-4 py-5",children:[72,88,64].map((m,j)=>e.jsxs("div",{className:A("flex gap-3",j%2===1&&"flex-row-reverse"),children:[e.jsx("span",{className:"h-7 w-7 shrink-0 animate-pulse rounded-md bg-[hsl(var(--deck-surface-2))]"}),e.jsx("span",{className:"h-10 animate-pulse rounded-lg bg-[hsl(var(--deck-surface-2))]",style:{width:`${m}%`,animationDelay:`${j*120}ms`}})]},m))})]})});if(t.length===0&&!s)return e.jsx("div",{className:"flex flex-1 justify-center items-center",children:e.jsxs("div",{className:"flex flex-col gap-4 items-center text-center",children:[e.jsx(ne,{size:44}),e.jsxs("div",{children:[e.jsx("div",{className:"deck-eyebrow text-[hsl(var(--deck-accent))]",children:r("chat.list.empty.eyebrow")}),e.jsx("div",{className:"mt-2 text-[15px] font-medium text-[hsl(var(--deck-ink))]",children:r("chat.list.empty.title")}),e.jsx("div",{className:"mt-1 max-w-xs text-[12px] text-[hsl(var(--deck-ink-muted))]",children:r("chat.list.empty.hint")})]})]})});const x=()=>{const m=G(a.current);m&&(n.current=!0,i(!1),m.scrollTo({top:m.scrollHeight,behavior:"smooth"}))},C=()=>{var j;const m=G(a.current);if(m){const S=((j=a.current)==null?void 0:j.querySelector("[data-chat-message-id]"))??null;b.current={element:S,viewportTop:(S==null?void 0:S.getBoundingClientRect().top)??0,scrollHeight:m.scrollHeight,scrollTop:m.scrollTop}}o(S=>ss(S,t.length,ae))},d=m=>m>=h?!0:(o(t.length),!1);return e.jsxs("div",{ref:a,className:"relative flex-1 min-h-0",children:[e.jsx(Ke,{className:"h-full",children:e.jsxs("div",{className:"flex flex-col px-4 pb-4 w-full md:px-6",children:[p>0&&e.jsx("div",{className:"flex justify-center py-3",children:e.jsx("button",{type:"button",onClick:C,"aria-label":r("chat.list.showEarlierWithRemaining",{count:Math.min(p,ae),remaining:p}),className:"rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-3 py-1.5 font-mono text-[12px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:border-[hsl(var(--deck-border-strong))] hover:text-[hsl(var(--deck-ink))]",children:r("chat.list.showEarlier",{count:Math.min(p,ae)})})}),k.map((m,j)=>{const S=h+j,w=S>0?t[S-1]:null,R=!w||w.role!==m.role||w.role==="user";return e.jsx(es,{message:m,showAvatar:R},m.id||`msg-${S}`)})]})}),e.jsx(rs,{turns:N,viewportRef:c,containerRef:a,onRevealTurn:d}),v&&e.jsxs("button",{type:"button",onClick:x,className:"absolute bottom-4 left-1/2 z-10 inline-flex -translate-x-1/2 items-center gap-1.5 rounded-full border border-[hsl(var(--deck-border-strong))] bg-[hsl(var(--deck-surface))]/95 px-3 py-1.5 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] shadow-lg backdrop-blur transition-colors hover:text-[hsl(var(--deck-ink))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:[e.jsx(Ae,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}),r("chat.list.jumpLatest")]})]})}const cs=f.memo(ls),Ie=gt,Be=vt,$e=kt,ue=f.forwardRef(({className:t,sideOffset:s=4,...r},a)=>e.jsx(Re,{ref:a,sideOffset:s,className:A("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",t),...r}));ue.displayName=Re.displayName;const ds={active:{labelKey:"goal.status.active",dot:"bg-[hsl(var(--deck-accent))] shadow-[0_0_6px_hsl(var(--deck-accent-glow)/0.5)]",accent:"text-[hsl(var(--deck-accent))]"},verifying:{labelKey:"goal.status.active",dot:"animate-pulse bg-sky-400",accent:"text-sky-600 dark:text-sky-300"},paused:{labelKey:"goal.status.paused",dot:"bg-amber-400",accent:"text-amber-600 dark:text-amber-300"},blocked:{labelKey:"goal.status.blocked",dot:"bg-rose-500",accent:"text-rose-600 dark:text-rose-300"},usage_limited:{labelKey:"goal.status.usageLimited",dot:"bg-orange-500",accent:"text-orange-600 dark:text-orange-300"},budget_limited:{labelKey:"goal.status.budgetLimited",dot:"bg-orange-500",accent:"text-orange-600 dark:text-orange-300"},complete:{labelKey:"goal.status.complete",dot:"bg-emerald-500",accent:"text-emerald-600 dark:text-emerald-300"}};function J(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t)}function us(t){if(t<60)return`${t}s`;const s=Math.floor(t/60),r=t%60;return r===0?`${s}m`:`${s}m ${r}s`}function ms(){var U;const t=D(),{locale:s}=qe(),r=y(E=>E.goal),a=y(E=>E.pauseGoal),c=y(E=>E.resumeGoal),n=y(E=>E.editGoal),u=y(E=>E.clearGoal),[b,l]=f.useState(!1),[o,v]=f.useState(!1),[i,p]=f.useState(""),[h,k]=f.useState(null),[N,x]=f.useState(!1);if(f.useEffect(()=>{l(!1),v(!1),p((r==null?void 0:r.objective)??""),x(!1)},[r==null?void 0:r.goalId]),!r)return null;const C=ds[r.status],d=["active","verifying","paused","blocked"].includes(r.status),m=r.status==="active"||r.status==="verifying",j=r.status==="paused"||r.status==="blocked",S=h!==null,w=async(E,$)=>{k(E);try{await $()}finally{k(null)}},R=()=>{p(r.objective),v(!0),l(!0)},K=async E=>{E.preventDefault();const $=i.trim();if(!$||$===r.objective){v(!1);return}await w("edit",()=>n($)),v(!1)},M=async()=>{await w("delete",u),x(!1)};return e.jsxs(e.Fragment,{children:[e.jsx(Ie,{delayDuration:250,children:e.jsxs("section",{"aria-label":t("goal.aria.section"),className:"mx-3 mb-1 shrink-0",children:[e.jsxs("div",{className:A("flex h-9 items-center gap-2 rounded-lg border px-3 transition-colors","border-[hsl(var(--deck-border))]/60 bg-[hsl(var(--deck-surface))]/80 backdrop-blur-sm",b&&"rounded-b-none border-b-0"),children:[r.status==="complete"?e.jsx(ot,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500"}):e.jsx(lt,{className:A("h-3.5 w-3.5 shrink-0",C.accent)}),e.jsx("span",{className:A("h-1.5 w-1.5 shrink-0 rounded-full",C.dot)}),e.jsx("span",{className:A("shrink-0 text-[10px] font-medium leading-none",C.accent),children:r.status==="verifying"?s==="zh"?"验证中":"Verifying":t(C.labelKey)}),e.jsx("span",{className:"h-3 w-px shrink-0 bg-[hsl(var(--deck-hairline))]"}),e.jsx("button",{type:"button","aria-label":t(b?"goal.action.collapse":"goal.action.expand"),className:"min-w-0 flex-1 truncate text-left text-[12px] leading-5 text-[hsl(var(--deck-ink))]/85 outline-none transition-colors hover:text-[hsl(var(--deck-ink))]",onClick:()=>l(E=>!E),"aria-expanded":b,title:r.objective,children:r.objective}),r.tokensUsed>0&&e.jsxs("span",{className:"hidden shrink-0 text-[10px] tabular-nums text-[hsl(var(--deck-ink-muted))] sm:inline",children:[J(r.tokensUsed),r.tokenBudget!==void 0&&`/${J(r.tokenBudget)}`]}),e.jsxs("div",{className:"flex shrink-0 items-center",children:[m&&e.jsx(Q,{label:t("goal.action.pause"),disabled:S,onClick:()=>void w("pause",a),children:h==="pause"?e.jsx(F,{className:"animate-spin"}):e.jsx(ct,{})}),j&&e.jsx(Q,{label:t("goal.action.resume"),disabled:S,onClick:()=>void w("resume",c),children:h==="resume"?e.jsx(F,{className:"animate-spin"}):e.jsx(dt,{})}),e.jsx(Q,{label:t(d?"goal.action.edit":"goal.action.expand"),disabled:!d&&!b,onClick:d?R:()=>l(E=>!E),children:d?e.jsx(Fe,{}):e.jsx(ut,{})}),e.jsx(Q,{label:t("goal.action.delete"),disabled:S,destructive:!0,onClick:()=>x(!0),children:e.jsx(Y,{})})]})]}),b&&e.jsx("div",{className:"rounded-b-lg border border-t-0 border-[hsl(var(--deck-border))]/60 bg-[hsl(var(--deck-surface))]/80 px-4 py-3 backdrop-blur-sm",children:o?e.jsxs("form",{onSubmit:K,children:[e.jsx("textarea",{id:"goal-objective",value:i,onChange:E=>p(E.target.value),onKeyDown:E=>{E.key==="Escape"&&v(!1)},rows:3,autoFocus:!0,className:"w-full resize-none rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-canvas))] px-3 py-2 text-[12px] leading-5 text-[hsl(var(--deck-ink))] outline-none transition-shadow focus:border-[hsl(var(--deck-accent))] focus:ring-1 focus:ring-[hsl(var(--deck-accent-glow))]"}),e.jsxs("div",{className:"mt-2 flex items-center justify-end gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>v(!1),className:"inline-flex h-7 items-center gap-1 rounded-md px-2.5 text-[11px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:bg-[hsl(var(--deck-hairline))]/60",children:[e.jsx(mt,{className:"h-3 w-3"}),t("goal.action.cancel")]}),e.jsxs("button",{type:"submit",disabled:!i.trim()||h==="edit",className:"inline-flex h-7 items-center gap-1 rounded-md bg-[hsl(var(--deck-accent))] px-2.5 text-[11px] font-medium text-white transition-colors hover:bg-[hsl(var(--deck-accent))]/90 disabled:cursor-not-allowed disabled:opacity-50",children:[h==="edit"?e.jsx(F,{className:"h-3 w-3 animate-spin"}):e.jsx(Z,{className:"h-3 w-3"}),t("goal.action.save")]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"whitespace-pre-wrap text-[12px] leading-5 text-[hsl(var(--deck-ink))]/90",children:r.objective}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1.5 text-[10px] text-[hsl(var(--deck-ink-muted))]",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(xt,{className:"h-3 w-3"}),J(r.tokensUsed),r.tokenBudget!==void 0&&` / ${J(r.tokenBudget)}`," ",t("goal.metrics.tokens")]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(ht,{className:"h-3 w-3"}),us(r.timeUsedSeconds)]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(le,{className:"h-3 w-3"}),r.continuationCount===1?t("goal.metrics.continuationOne",{n:r.continuationCount}):t("goal.metrics.continuationMany",{n:r.continuationCount})]})]}),r.completionVerification&&e.jsxs("div",{"data-goal-verification":r.completionVerification.status,className:"mt-2 rounded-md border border-sky-200/50 bg-sky-50/60 px-2.5 py-2 text-[11px] text-sky-900 dark:border-sky-400/15 dark:bg-sky-400/[0.05] dark:text-sky-100",children:[e.jsxs("p",{className:"font-mono font-medium",children:["#",r.completionVerification.attempt," ·"," ",r.completionVerification.status.toUpperCase()," ·"," ",((U=r.completionVerification.verifierSessionId)==null?void 0:U.slice(0,12))??"-"]}),r.completionVerification.summary&&e.jsx("p",{className:"mt-1 line-clamp-3 whitespace-pre-wrap opacity-80",children:r.completionVerification.summary}),r.completionVerification.evidenceSha256&&e.jsxs("p",{className:"mt-1 font-mono text-[10px] opacity-60",children:["sha256:",r.completionVerification.evidenceSha256.slice(0,12)]})]}),r.statusReason&&e.jsx("div",{className:"mt-2 rounded-md border border-amber-200/50 bg-amber-50/60 px-2.5 py-1.5 text-[11px] text-amber-800 dark:border-amber-400/15 dark:bg-amber-400/[0.05] dark:text-amber-200",children:r.statusReason})]})})]})}),e.jsx(we,{open:N,onOpenChange:x,children:e.jsxs(Ne,{className:"max-w-[400px] border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsx(Se,{children:t("goal.dialog.title")}),e.jsx(Ce,{children:t("goal.dialog.description")}),e.jsxs(Ee,{className:"mt-2",children:[e.jsx("button",{type:"button",onClick:()=>x(!1),className:"inline-flex h-8 items-center justify-center rounded-md border border-[hsl(var(--deck-border))] px-3 text-[12px] text-[hsl(var(--deck-ink))] hover:bg-[hsl(var(--deck-hairline))]/60",children:t("goal.action.cancel")}),e.jsxs("button",{type:"button",disabled:h==="delete",onClick:()=>void M(),className:"inline-flex gap-1.5 justify-center items-center px-3 h-8 text-[12px] font-medium text-white bg-rose-600 rounded-md hover:bg-rose-500 disabled:opacity-50",children:[h==="delete"&&e.jsx(F,{className:"w-3.5 h-3.5 animate-spin"}),t("goal.action.delete")]})]})]})})]})}function Q({label:t,children:s,disabled:r,destructive:a,onClick:c}){return e.jsxs(Be,{children:[e.jsx($e,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":t,disabled:r,onClick:c,className:A("flex h-6 w-6 items-center justify-center rounded-md text-[hsl(var(--deck-ink-muted))] outline-none transition-colors focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent-glow))]/50 disabled:cursor-not-allowed disabled:opacity-35 [&_svg]:h-3.5 [&_svg]:w-3.5",a?"hover:bg-rose-500/10 hover:text-rose-500":"hover:bg-[hsl(var(--deck-hairline))]/60 hover:text-[hsl(var(--deck-ink))]"),children:s})}),e.jsx(ue,{side:"top",className:"text-[10px]",children:t})]})}function xs(){const t=D(),s=y(l=>l.currentSessionRef),r=y(l=>l.sessions),a=y(l=>l.messages),c=f.useMemo(()=>{var o,v,i,p,h;const l=s?(o=ze(r,s))==null?void 0:o.pendingInteraction:void 0;if(l)return l.type;for(let k=a.length-1;k>=0;k-=1){const N=(v=a[k])==null?void 0:v.agentContent;if(((i=N==null?void 0:N.confirmation)==null?void 0:i.status)==="pending")return"permission";if(((p=N==null?void 0:N.question)==null?void 0:p.status)==="pending")return"question";if(((h=N==null?void 0:N.elicitation)==null?void 0:h.status)==="pending")return"elicitation"}return null},[s,a,r]);if(!c)return null;const n=()=>{const l=document.querySelector(`[data-pending-interaction="${c}"]`);l==null||l.scrollIntoView({block:"center",behavior:"smooth"}),window.setTimeout(()=>l==null?void 0:l.focus(),250)},u=c==="question",b=c==="elicitation";return e.jsxs("div",{role:"alert",className:"mx-3 mb-2 flex flex-wrap items-center gap-2 rounded-lg border border-amber-300/80 bg-amber-50/95 px-3 py-2 font-mono text-amber-950 shadow-sm backdrop-blur dark:border-amber-800/80 dark:bg-amber-950/90 dark:text-amber-100 sm:mx-5",children:[e.jsx(De,{className:"h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400"}),e.jsxs("div",{className:"min-w-[180px] flex-1",children:[e.jsx("div",{className:"text-[11.5px] font-semibold",children:t(u?"interaction.bar.questionTitle":b?"interaction.bar.elicitationTitle":"interaction.bar.permissionTitle")}),e.jsx("div",{className:"mt-0.5 text-[10px] leading-4 text-amber-800 dark:text-amber-300",children:t(u?"interaction.bar.questionHint":b?"interaction.bar.elicitationHint":"interaction.bar.permissionHint")})]}),e.jsxs("button",{type:"button",onClick:n,className:"inline-flex min-h-8 shrink-0 items-center gap-1.5 rounded-md border border-amber-400/80 bg-white/80 px-2.5 text-[10.5px] font-medium transition-colors hover:bg-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-700 dark:bg-amber-950/70 dark:hover:bg-amber-900",children:[e.jsx(Ae,{className:"h-3 w-3"}),t("interaction.bar.review")]})]})}const hs={running:"status.phase.running",compacting:"status.phase.compacting",switching_model:"status.phase.switchingModel",waiting_permission:"status.phase.waitingPermission",error:"status.phase.error",idle:""},je=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString();function ps(){const t=D(),s=y(o=>o.tokenUsage),r=y(o=>o.isStreaming),a=y(o=>o.agentPhase),c=hs[a]??"",n=c?t(c):"",u=s.maxContextTokens>0?Math.round(s.totalTokens/s.maxContextTokens*100):0,b=Math.min(u,100),l=u>95?"danger":u>80?"warn":"safe";return e.jsxs("div",{className:"flex items-center gap-4 border-t border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))]/70 px-5 py-2 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] backdrop-blur-sm",children:[e.jsxs("div",{className:"flex gap-3 items-center",children:[e.jsx("span",{className:"deck-eyebrow text-[hsl(var(--deck-ink-faint))]",children:t("status.context")}),e.jsxs("span",{className:"flex gap-1 items-baseline tabular-nums",children:[e.jsx("span",{className:A("text-[12px] font-medium",l==="safe"&&"text-[hsl(var(--deck-ink))]",l==="warn"&&"text-amber-600 dark:text-amber-400",l==="danger"&&"text-red-600 dark:text-red-400"),children:je(s.totalTokens)}),e.jsxs("span",{className:"text-[hsl(var(--deck-ink-faint))]",children:["/ ",je(s.maxContextTokens)]})]}),s.isDefaultMaxTokens&&e.jsx(Ie,{children:e.jsxs(Be,{children:[e.jsx($e,{asChild:!0,children:e.jsx(pt,{className:"h-3 w-3 cursor-help text-[hsl(var(--deck-ink-faint))]"})}),e.jsx(ue,{side:"top",className:"max-w-[220px]",children:e.jsx("p",{className:"text-xs",children:t("status.tokenLimitTooltip")})})]})}),e.jsxs("div",{className:"relative h-2 w-32 overflow-hidden rounded-sm border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]","aria-hidden":"true",children:[e.jsx("div",{className:A("absolute inset-y-0 left-0 transition-[width] duration-300",l==="safe"&&"bg-[hsl(var(--deck-accent))]",l==="warn"&&"bg-amber-500",l==="danger"&&"bg-red-500"),style:{width:`${b}%`}}),e.jsx("div",{className:"flex absolute inset-0 pointer-events-none",children:[25,50,75].map(o=>e.jsx("span",{className:"absolute inset-y-0 w-px bg-[hsl(var(--deck-canvas-veil))]/60",style:{left:`${o}%`}},o))})]}),e.jsxs("span",{className:A("w-10 text-right tabular-nums text-[hsl(var(--deck-ink-faint))]",l==="warn"&&"text-amber-600 dark:text-amber-400",l==="danger"&&"text-red-600 dark:text-red-400"),children:[u,"%"]})]}),e.jsx("div",{className:"flex-1"}),r&&n&&e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("span",{className:"deck-pulse-dot"}),e.jsx("span",{className:"text-[hsl(var(--deck-accent))]",children:n})]})]})}function fs(t){const s=[...t].reverse().find(c=>c.role==="user");if(!s)return null;if(typeof s.content=="string")return{content:s.content,attachments:[]};const r=s.content.filter(c=>c.type==="text").map(c=>c.text).join(`
|
|
7
|
+
`),a=s.content.filter(c=>c.type==="image_url").map((c,n)=>{var b;const u=((b=c.image_url.url.match(/^data:([^;,]+)[;,]/))==null?void 0:b[1])??"application/octet-stream";return{id:`recovery-${s.id}-${n}`,name:`attachment-${n+1}`,mimeType:u,dataUrl:c.image_url.url}});return{content:r,attachments:a}}function js(){var xe;const t=D(),s=y(g=>g.messages),r=y(g=>g.currentSessionRef),a=y(g=>g.isStreaming),c=y(g=>g.isStopping),n=y(g=>g.sessionEventConnectionState),u=y(g=>g.pendingSteeringCount),b=y(g=>g.pendingInputDelivery),l=y(g=>g.recoveredSteeringCount),o=y(g=>g.isLoading),v=y(g=>g.error),i=y(g=>g.errorContext),p=y(g=>g.sessions),h=y(g=>g.sendMessage),k=y(g=>g.abortSession),N=y(g=>g.retryTask),x=y(g=>g.retryingTaskKeys),C=ie(g=>g.openSettings),d=y(g=>g.reconnectSessionEvents),m=y(g=>g.clearError),j=y(g=>g.unsubscribeFromEvents),[S,w]=f.useState(null),R=r?p.find(g=>g.sessionId===r.sessionId&&g.projectPath===r.projectPath):void 0,K=!!v&&((i==null?void 0:i.kind)==="navigation"||!(i!=null&&i.sessionRef)||ye(i.sessionRef,r)),M=(i==null?void 0:i.failureCode)??((xe=R==null?void 0:R.taskFailure)==null?void 0:xe.code),U=(i==null?void 0:i.kind)==="execution"&&M?t(Ge(M)):v==="queue_full"?t("chat.error.queueFull"):v==="turn_unavailable"||v==="turn_active"?t("chat.error.turnChanged"):v,E=n==="connecting"||n==="reconnecting",$=a&&n!=="connected",q=r?`session:${W(r)}`:"session:temporary",T=f.useMemo(()=>fs(s),[s]),V=r?W(r):"temporary-session",P=!!(r&&(R!=null&&R.taskRetryAvailable)&&(!M||We(M)))&&((i==null?void 0:i.kind)==="execution"||(i==null?void 0:i.kind)==="task_action"),_=(i==null?void 0:i.kind)==="execution"&&(M==="authentication"||M==="permission"||M==="model_unavailable"),B=r?x.includes(W(r)):!1;f.useEffect(()=>()=>{j()},[j]),f.useEffect(()=>{w(null)},[V]);const I=async g=>h({content:g.content,modelId:g.modelId,reasoningEffort:g.reasoningEffort,serviceTier:g.serviceTier,responseVerbosity:g.responseVerbosity,communicationStyle:g.communicationStyle,...g.outputSchema?{outputSchema:g.outputSchema}:{},attachments:g.attachments.map(se=>({type:"image",content:se.dataUrl,mimeType:se.mimeType,name:se.name}))}),L=()=>k(),z=async()=>{if(_){m(),C("models");return}if(P&&r){m(),await N(r).catch(()=>{});return}if((i==null?void 0:i.kind)==="execution"&&T){w({...T,revision:Date.now()}),m();return}m(),requestAnimationFrame(()=>Qe())},me=P?t(B?"chat.error.action.retryingTask":"chat.error.action.retryTask"):_?t("chat.error.action.checkModels"):(i==null?void 0:i.kind)==="execution"&&T?t("chat.error.action.editResend"):(i==null?void 0:i.kind)==="submission"?t("chat.error.action.returnDraft"):null;return e.jsxs("div",{className:"flex h-full flex-col bg-[hsl(var(--deck-canvas))]",children:[K&&e.jsxs("div",{role:"alert",className:"flex min-h-11 flex-wrap items-center gap-2 border-b border-red-200/60 bg-red-50/80 px-4 py-2 font-mono text-[11px] text-red-700 dark:border-red-900/50 dark:bg-red-950/30 dark:text-red-300 sm:px-5",children:[e.jsx(De,{className:"h-3.5 w-3.5 shrink-0"}),e.jsxs("span",{className:"min-w-0 flex-1 break-words",children:[e.jsx("span",{className:"font-semibold",children:t((i==null?void 0:i.kind)==="submission"?"chat.error.title.submission":(i==null?void 0:i.kind)==="execution"?"chat.error.title.execution":(i==null?void 0:i.kind)==="navigation"?"chat.error.title.navigation":"chat.error.title.generic")})," ",U]}),me&&e.jsxs("button",{type:"button",onClick:()=>void z(),disabled:B,className:"inline-flex min-h-7 shrink-0 items-center gap-1.5 rounded-md border border-red-300/70 bg-white/65 px-2.5 font-medium transition-colors hover:bg-white focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-red-500 disabled:cursor-wait disabled:opacity-60 dark:border-red-800 dark:bg-red-950/45 dark:hover:bg-red-900/60",children:[P?B?e.jsx(F,{className:"h-3 w-3 animate-spin"}):e.jsx(le,{className:"h-3 w-3"}):e.jsx(Fe,{className:"h-3 w-3"}),me]}),e.jsx("button",{type:"button",onClick:m,"aria-label":t("chat.error.dismiss"),className:"p-1 text-red-500 rounded transition-colors hover:bg-red-100/60 hover:text-red-700 dark:hover:bg-red-950/60 dark:hover:text-red-100",children:"✕"})]}),(E||n==="offline")&&e.jsxs("div",{role:n==="offline"?"alert":"status","aria-live":"polite",className:"flex min-h-10 flex-wrap items-center gap-2 border-b border-amber-300/60 bg-amber-50/80 px-4 py-2 font-mono text-[11px] text-amber-900 dark:border-amber-800/60 dark:bg-amber-950/35 dark:text-amber-200 sm:px-5",children:[E?e.jsx(F,{className:"h-3.5 w-3.5 shrink-0 animate-spin"}):e.jsx(ft,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1",children:t(E?"chat.connection.reconnecting":"chat.connection.offline")}),n==="offline"&&e.jsxs("button",{type:"button",onClick:()=>void d().catch(()=>{}),className:"inline-flex min-h-7 items-center gap-1.5 rounded-md border border-amber-400/70 bg-white/60 px-2.5 font-medium transition-colors hover:bg-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-700 dark:bg-amber-950/50 dark:hover:bg-amber-900/50",children:[e.jsx(bt,{className:"h-3 w-3"}),t("chat.connection.retry")]})]}),e.jsx(jt,{}),e.jsx(cs,{messages:s,isLoading:o},r?W(r):"temporary-session"),e.jsx(xs,{}),e.jsx(ms,{}),e.jsx(Je,{draftKey:q,draft:S==null?void 0:S.content,draftAttachments:S==null?void 0:S.attachments,draftRevision:S==null?void 0:S.revision,onSend:I,onAbort:L,disabled:o||$,isStreaming:a,isStopping:c,pendingSteeringCount:u,pendingInputDelivery:b,recoveredSteeringCount:l,workspacePath:r==null?void 0:r.projectPath},q),e.jsx(ps,{})]})}export{js as ChatView};
|
package/dist/web/assets/{CodeBlockHighlighter-7DiEw-B3.js → CodeBlockHighlighter-Cf3DBUGk.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as I,j as Ke}from"./vendor-react-DG5dkZ_t.js";import{f as Ve,p as Se,a as xe,n as Ae,h as Je,s as Qe,d as Ne}from"./MarkdownRenderer-
|
|
1
|
+
import{c as I,j as Ke}from"./vendor-react-DG5dkZ_t.js";import{f as Ve,p as Se,a as xe,n as Ae,h as Je,s as Qe,d as Ne}from"./MarkdownRenderer-CkSbe36j.js";import"./index-DWtXGF3o.js";import"./vendor-radix-DXRuAJHH.js";import"./vendor-icons-ICv1v-tf.js";function Pe(e,t){if(e==null)return{};var n={};for(var a in e)if({}.hasOwnProperty.call(e,a)){if(t.indexOf(a)!==-1)continue;n[a]=e[a]}return n}function et(e,t){if(e==null)return{};var n,a,o=Pe(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a<r.length;a++)n=r[a],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function se(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,a=Array(t);n<t;n++)a[n]=e[n];return a}function tt(e){if(Array.isArray(e))return se(e)}function nt(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function at(e,t){if(e){if(typeof e=="string")return se(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?se(e,t):void 0}}function ot(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
2
2
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function le(e){return tt(e)||nt(e)||at(e)||ot()}function Z(e){"@babel/helpers - typeof";return Z=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Z(e)}function rt(e,t){if(Z(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var a=n.call(e,t);if(Z(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function it(e){var t=rt(e,"string");return Z(t)=="symbol"?t:t+""}function Te(e,t,n){return(t=it(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ce(){return ce=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)({}).hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},ce.apply(null,arguments)}function Ee(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,a)}return n}function H(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Ee(Object(n),!0).forEach(function(a){Te(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ee(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}function st(e){var t=e.length;if(t===0||t===1)return e;if(t===2)return[e[0],e[1],"".concat(e[0],".").concat(e[1]),"".concat(e[1],".").concat(e[0])];if(t===3)return[e[0],e[1],e[2],"".concat(e[0],".").concat(e[1]),"".concat(e[0],".").concat(e[2]),"".concat(e[1],".").concat(e[0]),"".concat(e[1],".").concat(e[2]),"".concat(e[2],".").concat(e[0]),"".concat(e[2],".").concat(e[1]),"".concat(e[0],".").concat(e[1],".").concat(e[2]),"".concat(e[0],".").concat(e[2],".").concat(e[1]),"".concat(e[1],".").concat(e[0],".").concat(e[2]),"".concat(e[1],".").concat(e[2],".").concat(e[0]),"".concat(e[2],".").concat(e[0],".").concat(e[1]),"".concat(e[2],".").concat(e[1],".").concat(e[0])];if(t>=4)return[e[0],e[1],e[2],e[3],"".concat(e[0],".").concat(e[1]),"".concat(e[0],".").concat(e[2]),"".concat(e[0],".").concat(e[3]),"".concat(e[1],".").concat(e[0]),"".concat(e[1],".").concat(e[2]),"".concat(e[1],".").concat(e[3]),"".concat(e[2],".").concat(e[0]),"".concat(e[2],".").concat(e[1]),"".concat(e[2],".").concat(e[3]),"".concat(e[3],".").concat(e[0]),"".concat(e[3],".").concat(e[1]),"".concat(e[3],".").concat(e[2]),"".concat(e[0],".").concat(e[1],".").concat(e[2]),"".concat(e[0],".").concat(e[1],".").concat(e[3]),"".concat(e[0],".").concat(e[2],".").concat(e[1]),"".concat(e[0],".").concat(e[2],".").concat(e[3]),"".concat(e[0],".").concat(e[3],".").concat(e[1]),"".concat(e[0],".").concat(e[3],".").concat(e[2]),"".concat(e[1],".").concat(e[0],".").concat(e[2]),"".concat(e[1],".").concat(e[0],".").concat(e[3]),"".concat(e[1],".").concat(e[2],".").concat(e[0]),"".concat(e[1],".").concat(e[2],".").concat(e[3]),"".concat(e[1],".").concat(e[3],".").concat(e[0]),"".concat(e[1],".").concat(e[3],".").concat(e[2]),"".concat(e[2],".").concat(e[0],".").concat(e[1]),"".concat(e[2],".").concat(e[0],".").concat(e[3]),"".concat(e[2],".").concat(e[1],".").concat(e[0]),"".concat(e[2],".").concat(e[1],".").concat(e[3]),"".concat(e[2],".").concat(e[3],".").concat(e[0]),"".concat(e[2],".").concat(e[3],".").concat(e[1]),"".concat(e[3],".").concat(e[0],".").concat(e[1]),"".concat(e[3],".").concat(e[0],".").concat(e[2]),"".concat(e[3],".").concat(e[1],".").concat(e[0]),"".concat(e[3],".").concat(e[1],".").concat(e[2]),"".concat(e[3],".").concat(e[2],".").concat(e[0]),"".concat(e[3],".").concat(e[2],".").concat(e[1]),"".concat(e[0],".").concat(e[1],".").concat(e[2],".").concat(e[3]),"".concat(e[0],".").concat(e[1],".").concat(e[3],".").concat(e[2]),"".concat(e[0],".").concat(e[2],".").concat(e[1],".").concat(e[3]),"".concat(e[0],".").concat(e[2],".").concat(e[3],".").concat(e[1]),"".concat(e[0],".").concat(e[3],".").concat(e[1],".").concat(e[2]),"".concat(e[0],".").concat(e[3],".").concat(e[2],".").concat(e[1]),"".concat(e[1],".").concat(e[0],".").concat(e[2],".").concat(e[3]),"".concat(e[1],".").concat(e[0],".").concat(e[3],".").concat(e[2]),"".concat(e[1],".").concat(e[2],".").concat(e[0],".").concat(e[3]),"".concat(e[1],".").concat(e[2],".").concat(e[3],".").concat(e[0]),"".concat(e[1],".").concat(e[3],".").concat(e[0],".").concat(e[2]),"".concat(e[1],".").concat(e[3],".").concat(e[2],".").concat(e[0]),"".concat(e[2],".").concat(e[0],".").concat(e[1],".").concat(e[3]),"".concat(e[2],".").concat(e[0],".").concat(e[3],".").concat(e[1]),"".concat(e[2],".").concat(e[1],".").concat(e[0],".").concat(e[3]),"".concat(e[2],".").concat(e[1],".").concat(e[3],".").concat(e[0]),"".concat(e[2],".").concat(e[3],".").concat(e[0],".").concat(e[1]),"".concat(e[2],".").concat(e[3],".").concat(e[1],".").concat(e[0]),"".concat(e[3],".").concat(e[0],".").concat(e[1],".").concat(e[2]),"".concat(e[3],".").concat(e[0],".").concat(e[2],".").concat(e[1]),"".concat(e[3],".").concat(e[1],".").concat(e[0],".").concat(e[2]),"".concat(e[3],".").concat(e[1],".").concat(e[2],".").concat(e[0]),"".concat(e[3],".").concat(e[2],".").concat(e[0],".").concat(e[1]),"".concat(e[3],".").concat(e[2],".").concat(e[1],".").concat(e[0])]}var ie={};function lt(e){if(e.length===0||e.length===1)return e;var t=e.join(".");return ie[t]||(ie[t]=st(e)),ie[t]}function ct(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0,a=e.filter(function(r){return r!=="token"}),o=lt(a);return o.reduce(function(r,s){return H(H({},r),n[s])},t)}function Fe(e){return e.join(" ")}function ut(e,t){var n=0;return function(a){return n+=1,a.map(function(o,r){return Ie({node:o,stylesheet:e,useInlineStyles:t,key:"code-segment-".concat(n,"-").concat(r)})})}}function Ie(e){var t=e.node,n=e.stylesheet,a=e.style,o=a===void 0?{}:a,r=e.useInlineStyles,s=e.key,i=t.properties,c=t.type,l=t.tagName,u=t.value;if(c==="text")return u;if(l){var g=ut(n,r),d;if(!r)d=H(H({},i),{},{className:Fe(i.className)});else{var p=Object.keys(n).reduce(function(b,w){return w.split(".").forEach(function(N){b.includes(N)||b.push(N)}),b},[]),f=i.className&&i.className.includes("token")?["token"]:[],v=i.className&&f.concat(i.className.filter(function(b){return!p.includes(b)}));d=H(H({},i),{},{className:Fe(v)||void 0,style:ct(i.className,Object.assign({},i.style,o),n)})}var y=g(t.children);return I.createElement(l,ce({key:s},d),y)}}const dt=function(e,t){var n=e.listLanguages();return n.indexOf(t)!==-1};var gt=["language","children","style","customStyle","codeTagProps","useInlineStyles","showLineNumbers","showInlineLineNumbers","startingLineNumber","lineNumberContainerStyle","lineNumberStyle","wrapLines","wrapLongLines","lineProps","renderer","PreTag","CodeTag","code","astGenerator"];function $e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,a)}return n}function R(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?$e(Object(n),!0).forEach(function(a){Te(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):$e(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}var pt=/\n/g;function ft(e){return e.match(pt)}function ht(e){var t=e.lines,n=e.startingLineNumber,a=e.style;return t.map(function(o,r){var s=r+n;return I.createElement("span",{key:"line-".concat(r),className:"react-syntax-highlighter-line-number",style:typeof a=="function"?a(s):a},"".concat(s,`
|
|
3
3
|
`))})}function bt(e){var t=e.codeString,n=e.codeStyle,a=e.containerStyle,o=a===void 0?{float:"left",paddingRight:"10px"}:a,r=e.numberStyle,s=r===void 0?{}:r,i=e.startingLineNumber;return I.createElement("code",{style:Object.assign({},n,o)},ht({lines:t.replace(/\n$/,"").split(`
|
|
4
4
|
`),style:s,startingLineNumber:i}))}function mt(e){return"".concat(e.toString().length,".25em")}function Re(e,t){return{type:"element",tagName:"span",properties:{key:"line-number--".concat(e),className:["comment","linenumber","react-syntax-highlighter-line-number"],style:t},children:[{type:"text",value:e}]}}function De(e,t,n){var a={display:"inline-block",minWidth:mt(n),paddingRight:"1em",textAlign:"right",userSelect:"none"},o=typeof e=="function"?e(t):e,r=R(R({},a),o);return r}function J(e){var t=e.children,n=e.lineNumber,a=e.lineNumberStyle,o=e.largestLineNumber,r=e.showInlineLineNumbers,s=e.lineProps,i=s===void 0?{}:s,c=e.className,l=c===void 0?[]:c,u=e.showLineNumbers,g=e.wrapLongLines,d=e.wrapLines,p=d===void 0?!1:d,f=p?R({},typeof i=="function"?i(n):i):{};if(f.className=f.className?[].concat(le(f.className.trim().split(/\s+/)),le(l)):l,n&&r){var v=De(a,n,o);t.unshift(Re(n,v))}return g&u&&(f.style=R({display:"flex"},f.style)),{type:"element",tagName:"span",properties:f,children:t}}function ze(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];e.length===void 0&&(e=[e]);for(var a=0;a<e.length;a++){var o=e[a];if(o.type==="text")n.push(J({children:[o],className:le(new Set(t))}));else if(o.children){var r,s=t.concat(((r=o.properties)===null||r===void 0?void 0:r.className)||[]);ze(o.children,s).forEach(function(i){return n.push(i)})}}return n}function yt(e,t,n,a,o,r,s,i,c){var l,u=ze(e.value),g=[],d=-1,p=0;function f(S,k){var x=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];return J({children:S,lineNumber:k,lineNumberStyle:i,largestLineNumber:s,showInlineLineNumbers:o,lineProps:n,className:x,showLineNumbers:a,wrapLongLines:c,wrapLines:t})}function v(S,k){if(a&&k&&o){var x=De(i,k,s);S.unshift(Re(k,x))}return S}function y(S,k){var x=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];return t||x.length>0?f(S,k,x):v(S,k)}for(var b=function(){var k=u[p],x=k.children[0].value,E=ft(x);if(E){var j=x.split(`
|