blade-code 0.10.131 → 0.10.133
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-7n268v68.js → chunk-00zazdct.js} +2 -2
- package/dist/chunk-04yas0t8.js +1 -0
- package/dist/{chunk-a7gyy1wb.js → chunk-0ap8b3sw.js} +1 -1
- package/dist/{chunk-tkydv9k8.js → chunk-0d440hhe.js} +1 -1
- package/dist/{chunk-hrjjhm84.js → chunk-0xph7bhe.js} +2 -2
- package/dist/{chunk-aaxc81jc.js → chunk-1tfjaazq.js} +1 -1
- package/dist/{chunk-v52wc8yg.js → chunk-2242dshn.js} +1 -1
- package/dist/{chunk-p00f53yq.js → chunk-2nv0kg12.js} +1 -1
- package/dist/chunk-2nxev7f2.js +1 -0
- package/dist/{chunk-6p6ts4kv.js → chunk-2qyh6qhb.js} +1 -1
- package/dist/{chunk-jkfkyedn.js → chunk-3csj18f1.js} +1 -1
- package/dist/{chunk-z03dtyh6.js → chunk-3ndwbb7h.js} +1 -1
- package/dist/chunk-43a0n5rw.js +1 -0
- package/dist/{chunk-853cgxwv.js → chunk-4xhawy0e.js} +1 -1
- package/dist/{chunk-c1w7e6c2.js → chunk-555ffyze.js} +1 -1
- package/dist/{chunk-sfe4810k.js → chunk-5x3h9ak8.js} +1 -1
- package/dist/{chunk-sj1dzeta.js → chunk-679b7s58.js} +1 -1
- package/dist/chunk-78wwep9f.js +1 -0
- package/dist/{chunk-7wbah1y5.js → chunk-7hxyxv4x.js} +2 -2
- package/dist/{chunk-edtxcqxa.js → chunk-7j628q12.js} +1 -1
- package/dist/chunk-7zvwfz85.js +2 -0
- package/dist/{chunk-mvm1rzc4.js → chunk-87ycd3f8.js} +2 -2
- package/dist/{chunk-9ph0t3h8.js → chunk-88jmtcv7.js} +2 -2
- package/dist/{chunk-2y1qngw7.js → chunk-8xem2mzy.js} +1 -1
- package/dist/{chunk-zwjrensv.js → chunk-961nemng.js} +1 -1
- package/dist/{chunk-ar5np5h5.js → chunk-ar3sdj0w.js} +2 -2
- package/dist/chunk-avf9spct.js +1 -0
- package/dist/chunk-azv25dg2.js +10 -0
- package/dist/chunk-b8c1vj8c.js +1 -0
- package/dist/chunk-bbw6s542.js +1 -0
- package/dist/{chunk-44jtpg8y.js → chunk-be2csw9m.js} +1 -1
- package/dist/{chunk-tndrbmk1.js → chunk-bj8cgfbr.js} +1 -1
- package/dist/{chunk-c3qmbrjj.js → chunk-bzp08nf6.js} +1 -1
- package/dist/{chunk-a60cmnmz.js → chunk-cfamqqgv.js} +2 -2
- package/dist/{chunk-637yvyry.js → chunk-cz9mqkn2.js} +1 -1
- package/dist/{chunk-gmqpfm52.js → chunk-d881py5y.js} +2 -2
- package/dist/chunk-dnt4c3gy.js +2 -0
- package/dist/{chunk-g59kv3v3.js → chunk-e1q1hvty.js} +1 -1
- package/dist/chunk-eetva9y8.js +1 -0
- package/dist/{chunk-dnsb80qt.js → chunk-f1wnva76.js} +3 -3
- package/dist/{chunk-g0ra6hge.js → chunk-f4pn5tmr.js} +1 -1
- package/dist/{chunk-pj69j4zp.js → chunk-fjvt9mwv.js} +1 -1
- package/dist/{chunk-dw22ns89.js → chunk-gv24cgpb.js} +3 -3
- package/dist/{chunk-gfbkrk60.js → chunk-h123tjsg.js} +35 -35
- package/dist/{chunk-grhsv55v.js → chunk-h6tr3zz7.js} +1 -1
- package/dist/{chunk-rwnfvbdh.js → chunk-jy61b0v8.js} +2 -2
- package/dist/chunk-kjjpn49y.js +1 -0
- package/dist/{chunk-h9wzvtmy.js → chunk-ks67gd2j.js} +1 -1
- package/dist/chunk-kx61g7xw.js +1 -0
- package/dist/chunk-m30sbsnw.js +1 -0
- package/dist/{chunk-wj44fpe7.js → chunk-mkvqtawj.js} +2 -2
- package/dist/{chunk-5nssnxbd.js → chunk-ms360ds6.js} +2 -2
- package/dist/chunk-n589jxsm.js +1 -0
- package/dist/{chunk-dbddc52r.js → chunk-n7pydthh.js} +2 -2
- package/dist/{chunk-9gs4eqt8.js → chunk-ndgdf5jx.js} +1 -1
- package/dist/{chunk-93x9xbew.js → chunk-nfdfthhb.js} +1 -1
- package/dist/chunk-nry7d26k.js +2 -0
- package/dist/{chunk-25wwj0qb.js → chunk-nyk5q71k.js} +1 -1
- package/dist/{chunk-580dwa0h.js → chunk-p8y5kk56.js} +1 -1
- package/dist/{chunk-xdf4m44y.js → chunk-py92cy57.js} +1 -1
- package/dist/{chunk-mdew58v9.js → chunk-r4bgsfj6.js} +1 -1
- package/dist/{chunk-dfjmvj3d.js → chunk-rcthrb7h.js} +2 -2
- package/dist/{chunk-ajsw4te2.js → chunk-rkjrft19.js} +2 -2
- package/dist/{chunk-qcvxff27.js → chunk-rmm7n9n3.js} +2 -2
- package/dist/chunk-sr9gqacp.js +1 -0
- package/dist/{chunk-2bnpn8be.js → chunk-sxqydew5.js} +1 -1
- package/dist/{chunk-39d95twk.js → chunk-t52v91dy.js} +1 -1
- package/dist/chunk-v7zt3pft.js +171 -0
- package/dist/{chunk-zkzhm39s.js → chunk-w3y69e4e.js} +1 -1
- package/dist/{chunk-j15db2db.js → chunk-x1w3fvhr.js} +2 -2
- package/dist/{chunk-k2e4yjsk.js → chunk-xgz1yanb.js} +1 -1
- package/dist/{chunk-g4xny949.js → chunk-yvk8w63g.js} +1 -1
- package/dist/{chunk-sx77dpxw.js → chunk-z5mm9g1y.js} +1 -1
- package/dist/web/assets/{ChatView-CkmlibKO.js → ChatView-hYd9mmJ6.js} +4 -4
- package/dist/web/assets/{CodeBlockHighlighter-DR5RLA1_.js → CodeBlockHighlighter-D0yM8QTf.js} +1 -1
- package/dist/web/assets/{FilePreview-C4tqzUOM.js → FilePreview-CaTCjV5i.js} +1 -1
- package/dist/web/assets/{KanbanBoard-D7HJQXE2.js → KanbanBoard-BY0SXCol.js} +1 -1
- package/dist/web/assets/{MarkdownRenderer-Ct8vtONO.js → MarkdownRenderer-zKto-Pty.js} +3 -3
- package/dist/web/assets/{ScrollArea-CMSE6nO4.js → ScrollArea-1qPJ8lcT.js} +1 -1
- package/dist/web/assets/{SessionHistorySurface-BPwnF9ND.js → SessionHistorySurface-Ce9xX62q.js} +1 -1
- package/dist/web/assets/{SettingsModal-KW5WYAov.js → SettingsModal-BxKOMuIm.js} +1 -1
- package/dist/web/assets/{Sidebar-8BUNEHHQ.js → Sidebar-CEF6lGps.js} +1 -1
- package/dist/web/assets/{TaskSwitcher-CZfkp2L_.js → TaskSwitcher-C-EY0nVG.js} +1 -1
- package/dist/web/assets/{TerminalPanel-DBBMaU_6.js → TerminalPanel-C3PVDyAr.js} +1 -1
- package/dist/web/assets/{archive-tBd5snSF.js → archive-D5Nuw__Q.js} +1 -1
- package/dist/web/assets/{arrow-left-Cs_sFMp-.js → arrow-left-DaOpfgEz.js} +1 -1
- package/dist/web/assets/{calendar-clock-C0ue6XTy.js → calendar-clock-DA_D4ppV.js} +1 -1
- package/dist/web/assets/{chevron-right-DZHCUfAH.js → chevron-right-COQAoZf3.js} +1 -1
- package/dist/web/assets/{chevrons-up-down-BSa16Scz.js → chevrons-up-down-B_WSFixv.js} +1 -1
- package/dist/web/assets/{clock-3-DstAM2AR.js → clock-3-DJ-pSj3t.js} +1 -1
- package/dist/web/assets/{copy-BfnFXTgG.js → copy-5c0ESKoo.js} +1 -1
- package/dist/web/assets/{download-XKyNtMnj.js → download-VkaTciEH.js} +1 -1
- package/dist/web/assets/{external-link-3bcWFMya.js → external-link-BypdqupZ.js} +1 -1
- package/dist/web/assets/{folder-D7hQLvy7.js → folder-B8znObPL.js} +1 -1
- package/dist/web/assets/{index-CCdnLriX.js → index-DorkRCqS.js} +12 -12
- package/dist/web/assets/{pause-CBR55GXy.js → pause-BWbHHYG6.js} +1 -1
- package/dist/web/assets/{pencil-8yqeFHC4.js → pencil-BPyvvR59.js} +1 -1
- package/dist/web/assets/{play-F_Spkp4p.js → play-CLJgUH4S.js} +1 -1
- package/dist/web/assets/{plus-CJCqq3rG.js → plus-D1VVvu-z.js} +1 -1
- package/dist/web/assets/{settings-G6riyt4S.js → settings-CGCgC_NX.js} +1 -1
- package/dist/web/assets/{teamService-Cixkq48S.js → teamService-DsYRmp6u.js} +1 -1
- package/dist/web/assets/{terminal-_Nebc2yj.js → terminal-pA96HZrI.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +2 -2
- package/dist/chunk-0z9nqbd0.js +0 -2
- package/dist/chunk-5nv95djf.js +0 -10
- package/dist/chunk-92fmzgzv.js +0 -1
- package/dist/chunk-9s8saznq.js +0 -1
- package/dist/chunk-af3qm97y.js +0 -1
- package/dist/chunk-cz0n951t.js +0 -1
- package/dist/chunk-f8gb685p.js +0 -2
- package/dist/chunk-kd3k1q9z.js +0 -1
- package/dist/chunk-m9mw8ppy.js +0 -1
- package/dist/chunk-ntdwkenx.js +0 -170
- package/dist/chunk-p9fs659w.js +0 -1
- package/dist/chunk-rd7b9tye.js +0 -1
- package/dist/chunk-rspcywmd.js +0 -2
- package/dist/chunk-s3f85gtm.js +0 -1
- package/dist/chunk-svkdrxk9.js +0 -1
- package/dist/chunk-v9qf59dy.js +0 -1
- package/dist/chunk-xrheg6xr.js +0 -1
- package/dist/chunk-ybwfm7yp.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{createRequire as a}from"node:module";var c=a(import.meta.url);
|
|
2
|
-
export{c as
|
|
2
|
+
export{c as sk};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Mg as A1,Ng as L0,Og as M1,Tg as v0}from"./chunk-z5mm9g1y.js";import{$g as F1,_g as SO}from"./chunk-1tfjaazq.js";import{ch as x1}from"./chunk-nfdfthhb.js";import{dh as A0,fh as J0}from"./chunk-gv24cgpb.js";import{si as z0,ti as WO,xi as b0}from"./chunk-jy61b0v8.js";import{Ji as M}from"./chunk-be2csw9m.js";import{Ki as u,Mi as L,Pi as l1}from"./chunk-679b7s58.js";import{pj as P,qj as S}from"./chunk-ar3sdj0w.js";import{Dj as c0}from"./chunk-dnt4c3gy.js";import{Kj as N}from"./chunk-rmm7n9n3.js";import{fk as qO}from"./chunk-fjvt9mwv.js";import N0 from"node:path";import YO from"node:path";import y0 from"node:fs";import W0 from"node:os";import E from"node:path";import pO from"yaml";var V1=2000,j1=50,B1=1000,X4={type:"object",properties:{verdict:{type:"string",enum:["pass","fail","partial"]},summary:{type:"string",minLength:1,maxLength:V1},findings:{type:"array",maxItems:j1,items:{type:"string",minLength:1,maxLength:B1}}},required:["verdict","summary","findings"],additionalProperties:!1};function U1(O,$){let Q=O.trim().replaceAll(/\s+/g," ");if($)Q=Q.replaceAll($,".");return Q.replace(/\bBearer\s+[^\s"'`]+/gi,"Bearer [redacted]").replace(/\bsk-[A-Za-z0-9_-]{8,}\b/g,"[redacted-key]").replace(/\b(api(?:[_-]?|\s+)key|access(?:[_-]?|\s+)token|authorization|cookie|password|passwd|refresh(?:[_-]?|\s+)token|secret|session(?:[_-]?|\s+)token)\b(\s*[:=]\s*)([^\s,;]+)/gi,"$1$2[redacted]")}function kO(O){if(O.length<=v0)return O;let $=" [verification feedback truncated]",Q=O.slice(0,v0-$.length);if(/[\uD800-\uDBFF]$/.test(Q))Q=Q.slice(0,-1);return Q.trimEnd()+$}function S1(O){if(!O||typeof O!=="object"||Array.isArray(O))return;let $=O;if($.verdict!=="pass"&&$.verdict!=="fail"&&$.verdict!=="partial"||typeof $.summary!=="string"||!$.summary.trim()||$.summary.length>V1||!Array.isArray($.findings)||$.findings.length>j1||!$.findings.every((Q)=>typeof Q==="string"&&Q.trim().length>0&&Q.length<=B1))return;return{verdict:$.verdict,summary:$.summary.trim(),findings:$.findings.map((Q)=>Q.trim())}}function H4(O,$){let Q=S1(O);if(!Q)return;let Z=U1(Q.summary,$),J=Q.findings.map((K)=>U1(K,$));return kO([Z,J.length>0?`Findings:
|
|
2
2
|
${J.map((K)=>`- ${K}`).join(`
|
|
3
3
|
`)}`:""].filter(Boolean).join(`
|
|
4
4
|
|
|
@@ -730,4 +730,4 @@ ${Z.join(`
|
|
|
730
730
|
</${Q}>`:"";return{content:K,files:[...O],references:O.map($4),triggerPaths:[...$],contentBytes:Buffer.byteLength(K,"utf8"),provenanceSha256:D0(O.map((q)=>`${q.id}:${q.contentSha256}`).join(`
|
|
731
731
|
`))}}function TO(O,$){let Q=$,Z=[];for(let J=O.length-1;J>=0;J-=1){let K=O[J];if(!K)continue;let q=Buffer.byteLength(K.content,"utf8");if(q>Q)continue;Z.push(K),Q-=q}return Z.reverse()}class m{projectRoot;catalogSha256;definitions;byId;constructor(O,$=[]){this.projectRoot=O;this.projectRoot=G1(O),this.definitions=Object.freeze([...$].sort(W1).map((Q)=>Object.freeze({...Q}))),this.byId=new Map(this.definitions.map((Q)=>[Q.id,Q])),this.catalogSha256=D0(this.definitions.map((Q)=>`${Q.id}:${Q.contentSha256}`).join(`
|
|
732
732
|
`))}static empty(O){return new m(O)}list(){return this.definitions.map((O)=>({id:O.id,relativePath:O.relativePath,source:O.source,kind:O.kind,conditional:O.conditional,contentSha256:O.contentSha256}))}snapshot(){return new m(this.projectRoot,this.definitions.map((O)=>({...O,patterns:O.patterns?[...O.patterns]:void 0})))}staticRules(O,$=l$){if(this.definitions.length===0)return q0([],[],"project-instructions");let Q=this.relativeSourcePath(O),Z=this.definitions.filter((J)=>!J.conditional&&L1(J.scopeDirectory,Q));return q0(TO(Z,$),[],"project-instructions")}contextualRules(O,$,Q,Z=s$){if(this.definitions.length===0)return q0([],[],"contextual-project-instructions");let J=this.relativeSourcePath(O),K=[...new Set($.map((G)=>Y1(z.relative(this.projectRoot,G1(G)))).filter(X1))].sort(),q=new Map;for(let G of K)for(let Y of this.definitions){if(Q.has(Y.id))continue;if(!L1(Y.scopeDirectory,G))continue;if(Y.conditional){let X=z.posix.relative(Y.scopeDirectory||".",G);if(!Y.patterns?.some((U)=>_O(U,{dot:!0})(X)))continue}else if(L1(Y.scopeDirectory,J))continue;q.set(Y.id,Y)}let W=TO([...q.values()].sort(W1),Z);return q0(W,K,"contextual-project-instructions")}hydrate(O){let $=O.map((Q)=>{let Z=this.byId.get(Q.id);if(!Z||Z.contentSha256!==Q.contentSha256||Z.relativePath!==Q.relativePath||Z.source!==Q.source)throw Error(`Project rule provenance mismatch: ${Q.relativePath}`);return Z});return q0([...new Map($.map((Q)=>[Q.id,Q])).values()].sort(W1),[],"contextual-project-instructions")}relativeSourcePath(O){let $=Y1(z.relative(this.projectRoot,G1(O)));if($&&!X1($))throw Error("Project instruction source is outside the catalog root");return $}}async function Q4(O,$){let Q=await d.lstat($);if(!Q.isFile()||Q.isSymbolicLink())throw Error("Project rule must be a regular file");if(Q.size>IO)throw Error(`Project rule exceeds ${IO} bytes`);let Z=await d.realpath($),J=Y1(z.relative(O,Z));if(!X1(J))throw Error("Project rule escapes its repository root");let K=await d.readFile(Z,"utf8");if(wO(K))throw Error("Project rule contains hidden control characters");let q=c$(K),W=q.content.trim();if(!W)throw Error("Project rule content must not be empty");let G=e$(q.data.paths),Y=O4(J),X=D0(JSON.stringify({relativePath:J,patterns:G??[],content:W}));return{id:`${Y.source}:${D0(J).slice(0,20)}`,relativePath:J,source:Y.source,kind:Y.kind,scopeDirectory:Y.scopeDirectory,priority:Y.priority,conditional:Boolean(G),...G?{patterns:G}:{},content:W,contentSha256:X}}async function DO(O,$){let Q=r$(O);if(!$.projectTrusted)return m.empty(Q);let Z=await d.realpath(Q),J=u$.stream([...a$],{cwd:Z,absolute:!0,dot:!0,deep:n$,onlyFiles:!0,followSymbolicLinks:!1,unique:!0,ignore:[...t$]}),K=[];for await(let Y of J)if(K.push(Y.toString()),K.length>MO)throw Error(`Project rule catalog exceeds ${MO} files`);K.sort();let q=new Set(K.filter((Y)=>z.basename(Y)==="AGENTS.override.md").map((Y)=>z.dirname(Y))),W=[],G=0;for(let Y of K){if(z.basename(Y)==="AGENTS.md"&&q.has(z.dirname(Y)))continue;try{let X=await Q4(Z,Y);if(G+=Buffer.byteLength(X.content,"utf8"),G>bO)throw Error(`Project rule catalog exceeds ${bO} bytes`);W.push(X)}catch(X){o$.warn(`[ProjectRules] Ignoring rule: ${X instanceof Error?X.message:String(X)}`)}}return new m(Z,W)}var CO=32,C0=64;class NO extends Error{capacity=C0;constructor(){super(`Workspace agent resource capacity is full (${C0})`);this.name="WorkspaceAgentResourceCapacityError"}}var T=new Map,H1=0,EO=[];async function Z4(O){let $=await N.getInstance().getStatus(O.workspaceRoot);O.communicationStyles=await K1(O.workspaceRoot,{projectTrusted:$.state==="trusted",plugins:O.plugins.getActive()})}function J4(O){let $={...O};for(let Q of Object.values(A0))$[Q]=(O[Q]??[]).map((Z)=>({...Z,matcher:Z.matcher?{...Z.matcher}:void 0,hooks:Z.hooks.map((J)=>({...J}))}));return $}function K5(O){EO=[...new Set(O.map(($)=>N0.resolve($)))]}function vO(O,$){HO(O,$.plugins),w.releaseInstance(O,$.subagents),h.releaseInstance({cwd:O},$.skills),x.releaseInstance(O,$.commands),C.releaseInstance(O,$.plugins)}function RO(O){vO(O.workspaceRoot,O)}function K0(){while(T.size>CO){let O=!1;for(let[$,Q]of T){if(!Q.resources||Q.users>0)continue;if(T.get($)!==Q)continue;T.delete($),RO(Q.resources),O=!0;break}if(!O)return}}function q4(O){setImmediate(()=>{O.users=Math.max(0,O.users-1),K0()}).unref?.()}async function K4(O,$){let Q=await N.getInstance().getStatus(O),Z=o(O),J=g({cwd:O}),K=x.getInstance(O),q=Q0(O);try{if(Z.getAllNames().length===0)Z.loadFromStandardLocations(Q.state==="trusted");await Promise.all([J.initialize(),K.isInitialized()?void 0:K.initialize(O),q.isInitialized()?void 0:q.initialize(O,[...$.cliPluginDirs??EO])]),x0(O),await J1(O);let W=await K1(O,{projectTrusted:Q.state==="trusted",plugins:q.getActive()}),G=await DO(O,{projectTrusted:Q.state==="trusted"});return{workspaceRoot:O,subagents:Z,skills:J,commands:K,plugins:q,communicationStyles:W,projectRules:G}}catch(W){throw vO(O,{subagents:Z,skills:J,commands:K,plugins:q}),W}}function G4(O,$){let Q={generation:H1,users:0};return Q.promise=K4(O,$).then((Z)=>{if(Q.generation!==H1||T.get(O)!==Q)return RO(Z),Z;return Q.resources=Z,K0(),Z},(Z)=>{if(T.get(O)===Q)T.delete(O);throw Z}),T.set(O,Q),Q}async function yO(O,$){let Q=N0.resolve(O),Z=T.get(Q);if(!Z){if(K0(),T.size>=C0)throw new NO;Z=G4(Q,$)}else T.delete(Q),T.set(Q,Z);Z.users++;let J;try{J=await Z.promise}catch(K){throw Z.users=Math.max(0,Z.users-1),K0(),K}return{entry:Z,resources:J}}async function fO(O,$){if(!$)return;x0(O.workspaceRoot),await J1(O.workspaceRoot),await Z4(O)}async function G5(O,$={}){let Q=await yO(O,$);try{return await fO(Q.resources,$.reconcilePlugins),Q.resources}finally{q4(Q.entry)}}async function L5(O,$,Q={}){let Z=await yO(O,Q);try{return await fO(Z.resources,Q.reconcilePlugins),await $(Z.resources)}finally{Z.entry.users=Math.max(0,Z.entry.users-1),K0()}}function W5(){let O=0,$=0;for(let Q of T.values()){if(Q.resources)O++;$+=Q.users}return{capacity:CO,activeCapacity:C0,entries:T.size,initialized:O,inFlight:T.size-O,activeUsers:$}}function Y5(O){let $="projectRoot"in O?O.projectRoot:O.workspaceRoot;return{projectRoot:N0.resolve($),subagents:O.subagents.snapshot(),skills:O.skills.snapshot(),commands:O.commands.snapshot(),communicationStyles:O.communicationStyles?.snapshot()??F1.snapshot(),projectRules:O.projectRules?.snapshot()??m.empty($),hooks:J4("hooks"in O&&O.hooks?O.hooks:J0.getInstance().getConfig($))}}function X5(O){let $=N0.resolve(O);return{projectRoot:$,subagents:new w,skills:new h,commands:x.empty($),hooks:{enabled:!1},communicationStyles:F1.snapshot(),projectRules:m.empty($)}}function H5(){H1++;for(let[O,$]of T)if($.resources)x0(O);T.clear(),w.resetInstances(),h.resetInstance(),x.resetInstance(),C.resetInstance()}
|
|
733
|
-
export{X4 as
|
|
733
|
+
export{X4 as jg,H4 as kg,F4 as lg,I1 as mg,S4 as ng,z4 as og,o as pg,f4 as qg,D1 as rg,g as sg,x as tg,e0 as ug,I0 as vg,C as wg,Q0 as xg,J1 as yg,x0 as zg,m as Ag,CO as Bg,C0 as Cg,NO as Dg,Z4 as Eg,K5 as Fg,G5 as Gg,L5 as Hg,W5 as Ig,Y5 as Jg,X5 as Kg,H5 as Lg};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{ba as p}from"./chunk-
|
|
1
|
+
import{ba as p}from"./chunk-f1wnva76.js";import{Ab as _}from"./chunk-88jmtcv7.js";import{Td as O,jd as N,kd as U,ld as I,md as A,nd as z,yd as q}from"./chunk-555ffyze.js";import{de as o}from"./chunk-h123tjsg.js";import{Pf as P}from"./chunk-r4bgsfj6.js";import{mg as e}from"./chunk-x1w3fvhr.js";import{ik as j}from"./chunk-fjvt9mwv.js";import{createHash as ff}from"node:crypto";var af=4,cf=1000,E=4000,wf=120000,M=0.2;function $f(a){try{return q(a)&&a.retryable}catch{return!1}}function gf(a,c){let f=Number.isSafeInteger(c)&&c>0?c:1,w=f-1,h=Math.min(cf*2**w,E),$=ff("sha256").update(`${a}\x00${f}`).digest().readUInt32BE(0)/4294967295,k=1-M+2*M*$;return Math.min(E,Math.max(0,Math.round(h*k)))}function Tf(a){let c=gf(a.sessionIdentity,a.failedAttempt),f=a.evidence,w=a.workStillPending===!0&&f!==void 0&&$f(f.taskFailure)&&f.outputStarted===!1&&f.toolExecutionStarted===!1&&Number.isInteger(f.toolCallsCount)&&f.toolCallsCount===0,h=Number.isSafeInteger(a.failedAttempt)&&a.failedAttempt>0&&a.failedAttempt<af,g=a.now??Date.now(),$=g-a.recoveryStartedAt,k=Number.isFinite(g)&&Number.isFinite(a.recoveryStartedAt)&&Number.isFinite($)&&$>=0&&$+c<=wf;return{phase:w?h&&k?"retry_scheduled":"exhausted":"failed",delayMs:c,retryable:w,withinAttemptBudget:h,withinTimeBudget:k}}import R from"node:path";import{nanoid as Lf}from"nanoid";import{execFile as hf}from"node:child_process";import{createHash as xf}from"node:crypto";import{lstat as bf,readFile as mf,realpath as i}from"node:fs/promises";import n from"node:path";import{promisify as kf}from"node:util";var lf=kf(hf),T=8388608,s=500,u=200;async function C(a,c){try{return(await lf("git",["-c","core.pager=cat",...c],{cwd:a,encoding:"utf8",timeout:30000,maxBuffer:T+1024,env:{...process.env,GIT_CONFIG_NOSYSTEM:"1",GIT_PAGER:"cat",GIT_OPTIONAL_LOCKS:"0"}})).stdout}catch(f){let w=f instanceof Error&&f.message.includes("maxBuffer")?`Review target exceeds the ${T} byte limit`:f instanceof Error?f.message:String(f);throw Error(`Git review target failed: ${w}`)}}function d(a,c){let f=a?.trim();if(!f||f.length>u||f.includes("\x00")||f.includes(`
|
|
2
2
|
`)||f.includes("\r"))throw Error(`${c} must contain 1-${u} characters`);return f}function Q(a){return a.split("\x00").filter(Boolean)}async function X(a,c){return(await C(a,["rev-parse","--verify",`${c}^{commit}`])).trim()}async function Ff(a,c,f,w,h){let g=h,$=await i(a);for(let k of c){let l=n.resolve($,k),x=n.relative($,l);if(!x||x.startsWith("..")||n.isAbsolute(x))throw Error(`Untracked review path escapes the workspace: ${k}`);let b=await bf(l);if(!b.isFile()||b.isSymbolicLink())throw Error(`Untracked review target must be a regular file: ${k}`);if(g+=b.size,g>T)throw Error(`Review target exceeds ${T} bytes`);f.update("\x00untracked\x00"),f.update(x.replaceAll(n.sep,"/")),f.update("\x00");let F=await mf(l);f.update(F);let m=Math.max(1,F.toString("utf8").split(`
|
|
3
3
|
`).length);w.set(x.replaceAll(n.sep,"/"),[{start:1,end:m}])}}function Y(a,c){let f=new Map,w,h,g,$,k=!1,l=(x,b)=>{let F=f.get(x)??[],m=F.at(-1);if(m&&b<=m.end+1)m.end=Math.max(m.end,b);else F.push({start:b,end:b});f.set(x,F)};for(let x of a.split(`
|
|
4
4
|
`)){if(x.startsWith("--- ")){let b=x.slice(4).split("\t")[0]?.trim();w=b&&b!=="/dev/null"?b.replace(/^a\//,"").replaceAll("\\","/"):void 0;continue}if(x.startsWith("+++ ")){let b=x.slice(4).split("\t")[0]?.trim();k=b==="/dev/null",h=k?w:b?b.replace(/^b\//,"").replaceAll("\\","/"):void 0,g=void 0,$=void 0;continue}if(x.startsWith("@@ ")){let b=/-(\d+)(?:,\d+)? \+(\d+)(?:,\d+)?/.exec(x);g=b?Math.max(1,Number(b[1])):void 0,$=b?Math.max(1,Number(b[2])):void 0;continue}if(!h||g===void 0||$===void 0)continue;if(x.startsWith("+")&&!x.startsWith("+++"))l(h,$),$++;else if(x.startsWith("-")&&!x.startsWith("---"))l(h,k?g:$),g++;else if(!x.startsWith("\\"))g++,$++}for(let x of c)if(!f.has(x))f.set(x,[{start:1,end:1}]);return f}function D(a){if(a.length>s)throw Error(`Review target exceeds the ${s} file limit`)}class K{static async resolve(a,c){let f=await i(a);await C(f,["rev-parse","--is-inside-work-tree"]);let w=await X(f,"HEAD"),h=xf("sha256");h.update(`kind\x00${c.kind}\x00head\x00${w}\x00`);let g="",$=[],k,l,x,b,F=new Map;switch(c.kind){case"uncommitted":{g=await C(f,["diff","--binary","--no-ext-diff","--relative","HEAD","--","."]);let m=Q(await C(f,["diff","--name-only","-z","--relative","HEAD","--","."])),L=Q(await C(f,["ls-files","--others","--exclude-standard","-z","--","."]));if($=[...new Set([...m,...L])].sort(),D($),$.length===0)throw Error("No uncommitted changes to review");h.update(g),F=Y(g,m),await Ff(f,L,h,F,Buffer.byteLength(g)),x="uncommitted changes",b=["Review the uncommitted working tree against HEAD.","Use git status --short, git diff --cached, and git diff, then inspect","every relevant untracked file listed by git status."].join(" ");break}case"base":{let m=d(c.ref,"Base ref");k=await X(f,m);let L=(await C(f,["merge-base",k,w])).trim();if(g=await C(f,["diff","--binary","--no-ext-diff","--relative",`${L}..${w}`,"--","."]),$=Q(await C(f,["diff","--name-only","-z","--relative",`${L}..${w}`,"--","."])),D($),$.length===0)throw Error(`No changes between ${m} and HEAD`);h.update(g),h.update(`\x00merge-base\x00${L}`),F=Y(g,$),x=`changes against ${m}`,b=`Review changes introduced by ${L}..${w}.`;break}case"commit":{let m=d(c.ref,"Commit ref");if(l=await X(f,m),g=await C(f,["show","--format=","--binary","--no-ext-diff","--relative",l,"--","."]),$=Q(await C(f,["diff-tree","--root","--no-commit-id","--name-only","-r","-z",l,"--","."])),D($),$.length===0)throw Error(`Commit has no changes in this workspace: ${m}`);h.update(g),h.update(`\x00commit\x00${l}`),F=Y(g,$),x=`commit ${m}`,b=`Review only the changes introduced by commit ${l}.`;break}}if(Buffer.byteLength(g)>T)throw Error(`Review diff exceeds ${T} bytes`);return{info:{kind:c.kind,label:x,headSha:w,...k?{baseSha:k}:{},...l?{commitSha:l}:{},digest:h.digest("hex"),fileCount:$.length},instruction:b,changedLines:F}}}var Wf=131072,t=50,Z=new Set;function v(a,c){return`${R.resolve(a)}\x00${c}`}function S(a){return`/review ${a.kind}${a.kind==="uncommitted"?"":` ${a.ref?.trim()??""}`}`}function V(a,c,f,w=!1){if(typeof a!=="string")throw Error(`${c} must be a string`);let h=a.trim();if(!w&&!h||h.length>f)throw Error(`${c} exceeds its allowed length`);return h}function Hf(a,c,f){if(!a||typeof a!=="object"||Array.isArray(a))throw Error("Review finding must be an object");let w=a,h=typeof w.line==="number"&&Number.isInteger(w.line)?w.line:void 0,g=w.code_location??(typeof w.file==="string"&&h!==void 0?{path:w.file,line_start:h,line_end:h}:void 0);if(!g||typeof g!=="object"||Array.isArray(g))throw Error("Review finding has no code_location");let $=g,k=V($.path,"Finding path",1000),l=R.posix.normalize(k.replaceAll("\\","/"));if(R.posix.isAbsolute(l)||l===".."||l.startsWith("../"))throw Error("Review finding path must be workspace-relative");let x=R.resolve(c,l),b=R.relative(R.resolve(c),x);if(b.startsWith("..")||R.isAbsolute(b))throw Error("Review finding path escapes the workspace");let F=typeof w.severity==="string"?w.severity.toLowerCase():"",m=F==="critical"?0:F==="high"?1:F==="medium"?2:F==="low"?3:void 0,L=w.priority??m;if(L!==0&&L!==1&&L!==2&&L!==3)throw Error("Review finding priority must be 0-3");let W=w.confidence_score??w.confidence??0.8;if(typeof W!=="number"||!Number.isFinite(W)||W<0||W>1)throw Error("Review finding confidence_score must be between 0 and 1");let{line_start:H,line_end:r}=$;if(!Number.isInteger(H)||!Number.isInteger(r)||H<1||r<H||r-H>=10)throw Error("Review finding line range is invalid");let G=f.changedLines.get(l);if(!G)throw Error("Review finding path is outside the review target");if(!G.some((y)=>H<=y.end&&r>=y.start))throw Error("Review finding line range does not overlap the changed lines");let B=V(w.title??`[P${L}] ${String(w.type??"Review finding").replaceAll("-"," ").replace(/\b\w/g,(y)=>y.toUpperCase())}`,"Finding title",120);if(!B.startsWith(`[P${L}] `))throw Error("Review finding title priority does not match priority");return{title:B,body:V(w.body??w.description,"Finding body",4000),priority:L,confidenceScore:W,codeLocation:{path:l,lineStart:H,lineEnd:r}}}function Rf(a,c,f){if(Buffer.byteLength(a)>Wf)throw Error("Review output exceeds the 128 KiB limit");let w=a.indexOf("{"),h=a.lastIndexOf("}");if(w<0||h<=w)throw Error("Reviewer did not return a JSON object");let g;try{g=JSON.parse(a.slice(w,h+1))}catch{throw Error("Reviewer returned invalid JSON")}if(!g||typeof g!=="object"||Array.isArray(g))throw Error("Reviewer output must be an object");let $=g;if(!Array.isArray($.findings))throw Error("Reviewer output must contain findings");if($.findings.length>t)throw Error(`Reviewer returned more than ${t} findings`);return{overallExplanation:V($.overall_explanation??$.summary,"Review explanation",1e4,!0),findings:$.findings.map((k)=>Hf(k,c,f))}}async function J(a,c){return new o(j(a,c)).readAll()}class rf{static async start(a){let{sessionId:c,projectPath:f,runtime:w,request:h,onEvent:g}=a;if(w.sessionId!==c||R.resolve(w.workspaceRoot)!==R.resolve(f))throw Error("Review runtime does not own the requested Session");if(w.hasTurnOwner())throw Error("Cannot start a review during an active turn");await O.assertSessionWritable(c,f);let $=v(f,c);if(Z.has($))throw Error("Session already has an active review");let k=await J(f,c);if(U(k))throw Error("Session has an interrupted review that must be recovered");let l=h.instructions?.trim();if(l&&l.length>4000)throw Error("Review instructions exceed 4,000 characters");let x=await K.resolve(f,h),b=Lf(16),F=P("review"),m=new Date().toISOString(),L={reviewId:b,reviewerSessionId:F,target:x.info,startedAt:m},W=new _(f);await W.saveReviewStart(c,L),await W.saveMessage(c,"user",S(h),null,{codeReview:{reviewId:b,phase:"started",targetKind:x.info.kind,targetDigest:x.info.digest}}),await O.updateSessionMetadata(c,f,{taskStatus:"running",taskStatusReason:`Reviewing ${x.info.label}`,taskPromptSummary:S(h),taskStartedAt:m,taskCompletedAt:null,taskFailure:null}),Z.add($);let H=this.execute({...a,target:x,reviewId:b,reviewerSessionId:F,instructions:l,store:W,onEvent:g}).finally(()=>{Z.delete($)});return{reviewId:b,completion:H}}static async execute(a){let{sessionId:c,projectPath:f,runtime:w,request:h,signal:g,onEvent:$,target:k,reviewId:l,reviewerSessionId:x,instructions:b,store:F}=a,m;try{let W=[k.instruction,"Bash already starts in the review workspace. Never prefix a command with cd.",`Authoritative target digest: ${k.info.digest}`,`Changed file count: ${k.info.fileCount}`,b?`Additional review instructions:
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{spawn as I}from"node:child_process";var X=500;function x(j){return new Promise((q)=>setTimeout(q,j))}function Z(j){return j&&typeof j==="object"&&"code"in j?String(j.code):void 0}function L(j){return j()||j()}function G(j,q=process.platform,y=process.kill.bind(process)){if(q==="win32"||!Number.isInteger(j)||j<=1||j===process.pid)return!1;try{return y(-j,0),!0}catch(z){let B=Z(z);if(B==="ESRCH")return!1;if(B==="EPERM")return!0;throw z}}function N(j,q){return new Promise((y)=>{let z=["/PID",String(j),"/T"];if(q)z.push("/F");let B=I("taskkill",z,{stdio:"ignore",windowsHide:!0}),K=!1,J=(H)=>{if(K)return;K=!0,y(H)};B.once("error",()=>J(!1)),B.once("close",(H)=>J(H===0))})}async function F(j,q={}){if(!Number.isInteger(j)||j<=1||j===process.pid)return{success:!1,alreadyExited:!1,forced:!1};let y=q.platform??process.platform,z=q.gracePeriodMs??X,B=q.killProcess??process.kill.bind(process),K=q.taskkill??N,J=q.wait??x,H=q.validatePidOwnership??(()=>!0);if(!L(H))return{success:!1,alreadyExited:!1,forced:!1};if(y==="win32"){let V=await K(j,!1);if(await J(z),!H())return{success:V,alreadyExited:!1,forced:!1};let Y=await K(j,!0);return{success:V||Y,alreadyExited:!V&&!Y,forced:Y}}let Q=(V,Y)=>{try{return B(V,Y)}catch(D){return Z(D)==="ESRCH"}},W=Q(-j,"SIGTERM")||Q(j,"SIGTERM");if(await J(z),!H())return{success:W,alreadyExited:!1,forced:!1};let $=Q(-j,"SIGKILL")||Q(j,"SIGKILL");return{success:W||$,alreadyExited:!1,forced:$}}async function R(j,q={}){if(!Number.isInteger(j)||j<=1||j===process.pid)return{success:!1,alreadyExited:!1,forced:!1};if((q.platform??process.platform)==="win32")return{success:!1,alreadyExited:!1,forced:!1};let z=q.gracePeriodMs??X,B=q.killProcess??process.kill.bind(process),K=q.wait??x,J=q.validatePidOwnership??(()=>!0);if(!J())return{success:!1,alreadyExited:!1,forced:!1};let H=($)=>{try{return B(-j,$),"sent"}catch(V){return Z(V)==="ESRCH"?"missing":"failed"}},Q=H("SIGTERM");if(Q==="missing")return{success:!0,alreadyExited:!0,forced:!1};if(Q==="failed")return{success:!1,alreadyExited:!1,forced:!1};if(await K(z),!J())return{success:!1,alreadyExited:!1,forced:!1};let W=H("SIGKILL");return{success:W!=="failed",alreadyExited:W==="missing",forced:W==="sent"}}class b{child;state="owned";terminationPromise;terminationResult;platform;gracePeriodMs;killProcess;taskkill;wait;constructor(j,q={}){this.child=j;if(this.platform=q.platform??process.platform,this.gracePeriodMs=q.gracePeriodMs??X,this.killProcess=q.killProcess??process.kill.bind(process),this.taskkill=q.taskkill??N,this.wait=q.wait??x,q.releaseOnExit!==!1){let y=()=>{if(this.state==="owned")this.state="released"};j.once("close",y),j.once("error",y)}}release(){if(this.state==="owned")this.state="released"}terminate(){if(this.terminationPromise)return this.terminationPromise;if(this.terminationResult)return Promise.resolve(this.terminationResult);if(this.state==="released")return this.terminationResult={success:!0,alreadyExited:!0,forced:!1},Promise.resolve(this.terminationResult);return this.state="terminating",this.terminationPromise=this.terminateOwnedTree().then((j)=>{return this.state="released",this.terminationResult=j,j}),this.terminationPromise}async terminateOwnedTree(){let j=this.child.pid;if(!j)return{success:!1,alreadyExited:!0,forced:!1};if(this.platform==="win32"){let z=await this.taskkill(j,!1);await this.wait(this.gracePeriodMs);let B=await this.taskkill(j,!0);if(!z&&!B)return{success:this.signalDirectChild("SIGKILL"),alreadyExited:!1,forced:!0};return{success:!0,alreadyExited:!1,forced:!0}}let q=this.signalPosixTree(j,"SIGTERM");await this.wait(this.gracePeriodMs);let y=this.signalPosixTree(j,"SIGKILL");return{success:q||y,alreadyExited:!1,forced:y}}signalPosixTree(j,q){if(j<=1||j===process.pid)return this.signalDirectChild(q);try{return this.killProcess(-j,q)}catch(y){if(Z(y)==="ESRCH")return!0;return this.signalDirectChild(q)}}signalDirectChild(j){try{return this.child.kill(j)}catch(q){return Z(q)==="ESRCH"}}}function v(j,q,y={},z={}){let B=I(j,q,{...y,detached:process.platform==="win32"?y.detached:!0,windowsHide:y.windowsHide??!0});return{child:B,processTree:new b(B,z)}}
|
|
2
|
-
export{G as
|
|
2
|
+
export{G as gh,F as hh,R as ih,v as jh};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
var n="verification",r="goal-verification",o="review";function e(t){return t==="verification"||t==="goal-verification"}function i(t){return e(t)||t==="review"}var s=["active","verifying","paused","blocked","usage_limited","budget_limited","complete"],c=["pending","pass","fail","partial"],l=4000,p=3,S=["unable_to_proceed","stopping_here","internal_wait","self_deferral","handoff"],u=3,_=["waiting_dependency","same_task_no_effect","repeated_deferral"],d=3;
|
|
2
|
-
export{n as
|
|
2
|
+
export{n as Mg,r as Ng,o as Og,e as Pg,i as Qg,s as Rg,c as Sg,l as Tg,p as Ug,S as Vg,u as Wg,_ as Xg,d as Yg};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownRenderer-
|
|
2
|
-
import{r as h,j as e}from"./vendor-react-DofNRwfy.js";import{c as ee,u as L,a as f,s as Le,b as at,d as ne,H as Me,P as nt,G as Oe,L as P,S as Ve,T as ie,C as xe,D as Ue,e as He,f as it,g as qe,h as ze,i as Ke,j as $,k as ot,l as Z,B as lt,m as je,n as oe,R as ue,F as ct,_ as Ge,o as dt,p as We,q as ut,X as Je,r as mt,A as Se,t as ht,W as xt,v as pt,w as ft,x as bt}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownRenderer-zKto-Pty.js","assets/index-DorkRCqS.js","assets/vendor-react-DofNRwfy.js","assets/vendor-radix-D6QrtXqd.js","assets/session-events-C6fPz20c.js","assets/index-B4186fIT.css","assets/copy-5c0ESKoo.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as h,j as e}from"./vendor-react-DofNRwfy.js";import{c as ee,u as L,a as f,s as Le,b as at,d as ne,H as Me,P as nt,G as Oe,L as P,S as Ve,T as ie,C as xe,D as Ue,e as He,f as it,g as qe,h as ze,i as Ke,j as $,k as ot,l as Z,B as lt,m as je,n as oe,R as ue,F as ct,_ as Ge,o as dt,p as We,q as ut,X as Je,r as mt,A as Se,t as ht,W as xt,v as pt,w as ft,x as bt}from"./index-DorkRCqS.js";import{m as Ce,i as se,r as O,n as vt,g as gt,o as kt,f as jt,k as yt,l as wt}from"./session-events-C6fPz20c.js";import{A as Nt,E as St}from"./external-link-BypdqupZ.js";import{S as Ct}from"./ScrollArea-1qPJ8lcT.js";import{C as Qe}from"./copy-5c0ESKoo.js";import{C as le}from"./chevron-right-COQAoZf3.js";import{A as Ye,C as Et}from"./chevrons-up-down-B_WSFixv.js";import{f as Tt,g as Mt,h as At,i as Xe}from"./vendor-radix-D6QrtXqd.js";import{P as Rt}from"./pause-BWbHHYG6.js";import{P as Ft}from"./play-CLJgUH4S.js";import{P as Ze}from"./pencil-BPyvvR59.js";import{C as $t}from"./clock-3-DJ-pSj3t.js";import{t as B}from"./team-QZ9byb3E.js";import{teamService as Ae}from"./teamService-DsYRmp6u.js";/**
|
|
3
3
|
* @license lucide-react v0.300.0 - ISC
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the ISC license.
|
|
@@ -34,7 +34,7 @@ import{r as h,j as e}from"./vendor-react-DofNRwfy.js";import{c as ee,u as L,a as
|
|
|
34
34
|
*
|
|
35
35
|
* This source code is licensed under the ISC license.
|
|
36
36
|
* See the LICENSE file in the root directory of this source tree.
|
|
37
|
-
*/const Ot=ee("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);function Re(t){return t.split("/").filter(Boolean).at(-1)||t}function Vt(){const t=L(),s=f(k=>k.sessions),r=f(k=>k.currentSessionRef),a=f(k=>k.historySurfaceSelection),l=f(k=>k.taskDeliveryActions),n=f(k=>k.deliverTask),d=Ce(k=>k.openFilePreview),[p,b]=h.useState(!1),i=s.find(k=>Le({sessionId:k.sessionId,projectPath:k.projectPath},r));if(se(a)||!(i!=null&&i.taskIsolation))return null;const x=i.taskDiffStat,o=i.taskIsolation==="worktree",v=at(i),y=l[ne(v)],m=i.taskDelivery,S=(m==null?void 0:m.status)==="conflicted",u=!!(x&&(x.changedFiles>0||x.commits>0)),E=!["queued","running"].includes(i.taskStatus),g=(m==null?void 0:m.status)==="applied"||(m==null?void 0:m.status)==="discarded",C=o&&u&&E&&!g,c=x?x.additions+x.deletions:0,A=c>0&&x?x.additions/c*100:0,w=k=>{O(f.getState())||n(v,k).catch(()=>{})},F=()=>{O(f.getState())||d({tab:"diff"})};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(Me,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"truncate text-[hsl(var(--deck-ink))]",children:Re(i.taskSourceProjectPath||i.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:[o?e.jsx(nt,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-accent))]"}):e.jsx(Me,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:o?"text-[hsl(var(--deck-accent))]":void 0,children:t(o?"artifact.env.isolated":"artifact.env.local")})]}),i.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:i.taskWorktreeBranch,children:[e.jsx(Oe,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"truncate",children:i.taskWorktreeBranch})]})]})]}),x&&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(Dt,{className:"h-3 w-3 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"tabular-nums",children:x.changedFiles})]}),c>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:`${A}%`}}),e.jsx("span",{className:"h-full bg-red-500/80",style:{width:`${100-A}%`}})]}),e.jsxs("span",{className:"tabular-nums text-[hsl(var(--deck-accent))]",children:["+",x.additions]}),e.jsxs("span",{className:"tabular-nums text-red-600 dark:text-red-400",children:["-",x.deletions]}),x.commits>0&&e.jsx("span",{className:"hidden tabular-nums text-[hsl(var(--deck-ink-faint))] sm:inline",children:t("artifact.commits",{count:x.commits})}),u&&(m==null?void 0:m.status)!=="discarded"&&e.jsx("button",{type:"button",onClick:F,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")}),C&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",disabled:!!y,onClick:()=>w("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:[y==="apply"?e.jsx(P,{className:"h-3 w-3 animate-spin"}):e.jsx(Ve,{className:"h-3 w-3"}),t(y==="apply"?"artifact.applying":S?"artifact.retryApply":"artifact.apply")]}),e.jsx("button",{type:"button",disabled:!!y,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:y==="discard"?e.jsx(P,{className:"h-3 w-3 animate-spin"}):e.jsx(ie,{className:"h-3 w-3"})})]}),(m==null?void 0:m.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(xe,{className:"h-3 w-3"}),t("artifact.applied")]}),(m==null?void 0:m.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(ie,{className:"h-3 w-3"}),t("artifact.discarded")]})]}),(m==null?void 0:m.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(Nt,{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:m.message||t("artifact.conflict")}),e.jsx("span",{className:"block text-[hsl(var(--deck-ink-faint))]",children:t("artifact.conflictHint")})]})]})]}),e.jsx(Ue,{open:p,onOpenChange:b,children:e.jsxs(He,{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(it,{children:[e.jsx(qe,{children:t("artifact.discardDialog.title")}),e.jsx(ze,{className:"text-[hsl(var(--deck-ink-muted))]",children:t("artifact.discardDialog.description",{project:Re(i.taskSourceProjectPath||i.projectPath),count:(x==null?void 0:x.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(Ke,{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),w("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(ie,{className:"h-3.5 w-3.5"}),t("artifact.discardDialog.confirm")]})]})]})})]})}const Ut=new Set(["completed","stale","failed","aborted","interrupted"]),Ht={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"},qt={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 me(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:void 0}function zt(t){const s=me(t),r=me(s==null?void 0:s.codeLocation),a=s==null?void 0:s.priority,l=s==null?void 0:s.confidenceScore,n=r==null?void 0:r.lineStart,d=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 l!="number"||!Number.isFinite(l)||typeof(r==null?void 0:r.path)!="string"||!Number.isInteger(n)||!Number.isInteger(d)))return{title:s.title,body:s.body,priority:a,confidenceScore:l,codeLocation:{path:r.path,lineStart:n,lineEnd:d}}}function Kt(t){const s=me(t),r=me(s==null?void 0:s.target);if((s==null?void 0:s.phase)!=="completed"||typeof s.status!="string"||!Ut.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(zt);if(!a.some(l=>l===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 Gt(t){const{path:s,lineStart:r,lineEnd:a}=t.codeLocation;return r===a?`${s}:L${r}`:`${s}:L${r}-${a}`}function Wt({report:t}){const s=L(),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:$("rounded-full border px-2.5 py-1 font-mono text-[10.5px] font-medium",qt[t.status]),children:[s("chat.review.status"),": ",s(Ht[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,l)=>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:Gt(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}:${l}`))})]}),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 Jt({elicitation:t,messageId:s}){const r=L(),a=f(g=>g.currentSessionRef),l=f(g=>g.setElicitation),[n,d]=h.useState(()=>Yt(t.details.fields??[])),[p,b]=h.useState(()=>Xt(t.details.fields??[])),[i,x]=h.useState(!1),[o,v]=h.useState(),y=t.details.fields??[],m=h.useMemo(()=>y.every(g=>{var c;if(!g.required)return!0;if(pe(g))return!!((c=p[g.name])!=null&&c.trim()||g.defaultValue!==void 0);const C=n[g.name]??g.defaultValue;return Array.isArray(C)?C.length>0:C!==void 0}),[y,p,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 S=async(g,C)=>{if(!O(f.getState())&&!(!a||i)){x(!0),v(void 0);try{await Z.respondToElicitation(a,t.toolCallId,{action:g,...C?{content:C}:{}}),l(s,{...t,status:"responded"})}catch(c){v(c instanceof Error?c.message:r("interaction.elicitation.failed"))}finally{x(!1)}}},u=async()=>{try{await S("accept",Zt(y,n,p))}catch(g){v(g instanceof Error?g.message:String(g))}},E=()=>{if(O(f.getState()))return;const g=t.details.url;if(!g){v("MCP URL is unavailable");return}if(!window.open(g,"_blank","noopener,noreferrer")){v("The browser blocked the external window");return}S("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(ot,{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(te,{onClick:E,disabled:i,primary:!0,label:r("interaction.elicitation.open"),icon:e.jsx(St,{className:"h-3.5 w-3.5"})}),e.jsx(te,{onClick:()=>void S("decline"),disabled:i,label:r("interaction.elicitation.decline")}),e.jsx(te,{onClick:()=>void S("cancel"),disabled:i,label:r("interaction.elicitation.cancel")})]})]}):e.jsxs("div",{className:"space-y-4",children:[y.map(g=>e.jsx(Qt,{field:g,value:n[g.name],rawValue:p[g.name]??"",onValueChange:C=>d(c=>({...c,[g.name]:C})),onRawChange:C=>b(c=>({...c,[g.name]:C}))},g.name)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(te,{onClick:()=>void u(),disabled:i||!m,primary:!0,label:r("interaction.elicitation.submit"),icon:i?e.jsx(P,{className:"h-3.5 w-3.5 animate-spin"}):null}),e.jsx(te,{onClick:()=>void S("decline"),disabled:i,label:r("interaction.elicitation.decline")}),e.jsx(te,{onClick:()=>void S("cancel"),disabled:i,label:r("interaction.elicitation.cancel")})]})]}),o&&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:o})]})}function Qt({field:t,value:s,rawValue:r,onValueChange:a,onRawChange:l}){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:es(t).map(n=>{const d=Array.isArray(s)?s.includes(n.value):s===n.typedValue;return e.jsx("button",{type:"button","aria-pressed":d,onClick:()=>{if(t.type==="multi-select"){const p=Array.isArray(s)?s:[];a(p.includes(n.value)?p.filter(b=>b!==n.value):[...p,n.value])}else a(n.typedValue)},className:$("rounded-md border px-3 py-2 font-mono text-[12px] transition-colors",d?"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:ts(t),value:r,onChange:n=>l(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 te({onClick:t,disabled:s,primary:r=!1,label:a,icon:l}){return e.jsxs("button",{type:"button",onClick:t,disabled:s,className:$("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:[l,a]})}function Yt(t){return Object.fromEntries(t.filter(s=>!pe(s)&&s.defaultValue!==void 0).map(s=>[s.name,Array.isArray(s.defaultValue)?[...s.defaultValue]:s.defaultValue]))}function Xt(t){return Object.fromEntries(t.filter(s=>pe(s)&&s.defaultValue!==void 0).map(s=>[s.name,String(s.defaultValue)]))}function Zt(t,s,r){var l;const a={};for(const n of t){if(pe(n)){const p=((l=r[n.name])==null?void 0:l.trim())??"";if(!p){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 b=Number(p);if(!Number.isFinite(b))throw new Error(`${n.title} must be a finite number`);if(n.type==="integer"&&!Number.isSafeInteger(b))throw new Error(`${n.title} must be a safe integer`);a[n.name]=b}else a[n.name]=p;continue}const d=s[n.name]??n.defaultValue;if(d===void 0){if(n.required)throw new Error(`${n.title} is required`);continue}if(Array.isArray(d)){if(n.minItems!==void 0&&d.length<n.minItems)throw new Error(`${n.title} requires at least ${n.minItems} choices`);if(n.maxItems!==void 0&&d.length>n.maxItems)throw new Error(`${n.title} allows at most ${n.maxItems} choices`)}a[n.name]=d}return a}function es(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 pe(t){return t.type==="string"||t.type==="number"||t.type==="integer"}function ts(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 ss(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 rs({report:t}){const s=L(),[r,a]=h.useState(!1),l=JSON.stringify(t.output,null,2),n=async()=>{try{await navigator.clipboard.writeText(l),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(lt,{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(xe,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}):e.jsx(Qe,{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:l})]})}const as=h.lazy(()=>Ge(()=>import("./MarkdownRenderer-Ct8vtONO.js").then(t=>t.M),__vite__mapDeps([0,1,2,3,4,5,6])).then(t=>({default:t.MarkdownRenderer})));function Fe({text:t,label:s}){const[r,a]=h.useState(!1);if(!t.trim())return null;const l=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:l,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(xe,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}):e.jsx(Qe,{className:"h-3.5 w-3.5"})})}function ns(){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(je,{size:20,pulse:!1})})}function is(){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 $e(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 os(t){if(typeof t=="string")return{text:$e(t),images:[]};const s=t.filter(a=>a.type==="text").map(a=>a.text).join(`
|
|
37
|
+
*/const Ot=ee("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);function Re(t){return t.split("/").filter(Boolean).at(-1)||t}function Vt(){const t=L(),s=f(k=>k.sessions),r=f(k=>k.currentSessionRef),a=f(k=>k.historySurfaceSelection),l=f(k=>k.taskDeliveryActions),n=f(k=>k.deliverTask),d=Ce(k=>k.openFilePreview),[p,b]=h.useState(!1),i=s.find(k=>Le({sessionId:k.sessionId,projectPath:k.projectPath},r));if(se(a)||!(i!=null&&i.taskIsolation))return null;const x=i.taskDiffStat,o=i.taskIsolation==="worktree",v=at(i),y=l[ne(v)],m=i.taskDelivery,S=(m==null?void 0:m.status)==="conflicted",u=!!(x&&(x.changedFiles>0||x.commits>0)),E=!["queued","running"].includes(i.taskStatus),g=(m==null?void 0:m.status)==="applied"||(m==null?void 0:m.status)==="discarded",C=o&&u&&E&&!g,c=x?x.additions+x.deletions:0,A=c>0&&x?x.additions/c*100:0,w=k=>{O(f.getState())||n(v,k).catch(()=>{})},F=()=>{O(f.getState())||d({tab:"diff"})};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(Me,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"truncate text-[hsl(var(--deck-ink))]",children:Re(i.taskSourceProjectPath||i.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:[o?e.jsx(nt,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-accent))]"}):e.jsx(Me,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:o?"text-[hsl(var(--deck-accent))]":void 0,children:t(o?"artifact.env.isolated":"artifact.env.local")})]}),i.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:i.taskWorktreeBranch,children:[e.jsx(Oe,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"truncate",children:i.taskWorktreeBranch})]})]})]}),x&&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(Dt,{className:"h-3 w-3 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"tabular-nums",children:x.changedFiles})]}),c>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:`${A}%`}}),e.jsx("span",{className:"h-full bg-red-500/80",style:{width:`${100-A}%`}})]}),e.jsxs("span",{className:"tabular-nums text-[hsl(var(--deck-accent))]",children:["+",x.additions]}),e.jsxs("span",{className:"tabular-nums text-red-600 dark:text-red-400",children:["-",x.deletions]}),x.commits>0&&e.jsx("span",{className:"hidden tabular-nums text-[hsl(var(--deck-ink-faint))] sm:inline",children:t("artifact.commits",{count:x.commits})}),u&&(m==null?void 0:m.status)!=="discarded"&&e.jsx("button",{type:"button",onClick:F,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")}),C&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",disabled:!!y,onClick:()=>w("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:[y==="apply"?e.jsx(P,{className:"h-3 w-3 animate-spin"}):e.jsx(Ve,{className:"h-3 w-3"}),t(y==="apply"?"artifact.applying":S?"artifact.retryApply":"artifact.apply")]}),e.jsx("button",{type:"button",disabled:!!y,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:y==="discard"?e.jsx(P,{className:"h-3 w-3 animate-spin"}):e.jsx(ie,{className:"h-3 w-3"})})]}),(m==null?void 0:m.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(xe,{className:"h-3 w-3"}),t("artifact.applied")]}),(m==null?void 0:m.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(ie,{className:"h-3 w-3"}),t("artifact.discarded")]})]}),(m==null?void 0:m.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(Nt,{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:m.message||t("artifact.conflict")}),e.jsx("span",{className:"block text-[hsl(var(--deck-ink-faint))]",children:t("artifact.conflictHint")})]})]})]}),e.jsx(Ue,{open:p,onOpenChange:b,children:e.jsxs(He,{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(it,{children:[e.jsx(qe,{children:t("artifact.discardDialog.title")}),e.jsx(ze,{className:"text-[hsl(var(--deck-ink-muted))]",children:t("artifact.discardDialog.description",{project:Re(i.taskSourceProjectPath||i.projectPath),count:(x==null?void 0:x.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(Ke,{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),w("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(ie,{className:"h-3.5 w-3.5"}),t("artifact.discardDialog.confirm")]})]})]})})]})}const Ut=new Set(["completed","stale","failed","aborted","interrupted"]),Ht={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"},qt={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 me(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:void 0}function zt(t){const s=me(t),r=me(s==null?void 0:s.codeLocation),a=s==null?void 0:s.priority,l=s==null?void 0:s.confidenceScore,n=r==null?void 0:r.lineStart,d=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 l!="number"||!Number.isFinite(l)||typeof(r==null?void 0:r.path)!="string"||!Number.isInteger(n)||!Number.isInteger(d)))return{title:s.title,body:s.body,priority:a,confidenceScore:l,codeLocation:{path:r.path,lineStart:n,lineEnd:d}}}function Kt(t){const s=me(t),r=me(s==null?void 0:s.target);if((s==null?void 0:s.phase)!=="completed"||typeof s.status!="string"||!Ut.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(zt);if(!a.some(l=>l===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 Gt(t){const{path:s,lineStart:r,lineEnd:a}=t.codeLocation;return r===a?`${s}:L${r}`:`${s}:L${r}-${a}`}function Wt({report:t}){const s=L(),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:$("rounded-full border px-2.5 py-1 font-mono text-[10.5px] font-medium",qt[t.status]),children:[s("chat.review.status"),": ",s(Ht[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,l)=>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:Gt(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}:${l}`))})]}),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 Jt({elicitation:t,messageId:s}){const r=L(),a=f(g=>g.currentSessionRef),l=f(g=>g.setElicitation),[n,d]=h.useState(()=>Yt(t.details.fields??[])),[p,b]=h.useState(()=>Xt(t.details.fields??[])),[i,x]=h.useState(!1),[o,v]=h.useState(),y=t.details.fields??[],m=h.useMemo(()=>y.every(g=>{var c;if(!g.required)return!0;if(pe(g))return!!((c=p[g.name])!=null&&c.trim()||g.defaultValue!==void 0);const C=n[g.name]??g.defaultValue;return Array.isArray(C)?C.length>0:C!==void 0}),[y,p,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 S=async(g,C)=>{if(!O(f.getState())&&!(!a||i)){x(!0),v(void 0);try{await Z.respondToElicitation(a,t.toolCallId,{action:g,...C?{content:C}:{}}),l(s,{...t,status:"responded"})}catch(c){v(c instanceof Error?c.message:r("interaction.elicitation.failed"))}finally{x(!1)}}},u=async()=>{try{await S("accept",Zt(y,n,p))}catch(g){v(g instanceof Error?g.message:String(g))}},E=()=>{if(O(f.getState()))return;const g=t.details.url;if(!g){v("MCP URL is unavailable");return}if(!window.open(g,"_blank","noopener,noreferrer")){v("The browser blocked the external window");return}S("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(ot,{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(te,{onClick:E,disabled:i,primary:!0,label:r("interaction.elicitation.open"),icon:e.jsx(St,{className:"h-3.5 w-3.5"})}),e.jsx(te,{onClick:()=>void S("decline"),disabled:i,label:r("interaction.elicitation.decline")}),e.jsx(te,{onClick:()=>void S("cancel"),disabled:i,label:r("interaction.elicitation.cancel")})]})]}):e.jsxs("div",{className:"space-y-4",children:[y.map(g=>e.jsx(Qt,{field:g,value:n[g.name],rawValue:p[g.name]??"",onValueChange:C=>d(c=>({...c,[g.name]:C})),onRawChange:C=>b(c=>({...c,[g.name]:C}))},g.name)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(te,{onClick:()=>void u(),disabled:i||!m,primary:!0,label:r("interaction.elicitation.submit"),icon:i?e.jsx(P,{className:"h-3.5 w-3.5 animate-spin"}):null}),e.jsx(te,{onClick:()=>void S("decline"),disabled:i,label:r("interaction.elicitation.decline")}),e.jsx(te,{onClick:()=>void S("cancel"),disabled:i,label:r("interaction.elicitation.cancel")})]})]}),o&&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:o})]})}function Qt({field:t,value:s,rawValue:r,onValueChange:a,onRawChange:l}){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:es(t).map(n=>{const d=Array.isArray(s)?s.includes(n.value):s===n.typedValue;return e.jsx("button",{type:"button","aria-pressed":d,onClick:()=>{if(t.type==="multi-select"){const p=Array.isArray(s)?s:[];a(p.includes(n.value)?p.filter(b=>b!==n.value):[...p,n.value])}else a(n.typedValue)},className:$("rounded-md border px-3 py-2 font-mono text-[12px] transition-colors",d?"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:ts(t),value:r,onChange:n=>l(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 te({onClick:t,disabled:s,primary:r=!1,label:a,icon:l}){return e.jsxs("button",{type:"button",onClick:t,disabled:s,className:$("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:[l,a]})}function Yt(t){return Object.fromEntries(t.filter(s=>!pe(s)&&s.defaultValue!==void 0).map(s=>[s.name,Array.isArray(s.defaultValue)?[...s.defaultValue]:s.defaultValue]))}function Xt(t){return Object.fromEntries(t.filter(s=>pe(s)&&s.defaultValue!==void 0).map(s=>[s.name,String(s.defaultValue)]))}function Zt(t,s,r){var l;const a={};for(const n of t){if(pe(n)){const p=((l=r[n.name])==null?void 0:l.trim())??"";if(!p){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 b=Number(p);if(!Number.isFinite(b))throw new Error(`${n.title} must be a finite number`);if(n.type==="integer"&&!Number.isSafeInteger(b))throw new Error(`${n.title} must be a safe integer`);a[n.name]=b}else a[n.name]=p;continue}const d=s[n.name]??n.defaultValue;if(d===void 0){if(n.required)throw new Error(`${n.title} is required`);continue}if(Array.isArray(d)){if(n.minItems!==void 0&&d.length<n.minItems)throw new Error(`${n.title} requires at least ${n.minItems} choices`);if(n.maxItems!==void 0&&d.length>n.maxItems)throw new Error(`${n.title} allows at most ${n.maxItems} choices`)}a[n.name]=d}return a}function es(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 pe(t){return t.type==="string"||t.type==="number"||t.type==="integer"}function ts(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 ss(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 rs({report:t}){const s=L(),[r,a]=h.useState(!1),l=JSON.stringify(t.output,null,2),n=async()=>{try{await navigator.clipboard.writeText(l),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(lt,{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(xe,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}):e.jsx(Qe,{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:l})]})}const as=h.lazy(()=>Ge(()=>import("./MarkdownRenderer-zKto-Pty.js").then(t=>t.M),__vite__mapDeps([0,1,2,3,4,5,6])).then(t=>({default:t.MarkdownRenderer})));function Fe({text:t,label:s}){const[r,a]=h.useState(!1);if(!t.trim())return null;const l=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:l,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(xe,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}):e.jsx(Qe,{className:"h-3.5 w-3.5"})})}function ns(){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(je,{size:20,pulse:!1})})}function is(){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 $e(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 os(t){if(typeof t=="string")return{text:$e(t),images:[]};const s=t.filter(a=>a.type==="text").map(a=>a.text).join(`
|
|
38
38
|
`),r=t.filter(a=>a.type==="image_url").map(a=>a.image_url.url);return{text:$e(s),images:r}}function Ee(t){return typeof t=="string"?t:t.filter(s=>s.type==="text").map(s=>s.text).join(`
|
|
39
39
|
`)}function ls(t){const s=t.agentContent;return s?vt(s):Ee(t.content)}function De({content:t,syntaxHighlight:s=!0}){return e.jsx(h.Suspense,{fallback:e.jsx("pre",{className:"text-[14px] text-[hsl(var(--deck-ink))] font-mono whitespace-pre-wrap",children:t}),children:e.jsx(as,{content:t,syntaxHighlight:s})})}function Te({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:$("text-[11px] px-2 py-0.5 rounded-full font-mono",s[t]),children:r[t]})}function cs(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)}const Ie=500;function et(t,s){if(t.length<=s)return t;let r=Math.max(0,s);return r>0&&/[\uD800-\uDBFF]/.test(t.charAt(r-1))&&(r-=1),t.slice(0,r)}function Be(t,s){if(t.length<=s)return t;let r=Math.max(0,t.length-s);return/[\uDC00-\uDFFF]/.test(t.charAt(r))&&(r+=1),t.slice(r)}function be(t,s){if(t.length<=s)return t;if(s<=0)return"";const r=`
|
|
40
40
|
... (display clipped) ...
|
|
@@ -49,5 +49,5 @@ stdout:
|
|
|
49
49
|
${be(o,v-y)}`}else i=be(l,d);return{body:et(i,d),...a?{notice:a}:{},truncated:!!a||t.length>Ie}}function us({tool:t}){const[s,r]=h.useState(!1),a=cs(t.arguments),l=t.output?ds(t.output):void 0;return e.jsxs("div",{"data-tool-name":t.toolName,"data-tool-status":t.status,"data-tool-truncated":l!=null&&l.truncated?"true":"false",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(n=>!n),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(oe,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))] shrink-0"}):e.jsx(le,{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(Te,{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})]}),l&&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.jsxs("pre",{"data-tool-output":!0,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:[l.body,l.notice&&e.jsxs(e.Fragment,{children:[`
|
|
50
50
|
`,e.jsx("span",{"data-tool-truncation-notice":!0,children:l.notice})]})]})]})]})]})}function tt({toolCalls:t}){return t.length===0?null:e.jsx("div",{className:"space-y-2",children:t.map(s=>e.jsx(us,{tool:s},s.toolCallId))})}function ms({toolCalls:t,toolCallIds:s}){const r=L(),[a,l]=h.useState(!1),n=h.useMemo(()=>new Map(t.map(o=>[o.toolCallId,o])),[t]),d=s.flatMap(o=>{const v=n.get(o);return v?[v]:[]});if(d.length===0)return null;const p=d.filter(o=>o.status==="running").length,b=d.filter(o=>o.status==="error").length,i=[...d].reverse().find(o=>o.status==="running"&&!!o.progressMessage),x=p>0?r(d.length===1?"chat.timeline.tools.runningOne":"chat.timeline.tools.running",{count:d.length}):b>0?r(d.length===1?"chat.timeline.tools.completedOneWithError":"chat.timeline.tools.completedWithErrors",{count:d.length,errors:b}):r(d.length===1?"chat.timeline.tools.completedOne":"chat.timeline.tools.completed",{count:d.length});return e.jsxs("div",{"data-agent-tool-group":!0,className:"py-0.5",children:[e.jsxs("button",{type:"button","aria-expanded":a,onClick:()=>l(o=>!o),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(oe,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(le,{className:"h-3.5 w-3.5 shrink-0"}),p>0&&e.jsx(P,{className:"h-3 w-3 shrink-0 animate-spin text-[hsl(var(--deck-accent))]"}),e.jsx("span",{children:x}),(i==null?void 0:i.progressMessage)&&e.jsxs("span",{className:"min-w-0 truncate text-[10.5px] text-[hsl(var(--deck-ink-muted))]",children:[i.progressMessage,i.progress!==void 0&&i.progressTotal!==void 0&&` · ${Math.max(0,Math.min(100,Math.round(i.progress/i.progressTotal*100)))}%`]})]}),(i==null?void 0:i.progress)!==void 0&&i.progressTotal!==void 0&&e.jsx("div",{role:"progressbar","aria-label":`${i.toolName} progress`,"aria-valuemin":0,"aria-valuemax":i.progressTotal,"aria-valuenow":Math.min(i.progress,i.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,i.progress/i.progressTotal*100))}%`}})}),a&&e.jsx("div",{"data-agent-tool-group-details":!0,className:"mt-2 space-y-2 pl-1",children:e.jsx(tt,{toolCalls:d})})]})}function hs({content:t}){const s=L(),[r,a]=h.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(l=>!l),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(oe,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))]"}):e.jsx(le,{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 xs({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 ps({toolCalls:t}){const s=Ce(n=>n.openFilePreview),r=f(n=>se(n.historySurfaceSelection)),a=h.useMemo(()=>{const n=new Map,d=["Write","SearchReplace","Edit","ApplyPatch"];for(const p of t){if(p.status!=="success")continue;const b=p.metadata;if(p.toolName==="ApplyPatch"&&Array.isArray(b==null?void 0:b.changes)){for(const x of b.changes)x&&typeof x=="object"&&"path"in x&&typeof x.path=="string"&&n.set(x.path,{path:x.path,toolName:p.toolName});continue}const i=b==null?void 0:b.file_path;i&&d.includes(p.toolName)&&n.set(i,{path:i,toolName:p.toolName})}return Array.from(n.values())},[t]);if(r||a.length===0)return null;const l=n=>{O(f.getState())||s({tab:"diff",targetPath:n})};return 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 (",a.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:a.map(({path:n})=>{const d=n.split("/").pop()||n;return e.jsxs("button",{onClick:()=>l(n),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:n,children:[e.jsx(ct,{className:"w-3 h-3"}),d]},n)})})]})}function fs({subagent:t}){var G,J,Q,Y;const s=L(),[r,a]=h.useState(null),[l,n]=h.useState(!1),[d,p]=h.useState(null),[b,i]=h.useState(!1),[x,o]=h.useState(""),[v,y]=h.useState(!1),[m,S]=h.useState(null),[u,E]=h.useState(null),[g,C]=h.useState(null),c=f(R=>R.currentSessionRef),A=f(R=>R.isStreaming),w=f(R=>R.isTemporarySession),F=f(R=>se(R.historySurfaceSelection));if(!t)return null;const k=t.status==="running",_=r!==null?r:k,U=t.toolCalls||d||[],N=t.output||t.thinking||U.length>0||t.sessionId,T=u&&u.status!=="running"?u:g,D=(T==null?void 0:T.id)??t.sessionId,I=((G=T==null?void 0:T.restartRecovery)==null?void 0:G.outcome)==="failed",H=!k&&!A&&!w&&!F&&!I&&(u==null?void 0:u.status)!=="running"&&!!(D&&c);h.useEffect(()=>{if(F||!_||k||!t.sessionId||!(c!=null&&c.projectPath)||d!==null||t.toolCalls&&t.toolCalls.length>0)return;let R=!0;return n(!0),Z.getMessages({sessionId:t.sessionId,projectPath:c.projectPath}).then(q=>{var z,M;if(!R)return;const j=jt(q),V=new Map;for(const K of j)if((M=(z=K.agentContent)==null?void 0:z.toolCalls)!=null&&M.length)for(const fe of K.agentContent.toolCalls)V.has(fe.toolCallId)||V.set(fe.toolCallId,fe);p(Array.from(V.values()))}).finally(()=>{R&&n(!1)}),()=>{R=!1}},[_,F,k,t.sessionId,t.toolCalls,d,c==null?void 0:c.projectPath]),h.useEffect(()=>{if(F||!t.sessionId||!c)return;let R=!0;const q=t.rootAgentId??t.sessionId,j=t.resumeDepth??0;return Z.listSubagents(c).then(V=>{if(!R)return;C(V.find(M=>M.id===t.sessionId)??null);const z=V.filter(M=>M.id!==t.sessionId&&M.rootAgentId===q&&M.resumeDepth>j).sort((M,K)=>K.resumeDepth-M.resumeDepth||K.lastActiveAt-M.lastActiveAt)[0];z&&E(z)}).catch(()=>{}),()=>{R=!1}},[c==null?void 0:c.sessionId,c==null?void 0:c.projectPath,F,t.sessionId,t.rootAgentId,t.resumeDepth]),h.useEffect(()=>{if(F||!u||u.status!=="running"||!c)return;let R=!0;const q=async()=>{try{const z=(await Z.listSubagents(c)).find(M=>M.id===u.id);R&&z&&E(z)}catch{}},j=window.setInterval(()=>{q()},1e3);return()=>{R=!1,window.clearInterval(j)}},[c,F,u==null?void 0:u.id,u==null?void 0:u.status]);const W=async()=>{if(!O(f.getState())&&!(!c||!D||!x.trim()||v)){y(!0),S(null);try{const R=await Z.resumeSubagent(c,D,x.trim());E(R.session),o(""),i(!1),a(!0)}catch(R){S(R instanceof Error?R.message:s("chat.subagent.resumeFailed"))}finally{y(!1)}}};return e.jsxs("div",{"data-subagent-id":t.id,"data-subagent-session-id":t.sessionId,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(!_),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:[k&&e.jsx(P,{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(Te,{status:t.status==="completed"?"success":t.status==="failed"?"error":"running"}),t.type==="verification"&&t.verificationVerdict&&e.jsx("span",{"data-verification-verdict":t.verificationVerdict,className:$("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})})]}),N&&e.jsx(oe,{className:$("h-3.5 w-3.5 text-[hsl(var(--deck-ink-muted))] transition-transform",_&&"rotate-180")})]}),!_&&!k&&t.output&&e.jsx("div",{"data-subagent-output-summary":!0,className:"mt-2 max-h-10 overflow-hidden whitespace-pre-wrap break-words font-mono text-[11px] text-[hsl(var(--deck-ink))]",children:t.output}),_&&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})]}),l&&e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono",children:[e.jsx(P,{className:"w-3 h-3 animate-spin"}),s("chat.subagent.loadingLogs")]}),!l&&U.length>0&&e.jsx(tt,{toolCalls:U}),u&&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:u.id,status:u.status,depth:u.resumeDepth??1})}),(((J=u.result)==null?void 0:J.message)||((Q=u.result)==null?void 0:Q.error))&&e.jsx("div",{className:"mt-1 whitespace-pre-wrap text-[hsl(var(--deck-ink))]",children:u.result.message||u.result.error})]}),I&&((Y=T==null?void 0:T.result)==null?void 0:Y.error)&&e.jsx("div",{role:"alert",className:"text-[11px] text-red-600",children:T.result.error}),H&&e.jsxs("div",{className:"space-y-2",children:[b?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:x,onChange:R=>o(R.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:()=>{i(!1),S(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 W(),disabled:!x.trim()||v,className:"flex items-center gap-1 rounded bg-[#7C3AED] px-2 py-1 text-[11px] font-medium text-white disabled:opacity-50",children:[v&&e.jsx(P,{className:"w-3 h-3 animate-spin"}),s("chat.subagent.resumeAgent")]})]})]}):e.jsxs("button",{type:"button","aria-label":s("chat.subagent.resumeAria"),onClick:()=>i(!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(ue,{className:"w-3 h-3"}),s("chat.subagent.resume")]}),m&&e.jsx("div",{role:"alert",className:"text-[11px] text-red-600",children:m})]})]})]})}function bs({confirmation:t,messageId:s}){const r=L(),[a,l]=h.useState(!1),[n,d]=h.useState(null),p=f(x=>x.currentSessionRef),b=f(x=>x.setConfirmation);if(!t)return null;const i=async(x,o)=>{if(!O(f.getState())&&!(!p||a)){l(!0),d(null);try{await Z.respondPermission(p,t.toolCallId,{approved:x,scope:o}),b(s,{...t,status:x?"approved":"denied"})}catch(v){d(v instanceof Error?v.message:r("interaction.permission.failed"))}finally{l(!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 i(!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(P,{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 i(!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 i(!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 i(!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 vs({question:t,messageId:s}){const r=L(),[a,l]=h.useState({}),[n,d]=h.useState({}),[p,b]=h.useState(!1),[i,x]=h.useState(null),o=f(u=>u.currentSessionRef),v=f(u=>u.setQuestion),y=h.useMemo(()=>t?t.questions.reduce((u,E)=>{var A;const g=(A=n[E.header])==null?void 0:A.trim(),C=a[E.header];if(E.multiSelect){const w=Array.isArray(C)?[...C]:[];return g&&w.push(g),w.length>0&&(u[E.header]=w),u}const c=g||(typeof C=="string"?C:"");return c&&(u[E.header]=c),u},{}):{},[a,n,t]),m=(t==null?void 0:t.questions.every(u=>u.header in y))??!1;if(!t)return null;const S=async()=>{if(!O(f.getState())&&!(!o||p||!m)){b(!0),x(null);try{await Z.respondToQuestion(o,t.toolCallId,y),v(s,{...t,status:"answered",answers:y})}catch(u){x(u instanceof Error?u.message:r("interaction.question.failed"))}finally{b(!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((u,E)=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-[13px] text-[hsl(var(--deck-ink))] font-mono",children:u.question}),e.jsxs("div",{className:"space-y-1",children:[u.options.map((g,C)=>e.jsxs("button",{type:"button",onClick:()=>{if(u.multiSelect){const c=a[u.header]||[],A=c.includes(g.label)?c.filter(w=>w!==g.label):[...c,g.label];l({...a,[u.header]:A})}else l({...a,[u.header]:g.label}),d({...n,[u.header]:""})},className:$("w-full text-left px-3 py-2 rounded-md border text-[12px] font-mono transition-colors","border-[hsl(var(--deck-border))]",(u.multiSelect?(a[u.header]||[]).includes(g.label):a[u.header]===g.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:g.label}),e.jsx("div",{className:"text-[11px] text-[hsl(var(--deck-ink-faint))] mt-1",children:g.description})]},C)),e.jsx("input",{"aria-label":`${u.header} other response`,value:n[u.header]??"",onChange:g=>d({...n,[u.header]:g.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]"})]})]},E)),i&&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:i}),e.jsxs("button",{type:"button",onClick:()=>void S(),disabled:p||!m,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:[p&&e.jsx(P,{className:"h-3.5 w-3.5 animate-spin"}),r("interaction.question.submit")]})]})}function gs({message:t}){const s=t.agentContent,r=f(m=>m.isStreaming&&m.currentAssistantMessageId===t.id);if(!s){const m=Ee(t.content);return m?e.jsx(De,{content:m}):null}const{toolCalls:a,tasks:l,confirmation:n,question:d,elicitation:p}=s,b=gt(s),i=kt(s);if(!(i.length>0||l.length>0||b.length>0||n||d||p)&&r)return e.jsxs("div",{className:"flex items-center gap-2 text-[hsl(var(--deck-ink-muted))]",children:[e.jsx(P,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{className:"text-[12px] font-mono",children:"Thinking..."})]});const v=a.length>0&&a.every(m=>m.status==="success"||m.status==="error")&&!r,y=!r;return e.jsxs("div",{className:"space-y-3",children:[i.map(m=>m.type==="thinking"?e.jsx("div",{"data-agent-timeline-block":"thinking",children:e.jsx(hs,{content:m.content})},m.id):m.type==="text"?e.jsx("div",{"data-agent-timeline-block":"text",children:e.jsx(De,{content:m.content,syntaxHighlight:y})},m.id):e.jsx("div",{"data-agent-timeline-block":"tool_group",children:e.jsx(ms,{toolCalls:a,toolCallIds:m.toolCallIds})},m.id)),l.length>0&&e.jsx(xs,{tasks:l}),b.map(m=>e.jsx(fs,{subagent:m},m.id)),n&&e.jsx(bs,{confirmation:n,messageId:t.id}),d&&e.jsx(vs,{question:d,messageId:t.id}),p&&e.jsx(Jt,{elicitation:p,messageId:t.id}),v&&e.jsx(ps,{toolCalls:a})]})}function ks({message:t,showAvatar:s=!0}){var p,b,i,x;const r=t.role==="user";if(t.role==="system"){const o=Ee(t.content);return e.jsx("div",{"data-chat-message-id":t.id,"data-chat-role":"system",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:o})})}if(r){const o=(p=t.metadata)!=null&&p.userShellCommand&&typeof t.metadata.userShellCommand=="object"?t.metadata.userShellCommand:(b=t.metadata)!=null&&b.userShellExecution&&typeof t.metadata.userShellExecution=="object"?t.metadata.userShellExecution:void 0;if(o){const m=typeof o.command=="string"?o.command:"",S=o.status==="running"?"running":o.status==="completed"?"success":"error",u=typeof o.output=="string"?o.output:[typeof o.stdout=="string"?o.stdout:"",typeof o.stderr=="string"&&o.stderr?`stderr:
|
|
51
51
|
${o.stderr}`:""].filter(Boolean).join(`
|
|
52
|
-
`);return e.jsx("div",{"data-chat-message-id":t.id,"data-chat-role":"user","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:"$"}),m]}),e.jsx(Te,{status:S})]}),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:u||"(no output)"}),typeof o.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 ",o.exitCode,typeof o.durationMs=="number"?` · ${(o.durationMs/1e3).toFixed(3)}s`:"",o.truncated===!0?" · truncated":""]})]})})}const{text:v,images:y}=os(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:v,label:"Copy message"})}),e.jsxs("div",{className:"bg-[hsl(var(--deck-surface-2))] rounded-lg px-4 py-3 max-w-[85%]",children:[v&&e.jsx("p",{className:"text-[14px] text-[hsl(var(--deck-ink))] font-mono leading-relaxed whitespace-pre-wrap",children:v}),y.length>0&&e.jsx("div",{className:$("grid gap-2",y.length===1?"grid-cols-1 mt-0":"grid-cols-2 mt-3"),children:y.map((m,S)=>e.jsx("img",{src:m,alt:`attachment-${S+1}`,className:"object-cover w-full max-h-64 rounded-md"},`${m}-${S}`))})]}),e.jsx(is,{})]})}const l=ls(t),n=Kt((i=t.metadata)==null?void 0:i.codeReview),d=ss((x=t.metadata)==null?void 0:x.structuredOutput);return e.jsxs("div",{"data-chat-message-id":t.id,"data-chat-role":"assistant",className:$("group flex gap-4 justify-start w-full",s?"p-4":"px-4 pt-0 pb-3"),children:[s?e.jsx(ns,{}):e.jsx("div",{className:"w-8 shrink-0"}),e.jsxs("div",{className:"overflow-hidden flex-1 min-w-0",children:[n?e.jsx(Wt,{report:n}):d?e.jsx(rs,{report:d}):e.jsx(gs,{message:t}),!d&&l.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:l,label:"Copy response"})})]})]})}const js=h.memo(ks);function ys(t,s,r){return Math.max(0,t+(r-s))}function ws(t,s,r){return Math.min(s,Math.max(0,t)+Math.max(0,r))}function Ns(t,s,r,a){const l=new Map(t.filter(d=>!!d.id).map(d=>[d.id,d])),n=new Set(r);for(const d of s){if(!d.id)continue;const p=l.get(d.id);p!==d&&(!p||!a||a(p)!==a(d))&&n.add(d.id)}return n}function _e(t,s){return t?t.querySelector(`[data-chat-message-id="${CSS.escape(s)}"]`):null}function Ss({turns:t,viewportRef:s,containerRef:r,onRevealTurn:a}){const l=L(),[n,d]=h.useState(null),[p,b]=h.useState(!1),i=h.useRef(null),x=h.useCallback(()=>{var u;const v=s.current,y=r.current;if(!v||!y||t.length===0)return;const m=v.getBoundingClientRect().top;let S=((u=t[0])==null?void 0:u.id)??null;for(const E of t){const g=_e(y,E.id);if(g)if(g.getBoundingClientRect().top-m<=24)S=E.id;else break}d(S)},[t,s,r]);h.useEffect(()=>{const v=s.current;if(!v)return;const y=()=>{i.current===null&&(i.current=window.requestAnimationFrame(()=>{i.current=null,x()}))};return x(),v.addEventListener("scroll",y,{passive:!0}),()=>{v.removeEventListener("scroll",y),i.current!==null&&(window.cancelAnimationFrame(i.current),i.current=null)}},[x,s]);const o=h.useCallback(v=>{const y=()=>{const S=_e(r.current,v.id);S&&(S.scrollIntoView({behavior:"smooth",block:"start"}),d(v.id))};a(v.index)?y():window.requestAnimationFrame(()=>window.requestAnimationFrame(y))},[r,a]);return t.length<2?null:e.jsx("nav",{"aria-label":l("chat.turns.aria"),className:"absolute right-1 top-1/2 z-20 hidden -translate-y-1/2 sm:block",onMouseEnter:()=>b(!0),onMouseLeave:()=>b(!1),onFocusCapture:()=>b(!0),onBlurCapture:v=>{v.currentTarget.contains(v.relatedTarget)||b(!1)},children:e.jsxs("div",{className:"relative flex items-center justify-end",children:[e.jsx("ul",{className:$("flex flex-col items-center gap-2 py-2 transition-opacity",p?"opacity-0":"opacity-100"),"aria-hidden":p,children:t.map(v=>e.jsx("li",{children:e.jsx("span",{className:$("block rounded-full transition-all",v.id===n?"h-2 w-2 bg-[hsl(var(--deck-accent))]":"h-1.5 w-1.5 bg-[hsl(var(--deck-ink-faint))]/40")})},v.id))}),e.jsx("div",{className:$("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",p?"pointer-events-auto translate-x-0 opacity-100":"pointer-events-none translate-x-2 opacity-0"),children:t.map((v,y)=>e.jsxs("button",{type:"button",onClick:()=>o(v),className:$("flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left transition-colors",v.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:$("mt-1 h-1.5 w-1.5 shrink-0 rounded-full",v.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:l("chat.turns.label",{n:y+1})}),e.jsx("span",{className:"line-clamp-2 text-[12px] leading-4",children:v.preview})]})]},v.id))})]})})}const Pe=80;function Cs(t){return typeof t=="string"?t:Array.isArray(t)?t.filter(s=>s.type==="text").map(s=>s.text).join(" "):""}function Es(t){const s=Cs(t).replace(/\s+/g," ").trim();return s?s.length>Pe?`${s.slice(0,Pe-1)}…`:s:""}function Ts(t){const s=[];for(let r=0;r<t.length;r+=1){const a=t[r];if(a.role!=="user"||!a.id)continue;const l=Es(a.content);l&&s.push({id:a.id,index:r,preview:l})}return s}const ve=120,ge=80,Ms=96;function re(t){return(t==null?void 0:t.querySelector("[data-radix-scroll-area-viewport]"))??null}function As(t){return JSON.stringify([t.role,t.content,t.metadata,t.agentContent])}function Rs({messages:t,isLoading:s}){const r=L(),a=h.useRef(null),l=h.useRef(null),n=h.useRef(!0),d=h.useRef(!1),p=h.useRef(t),b=h.useRef(t),i=h.useRef(new Set),x=h.useRef(t.length),o=h.useRef(null),[v,y]=h.useState(ve),[m,S]=h.useState(!1),[u,E]=h.useState(0),g=t.length>0;p.current=t,h.useEffect(()=>{const N=re(a.current);if(!N||d.current&&!n.current)return;const T=window.requestAnimationFrame(()=>{N.scrollTop=N.scrollHeight,d.current=!0,n.current=!0,i.current=new Set,E(0),S(!1)});return()=>window.cancelAnimationFrame(T)},[t]),h.useEffect(()=>{const N=re(a.current);if(!N)return;l.current=N;const T=()=>{if(!d.current)return;const I=N.scrollHeight-N.scrollTop-N.clientHeight<=Ms,H=n.current;n.current=I,S(!I),I?(i.current=new Set,E(0)):H&&(b.current=p.current,i.current=new Set,E(0))};return T(),N.addEventListener("scroll",T,{passive:!0}),()=>N.removeEventListener("scroll",T)},[g,s]),h.useEffect(()=>{const N=b.current;if(b.current=t,n.current){i.current.size>0&&(i.current=new Set,E(0));return}const T=Ns(N,t,i.current,As);i.current=T,E(T.size)},[t]),h.useEffect(()=>{const N=x.current;x.current=t.length,y(T=>T>=N&&t.length>N?t.length:Math.min(Math.max(T,ve),t.length||ve))},[t.length]);const C=Math.max(t.length-v,0),c=C,A=h.useMemo(()=>t.slice(c),[t,c]),w=h.useMemo(()=>Ts(t),[t]);if(h.useLayoutEffect(()=>{var D;const N=o.current;if(!N)return;const T=re(a.current);if(o.current=null,!!T){if((D=N.element)!=null&&D.isConnected){const I=N.element.getBoundingClientRect().top-N.viewportTop;T.scrollTop+=I;return}T.scrollTop=ys(N.scrollTop,N.scrollHeight,T.scrollHeight)}},[v]),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(je,{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(dt,{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((N,T)=>e.jsxs("div",{className:$("flex gap-3",T%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:`${N}%`,animationDelay:`${T*120}ms`}})]},N))})]})});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(je,{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 F=()=>{const N=re(a.current);N&&(N.scrollTop=N.scrollHeight,n.current=!0,d.current=!0,i.current=new Set,E(0),S(!1))},k=()=>{var T;const N=re(a.current);if(N){const D=((T=a.current)==null?void 0:T.querySelector("[data-chat-message-id]"))??null;o.current={element:D,viewportTop:(D==null?void 0:D.getBoundingClientRect().top)??0,scrollHeight:N.scrollHeight,scrollTop:N.scrollTop}}y(D=>ws(D,t.length,ge))},_=N=>N>=c?!0:(y(t.length),!1),U=u===1?r("chat.list.unreadMessage"):r("chat.list.unreadMessages",{count:u});return e.jsxs("div",{ref:a,className:"relative flex-1 min-h-0",children:[e.jsx(Ct,{className:"h-full",children:e.jsxs("div",{className:"flex flex-col px-4 pb-4 w-full md:px-6",children:[C>0&&e.jsx("div",{className:"flex justify-center py-3",children:e.jsx("button",{type:"button",onClick:k,"aria-label":r("chat.list.showEarlierWithRemaining",{count:Math.min(C,ge),remaining:C}),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(C,ge)})})}),A.map((N,T)=>{const D=c+T,I=D>0?t[D-1]:null,H=!I||I.role!==N.role||I.role==="user";return e.jsx(js,{message:N,showAvatar:H},N.id||`msg-${D}`)})]})}),e.jsx(Ss,{turns:w,viewportRef:l,containerRef:a,onRevealTurn:_}),m&&e.jsxs("button",{type:"button",onClick:F,"aria-live":"polite","aria-label":u>0?U:r("chat.list.jumpLatest"),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(Ye,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}),u>0?U:r("chat.list.jumpLatest")]})]})}const st=h.memo(Rs),ye=Tt,we=Mt,Ne=At,he=h.forwardRef(({className:t,sideOffset:s=4,...r},a)=>e.jsx(Xe,{ref:a,sideOffset:s,className:$("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}));he.displayName=Xe.displayName;const Fs={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 ce(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t)}function $s(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 Ds(){var N,T,D,I,H,W,G,J,Q,Y,R,q,j,V,z;const t=L(),{locale:s}=We(),r=f(M=>M.goal),a=f(M=>M.pauseGoal),l=f(M=>M.resumeGoal),n=f(M=>M.editGoal),d=f(M=>M.clearGoal),p=f(M=>se(M.historySurfaceSelection)),[b,i]=h.useState(!1),[x,o]=h.useState(!1),[v,y]=h.useState(""),[m,S]=h.useState(null),[u,E]=h.useState(!1);if(h.useEffect(()=>{i(!1),o(!1),y((r==null?void 0:r.objective)??""),E(!1)},[r==null?void 0:r.goalId]),p||!r)return null;const g=Fs[r.status],C=["active","verifying","paused","blocked"].includes(r.status),c=r.status==="active"||r.status==="verifying",A=r.status==="paused"||r.status==="blocked",w=m!==null,F=async(M,K)=>{if(!O(f.getState())){S(M);try{await K()}finally{S(null)}}},k=()=>{y(r.objective),o(!0),i(!0)},_=async M=>{M.preventDefault();const K=v.trim();if(!K||K===r.objective){o(!1);return}await F("edit",()=>n(K)),o(!1)},U=async()=>{await F("delete",d),E(!1)};return e.jsxs(e.Fragment,{children:[e.jsx(ye,{delayDuration:250,children:e.jsxs("section",{"aria-label":t("goal.aria.section"),className:"mx-3 mb-1 shrink-0","data-blade-goal-status":r.status,"data-blade-goal-recovery":(N=r.prematureStop)==null?void 0:N.consecutiveCount,"data-blade-goal-recovery-pattern":(T=r.prematureStop)==null?void 0:T.pattern,"data-blade-goal-verification-stall":(D=r.verificationStall)==null?void 0:D.consecutiveCount,"data-blade-goal-frontier-task-list":(I=r.executionFrontier)==null?void 0:I.taskListId,"data-blade-goal-frontier-total":(H=r.executionFrontier)==null?void 0:H.total,"data-blade-goal-frontier-completed":(W=r.executionFrontier)==null?void 0:W.completed,"data-blade-goal-frontier-in-progress":(G=r.executionFrontier)==null?void 0:G.inProgress,"data-blade-goal-frontier-pending":(J=r.executionFrontier)==null?void 0:J.pending,"data-blade-goal-frontier-blocked":(Q=r.executionFrontier)==null?void 0:Q.blocked,"data-blade-goal-frontier-next-task":(R=(Y=r.executionFrontier)==null?void 0:Y.nextTask)==null?void 0:R.id,"data-blade-goal-frontier-digest":(q=r.executionFrontier)==null?void 0:q.digestSha256.slice(0,16),"data-blade-goal-frontier-stall":(j=r.frontierStall)==null?void 0:j.category,"data-blade-goal-frontier-stall-count":(V=r.frontierStall)==null?void 0:V.consecutiveCount,children:[e.jsxs("div",{className:$("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(ut,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500"}):e.jsx(Pt,{className:$("h-3.5 w-3.5 shrink-0",g.accent)}),e.jsx("span",{className:$("h-1.5 w-1.5 shrink-0 rounded-full",g.dot)}),e.jsx("span",{className:$("shrink-0 text-[10px] font-medium leading-none",g.accent),children:r.status==="verifying"?s==="zh"?"验证中":"Verifying":t(g.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:()=>i(M=>!M),"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:[ce(r.tokensUsed),r.tokenBudget!==void 0&&`/${ce(r.tokenBudget)}`]}),e.jsxs("div",{className:"flex shrink-0 items-center",children:[c&&e.jsx(de,{label:t("goal.action.pause"),disabled:w,onClick:()=>void F("pause",a),children:m==="pause"?e.jsx(P,{className:"animate-spin"}):e.jsx(Rt,{})}),A&&e.jsx(de,{label:t("goal.action.resume"),disabled:w,onClick:()=>void F("resume",l),children:m==="resume"?e.jsx(P,{className:"animate-spin"}):e.jsx(Ft,{})}),e.jsx(de,{label:t(C?"goal.action.edit":"goal.action.expand"),disabled:!C&&!b,onClick:C?k:()=>i(M=>!M),children:C?e.jsx(Ze,{}):e.jsx(Et,{})}),e.jsx(de,{label:t("goal.action.delete"),disabled:w,destructive:!0,onClick:()=>E(!0),children:e.jsx(ie,{})})]})]}),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:x?e.jsxs("form",{onSubmit:_,children:[e.jsx("textarea",{id:"goal-objective",value:v,onChange:M=>y(M.target.value),onKeyDown:M=>{M.key==="Escape"&&o(!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:()=>o(!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(Je,{className:"h-3 w-3"}),t("goal.action.cancel")]}),e.jsxs("button",{type:"submit",disabled:!v.trim()||m==="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:[m==="edit"?e.jsx(P,{className:"h-3 w-3 animate-spin"}):e.jsx(xe,{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(It,{className:"h-3 w-3"}),ce(r.tokensUsed),r.tokenBudget!==void 0&&` / ${ce(r.tokenBudget)}`," ",t("goal.metrics.tokens")]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Lt,{className:"h-3 w-3"}),$s(r.timeUsedSeconds)]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(ue,{className:"h-3 w-3"}),r.continuationCount===1?t("goal.metrics.continuationOne",{n:r.continuationCount}):t("goal.metrics.continuationMany",{n:r.continuationCount})]})]}),r.prematureStop&&e.jsxs("div",{className:"mt-2 inline-flex items-center gap-1.5 font-mono text-[10px] text-amber-700 dark:text-amber-300",children:[e.jsx(ue,{className:"h-3 w-3"}),s==="zh"?"恢复提示":"Recovery nudge"," ",r.prematureStop.consecutiveCount," ·"," ",r.prematureStop.pattern.replaceAll("_"," ")]}),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()," ·"," ",((z=r.completionVerification.verifierSessionId)==null?void 0:z.slice(0,12))??"-",r.verificationStall?s==="zh"?` · 重复 ${r.verificationStall.consecutiveCount}/3`:` · repeat ${r.verificationStall.consecutiveCount}/3`:""]}),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(Ue,{open:u,onOpenChange:E,children:e.jsxs(He,{className:"max-w-[400px] border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsx(qe,{children:t("goal.dialog.title")}),e.jsx(ze,{children:t("goal.dialog.description")}),e.jsxs(Ke,{className:"mt-2",children:[e.jsx("button",{type:"button",onClick:()=>E(!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:m==="delete",onClick:()=>void U(),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:[m==="delete"&&e.jsx(P,{className:"w-3.5 h-3.5 animate-spin"}),t("goal.action.delete")]})]})]})})]})}function de({label:t,children:s,disabled:r,destructive:a,onClick:l}){return e.jsxs(we,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":t,disabled:r,onClick:l,className:$("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(he,{side:"top",className:"text-[10px]",children:t})]})}function Is(){const t=L(),s=f(i=>i.currentSessionRef),r=f(i=>i.sessions),a=f(i=>i.messages),l=f(i=>se(i.historySurfaceSelection)),n=h.useMemo(()=>{var x,o,v,y,m;const i=s?(x=mt(r,s))==null?void 0:x.pendingInteraction:void 0;if(i)return i.type;for(let S=a.length-1;S>=0;S-=1){const u=(o=a[S])==null?void 0:o.agentContent;if(((v=u==null?void 0:u.confirmation)==null?void 0:v.status)==="pending")return"permission";if(((y=u==null?void 0:u.question)==null?void 0:y.status)==="pending")return"question";if(((m=u==null?void 0:u.elicitation)==null?void 0:m.status)==="pending")return"elicitation"}return null},[s,a,r]);if(l||!n)return null;const d=()=>{const i=document.querySelector(`[data-pending-interaction="${n}"]`);i==null||i.scrollIntoView({block:"center",behavior:"smooth"}),window.setTimeout(()=>i==null?void 0:i.focus(),250)},p=n==="question",b=n==="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(Se,{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(p?"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(p?"interaction.bar.questionHint":b?"interaction.bar.elicitationHint":"interaction.bar.permissionHint")})]}),e.jsxs("button",{type:"button",onClick:d,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(Ye,{className:"h-3 w-3"}),t("interaction.bar.review")]})]})}const Bs=h.lazy(()=>Ge(()=>import("./MarkdownRenderer-Ct8vtONO.js").then(t=>t.M),__vite__mapDeps([0,1,2,3,4,5,6])).then(t=>({default:t.MarkdownRenderer})));function _s(t){return t<1e3?`${t}ms`:`${(t/1e3).toFixed(1)}s`}function Ps(){const t=L(),s=f(a=>a.sideConversation),r=f(a=>a.dismissSideConversation);return s?e.jsx("section",{"aria-label":t("chat.side.title"),"data-blade-side-conversation":!0,"data-status":s.status,className:"shrink-0 border-y border-[hsl(var(--deck-accent)/0.28)] bg-[hsl(var(--deck-accent-soft)/0.42)]",children:e.jsxs("div",{className:"px-4 py-3 md:px-6",children:[e.jsxs("header",{className:"flex min-h-7 items-start gap-2",children:[e.jsx(_t,{"aria-hidden":!0,className:"mt-0.5 h-4 w-4 shrink-0 text-[hsl(var(--deck-accent))]"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-1",children:[e.jsx("h2",{className:"font-mono text-[11px] font-semibold uppercase text-[hsl(var(--deck-accent))]",children:t("chat.side.title")}),s.durationMs!==void 0&&e.jsxs("span",{className:"inline-flex items-center gap-1 font-mono text-[9.5px] text-[hsl(var(--deck-ink-faint))]",children:[e.jsx($t,{"aria-hidden":!0,className:"h-3 w-3"}),_s(s.durationMs)]})]}),e.jsx("p",{className:"mt-0.5 break-words font-mono text-[11px] leading-4 text-[hsl(var(--deck-ink-muted))]",children:s.question})]}),e.jsx("button",{type:"button",onClick:r,"aria-label":t("chat.side.dismiss"),title:t("chat.side.dismiss"),className:"flex h-7 w-7 shrink-0 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:e.jsx(Je,{"aria-hidden":!0,className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{"aria-live":"polite","aria-busy":s.status==="loading",className:"mt-2 max-h-[min(36vh,320px)] overflow-y-auto border-l-2 border-[hsl(var(--deck-accent)/0.42)] pl-3 pr-1",children:[s.status==="loading"&&e.jsxs("div",{role:"status",className:"flex min-h-9 items-center gap-2 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))]",children:[e.jsx(P,{"aria-hidden":!0,className:"h-3.5 w-3.5 animate-spin text-[hsl(var(--deck-accent))]"}),t("chat.side.loading")]}),s.status==="error"&&e.jsxs("div",{role:"alert",className:"flex min-h-9 items-start gap-2 font-mono text-[11px] leading-5 text-red-700 dark:text-red-300",children:[e.jsx(Se,{"aria-hidden":!0,className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"break-words",children:s.error??t("chat.side.failed")})]}),s.status==="completed"&&s.response&&e.jsx(h.Suspense,{fallback:e.jsx("div",{className:"whitespace-pre-wrap break-words font-mono text-[12px] leading-5 text-[hsl(var(--deck-ink))]",children:s.response}),children:e.jsx(Bs,{content:s.response,className:"text-[12px] leading-5 [&_h1]:text-[14px] [&_h2]:text-[13px] [&_h3]:text-[12px]"})})]})]})}):null}function ke(t){return Number.isFinite(t)?Math.max(0,t):0}function Ls(t){const s=ke(t.totalInputTokens),r=ke(t.cacheReadTokens),a=ke(t.cacheWriteTokens),l=Math.min(r,s),n=Math.min(a,Math.max(0,s-l)),d=Math.max(0,s-l-n),p=s>0&&(r>0||a>0);return{totalInputTokens:s,cacheReadTokens:l,cacheWriteTokens:n,uncachedInputTokens:d,...p?{hitRate:l/s}:{}}}function Os(t){return t===void 0||!Number.isFinite(t)?"—":`${Math.round(Math.max(0,Math.min(1,t))*100)}%`}const Vs={running:"status.phase.running",compacting:"status.phase.compacting",recovering_context:"status.phase.recoveringContext",switching_model:"status.phase.switchingModel",waiting_permission:"status.phase.waitingPermission",error:"status.phase.error",idle:""},Us={model_changed:"status.cacheBreak.model",system_prompt_changed:"status.cacheBreak.system",tools_changed:"status.cacheBreak.tools",request_policy_changed:"status.cacheBreak.policy",ttl_expired:"status.cacheBreak.ttl",server_side:"status.cacheBreak.server"},X=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString(),ae=t=>{const s=Math.max(0,Math.ceil(t/1e3)),r=Math.floor(s/60),a=s%60;return r>0?`${r}m ${a}s`:`${a}s`};function rt(){const t=L(),s=f(w=>w.tokenUsage),r=f(w=>w.isStreaming),a=f(w=>w.agentPhase),l=f(w=>w.providerAdmission),n=f(w=>w.providerCircuit),d=f(w=>w.providerRetry),p=f(w=>w.pendingResume),b=f(w=>w.providerStall),i=f(w=>w.actionStationarity),x=f(w=>w.turnRecovery),o=Vs[a]??"",v=(d==null?void 0:d.delayMs)!==void 0?` · ${Math.max(0,Math.ceil(d.delayMs/1e3))}s`:"",y=(p==null?void 0:p.delayMs)!==void 0?` · retry in ${ae(p.delayMs)}`:"",m=(x==null?void 0:x.state)==="requires_attention"?t("status.recovery.review"):"",S=(x==null?void 0:x.state)==="requires_attention"?t(x.reason==="interrupted_tool_call"?"status.recovery.interruptedTool":"status.recovery.successfulTool"):"",u=m||(i?`${t(i.phase==="halted"?"status.phase.actionStationarityStopped":"status.phase.actionStationarityRecovering")} · ${i.toolName} · ${i.runLength}/${i.haltThreshold}`:n?n.phase==="probe"?"Provider · Recovery probe":`Provider · Circuit open${n.retryAfterMs!==void 0?` · probe in ${ae(n.retryAfterMs)}`:""}${n.recoveryRemainingMs!==void 0?` · ${ae(n.recoveryRemainingMs)}`:""}`:l?`Provider · Capacity queue ${l.queuePosition}/${Math.max(l.queueDepth,l.queuePosition)} · ${l.scope} · ${ae(l.waitMs)}`:d?d.mode==="bounded_foreground"?`Provider · Bounded recovery · ${d.attempt}/${d.maxRetries} · ${ae(d.recoveryRemainingMs??0)}`:`Provider · ${t("chat.error.action.retryingTask")} · ${d.attempt}/${d.maxRetries}${v}`:p?`Recovery attempt ${p.attempt}/${p.maxAttempts}${y}`:b?`${t("status.phase.providerStall")} · ${Math.ceil(b.durationMs/1e3)}s / ${Math.ceil(b.timeoutMs/1e3)}s`:o?t(o):""),E=s.maxContextTokens>0?Math.round(s.totalTokens/s.maxContextTokens*100):0,g=Ls(s),C=Os(g.hitRate),c=Math.min(E,100),A=E>95?"danger":E>80?"warn":"safe";return e.jsxs("div",{"data-chat-status-bar":!0,className:"flex items-center gap-2 border-t border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))]/70 px-3 py-2 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] backdrop-blur-sm sm:gap-4 sm:px-5",children:[e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",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:$("text-[12px] font-medium",A==="safe"&&"text-[hsl(var(--deck-ink))]",A==="warn"&&"text-amber-600 dark:text-amber-400",A==="danger"&&"text-red-600 dark:text-red-400"),children:X(s.totalTokens)}),e.jsxs("span",{className:"text-[hsl(var(--deck-ink-faint))]",children:["/ ",X(s.maxContextTokens)]})]}),s.isDefaultMaxTokens&&e.jsx(ye,{children:e.jsxs(we,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx(Bt,{className:"h-3 w-3 cursor-help text-[hsl(var(--deck-ink-faint))]"})}),e.jsx(he,{side:"top",className:"max-w-[220px]",children:e.jsx("p",{className:"text-xs",children:t("status.tokenLimitTooltip")})})]})}),e.jsxs("div",{className:"relative hidden h-2 w-32 overflow-hidden rounded-sm border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] sm:block","aria-hidden":"true",children:[e.jsx("div",{className:$("absolute inset-y-0 left-0 transition-[width] duration-300",A==="safe"&&"bg-[hsl(var(--deck-accent))]",A==="warn"&&"bg-amber-500",A==="danger"&&"bg-red-500"),style:{width:`${c}%`}}),e.jsx("div",{className:"flex absolute inset-0 pointer-events-none",children:[25,50,75].map(w=>e.jsx("span",{className:"absolute inset-y-0 w-px bg-[hsl(var(--deck-canvas-veil))]/60",style:{left:`${w}%`}},w))})]}),e.jsxs("span",{className:$("w-10 text-right tabular-nums text-[hsl(var(--deck-ink-faint))]",A==="warn"&&"text-amber-600 dark:text-amber-400",A==="danger"&&"text-red-600 dark:text-red-400"),children:[E,"%"]})]}),e.jsx(ye,{children:e.jsxs(we,{children:[e.jsx(Ne,{asChild:!0,children:e.jsxs("div",{className:"flex shrink-0 cursor-help items-baseline gap-2 border-l border-[hsl(var(--deck-hairline))] pl-2 sm:pl-4","data-testid":"prompt-cache-hit-rate","aria-label":`${t("status.cache")} ${C}`,children:[e.jsx("span",{className:"deck-eyebrow text-[hsl(var(--deck-ink-faint))]",children:t("status.cache")}),e.jsx("span",{className:$("tabular-nums",g.hitRate===void 0?"text-[hsl(var(--deck-ink-faint))]":"font-medium text-[hsl(var(--deck-accent))]"),children:C})]})}),e.jsx(he,{side:"top",className:"max-w-[280px]",children:g.hitRate===void 0?e.jsx("p",{className:"text-xs",children:t("status.cacheUnavailable")}):e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsx("p",{children:t("status.cacheTooltip")}),e.jsx("p",{className:"font-mono tabular-nums",children:t("status.cacheDetails",{read:X(g.cacheReadTokens),write:X(g.cacheWriteTokens),uncached:X(g.uncachedInputTokens)})}),s.cacheBreak&&e.jsx("p",{className:"text-[hsl(var(--deck-accent))]",children:t("status.cacheBreak",{reason:t(Us[s.cacheBreak.reason]??"status.cacheBreak.server"),previous:X(s.cacheBreak.previousCacheReadTokens),current:X(s.cacheBreak.cacheReadTokens)})})]})})]})}),e.jsx("div",{className:"flex-1"}),(m||r&&u)&&e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:$("shrink-0",m?"h-2 w-2 rounded-sm bg-amber-500":"deck-pulse-dot")}),e.jsxs("span",{className:$("truncate",m?"text-amber-600 dark:text-amber-400":"text-[hsl(var(--deck-accent))]"),children:[u,S?e.jsxs("span",{className:"hidden sm:inline",children:[" · ",S]}):null]})]})]})}function Hs(){const{locale:t}=We(),s=ht(c=>c.agentTeamsEnabled),r=f(c=>c.teams),a=f(c=>c.currentSessionRef),l=f(c=>se(c.historySurfaceSelection)),n=f(c=>c.loadTeams),[d,p]=h.useState({}),[b,i]=h.useState({}),[x,o]=h.useState({}),[v,y]=h.useState(null),[m,S]=h.useState(null),[u,E]=h.useState(null);if(h.useEffect(()=>{l||n(a??void 0)},[s,a,l,n]),l||!s||!a||r.length===0)return null;const g=async c=>{var w;if(O(f.getState()))return;const A=(w=x[c])==null?void 0:w.trim();if(!(!A||v)){y(c),E(null);try{await Ae.sendMessage(a,c,b[c]??"*",A),o(F=>({...F,[c]:""})),await n(a)}catch(F){E(F instanceof Error?F.message:B(t,"actionFailed"))}finally{y(null)}}},C=async c=>{if(!O(f.getState())&&!m){S(c),E(null);try{await Ae.delete(a,c),await n(a)}catch(A){E(A instanceof Error?A.message:B(t,"actionFailed"))}finally{S(null)}}};return e.jsxs("section",{"aria-label":B(t,"title"),"data-blade-team-panel":!0,className:"shrink-0 border-y border-emerald-300/50 bg-emerald-50/55 dark:border-emerald-800/55 dark:bg-emerald-950/20",children:[u&&e.jsx("div",{role:"alert",className:"border-b border-red-200 bg-red-50 px-4 py-2 font-mono text-[10px] text-red-700 dark:border-red-900 dark:bg-red-950/30 dark:text-red-300 md:px-6",children:u}),r.filter(c=>c.status!=="deleted").map(c=>{var F;const A=d[c.name]??c.status==="running",w=c.tasks.filter(k=>k.status==="completed").length;return e.jsxs("div",{className:"border-b border-emerald-200/40 last:border-0 dark:border-emerald-900/40",children:[e.jsxs("div",{className:"flex min-h-11 items-center gap-2 px-4 py-2 md:px-6",children:[e.jsx("button",{type:"button",onClick:()=>p(k=>({...k,[c.name]:!A})),"aria-label":A?B(t,"collapse"):B(t,"expand"),className:"flex h-7 w-7 items-center justify-center rounded-md text-emerald-700 hover:bg-emerald-100 dark:text-emerald-300 dark:hover:bg-emerald-900/50",children:A?e.jsx(oe,{className:"h-4 w-4"}):e.jsx(le,{className:"h-4 w-4"})}),e.jsx(Ot,{className:"h-4 w-4 shrink-0 text-emerald-700 dark:text-emerald-300"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[e.jsx("h2",{className:"truncate font-mono text-[11px] font-semibold uppercase text-emerald-800 dark:text-emerald-200",children:c.name}),e.jsxs("span",{className:"font-mono text-[9.5px] text-[hsl(var(--deck-ink-faint))]",children:[c.status," · ",c.members.length-1," ",B(t,"members")," · ",w,"/",c.tasks.length," ",B(t,"tasks")]})]}),c.description&&e.jsx("p",{className:"truncate font-mono text-[10px] text-[hsl(var(--deck-ink-muted))]",children:c.description})]}),e.jsx("button",{type:"button",onClick:()=>void C(c.name),disabled:m===c.name,"aria-label":B(t,"delete"),title:B(t,"delete"),className:"flex h-7 w-7 items-center justify-center rounded-md text-[hsl(var(--deck-ink-faint))] hover:bg-red-50 hover:text-red-600 disabled:opacity-40 dark:hover:bg-red-950/40",children:e.jsx(ie,{className:"h-3.5 w-3.5"})})]}),A&&e.jsxs("div",{className:"max-h-[min(40vh,360px)] overflow-y-auto border-t border-emerald-200/40 px-4 py-3 md:px-6 dark:border-emerald-900/40",children:[e.jsxs("div",{className:"grid gap-x-6 gap-y-2 lg:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"mb-1 font-mono text-[9.5px] font-semibold uppercase text-[hsl(var(--deck-ink-faint))]",children:B(t,"members")}),c.members.map(k=>e.jsxs("div",{className:"flex min-h-7 items-center gap-2 border-b border-[hsl(var(--deck-hairline)/0.55)] py-1 last:border-0",children:[e.jsx("span",{"aria-label":k.status,className:`h-1.5 w-1.5 shrink-0 rounded-full ${k.status==="running"?"bg-emerald-500":k.status==="completed"||k.status==="leader"?"bg-sky-500":k.status==="failed"?"bg-red-500":"bg-zinc-400"}`}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[10.5px] text-[hsl(var(--deck-ink))]",children:k.name}),e.jsx("span",{className:"font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:k.subagentType}),k.worktreePath&&e.jsx(Oe,{className:"h-3 w-3 text-[hsl(var(--deck-ink-faint))]","aria-label":B(t,"worktree")})]},k.id))]}),e.jsxs("div",{children:[e.jsx("h3",{className:"mb-1 font-mono text-[9.5px] font-semibold uppercase text-[hsl(var(--deck-ink-faint))]",children:B(t,"tasks")}),c.tasks.length===0?e.jsx("p",{className:"font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:B(t,"noTasks")}):c.tasks.map(k=>e.jsxs("div",{className:"flex min-h-7 items-center gap-2 border-b border-[hsl(var(--deck-hairline)/0.55)] py-1 last:border-0",children:[e.jsxs("span",{className:"w-5 shrink-0 font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:["#",k.id]}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[10.5px] text-[hsl(var(--deck-ink))]",children:k.subject}),e.jsx("span",{className:"font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:k.status})]},k.id))]})]}),c.peerMessagingEnabled&&e.jsxs("div",{className:"mt-3 flex items-center gap-2 border-t border-emerald-200/40 pt-3 dark:border-emerald-900/40",children:[e.jsxs("select",{"aria-label":B(t,"recipient"),value:b[c.name]??"*",onChange:k=>i(_=>({..._,[c.name]:k.target.value})),className:"h-8 max-w-32 rounded-md border border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-surface))] px-2 font-mono text-[10px]",children:[e.jsx("option",{value:"*",children:B(t,"broadcast")}),c.members.filter(k=>k.status!=="leader").map(k=>e.jsx("option",{value:k.name,children:k.name},k.id))]}),e.jsx("input",{value:x[c.name]??"",onChange:k=>o(_=>({..._,[c.name]:k.target.value})),onKeyDown:k=>{k.key==="Enter"&&g(c.name)},placeholder:B(t,"messagePlaceholder"),className:"h-8 min-w-0 flex-1 rounded-md border border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-surface))] px-2 font-mono text-[10.5px] outline-none focus:border-emerald-500"}),e.jsx("button",{type:"button",onClick:()=>void g(c.name),disabled:!((F=x[c.name])!=null&&F.trim())||v===c.name,"aria-label":B(t,"send"),title:B(t,"send"),className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-emerald-700 text-white hover:bg-emerald-800 disabled:opacity-40 dark:bg-emerald-600",children:e.jsx(Ve,{className:"h-3.5 w-3.5"})})]})]})]},c.name)})]})}function qs(t){const s=[...t].reverse().find(l=>l.role==="user");if(!s)return null;if(typeof s.content=="string")return{content:s.content,attachments:[]};const r=s.content.filter(l=>l.type==="text").map(l=>l.text).join(`
|
|
52
|
+
`);return e.jsx("div",{"data-chat-message-id":t.id,"data-chat-role":"user","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:"$"}),m]}),e.jsx(Te,{status:S})]}),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:u||"(no output)"}),typeof o.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 ",o.exitCode,typeof o.durationMs=="number"?` · ${(o.durationMs/1e3).toFixed(3)}s`:"",o.truncated===!0?" · truncated":""]})]})})}const{text:v,images:y}=os(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:v,label:"Copy message"})}),e.jsxs("div",{className:"bg-[hsl(var(--deck-surface-2))] rounded-lg px-4 py-3 max-w-[85%]",children:[v&&e.jsx("p",{className:"text-[14px] text-[hsl(var(--deck-ink))] font-mono leading-relaxed whitespace-pre-wrap",children:v}),y.length>0&&e.jsx("div",{className:$("grid gap-2",y.length===1?"grid-cols-1 mt-0":"grid-cols-2 mt-3"),children:y.map((m,S)=>e.jsx("img",{src:m,alt:`attachment-${S+1}`,className:"object-cover w-full max-h-64 rounded-md"},`${m}-${S}`))})]}),e.jsx(is,{})]})}const l=ls(t),n=Kt((i=t.metadata)==null?void 0:i.codeReview),d=ss((x=t.metadata)==null?void 0:x.structuredOutput);return e.jsxs("div",{"data-chat-message-id":t.id,"data-chat-role":"assistant",className:$("group flex gap-4 justify-start w-full",s?"p-4":"px-4 pt-0 pb-3"),children:[s?e.jsx(ns,{}):e.jsx("div",{className:"w-8 shrink-0"}),e.jsxs("div",{className:"overflow-hidden flex-1 min-w-0",children:[n?e.jsx(Wt,{report:n}):d?e.jsx(rs,{report:d}):e.jsx(gs,{message:t}),!d&&l.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:l,label:"Copy response"})})]})]})}const js=h.memo(ks);function ys(t,s,r){return Math.max(0,t+(r-s))}function ws(t,s,r){return Math.min(s,Math.max(0,t)+Math.max(0,r))}function Ns(t,s,r,a){const l=new Map(t.filter(d=>!!d.id).map(d=>[d.id,d])),n=new Set(r);for(const d of s){if(!d.id)continue;const p=l.get(d.id);p!==d&&(!p||!a||a(p)!==a(d))&&n.add(d.id)}return n}function _e(t,s){return t?t.querySelector(`[data-chat-message-id="${CSS.escape(s)}"]`):null}function Ss({turns:t,viewportRef:s,containerRef:r,onRevealTurn:a}){const l=L(),[n,d]=h.useState(null),[p,b]=h.useState(!1),i=h.useRef(null),x=h.useCallback(()=>{var u;const v=s.current,y=r.current;if(!v||!y||t.length===0)return;const m=v.getBoundingClientRect().top;let S=((u=t[0])==null?void 0:u.id)??null;for(const E of t){const g=_e(y,E.id);if(g)if(g.getBoundingClientRect().top-m<=24)S=E.id;else break}d(S)},[t,s,r]);h.useEffect(()=>{const v=s.current;if(!v)return;const y=()=>{i.current===null&&(i.current=window.requestAnimationFrame(()=>{i.current=null,x()}))};return x(),v.addEventListener("scroll",y,{passive:!0}),()=>{v.removeEventListener("scroll",y),i.current!==null&&(window.cancelAnimationFrame(i.current),i.current=null)}},[x,s]);const o=h.useCallback(v=>{const y=()=>{const S=_e(r.current,v.id);S&&(S.scrollIntoView({behavior:"smooth",block:"start"}),d(v.id))};a(v.index)?y():window.requestAnimationFrame(()=>window.requestAnimationFrame(y))},[r,a]);return t.length<2?null:e.jsx("nav",{"aria-label":l("chat.turns.aria"),className:"absolute right-1 top-1/2 z-20 hidden -translate-y-1/2 sm:block",onMouseEnter:()=>b(!0),onMouseLeave:()=>b(!1),onFocusCapture:()=>b(!0),onBlurCapture:v=>{v.currentTarget.contains(v.relatedTarget)||b(!1)},children:e.jsxs("div",{className:"relative flex items-center justify-end",children:[e.jsx("ul",{className:$("flex flex-col items-center gap-2 py-2 transition-opacity",p?"opacity-0":"opacity-100"),"aria-hidden":p,children:t.map(v=>e.jsx("li",{children:e.jsx("span",{className:$("block rounded-full transition-all",v.id===n?"h-2 w-2 bg-[hsl(var(--deck-accent))]":"h-1.5 w-1.5 bg-[hsl(var(--deck-ink-faint))]/40")})},v.id))}),e.jsx("div",{className:$("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",p?"pointer-events-auto translate-x-0 opacity-100":"pointer-events-none translate-x-2 opacity-0"),children:t.map((v,y)=>e.jsxs("button",{type:"button",onClick:()=>o(v),className:$("flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left transition-colors",v.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:$("mt-1 h-1.5 w-1.5 shrink-0 rounded-full",v.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:l("chat.turns.label",{n:y+1})}),e.jsx("span",{className:"line-clamp-2 text-[12px] leading-4",children:v.preview})]})]},v.id))})]})})}const Pe=80;function Cs(t){return typeof t=="string"?t:Array.isArray(t)?t.filter(s=>s.type==="text").map(s=>s.text).join(" "):""}function Es(t){const s=Cs(t).replace(/\s+/g," ").trim();return s?s.length>Pe?`${s.slice(0,Pe-1)}…`:s:""}function Ts(t){const s=[];for(let r=0;r<t.length;r+=1){const a=t[r];if(a.role!=="user"||!a.id)continue;const l=Es(a.content);l&&s.push({id:a.id,index:r,preview:l})}return s}const ve=120,ge=80,Ms=96;function re(t){return(t==null?void 0:t.querySelector("[data-radix-scroll-area-viewport]"))??null}function As(t){return JSON.stringify([t.role,t.content,t.metadata,t.agentContent])}function Rs({messages:t,isLoading:s}){const r=L(),a=h.useRef(null),l=h.useRef(null),n=h.useRef(!0),d=h.useRef(!1),p=h.useRef(t),b=h.useRef(t),i=h.useRef(new Set),x=h.useRef(t.length),o=h.useRef(null),[v,y]=h.useState(ve),[m,S]=h.useState(!1),[u,E]=h.useState(0),g=t.length>0;p.current=t,h.useEffect(()=>{const N=re(a.current);if(!N||d.current&&!n.current)return;const T=window.requestAnimationFrame(()=>{N.scrollTop=N.scrollHeight,d.current=!0,n.current=!0,i.current=new Set,E(0),S(!1)});return()=>window.cancelAnimationFrame(T)},[t]),h.useEffect(()=>{const N=re(a.current);if(!N)return;l.current=N;const T=()=>{if(!d.current)return;const I=N.scrollHeight-N.scrollTop-N.clientHeight<=Ms,H=n.current;n.current=I,S(!I),I?(i.current=new Set,E(0)):H&&(b.current=p.current,i.current=new Set,E(0))};return T(),N.addEventListener("scroll",T,{passive:!0}),()=>N.removeEventListener("scroll",T)},[g,s]),h.useEffect(()=>{const N=b.current;if(b.current=t,n.current){i.current.size>0&&(i.current=new Set,E(0));return}const T=Ns(N,t,i.current,As);i.current=T,E(T.size)},[t]),h.useEffect(()=>{const N=x.current;x.current=t.length,y(T=>T>=N&&t.length>N?t.length:Math.min(Math.max(T,ve),t.length||ve))},[t.length]);const C=Math.max(t.length-v,0),c=C,A=h.useMemo(()=>t.slice(c),[t,c]),w=h.useMemo(()=>Ts(t),[t]);if(h.useLayoutEffect(()=>{var D;const N=o.current;if(!N)return;const T=re(a.current);if(o.current=null,!!T){if((D=N.element)!=null&&D.isConnected){const I=N.element.getBoundingClientRect().top-N.viewportTop;T.scrollTop+=I;return}T.scrollTop=ys(N.scrollTop,N.scrollHeight,T.scrollHeight)}},[v]),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(je,{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(dt,{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((N,T)=>e.jsxs("div",{className:$("flex gap-3",T%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:`${N}%`,animationDelay:`${T*120}ms`}})]},N))})]})});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(je,{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 F=()=>{const N=re(a.current);N&&(N.scrollTop=N.scrollHeight,n.current=!0,d.current=!0,i.current=new Set,E(0),S(!1))},k=()=>{var T;const N=re(a.current);if(N){const D=((T=a.current)==null?void 0:T.querySelector("[data-chat-message-id]"))??null;o.current={element:D,viewportTop:(D==null?void 0:D.getBoundingClientRect().top)??0,scrollHeight:N.scrollHeight,scrollTop:N.scrollTop}}y(D=>ws(D,t.length,ge))},_=N=>N>=c?!0:(y(t.length),!1),U=u===1?r("chat.list.unreadMessage"):r("chat.list.unreadMessages",{count:u});return e.jsxs("div",{ref:a,className:"relative flex-1 min-h-0",children:[e.jsx(Ct,{className:"h-full",children:e.jsxs("div",{className:"flex flex-col px-4 pb-4 w-full md:px-6",children:[C>0&&e.jsx("div",{className:"flex justify-center py-3",children:e.jsx("button",{type:"button",onClick:k,"aria-label":r("chat.list.showEarlierWithRemaining",{count:Math.min(C,ge),remaining:C}),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(C,ge)})})}),A.map((N,T)=>{const D=c+T,I=D>0?t[D-1]:null,H=!I||I.role!==N.role||I.role==="user";return e.jsx(js,{message:N,showAvatar:H},N.id||`msg-${D}`)})]})}),e.jsx(Ss,{turns:w,viewportRef:l,containerRef:a,onRevealTurn:_}),m&&e.jsxs("button",{type:"button",onClick:F,"aria-live":"polite","aria-label":u>0?U:r("chat.list.jumpLatest"),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(Ye,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}),u>0?U:r("chat.list.jumpLatest")]})]})}const st=h.memo(Rs),ye=Tt,we=Mt,Ne=At,he=h.forwardRef(({className:t,sideOffset:s=4,...r},a)=>e.jsx(Xe,{ref:a,sideOffset:s,className:$("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}));he.displayName=Xe.displayName;const Fs={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 ce(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t)}function $s(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 Ds(){var N,T,D,I,H,W,G,J,Q,Y,R,q,j,V,z;const t=L(),{locale:s}=We(),r=f(M=>M.goal),a=f(M=>M.pauseGoal),l=f(M=>M.resumeGoal),n=f(M=>M.editGoal),d=f(M=>M.clearGoal),p=f(M=>se(M.historySurfaceSelection)),[b,i]=h.useState(!1),[x,o]=h.useState(!1),[v,y]=h.useState(""),[m,S]=h.useState(null),[u,E]=h.useState(!1);if(h.useEffect(()=>{i(!1),o(!1),y((r==null?void 0:r.objective)??""),E(!1)},[r==null?void 0:r.goalId]),p||!r)return null;const g=Fs[r.status],C=["active","verifying","paused","blocked"].includes(r.status),c=r.status==="active"||r.status==="verifying",A=r.status==="paused"||r.status==="blocked",w=m!==null,F=async(M,K)=>{if(!O(f.getState())){S(M);try{await K()}finally{S(null)}}},k=()=>{y(r.objective),o(!0),i(!0)},_=async M=>{M.preventDefault();const K=v.trim();if(!K||K===r.objective){o(!1);return}await F("edit",()=>n(K)),o(!1)},U=async()=>{await F("delete",d),E(!1)};return e.jsxs(e.Fragment,{children:[e.jsx(ye,{delayDuration:250,children:e.jsxs("section",{"aria-label":t("goal.aria.section"),className:"mx-3 mb-1 shrink-0","data-blade-goal-status":r.status,"data-blade-goal-recovery":(N=r.prematureStop)==null?void 0:N.consecutiveCount,"data-blade-goal-recovery-pattern":(T=r.prematureStop)==null?void 0:T.pattern,"data-blade-goal-verification-stall":(D=r.verificationStall)==null?void 0:D.consecutiveCount,"data-blade-goal-frontier-task-list":(I=r.executionFrontier)==null?void 0:I.taskListId,"data-blade-goal-frontier-total":(H=r.executionFrontier)==null?void 0:H.total,"data-blade-goal-frontier-completed":(W=r.executionFrontier)==null?void 0:W.completed,"data-blade-goal-frontier-in-progress":(G=r.executionFrontier)==null?void 0:G.inProgress,"data-blade-goal-frontier-pending":(J=r.executionFrontier)==null?void 0:J.pending,"data-blade-goal-frontier-blocked":(Q=r.executionFrontier)==null?void 0:Q.blocked,"data-blade-goal-frontier-next-task":(R=(Y=r.executionFrontier)==null?void 0:Y.nextTask)==null?void 0:R.id,"data-blade-goal-frontier-digest":(q=r.executionFrontier)==null?void 0:q.digestSha256.slice(0,16),"data-blade-goal-frontier-stall":(j=r.frontierStall)==null?void 0:j.category,"data-blade-goal-frontier-stall-count":(V=r.frontierStall)==null?void 0:V.consecutiveCount,children:[e.jsxs("div",{className:$("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(ut,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500"}):e.jsx(Pt,{className:$("h-3.5 w-3.5 shrink-0",g.accent)}),e.jsx("span",{className:$("h-1.5 w-1.5 shrink-0 rounded-full",g.dot)}),e.jsx("span",{className:$("shrink-0 text-[10px] font-medium leading-none",g.accent),children:r.status==="verifying"?s==="zh"?"验证中":"Verifying":t(g.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:()=>i(M=>!M),"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:[ce(r.tokensUsed),r.tokenBudget!==void 0&&`/${ce(r.tokenBudget)}`]}),e.jsxs("div",{className:"flex shrink-0 items-center",children:[c&&e.jsx(de,{label:t("goal.action.pause"),disabled:w,onClick:()=>void F("pause",a),children:m==="pause"?e.jsx(P,{className:"animate-spin"}):e.jsx(Rt,{})}),A&&e.jsx(de,{label:t("goal.action.resume"),disabled:w,onClick:()=>void F("resume",l),children:m==="resume"?e.jsx(P,{className:"animate-spin"}):e.jsx(Ft,{})}),e.jsx(de,{label:t(C?"goal.action.edit":"goal.action.expand"),disabled:!C&&!b,onClick:C?k:()=>i(M=>!M),children:C?e.jsx(Ze,{}):e.jsx(Et,{})}),e.jsx(de,{label:t("goal.action.delete"),disabled:w,destructive:!0,onClick:()=>E(!0),children:e.jsx(ie,{})})]})]}),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:x?e.jsxs("form",{onSubmit:_,children:[e.jsx("textarea",{id:"goal-objective",value:v,onChange:M=>y(M.target.value),onKeyDown:M=>{M.key==="Escape"&&o(!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:()=>o(!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(Je,{className:"h-3 w-3"}),t("goal.action.cancel")]}),e.jsxs("button",{type:"submit",disabled:!v.trim()||m==="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:[m==="edit"?e.jsx(P,{className:"h-3 w-3 animate-spin"}):e.jsx(xe,{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(It,{className:"h-3 w-3"}),ce(r.tokensUsed),r.tokenBudget!==void 0&&` / ${ce(r.tokenBudget)}`," ",t("goal.metrics.tokens")]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Lt,{className:"h-3 w-3"}),$s(r.timeUsedSeconds)]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(ue,{className:"h-3 w-3"}),r.continuationCount===1?t("goal.metrics.continuationOne",{n:r.continuationCount}):t("goal.metrics.continuationMany",{n:r.continuationCount})]})]}),r.prematureStop&&e.jsxs("div",{className:"mt-2 inline-flex items-center gap-1.5 font-mono text-[10px] text-amber-700 dark:text-amber-300",children:[e.jsx(ue,{className:"h-3 w-3"}),s==="zh"?"恢复提示":"Recovery nudge"," ",r.prematureStop.consecutiveCount," ·"," ",r.prematureStop.pattern.replaceAll("_"," ")]}),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()," ·"," ",((z=r.completionVerification.verifierSessionId)==null?void 0:z.slice(0,12))??"-",r.verificationStall?s==="zh"?` · 重复 ${r.verificationStall.consecutiveCount}/3`:` · repeat ${r.verificationStall.consecutiveCount}/3`:""]}),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(Ue,{open:u,onOpenChange:E,children:e.jsxs(He,{className:"max-w-[400px] border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsx(qe,{children:t("goal.dialog.title")}),e.jsx(ze,{children:t("goal.dialog.description")}),e.jsxs(Ke,{className:"mt-2",children:[e.jsx("button",{type:"button",onClick:()=>E(!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:m==="delete",onClick:()=>void U(),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:[m==="delete"&&e.jsx(P,{className:"w-3.5 h-3.5 animate-spin"}),t("goal.action.delete")]})]})]})})]})}function de({label:t,children:s,disabled:r,destructive:a,onClick:l}){return e.jsxs(we,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":t,disabled:r,onClick:l,className:$("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(he,{side:"top",className:"text-[10px]",children:t})]})}function Is(){const t=L(),s=f(i=>i.currentSessionRef),r=f(i=>i.sessions),a=f(i=>i.messages),l=f(i=>se(i.historySurfaceSelection)),n=h.useMemo(()=>{var x,o,v,y,m;const i=s?(x=mt(r,s))==null?void 0:x.pendingInteraction:void 0;if(i)return i.type;for(let S=a.length-1;S>=0;S-=1){const u=(o=a[S])==null?void 0:o.agentContent;if(((v=u==null?void 0:u.confirmation)==null?void 0:v.status)==="pending")return"permission";if(((y=u==null?void 0:u.question)==null?void 0:y.status)==="pending")return"question";if(((m=u==null?void 0:u.elicitation)==null?void 0:m.status)==="pending")return"elicitation"}return null},[s,a,r]);if(l||!n)return null;const d=()=>{const i=document.querySelector(`[data-pending-interaction="${n}"]`);i==null||i.scrollIntoView({block:"center",behavior:"smooth"}),window.setTimeout(()=>i==null?void 0:i.focus(),250)},p=n==="question",b=n==="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(Se,{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(p?"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(p?"interaction.bar.questionHint":b?"interaction.bar.elicitationHint":"interaction.bar.permissionHint")})]}),e.jsxs("button",{type:"button",onClick:d,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(Ye,{className:"h-3 w-3"}),t("interaction.bar.review")]})]})}const Bs=h.lazy(()=>Ge(()=>import("./MarkdownRenderer-zKto-Pty.js").then(t=>t.M),__vite__mapDeps([0,1,2,3,4,5,6])).then(t=>({default:t.MarkdownRenderer})));function _s(t){return t<1e3?`${t}ms`:`${(t/1e3).toFixed(1)}s`}function Ps(){const t=L(),s=f(a=>a.sideConversation),r=f(a=>a.dismissSideConversation);return s?e.jsx("section",{"aria-label":t("chat.side.title"),"data-blade-side-conversation":!0,"data-status":s.status,className:"shrink-0 border-y border-[hsl(var(--deck-accent)/0.28)] bg-[hsl(var(--deck-accent-soft)/0.42)]",children:e.jsxs("div",{className:"px-4 py-3 md:px-6",children:[e.jsxs("header",{className:"flex min-h-7 items-start gap-2",children:[e.jsx(_t,{"aria-hidden":!0,className:"mt-0.5 h-4 w-4 shrink-0 text-[hsl(var(--deck-accent))]"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-1",children:[e.jsx("h2",{className:"font-mono text-[11px] font-semibold uppercase text-[hsl(var(--deck-accent))]",children:t("chat.side.title")}),s.durationMs!==void 0&&e.jsxs("span",{className:"inline-flex items-center gap-1 font-mono text-[9.5px] text-[hsl(var(--deck-ink-faint))]",children:[e.jsx($t,{"aria-hidden":!0,className:"h-3 w-3"}),_s(s.durationMs)]})]}),e.jsx("p",{className:"mt-0.5 break-words font-mono text-[11px] leading-4 text-[hsl(var(--deck-ink-muted))]",children:s.question})]}),e.jsx("button",{type:"button",onClick:r,"aria-label":t("chat.side.dismiss"),title:t("chat.side.dismiss"),className:"flex h-7 w-7 shrink-0 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:e.jsx(Je,{"aria-hidden":!0,className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{"aria-live":"polite","aria-busy":s.status==="loading",className:"mt-2 max-h-[min(36vh,320px)] overflow-y-auto border-l-2 border-[hsl(var(--deck-accent)/0.42)] pl-3 pr-1",children:[s.status==="loading"&&e.jsxs("div",{role:"status",className:"flex min-h-9 items-center gap-2 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))]",children:[e.jsx(P,{"aria-hidden":!0,className:"h-3.5 w-3.5 animate-spin text-[hsl(var(--deck-accent))]"}),t("chat.side.loading")]}),s.status==="error"&&e.jsxs("div",{role:"alert",className:"flex min-h-9 items-start gap-2 font-mono text-[11px] leading-5 text-red-700 dark:text-red-300",children:[e.jsx(Se,{"aria-hidden":!0,className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"break-words",children:s.error??t("chat.side.failed")})]}),s.status==="completed"&&s.response&&e.jsx(h.Suspense,{fallback:e.jsx("div",{className:"whitespace-pre-wrap break-words font-mono text-[12px] leading-5 text-[hsl(var(--deck-ink))]",children:s.response}),children:e.jsx(Bs,{content:s.response,className:"text-[12px] leading-5 [&_h1]:text-[14px] [&_h2]:text-[13px] [&_h3]:text-[12px]"})})]})]})}):null}function ke(t){return Number.isFinite(t)?Math.max(0,t):0}function Ls(t){const s=ke(t.totalInputTokens),r=ke(t.cacheReadTokens),a=ke(t.cacheWriteTokens),l=Math.min(r,s),n=Math.min(a,Math.max(0,s-l)),d=Math.max(0,s-l-n),p=s>0&&(r>0||a>0);return{totalInputTokens:s,cacheReadTokens:l,cacheWriteTokens:n,uncachedInputTokens:d,...p?{hitRate:l/s}:{}}}function Os(t){return t===void 0||!Number.isFinite(t)?"—":`${Math.round(Math.max(0,Math.min(1,t))*100)}%`}const Vs={running:"status.phase.running",compacting:"status.phase.compacting",recovering_context:"status.phase.recoveringContext",switching_model:"status.phase.switchingModel",waiting_permission:"status.phase.waitingPermission",error:"status.phase.error",idle:""},Us={model_changed:"status.cacheBreak.model",system_prompt_changed:"status.cacheBreak.system",tools_changed:"status.cacheBreak.tools",request_policy_changed:"status.cacheBreak.policy",ttl_expired:"status.cacheBreak.ttl",server_side:"status.cacheBreak.server"},X=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString(),ae=t=>{const s=Math.max(0,Math.ceil(t/1e3)),r=Math.floor(s/60),a=s%60;return r>0?`${r}m ${a}s`:`${a}s`};function rt(){const t=L(),s=f(w=>w.tokenUsage),r=f(w=>w.isStreaming),a=f(w=>w.agentPhase),l=f(w=>w.providerAdmission),n=f(w=>w.providerCircuit),d=f(w=>w.providerRetry),p=f(w=>w.pendingResume),b=f(w=>w.providerStall),i=f(w=>w.actionStationarity),x=f(w=>w.turnRecovery),o=Vs[a]??"",v=(d==null?void 0:d.delayMs)!==void 0?` · ${Math.max(0,Math.ceil(d.delayMs/1e3))}s`:"",y=(p==null?void 0:p.delayMs)!==void 0?` · retry in ${ae(p.delayMs)}`:"",m=(x==null?void 0:x.state)==="requires_attention"?t("status.recovery.review"):"",S=(x==null?void 0:x.state)==="requires_attention"?t(x.reason==="interrupted_tool_call"?"status.recovery.interruptedTool":"status.recovery.successfulTool"):"",u=m||(i?`${t(i.phase==="halted"?"status.phase.actionStationarityStopped":"status.phase.actionStationarityRecovering")} · ${i.toolName} · ${i.runLength}/${i.haltThreshold}`:n?n.phase==="probe"?"Provider · Recovery probe":`Provider · Circuit open${n.retryAfterMs!==void 0?` · probe in ${ae(n.retryAfterMs)}`:""}${n.recoveryRemainingMs!==void 0?` · ${ae(n.recoveryRemainingMs)}`:""}`:l?`Provider · Capacity queue ${l.queuePosition}/${Math.max(l.queueDepth,l.queuePosition)} · ${l.scope} · ${ae(l.waitMs)}`:d?d.mode==="bounded_foreground"?`Provider · Bounded recovery · ${d.attempt}/${d.maxRetries} · ${ae(d.recoveryRemainingMs??0)}`:`Provider · ${t("chat.error.action.retryingTask")} · ${d.attempt}/${d.maxRetries}${v}`:p?`Recovery attempt ${p.attempt}/${p.maxAttempts}${y}`:b?`${t("status.phase.providerStall")} · ${Math.ceil(b.durationMs/1e3)}s / ${Math.ceil(b.timeoutMs/1e3)}s`:o?t(o):""),E=s.maxContextTokens>0?Math.round(s.totalTokens/s.maxContextTokens*100):0,g=Ls(s),C=Os(g.hitRate),c=Math.min(E,100),A=E>95?"danger":E>80?"warn":"safe";return e.jsxs("div",{"data-chat-status-bar":!0,className:"flex items-center gap-2 border-t border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))]/70 px-3 py-2 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] backdrop-blur-sm sm:gap-4 sm:px-5",children:[e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",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:$("text-[12px] font-medium",A==="safe"&&"text-[hsl(var(--deck-ink))]",A==="warn"&&"text-amber-600 dark:text-amber-400",A==="danger"&&"text-red-600 dark:text-red-400"),children:X(s.totalTokens)}),e.jsxs("span",{className:"text-[hsl(var(--deck-ink-faint))]",children:["/ ",X(s.maxContextTokens)]})]}),s.isDefaultMaxTokens&&e.jsx(ye,{children:e.jsxs(we,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx(Bt,{className:"h-3 w-3 cursor-help text-[hsl(var(--deck-ink-faint))]"})}),e.jsx(he,{side:"top",className:"max-w-[220px]",children:e.jsx("p",{className:"text-xs",children:t("status.tokenLimitTooltip")})})]})}),e.jsxs("div",{className:"relative hidden h-2 w-32 overflow-hidden rounded-sm border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] sm:block","aria-hidden":"true",children:[e.jsx("div",{className:$("absolute inset-y-0 left-0 transition-[width] duration-300",A==="safe"&&"bg-[hsl(var(--deck-accent))]",A==="warn"&&"bg-amber-500",A==="danger"&&"bg-red-500"),style:{width:`${c}%`}}),e.jsx("div",{className:"flex absolute inset-0 pointer-events-none",children:[25,50,75].map(w=>e.jsx("span",{className:"absolute inset-y-0 w-px bg-[hsl(var(--deck-canvas-veil))]/60",style:{left:`${w}%`}},w))})]}),e.jsxs("span",{className:$("w-10 text-right tabular-nums text-[hsl(var(--deck-ink-faint))]",A==="warn"&&"text-amber-600 dark:text-amber-400",A==="danger"&&"text-red-600 dark:text-red-400"),children:[E,"%"]})]}),e.jsx(ye,{children:e.jsxs(we,{children:[e.jsx(Ne,{asChild:!0,children:e.jsxs("div",{className:"flex shrink-0 cursor-help items-baseline gap-2 border-l border-[hsl(var(--deck-hairline))] pl-2 sm:pl-4","data-testid":"prompt-cache-hit-rate","aria-label":`${t("status.cache")} ${C}`,children:[e.jsx("span",{className:"deck-eyebrow text-[hsl(var(--deck-ink-faint))]",children:t("status.cache")}),e.jsx("span",{className:$("tabular-nums",g.hitRate===void 0?"text-[hsl(var(--deck-ink-faint))]":"font-medium text-[hsl(var(--deck-accent))]"),children:C})]})}),e.jsx(he,{side:"top",className:"max-w-[280px]",children:g.hitRate===void 0?e.jsx("p",{className:"text-xs",children:t("status.cacheUnavailable")}):e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsx("p",{children:t("status.cacheTooltip")}),e.jsx("p",{className:"font-mono tabular-nums",children:t("status.cacheDetails",{read:X(g.cacheReadTokens),write:X(g.cacheWriteTokens),uncached:X(g.uncachedInputTokens)})}),s.cacheBreak&&e.jsx("p",{className:"text-[hsl(var(--deck-accent))]",children:t("status.cacheBreak",{reason:t(Us[s.cacheBreak.reason]??"status.cacheBreak.server"),previous:X(s.cacheBreak.previousCacheReadTokens),current:X(s.cacheBreak.cacheReadTokens)})})]})})]})}),e.jsx("div",{className:"flex-1"}),(m||r&&u)&&e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:$("shrink-0",m?"h-2 w-2 rounded-sm bg-amber-500":"deck-pulse-dot")}),e.jsxs("span",{className:$("truncate",m?"text-amber-600 dark:text-amber-400":"text-[hsl(var(--deck-accent))]"),children:[u,S?e.jsxs("span",{className:"hidden sm:inline",children:[" · ",S]}):null]})]})]})}function Hs(){const{locale:t}=We(),s=ht(c=>c.agentTeamsEnabled),r=f(c=>c.teams),a=f(c=>c.currentSessionRef),l=f(c=>se(c.historySurfaceSelection)),n=f(c=>c.loadTeams),[d,p]=h.useState({}),[b,i]=h.useState({}),[x,o]=h.useState({}),[v,y]=h.useState(null),[m,S]=h.useState(null),[u,E]=h.useState(null);if(h.useEffect(()=>{l||n(a??void 0)},[s,a,l,n]),l||!s||!a||r.length===0)return null;const g=async c=>{var w;if(O(f.getState()))return;const A=(w=x[c])==null?void 0:w.trim();if(!(!A||v)){y(c),E(null);try{await Ae.sendMessage(a,c,b[c]??"*",A),o(F=>({...F,[c]:""})),await n(a)}catch(F){E(F instanceof Error?F.message:B(t,"actionFailed"))}finally{y(null)}}},C=async c=>{if(!O(f.getState())&&!m){S(c),E(null);try{await Ae.delete(a,c),await n(a)}catch(A){E(A instanceof Error?A.message:B(t,"actionFailed"))}finally{S(null)}}};return e.jsxs("section",{"aria-label":B(t,"title"),"data-blade-team-panel":!0,className:"shrink-0 border-y border-emerald-300/50 bg-emerald-50/55 dark:border-emerald-800/55 dark:bg-emerald-950/20",children:[u&&e.jsx("div",{role:"alert",className:"border-b border-red-200 bg-red-50 px-4 py-2 font-mono text-[10px] text-red-700 dark:border-red-900 dark:bg-red-950/30 dark:text-red-300 md:px-6",children:u}),r.filter(c=>c.status!=="deleted").map(c=>{var F;const A=d[c.name]??c.status==="running",w=c.tasks.filter(k=>k.status==="completed").length;return e.jsxs("div",{className:"border-b border-emerald-200/40 last:border-0 dark:border-emerald-900/40",children:[e.jsxs("div",{className:"flex min-h-11 items-center gap-2 px-4 py-2 md:px-6",children:[e.jsx("button",{type:"button",onClick:()=>p(k=>({...k,[c.name]:!A})),"aria-label":A?B(t,"collapse"):B(t,"expand"),className:"flex h-7 w-7 items-center justify-center rounded-md text-emerald-700 hover:bg-emerald-100 dark:text-emerald-300 dark:hover:bg-emerald-900/50",children:A?e.jsx(oe,{className:"h-4 w-4"}):e.jsx(le,{className:"h-4 w-4"})}),e.jsx(Ot,{className:"h-4 w-4 shrink-0 text-emerald-700 dark:text-emerald-300"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[e.jsx("h2",{className:"truncate font-mono text-[11px] font-semibold uppercase text-emerald-800 dark:text-emerald-200",children:c.name}),e.jsxs("span",{className:"font-mono text-[9.5px] text-[hsl(var(--deck-ink-faint))]",children:[c.status," · ",c.members.length-1," ",B(t,"members")," · ",w,"/",c.tasks.length," ",B(t,"tasks")]})]}),c.description&&e.jsx("p",{className:"truncate font-mono text-[10px] text-[hsl(var(--deck-ink-muted))]",children:c.description})]}),e.jsx("button",{type:"button",onClick:()=>void C(c.name),disabled:m===c.name,"aria-label":B(t,"delete"),title:B(t,"delete"),className:"flex h-7 w-7 items-center justify-center rounded-md text-[hsl(var(--deck-ink-faint))] hover:bg-red-50 hover:text-red-600 disabled:opacity-40 dark:hover:bg-red-950/40",children:e.jsx(ie,{className:"h-3.5 w-3.5"})})]}),A&&e.jsxs("div",{className:"max-h-[min(40vh,360px)] overflow-y-auto border-t border-emerald-200/40 px-4 py-3 md:px-6 dark:border-emerald-900/40",children:[e.jsxs("div",{className:"grid gap-x-6 gap-y-2 lg:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"mb-1 font-mono text-[9.5px] font-semibold uppercase text-[hsl(var(--deck-ink-faint))]",children:B(t,"members")}),c.members.map(k=>e.jsxs("div",{className:"flex min-h-7 items-center gap-2 border-b border-[hsl(var(--deck-hairline)/0.55)] py-1 last:border-0",children:[e.jsx("span",{"aria-label":k.status,className:`h-1.5 w-1.5 shrink-0 rounded-full ${k.status==="running"?"bg-emerald-500":k.status==="completed"||k.status==="leader"?"bg-sky-500":k.status==="failed"?"bg-red-500":"bg-zinc-400"}`}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[10.5px] text-[hsl(var(--deck-ink))]",children:k.name}),e.jsx("span",{className:"font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:k.subagentType}),k.worktreePath&&e.jsx(Oe,{className:"h-3 w-3 text-[hsl(var(--deck-ink-faint))]","aria-label":B(t,"worktree")})]},k.id))]}),e.jsxs("div",{children:[e.jsx("h3",{className:"mb-1 font-mono text-[9.5px] font-semibold uppercase text-[hsl(var(--deck-ink-faint))]",children:B(t,"tasks")}),c.tasks.length===0?e.jsx("p",{className:"font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:B(t,"noTasks")}):c.tasks.map(k=>e.jsxs("div",{className:"flex min-h-7 items-center gap-2 border-b border-[hsl(var(--deck-hairline)/0.55)] py-1 last:border-0",children:[e.jsxs("span",{className:"w-5 shrink-0 font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:["#",k.id]}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[10.5px] text-[hsl(var(--deck-ink))]",children:k.subject}),e.jsx("span",{className:"font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:k.status})]},k.id))]})]}),c.peerMessagingEnabled&&e.jsxs("div",{className:"mt-3 flex items-center gap-2 border-t border-emerald-200/40 pt-3 dark:border-emerald-900/40",children:[e.jsxs("select",{"aria-label":B(t,"recipient"),value:b[c.name]??"*",onChange:k=>i(_=>({..._,[c.name]:k.target.value})),className:"h-8 max-w-32 rounded-md border border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-surface))] px-2 font-mono text-[10px]",children:[e.jsx("option",{value:"*",children:B(t,"broadcast")}),c.members.filter(k=>k.status!=="leader").map(k=>e.jsx("option",{value:k.name,children:k.name},k.id))]}),e.jsx("input",{value:x[c.name]??"",onChange:k=>o(_=>({..._,[c.name]:k.target.value})),onKeyDown:k=>{k.key==="Enter"&&g(c.name)},placeholder:B(t,"messagePlaceholder"),className:"h-8 min-w-0 flex-1 rounded-md border border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-surface))] px-2 font-mono text-[10.5px] outline-none focus:border-emerald-500"}),e.jsx("button",{type:"button",onClick:()=>void g(c.name),disabled:!((F=x[c.name])!=null&&F.trim())||v===c.name,"aria-label":B(t,"send"),title:B(t,"send"),className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-emerald-700 text-white hover:bg-emerald-800 disabled:opacity-40 dark:bg-emerald-600",children:e.jsx(Ve,{className:"h-3.5 w-3.5"})})]})]})]},c.name)})]})}function qs(t){const s=[...t].reverse().find(l=>l.role==="user");if(!s)return null;if(typeof s.content=="string")return{content:s.content,attachments:[]};const r=s.content.filter(l=>l.type==="text").map(l=>l.text).join(`
|
|
53
53
|
`),a=s.content.filter(l=>l.type==="image_url").map((l,n)=>{var p;const d=((p=l.image_url.url.match(/^data:([^;,]+)[;,]/))==null?void 0:p[1])??"application/octet-stream";return{id:`recovery-${s.id}-${n}`,name:`attachment-${n+1}`,mimeType:d,dataUrl:l.image_url.url}});return{content:r,attachments:a}}function zs({messages:t,isLoading:s,isStreaming:r,isStopping:a,errorMessage:l}){const n=L(),[d,p]=h.useState(!1),b=n(l?"status.phase.error":a?"chat.input.action.stopping":r?"status.phase.running":"preview.files.status.ready");return e.jsxs("details",{"data-preview-status-disclosure":!0,open:d,onToggle:i=>p(i.currentTarget.open),className:"group hidden",children:[e.jsxs("summary",{className:"flex h-9 cursor-pointer list-none items-center gap-2 px-3 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[hsl(var(--deck-accent))]",children:[r&&e.jsx("span",{className:"deck-pulse-dot"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:b}),e.jsx(le,{className:"h-3.5 w-3.5 shrink-0 transition-transform group-open:rotate-90"})]}),d&&e.jsxs("div",{"data-preview-activity-details":!0,className:"flex h-[min(44vh,420px)] min-h-0 flex-col border-t border-[hsl(var(--deck-hairline))]",children:[l&&e.jsx("div",{role:"alert",className:"border-b border-red-200/60 bg-red-50/80 px-3 py-2 font-mono text-[11px] text-red-700 dark:border-red-900/50 dark:bg-red-950/30 dark:text-red-300",children:l}),e.jsx(st,{messages:t,isLoading:s}),e.jsx(rt,{})]})]})}function or(){var q;const t=L(),s=f(j=>j.messages),r=f(j=>j.currentSessionRef),a=f(j=>j.isStreaming),l=f(j=>j.isStopping),n=f(j=>j.sessionEventConnectionState),d=f(j=>j.pendingSteeringCount),p=f(j=>j.pendingInputDelivery),b=f(j=>j.recoveredSteeringCount),i=f(j=>j.isLoading),x=f(j=>j.error),o=f(j=>j.errorContext),v=f(j=>j.sessions),y=f(j=>j.sendMessage),m=f(j=>j.abortSession),S=f(j=>j.retryTask),u=f(j=>j.retryingTaskKeys),E=Ce(j=>j.openSettings),g=f(j=>j.reconnectSessionEvents),C=f(j=>j.clearError),[c,A]=h.useState(null),w=r?v.find(j=>j.sessionId===r.sessionId&&j.projectPath===r.projectPath):void 0,F=!!x&&((o==null?void 0:o.kind)==="navigation"||!(o!=null&&o.sessionRef)||Le(o.sessionRef,r)),k=(o==null?void 0:o.failureCode)??((q=w==null?void 0:w.taskFailure)==null?void 0:q.code),_=((o==null?void 0:o.kind)==="execution"||o!=null&&o.failureCode)&&k?t(yt(k)):x==="queue_full"?t("chat.error.queueFull"):x==="turn_unavailable"||x==="turn_active"?t("chat.error.turnChanged"):x,U=n==="connecting"||n==="reconnecting",N=a&&n!=="connected",T=r?`session:${ne(r)}`:"session:temporary",D=h.useMemo(()=>qs(s),[s]),I=r?ne(r):"temporary-session",H=!!(r&&(w!=null&&w.taskRetryAvailable)&&(!k||wt(k)))&&((o==null?void 0:o.kind)==="execution"||(o==null?void 0:o.kind)==="task_action"),W=(o==null?void 0:o.kind)==="execution"&&(k==="authentication"||k==="permission"||k==="model_unavailable"),G=r?u.includes(ne(r)):!1;h.useEffect(()=>{A(null)},[I]);const J=async j=>O(f.getState())?!1:y({content:j.content,modelId:j.modelId,reasoningEffort:j.reasoningEffort,serviceTier:j.serviceTier,responseVerbosity:j.responseVerbosity,communicationStyle:j.communicationStyle,...j.outputSchema?{outputSchema:j.outputSchema}:{},attachments:j.attachments.map(V=>({type:"image",content:V.dataUrl,mimeType:V.mimeType,name:V.name}))}),Q=()=>{if(!O(f.getState()))return m()},Y=async()=>{if(!O(f.getState())){if(W){C(),E("models");return}if(H&&r){C(),await S(r).catch(()=>{});return}if((o==null?void 0:o.kind)==="execution"&&D){A({...D,revision:Date.now()}),C();return}C(),requestAnimationFrame(()=>bt())}},R=H?t(G?"chat.error.action.retryingTask":"chat.error.action.retryTask"):W?t("chat.error.action.checkModels"):(o==null?void 0:o.kind)==="execution"&&D?t("chat.error.action.editResend"):(o==null?void 0:o.kind)==="submission"?t("chat.error.action.returnDraft"):null;return e.jsxs("div",{"data-chat-view":!0,className:"flex h-full flex-col bg-[hsl(var(--deck-canvas))]",children:[e.jsxs("div",{"data-chat-history":!0,className:"contents",children:[F&&e.jsxs("div",{role:"alert","data-blade-session-error":!0,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(Se,{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((o==null?void 0:o.kind)==="submission"?"chat.error.title.submission":(o==null?void 0:o.kind)==="execution"?"chat.error.title.execution":(o==null?void 0:o.kind)==="navigation"?"chat.error.title.navigation":"chat.error.title.generic")})," ",_]}),R&&e.jsxs("button",{type:"button",onClick:()=>void Y(),disabled:G,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:[H?G?e.jsx(P,{className:"h-3 w-3 animate-spin"}):e.jsx(ue,{className:"h-3 w-3"}):e.jsx(Ze,{className:"h-3 w-3"}),R]}),e.jsx("button",{type:"button",onClick:C,"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:"✕"})]}),(U||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:[U?e.jsx(P,{className:"h-3.5 w-3.5 shrink-0 animate-spin"}):e.jsx(xt,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1",children:t(U?"chat.connection.reconnecting":"chat.connection.offline")}),n==="offline"&&e.jsxs("button",{type:"button",onClick:()=>{O(f.getState())||g().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(pt,{className:"h-3 w-3"}),t("chat.connection.retry")]})]}),e.jsx(Vt,{}),e.jsx(st,{messages:s,isLoading:i},r?ne(r):"temporary-session"),e.jsx(Hs,{}),e.jsx(Ps,{})]}),e.jsxs("div",{"data-chat-composer-dock":!0,className:"contents",children:[e.jsx(zs,{messages:s,isLoading:i,isStreaming:a,isStopping:l,errorMessage:F?_:null},I),e.jsx(Is,{}),e.jsx(Ds,{}),e.jsx(ft,{draftKey:T,draft:c==null?void 0:c.content,draftAttachments:c==null?void 0:c.attachments,draftRevision:c==null?void 0:c.revision,onSend:J,onAbort:Q,disabled:i||N,isStreaming:a,isStopping:l,pendingSteeringCount:d,pendingInputDelivery:p,recoveredSteeringCount:b,workspacePath:r==null?void 0:r.projectPath},T),e.jsx("div",{"data-chat-primary-status":!0,className:"contents",children:e.jsx(rt,{})})]})]})}export{or as ChatView};
|