blade-code 0.10.127 → 0.10.129
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-0z9nqbd0.js +2 -0
- package/dist/chunk-1c11sbk3.js +2 -0
- package/dist/{chunk-g7f3nhg2.js → chunk-1q6sasj0.js} +2 -2
- package/dist/chunk-1y8x5q68.js +1 -0
- package/dist/chunk-2bnpn8be.js +1 -0
- package/dist/{chunk-hbafhk9y.js → chunk-2y1qngw7.js} +1 -1
- package/dist/{chunk-s20hq62y.js → chunk-440v1nhy.js} +3 -3
- package/dist/{chunk-s6562rsq.js → chunk-44jtpg8y.js} +1 -1
- package/dist/{chunk-q265drks.js → chunk-53h87fmt.js} +1 -1
- package/dist/chunk-54yagjc7.js +2 -0
- package/dist/chunk-606343xt.js +1 -0
- package/dist/{chunk-a552m4hx.js → chunk-651cnx1s.js} +2 -2
- package/dist/{chunk-p0khbmbc.js → chunk-67qdrjyy.js} +1 -1
- package/dist/chunk-6czf04er.js +1 -0
- package/dist/{chunk-zm2bbagg.js → chunk-6p6ts4kv.js} +2 -2
- package/dist/{chunk-sca5q3tt.js → chunk-77efqpdc.js} +1 -1
- package/dist/{chunk-85bamng3.js → chunk-93x9xbew.js} +1 -1
- package/dist/chunk-9gs4eqt8.js +1 -0
- package/dist/{chunk-hhmhs2q1.js → chunk-9kt66etm.js} +1 -1
- package/dist/chunk-9pzfv6nb.js +1 -0
- package/dist/{chunk-eq1anf88.js → chunk-9rj01jd1.js} +2 -2
- package/dist/chunk-9s8saznq.js +1 -0
- package/dist/{chunk-gna6njws.js → chunk-9snmrjg8.js} +2 -2
- package/dist/{chunk-pezzyyyk.js → chunk-a60cmnmz.js} +2 -2
- package/dist/{chunk-adkpwx6c.js → chunk-aaxc81jc.js} +1 -1
- package/dist/{chunk-7n7swtwg.js → chunk-ajsw4te2.js} +2 -2
- package/dist/{chunk-rw2sq3mf.js → chunk-amc5d34g.js} +1 -1
- package/dist/{chunk-68sf54n4.js → chunk-ar5np5h5.js} +2 -2
- package/dist/{chunk-t727txa9.js → chunk-bamj4e6v.js} +2 -2
- package/dist/{chunk-sv833k2e.js → chunk-dfjmvj3d.js} +2 -2
- package/dist/{chunk-dknmpacf.js → chunk-dg54m1y3.js} +2 -2
- package/dist/{chunk-8qp8v96d.js → chunk-edtxcqxa.js} +1 -1
- package/dist/chunk-f8gb685p.js +2 -0
- package/dist/chunk-fhafrrvs.js +1 -0
- package/dist/{chunk-2t6b962t.js → chunk-g4xny949.js} +1 -1
- package/dist/chunk-gfbkrk60.js +338 -0
- package/dist/{chunk-1b2dkwpv.js → chunk-gmqpfm52.js} +2 -2
- package/dist/{chunk-2xezz3nt.js → chunk-grhsv55v.js} +2 -2
- package/dist/{chunk-y94239bb.js → chunk-jkfkyedn.js} +1 -1
- package/dist/chunk-jxh9wf3c.js +1708 -0
- package/dist/{chunk-a3ewfebr.js → chunk-kbxqsf93.js} +2 -2
- package/dist/chunk-kd3k1q9z.js +1 -0
- package/dist/{chunk-ve4kvj1n.js → chunk-m5vpmvrs.js} +20 -20
- package/dist/chunk-m9mw8ppy.js +1 -0
- package/dist/{chunk-r5nvt35e.js → chunk-mawx6fa5.js} +2 -2
- package/dist/{chunk-ye4wyq1k.js → chunk-mdew58v9.js} +1 -1
- package/dist/{chunk-mpwyf1fe.js → chunk-mkzze9aq.js} +2 -2
- package/dist/{chunk-dh03cybw.js → chunk-mvm1rzc4.js} +2 -2
- package/dist/chunk-nz8wbcf1.js +1 -0
- package/dist/{chunk-g2jx4y8f.js → chunk-p00f53yq.js} +1 -1
- package/dist/{chunk-wmds1jq3.js → chunk-pa636c8e.js} +1 -1
- package/dist/chunk-pd1b8jrv.js +1 -0
- package/dist/chunk-pj69j4zp.js +2 -0
- package/dist/{chunk-t23n4wn0.js → chunk-q6xsfm60.js} +2 -2
- package/dist/{chunk-1g0d9yw0.js → chunk-qcvxff27.js} +2 -2
- package/dist/chunk-r1b4pnce.js +94 -0
- package/dist/{chunk-gqv0vkg9.js → chunk-rnmt44jm.js} +2 -2
- package/dist/chunk-s51h6n70.js +23 -0
- package/dist/chunk-s6158tg7.js +170 -0
- package/dist/{chunk-xvn80fge.js → chunk-sfe4810k.js} +1 -1
- package/dist/{chunk-cw2b3383.js → chunk-sj1dzeta.js} +1 -1
- package/dist/{chunk-0zzh482s.js → chunk-sx77dpxw.js} +1 -1
- package/dist/chunk-t6bg5b37.js +1 -0
- package/dist/{chunk-w7n73ag8.js → chunk-tkydv9k8.js} +1 -1
- package/dist/{chunk-z1zr4wts.js → chunk-v52wc8yg.js} +2 -2
- package/dist/chunk-wzcwxhhz.js +1 -0
- package/dist/{chunk-shd1ec3n.js → chunk-xcmadwjv.js} +2 -2
- package/dist/chunk-xdphpfrg.js +14 -0
- package/dist/chunk-xsjtjrt9.js +10 -0
- package/dist/{chunk-m76jmvsf.js → chunk-y4f99y85.js} +2 -2
- package/dist/{chunk-xdvn6yrd.js → chunk-z03dtyh6.js} +1 -1
- package/dist/chunk-za8gyypy.js +171 -0
- package/dist/{chunk-hmwz31tc.js → chunk-zkzhm39s.js} +1 -1
- package/dist/{chunk-6kwg4hcv.js → chunk-zwjrensv.js} +1 -1
- package/dist/chunk-zzgxy86p.js +1 -0
- package/dist/web/assets/ChatView-Bg36FUaj.js +53 -0
- package/dist/web/assets/{CodeBlockHighlighter-0VOa5Mes.js → CodeBlockHighlighter-D5rB73Eo.js} +2 -2
- package/dist/web/assets/FilePreview-BxaBSmap.js +65 -0
- package/dist/web/assets/KanbanBoard-B4gx3JMo.js +16 -0
- package/dist/web/assets/{MarkdownRenderer-3g4TPTeI.js → MarkdownRenderer-BRH7LHhN.js} +3 -3
- package/dist/web/assets/ScrollArea-DikU3QeQ.js +1 -0
- package/dist/web/assets/SessionHistorySurface-DG80d6-F.js +6 -0
- package/dist/web/assets/{SettingsModal-3GMy6V-E.js → SettingsModal-Bxqkok81.js} +3 -3
- package/dist/web/assets/Sidebar-DGaHGcHx.js +31 -0
- package/dist/web/assets/TaskSwitcher-DOnLPurk.js +26 -0
- package/dist/web/assets/TerminalPanel-BzhCF9vw.js +6 -0
- package/dist/web/assets/archive-BiDGrqry.js +6 -0
- package/dist/web/assets/{arrow-left-03GxbYI7.js → arrow-left-BY-esOAP.js} +1 -1
- package/dist/web/assets/{calendar-clock-8W4ostX1.js → calendar-clock-BCyxvfVt.js} +1 -1
- package/dist/web/assets/chevron-right-Bg-10yuN.js +6 -0
- package/dist/web/assets/{chevrons-up-down-BboZzEAk.js → chevrons-up-down-M5SAJq7T.js} +1 -1
- package/dist/web/assets/{clock-3-aXgeptZP.js → clock-3-v-nHTA0A.js} +1 -1
- package/dist/web/assets/copy-p1zc_rjZ.js +6 -0
- package/dist/web/assets/download-D_-kbJXR.js +6 -0
- package/dist/web/assets/{external-link-UkIIC2ds.js → external-link-wSGTIqe3.js} +1 -1
- package/dist/web/assets/{folder-BOCc5dv2.js → folder-Ltm9jCS5.js} +1 -1
- package/dist/web/assets/index-B4186fIT.css +1 -0
- package/dist/web/assets/index-_xnlrekR.js +210 -0
- package/dist/web/assets/{pause-DVIT6IIr.js → pause-_LvCZkxM.js} +1 -1
- package/dist/web/assets/pencil-DB6ICr_h.js +6 -0
- package/dist/web/assets/{play-DsdF5dji.js → play-BRXP1rHJ.js} +1 -1
- package/dist/web/assets/plus-BqvjEpLw.js +6 -0
- package/dist/web/assets/session-events-AGMXvPey.js +22 -0
- package/dist/web/assets/settings-LfQbDvBA.js +6 -0
- package/dist/web/assets/teamService-B5FnUcet.js +1 -0
- package/dist/web/assets/terminal-By4sO9Gw.js +6 -0
- package/dist/web/assets/vendor-radix-D6QrtXqd.js +45 -0
- package/dist/web/index.html +3 -3
- package/package.json +1 -1
- package/dist/chunk-23wg4jvz.js +0 -8
- package/dist/chunk-2a0vs0a0.js +0 -1
- package/dist/chunk-2j2mnzdg.js +0 -2
- package/dist/chunk-462sbp8t.js +0 -171
- package/dist/chunk-54f7t2g3.js +0 -1
- package/dist/chunk-8k26rhcp.js +0 -1
- package/dist/chunk-8zftskf2.js +0 -2
- package/dist/chunk-9cvq8w6k.js +0 -10
- package/dist/chunk-9hm3hy8d.js +0 -1
- package/dist/chunk-9rj1may5.js +0 -1
- package/dist/chunk-9xzw649r.js +0 -2
- package/dist/chunk-a0t558d4.js +0 -169
- package/dist/chunk-az5eb47t.js +0 -1
- package/dist/chunk-d4z5cp40.js +0 -2
- package/dist/chunk-d71gxct6.js +0 -118
- package/dist/chunk-hxfqcy5r.js +0 -23
- package/dist/chunk-k0n2028d.js +0 -1
- package/dist/chunk-mg4jnq0p.js +0 -1
- package/dist/chunk-mxkezzj9.js +0 -1
- package/dist/chunk-mzxwhhnc.js +0 -1
- package/dist/chunk-tqjrt537.js +0 -1
- package/dist/chunk-xba79vkf.js +0 -1703
- package/dist/chunk-xgp318dt.js +0 -1
- package/dist/chunk-xnbzrh8b.js +0 -140
- package/dist/chunk-y3jbc2xx.js +0 -1
- package/dist/chunk-yc64nfym.js +0 -1
- package/dist/chunk-yqh061d8.js +0 -1
- package/dist/web/assets/ChatView-DCHnicTP.js +0 -58
- package/dist/web/assets/FilePreview-C_3KHzzj.js +0 -65
- package/dist/web/assets/KanbanBoard-D_NTkUnD.js +0 -16
- package/dist/web/assets/TaskSwitcher-eCdxu5Eo.js +0 -26
- package/dist/web/assets/TerminalPanel-9q9Trmv9.js +0 -6
- package/dist/web/assets/index-DGf6Z2kM.css +0 -1
- package/dist/web/assets/index-DaiT-mmo.js +0 -275
- package/dist/web/assets/session-events-CWzF04l4.js +0 -22
- package/dist/web/assets/teamService-BliaDj1Z.js +0 -1
- package/dist/web/assets/vendor-radix-Bc1_Q9tz.js +0 -45
package/dist/chunk-xgp318dt.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Bb as c,Fb as d,Gb as e,Hb as f,Ib as g,Jb as h,Kb as i,Lb as j,Mb as k,Tb as l,Ub as m,Vb as n,Wb as o,Yb as p,Zb as q,_b as r,yb as a,zb as b}from"./chunk-462sbp8t.js";import"./chunk-sca5q3tt.js";import"./chunk-d71gxct6.js";import"./chunk-q265drks.js";import"./chunk-xnbzrh8b.js";import"./chunk-ye4wyq1k.js";import"./chunk-7n7swtwg.js";import"./chunk-8qp8v96d.js";import"./chunk-0zzh482s.js";import"./chunk-adkpwx6c.js";import"./chunk-s20hq62y.js";import"./chunk-2t6b962t.js";import"./chunk-y94239bb.js";import"./chunk-cw2b3383.js";import"./chunk-2j2mnzdg.js";import"./chunk-s6562rsq.js";import"./chunk-hbafhk9y.js";import"./chunk-68sf54n4.js";import"./chunk-sv833k2e.js";import"./chunk-w7n73ag8.js";import"./chunk-a3ewfebr.js";import"./chunk-6kwg4hcv.js";import"./chunk-9xzw649r.js";import"./chunk-hmwz31tc.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};
|
package/dist/chunk-xnbzrh8b.js
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import{Ei as r}from"./chunk-68sf54n4.js";import{aj as d,cj as x,ej as j,ij as u,jj as i}from"./chunk-9xzw649r.js";import{kj as I}from"./chunk-hmwz31tc.js";import{stat as a}from"node:fs/promises";import B from"node:path";import*as U from"node:path";var e=50,__=100,E_=new Set(["queued","running","completed","failed","cancelled","interrupted"]),R_=new Set(["high","medium","low"]),W_=/^[A-Za-z0-9_-]+$/,$_=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?(?:Z|[+-]\d{2}:\d{2})$/;function H_(_){return typeof _==="string"&&$_.test(_)&&Number.isFinite(Date.parse(_))}function v(_){return typeof _==="string"&&U.isAbsolute(_)}function M_(_){return Buffer.from(JSON.stringify(_),"utf8").toString("base64url")}function Q_(_){try{if(!W_.test(_))throw Error("invalid");let E=Buffer.from(_,"base64url").toString("utf8");if(Buffer.from(E,"utf8").toString("base64url")!==_)throw Error("invalid");let R=JSON.parse(E);if(R.version!==1||typeof R.includeSubagents!=="boolean"||R.archived!==void 0&&typeof R.archived!=="boolean"||!(R.cwd===null||v(R.cwd))||!H_(R.lastMessageTime)||!v(R.projectPath)||!x(R.sessionId))throw Error("invalid");return{version:1,cwd:R.cwd===null?null:U.resolve(R.cwd),includeSubagents:R.includeSubagents,archived:R.archived??!1,lastMessageTime:R.lastMessageTime,projectPath:U.resolve(R.projectPath),sessionId:R.sessionId}}catch{throw Error("Invalid session cursor")}}function J(_){let E="";for(let R=0;R<_.length;R+=1)E+=_.charCodeAt(R).toString(16).padStart(4,"0");return E}function V_(_){if(!_.cursor)return;let E=Q_(_.cursor);if(E.cwd!==_.cwd||E.includeSubagents!==_.includeSubagents||(E.archived??!1)!==_.archived)throw Error("Session cursor scope does not match this query");return E}function O_(_={}){let{cwd:E,cursor:R,limit:W,includeSubagents:$=!1,archived:M=!1}=_;if(E!==void 0&&!U.isAbsolute(E))throw Error("Session catalog cwd must be absolute");let H=W===void 0?e:W;if(!Number.isInteger(H)||H<1||H>__)throw Error("Session catalog limit must be an integer from 1 to 100");return{cwd:E===void 0?null:U.resolve(E),cursor:R??void 0,limit:H,includeSubagents:$,archived:M}}function N_(_={}){let E=c(_.taskStatus,E_,"task status"),R=c(_.taskPriority,R_,"task priority"),W=S(_.taskDueAfter,"taskDueAfter"),$=S(_.taskDueBefore,"taskDueBefore");return X_(W,$),{...E?{taskStatuses:E}:{},...R?{taskPriorities:R}:{},...W?{taskDueAfter:W}:{},...$?{taskDueBefore:$}:{}}}function c(_,E,R){if(_===void 0)return;let W=Array.isArray(_)?_:[_];if(W.length===0)return;let $=new Set;for(let M of W){if(typeof M!=="string"||!E.has(M))throw Error(`Invalid session ${R} filter`);$.add(M)}return[...$].sort()}function S(_,E){if(_===void 0)return;if(typeof _!=="string"||!Number.isFinite(Date.parse(_)))throw Error(`Invalid session ${E} filter`);return new Date(_).toISOString()}function X_(_,E){if(_!==void 0&&E!==void 0&&_>E)throw Error("Session task due range is inverted")}function Y_(_,E){if(_.lastMessageTime>E.lastMessageTime)return-1;if(_.lastMessageTime<E.lastMessageTime)return 1;if(_.projectPath<E.projectPath)return-1;if(_.projectPath>E.projectPath)return 1;if(_.sessionId<E.sessionId)return-1;if(_.sessionId>E.sessionId)return 1;return 0}function f_(_,E){let R=[..._],W=V_(E);if(W)R=R.filter((H)=>Y_(H,{sessionId:W.sessionId,projectPath:W.projectPath,lastMessageTime:W.lastMessageTime})>0);let $=R.slice(0,E.limit);if($.length===0||R.length<=$.length)return{sessions:$};let M=$[$.length-1];return{sessions:$,nextCursor:M_({version:1,cwd:E.cwd,includeSubagents:E.includeSubagents,archived:E.archived,lastMessageTime:M.lastMessageTime,projectPath:M.projectPath,sessionId:M.sessionId})}}function G_(_){return _.type==="message_created"||_.type==="token_budget_handoff_recorded"||_.type==="part_created"||_.type==="part_updated"||_.type==="turn_started"||_.type==="turn_completed"||_.type==="turn_aborted"||_.type==="turn_recovery_acknowledged"||_.type==="interaction_requested"||_.type==="interaction_responded"||_.type==="interaction_recovered"||_.type==="review_started"||_.type==="review_completed"}function O(_){return _.type==="message_created"&&_.data.role==="user"&&(_.data.inboxMessageId!==void 0||_.data.parentMessageId===void 0)}function N(_,E){let R=_.find((W)=>O(W)&&W.data.messageId===E);if(!R)throw Error(`Rewind checkpoint not found: ${E}`);return{messageId:E,preview:m(_,E),createdAt:R.data.createdAt}}function m(_,E){let R=_.flatMap((W)=>{if(W.type!=="part_created"||W.data.messageId!==E)return[];if(W.data.partType==="text"){let $=W.data.payload;return typeof $.text==="string"?[$.text]:[]}if(W.data.partType==="image")return["[Image]"];return[]}).join("").trim();if(R.length<=160)return R;return`${R.slice(0,160)}...`}function h(_,E){N(_,E);let R=_.findIndex((H)=>H.type==="message_created"&&H.data.messageId===E),W=_[R],$=W?.type==="message_created"?W.data.inboxMessageId:void 0,M=new Set(_.flatMap((H)=>H.type==="turn_started"&&$&&H.data.inputMessageIds?.includes($)?[H.data.turnId]:[]));return _.filter((H,Q)=>{if((H.type==="turn_started"||H.type==="turn_completed"||H.type==="turn_aborted"||H.type==="turn_recovery_acknowledged")&&M.has(H.data.turnId))return!1;return Q<R||!G_(H)})}function w(_){let E=[];for(let R of _){if(R.type!=="session_rewound"){E.push(R);continue}if(N(E,R.data.targetMessageId),R.data.mode!=="code")E=h(E,R.data.targetMessageId)}return E}function j_(_){let E=w(_);return E.filter(O).map((R)=>({messageId:R.data.messageId,preview:m(E,R.data.messageId),createdAt:R.data.createdAt})).reverse()}function u_(_,E){let R=w(_),W=N(R,E),$=R.findIndex((H)=>H.type==="message_created"&&H.data.messageId===E),M=R.slice($);return{checkpoint:W,projectedEntries:h(R,E),removedTurns:M.filter(O).length,snapshotMessageIds:M.flatMap((H)=>H.type==="part_created"&&H.data.partType==="tool_call"?[H.data.partId]:[])}}import*as z from"node:fs";import{createReadStream as g_}from"node:fs";import*as X from"node:fs/promises";import*as f from"node:path";import{createInterface as T_}from"node:readline";var b=65536;function D(_){let E=_.data;if(E===null||typeof E!=="object"||Array.isArray(E))throw Error("Session event data must be a JSON object");return JSON.stringify(_)}function Z_(_,E,R){let W=_.trim();if(!W)return;try{return JSON.parse(W)}catch($){throw Error(`Invalid session JSONL in ${R} at line ${E}`,{cause:$})}}function y(_,E="session transcript"){let R=_.split(`
|
|
2
|
-
`),W=!_.endsWith(`
|
|
3
|
-
`),$=[];for(let[M,H]of R.entries())try{let Q=Z_(H,M+1,E);if(Q){if(typeof Q.seq!=="number")Q.seq=$.length+1;$.push(Q)}}catch(Q){if(W&&M===R.length-1)break;throw Q}return $}class G{static appendQueues=new Map;filePath;constructor(_){this.filePath=_}static maxSeq(_){let E=0;for(let R of _)if(typeof R.seq==="number"&&R.seq>E)E=R.seq;return E}static stampSeqFrom(_,E){let R=E;return _.map((W)=>{if(typeof W.seq==="number"){if(W.seq>R)R=W.seq;return W}return R+=1,{...W,seq:R}})}static stampSeq(_,E){return G.stampSeqFrom(_,G.maxSeq(E))}async append(_){try{let[E]=await this.appendEntries([_]);return E}catch(E){throw console.error(`[JSONLStore] 追加写入失败: ${this.filePath}`,E),E}}async appendBatch(_){try{return await this.appendEntries(_)}catch(E){throw console.error(`[JSONLStore] 批量追加写入失败: ${this.filePath}`,E),E}}async appendEntries(_){if(_.length===0)return[];return this.enqueue(async()=>{await X.mkdir(f.dirname(this.filePath),{recursive:!0,mode:493});let E=await X.open(this.filePath,"a+",384);try{let R=await this.repairIncompleteTail(E),W=await this.readTailSeq(E),$=G.stampSeqFrom(_,W),M=`${$.map(D).join(`
|
|
4
|
-
`)}
|
|
5
|
-
`;return await E.appendFile(R+M,"utf8"),await E.sync(),$}finally{await E.close()}})}async createExclusive(_){if(_.length===0)throw Error("Cannot create an empty session transcript");await X.mkdir(f.dirname(this.filePath),{recursive:!0,mode:493});let E;try{E=await X.open(this.filePath,"wx",384);let W=`${G.stampSeq(_,[]).map(D).join(`
|
|
6
|
-
`)}
|
|
7
|
-
`;await E.writeFile(W,"utf-8"),await E.sync()}catch(R){if(E)await E.close(),E=void 0,await X.unlink(this.filePath).catch(()=>{return});throw R}finally{await E?.close()}}async readAll(){if(!z.existsSync(this.filePath))return[];let _=await X.readFile(this.filePath,"utf-8");return y(_,this.filePath)}async readStream(_){return new Promise((E,R)=>{if(!z.existsSync(this.filePath)){E();return}let W=g_(this.filePath,"utf-8"),$=T_({input:W,crlfDelay:Number.POSITIVE_INFINITY}),M=0;$.on("line",async(H)=>{let Q=H.trim();if(Q.length===0)return;try{let Y=JSON.parse(Q);if(M+=1,typeof Y.seq!=="number")Y.seq=M;await _(Y)}catch(Y){console.warn(`[JSONLStore] 解析 JSON 行失败: ${Q}`,Y)}}),$.on("close",()=>E()),$.on("error",R),W.on("error",R)})}async filter(_){let E=[];return await this.readStream((R)=>{if(_(R))E.push(R)}),E}async readLast(_){return(await this.readAll()).slice(-_)}async readFromSeq(_){return(await this.readAll()).filter((R)=>(R.seq??0)>=_)}async getStats(){try{if(!z.existsSync(this.filePath))return{exists:!1,size:0,lineCount:0};let _=await X.stat(this.filePath),R=(await X.readFile(this.filePath,"utf-8")).split(`
|
|
8
|
-
`).filter((W)=>W.trim().length>0).length;return{exists:!0,size:_.size,lineCount:R}}catch(_){return console.error(`[JSONLStore] 获取统计信息失败: ${this.filePath}`,_),{exists:!1,size:0,lineCount:0}}}async exists(){try{return await X.access(this.filePath),!0}catch{return!1}}async delete(){try{return await this.enqueue(async()=>{try{return await X.unlink(this.filePath),!0}catch(_){if(_.code==="ENOENT")return!1;throw _}})}catch(_){throw console.error(`[JSONLStore] 删除文件失败: ${this.filePath}`,_),_}}async deleteValidated(_){return this.enqueue(async()=>{let E;try{E=await X.open(this.filePath,"r")}catch(W){if(W.code==="ENOENT")return!1;throw W}let R;try{R=y(await E.readFile("utf8"),"session transcript")}finally{await E.close()}if(!_(R))return!1;try{return await X.unlink(this.filePath),!0}catch(W){if(W.code==="ENOENT")return!1;throw W}})}async appendValidated(_){return this.appendValidatedAsync(async(E)=>_(E))}async appendValidatedBatch(_){return this.appendValidatedBatchAsync(async(E)=>_(E))}async appendValidatedBatchAsync(_){return this.enqueue(async()=>{let E=await X.open(this.filePath,"r+");try{let{entries:R,separator:W,size:$}=await this.readCommittedState(E,"session transcript"),M=await _(R);if(M.length===0)return[];let H=G.stampSeq(M,R),Q=`${H.map(D).join(`
|
|
9
|
-
`)}
|
|
10
|
-
`;return await E.write(W+Q,$,"utf8"),await E.sync(),H}finally{await E.close()}})}async appendValidatedAsync(_){return this.enqueue(async()=>{let E=await X.open(this.filePath,"r+");try{let{entries:R,separator:W,size:$}=await this.readCommittedState(E,"session transcript"),M=await _(R),[H]=G.stampSeq([M],R),Q=`${W}${D(H)}
|
|
11
|
-
`;return await E.write(Q,$,"utf8"),await E.sync(),H}finally{await E.close()}})}getFilePath(){return this.filePath}async enqueue(_){let R=(G.appendQueues.get(this.filePath)??Promise.resolve()).catch(()=>{return}).then(_),W=R.then(()=>{return},()=>{return});G.appendQueues.set(this.filePath,W);try{return await R}finally{if(G.appendQueues.get(this.filePath)===W)G.appendQueues.delete(this.filePath)}}async readCommittedState(_,E=this.filePath){let R=await this.repairIncompleteTail(_),W=await _.readFile("utf8"),$=y(W,E),{size:M}=await _.stat();return{entries:$,separator:R,size:M}}async readTailSeq(_){let{size:E}=await _.stat();if(E===0)return 0;let R=Math.max(0,E-b),W=Buffer.allocUnsafe(E-R);await _.read(W,0,W.length,R);let $=W.toString("utf8").split(`
|
|
12
|
-
`);for(let H=$.length-1;H>=0;H--){let Q=$[H].trim();if(!Q)continue;if(H===0&&R>0)break;try{let Y=JSON.parse(Q).seq;if(typeof Y==="number")return Y}catch{}break}let M=await _.readFile("utf8");return G.maxSeq(y(M,this.filePath))}async repairIncompleteTail(_){let{size:E}=await _.stat();if(E===0)return"";let R=Buffer.allocUnsafe(1);if(await _.read(R,0,1,E-1),R[0]===10)return"";let W=await this.findTailStart(_,E),$=Buffer.allocUnsafe(E-W);await _.read($,0,$.length,W);try{return JSON.parse($.toString("utf8").trim()),`
|
|
13
|
-
`}catch{return await _.truncate(W),""}}async findTailStart(_,E){let R=E;while(R>0){let W=Math.max(0,R-b),$=Buffer.allocUnsafe(R-W);await _.read($,0,$.length,W);let M=$.lastIndexOf(10);if(M>=0)return W+M+1;R=W}return 0}}function K_(){return typeof globalThis.Bun<"u"}function U_(_){return{exec:(E)=>_.exec(E),prepare:(E)=>{let R=_.prepare(E);return{run:(...W)=>{R.run(...W)},get:(...W)=>R.get(...W),all:(...W)=>R.all(...W)}},transaction:(E)=>_.transaction(E)(),pragma:(E)=>_.pragma(E,{simple:!0}),close:()=>_.close()}}function F_(_){return{exec:(E)=>_.exec(E),prepare:(E)=>{let R=_.query(E);return{run:(...W)=>{R.run(...W)},get:(...W)=>R.get(...W),all:(...W)=>R.all(...W)}},transaction:(E)=>_.transaction(E)(),pragma:(E)=>{let R=_.query(`PRAGMA ${E}`).get();if(!R)return;let W=Object.values(R);return W.length===1?W[0]:R},close:()=>_.close()}}var C_=["PRAGMA journal_mode=WAL;","PRAGMA busy_timeout=5000;","PRAGMA synchronous=NORMAL;","PRAGMA foreign_keys=ON;"].join(`
|
|
14
|
-
`);async function l(_){try{let E;if(K_()){let{Database:W}=await import("bun:sqlite");E=F_(new W(_))}else{let $=(await import("better-sqlite3")).default;E=U_(new $(_))}return E.exec(C_),E}catch{return null}}function o(_){let E=Number(_.pragma("user_version")??0);if(E===5)return;if(E>0&&E!==5)_.exec(`
|
|
15
|
-
DROP TABLE IF EXISTS parts_fts;
|
|
16
|
-
DROP TABLE IF EXISTS parts;
|
|
17
|
-
DROP TABLE IF EXISTS sessions;
|
|
18
|
-
DROP TABLE IF EXISTS projection_state;
|
|
19
|
-
`);_.exec(`
|
|
20
|
-
CREATE TABLE IF NOT EXISTS projection_state (
|
|
21
|
-
project_path TEXT NOT NULL,
|
|
22
|
-
session_id TEXT NOT NULL,
|
|
23
|
-
last_seq INTEGER NOT NULL DEFAULT 0,
|
|
24
|
-
file_size INTEGER NOT NULL DEFAULT 0,
|
|
25
|
-
mtime_ms INTEGER NOT NULL DEFAULT 0,
|
|
26
|
-
PRIMARY KEY (project_path, session_id)
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
CREATE TABLE IF NOT EXISTS sessions (
|
|
30
|
-
project_path TEXT NOT NULL,
|
|
31
|
-
session_id TEXT NOT NULL,
|
|
32
|
-
root_id TEXT,
|
|
33
|
-
parent_id TEXT,
|
|
34
|
-
relation_type TEXT,
|
|
35
|
-
title TEXT,
|
|
36
|
-
agent_type TEXT,
|
|
37
|
-
model TEXT,
|
|
38
|
-
task_status TEXT,
|
|
39
|
-
task_priority TEXT,
|
|
40
|
-
task_kind TEXT,
|
|
41
|
-
task_due_at TEXT,
|
|
42
|
-
archived_at TEXT,
|
|
43
|
-
last_message_time TEXT,
|
|
44
|
-
project_sort_key TEXT NOT NULL,
|
|
45
|
-
session_sort_key TEXT NOT NULL,
|
|
46
|
-
first_message_time TEXT,
|
|
47
|
-
message_count INTEGER NOT NULL DEFAULT 0,
|
|
48
|
-
has_errors INTEGER NOT NULL DEFAULT 0,
|
|
49
|
-
is_subagent INTEGER NOT NULL DEFAULT 0,
|
|
50
|
-
-- 完整 StoredSessionMetadata JSON,读回时直接反序列化,保证与 JSONL 路径一致。
|
|
51
|
-
metadata_json TEXT NOT NULL,
|
|
52
|
-
PRIMARY KEY (project_path, session_id)
|
|
53
|
-
);
|
|
54
|
-
CREATE INDEX IF NOT EXISTS idx_sessions_catalog ON sessions(
|
|
55
|
-
last_message_time DESC,
|
|
56
|
-
project_sort_key ASC,
|
|
57
|
-
session_sort_key ASC
|
|
58
|
-
);
|
|
59
|
-
CREATE INDEX IF NOT EXISTS idx_sessions_archived ON sessions(
|
|
60
|
-
archived_at,
|
|
61
|
-
project_path,
|
|
62
|
-
parent_id
|
|
63
|
-
);
|
|
64
|
-
-- 任务看板过滤/排序:按项目锁定后再按状态、优先级、截止时间收敛。
|
|
65
|
-
CREATE INDEX IF NOT EXISTS idx_sessions_task_board ON sessions(
|
|
66
|
-
project_path,
|
|
67
|
-
task_status,
|
|
68
|
-
task_priority,
|
|
69
|
-
task_due_at
|
|
70
|
-
);
|
|
71
|
-
CREATE INDEX IF NOT EXISTS idx_sessions_task_status ON sessions(
|
|
72
|
-
task_status,
|
|
73
|
-
project_path
|
|
74
|
-
);
|
|
75
|
-
CREATE INDEX IF NOT EXISTS idx_sessions_task_priority ON sessions(
|
|
76
|
-
task_priority,
|
|
77
|
-
task_due_at
|
|
78
|
-
) WHERE task_priority IS NOT NULL;
|
|
79
|
-
CREATE INDEX IF NOT EXISTS idx_sessions_task_due_at ON sessions(
|
|
80
|
-
task_due_at
|
|
81
|
-
) WHERE task_due_at IS NOT NULL;
|
|
82
|
-
|
|
83
|
-
CREATE TABLE IF NOT EXISTS parts (
|
|
84
|
-
project_path TEXT NOT NULL,
|
|
85
|
-
session_id TEXT NOT NULL,
|
|
86
|
-
part_id TEXT NOT NULL,
|
|
87
|
-
message_id TEXT,
|
|
88
|
-
part_type TEXT,
|
|
89
|
-
role TEXT,
|
|
90
|
-
seq INTEGER,
|
|
91
|
-
timestamp TEXT,
|
|
92
|
-
text TEXT,
|
|
93
|
-
PRIMARY KEY (project_path, session_id, part_id)
|
|
94
|
-
);
|
|
95
|
-
CREATE INDEX IF NOT EXISTS idx_parts_session ON parts(project_path, session_id);
|
|
96
|
-
|
|
97
|
-
CREATE VIRTUAL TABLE IF NOT EXISTS parts_fts USING fts5(
|
|
98
|
-
text,
|
|
99
|
-
project_path UNINDEXED,
|
|
100
|
-
session_id UNINDEXED,
|
|
101
|
-
part_id UNINDEXED,
|
|
102
|
-
role UNINDEXED,
|
|
103
|
-
timestamp UNINDEXED,
|
|
104
|
-
seq UNINDEXED,
|
|
105
|
-
tokenize = 'unicode61'
|
|
106
|
-
);
|
|
107
|
-
`),_.exec("PRAGMA user_version=5;")}var k_=r("Service"),k;function s(){return B.join(u(),"index.db")}async function B_(){let _=s();if(k&&k.path===_)return k.db;let E=(async()=>{let R=await l(_);if(!R)return null;try{return o(R),R}catch{return null}})();return k={path:_,db:E},E}function A_(){k=void 0}function x_(_){if(_&&typeof _==="object"){let E=_.text;if(typeof E==="string")return E}return null}function w_(_,E,R,W){_.prepare("DELETE FROM parts WHERE project_path=? AND session_id=?").run(E,R),_.prepare("DELETE FROM parts_fts WHERE project_path=? AND session_id=?").run(E,R);let $=new Map;for(let Q of W)if(Q.type==="message_created")$.set(Q.data.messageId,Q.data.role);let M=_.prepare(`INSERT OR REPLACE INTO parts
|
|
108
|
-
(project_path, session_id, part_id, message_id, part_type, role, seq, timestamp, text)
|
|
109
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`),H=_.prepare(`INSERT INTO parts_fts (text, project_path, session_id, part_id, role, timestamp, seq)
|
|
110
|
-
VALUES (?, ?, ?, ?, ?, ?, ?)`);for(let Q of W){if(Q.type!=="part_created"&&Q.type!=="part_updated")continue;if(Q.data.partType!=="text")continue;let Y=x_(Q.data.payload);if(Y===null)continue;let g=$.get(Q.data.messageId)??"assistant",F=Q.seq??0;if(M.run(E,R,Q.data.partId,Q.data.messageId,Q.data.partType,g,F,Q.timestamp,Y),g==="user"||g==="assistant")H.run(Y,E,R,Q.data.partId,g,Q.timestamp,F)}}function D_(_,E){_.prepare(`INSERT INTO sessions
|
|
111
|
-
(project_path, session_id, root_id, parent_id, relation_type, title,
|
|
112
|
-
agent_type, model, task_status, task_priority, task_kind, task_due_at,
|
|
113
|
-
archived_at, last_message_time, project_sort_key,
|
|
114
|
-
session_sort_key, first_message_time, message_count, has_errors,
|
|
115
|
-
is_subagent, metadata_json)
|
|
116
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
117
|
-
ON CONFLICT(project_path, session_id) DO UPDATE SET
|
|
118
|
-
root_id=excluded.root_id, parent_id=excluded.parent_id,
|
|
119
|
-
relation_type=excluded.relation_type, title=excluded.title,
|
|
120
|
-
agent_type=excluded.agent_type, model=excluded.model,
|
|
121
|
-
task_status=excluded.task_status, task_priority=excluded.task_priority,
|
|
122
|
-
task_kind=excluded.task_kind, task_due_at=excluded.task_due_at,
|
|
123
|
-
archived_at=excluded.archived_at,
|
|
124
|
-
last_message_time=excluded.last_message_time,
|
|
125
|
-
project_sort_key=excluded.project_sort_key,
|
|
126
|
-
session_sort_key=excluded.session_sort_key,
|
|
127
|
-
first_message_time=excluded.first_message_time, message_count=excluded.message_count,
|
|
128
|
-
has_errors=excluded.has_errors, is_subagent=excluded.is_subagent,
|
|
129
|
-
metadata_json=excluded.metadata_json`).run(E.projectPath,E.sessionId,E.rootId,E.parentId??null,E.relationType??null,E.title??null,E.agentType??null,E.model??null,E.taskStatus,E.taskPriority??null,E.taskKind??null,E.taskDueAt??null,E.archivedAt??null,E.lastMessageTime,J(E.projectPath),J(E.sessionId),E.firstMessageTime,E.messageCount,E.hasErrors?1:0,E.relationType==="subagent"?1:0,JSON.stringify(E))}function t(_,E,R){for(let W of["sessions","parts","parts_fts"])_.prepare(`DELETE FROM ${W} WHERE project_path=? AND session_id=?`).run(E,R)}function p(_,E,R){t(_,E,R),_.prepare("DELETE FROM projection_state WHERE project_path=? AND session_id=?").run(E,R)}function L(_,E,R,W,$,M){_.prepare(`INSERT INTO projection_state
|
|
130
|
-
(project_path, session_id, last_seq, file_size, mtime_ms)
|
|
131
|
-
VALUES (?, ?, ?, ?, ?)
|
|
132
|
-
ON CONFLICT(project_path, session_id) DO UPDATE SET
|
|
133
|
-
last_seq=excluded.last_seq, file_size=excluded.file_size,
|
|
134
|
-
mtime_ms=excluded.mtime_ms`).run(E,R,W,$,M)}async function y_(_,E,R,W,$=j(R,E)){let M;try{let V=await a($);M={size:V.size,mtimeMs:V.mtimeMs}}catch{return _.transaction(()=>p(_,R,E)),!0}let H=_.prepare("SELECT last_seq, file_size, mtime_ms FROM projection_state WHERE project_path=? AND session_id=?").get(R,E);if(H&&H.file_size===M.size&&H.mtime_ms===Math.floor(M.mtimeMs))return!1;let Y=await new G($).readAll(),g=Y.reduce((V,Z)=>typeof Z.seq==="number"&&Z.seq>V?Z.seq:V,0),F=w(Y),T=W(Y,E,R);if(Y.length===0||!T)return _.transaction(()=>{t(_,R,E),L(_,R,E,g,M.size,Math.floor(M.mtimeMs))}),!0;let C=_.prepare("SELECT last_message_time FROM sessions WHERE project_path=? AND session_id=?").get(T.projectPath,T.sessionId),A=B.resolve($)===B.resolve(j(T.projectPath,T.sessionId));if(C&&!A&&typeof C.last_message_time==="string"&&C.last_message_time>T.lastMessageTime)return L(_,R,E,g,M.size,Math.floor(M.mtimeMs)),!0;return _.transaction(()=>{D_(_,T),w_(_,T.projectPath,T.sessionId,F),L(_,R,E,g,M.size,Math.floor(M.mtimeMs))}),!0}var n=new WeakMap;async function z_(_,E,R=0){let W=n.get(_)??{};if(n.set(_,W),W.inFlight)return W.inFlight;if(R>0&&W.lastCompletedAt!==void 0&&Date.now()-W.lastCompletedAt<=R)return;let $=I_(_,E);W.inFlight=$;try{await $,W.lastCompletedAt=Date.now()}finally{if(W.inFlight===$)W.inFlight=void 0}}async function I_(_,E){let{readdir:R}=await import("node:fs/promises"),W=await i(),$=new Set,H=(await Promise.all(W.map(async(V)=>{let Z=d(V),K=B.join(u(),"projects",V);try{return(await R(K)).flatMap((q)=>{if(!q.endsWith(".jsonl"))return[];let P=q.slice(0,-6);if(!x(P))return[];return[{filePath:B.join(K,q),projectPath:Z,sessionId:P}]})}catch{return[]}}))).flat();for(let V of H)$.add(`${V.projectPath}\x00${V.sessionId}`);let Q=_.prepare(`SELECT project_path, session_id, last_seq, file_size, mtime_ms
|
|
135
|
-
FROM projection_state`).all(),Y=new Map(Q.map((V)=>[`${V.project_path}\x00${V.session_id}`,V])),g=[],F=Math.min(128,H.length),T=0;await Promise.all(Array.from({length:F},async()=>{while(T<H.length){let V=H[T++];if(!V)continue;try{let Z=await a(V.filePath),K=Y.get(`${V.projectPath}\x00${V.sessionId}`);if(K&&K.file_size===Z.size&&K.mtime_ms===Math.floor(Z.mtimeMs))continue}catch{}g.push(V)}}));let C=Math.min(32,g.length),A=0;await Promise.all(Array.from({length:C},async()=>{while(A<g.length){let V=g[A++];if(!V)continue;try{await y_(_,V.sessionId,V.projectPath,E,V.filePath)}catch(Z){if(Z.code!=="ENOENT")k_.warn(`[SessionService] Skipping invalid session transcript: ${V.sessionId}`)}}}));for(let V of Q)if(!$.has(`${V.project_path}\x00${V.session_id}`))_.transaction(()=>p(_,V.project_path,V.session_id))}function t_(_,E,R){_.transaction(()=>p(_,R,E))}async function e_(_){let{rm:E}=await import("node:fs/promises");A_();let R=s();for(let M of["","-wal","-shm"])await E(`${R}${M}`,{force:!0}).catch(()=>{return});let W=await B_();if(!W)return null;return await z_(W,_),W.prepare("SELECT COUNT(*) c FROM sessions").get()?.c??0}function _E(_,E,R,W){let $=E.replace(/["*]/g," ").trim().split(/\s+/)[0];if(!$)return[];let M=`"${$}"*`,H=R?`SELECT session_id, role, timestamp, text FROM parts_fts
|
|
136
|
-
WHERE parts_fts MATCH ? AND project_path = ?
|
|
137
|
-
ORDER BY timestamp DESC LIMIT ?`:`SELECT session_id, role, timestamp, text FROM parts_fts
|
|
138
|
-
WHERE parts_fts MATCH ?
|
|
139
|
-
ORDER BY timestamp DESC LIMIT ?`,Q=_.prepare(H);return R?Q.all(M,R,W):Q.all(M,W)}
|
|
140
|
-
export{w as $d,j_ as ae,u_ as be,y as ce,G as de,J as ee,V_ as fe,O_ as ge,N_ as he,Y_ as ie,f_ as je,s as ke,B_ as le,A_ as me,y_ as ne,z_ as oe,t_ as pe,e_ as qe,_E as re};
|
package/dist/chunk-y3jbc2xx.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ue as a,ve as b,we as c}from"./chunk-t23n4wn0.js";import"./chunk-1b2dkwpv.js";import"./chunk-gqv0vkg9.js";import"./chunk-v508x7cg.js";import"./chunk-ye4wyq1k.js";import"./chunk-85bamng3.js";import"./chunk-m76jmvsf.js";import"./chunk-y94239bb.js";import"./chunk-cw2b3383.js";import"./chunk-2j2mnzdg.js";import"./chunk-s6562rsq.js";import"./chunk-hbafhk9y.js";import"./chunk-68sf54n4.js";import"./chunk-sv833k2e.js";import"./chunk-w7n73ag8.js";import"./chunk-a3ewfebr.js";import"./chunk-1g0d9yw0.js";import"./chunk-6kwg4hcv.js";import"./chunk-9xzw649r.js";import"./chunk-hmwz31tc.js";export{a as validatePermissions,c as validateOutput,b as loadConfiguration};
|
package/dist/chunk-yc64nfym.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{se as a,te as b}from"./chunk-t727txa9.js";import"./chunk-a3ewfebr.js";import"./chunk-hmwz31tc.js";export{a as globalOptions,b as cliConfig};
|
package/dist/chunk-yqh061d8.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$e as m,Pe as a,Qe as b,Re as c,Se as d,Te as e,Ue as f,Ve as g,We as h,Xe as i,Ye as j,Ze as k,_e as l,af as n,bf as o,cf as p,df as q}from"./chunk-gqv0vkg9.js";import"./chunk-v508x7cg.js";import"./chunk-ye4wyq1k.js";import"./chunk-m76jmvsf.js";import"./chunk-y94239bb.js";import"./chunk-cw2b3383.js";import"./chunk-2j2mnzdg.js";import"./chunk-s6562rsq.js";import"./chunk-hbafhk9y.js";import"./chunk-68sf54n4.js";import"./chunk-sv833k2e.js";import"./chunk-w7n73ag8.js";import"./chunk-a3ewfebr.js";import"./chunk-1g0d9yw0.js";import"./chunk-6kwg4hcv.js";import"./chunk-9xzw649r.js";import"./chunk-hmwz31tc.js";export{a as vanillaStore,c as sessionActions,l as getThinkingModeEnabled,b as getState,n as getServiceTier,o as getResponseVerbosity,m as getReasoningEffort,j as getModelById,e as getMessages,k as getMcpServers,i as getCurrentModel,f as getConfig,p as getCommunicationStyle,h as getAllModels,g as ensureStoreInitialized,q as configActions,d as appActions};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownRenderer-3g4TPTeI.js","assets/index-DaiT-mmo.js","assets/vendor-react-DofNRwfy.js","assets/vendor-radix-Bc1_Q9tz.js","assets/session-events-CWzF04l4.js","assets/index-DGf6Z2kM.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as m,j as e}from"./vendor-react-DofNRwfy.js";import{c as W,u as P,a as N,s as Be,b as tt,d as se,H as Ce,P as st,G as _e,L as _,S as Pe,T as ae,C as ue,D as Le,e as Ve,f as at,g as Oe,h as Ue,i as He,j as F,k as rt,l as X,B as nt,m as ve,n as re,o as ne,R as le,F as it,_ as qe,p as ot,q as lt,r as ze,t as ct,v as Ke,X as Ge,w as dt,A as ye,x as ut,W as mt,y as ht,z as xt,E as pt}from"./index-DaiT-mmo.js";import{l as we,m as ft,g as bt,n as vt,f as gt,t as kt,k as jt}from"./session-events-CWzF04l4.js";import{A as yt,E as wt}from"./external-link-UkIIC2ds.js";import{A as We,C as Nt}from"./chevrons-up-down-BboZzEAk.js";import{j as St,k as Ct,l as Et,m as Je}from"./vendor-radix-Bc1_Q9tz.js";import{P as Tt}from"./pause-DVIT6IIr.js";import{P as Mt}from"./play-DsdF5dji.js";import{C as At}from"./clock-3-aXgeptZP.js";import{t as I}from"./team-QZ9byb3E.js";import{teamService as Ee}from"./teamService-BliaDj1Z.js";/**
|
|
3
|
-
* @license lucide-react v0.300.0 - ISC
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the ISC license.
|
|
6
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/const Qe=W("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
|
|
8
|
-
* @license lucide-react v0.300.0 - ISC
|
|
9
|
-
*
|
|
10
|
-
* This source code is licensed under the ISC license.
|
|
11
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
12
|
-
*/const Rt=W("Files",[["path",{d:"M15.5 2H8.6c-.4 0-.8.2-1.1.5-.3.3-.5.7-.5 1.1v12.8c0 .4.2.8.5 1.1.3.3.7.5 1.1.5h9.8c.4 0 .8-.2 1.1-.5.3-.3.5-.7.5-1.1V6.5L15.5 2z",key:"cennsq"}],["path",{d:"M3 7.6v12.8c0 .4.2.8.5 1.1.3.3.7.5 1.1.5h9.8",key:"ms809a"}],["path",{d:"M15 2v5h5",key:"qq6kwv"}]]);/**
|
|
13
|
-
* @license lucide-react v0.300.0 - ISC
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the ISC license.
|
|
16
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/const Ft=W("Gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]);/**
|
|
18
|
-
* @license lucide-react v0.300.0 - ISC
|
|
19
|
-
*
|
|
20
|
-
* This source code is licensed under the ISC license.
|
|
21
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
22
|
-
*/const $t=W("HelpCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
|
|
23
|
-
* @license lucide-react v0.300.0 - ISC
|
|
24
|
-
*
|
|
25
|
-
* This source code is licensed under the ISC license.
|
|
26
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
27
|
-
*/const Dt=W("MessageCircleQuestion",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
|
|
28
|
-
* @license lucide-react v0.300.0 - ISC
|
|
29
|
-
*
|
|
30
|
-
* This source code is licensed under the ISC license.
|
|
31
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
32
|
-
*/const It=W("Target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/**
|
|
33
|
-
* @license lucide-react v0.300.0 - ISC
|
|
34
|
-
*
|
|
35
|
-
* This source code is licensed under the ISC license.
|
|
36
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
37
|
-
*/const Bt=W("Timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]);/**
|
|
38
|
-
* @license lucide-react v0.300.0 - ISC
|
|
39
|
-
*
|
|
40
|
-
* This source code is licensed under the ISC license.
|
|
41
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
42
|
-
*/const _t=W("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 Te(t){return t.split("/").filter(Boolean).at(-1)||t}function Pt(){const t=P(),s=N(v=>v.sessions),a=N(v=>v.currentSessionRef),r=N(v=>v.taskDeliveryActions),i=N(v=>v.deliverTask),n=we(v=>v.openFilePreview),[l,h]=m.useState(!1),d=s.find(v=>Be({sessionId:v.sessionId,projectPath:v.projectPath},a));if(!(d!=null&&d.taskIsolation))return null;const c=d.taskDiffStat,k=d.taskIsolation==="worktree",o=tt(d),f=r[se(o)],p=d.taskDelivery,y=(p==null?void 0:p.status)==="conflicted",S=!!(c&&(c.changedFiles>0||c.commits>0)),x=!["queued","running"].includes(d.taskStatus),E=(p==null?void 0:p.status)==="applied"||(p==null?void 0:p.status)==="discarded",g=k&&S&&x&&!E,u=c?c.additions+c.deletions:0,b=u>0&&c?c.additions/u*100:0,A=v=>{i(o,v).catch(()=>{})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex min-h-10 flex-wrap items-center gap-x-3 gap-y-1.5 border-b border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))]/60 px-3 py-1.5 font-mono text-[10.5px] text-[hsl(var(--deck-ink-muted))] backdrop-blur-sm sm:px-5",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[e.jsx(Ce,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"truncate text-[hsl(var(--deck-ink))]",children:Te(d.taskSourceProjectPath||d.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:[k?e.jsx(st,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-accent))]"}):e.jsx(Ce,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:k?"text-[hsl(var(--deck-accent))]":void 0,children:t(k?"artifact.env.isolated":"artifact.env.local")})]}),d.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:d.taskWorktreeBranch,children:[e.jsx(_e,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"truncate",children:d.taskWorktreeBranch})]})]})]}),c&&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(Rt,{className:"h-3 w-3 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"tabular-nums",children:c.changedFiles})]}),u>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:`${b}%`}}),e.jsx("span",{className:"h-full bg-red-500/80",style:{width:`${100-b}%`}})]}),e.jsxs("span",{className:"tabular-nums text-[hsl(var(--deck-accent))]",children:["+",c.additions]}),e.jsxs("span",{className:"tabular-nums text-red-600 dark:text-red-400",children:["-",c.deletions]}),c.commits>0&&e.jsx("span",{className:"hidden tabular-nums text-[hsl(var(--deck-ink-faint))] sm:inline",children:t("artifact.commits",{count:c.commits})}),S&&(p==null?void 0:p.status)!=="discarded"&&e.jsx("button",{type:"button",onClick:()=>n({tab:"diff"}),className:"inline-flex items-center gap-1 rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-2 py-1 text-[hsl(var(--deck-ink))] transition hover:border-[hsl(var(--deck-accent)/0.55)] hover:text-[hsl(var(--deck-accent))]",children:t("artifact.review")}),g&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",disabled:!!f,onClick:()=>A("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:[f==="apply"?e.jsx(_,{className:"h-3 w-3 animate-spin"}):e.jsx(Pe,{className:"h-3 w-3"}),t(f==="apply"?"artifact.applying":y?"artifact.retryApply":"artifact.apply")]}),e.jsx("button",{type:"button",disabled:!!f,onClick:()=>h(!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:f==="discard"?e.jsx(_,{className:"h-3 w-3 animate-spin"}):e.jsx(ae,{className:"h-3 w-3"})})]}),(p==null?void 0:p.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(ue,{className:"h-3 w-3"}),t("artifact.applied")]}),(p==null?void 0:p.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(ae,{className:"h-3 w-3"}),t("artifact.discarded")]})]}),(p==null?void 0:p.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(yt,{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:p.message||t("artifact.conflict")}),e.jsx("span",{className:"block text-[hsl(var(--deck-ink-faint))]",children:t("artifact.conflictHint")})]})]})]}),e.jsx(Le,{open:l,onOpenChange:h,children:e.jsxs(Ve,{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(at,{children:[e.jsx(Oe,{children:t("artifact.discardDialog.title")}),e.jsx(Ue,{className:"text-[hsl(var(--deck-ink-muted))]",children:t("artifact.discardDialog.description",{project:Te(d.taskSourceProjectPath||d.projectPath),count:(c==null?void 0:c.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(He,{className:"gap-2 sm:space-x-0",children:[e.jsx("button",{type:"button",onClick:()=>h(!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:()=>{h(!1),A("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(ae,{className:"h-3.5 w-3.5"}),t("artifact.discardDialog.confirm")]})]})]})})]})}const Lt=new Set(["completed","stale","failed","aborted","interrupted"]),Vt={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"},Ot={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 ce(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:void 0}function Ut(t){const s=ce(t),a=ce(s==null?void 0:s.codeLocation),r=s==null?void 0:s.priority,i=s==null?void 0:s.confidenceScore,n=a==null?void 0:a.lineStart,l=a==null?void 0:a.lineEnd;if(!(typeof(s==null?void 0:s.title)!="string"||typeof s.body!="string"||r!==0&&r!==1&&r!==2&&r!==3||typeof i!="number"||!Number.isFinite(i)||typeof(a==null?void 0:a.path)!="string"||!Number.isInteger(n)||!Number.isInteger(l)))return{title:s.title,body:s.body,priority:r,confidenceScore:i,codeLocation:{path:a.path,lineStart:n,lineEnd:l}}}function Ht(t){const s=ce(t),a=ce(s==null?void 0:s.target);if((s==null?void 0:s.phase)!=="completed"||typeof s.status!="string"||!Lt.has(s.status)||typeof(a==null?void 0:a.label)!="string"||a.kind!=="uncommitted"&&a.kind!=="base"&&a.kind!=="commit"||typeof s.overallExplanation!="string"||!Array.isArray(s.findings))return;const r=s.findings.map(Ut);if(!r.some(i=>i===void 0))return{status:s.status,target:{kind:a.kind,label:a.label,...typeof a.reference=="string"?{reference:a.reference}:{}},overallExplanation:s.overallExplanation,findings:r,...typeof s.error=="string"?{error:s.error}:{}}}function qt(t){const{path:s,lineStart:a,lineEnd:r}=t.codeLocation;return a===r?`${s}:L${a}`:`${s}:L${a}-${r}`}function zt({report:t}){const s=P(),a=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"),": ",a]})]}),e.jsxs("span",{className:F("rounded-full border px-2.5 py-1 font-mono text-[10.5px] font-medium",Ot[t.status]),children:[s("chat.review.status"),": ",s(Vt[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((r,i)=>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:r.title}),e.jsx("span",{className:"shrink-0 font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:s("chat.review.confidence",{value:r.confidenceScore.toFixed(2)})})]}),e.jsx("code",{className:"mt-1 block text-[10.5px] text-[hsl(var(--deck-accent))]",children:qt(r)}),e.jsx("p",{className:"mt-1.5 whitespace-pre-wrap text-[12px] leading-5 text-[hsl(var(--deck-ink-muted))]",children:r.body})]},`${r.codeLocation.path}:${r.codeLocation.lineStart}:${i}`))})]}),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 Kt({elicitation:t,messageId:s}){const a=P(),r=N(g=>g.currentSessionRef),i=N(g=>g.setElicitation),[n,l]=m.useState(()=>Wt(t.details.fields??[])),[h,d]=m.useState(()=>Jt(t.details.fields??[])),[c,k]=m.useState(!1),[o,f]=m.useState(),p=t.details.fields??[],y=m.useMemo(()=>p.every(g=>{var b;if(!g.required)return!0;if(me(g))return!!((b=h[g.name])!=null&&b.trim()||g.defaultValue!==void 0);const u=n[g.name]??g.defaultValue;return Array.isArray(u)?u.length>0:u!==void 0}),[p,h,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:a(t.status==="cancelled"?"interaction.elicitation.cancelled":"interaction.elicitation.responded")});const S=async(g,u)=>{if(!(!r||c)){k(!0),f(void 0);try{await X.respondToElicitation(r,t.toolCallId,{action:g,...u?{content:u}:{}}),i(s,{...t,status:"responded"})}catch(b){f(b instanceof Error?b.message:a("interaction.elicitation.failed"))}finally{k(!1)}}},x=async()=>{try{await S("accept",Qt(p,n,h))}catch(g){f(g instanceof Error?g.message:String(g))}},E=()=>{const g=t.details.url;if(!g){f("MCP URL is unavailable");return}if(!window.open(g,"_blank","noopener,noreferrer")){f("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(rt,{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:[a("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:a("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(Z,{onClick:E,disabled:c,primary:!0,label:a("interaction.elicitation.open"),icon:e.jsx(wt,{className:"h-3.5 w-3.5"})}),e.jsx(Z,{onClick:()=>void S("decline"),disabled:c,label:a("interaction.elicitation.decline")}),e.jsx(Z,{onClick:()=>void S("cancel"),disabled:c,label:a("interaction.elicitation.cancel")})]})]}):e.jsxs("div",{className:"space-y-4",children:[p.map(g=>e.jsx(Gt,{field:g,value:n[g.name],rawValue:h[g.name]??"",onValueChange:u=>l(b=>({...b,[g.name]:u})),onRawChange:u=>d(b=>({...b,[g.name]:u}))},g.name)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(Z,{onClick:()=>void x(),disabled:c||!y,primary:!0,label:a("interaction.elicitation.submit"),icon:c?e.jsx(_,{className:"h-3.5 w-3.5 animate-spin"}):null}),e.jsx(Z,{onClick:()=>void S("decline"),disabled:c,label:a("interaction.elicitation.decline")}),e.jsx(Z,{onClick:()=>void S("cancel"),disabled:c,label:a("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 Gt({field:t,value:s,rawValue:a,onValueChange:r,onRawChange:i}){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:Yt(t).map(n=>{const l=Array.isArray(s)?s.includes(n.value):s===n.typedValue;return e.jsx("button",{type:"button","aria-pressed":l,onClick:()=>{if(t.type==="multi-select"){const h=Array.isArray(s)?s:[];r(h.includes(n.value)?h.filter(d=>d!==n.value):[...h,n.value])}else r(n.typedValue)},className:F("rounded-md border px-3 py-2 font-mono text-[12px] transition-colors",l?"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:Xt(t),value:a,onChange:n=>i(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 Z({onClick:t,disabled:s,primary:a=!1,label:r,icon:i}){return e.jsxs("button",{type:"button",onClick:t,disabled:s,className:F("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",a?"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:[i,r]})}function Wt(t){return Object.fromEntries(t.filter(s=>!me(s)&&s.defaultValue!==void 0).map(s=>[s.name,Array.isArray(s.defaultValue)?[...s.defaultValue]:s.defaultValue]))}function Jt(t){return Object.fromEntries(t.filter(s=>me(s)&&s.defaultValue!==void 0).map(s=>[s.name,String(s.defaultValue)]))}function Qt(t,s,a){var i;const r={};for(const n of t){if(me(n)){const h=((i=a[n.name])==null?void 0:i.trim())??"";if(!h){if(n.defaultValue!==void 0)r[n.name]=n.defaultValue;else if(n.required)throw new Error(`${n.title} is required`);continue}if(n.type==="number"||n.type==="integer"){const d=Number(h);if(!Number.isFinite(d))throw new Error(`${n.title} must be a finite number`);if(n.type==="integer"&&!Number.isSafeInteger(d))throw new Error(`${n.title} must be a safe integer`);r[n.name]=d}else r[n.name]=h;continue}const l=s[n.name]??n.defaultValue;if(l===void 0){if(n.required)throw new Error(`${n.title} is required`);continue}if(Array.isArray(l)){if(n.minItems!==void 0&&l.length<n.minItems)throw new Error(`${n.title} requires at least ${n.minItems} choices`);if(n.maxItems!==void 0&&l.length>n.maxItems)throw new Error(`${n.title} allows at most ${n.maxItems} choices`)}r[n.name]=l}return r}function Yt(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 me(t){return t.type==="string"||t.type==="number"||t.type==="integer"}function Xt(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 Zt(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 es({report:t}){const s=P(),[a,r]=m.useState(!1),i=JSON.stringify(t.output,null,2),n=async()=>{try{await navigator.clipboard.writeText(i),r(!0),window.setTimeout(()=>r(!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(nt,{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:a?e.jsx(ue,{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:i})]})}const ts=m.lazy(()=>qe(()=>import("./MarkdownRenderer-3g4TPTeI.js").then(t=>t.M),__vite__mapDeps([0,1,2,3,4,5])).then(t=>({default:t.MarkdownRenderer})));function Me({text:t,label:s}){const[a,r]=m.useState(!1);if(!t.trim())return null;const i=async()=>{try{await navigator.clipboard.writeText(t),r(!0),window.setTimeout(()=>r(!1),1400)}catch{}};return e.jsx("button",{type:"button","aria-label":s,title:s,onClick:i,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:a?e.jsx(ue,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}):e.jsx(Qe,{className:"h-3.5 w-3.5"})})}function ss(){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(ve,{size:20,pulse:!1})})}function as(){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 Ae(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 rs(t){if(typeof t=="string")return{text:Ae(t),images:[]};const s=t.filter(r=>r.type==="text").map(r=>r.text).join(`
|
|
43
|
-
`),a=t.filter(r=>r.type==="image_url").map(r=>r.image_url.url);return{text:Ae(s),images:a}}function Ne(t){return typeof t=="string"?t:t.filter(s=>s.type==="text").map(s=>s.text).join(`
|
|
44
|
-
`)}function ns(t){const s=t.agentContent;return s?ft(s):Ne(t.content)}function Re({content:t,syntaxHighlight:s=!0}){return e.jsx(m.Suspense,{fallback:e.jsx("pre",{className:"text-[14px] text-[hsl(var(--deck-ink))] font-mono whitespace-pre-wrap",children:t}),children:e.jsx(ts,{content:t,syntaxHighlight:s})})}function Se({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]"},a={running:"Running",success:"Success",error:"Error",pending:"Pending",info:"Info"};return e.jsx("span",{className:F("text-[11px] px-2 py-0.5 rounded-full font-mono",s[t]),children:a[t]})}function is(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 Fe=500;function Ye(t,s){if(t.length<=s)return t;let a=Math.max(0,s);return a>0&&/[\uD800-\uDBFF]/.test(t.charAt(a-1))&&(a-=1),t.slice(0,a)}function $e(t,s){if(t.length<=s)return t;let a=Math.max(0,t.length-s);return/[\uDC00-\uDFFF]/.test(t.charAt(a))&&(a+=1),t.slice(a)}function xe(t,s){if(t.length<=s)return t;if(s<=0)return"";const a=`
|
|
45
|
-
... (display clipped) ...
|
|
46
|
-
`,r=s-a.length;if(r<=0)return $e(t,s);const i=Math.floor(r/3);return`${Ye(t,i)}${a}${$e(t,r-i)}`}function os(t){const s=t.split(`
|
|
47
|
-
`),a=s.at(-1),r=a!=null&&a.startsWith("Output truncated")?a:void 0,i=r?s.slice(0,-1).join(`
|
|
48
|
-
`):t,n=r?`
|
|
49
|
-
${r}`:"",l=Math.max(0,Fe-n.length),d=i.indexOf(`
|
|
50
|
-
stderr:
|
|
51
|
-
`);let c;if(d>=0&&i.includes(`
|
|
52
|
-
stdout:
|
|
53
|
-
`)){const k=i.slice(0,d),o=i.slice(d+1),f=Math.max(0,l-1),p=Math.floor(f/2);c=`${xe(k,p)}
|
|
54
|
-
${xe(o,f-p)}`}else c=xe(i,l);return{body:Ye(c,l),...r?{notice:r}:{},truncated:!!r||t.length>Fe}}function ls({tool:t}){const[s,a]=m.useState(!1),r=is(t.arguments),i=t.output?os(t.output):void 0;return e.jsxs("div",{"data-tool-name":t.toolName,"data-tool-status":t.status,"data-tool-truncated":i!=null&&i.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:()=>a(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(re,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))] shrink-0"}):e.jsx(ne,{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(Se,{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:[r&&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:r})]}),i&&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:[i.body,i.notice&&e.jsxs(e.Fragment,{children:[`
|
|
55
|
-
`,e.jsx("span",{"data-tool-truncation-notice":!0,children:i.notice})]})]})]})]})]})}function Xe({toolCalls:t}){return t.length===0?null:e.jsx("div",{className:"space-y-2",children:t.map(s=>e.jsx(ls,{tool:s},s.toolCallId))})}function cs({toolCalls:t,toolCallIds:s}){const a=P(),[r,i]=m.useState(!1),n=m.useMemo(()=>new Map(t.map(o=>[o.toolCallId,o])),[t]),l=s.flatMap(o=>{const f=n.get(o);return f?[f]:[]});if(l.length===0)return null;const h=l.filter(o=>o.status==="running").length,d=l.filter(o=>o.status==="error").length,c=[...l].reverse().find(o=>o.status==="running"&&!!o.progressMessage),k=h>0?a(l.length===1?"chat.timeline.tools.runningOne":"chat.timeline.tools.running",{count:l.length}):d>0?a(l.length===1?"chat.timeline.tools.completedOneWithError":"chat.timeline.tools.completedWithErrors",{count:l.length,errors:d}):a(l.length===1?"chat.timeline.tools.completedOne":"chat.timeline.tools.completed",{count:l.length});return e.jsxs("div",{"data-agent-tool-group":!0,className:"py-0.5",children:[e.jsxs("button",{type:"button","aria-expanded":r,onClick:()=>i(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:[r?e.jsx(re,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(ne,{className:"h-3.5 w-3.5 shrink-0"}),h>0&&e.jsx(_,{className:"h-3 w-3 shrink-0 animate-spin text-[hsl(var(--deck-accent))]"}),e.jsx("span",{children:k}),(c==null?void 0:c.progressMessage)&&e.jsxs("span",{className:"min-w-0 truncate text-[10.5px] text-[hsl(var(--deck-ink-muted))]",children:[c.progressMessage,c.progress!==void 0&&c.progressTotal!==void 0&&` · ${Math.max(0,Math.min(100,Math.round(c.progress/c.progressTotal*100)))}%`]})]}),(c==null?void 0:c.progress)!==void 0&&c.progressTotal!==void 0&&e.jsx("div",{role:"progressbar","aria-label":`${c.toolName} progress`,"aria-valuemin":0,"aria-valuemax":c.progressTotal,"aria-valuenow":Math.min(c.progress,c.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,c.progress/c.progressTotal*100))}%`}})}),r&&e.jsx("div",{"data-agent-tool-group-details":!0,className:"mt-2 space-y-2 pl-1",children:e.jsx(Xe,{toolCalls:l})})]})}function ds({content:t}){const s=P(),[a,r]=m.useState(!1);return t?e.jsxs("div",{"data-agent-thinking":!0,className:"py-0.5",children:[e.jsxs("button",{type:"button","aria-expanded":a,onClick:()=>r(i=>!i),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:[a?e.jsx(re,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))]"}):e.jsx(ne,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{children:s("chat.timeline.thinking")})]}),a&&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 us({tasks:t}){if(t.length===0)return null;const s=t.filter(r=>r.status==="completed").length,a=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:a?"✓ All tasks done":`Tasks: ${s}/${t.length}`})})})}function ms({toolCalls:t}){const s=we(r=>r.openFilePreview),a=m.useMemo(()=>{const r=new Map,i=["Write","SearchReplace","Edit","ApplyPatch"];for(const n of t){if(n.status!=="success")continue;const l=n.metadata;if(n.toolName==="ApplyPatch"&&Array.isArray(l==null?void 0:l.changes)){for(const d of l.changes)d&&typeof d=="object"&&"path"in d&&typeof d.path=="string"&&r.set(d.path,{path:d.path,toolName:n.toolName});continue}const h=l==null?void 0:l.file_path;h&&i.includes(n.toolName)&&r.set(h,{path:h,toolName:n.toolName})}return Array.from(r.values())},[t]);return a.length===0?null:e.jsxs("div",{className:"bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-lg px-3 py-2",children:[e.jsxs("div",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono mb-1.5",children:["Changed files (",a.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:a.map(({path:r})=>{const i=r.split("/").pop()||r;return e.jsxs("button",{onClick:()=>s({tab:"diff",targetPath:r}),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:r,children:[e.jsx(it,{className:"w-3 h-3"}),i]},r)})})]})}function hs({subagent:t}){var G,K,J,Q;const s=P(),[a,r]=m.useState(null),[i,n]=m.useState(!1),[l,h]=m.useState(null),[d,c]=m.useState(!1),[k,o]=m.useState(""),[f,p]=m.useState(!1),[y,S]=m.useState(null),[x,E]=m.useState(null),[g,u]=m.useState(null),b=N(R=>R.currentSessionRef),A=N(R=>R.isStreaming),v=N(R=>R.isTemporarySession);if(!t)return null;const C=t.status==="running",D=a!==null?a:C,z=t.toolCalls||l||[],O=t.output||t.thinking||z.length>0||t.sessionId,w=x&&x.status!=="running"?x:g,M=(w==null?void 0:w.id)??t.sessionId,$=((G=w==null?void 0:w.restartRecovery)==null?void 0:G.outcome)==="failed",B=!C&&!A&&!v&&!$&&(x==null?void 0:x.status)!=="running"&&!!(M&&b);m.useEffect(()=>{if(!D||C||!t.sessionId||!(b!=null&&b.projectPath)||l!==null||t.toolCalls&&t.toolCalls.length>0)return;let R=!0;return n(!0),X.getMessages({sessionId:t.sessionId,projectPath:b.projectPath}).then(U=>{var L,T;if(!R)return;const H=gt(U),j=new Map;for(const q of H)if((T=(L=q.agentContent)==null?void 0:L.toolCalls)!=null&&T.length)for(const he of q.agentContent.toolCalls)j.has(he.toolCallId)||j.set(he.toolCallId,he);h(Array.from(j.values()))}).finally(()=>{R&&n(!1)}),()=>{R=!1}},[D,C,t.sessionId,t.toolCalls,l,b==null?void 0:b.projectPath]),m.useEffect(()=>{if(!t.sessionId||!b)return;let R=!0;const U=t.rootAgentId??t.sessionId,H=t.resumeDepth??0;return X.listSubagents(b).then(j=>{if(!R)return;u(j.find(T=>T.id===t.sessionId)??null);const L=j.filter(T=>T.id!==t.sessionId&&T.rootAgentId===U&&T.resumeDepth>H).sort((T,q)=>q.resumeDepth-T.resumeDepth||q.lastActiveAt-T.lastActiveAt)[0];L&&E(L)}).catch(()=>{}),()=>{R=!1}},[b==null?void 0:b.sessionId,b==null?void 0:b.projectPath,t.sessionId,t.rootAgentId,t.resumeDepth]),m.useEffect(()=>{if(!x||x.status!=="running"||!b)return;let R=!0;const U=async()=>{try{const L=(await X.listSubagents(b)).find(T=>T.id===x.id);R&&L&&E(L)}catch{}},H=window.setInterval(()=>{U()},1e3);return()=>{R=!1,window.clearInterval(H)}},[b,x==null?void 0:x.id,x==null?void 0:x.status]);const V=async()=>{if(!(!b||!M||!k.trim()||f)){p(!0),S(null);try{const R=await X.resumeSubagent(b,M,k.trim());E(R.session),o(""),c(!1),r(!0)}catch(R){S(R instanceof Error?R.message:s("chat.subagent.resumeFailed"))}finally{p(!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:()=>r(!D),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:[C&&e.jsx(_,{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(Se,{status:t.status==="completed"?"success":t.status==="failed"?"error":"running"}),t.type==="verification"&&t.verificationVerdict&&e.jsx("span",{"data-verification-verdict":t.verificationVerdict,className:F("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})})]}),O&&e.jsx(re,{className:F("h-3.5 w-3.5 text-[hsl(var(--deck-ink-muted))] transition-transform",D&&"rotate-180")})]}),!D&&!C&&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}),D&&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})]}),i&&e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono",children:[e.jsx(_,{className:"w-3 h-3 animate-spin"}),s("chat.subagent.loadingLogs")]}),!i&&z.length>0&&e.jsx(Xe,{toolCalls:z}),x&&e.jsxs("div",{className:"rounded-md border border-[#DDD6FE] bg-[#F5F3FF] p-2 text-[11px] font-mono text-[#5B21B6] dark:border-[#4C1D95] dark:bg-[#1E1B4B] dark:text-[#C4B5FD]",children:[e.jsx("div",{children:s("chat.subagent.resumedAs",{id:x.id,status:x.status,depth:x.resumeDepth??1})}),(((K=x.result)==null?void 0:K.message)||((J=x.result)==null?void 0:J.error))&&e.jsx("div",{className:"mt-1 whitespace-pre-wrap text-[hsl(var(--deck-ink))]",children:x.result.message||x.result.error})]}),$&&((Q=w==null?void 0:w.result)==null?void 0:Q.error)&&e.jsx("div",{role:"alert",className:"text-[11px] text-red-600",children:w.result.error}),B&&e.jsxs("div",{className:"space-y-2",children:[d?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:k,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:()=>{c(!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 V(),disabled:!k.trim()||f,className:"flex items-center gap-1 rounded bg-[#7C3AED] px-2 py-1 text-[11px] font-medium text-white disabled:opacity-50",children:[f&&e.jsx(_,{className:"w-3 h-3 animate-spin"}),s("chat.subagent.resumeAgent")]})]})]}):e.jsxs("button",{type:"button","aria-label":s("chat.subagent.resumeAria"),onClick:()=>c(!0),className:"flex items-center gap-1.5 rounded-md border border-[#D1D5DB] px-2 py-1 text-[11px] font-medium text-[#374151] transition-colors hover:bg-[#F3F4F6] dark:border-[#3f3f46] dark:text-[#d4d4d8] dark:hover:bg-[#27272a]",children:[e.jsx(le,{className:"w-3 h-3"}),s("chat.subagent.resume")]}),y&&e.jsx("div",{role:"alert",className:"text-[11px] text-red-600",children:y})]})]})]})}function xs({confirmation:t,messageId:s}){const a=P(),[r,i]=m.useState(!1),[n,l]=m.useState(null),h=N(k=>k.currentSessionRef),d=N(k=>k.setConfirmation);if(!t)return null;const c=async(k,o)=>{if(!(!h||r)){i(!0),l(null);try{await X.respondPermission(h,t.toolCallId,{approved:k,scope:o}),d(s,{...t,status:k?"approved":"denied"})}catch(f){l(f instanceof Error?f.message:a("interaction.permission.failed"))}finally{i(!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:a("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 c(!0,"once"),disabled:r,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:r?e.jsx(_,{className:"h-3.5 w-3.5 animate-spin"}):a("interaction.permission.once")}),t.allowRemember!==!1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>void c(!0,"session"),disabled:r,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:a("interaction.permission.session")}),e.jsx("button",{type:"button",onClick:()=>void c(!0,"project"),disabled:r,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:a("interaction.permission.project")})]}),e.jsx("button",{type:"button",onClick:()=>void c(!1),disabled:r,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:a("interaction.permission.deny")})]})]})}function ps({question:t,messageId:s}){const a=P(),[r,i]=m.useState({}),[n,l]=m.useState({}),[h,d]=m.useState(!1),[c,k]=m.useState(null),o=N(x=>x.currentSessionRef),f=N(x=>x.setQuestion),p=m.useMemo(()=>t?t.questions.reduce((x,E)=>{var A;const g=(A=n[E.header])==null?void 0:A.trim(),u=r[E.header];if(E.multiSelect){const v=Array.isArray(u)?[...u]:[];return g&&v.push(g),v.length>0&&(x[E.header]=v),x}const b=g||(typeof u=="string"?u:"");return b&&(x[E.header]=b),x},{}):{},[r,n,t]),y=(t==null?void 0:t.questions.every(x=>x.header in p))??!1;if(!t)return null;const S=async()=>{if(!(!o||h||!y)){d(!0),k(null);try{await X.respondToQuestion(o,t.toolCallId,p),f(s,{...t,status:"answered",answers:p})}catch(x){k(x instanceof Error?x.message:a("interaction.question.failed"))}finally{d(!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:a("interaction.question.answered")})}):e.jsxs("div",{"data-pending-interaction":"question",tabIndex:-1,role:"alert",className:"space-y-4 rounded-lg border border-amber-300/70 bg-amber-50/70 p-4 outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-800/70 dark:bg-amber-950/25",children:[t.questions.map((x,E)=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-[13px] text-[hsl(var(--deck-ink))] font-mono",children:x.question}),e.jsxs("div",{className:"space-y-1",children:[x.options.map((g,u)=>e.jsxs("button",{type:"button",onClick:()=>{if(x.multiSelect){const b=r[x.header]||[],A=b.includes(g.label)?b.filter(v=>v!==g.label):[...b,g.label];i({...r,[x.header]:A})}else i({...r,[x.header]:g.label}),l({...n,[x.header]:""})},className:F("w-full text-left px-3 py-2 rounded-md border text-[12px] font-mono transition-colors","border-[hsl(var(--deck-border))]",(x.multiSelect?(r[x.header]||[]).includes(g.label):r[x.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})]},u)),e.jsx("input",{"aria-label":`${x.header} other response`,value:n[x.header]??"",onChange:g=>l({...n,[x.header]:g.target.value}),placeholder:a("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)),c&&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:c}),e.jsxs("button",{type:"button",onClick:()=>void S(),disabled:h||!y,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:[h&&e.jsx(_,{className:"h-3.5 w-3.5 animate-spin"}),a("interaction.question.submit")]})]})}function fs({message:t}){const s=t.agentContent,a=N(y=>y.isStreaming&&y.currentAssistantMessageId===t.id);if(!s){const y=Ne(t.content);return y?e.jsx(Re,{content:y}):null}const{toolCalls:r,tasks:i,confirmation:n,question:l,elicitation:h}=s,d=bt(s),c=vt(s);if(!(c.length>0||i.length>0||d.length>0||n||l||h)&&a)return e.jsxs("div",{className:"flex items-center gap-2 text-[hsl(var(--deck-ink-muted))]",children:[e.jsx(_,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{className:"text-[12px] font-mono",children:"Thinking..."})]});const f=r.length>0&&r.every(y=>y.status==="success"||y.status==="error")&&!a,p=!a;return e.jsxs("div",{className:"space-y-3",children:[c.map(y=>y.type==="thinking"?e.jsx("div",{"data-agent-timeline-block":"thinking",children:e.jsx(ds,{content:y.content})},y.id):y.type==="text"?e.jsx("div",{"data-agent-timeline-block":"text",children:e.jsx(Re,{content:y.content,syntaxHighlight:p})},y.id):e.jsx("div",{"data-agent-timeline-block":"tool_group",children:e.jsx(cs,{toolCalls:r,toolCallIds:y.toolCallIds})},y.id)),i.length>0&&e.jsx(us,{tasks:i}),d.map(y=>e.jsx(hs,{subagent:y},y.id)),n&&e.jsx(xs,{confirmation:n,messageId:t.id}),l&&e.jsx(ps,{question:l,messageId:t.id}),h&&e.jsx(Kt,{elicitation:h,messageId:t.id}),f&&e.jsx(ms,{toolCalls:r})]})}function bs({message:t,showAvatar:s=!0}){var h,d,c,k;const a=t.role==="user";if(t.role==="system"){const o=Ne(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(a){const o=(h=t.metadata)!=null&&h.userShellCommand&&typeof t.metadata.userShellCommand=="object"?t.metadata.userShellCommand:(d=t.metadata)!=null&&d.userShellExecution&&typeof t.metadata.userShellExecution=="object"?t.metadata.userShellExecution:void 0;if(o){const y=typeof o.command=="string"?o.command:"",S=o.status==="running"?"running":o.status==="completed"?"success":"error",x=typeof o.output=="string"?o.output:[typeof o.stdout=="string"?o.stdout:"",typeof o.stderr=="string"&&o.stderr?`stderr:
|
|
56
|
-
${o.stderr}`:""].filter(Boolean).join(`
|
|
57
|
-
`);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:"$"}),y]}),e.jsx(Se,{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:x||"(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:f,images:p}=rs(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(Me,{text:f,label:"Copy message"})}),e.jsxs("div",{className:"bg-[hsl(var(--deck-surface-2))] rounded-lg px-4 py-3 max-w-[85%]",children:[f&&e.jsx("p",{className:"text-[14px] text-[hsl(var(--deck-ink))] font-mono leading-relaxed whitespace-pre-wrap",children:f}),p.length>0&&e.jsx("div",{className:F("grid gap-2",p.length===1?"grid-cols-1 mt-0":"grid-cols-2 mt-3"),children:p.map((y,S)=>e.jsx("img",{src:y,alt:`attachment-${S+1}`,className:"object-cover w-full max-h-64 rounded-md"},`${y}-${S}`))})]}),e.jsx(as,{})]})}const i=ns(t),n=Ht((c=t.metadata)==null?void 0:c.codeReview),l=Zt((k=t.metadata)==null?void 0:k.structuredOutput);return e.jsxs("div",{"data-chat-message-id":t.id,"data-chat-role":"assistant",className:F("group flex gap-4 justify-start w-full",s?"p-4":"px-4 pt-0 pb-3"),children:[s?e.jsx(ss,{}):e.jsx("div",{className:"w-8 shrink-0"}),e.jsxs("div",{className:"overflow-hidden flex-1 min-w-0",children:[n?e.jsx(zt,{report:n}):l?e.jsx(es,{report:l}):e.jsx(fs,{message:t}),!l&&i.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(Me,{text:i,label:"Copy response"})})]})]})}const vs=m.memo(bs);function gs(t,s,a){return Math.max(0,t+(a-s))}function ks(t,s,a){return Math.min(s,Math.max(0,t)+Math.max(0,a))}function js(t,s,a,r){const i=new Map(t.filter(l=>!!l.id).map(l=>[l.id,l])),n=new Set(a);for(const l of s){if(!l.id)continue;const h=i.get(l.id);h!==l&&(!h||!r||r(h)!==r(l))&&n.add(l.id)}return n}function De(t,s){return t?t.querySelector(`[data-chat-message-id="${CSS.escape(s)}"]`):null}function ys({turns:t,viewportRef:s,containerRef:a,onRevealTurn:r}){const i=P(),[n,l]=m.useState(null),[h,d]=m.useState(!1),c=m.useRef(null),k=m.useCallback(()=>{var x;const f=s.current,p=a.current;if(!f||!p||t.length===0)return;const y=f.getBoundingClientRect().top;let S=((x=t[0])==null?void 0:x.id)??null;for(const E of t){const g=De(p,E.id);if(g)if(g.getBoundingClientRect().top-y<=24)S=E.id;else break}l(S)},[t,s,a]);m.useEffect(()=>{const f=s.current;if(!f)return;const p=()=>{c.current===null&&(c.current=window.requestAnimationFrame(()=>{c.current=null,k()}))};return k(),f.addEventListener("scroll",p,{passive:!0}),()=>{f.removeEventListener("scroll",p),c.current!==null&&(window.cancelAnimationFrame(c.current),c.current=null)}},[k,s]);const o=m.useCallback(f=>{const p=()=>{const S=De(a.current,f.id);S&&(S.scrollIntoView({behavior:"smooth",block:"start"}),l(f.id))};r(f.index)?p():window.requestAnimationFrame(()=>window.requestAnimationFrame(p))},[a,r]);return t.length<2?null:e.jsx("nav",{"aria-label":i("chat.turns.aria"),className:"absolute right-1 top-1/2 z-20 hidden -translate-y-1/2 sm:block",onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),onFocusCapture:()=>d(!0),onBlurCapture:f=>{f.currentTarget.contains(f.relatedTarget)||d(!1)},children:e.jsxs("div",{className:"relative flex items-center justify-end",children:[e.jsx("ul",{className:F("flex flex-col items-center gap-2 py-2 transition-opacity",h?"opacity-0":"opacity-100"),"aria-hidden":h,children:t.map(f=>e.jsx("li",{children:e.jsx("span",{className:F("block rounded-full transition-all",f.id===n?"h-2 w-2 bg-[hsl(var(--deck-accent))]":"h-1.5 w-1.5 bg-[hsl(var(--deck-ink-faint))]/40")})},f.id))}),e.jsx("div",{className:F("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",h?"pointer-events-auto translate-x-0 opacity-100":"pointer-events-none translate-x-2 opacity-0"),children:t.map((f,p)=>e.jsxs("button",{type:"button",onClick:()=>o(f),className:F("flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left transition-colors",f.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:F("mt-1 h-1.5 w-1.5 shrink-0 rounded-full",f.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:i("chat.turns.label",{n:p+1})}),e.jsx("span",{className:"line-clamp-2 text-[12px] leading-4",children:f.preview})]})]},f.id))})]})})}const Ie=80;function ws(t){return typeof t=="string"?t:Array.isArray(t)?t.filter(s=>s.type==="text").map(s=>s.text).join(" "):""}function Ns(t){const s=ws(t).replace(/\s+/g," ").trim();return s?s.length>Ie?`${s.slice(0,Ie-1)}…`:s:""}function Ss(t){const s=[];for(let a=0;a<t.length;a+=1){const r=t[a];if(r.role!=="user"||!r.id)continue;const i=Ns(r.content);i&&s.push({id:r.id,index:a,preview:i})}return s}const pe=120,fe=80,Cs=96;function ee(t){return(t==null?void 0:t.querySelector("[data-radix-scroll-area-viewport]"))??null}function Es(t){return JSON.stringify([t.role,t.content,t.metadata,t.agentContent])}function Ts({messages:t,isLoading:s}){const a=P(),r=m.useRef(null),i=m.useRef(null),n=m.useRef(!0),l=m.useRef(!1),h=m.useRef(t),d=m.useRef(t),c=m.useRef(new Set),k=m.useRef(t.length),o=m.useRef(null),[f,p]=m.useState(pe),[y,S]=m.useState(!1),[x,E]=m.useState(0),g=t.length>0;h.current=t,m.useEffect(()=>{const w=ee(r.current);if(!w||l.current&&!n.current)return;const M=window.requestAnimationFrame(()=>{w.scrollTop=w.scrollHeight,l.current=!0,n.current=!0,c.current=new Set,E(0),S(!1)});return()=>window.cancelAnimationFrame(M)},[t]),m.useEffect(()=>{const w=ee(r.current);if(!w)return;i.current=w;const M=()=>{if(!l.current)return;const B=w.scrollHeight-w.scrollTop-w.clientHeight<=Cs,V=n.current;n.current=B,S(!B),B?(c.current=new Set,E(0)):V&&(d.current=h.current,c.current=new Set,E(0))};return M(),w.addEventListener("scroll",M,{passive:!0}),()=>w.removeEventListener("scroll",M)},[g,s]),m.useEffect(()=>{const w=d.current;if(d.current=t,n.current){c.current.size>0&&(c.current=new Set,E(0));return}const M=js(w,t,c.current,Es);c.current=M,E(M.size)},[t]),m.useEffect(()=>{const w=k.current;k.current=t.length,p(M=>M>=w&&t.length>w?t.length:Math.min(Math.max(M,pe),t.length||pe))},[t.length]);const u=Math.max(t.length-f,0),b=u,A=m.useMemo(()=>t.slice(b),[t,b]),v=m.useMemo(()=>Ss(t),[t]);if(m.useLayoutEffect(()=>{var $;const w=o.current;if(!w)return;const M=ee(r.current);if(o.current=null,!!M){if(($=w.element)!=null&&$.isConnected){const B=w.element.getBoundingClientRect().top-w.viewportTop;M.scrollTop+=B;return}M.scrollTop=gs(w.scrollTop,w.scrollHeight,M.scrollHeight)}},[f]),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(ve,{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(ot,{className:"w-3 h-3"}),a("chat.list.loading.eyebrow")]}),e.jsx("h2",{className:"mt-2 text-[15px] font-medium text-[hsl(var(--deck-ink))]",children:a("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:a("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((w,M)=>e.jsxs("div",{className:F("flex gap-3",M%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:`${w}%`,animationDelay:`${M*120}ms`}})]},w))})]})});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(ve,{size:44}),e.jsxs("div",{children:[e.jsx("div",{className:"deck-eyebrow text-[hsl(var(--deck-accent))]",children:a("chat.list.empty.eyebrow")}),e.jsx("div",{className:"mt-2 text-[15px] font-medium text-[hsl(var(--deck-ink))]",children:a("chat.list.empty.title")}),e.jsx("div",{className:"mt-1 max-w-xs text-[12px] text-[hsl(var(--deck-ink-muted))]",children:a("chat.list.empty.hint")})]})]})});const C=()=>{const w=ee(r.current);w&&(w.scrollTop=w.scrollHeight,n.current=!0,l.current=!0,c.current=new Set,E(0),S(!1))},D=()=>{var M;const w=ee(r.current);if(w){const $=((M=r.current)==null?void 0:M.querySelector("[data-chat-message-id]"))??null;o.current={element:$,viewportTop:($==null?void 0:$.getBoundingClientRect().top)??0,scrollHeight:w.scrollHeight,scrollTop:w.scrollTop}}p($=>ks($,t.length,fe))},z=w=>w>=b?!0:(p(t.length),!1),O=x===1?a("chat.list.unreadMessage"):a("chat.list.unreadMessages",{count:x});return e.jsxs("div",{ref:r,className:"relative flex-1 min-h-0",children:[e.jsx(lt,{className:"h-full",children:e.jsxs("div",{className:"flex flex-col px-4 pb-4 w-full md:px-6",children:[u>0&&e.jsx("div",{className:"flex justify-center py-3",children:e.jsx("button",{type:"button",onClick:D,"aria-label":a("chat.list.showEarlierWithRemaining",{count:Math.min(u,fe),remaining:u}),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:a("chat.list.showEarlier",{count:Math.min(u,fe)})})}),A.map((w,M)=>{const $=b+M,B=$>0?t[$-1]:null,V=!B||B.role!==w.role||B.role==="user";return e.jsx(vs,{message:w,showAvatar:V},w.id||`msg-${$}`)})]})}),e.jsx(ys,{turns:v,viewportRef:i,containerRef:r,onRevealTurn:z}),y&&e.jsxs("button",{type:"button",onClick:C,"aria-live":"polite","aria-label":x>0?O:a("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(We,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}),x>0?O:a("chat.list.jumpLatest")]})]})}const Ze=m.memo(Ts),ge=St,ke=Ct,je=Et,de=m.forwardRef(({className:t,sideOffset:s=4,...a},r)=>e.jsx(Je,{ref:r,sideOffset:s,className:F("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),...a}));de.displayName=Je.displayName;const Ms={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 ie(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t)}function As(t){if(t<60)return`${t}s`;const s=Math.floor(t/60),a=t%60;return a===0?`${s}m`:`${s}m ${a}s`}function Rs(){var O,w,M,$,B,V,G,K,J,Q,R,U,H,j,L;const t=P(),{locale:s}=ze(),a=N(T=>T.goal),r=N(T=>T.pauseGoal),i=N(T=>T.resumeGoal),n=N(T=>T.editGoal),l=N(T=>T.clearGoal),[h,d]=m.useState(!1),[c,k]=m.useState(!1),[o,f]=m.useState(""),[p,y]=m.useState(null),[S,x]=m.useState(!1);if(m.useEffect(()=>{d(!1),k(!1),f((a==null?void 0:a.objective)??""),x(!1)},[a==null?void 0:a.goalId]),!a)return null;const E=Ms[a.status],g=["active","verifying","paused","blocked"].includes(a.status),u=a.status==="active"||a.status==="verifying",b=a.status==="paused"||a.status==="blocked",A=p!==null,v=async(T,q)=>{y(T);try{await q()}finally{y(null)}},C=()=>{f(a.objective),k(!0),d(!0)},D=async T=>{T.preventDefault();const q=o.trim();if(!q||q===a.objective){k(!1);return}await v("edit",()=>n(q)),k(!1)},z=async()=>{await v("delete",l),x(!1)};return e.jsxs(e.Fragment,{children:[e.jsx(ge,{delayDuration:250,children:e.jsxs("section",{"aria-label":t("goal.aria.section"),className:"mx-3 mb-1 shrink-0","data-blade-goal-status":a.status,"data-blade-goal-recovery":(O=a.prematureStop)==null?void 0:O.consecutiveCount,"data-blade-goal-recovery-pattern":(w=a.prematureStop)==null?void 0:w.pattern,"data-blade-goal-verification-stall":(M=a.verificationStall)==null?void 0:M.consecutiveCount,"data-blade-goal-frontier-task-list":($=a.executionFrontier)==null?void 0:$.taskListId,"data-blade-goal-frontier-total":(B=a.executionFrontier)==null?void 0:B.total,"data-blade-goal-frontier-completed":(V=a.executionFrontier)==null?void 0:V.completed,"data-blade-goal-frontier-in-progress":(G=a.executionFrontier)==null?void 0:G.inProgress,"data-blade-goal-frontier-pending":(K=a.executionFrontier)==null?void 0:K.pending,"data-blade-goal-frontier-blocked":(J=a.executionFrontier)==null?void 0:J.blocked,"data-blade-goal-frontier-next-task":(R=(Q=a.executionFrontier)==null?void 0:Q.nextTask)==null?void 0:R.id,"data-blade-goal-frontier-digest":(U=a.executionFrontier)==null?void 0:U.digestSha256.slice(0,16),"data-blade-goal-frontier-stall":(H=a.frontierStall)==null?void 0:H.category,"data-blade-goal-frontier-stall-count":(j=a.frontierStall)==null?void 0:j.consecutiveCount,children:[e.jsxs("div",{className:F("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",h&&"rounded-b-none border-b-0"),children:[a.status==="complete"?e.jsx(ct,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500"}):e.jsx(It,{className:F("h-3.5 w-3.5 shrink-0",E.accent)}),e.jsx("span",{className:F("h-1.5 w-1.5 shrink-0 rounded-full",E.dot)}),e.jsx("span",{className:F("shrink-0 text-[10px] font-medium leading-none",E.accent),children:a.status==="verifying"?s==="zh"?"验证中":"Verifying":t(E.labelKey)}),e.jsx("span",{className:"h-3 w-px shrink-0 bg-[hsl(var(--deck-hairline))]"}),e.jsx("button",{type:"button","aria-label":t(h?"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:()=>d(T=>!T),"aria-expanded":h,title:a.objective,children:a.objective}),a.tokensUsed>0&&e.jsxs("span",{className:"hidden shrink-0 text-[10px] tabular-nums text-[hsl(var(--deck-ink-muted))] sm:inline",children:[ie(a.tokensUsed),a.tokenBudget!==void 0&&`/${ie(a.tokenBudget)}`]}),e.jsxs("div",{className:"flex shrink-0 items-center",children:[u&&e.jsx(oe,{label:t("goal.action.pause"),disabled:A,onClick:()=>void v("pause",r),children:p==="pause"?e.jsx(_,{className:"animate-spin"}):e.jsx(Tt,{})}),b&&e.jsx(oe,{label:t("goal.action.resume"),disabled:A,onClick:()=>void v("resume",i),children:p==="resume"?e.jsx(_,{className:"animate-spin"}):e.jsx(Mt,{})}),e.jsx(oe,{label:t(g?"goal.action.edit":"goal.action.expand"),disabled:!g&&!h,onClick:g?C:()=>d(T=>!T),children:g?e.jsx(Ke,{}):e.jsx(Nt,{})}),e.jsx(oe,{label:t("goal.action.delete"),disabled:A,destructive:!0,onClick:()=>x(!0),children:e.jsx(ae,{})})]})]}),h&&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:c?e.jsxs("form",{onSubmit:D,children:[e.jsx("textarea",{id:"goal-objective",value:o,onChange:T=>f(T.target.value),onKeyDown:T=>{T.key==="Escape"&&k(!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:()=>k(!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(Ge,{className:"h-3 w-3"}),t("goal.action.cancel")]}),e.jsxs("button",{type:"submit",disabled:!o.trim()||p==="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:[p==="edit"?e.jsx(_,{className:"h-3 w-3 animate-spin"}):e.jsx(ue,{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:a.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(Ft,{className:"h-3 w-3"}),ie(a.tokensUsed),a.tokenBudget!==void 0&&` / ${ie(a.tokenBudget)}`," ",t("goal.metrics.tokens")]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Bt,{className:"h-3 w-3"}),As(a.timeUsedSeconds)]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(le,{className:"h-3 w-3"}),a.continuationCount===1?t("goal.metrics.continuationOne",{n:a.continuationCount}):t("goal.metrics.continuationMany",{n:a.continuationCount})]})]}),a.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(le,{className:"h-3 w-3"}),s==="zh"?"恢复提示":"Recovery nudge"," ",a.prematureStop.consecutiveCount," ·"," ",a.prematureStop.pattern.replaceAll("_"," ")]}),a.completionVerification&&e.jsxs("div",{"data-goal-verification":a.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:["#",a.completionVerification.attempt," ·"," ",a.completionVerification.status.toUpperCase()," ·"," ",((L=a.completionVerification.verifierSessionId)==null?void 0:L.slice(0,12))??"-",a.verificationStall?s==="zh"?` · 重复 ${a.verificationStall.consecutiveCount}/3`:` · repeat ${a.verificationStall.consecutiveCount}/3`:""]}),a.completionVerification.summary&&e.jsx("p",{className:"mt-1 line-clamp-3 whitespace-pre-wrap opacity-80",children:a.completionVerification.summary}),a.completionVerification.evidenceSha256&&e.jsxs("p",{className:"mt-1 font-mono text-[10px] opacity-60",children:["sha256:",a.completionVerification.evidenceSha256.slice(0,12)]})]}),a.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:a.statusReason})]})})]})}),e.jsx(Le,{open:S,onOpenChange:x,children:e.jsxs(Ve,{className:"max-w-[400px] border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsx(Oe,{children:t("goal.dialog.title")}),e.jsx(Ue,{children:t("goal.dialog.description")}),e.jsxs(He,{className:"mt-2",children:[e.jsx("button",{type:"button",onClick:()=>x(!1),className:"inline-flex h-8 items-center justify-center rounded-md border border-[hsl(var(--deck-border))] px-3 text-[12px] text-[hsl(var(--deck-ink))] hover:bg-[hsl(var(--deck-hairline))]/60",children:t("goal.action.cancel")}),e.jsxs("button",{type:"button",disabled:p==="delete",onClick:()=>void z(),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:[p==="delete"&&e.jsx(_,{className:"w-3.5 h-3.5 animate-spin"}),t("goal.action.delete")]})]})]})})]})}function oe({label:t,children:s,disabled:a,destructive:r,onClick:i}){return e.jsxs(ke,{children:[e.jsx(je,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":t,disabled:a,onClick:i,className:F("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",r?"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(de,{side:"top",className:"text-[10px]",children:t})]})}function Fs(){const t=P(),s=N(d=>d.currentSessionRef),a=N(d=>d.sessions),r=N(d=>d.messages),i=m.useMemo(()=>{var c,k,o,f,p;const d=s?(c=dt(a,s))==null?void 0:c.pendingInteraction:void 0;if(d)return d.type;for(let y=r.length-1;y>=0;y-=1){const S=(k=r[y])==null?void 0:k.agentContent;if(((o=S==null?void 0:S.confirmation)==null?void 0:o.status)==="pending")return"permission";if(((f=S==null?void 0:S.question)==null?void 0:f.status)==="pending")return"question";if(((p=S==null?void 0:S.elicitation)==null?void 0:p.status)==="pending")return"elicitation"}return null},[s,r,a]);if(!i)return null;const n=()=>{const d=document.querySelector(`[data-pending-interaction="${i}"]`);d==null||d.scrollIntoView({block:"center",behavior:"smooth"}),window.setTimeout(()=>d==null?void 0:d.focus(),250)},l=i==="question",h=i==="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(ye,{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(l?"interaction.bar.questionTitle":h?"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(l?"interaction.bar.questionHint":h?"interaction.bar.elicitationHint":"interaction.bar.permissionHint")})]}),e.jsxs("button",{type:"button",onClick:n,className:"inline-flex min-h-8 shrink-0 items-center gap-1.5 rounded-md border border-amber-400/80 bg-white/80 px-2.5 text-[10.5px] font-medium transition-colors hover:bg-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-700 dark:bg-amber-950/70 dark:hover:bg-amber-900",children:[e.jsx(We,{className:"h-3 w-3"}),t("interaction.bar.review")]})]})}const $s=m.lazy(()=>qe(()=>import("./MarkdownRenderer-3g4TPTeI.js").then(t=>t.M),__vite__mapDeps([0,1,2,3,4,5])).then(t=>({default:t.MarkdownRenderer})));function Ds(t){return t<1e3?`${t}ms`:`${(t/1e3).toFixed(1)}s`}function Is(){const t=P(),s=N(r=>r.sideConversation),a=N(r=>r.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(Dt,{"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(At,{"aria-hidden":!0,className:"h-3 w-3"}),Ds(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:a,"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(Ge,{"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(_,{"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(ye,{"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(m.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($s,{content:s.response,className:"text-[12px] leading-5 [&_h1]:text-[14px] [&_h2]:text-[13px] [&_h3]:text-[12px]"})})]})]})}):null}function be(t){return Number.isFinite(t)?Math.max(0,t):0}function Bs(t){const s=be(t.totalInputTokens),a=be(t.cacheReadTokens),r=be(t.cacheWriteTokens),i=Math.min(a,s),n=Math.min(r,Math.max(0,s-i)),l=Math.max(0,s-i-n),h=s>0&&(a>0||r>0);return{totalInputTokens:s,cacheReadTokens:i,cacheWriteTokens:n,uncachedInputTokens:l,...h?{hitRate:i/s}:{}}}function _s(t){return t===void 0||!Number.isFinite(t)?"—":`${Math.round(Math.max(0,Math.min(1,t))*100)}%`}const Ps={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:""},Ls={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"},Y=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString(),te=t=>{const s=Math.max(0,Math.ceil(t/1e3)),a=Math.floor(s/60),r=s%60;return a>0?`${a}m ${r}s`:`${r}s`};function et(){const t=P(),s=N(v=>v.tokenUsage),a=N(v=>v.isStreaming),r=N(v=>v.agentPhase),i=N(v=>v.providerAdmission),n=N(v=>v.providerCircuit),l=N(v=>v.providerRetry),h=N(v=>v.pendingResume),d=N(v=>v.providerStall),c=N(v=>v.actionStationarity),k=N(v=>v.turnRecovery),o=Ps[r]??"",f=(l==null?void 0:l.delayMs)!==void 0?` · ${Math.max(0,Math.ceil(l.delayMs/1e3))}s`:"",p=(h==null?void 0:h.delayMs)!==void 0?` · retry in ${te(h.delayMs)}`:"",y=(k==null?void 0:k.state)==="requires_attention"?t("status.recovery.review"):"",S=(k==null?void 0:k.state)==="requires_attention"?t(k.reason==="interrupted_tool_call"?"status.recovery.interruptedTool":"status.recovery.successfulTool"):"",x=y||(c?`${t(c.phase==="halted"?"status.phase.actionStationarityStopped":"status.phase.actionStationarityRecovering")} · ${c.toolName} · ${c.runLength}/${c.haltThreshold}`:n?n.phase==="probe"?"Provider · Recovery probe":`Provider · Circuit open${n.retryAfterMs!==void 0?` · probe in ${te(n.retryAfterMs)}`:""}${n.recoveryRemainingMs!==void 0?` · ${te(n.recoveryRemainingMs)}`:""}`:i?`Provider · Capacity queue ${i.queuePosition}/${Math.max(i.queueDepth,i.queuePosition)} · ${i.scope} · ${te(i.waitMs)}`:l?l.mode==="bounded_foreground"?`Provider · Bounded recovery · ${l.attempt}/${l.maxRetries} · ${te(l.recoveryRemainingMs??0)}`:`Provider · ${t("chat.error.action.retryingTask")} · ${l.attempt}/${l.maxRetries}${f}`:h?`Recovery attempt ${h.attempt}/${h.maxAttempts}${p}`:d?`${t("status.phase.providerStall")} · ${Math.ceil(d.durationMs/1e3)}s / ${Math.ceil(d.timeoutMs/1e3)}s`:o?t(o):""),E=s.maxContextTokens>0?Math.round(s.totalTokens/s.maxContextTokens*100):0,g=Bs(s),u=_s(g.hitRate),b=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:F("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:Y(s.totalTokens)}),e.jsxs("span",{className:"text-[hsl(var(--deck-ink-faint))]",children:["/ ",Y(s.maxContextTokens)]})]}),s.isDefaultMaxTokens&&e.jsx(ge,{children:e.jsxs(ke,{children:[e.jsx(je,{asChild:!0,children:e.jsx($t,{className:"h-3 w-3 cursor-help text-[hsl(var(--deck-ink-faint))]"})}),e.jsx(de,{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:F("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:`${b}%`}}),e.jsx("div",{className:"flex absolute inset-0 pointer-events-none",children:[25,50,75].map(v=>e.jsx("span",{className:"absolute inset-y-0 w-px bg-[hsl(var(--deck-canvas-veil))]/60",style:{left:`${v}%`}},v))})]}),e.jsxs("span",{className:F("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(ge,{children:e.jsxs(ke,{children:[e.jsx(je,{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")} ${u}`,children:[e.jsx("span",{className:"deck-eyebrow text-[hsl(var(--deck-ink-faint))]",children:t("status.cache")}),e.jsx("span",{className:F("tabular-nums",g.hitRate===void 0?"text-[hsl(var(--deck-ink-faint))]":"font-medium text-[hsl(var(--deck-accent))]"),children:u})]})}),e.jsx(de,{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:Y(g.cacheReadTokens),write:Y(g.cacheWriteTokens),uncached:Y(g.uncachedInputTokens)})}),s.cacheBreak&&e.jsx("p",{className:"text-[hsl(var(--deck-accent))]",children:t("status.cacheBreak",{reason:t(Ls[s.cacheBreak.reason]??"status.cacheBreak.server"),previous:Y(s.cacheBreak.previousCacheReadTokens),current:Y(s.cacheBreak.cacheReadTokens)})})]})})]})}),e.jsx("div",{className:"flex-1"}),(y||a&&x)&&e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:F("shrink-0",y?"h-2 w-2 rounded-sm bg-amber-500":"deck-pulse-dot")}),e.jsxs("span",{className:F("truncate",y?"text-amber-600 dark:text-amber-400":"text-[hsl(var(--deck-accent))]"),children:[x,S?e.jsxs("span",{className:"hidden sm:inline",children:[" · ",S]}):null]})]})]})}function Vs(){const{locale:t}=ze(),s=ut(u=>u.agentTeamsEnabled),a=N(u=>u.teams),r=N(u=>u.currentSessionRef),i=N(u=>u.loadTeams),[n,l]=m.useState({}),[h,d]=m.useState({}),[c,k]=m.useState({}),[o,f]=m.useState(null),[p,y]=m.useState(null),[S,x]=m.useState(null);if(m.useEffect(()=>{i(r??void 0)},[s,r,i]),!s||!r||a.length===0)return null;const E=async u=>{var A;const b=(A=c[u])==null?void 0:A.trim();if(!(!b||o)){f(u),x(null);try{await Ee.sendMessage(r,u,h[u]??"*",b),k(v=>({...v,[u]:""})),await i(r)}catch(v){x(v instanceof Error?v.message:I(t,"actionFailed"))}finally{f(null)}}},g=async u=>{if(!p){y(u),x(null);try{await Ee.delete(r,u),await i(r)}catch(b){x(b instanceof Error?b.message:I(t,"actionFailed"))}finally{y(null)}}};return e.jsxs("section",{"aria-label":I(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:[S&&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:S}),a.filter(u=>u.status!=="deleted").map(u=>{var v;const b=n[u.name]??u.status==="running",A=u.tasks.filter(C=>C.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:()=>l(C=>({...C,[u.name]:!b})),"aria-label":b?I(t,"collapse"):I(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:b?e.jsx(re,{className:"h-4 w-4"}):e.jsx(ne,{className:"h-4 w-4"})}),e.jsx(_t,{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:u.name}),e.jsxs("span",{className:"font-mono text-[9.5px] text-[hsl(var(--deck-ink-faint))]",children:[u.status," · ",u.members.length-1," ",I(t,"members")," · ",A,"/",u.tasks.length," ",I(t,"tasks")]})]}),u.description&&e.jsx("p",{className:"truncate font-mono text-[10px] text-[hsl(var(--deck-ink-muted))]",children:u.description})]}),e.jsx("button",{type:"button",onClick:()=>void g(u.name),disabled:p===u.name,"aria-label":I(t,"delete"),title:I(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(ae,{className:"h-3.5 w-3.5"})})]}),b&&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:I(t,"members")}),u.members.map(C=>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":C.status,className:`h-1.5 w-1.5 shrink-0 rounded-full ${C.status==="running"?"bg-emerald-500":C.status==="completed"||C.status==="leader"?"bg-sky-500":C.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:C.name}),e.jsx("span",{className:"font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:C.subagentType}),C.worktreePath&&e.jsx(_e,{className:"h-3 w-3 text-[hsl(var(--deck-ink-faint))]","aria-label":I(t,"worktree")})]},C.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:I(t,"tasks")}),u.tasks.length===0?e.jsx("p",{className:"font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:I(t,"noTasks")}):u.tasks.map(C=>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:["#",C.id]}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[10.5px] text-[hsl(var(--deck-ink))]",children:C.subject}),e.jsx("span",{className:"font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:C.status})]},C.id))]})]}),u.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":I(t,"recipient"),value:h[u.name]??"*",onChange:C=>d(D=>({...D,[u.name]:C.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:I(t,"broadcast")}),u.members.filter(C=>C.status!=="leader").map(C=>e.jsx("option",{value:C.name,children:C.name},C.id))]}),e.jsx("input",{value:c[u.name]??"",onChange:C=>k(D=>({...D,[u.name]:C.target.value})),onKeyDown:C=>{C.key==="Enter"&&E(u.name)},placeholder:I(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 E(u.name),disabled:!((v=c[u.name])!=null&&v.trim())||o===u.name,"aria-label":I(t,"send"),title:I(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(Pe,{className:"h-3.5 w-3.5"})})]})]})]},u.name)})]})}function Os(t){const s=[...t].reverse().find(i=>i.role==="user");if(!s)return null;if(typeof s.content=="string")return{content:s.content,attachments:[]};const a=s.content.filter(i=>i.type==="text").map(i=>i.text).join(`
|
|
58
|
-
`),r=s.content.filter(i=>i.type==="image_url").map((i,n)=>{var h;const l=((h=i.image_url.url.match(/^data:([^;,]+)[;,]/))==null?void 0:h[1])??"application/octet-stream";return{id:`recovery-${s.id}-${n}`,name:`attachment-${n+1}`,mimeType:l,dataUrl:i.image_url.url}});return{content:a,attachments:r}}function Us({messages:t,isLoading:s,isStreaming:a,isStopping:r,errorMessage:i}){const n=P(),[l,h]=m.useState(!1),d=n(i?"status.phase.error":r?"chat.input.action.stopping":a?"status.phase.running":"preview.files.status.ready");return e.jsxs("details",{"data-preview-status-disclosure":!0,open:l,onToggle:c=>h(c.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:[a&&e.jsx("span",{className:"deck-pulse-dot"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:d}),e.jsx(ne,{className:"h-3.5 w-3.5 shrink-0 transition-transform group-open:rotate-90"})]}),l&&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:[i&&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:i}),e.jsx(Ze,{messages:t,isLoading:s}),e.jsx(et,{})]})]})}function Hs(){var H;const t=P(),s=N(j=>j.messages),a=N(j=>j.currentSessionRef),r=N(j=>j.isStreaming),i=N(j=>j.isStopping),n=N(j=>j.sessionEventConnectionState),l=N(j=>j.pendingSteeringCount),h=N(j=>j.pendingInputDelivery),d=N(j=>j.recoveredSteeringCount),c=N(j=>j.isLoading),k=N(j=>j.error),o=N(j=>j.errorContext),f=N(j=>j.sessions),p=N(j=>j.sendMessage),y=N(j=>j.abortSession),S=N(j=>j.retryTask),x=N(j=>j.retryingTaskKeys),E=we(j=>j.openSettings),g=N(j=>j.reconnectSessionEvents),u=N(j=>j.clearError),[b,A]=m.useState(null),v=a?f.find(j=>j.sessionId===a.sessionId&&j.projectPath===a.projectPath):void 0,C=!!k&&((o==null?void 0:o.kind)==="navigation"||!(o!=null&&o.sessionRef)||Be(o.sessionRef,a)),D=(o==null?void 0:o.failureCode)??((H=v==null?void 0:v.taskFailure)==null?void 0:H.code),z=((o==null?void 0:o.kind)==="execution"||o!=null&&o.failureCode)&&D?t(kt(D)):k==="queue_full"?t("chat.error.queueFull"):k==="turn_unavailable"||k==="turn_active"?t("chat.error.turnChanged"):k,O=n==="connecting"||n==="reconnecting",w=r&&n!=="connected",M=a?`session:${se(a)}`:"session:temporary",$=m.useMemo(()=>Os(s),[s]),B=a?se(a):"temporary-session",V=!!(a&&(v!=null&&v.taskRetryAvailable)&&(!D||jt(D)))&&((o==null?void 0:o.kind)==="execution"||(o==null?void 0:o.kind)==="task_action"),G=(o==null?void 0:o.kind)==="execution"&&(D==="authentication"||D==="permission"||D==="model_unavailable"),K=a?x.includes(se(a)):!1;m.useEffect(()=>{A(null)},[B]);const J=async j=>p({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(L=>({type:"image",content:L.dataUrl,mimeType:L.mimeType,name:L.name}))}),Q=()=>y(),R=async()=>{if(G){u(),E("models");return}if(V&&a){u(),await S(a).catch(()=>{});return}if((o==null?void 0:o.kind)==="execution"&&$){A({...$,revision:Date.now()}),u();return}u(),requestAnimationFrame(()=>pt())},U=V?t(K?"chat.error.action.retryingTask":"chat.error.action.retryTask"):G?t("chat.error.action.checkModels"):(o==null?void 0:o.kind)==="execution"&&$?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:[C&&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(ye,{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")})," ",z]}),U&&e.jsxs("button",{type:"button",onClick:()=>void R(),disabled:K,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:[V?K?e.jsx(_,{className:"h-3 w-3 animate-spin"}):e.jsx(le,{className:"h-3 w-3"}):e.jsx(Ke,{className:"h-3 w-3"}),U]}),e.jsx("button",{type:"button",onClick:u,"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:"✕"})]}),(O||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:[O?e.jsx(_,{className:"h-3.5 w-3.5 shrink-0 animate-spin"}):e.jsx(mt,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1",children:t(O?"chat.connection.reconnecting":"chat.connection.offline")}),n==="offline"&&e.jsxs("button",{type:"button",onClick:()=>void 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(ht,{className:"h-3 w-3"}),t("chat.connection.retry")]})]}),e.jsx(Pt,{}),e.jsx(Ze,{messages:s,isLoading:c},a?se(a):"temporary-session"),e.jsx(Vs,{}),e.jsx(Is,{})]}),e.jsxs("div",{"data-chat-composer-dock":!0,className:"contents",children:[e.jsx(Us,{messages:s,isLoading:c,isStreaming:r,isStopping:i,errorMessage:C?z:null},B),e.jsx(Fs,{}),e.jsx(Rs,{}),e.jsx(xt,{draftKey:M,draft:b==null?void 0:b.content,draftAttachments:b==null?void 0:b.attachments,draftRevision:b==null?void 0:b.revision,onSend:J,onAbort:Q,disabled:c||w,isStreaming:r,isStopping:i,pendingSteeringCount:l,pendingInputDelivery:h,recoveredSteeringCount:d,workspacePath:a==null?void 0:a.projectPath},M),e.jsx("div",{"data-chat-primary-status":!0,className:"contents",children:e.jsx(et,{})})]})]})}const ta=Object.freeze(Object.defineProperty({__proto__:null,ChatView:Hs},Symbol.toStringTag,{value:"Module"}));export{Qe as C,ta as a};
|