blade-code 0.10.129 → 0.10.131
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-xcmadwjv.js → chunk-25wwj0qb.js} +1 -1
- package/dist/{chunk-s51h6n70.js → chunk-39d95twk.js} +1 -1
- package/dist/{chunk-9kt66etm.js → chunk-580dwa0h.js} +1 -1
- package/dist/{chunk-1c11sbk3.js → chunk-5nssnxbd.js} +1 -1
- package/dist/{chunk-xsjtjrt9.js → chunk-5nv95djf.js} +1 -1
- package/dist/{chunk-651cnx1s.js → chunk-637yvyry.js} +1 -1
- package/dist/{chunk-rnmt44jm.js → chunk-7n268v68.js} +1 -1
- package/dist/{chunk-9snmrjg8.js → chunk-7wbah1y5.js} +1 -1
- package/dist/{chunk-amc5d34g.js → chunk-853cgxwv.js} +1 -1
- package/dist/chunk-92fmzgzv.js +1 -0
- package/dist/{chunk-za8gyypy.js → chunk-9ph0t3h8.js} +1 -1
- package/dist/{chunk-pa636c8e.js → chunk-a7gyy1wb.js} +1 -1
- package/dist/{chunk-9pzfv6nb.js → chunk-af3qm97y.js} +1 -1
- package/dist/{chunk-r1b4pnce.js → chunk-c1w7e6c2.js} +1 -1
- package/dist/{chunk-1q6sasj0.js → chunk-c3qmbrjj.js} +1 -1
- package/dist/{chunk-nz8wbcf1.js → chunk-cz0n951t.js} +1 -1
- package/dist/{chunk-q6xsfm60.js → chunk-dbddc52r.js} +1 -1
- package/dist/{chunk-jxh9wf3c.js → chunk-dnsb80qt.js} +294 -294
- package/dist/{chunk-440v1nhy.js → chunk-dw22ns89.js} +1 -1
- package/dist/{chunk-67qdrjyy.js → chunk-g0ra6hge.js} +1 -1
- package/dist/{chunk-mkzze9aq.js → chunk-g59kv3v3.js} +1 -1
- package/dist/{chunk-54yagjc7.js → chunk-h9wzvtmy.js} +1 -1
- package/dist/{chunk-mawx6fa5.js → chunk-hrjjhm84.js} +2 -2
- package/dist/{chunk-m5vpmvrs.js → chunk-j15db2db.js} +1 -1
- package/dist/{chunk-dg54m1y3.js → chunk-k2e4yjsk.js} +1 -1
- package/dist/{chunk-s6158tg7.js → chunk-ntdwkenx.js} +1 -1
- package/dist/{chunk-6czf04er.js → chunk-p9fs659w.js} +1 -1
- package/dist/{chunk-zzgxy86p.js → chunk-rd7b9tye.js} +1 -1
- package/dist/{chunk-kbxqsf93.js → chunk-rspcywmd.js} +1 -1
- package/dist/{chunk-y4f99y85.js → chunk-rwnfvbdh.js} +1 -1
- package/dist/chunk-s3f85gtm.js +1 -0
- package/dist/{chunk-1y8x5q68.js → chunk-svkdrxk9.js} +1 -1
- package/dist/{chunk-9rj01jd1.js → chunk-tndrbmk1.js} +1 -1
- package/dist/{chunk-fhafrrvs.js → chunk-v9qf59dy.js} +1 -1
- package/dist/{chunk-bamj4e6v.js → chunk-wj44fpe7.js} +1 -1
- package/dist/{chunk-xdphpfrg.js → chunk-xdf4m44y.js} +1 -1
- package/dist/{chunk-wzcwxhhz.js → chunk-xrheg6xr.js} +1 -1
- package/dist/{chunk-606343xt.js → chunk-ybwfm7yp.js} +1 -1
- package/dist/web/assets/{ChatView-Bg36FUaj.js → ChatView-CkmlibKO.js} +4 -4
- package/dist/web/assets/{CodeBlockHighlighter-D5rB73Eo.js → CodeBlockHighlighter-DR5RLA1_.js} +1 -1
- package/dist/web/assets/{FilePreview-BxaBSmap.js → FilePreview-C4tqzUOM.js} +1 -1
- package/dist/web/assets/{KanbanBoard-B4gx3JMo.js → KanbanBoard-D7HJQXE2.js} +1 -1
- package/dist/web/assets/{MarkdownRenderer-BRH7LHhN.js → MarkdownRenderer-Ct8vtONO.js} +3 -3
- package/dist/web/assets/{ScrollArea-DikU3QeQ.js → ScrollArea-CMSE6nO4.js} +1 -1
- package/dist/web/assets/{SessionHistorySurface-DG80d6-F.js → SessionHistorySurface-BPwnF9ND.js} +1 -1
- package/dist/web/assets/{SettingsModal-Bxqkok81.js → SettingsModal-KW5WYAov.js} +1 -1
- package/dist/web/assets/{Sidebar-DGaHGcHx.js → Sidebar-8BUNEHHQ.js} +1 -1
- package/dist/web/assets/{TaskSwitcher-DOnLPurk.js → TaskSwitcher-CZfkp2L_.js} +1 -1
- package/dist/web/assets/{TerminalPanel-BzhCF9vw.js → TerminalPanel-DBBMaU_6.js} +1 -1
- package/dist/web/assets/{archive-BiDGrqry.js → archive-tBd5snSF.js} +1 -1
- package/dist/web/assets/{arrow-left-BY-esOAP.js → arrow-left-Cs_sFMp-.js} +1 -1
- package/dist/web/assets/{calendar-clock-BCyxvfVt.js → calendar-clock-C0ue6XTy.js} +1 -1
- package/dist/web/assets/{chevron-right-Bg-10yuN.js → chevron-right-DZHCUfAH.js} +1 -1
- package/dist/web/assets/{chevrons-up-down-M5SAJq7T.js → chevrons-up-down-BSa16Scz.js} +1 -1
- package/dist/web/assets/{clock-3-v-nHTA0A.js → clock-3-DstAM2AR.js} +1 -1
- package/dist/web/assets/{copy-p1zc_rjZ.js → copy-BfnFXTgG.js} +1 -1
- package/dist/web/assets/{download-D_-kbJXR.js → download-XKyNtMnj.js} +1 -1
- package/dist/web/assets/{external-link-wSGTIqe3.js → external-link-3bcWFMya.js} +1 -1
- package/dist/web/assets/{folder-Ltm9jCS5.js → folder-D7hQLvy7.js} +1 -1
- package/dist/web/assets/index-CCdnLriX.js +210 -0
- package/dist/web/assets/{pause-_LvCZkxM.js → pause-CBR55GXy.js} +1 -1
- package/dist/web/assets/{pencil-DB6ICr_h.js → pencil-8yqeFHC4.js} +1 -1
- package/dist/web/assets/{play-BRXP1rHJ.js → play-F_Spkp4p.js} +1 -1
- package/dist/web/assets/{plus-BqvjEpLw.js → plus-CJCqq3rG.js} +1 -1
- package/dist/web/assets/{session-events-AGMXvPey.js → session-events-C6fPz20c.js} +4 -4
- package/dist/web/assets/{settings-LfQbDvBA.js → settings-G6riyt4S.js} +1 -1
- package/dist/web/assets/{teamService-B5FnUcet.js → teamService-Cixkq48S.js} +1 -1
- package/dist/web/assets/{terminal-By4sO9Gw.js → terminal-_Nebc2yj.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/dist/chunk-pd1b8jrv.js +0 -1
- package/dist/chunk-t6bg5b37.js +0 -1
- package/dist/web/assets/index-_xnlrekR.js +0 -210
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Cj as d,Ej as h}from"./chunk-
|
|
1
|
+
import{Cj as d,Ej as h}from"./chunk-rspcywmd.js";var q={debug:{alias:"d",type:"string",describe:'Enable debug mode with optional category filtering (e.g., "agent,ui" or "!chat,!loop")',group:"Debug Options:"},model:{type:"string",describe:"Override the current run model using a model config ID (TUI / print / headless)",group:"AI Options:"},print:{alias:"p",type:"boolean",describe:"Print response and exit (useful for pipes)",group:"Output Options:"},headless:{type:"boolean",describe:"Run full agent loop without Ink UI and print all events to the terminal",group:"Output Options:"},"output-format":{alias:["outputFormat"],type:"string",choices:["text","json","stream-json","jsonl"],default:"text",describe:"Output format: --print supports text|json|stream-json; --headless supports text|jsonl",group:"Output Options:"},"json-schema":{alias:["jsonSchema"],type:"string",describe:"Inline JSON Schema for the turn-scoped structured final response",group:"Output Options:"},"output-schema":{alias:["outputSchema"],type:"string",describe:"Path to a JSON Schema file for the structured final response",group:"Output Options:"},"include-partial-messages":{alias:["includePartialMessages"],type:"boolean",describe:"Include partial message chunks as they arrive",group:"Output Options:"},"input-format":{alias:["inputFormat"],type:"string",choices:["text","stream-json"],default:"text",describe:"Input format",group:"Input Options:"},"replay-user-messages":{alias:["replayUserMessages"],type:"boolean",describe:"Re-emit user messages from stdin",group:"Input Options:"},"allowed-tools":{alias:["allowedTools"],type:"array",string:!0,describe:"Comma or space-separated list of tool names to allow",group:"Security Options:"},"disallowed-tools":{alias:["disallowedTools"],type:"array",string:!0,describe:"Comma or space-separated list of tool names to deny",group:"Security Options:"},"mcp-config":{alias:["mcpConfig"],type:"array",string:!0,describe:"Load MCP servers from JSON files or strings",group:"MCP Options:"},"system-prompt":{alias:["systemPrompt"],type:"string",describe:"System prompt to use for the session (replaces default)",group:"AI Options:"},"append-system-prompt":{alias:["appendSystemPrompt"],type:"string",describe:"Append a system prompt to the default system prompt",group:"AI Options:"},"max-turns":{alias:["maxTurns"],type:"number",describe:"Maximum conversation turns (-1: unlimited, 0: disable chat, N>0: limit to N turns)",group:"AI Options:",default:void 0},"max-concurrent-tasks":{alias:["maxConcurrentTasks"],type:"number",describe:"Maximum top-level tasks running concurrently in this process",group:"AI Options:",default:void 0},"max-queued-tasks":{alias:["maxQueuedTasks"],type:"number",describe:"Maximum top-level tasks waiting for an admission slot",group:"AI Options:",default:void 0},"max-queued-task-bytes":{alias:["maxQueuedTaskBytes"],type:"number",describe:"Maximum retained bytes across queued top-level tasks",group:"AI Options:",default:void 0},"max-resident-session-runtimes":{alias:["maxResidentSessionRuntimes"],type:"number",describe:"Maximum initialized Session runtimes resident in this process",group:"AI Options:",default:void 0},"session-runtime-idle-ms":{alias:["sessionRuntimeIdleMs"],type:"number",describe:"Idle time before an evictable Web Session runtime is evicted",group:"AI Options:",default:void 0},"max-resident-session-projections":{alias:["maxResidentSessionProjections"],type:"number",describe:"Maximum resident Session projections retained in this process",group:"AI Options:",default:void 0},"session-projection-idle-ms":{alias:["sessionProjectionIdleMs"],type:"number",describe:"Idle time before an evictable Session projection is evicted",group:"AI Options:",default:void 0},"permission-mode":{alias:["permissionMode"],type:"string",choices:["default","autoEdit","yolo","plan"],describe:"Permission mode (default: ask for non-read tools, autoEdit: auto-approve edits, yolo: auto-approve all, plan: reserved)",group:"Security Options:"},yolo:{type:"boolean",describe:"Auto-approve all tools (shortcut for --permission-mode=yolo)",group:"Security Options:"},"trust-workspace":{alias:["trustWorkspace"],type:"boolean",describe:"Trust the current workspace before loading project models, MCP, LSP, permissions, or plugins",group:"Security Options:"},continue:{alias:"c",type:"boolean",describe:"Continue the most recent conversation",group:"Session Options:"},resume:{alias:"r",describe:"Resume a conversation - provide a session ID or interactively select a conversation to resume",group:"Session Options:",coerce:(b)=>{if(b===void 0||b===!0||b==="")return"true";return String(b)}},"fork-session":{alias:["forkSession"],type:"boolean",describe:"Create a new session ID when resuming",group:"Session Options:"},settings:{type:"string",describe:"Path to a settings JSON file or JSON string",group:"Configuration:"},"add-dir":{alias:["addDir"],type:"array",string:!0,describe:"Additional directories to allow tool access to",group:"Security Options:"},ide:{type:"boolean",describe:"Automatically connect to IDE on startup",group:"Integration:"},acp:{type:"boolean",describe:"Run in ACP (Agent Client Protocol) mode for IDE integration",group:"Integration:"},"strict-mcp-config":{alias:["strictMcpConfig"],type:"boolean",describe:"Only use MCP servers from --mcp-config",group:"MCP Options:"},"session-id":{alias:["sessionId"],type:"string",describe:"Use a specific session ID for the conversation",group:"Session Options:"},agents:{type:"string",describe:"JSON object defining custom agents",group:"AI Options:"},"setting-sources":{alias:["settingSources"],type:"string",describe:"Comma-separated list of setting sources to load",group:"Configuration:"},"plugin-dir":{alias:["pluginDir"],type:"array",string:!0,describe:"Load plugins from specified directories",group:"Plugin Options:"}},w={scriptName:"blade",usage:"$0 [command] [options]",description:h(),version:d(),locale:"en",showHelpOnFail:!0,demandCommand:!1,recommendCommands:!0,strict:!1};
|
|
2
2
|
export{q as af,w as bf};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{e as i2,f as c2,g as Y3,h as l0,i as N3}from"./chunk-
|
|
1
|
+
import{e as i2,f as c2,g as Y3,h as l0,i as N3}from"./chunk-h9wzvtmy.js";import{j as u1}from"./chunk-grhsv55v.js";import{v as p0,w as w2}from"./chunk-637yvyry.js";import{A as E0,x as H2,y as B2,z as D2}from"./chunk-k2e4yjsk.js";import{B as z2,C as O$,D as $$,E as Q$,F as $0,G as Z$}from"./chunk-c3qmbrjj.js";import{$ as w0,Ba as H3,J as $2,K as k1,L as w3,O as Q2,P as c0,Q as S4,R as y1,S as T$,T as K4,U as J2,V as J0,W as Y2,X as N2,Y as Y$,Z as Y1,_ as F4,aa as q0,da as x1,ea as L1,fa as q3,ga as X2,ha as V2,ia as q2,ja as E2,ka as S2,la as C2,ma as f2,na as P2,oa as k2,pa as m2,qa as h2,ta as l2,wa as g3}from"./chunk-dnsb80qt.js";import{Ia as F$,Oa as PO}from"./chunk-g59kv3v3.js";import{$a as f4,Sa as r1,Va as D3,Wa as C4,Xa as G2,Ya as U2,Za as x3,_a as L3,ab as M3,bb as P0,cb as n2,db as o2,eb as t2,fb as W2,gb as _2,hb as K2,ib as F2,jb as t4,kb as p4}from"./chunk-v52wc8yg.js";import{Kb as _4,Tb as f0,vb as kO,wb as o,yb as k,zb as Z2}from"./chunk-9ph0t3h8.js";import{cc as H4}from"./chunk-77efqpdc.js";import{Cc as i$,Ed as B1,Fd as B4,Gd as D1,Id as u0,Jc as c$,Kc as z4,Lc as a$,Ld as G4,Mc as G1,Nc as n$,Qc as Y4,Qd as O2,Rd as U4,Sd as W4,Td as v,bd as o$,md as t$,wd as K1,xd as C0}from"./chunk-c1w7e6c2.js";import{pe as s$,we as r$,xe as e$}from"./chunk-gfbkrk60.js";import{$e as J3,Se as r2,Ve as e2,We as O3,Xe as $3,Ye as Q3,Ze as q4,_e as Z3}from"./chunk-0z9nqbd0.js";import{Cf as DO,Gf as D$,Nf as uO,yf as I3}from"./chunk-7n268v68.js";import{Of as h1}from"./chunk-mdew58v9.js";import{dg as d$}from"./chunk-edtxcqxa.js";import{fg as P1}from"./chunk-5nssnxbd.js";import{Cg as a3,Fg as tO,Gg as z1,Kg as g4,og as R3,qg as z3,tg as R2,xg as X1,yg as V1}from"./chunk-j15db2db.js";import{$g as l$,_g as x$}from"./chunk-aaxc81jc.js";import{dh as U$,eh as g0}from"./chunk-dw22ns89.js";import{$h as p$,Mh as m$,Ph as h$,Rh as y$,Sh as g$,Th as A$,Uh as b$,Vh as s4,ci as v$,ei as u$,ri as W$,wh as K$,wi as N1}from"./chunk-rwnfvbdh.js";import{zi as X4}from"./chunk-jkfkyedn.js";import{Bi as p1,Ei as V4}from"./chunk-f8gb685p.js";import{Ii as NO}from"./chunk-44jtpg8y.js";import{Ji as y,Li as z,Mi as rO,Oi as YO}from"./chunk-sj1dzeta.js";import{oj as $O}from"./chunk-ar5np5h5.js";import{uj as j0}from"./chunk-dfjmvj3d.js";import{Aj as k$,wj as H$,xj as P$,zj as B$}from"./chunk-tkydv9k8.js";import{Cj as y0}from"./chunk-rspcywmd.js";import{Jj as y4}from"./chunk-qcvxff27.js";import{Mj as g1,ek as _O,gk as S1,ok as X$}from"./chunk-pj69j4zp.js";import{rk as k4}from"./chunk-zkzhm39s.js";var h6={port:{type:"number",describe:"Port to listen on (0 for auto)",default:0},hostname:{type:"string",describe:"Hostname to listen on",default:"127.0.0.1"},cors:{type:"array",describe:"Additional domains to allow for CORS",default:[]}};function y6(O){return{port:O.port??0,hostname:O.hostname??"127.0.0.1",cors:O.cors??[]}}import{existsSync as v4,readFileSync as b1}from"node:fs";import{createServer as W6}from"node:http";import{networkInterfaces as _6}from"node:os";import{dirname as K6,extname as F6,join as L0}from"node:path";import{fileURLToPath as w6}from"node:url";import{brotliCompressSync as H6,gzipSync as B6,constants as D6}from"node:zlib";import{Hono as x6}from"hono";import{cors as L6}from"hono/cors";import{WebSocketServer as M6}from"ws";var h0=$O("Service"),V5=30000,z5=new Set(["completed","failed","cancelled","interrupted"]);class e1{dispatch;store;tickMs;timer;unsubscribeBus;ticking=!1;inFlight=new Set;constructor(O){this.dispatch=O.dispatch,this.store=O.store??t4.getInstance(),this.tickMs=O.tickMs??V5}start(){if(this.timer)return;h0.info("[TaskScheduler] Starting scheduler tick loop"),this.timer=setInterval(()=>{this.tick()},this.tickMs),this.timer.unref?.(),this.unsubscribeBus=k.subscribe((O)=>{if(O.type!=="task.status")return;let $=O.properties.taskStatus;if(typeof $!=="string"||!z5.has($))return;this.recordTerminalStatus(O.sessionId,$,typeof O.properties.taskStatusReason==="string"?O.properties.taskStatusReason:void 0)}),this.tick()}stop(){if(this.timer)clearInterval(this.timer),this.timer=void 0,this.unsubscribeBus?.(),this.unsubscribeBus=void 0,h0.info("[TaskScheduler] Stopped scheduler tick loop")}async tick(O=new Date){if(this.ticking)return;this.ticking=!0;try{let $=await this.store.list();for(let Q of $)await this.evaluate(Q,O)}catch($){h0.warn("[TaskScheduler] Tick failed:",$)}finally{this.ticking=!1}}async evaluate(O,$){if(!O.enabled)return;if(this.inFlight.has(O.id))return;if(O.expiresAt&&new Date(O.expiresAt).getTime()<=$.getTime()){await this.store.update(O.id,{enabled:!1,nextRunAt:null}),h0.info(`[TaskScheduler] Schedule ${O.id} expired; disabled`);return}if(!O.nextRunAt)return;if(!(new Date(O.nextRunAt).getTime()<=$.getTime()))return;await this.fire(O,$)}async fire(O,$=new Date,Q={}){if(this.inFlight.has(O.id))throw Error(`Schedule ${O.id} is already dispatching`);this.inFlight.add(O.id);let Z=$.toISOString();try{let J=await this.dispatch({prompt:O.prompt,title:O.title??G5(O),sourceProjectPath:O.projectPath,isolation:O.dispatch.isolation??"worktree",permissionMode:O.dispatch.permissionMode??"default",modelId:O.dispatch.modelId,reasoningEffort:O.dispatch.reasoningEffort,serviceTier:O.dispatch.serviceTier,responseVerbosity:O.dispatch.responseVerbosity,communicationStyle:O.dispatch.communicationStyle}),N=O.trigger.kind==="once"?null:Q.manual?O.nextRunAt?new Date(O.nextRunAt):null:r1(O.trigger,$,$);await this.store.update(O.id,{lastRunAt:Z,lastRunSessionId:J.session.sessionId,lastStatus:J.status,lastError:void 0,runCount:O.runCount+1,nextRunAt:N?N.toISOString():null,enabled:O.trigger.kind==="once"?!1:O.enabled}),k.publish({sessionId:J.session.sessionId,projectPath:O.projectPath},"schedule.fired",{scheduleId:O.id,firedAt:Z,sessionId:J.session.sessionId,runId:J.runId,status:J.status}),h0.info(`[TaskScheduler] Fired schedule ${O.id} -> session ${J.session.sessionId} (${J.status})`)}catch(J){let N=J instanceof Error?J.message:String(J);h0.warn(`[TaskScheduler] Schedule ${O.id} dispatch failed:`,J);let X=O.trigger.kind==="once"?null:Q.manual?O.nextRunAt?new Date(O.nextRunAt):null:r1(O.trigger,$,$);await this.store.update(O.id,{lastRunAt:Z,lastStatus:"error",lastError:N,nextRunAt:X?X.toISOString():null,enabled:O.trigger.kind==="once"?!1:O.enabled})}finally{this.inFlight.delete(O.id)}}async recordTerminalStatus(O,$,Q){let J=(await this.store.list()).find((N)=>N.lastRunSessionId===O);if(!J)return;await this.store.update(J.id,{lastStatus:$,...Q?{lastError:Q}:{lastError:void 0}})}}function G5(O){return`Scheduled: ${O.prompt.trim().replace(/\s+/g," ").slice(0,60)}`}class zO extends Error{code;statusCode;details;constructor(O,$,Q=500,Z){super($);this.code=O;this.statusCode=Q;this.details=Z;this.name="BladeServerError"}toObject(){return{error:{code:this.code,message:this.message,...this.details?{details:this.details}:{}}}}}class l extends zO{constructor(O,$){super("NOT_FOUND",$?`${O} not found: ${$}`:`${O} not found`,404)}}class w extends zO{constructor(O){super("BAD_REQUEST",O,400)}}class u extends zO{constructor(O){super("CONFLICT",O,409)}}class cO extends zO{constructor(O,$){super("TOO_MANY_REQUESTS",O,429,$)}}class BO extends zO{constructor(O="Server is shutting down"){super("SERVICE_UNAVAILABLE",O,503)}}class q1 extends zO{constructor(O){super("SESSION_WORKSPACE_UNAVAILABLE","This session workspace is no longer available",409,{reason:O})}}class fO extends zO{constructor(){super("AMBIGUOUS_SESSION","Multiple workspaces contain this session ID; projectPath is required",409)}}class JO extends zO{constructor(O="Internal server error"){super("INTERNAL_ERROR",O,500)}}var c6=z.Object({error:z.Object({code:z.String(),message:z.String(),details:z.Optional(z.Record(z.String(),z.Unknown()))})});import{Hono as U5}from"hono";var O4=$O("Service"),W5=z.Object({updates:z.Record(z.String(),z.Any()),options:z.Optional(z.Object({scope:z.Optional(YO(["local","project","global"])),immediate:z.Optional(z.Boolean())}))});function _5(O){return{currentModelId:O.currentModelId,permissionMode:O.permissionMode,language:O.language,codeTheme:O.codeTheme,uiTheme:O.uiTheme,autoSaveSessions:O.autoSaveSessions,notifyBuild:O.notifyBuild,notifyErrors:O.notifyErrors,notifySounds:O.notifySounds,privacyTelemetry:O.privacyTelemetry,privacyCrash:O.privacyCrash,agentTeamsEnabled:O.agentTeamsEnabled===!0,communicationStyle:O.communicationStyle,maxConcurrentTasks:O.maxConcurrentTasks,maxQueuedTasks:O.maxQueuedTasks,maxQueuedTaskBytes:O.maxQueuedTaskBytes,maxResidentSessionRuntimes:O.maxResidentSessionRuntimes,sessionRuntimeIdleMs:O.sessionRuntimeIdleMs,maxResidentSessionProjections:O.maxResidentSessionProjections,sessionProjectionIdleMs:O.sessionProjectionIdleMs}}var r4=()=>{let O=new U5;return O.get("/",async($)=>{try{let Q=DO();return $.json(Q?_5(Q):{})}catch(Q){return O4.error("[ConfigRoutes] Failed to get config:",Q),$.json({})}}),O.put("/",async($)=>{try{let Q=await $.req.json(),Z=y(W5,Q);if(!Z.success)throw new w("Invalid config update format");let{updates:J,options:N}=Z.data;return await uO().updateConfig(J,N),$.json({success:!0,updates:J})}catch(Q){if(Q instanceof s4)throw new w(Q.message);throw O4.error("[ConfigRoutes] Failed to update config:",Q),Q}}),O.get("/permissions",async($)=>{try{let Q=DO();return $.json(Q?.permissions||{})}catch(Q){return O4.error("[ConfigRoutes] Failed to get permissions:",Q),$.json({})}}),O};import{Hono as K5}from"hono";import{streamSSE as F5}from"hono/streaming";function e4(O){let $="";if(O.id!==void 0)$+=`id: ${O.id}
|
|
2
2
|
`;if(O.event!==void 0)$+=`event: ${O.event}
|
|
3
3
|
`;for(let Q of O.data.split(/\r\n|\r|\n/))$+=`data: ${Q}
|
|
4
4
|
`;if(O.retry!==void 0)$+=`retry: ${O.retry}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$b as p,Bb as a,Cb as b,Eb as c,Ib as d,Jb as e,Kb as f,Lb as g,Mb as h,Nb as i,Ob as j,Pb as k,Wb as l,Xb as m,Yb as n,Zb as o,ac as q,bc as r}from"./chunk-
|
|
1
|
+
import{$b as p,Bb as a,Cb as b,Eb as c,Ib as d,Jb as e,Kb as f,Lb as g,Mb as h,Nb as i,Ob as j,Pb as k,Wb as l,Xb as m,Yb as n,Zb as o,ac as q,bc as r}from"./chunk-9ph0t3h8.js";import"./chunk-77efqpdc.js";import"./chunk-c1w7e6c2.js";import"./chunk-53h87fmt.js";import"./chunk-gfbkrk60.js";import"./chunk-0z9nqbd0.js";import"./chunk-mdew58v9.js";import"./chunk-ajsw4te2.js";import"./chunk-edtxcqxa.js";import"./chunk-sx77dpxw.js";import"./chunk-aaxc81jc.js";import"./chunk-dw22ns89.js";import"./chunk-g4xny949.js";import"./chunk-jkfkyedn.js";import"./chunk-f8gb685p.js";import"./chunk-44jtpg8y.js";import"./chunk-sj1dzeta.js";import"./chunk-2y1qngw7.js";import"./chunk-ar5np5h5.js";import"./chunk-dfjmvj3d.js";import"./chunk-tkydv9k8.js";import"./chunk-rspcywmd.js";import"./chunk-zwjrensv.js";import"./chunk-pj69j4zp.js";import"./chunk-zkzhm39s.js";export{g as saveUserMessage,i as saveToolUse,j as saveToolResult,k as saveCompaction,h as saveAssistantMessage,d as isRootSystemPrompt,m as handleTaskListUpdate,n as handleSkillActivation,o as extractModelSwitch,r as executeLoopGenerator,f as drainLoop,c as checkStopHook,a as checkOutputRecovery,b as checkIncompleteIntent,q as checkAndCompactInLoop,p as applyToolDomainEffects,l as StreamingToolExecutor,e as ConversationState};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Ag as a,Bg as b,Cg as c,Dg as d,Eg as e,Fg as f,Gg as g,Hg as h,Ig as i,Jg as j,Kg as k}from"./chunk-
|
|
1
|
+
import{Ag as a,Bg as b,Cg as c,Dg as d,Eg as e,Fg as f,Gg as g,Hg as h,Ig as i,Jg as j,Kg as k}from"./chunk-j15db2db.js";import"./chunk-sx77dpxw.js";import"./chunk-aaxc81jc.js";import"./chunk-93x9xbew.js";import"./chunk-dw22ns89.js";import"./chunk-g4xny949.js";import"./chunk-rwnfvbdh.js";import"./chunk-jkfkyedn.js";import"./chunk-f8gb685p.js";import"./chunk-44jtpg8y.js";import"./chunk-sj1dzeta.js";import"./chunk-2y1qngw7.js";import"./chunk-ar5np5h5.js";import"./chunk-dfjmvj3d.js";import"./chunk-tkydv9k8.js";import"./chunk-rspcywmd.js";import"./chunk-qcvxff27.js";import"./chunk-zwjrensv.js";import"./chunk-pj69j4zp.js";import"./chunk-zkzhm39s.js";export{g as withWorkspaceAgentResources,i as snapshotWorkspaceAgentResources,f as resolveWorkspaceAgentResources,k as resetWorkspaceAgentResources,d as refreshWorkspaceCommunicationStyles,h as getWorkspaceAgentResourceCacheStats,j as createEmptySessionAgentResources,e as configureInvocationPluginDirs,c as WorkspaceAgentResourceCapacityError,a as MAX_RESIDENT_WORKSPACE_AGENT_RESOURCES,b as MAX_ACTIVE_WORKSPACE_AGENT_RESOURCES};
|
|
@@ -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-Ct8vtONO.js","assets/index-CCdnLriX.js","assets/vendor-react-DofNRwfy.js","assets/vendor-radix-D6QrtXqd.js","assets/session-events-C6fPz20c.js","assets/index-B4186fIT.css","assets/copy-BfnFXTgG.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-CCdnLriX.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-3bcWFMya.js";import{S as Ct}from"./ScrollArea-CMSE6nO4.js";import{C as Qe}from"./copy-BfnFXTgG.js";import{C as le}from"./chevron-right-DZHCUfAH.js";import{A as Ye,C as Et}from"./chevrons-up-down-BSa16Scz.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-CBR55GXy.js";import{P as Ft}from"./play-F_Spkp4p.js";import{P as Ze}from"./pencil-8yqeFHC4.js";import{C as $t}from"./clock-3-DstAM2AR.js";import{t as B}from"./team-QZ9byb3E.js";import{teamService as Ae}from"./teamService-Cixkq48S.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-BRH7LHhN.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-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(`
|
|
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-BRH7LHhN.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-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(`
|
|
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};
|