blade-code 0.10.136 → 0.10.137

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/dist/blade.js +2 -2
  2. package/dist/{chunk-r51afpkk.js → chunk-0c82q1sz.js} +1 -1
  3. package/dist/chunk-0ccm29qy.js +2 -0
  4. package/dist/{chunk-na3nregt.js → chunk-0k2x2ae6.js} +1 -1
  5. package/dist/{chunk-v2qxszks.js → chunk-1evc05gr.js} +1 -1
  6. package/dist/chunk-35668hyn.js +1 -0
  7. package/dist/{chunk-13sdjfks.js → chunk-39de5k03.js} +1 -1
  8. package/dist/chunk-3gmcvd0c.js +1 -0
  9. package/dist/{chunk-vvawhvea.js → chunk-4jqw75ce.js} +1 -1
  10. package/dist/chunk-5774a669.js +1 -0
  11. package/dist/{chunk-qjydadex.js → chunk-5btfnf2r.js} +5 -5
  12. package/dist/{chunk-91pb41e7.js → chunk-5dwmhsrx.js} +1 -1
  13. package/dist/{chunk-c5rfnzhf.js → chunk-5sf2rc1z.js} +3 -3
  14. package/dist/{chunk-sv5z5sna.js → chunk-69nwa6bn.js} +1 -1
  15. package/dist/{chunk-wj16pvvn.js → chunk-69rjav47.js} +1 -1
  16. package/dist/{chunk-ntd69c0k.js → chunk-6e3mh79j.js} +1 -1
  17. package/dist/{chunk-gdnyt8a7.js → chunk-6xvrrypm.js} +1 -1
  18. package/dist/{chunk-tev70rzj.js → chunk-74bswv4z.js} +2 -2
  19. package/dist/{chunk-g45camrd.js → chunk-75yy9yre.js} +1 -1
  20. package/dist/chunk-7n035mhg.js +1 -0
  21. package/dist/{chunk-hx10bph0.js → chunk-7ykqvsph.js} +1 -1
  22. package/dist/chunk-9a7bppj7.js +2 -0
  23. package/dist/{chunk-kbnxbb23.js → chunk-9frd4fpk.js} +1 -1
  24. package/dist/chunk-a26vtcv5.js +5 -0
  25. package/dist/{chunk-c85xvthj.js → chunk-affzv7f1.js} +1 -1
  26. package/dist/chunk-b08thknq.js +1 -0
  27. package/dist/{chunk-sy0vxdc3.js → chunk-bx75fd0d.js} +311 -311
  28. package/dist/chunk-bzqbmz6t.js +171 -0
  29. package/dist/{chunk-77x1rrz9.js → chunk-c2mx5zg0.js} +1 -1
  30. package/dist/chunk-chspy9f8.js +23 -0
  31. package/dist/chunk-d6tbr25k.js +1 -0
  32. package/dist/chunk-dt9n4f4e.js +1 -0
  33. package/dist/{chunk-82x77b2p.js → chunk-e76gej4y.js} +2 -2
  34. package/dist/{chunk-g4vgnxh4.js → chunk-e8pfbb6c.js} +1 -1
  35. package/dist/chunk-ermypm1x.js +2 -0
  36. package/dist/chunk-esp69w6w.js +1 -0
  37. package/dist/{chunk-5sknjz9b.js → chunk-etf3e9kt.js} +1 -1
  38. package/dist/{chunk-1cbaqh71.js → chunk-f2b9cyj5.js} +2 -2
  39. package/dist/chunk-g1y60ey9.js +1 -0
  40. package/dist/{chunk-jc28ddt0.js → chunk-g799czsy.js} +1 -1
  41. package/dist/{chunk-w2n1vwzg.js → chunk-g9vdmvk2.js} +2 -2
  42. package/dist/chunk-gf5v8aff.js +1 -0
  43. package/dist/chunk-gpj7k3er.js +6 -0
  44. package/dist/{chunk-hqwpnb0x.js → chunk-h05qhgrb.js} +1 -1
  45. package/dist/{chunk-24rsvr6e.js → chunk-h74p51hg.js} +1 -1
  46. package/dist/{chunk-f7hsagj6.js → chunk-karq4wfd.js} +1 -1
  47. package/dist/{chunk-9z9v8v4j.js → chunk-ky9br0z8.js} +1 -1
  48. package/dist/chunk-m9kh7djg.js +6 -0
  49. package/dist/{chunk-qm96k94k.js → chunk-mavranwn.js} +3 -3
  50. package/dist/{chunk-6rvrx275.js → chunk-mthf5akx.js} +2 -2
  51. package/dist/{chunk-jb8stg10.js → chunk-mzye1ah2.js} +1 -1
  52. package/dist/chunk-na4wzne8.js +1 -0
  53. package/dist/chunk-ntmkzrs8.js +1 -0
  54. package/dist/{chunk-1p9sjb8d.js → chunk-nxnmqk4s.js} +1 -1
  55. package/dist/{chunk-mq1mk3v5.js → chunk-p0gbxaqz.js} +1 -1
  56. package/dist/chunk-pj15kt5b.js +10 -0
  57. package/dist/chunk-pv1vwasz.js +1 -0
  58. package/dist/{chunk-mm1atkae.js → chunk-ramana2t.js} +2 -2
  59. package/dist/{chunk-1pmvyqed.js → chunk-rgjr7jsd.js} +1 -1
  60. package/dist/{chunk-0qq64xqm.js → chunk-v5503t2t.js} +3 -3
  61. package/dist/chunk-vda03kxj.js +1 -0
  62. package/dist/{chunk-cgkbdh2m.js → chunk-vg3zwv4g.js} +1 -1
  63. package/dist/chunk-vp6d1fqp.js +3 -0
  64. package/dist/{chunk-xtngc0th.js → chunk-w9z34f27.js} +1 -1
  65. package/dist/{chunk-nzwh9v6t.js → chunk-wa71vstt.js} +1 -1
  66. package/dist/{chunk-ffh4c30x.js → chunk-wc9wsyrc.js} +1 -1
  67. package/dist/{chunk-bdtpq7j9.js → chunk-wxtj6gqb.js} +1 -1
  68. package/dist/{chunk-zy2etr3v.js → chunk-wxypv01z.js} +2 -2
  69. package/dist/{chunk-s3a017q7.js → chunk-xg9fyvw0.js} +2 -2
  70. package/dist/{chunk-fnc97xg7.js → chunk-xt0ktytp.js} +1 -1
  71. package/dist/{chunk-46jmq302.js → chunk-y6jee9w7.js} +1 -1
  72. package/dist/{chunk-yacv7f7h.js → chunk-ybc5myz7.js} +1 -1
  73. package/dist/{chunk-mxe4pr8t.js → chunk-zk9rf1d7.js} +1 -1
  74. package/dist/web/assets/ChatView-DpvPjAh7.js +63 -0
  75. package/dist/web/assets/{CodeBlockHighlighter-41xRPXs2.js → CodeBlockHighlighter-Czp4VZIg.js} +1 -1
  76. package/dist/web/assets/{FilePreview-lcc_hL7J.js → FilePreview-BJWuYfyF.js} +7 -7
  77. package/dist/web/assets/{KanbanBoard-BHgM338V.js → KanbanBoard-DrYzt5Kh.js} +2 -2
  78. package/dist/web/assets/{MarkdownRenderer-BMAuTkc6.js → MarkdownRenderer-DxkR5r7t.js} +3 -3
  79. package/dist/web/assets/{ScrollArea-DJq2Kdpi.js → ScrollArea-D71pJjgW.js} +1 -1
  80. package/dist/web/assets/{SessionHistorySurface-DSe8ePBJ.js → SessionHistorySurface-2y9bnndm.js} +1 -1
  81. package/dist/web/assets/{SettingsModal-Cih4bWul.js → SettingsModal-BbaTL5Rk.js} +1 -1
  82. package/dist/web/assets/{Sidebar-DnWlUKmO.js → Sidebar-COZltpL9.js} +2 -2
  83. package/dist/web/assets/{TaskSwitcher-D3mrXv_i.js → TaskSwitcher-3giB7l1P.js} +1 -1
  84. package/dist/web/assets/{TerminalPanel-BNKHhBVM.js → TerminalPanel-gvTTiTgX.js} +1 -1
  85. package/dist/web/assets/{archive-Dof4YpyT.js → archive-DndqAA2q.js} +1 -1
  86. package/dist/web/assets/{arrow-left-DGFXaGox.js → arrow-left-XNYfpUAb.js} +1 -1
  87. package/dist/web/assets/{calendar-clock-BoxUNOvH.js → calendar-clock-BQOfNcCK.js} +1 -1
  88. package/dist/web/assets/{chevron-right-Brb1rhaA.js → chevron-right-Cvq3LzHK.js} +1 -1
  89. package/dist/web/assets/{chevrons-up-down-N-VshXV_.js → chevrons-up-down-Dia1U9Sz.js} +1 -1
  90. package/dist/web/assets/{clock-3-gdZEKe2U.js → clock-3-CnxLS8cv.js} +1 -1
  91. package/dist/web/assets/{copy-d9M8JUfQ.js → copy-CWCS3Lql.js} +1 -1
  92. package/dist/web/assets/{download-CQ-Pwfq0.js → download-DXdsM18t.js} +1 -1
  93. package/dist/web/assets/{external-link-GRAtjoO2.js → external-link-1IN2ZfaO.js} +1 -1
  94. package/dist/web/assets/{folder-CqLD0IBh.js → folder-Bpq602dI.js} +1 -1
  95. package/dist/web/assets/index-57UZsfTt.css +1 -0
  96. package/dist/web/assets/index-DEOQizD2.js +203 -0
  97. package/dist/web/assets/{pause-BqsFgQi0.js → pause-BYhoGDZq.js} +1 -1
  98. package/dist/web/assets/{pencil-Ca9289F-.js → pencil-pRZQVHFU.js} +1 -1
  99. package/dist/web/assets/{play-DmEPnYDS.js → play-DGZdCyPk.js} +1 -1
  100. package/dist/web/assets/{plus-kIBLgk0p.js → plus-CAQ3qlUJ.js} +1 -1
  101. package/dist/web/assets/session-events-C5_Q0kZV.js +29 -0
  102. package/dist/web/assets/{settings-BuSrJl6s.js → settings-BPfzj_Vf.js} +1 -1
  103. package/dist/web/assets/{teamService-B7Fp8Oyg.js → teamService-BScT9o9A.js} +1 -1
  104. package/dist/web/assets/{terminal-Qkr_gcNu.js → terminal-CldJbdMr.js} +1 -1
  105. package/dist/web/index.html +2 -2
  106. package/package.json +1 -1
  107. package/dist/chunk-1dscf8xj.js +0 -23
  108. package/dist/chunk-1n5d6b5k.js +0 -1
  109. package/dist/chunk-1qdemrkr.js +0 -1
  110. package/dist/chunk-83nxcfz3.js +0 -1
  111. package/dist/chunk-9y7j565j.js +0 -6
  112. package/dist/chunk-acsfh1cw.js +0 -5
  113. package/dist/chunk-as8stb2j.js +0 -10
  114. package/dist/chunk-azaqc1b6.js +0 -1
  115. package/dist/chunk-e1warjkn.js +0 -171
  116. package/dist/chunk-g13jmewd.js +0 -1
  117. package/dist/chunk-g7h0peka.js +0 -3
  118. package/dist/chunk-gq7fdc8c.js +0 -2
  119. package/dist/chunk-gwjah260.js +0 -1
  120. package/dist/chunk-n238rdz8.js +0 -1
  121. package/dist/chunk-nfzad4te.js +0 -2
  122. package/dist/chunk-pnanbvn3.js +0 -1
  123. package/dist/chunk-pz91qga3.js +0 -1
  124. package/dist/chunk-s4b1r3my.js +0 -1
  125. package/dist/chunk-t6cajkaj.js +0 -6
  126. package/dist/chunk-tah2002b.js +0 -1
  127. package/dist/chunk-tzfd2fza.js +0 -1
  128. package/dist/chunk-v3veeja5.js +0 -1
  129. package/dist/chunk-vptn8fhx.js +0 -2
  130. package/dist/chunk-wj813rcc.js +0 -1
  131. package/dist/web/assets/ChatView-Bc9twpWM.js +0 -63
  132. package/dist/web/assets/index-CPpIFWLG.css +0 -1
  133. package/dist/web/assets/index-DiRs2_w4.js +0 -203
  134. package/dist/web/assets/session-events-BqQQkbAN.js +0 -29
@@ -1 +0,0 @@
1
- import{mg as a,ng as b,og as c,pg as d}from"./chunk-82x77b2p.js";import"./chunk-mm1atkae.js";import"./chunk-gdnyt8a7.js";import"./chunk-vptn8fhx.js";import"./chunk-jc28ddt0.js";import"./chunk-nfzad4te.js";import"./chunk-jb8stg10.js";import"./chunk-g7h0peka.js";import"./chunk-s3a017q7.js";import"./chunk-bdtpq7j9.js";import"./chunk-w2n1vwzg.js";import"./chunk-zy2etr3v.js";import"./chunk-1p9sjb8d.js";import"./chunk-na3nregt.js";import"./chunk-ntd69c0k.js";export{c as snapshotWorkspaceModelResources,b as resolveWorkspaceModelResources,d as createProcessModelResources,a as cloneWorkspaceModelConfig};
@@ -1,3 +0,0 @@
1
- import{Uj as j}from"./chunk-na3nregt.js";import{appendFileSync as E,existsSync as O,mkdirSync as R,readdirSync as U,statSync as B,unlinkSync as k}from"node:fs";import W from"node:path";var X;((H)=>{H[H.DEBUG=0]="DEBUG";H[H.INFO=1]="INFO";H[H.WARN=2]="WARN";H[H.ERROR=3]="ERROR"})(X||={});var T=null,_=null,$=!1;function m(q){if(T!==q)T=q}async function I(){}function w(){if($)return _;$=!0;try{let q=W.join(j(),"logs");if(!O(q))R(q,{recursive:!0,mode:493});if(B(q).uid===0&&process.getuid&&process.getuid()!==0)return console.error(""),console.error("[FAIL] 权限错误:~/.blade/logs 目录属于 root 用户"),console.error(""),console.error("这通常是因为您曾经使用 sudo 运行过 blade。"),console.error(""),console.error("解决方法:"),console.error(" sudo chown -R $USER:$USER ~/.blade/"),console.error(""),console.error("然后重新运行 blade(不要使用 sudo)"),console.error(""),null;return z(q,30),_=q,q}catch(q){return console.error("[Logger] 无法创建日志目录:",q),null}}function z(q,G){try{let J=U(q),K=Date.now(),H=G*24*60*60*1000;for(let Q of J){if(!Q.startsWith("blade-")||!Q.endsWith(".log")&&!Q.endsWith(".jsonl"))continue;let Y=W.join(q,Q);try{let Z=B(Y);if(K-Z.mtimeMs>H)k(Y)}catch(Z){}}}catch(J){}}function F(){let q=w();if(!q)return null;let G=T||"default";return W.join(q,`blade-${G}.jsonl`)}function A(q,G,J){let K=F();if(!K)return;try{let H={timestamp:new Date().toISOString(),level:X[G],category:q,message:J};E(K,JSON.stringify(H)+`
2
- `)}catch(H){}}class M{static globalDebugConfig=null;enabled;minLevel;category;constructor(q={}){if(q.enabled!==void 0)this.enabled=q.enabled;else if(M.globalDebugConfig!==null)this.enabled=Boolean(M.globalDebugConfig);else this.enabled=!1;this.minLevel=q.minLevel??0,this.category=q.category??"General"}static setGlobalDebug(q){M.globalDebugConfig=q}static clearGlobalDebug(){M.globalDebugConfig=null}setEnabled(q){this.enabled=q}parseDebugFilter(q){if(!q)return{enabled:!1};if(q===!0||q==="true"||q==="1")return{enabled:!0};let G=String(q).trim();if(!G)return{enabled:!0};if(G.startsWith("!"))return{enabled:!0,filter:{mode:"exclude",categories:G.split(",").map((H)=>H.trim().replace(/^!/,"")).filter(Boolean)}};return{enabled:!0,filter:{mode:"include",categories:G.split(",").map((K)=>K.trim()).filter(Boolean)}}}shouldLogCategory(q){if(!q)return!0;let G=this.category.toLowerCase();if(q.mode==="include")return q.categories.some((J)=>G.includes(J.toLowerCase()));return!q.categories.some((J)=>G.includes(J.toLowerCase()))}shouldLogToConsole(q){if(M.globalDebugConfig!==null){let{enabled:G,filter:J}=this.parseDebugFilter(M.globalDebugConfig);if(!G)return!1;if(q<this.minLevel)return!1;return this.shouldLogCategory(J)}return this.enabled&&q>=this.minLevel}log(q,...G){let J=G.map((K)=>typeof K==="object"?JSON.stringify(K):String(K)).join(" ");if(A(this.category,q,J),this.shouldLogToConsole(q)){let K=X[q],H=`[${this.category}] [${K}]`;console.error(H,...G)}}debug(...q){this.log(0,...q)}info(...q){this.log(1,...q)}warn(...q){this.log(2,...q)}error(...q){this.log(3,...q)}}function V(q,G){return new M({...G,category:q})}var h=new M({category:"General"});
3
- export{m as tj,I as uj,M as vj,V as wj,h as xj};
@@ -1,2 +0,0 @@
1
- import{Ii as U,Ji as c,Li as n}from"./chunk-vptn8fhx.js";import{Ti as $,Ui as Z,Vi as W,Wi as K}from"./chunk-nfzad4te.js";import{wj as y}from"./chunk-g7h0peka.js";import{Uj as r}from"./chunk-na3nregt.js";var w=[{min:0,max:59},{min:0,max:23},{min:1,max:31},{min:1,max:12},{min:0,max:7}],e={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6},E=new Map;function x(J,B,H){let Y=new Set;for(let j of J.split(",")){let[k,G]=j.split("/"),V=G?Number.parseInt(G,10):1;if(!Number.isInteger(V)||V<1)throw Error(`Invalid cron step in "${J}"`);let Q=B,X=H;if(k!=="*"&&k!=="")if(k.includes("-")){let[b,p]=k.split("-");Q=Number.parseInt(b,10),X=Number.parseInt(p,10)}else Q=Number.parseInt(k,10),X=Q;if(!Number.isInteger(Q)||!Number.isInteger(X)||Q<B||X>H||Q>X)throw Error(`Invalid cron range "${k}" in field "${J}"`);for(let b=Q;b<=X;b+=V)Y.add(b)}return Y}function S(J){let B=J.trim().split(/\s+/);if(B.length!==5)throw Error(`Cron expression must have 5 fields (min hour dom mon dow), got ${B.length}`);let[H,Y,j,k,G]=B,V=x(G,w[4].min,w[4].max),Q=new Set([...V].map((X)=>X===7?0:X));return{minutes:x(H,w[0].min,w[0].max),hours:x(Y,w[1].min,w[1].max),daysOfMonth:x(j,w[2].min,w[2].max),months:x(k,w[3].min,w[3].max),daysOfWeek:Q,domRestricted:j.trim()!=="*",dowRestricted:G.trim()!=="*"}}function $1(J,B){if(!B)return{minute:J.getMinutes(),hour:J.getHours(),dayOfMonth:J.getDate(),month:J.getMonth()+1,dayOfWeek:J.getDay()};let H=E.get(B);if(!H)H=new Intl.DateTimeFormat("en-US",{timeZone:B,month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",weekday:"short",hourCycle:"h23"}),E.set(B,H);let Y=Object.fromEntries(H.formatToParts(J).filter((j)=>j.type!=="literal").map((j)=>[j.type,j.value]));return{minute:Number(Y.minute),hour:Number(Y.hour),dayOfMonth:Number(Y.day),month:Number(Y.month),dayOfWeek:e[Y.weekday]??-1}}function J1(J,B,H){let Y=$1(B,H);if(!J.minutes.has(Y.minute))return!1;if(!J.hours.has(Y.hour))return!1;if(!J.months.has(Y.month))return!1;let j=J.daysOfMonth.has(Y.dayOfMonth),k=J.daysOfWeek.has(Y.dayOfWeek);if(J.domRestricted&&J.dowRestricted)return j||k;if(J.domRestricted)return j;if(J.dowRestricted)return k;return!0}function Z1(J,B,H){let Y=S(J),j=new Date(B.getTime());j.setSeconds(0,0),j.setMinutes(j.getMinutes()+1);let k=new Date(B.getTime());k.setFullYear(k.getFullYear()+4);while(j.getTime()<=k.getTime()){if(J1(Y,j,H))return new Date(j.getTime());j.setMinutes(j.getMinutes()+1)}return null}var l={s:1000,m:60000,h:3600000,d:86400000};function R1(J){let H=J.trim().toLowerCase().match(/^(\d+)\s*([smhd]?)$/);if(!H)return null;let Y=Number.parseInt(H[1],10);if(!Number.isInteger(Y)||Y<=0)return null;let j=H[2]||"m";return Y*l[j]}function B1(J){for(let B of["d","h","m","s"]){let H=l[B];if(J%H===0)return`${J/H}${B}`}return`${Math.round(J/1000)}s`}function f(J,B,H){switch(J.kind){case"cron":{if(!J.cron)return null;try{return Z1(J.cron,B,J.timezone)}catch{return null}}case"interval":{if(!J.intervalMs||J.intervalMs<=0)return null;let j=new Date((H??B).getTime()+J.intervalMs);return j.getTime()<=B.getTime()?new Date(B.getTime()+1000):j}case"once":{if(!J.runAt)return null;let Y=new Date(J.runAt);if(Number.isNaN(Y.getTime()))return null;return Y.getTime()>B.getTime()?Y:null}default:return null}}function A(J){switch(J.kind){case"cron":if(!J.cron)return"cron trigger requires a cron expression";try{if(S(J.cron),J.timezone)new Intl.DateTimeFormat("en-US",{timeZone:J.timezone}).format();return null}catch(B){return B instanceof Error?B.message:"invalid cron expression"}case"interval":if(!J.intervalMs||J.intervalMs<60000)return"interval trigger requires intervalMs >= 60000 (1 minute)";return null;case"once":{if(!J.runAt)return"once trigger requires runAt timestamp";let B=new Date(J.runAt);if(Number.isNaN(B.getTime()))return"once trigger runAt is not a valid date";return null}default:return"unknown trigger kind"}}function _1(J){switch(J.kind){case"cron":return`cron: ${J.cron??"?"}`;case"interval":return`every ${J.intervalMs?B1(J.intervalMs):"?"}`;case"once":return`once at ${J.runAt??"?"}`;default:return"unknown"}}import{mkdir as f1,readFile as A1}from"node:fs/promises";import T from"node:path";import{nanoid as U1}from"nanoid";import M1 from"write-file-atomic";var O=160,K1=240,h=$.String({pattern:"^[a-f0-9]{64}$"}),Y1=Z($.Object({id:$.String({minLength:1,maxLength:128}),position:$.Integer({minimum:0,maximum:O-1}),queuedAt:$.String({minLength:20,maxLength:32}),kind:K(["user","internal"]),state:K(["pending","locked"]),delivery:K(["current_turn","next_turn","recovery"]),mutable:$.Boolean(),preview:$.Optional($.String({maxLength:K1})),previewTruncated:$.Boolean(),attachmentCount:$.Integer({minimum:0,maximum:20})},{additionalProperties:!1})),u=Z($.Object({version:h,pending:$.Integer({minimum:0,maximum:O}),mutable:$.Integer({minimum:0,maximum:O}),locked:$.Integer({minimum:0,maximum:O}),internal:$.Integer({minimum:0,maximum:O}),items:$.Array(Y1,{maxItems:O})},{additionalProperties:!1})),H1=$.Union([$.Object({type:$.Literal("remove"),messageId:$.String({minLength:1,maxLength:128})},{additionalProperties:!1}),$.Object({type:$.Literal("move"),messageId:$.String({minLength:1,maxLength:128}),toPosition:$.Integer({minimum:0,maximum:O-1})},{additionalProperties:!1})]),l1=Z($.Object({expectedVersion:h,operation:H1},{additionalProperties:!1})),h1=Z($.Object({snapshot:u},{additionalProperties:!1})),j1=K(["revision_conflict","already_claimed","immutable_origin","immutable_boundary","not_found","runtime_unavailable","invalid_mutation","storage_unavailable"]),u1=Z($.Object({error:$.Object({code:j1,message:$.String({minLength:1,maxLength:256})},{additionalProperties:!1}),snapshot:u},{additionalProperties:!1}));var d=16384;function m1(J){let B=/^\s*\/btw(?:\s+([\s\S]*))?\s*$/iu.exec(J);if(!B)return;return{question:(B[1]??"").trim()}}var z=Z(K(["default","autoEdit","yolo","plan"]));var M=Z(K(["user","assistant","system","tool"])),k1=Z($.Union([$.Object({type:$.Literal("text"),text:$.String()}),$.Object({type:$.Literal("image_url"),image_url:$.Object({url:$.String()})})])),g=$.Union([$.String(),$.Array(k1)]),i1=Z($.Object({id:$.String(),role:M,content:g,timestamp:$.Number(),metadata:$.Optional($.Record($.String(),$.Unknown())),thinkingContent:$.Optional($.String()),tool_call_id:$.Optional($.String()),name:$.Optional($.String()),tool_calls:$.Optional($.Unknown())})),X1=Z(K(["queued","running","completed","failed","cancelled","interrupted"])),q=Z(K(["local","worktree"])),L=Z(K(["high","medium","low"])),F=Z(K(["feature","bug","maintenance","research"])),Q1=Z(K(["applied","discarded","conflicted"])),W1=Z($.Object({status:Q1,updatedAt:$.String(),sourceCommit:$.Optional($.String()),changedFiles:$.Optional($.Integer({minimum:0})),message:$.Optional($.String())})),b1=Z($.Object({changedFiles:$.Integer({minimum:0}),additions:$.Integer({minimum:0}),deletions:$.Integer({minimum:0}),commits:$.Integer({minimum:0})})),G1=Z($.Object({path:$.String({minLength:1}),patch:$.String({maxLength:2097152}),additions:$.Integer({minimum:0}),deletions:$.Integer({minimum:0}),binary:$.Boolean(),truncated:$.Boolean()})),a1=Z($.Object({sessionId:$.String(),projectPath:$.String(),baseCommit:$.String(),files:$.Array(G1,{maxItems:100}),truncated:$.Boolean()})),V1=$.Union([$.String(),$.Number(),$.Boolean(),$.Array($.String())]),w1=Z($.Object({name:$.String(),type:K(["string","number","integer","boolean","select","multi-select"]),title:$.String(),description:$.Optional($.String()),required:$.Boolean(),defaultValue:$.Optional(V1),options:$.Optional($.Array($.Object({value:$.String(),label:$.String()}))),format:$.Optional(K(["date","uri","email","date-time"])),minimum:$.Optional($.Number()),maximum:$.Optional($.Number()),minLength:$.Optional($.Number()),maxLength:$.Optional($.Number()),minItems:$.Optional($.Number()),maxItems:$.Optional($.Number())})),t1=Z($.Object({serverName:$.String(),mode:K(["form","url"]),message:$.String(),fields:$.Optional($.Array(w1)),requestedSchema:$.Optional($.Record($.String(),$.Unknown())),url:$.Optional($.String()),domain:$.Optional($.String()),elicitationId:$.Optional($.String())})),D1=Z($.Object({type:K(["permission","question","elicitation"]),requestId:$.String()})),O1=Z($.Object({code:K(["authentication","permission","rate_limit","timeout","network","model_unavailable","context_limit","unsupported_input","workspace_unavailable","capacity","runtime"]),message:$.String({minLength:1,maxLength:500}),retryable:$.Boolean(),resource:$.Optional(K(["pending_count","pending_bytes","resident_runtimes"]))})),N=Z(K(["auto","off","minimal","low","medium","high","xhigh","max"])),v=Z(K(["auto","standard","fast","flex"])),I=Z(K(["auto","low","medium","high"])),D=Z($.Union([K(["auto","pragmatic","friendly","explanatory"]),$.String({minLength:7,maxLength:300,pattern:"^(?:(?:user|project):[a-z0-9][a-z0-9._-]{0,63}(?::[a-z0-9][a-z0-9._-]{0,63}){0,3}|plugin:[a-z0-9][a-z0-9._-]{0,63}:[a-z0-9][a-z0-9._-]{0,63}(?::[a-z0-9][a-z0-9._-]{0,63}){0,3})$"})])),C=Z($.Object({sessionId:$.String(),projectPath:$.String(),title:$.Optional($.String()),gitBranch:$.Optional($.String()),rootId:$.String(),parentId:$.Optional($.String()),relationType:$.Optional(K(["subagent","fork"])),resumedFrom:$.Optional($.String()),rootAgentId:$.Optional($.String()),resumeDepth:$.Optional($.Integer({minimum:0})),taskStatus:W(X1,"completed"),taskStatusReason:$.Optional($.String()),taskFailure:$.Optional(O1),taskStartedAt:$.Optional($.String()),taskCompletedAt:$.Optional($.String()),taskPromptSummary:$.Optional($.String()),taskPriority:$.Optional(L),taskKind:$.Optional(F),taskDueAt:$.Optional($.String()),taskModelId:$.Optional($.String()),selectedModelId:$.Optional($.String()),permissionMode:$.Optional(z),reasoningEffort:$.Optional(N),serviceTier:$.Optional(v),responseVerbosity:$.Optional(I),communicationStyle:$.Optional(D),communicationStyleDigest:$.Optional($.String({pattern:"^[a-f0-9]{64}$"})),projectInstructionsDigest:$.Optional($.String({pattern:"^[a-f0-9]{64}$"})),taskRetryAvailable:$.Optional($.Boolean()),taskRetriedFrom:$.Optional($.Object({sessionId:$.String(),projectPath:$.String()})),taskDelivery:$.Optional(W1),taskIsolation:$.Optional(q),taskSourceProjectPath:$.Optional($.String()),taskWorktreePath:$.Optional($.String()),taskWorktreeBranch:$.Optional($.String()),taskBaseCommit:$.Optional($.String()),taskDiffStat:$.Optional(b1),taskQueuePosition:$.Optional($.Integer({minimum:1})),taskQueueDepth:$.Optional($.Integer({minimum:0})),taskConcurrencyLimit:$.Optional($.Integer({minimum:1})),archivedAt:$.Optional($.String()),archivedBySessionId:$.Optional($.String()),pendingInteraction:$.Optional(D1),messageCount:$.Number(),firstMessageTime:$.String(),lastMessageTime:$.String(),hasErrors:$.Boolean()})),r1=Z($.Object({sessions:$.Array(C),nextCursor:$.Optional($.String())})),y1=Z($.Object({session:C,archivedSessionIds:$.Array($.String())})),T1=Z($.Object({session:C,restoredSessionIds:$.Array($.String())})),p1=Z($.Object({version:$.Union([$.Literal(1),$.Literal(2)]),sessionId:$.String(),goalId:$.String(),objective:$.String(),status:K(["active","verifying","paused","blocked","usage_limited","budget_limited","complete"]),tokenBudget:$.Optional($.Number()),tokensUsed:$.Number(),timeUsedSeconds:$.Number(),continuationCount:$.Number(),statusReason:$.Optional($.String()),completionVerification:$.Optional($.Object({attempt:$.Integer({minimum:1}),status:K(["pending","pass","fail","partial"]),requestedAt:$.String(),completedAt:$.Optional($.String()),verifierSessionId:$.Optional($.String()),summary:$.Optional($.String()),evidenceSha256:$.Optional($.String({pattern:"^[a-f0-9]{64}$"}))})),prematureStop:$.Optional($.Object({pattern:$.Unsafe({type:"string"}),consecutiveCount:$.Integer({minimum:1}),detectedAt:$.String()})),verificationStall:$.Optional($.Unsafe({type:"object"})),executionFrontier:$.Optional($.Object({taskListId:$.String({minLength:1,maxLength:256}),total:$.Integer({minimum:0}),completed:$.Integer({minimum:0}),inProgress:$.Integer({minimum:0}),pending:$.Integer({minimum:0}),blocked:$.Integer({minimum:0}),nextTask:$.Optional($.Object({id:$.String({minLength:1}),subject:$.String({minLength:1,maxLength:512}),priority:K(["high","medium","low"])})),digestSha256:$.String({pattern:"^[a-f0-9]{64}$"}),observedAt:$.String()})),frontierStall:$.Optional($.Object({category:K(["waiting_dependency","same_task_no_effect","repeated_deferral"]),consecutiveCount:$.Integer({minimum:1,maximum:3}),digestSha256:$.String({pattern:"^[a-f0-9]{64}$"}),detectedAt:$.String()})),createdAt:$.String(),updatedAt:$.String()})),o=Z($.Object({role:M,content:g,metadata:$.Optional($.Unknown()),reasoningContent:$.Optional($.String()),thinkingContent:$.Optional($.String()),tool_call_id:$.Optional($.String()),name:$.Optional($.String()),tool_calls:$.Optional($.Unknown())})),e1=Z($.Object({session:C,messages:$.Array(o)})),s=Z(K(["conversation","code","both"])),z1=Z($.Object({messageId:$.String(),preview:$.String(),createdAt:$.String(),fileCount:$.Integer({minimum:0})})),$0=Z($.Object({targetMessageId:$.String({minLength:1}),mode:W(s,"conversation")})),J0=Z($.Object({checkpoint:z1,mode:s,removedTurns:$.Integer({minimum:1}),restoredFiles:$.Array($.String()),messages:$.Array(o)})),N1=K(["running","completed","failed","cancelled"]),m=Z($.Object({id:$.String(),subagentType:$.String(),description:$.String(),status:N1,background:$.Boolean(),rootAgentId:$.String(),resumedFrom:$.Optional($.String()),resumeDepth:$.Integer({minimum:0}),createdAt:$.Number(),lastActiveAt:$.Number(),completedAt:$.Optional($.Number()),restartRecovery:$.Optional($.Object({outcome:K(["completed","interrupted","failed"]),recoveredAt:$.Number()})),result:$.Optional($.Object({success:$.Boolean(),message:$.String(),error:$.Optional($.String()),verificationCommands:$.Optional($.Array($.String())),verificationVerdict:$.Optional(K(["pass","fail","partial"])),modifiedFiles:$.Optional($.Array($.String()))})),stats:$.Optional($.Object({tokens:$.Optional($.Number()),toolCalls:$.Optional($.Number()),duration:$.Optional($.Number())}))})),Z0=Z($.Object({prompt:$.String({minLength:1,maxLength:32000,pattern:"\\S"})})),B0=Z($.Object({source:m,session:m})),K0=Z($.Object({sessionId:$.String(),projectPath:$.String()})),Y0=Z($.Object({path:$.String(),name:$.String(),gitBranch:$.Optional($.String()),available:$.Boolean(),isCurrent:$.Boolean(),boundAt:$.String()})),H0=Z($.Union([$.Object({cancelled:$.Literal(!0)}),$.Object({cancelled:$.Literal(!1),path:$.String({minLength:1})})])),j0=Z($.Object({type:$.String(),seq:$.Optional($.Number()),properties:$.Record($.String(),$.Unknown())})),i=$.Object({type:K(["file","image","url"]),path:$.Optional($.String()),url:$.Optional($.String()),content:$.Optional($.String({maxLength:c})),mimeType:$.Optional($.String()),name:$.Optional($.String())}),a=$.Record($.String(),$.Unknown()),k0=Z($.Object({prompt:$.String({minLength:1,maxLength:32000,pattern:"\\S"}),title:$.Optional($.String({minLength:1,maxLength:200})),taskPriority:W(L,"medium"),taskKind:W(F,"feature"),taskDueAt:$.Optional($.String({minLength:1,maxLength:64})),projectPath:$.Optional($.String()),modelId:$.Optional($.String({minLength:1,maxLength:500})),reasoningEffort:$.Optional(N),serviceTier:$.Optional(v),responseVerbosity:$.Optional(I),communicationStyle:$.Optional(D),isolation:W(q,"worktree"),permissionMode:W(z,"default"),attachments:$.Optional($.Array(i,{maxItems:U})),outputSchema:$.Optional(a)})),X0=Z($.Object({title:$.Optional($.String({minLength:1,maxLength:200})),taskPriority:$.Optional(L),taskKind:$.Optional(F),taskDueAt:$.Optional($.Union([$.String({minLength:1,maxLength:64}),$.Null()]))})),Q0=Z($.Object({session:C,runId:$.String(),messageId:$.String(),status:K(["queued","running"]),queuePosition:$.Optional($.Integer({minimum:1})),queueDepth:$.Optional($.Integer({minimum:0})),maxConcurrentTasks:$.Optional($.Integer({minimum:1}))})),W0=Z($.Object({action:K(["apply","discard"])})),R=Z($.Object({kind:K(["cron","interval","once"]),cron:$.Optional($.String({minLength:1,maxLength:120})),intervalMs:$.Optional($.Integer({minimum:60000})),runAt:$.Optional($.String({minLength:1,maxLength:40})),timezone:$.Optional($.String({minLength:1,maxLength:80}))})),v1=Z($.Object({modelId:$.Optional($.String({minLength:1,maxLength:500})),reasoningEffort:$.Optional(N),serviceTier:$.Optional(v),responseVerbosity:$.Optional(I),communicationStyle:$.Optional(D),isolation:W(q,"worktree"),permissionMode:W(z,"default")})),_=Z($.Object({id:$.String(),title:$.Optional($.String({minLength:1,maxLength:200})),prompt:$.String({minLength:1,maxLength:32000,pattern:"\\S"}),projectPath:$.String({minLength:1}),trigger:R,dispatch:v1,enabled:$.Boolean(),createdAt:$.String(),updatedAt:$.String(),nextRunAt:$.Union([$.String(),$.Null()]),expiresAt:$.Union([$.String(),$.Null()]),lastRunAt:$.Optional($.String()),lastRunSessionId:$.Optional($.String()),lastStatus:$.Optional(K(["queued","running","completed","failed","cancelled","interrupted","error"])),lastError:$.Optional($.String()),runCount:$.Integer({minimum:0})})),b0=Z($.Object({title:$.Optional($.String({minLength:1,maxLength:200})),prompt:$.String({minLength:1,maxLength:32000,pattern:"\\S"}),projectPath:$.String({minLength:1}),trigger:R,modelId:$.Optional($.String({minLength:1,maxLength:500})),reasoningEffort:$.Optional(N),serviceTier:$.Optional(v),responseVerbosity:$.Optional(I),communicationStyle:$.Optional(D),isolation:W(q,"worktree"),permissionMode:W(z,"default"),enabled:W($.Boolean(),!0)})),G0=Z($.Object({title:$.Optional($.String({minLength:1,maxLength:200})),prompt:$.Optional($.String({minLength:1,maxLength:32000,pattern:"\\S"})),trigger:$.Optional(R),modelId:$.Optional($.String({minLength:1,maxLength:500})),reasoningEffort:$.Optional(N),serviceTier:$.Optional(v),responseVerbosity:$.Optional(I),communicationStyle:$.Optional(D),isolation:$.Optional(q),permissionMode:$.Optional(z),enabled:$.Optional($.Boolean())})),V0=Z($.Object({schedules:$.Array(_)})),w0=Z($.Object({content:$.String({maxLength:n}),projectPath:$.Optional($.String()),modelId:$.Optional($.String({minLength:1,maxLength:500})),reasoningEffort:$.Optional(N),serviceTier:$.Optional(v),responseVerbosity:$.Optional(I),communicationStyle:$.Optional(D),permissionMode:$.Optional(z),attachments:$.Optional($.Array(i,{maxItems:U})),outputSchema:$.Optional(a)})),I1=K(["completed","failed","aborted","timed_out","spawn_error"]),P1=Z($.Object({version:$.Literal(1),command:$.String(),status:I1,exitCode:$.Union([$.Integer(),$.Null()]),durationMs:$.Number({minimum:0}),stdout:$.String(),stderr:$.String(),stdoutOmittedBytes:$.Integer({minimum:0}),stderrOmittedBytes:$.Integer({minimum:0}),binaryOutput:$.Boolean(),truncated:$.Boolean()})),D0=Z($.Object({command:$.String({minLength:1,maxLength:32768,pattern:"^(?![\\s\\S]*\\u0000)(?=[\\s\\S]*\\S)[\\s\\S]*$"}),projectPath:$.Optional($.String())})),O0=Z($.Object({executionId:$.String(),messageId:$.String(),record:P1,auxiliary:$.Boolean(),delivery:$.Optional(K(["current_turn","next_turn"])),queued:$.Optional($.Integer({minimum:0}))})),z0=Z($.Object({question:$.String({minLength:1,maxLength:d,pattern:"^(?![\\s\\S]*\\x00)(?=[\\s\\S]*\\S)[\\s\\S]*$"}),projectPath:$.Optional($.String())})),N0=Z($.Object({response:$.String({minLength:1}),durationMs:$.Number({minimum:0}),modelId:$.Optional($.String()),usage:$.Optional($.Object({promptTokens:$.Number({minimum:0}),completionTokens:$.Number({minimum:0}),totalTokens:$.Number({minimum:0}),reasoningTokens:$.Optional($.Number({minimum:0})),cacheCreationInputTokens:$.Optional($.Number({minimum:0})),cacheReadInputTokens:$.Optional($.Number({minimum:0})),costUsd:$.Optional($.Number({minimum:0}))}))})),v0=Z($.Object({projectPath:$.String(),kind:K(["uncommitted","base","commit"]),ref:$.Optional($.String({maxLength:200})),instructions:$.Optional($.String({maxLength:4000})),modelId:$.Optional($.String({minLength:1,maxLength:200}))})),I0=Z($.Object({reviewId:$.String(),status:$.Literal("running")})),P0=Z($.Object({messageId:$.String(),role:M,content:$.String(),timestamp:$.String()})),x0=Z($.Object({approved:$.Boolean(),remember:$.Optional($.Boolean()),scope:$.Optional(K(["once","session","project"])),targetMode:$.Optional(z),feedback:$.Optional($.String()),answers:$.Optional($.Record($.String(),$.Union([$.String(),$.Array($.String())]))),elicitation:$.Optional($.Object({action:K(["accept","decline","cancel"]),content:$.Optional($.Record($.String(),$.Union([$.String({maxLength:4000}),$.Number(),$.Boolean(),$.Array($.String({maxLength:1000}),{maxItems:100})]),{maxProperties:32}))}))})),x1=Z($.Object({id:D,name:$.String({minLength:1,maxLength:80}),description:$.String({minLength:1,maxLength:256}),source:K(["built-in","user","project","plugin"]),contentSha256:$.Optional($.String({pattern:"^[a-f0-9]{64}$"}))})),q0=Z($.Object({id:$.String(),displayName:$.Optional($.String()),provider:$.String(),model:$.String(),contextWindow:$.Optional($.Number()),maxTokens:$.Optional($.Number()),reasoning:$.Optional($.Boolean()),supportedReasoningEfforts:$.Optional($.Array(K(["off","minimal","low","medium","high","xhigh","max"]))),supportedServiceTiers:$.Optional($.Array(K(["standard","fast","flex"]))),supportedResponseVerbosities:$.Optional($.Array(K(["low","medium","high"]))),communicationStyles:$.Optional($.Array(x1,{maxItems:36})),input:$.Optional($.Array(K(["text","image"]))),overrides:$.Optional($.Object({baseUrl:$.Optional($.String()),temperature:$.Optional($.Number()),maxOutputTokens:$.Optional($.Number()),timeout:$.Optional($.Number()),streamIdleTimeout:$.Optional($.Number({minimum:1000}))}))})),C0=Z(K(["vs-dark","vs-light","hc-black"])),q1=Z(K(["light","dark","system"])),C1=Z($.Object({language:$.String(),codeTheme:$.String(),uiTheme:q1,autoSaveSessions:$.Boolean(),notifyBuild:$.Boolean(),notifyErrors:$.Boolean(),notifySounds:$.Boolean(),privacyTelemetry:$.Boolean(),privacyCrash:$.Boolean(),agentTeamsEnabled:$.Boolean(),communicationStyle:$.Optional(D)})),f0=Z($.Partial(C1));var t=y("Service"),L1=1;function F1(){return T.join(r(),"schedules.json")}class P{filePath;static instance;static getInstance(){if(!P.instance)P.instance=new P;return P.instance}writeChain=Promise.resolve();constructor(J=F1()){this.filePath=J}async readFile(){try{let J=await A1(this.filePath,"utf-8"),B=JSON.parse(J);if(!B||!Array.isArray(B.schedules))return[];let H=[],Y=0;for(let j of B.schedules){let k=_.safeParse(j);if(k.success)H.push(k.data);else Y+=1}if(Y>0)t.warn(`[ScheduleStore] Ignored ${Y} invalid persisted schedule(s)`);return H}catch(J){let B=J;if(B.code!=="ENOENT")t.warn("[ScheduleStore] Failed to read schedules; treating as empty:",B);return[]}}async writeFile(J){await f1(T.dirname(this.filePath),{recursive:!0,mode:493});let B={version:L1,schedules:J};await M1(this.filePath,JSON.stringify(B,null,2),{mode:384})}serializeWrite(J){let B=this.writeChain.then(J,J);return this.writeChain=B.then(()=>{return},()=>{return}),B}async list(){return this.readFile()}async get(J){return(await this.readFile()).find((H)=>H.id===J)}async create(J){return this.serializeWrite(async()=>{let B=J.trigger.kind==="cron"&&!J.trigger.timezone?{...J.trigger,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone}:J.trigger,H=A(B);if(H)throw Error(H);let Y=new Date;if(B.kind==="once"&&new Date(B.runAt).getTime()<=Y.getTime())throw Error("once trigger runAt must be in the future");let j=Y.toISOString(),k=f(B,Y),G={id:U1(10),title:J.title,prompt:J.prompt,projectPath:J.projectPath,trigger:B,dispatch:{modelId:J.modelId,reasoningEffort:J.reasoningEffort,serviceTier:J.serviceTier,responseVerbosity:J.responseVerbosity,communicationStyle:J.communicationStyle,isolation:J.isolation??"worktree",permissionMode:J.permissionMode??"default"},enabled:J.enabled??!0,createdAt:j,updatedAt:j,nextRunAt:k?k.toISOString():null,expiresAt:null,runCount:0},V=await this.readFile();return V.push(G),await this.writeFile(V),G})}async update(J,B){return this.serializeWrite(async()=>{let H=await this.readFile(),Y=H.findIndex((X)=>X.id===J);if(Y===-1)return;let j=H[Y];if(B.trigger){let X=B.trigger.kind==="cron"&&!B.trigger.timezone?{...B.trigger,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone}:B.trigger,b=A(X);if(b)throw Error(b);if(X.kind==="once"&&new Date(X.runAt).getTime()<=Date.now())throw Error("once trigger runAt must be in the future");B={...B,trigger:X}}let k={...j,...B,dispatch:B.dispatch?{...j.dispatch,...B.dispatch}:j.dispatch,updatedAt:new Date().toISOString()},G=!j.enabled,V=k.enabled,Q=B.trigger!==void 0;if((Q||G&&V)&&B.nextRunAt===void 0){let X=new Date,b=f(k.trigger,X);if(k.nextRunAt=b?b.toISOString():null,Q)k.expiresAt=null}return H[Y]=k,await this.writeFile(H),k})}async remove(J){return this.serializeWrite(async()=>{let B=await this.readFile(),H=B.filter((Y)=>Y.id!==J);if(H.length===B.length)return!1;return await this.writeFile(H),!0})}async setEnabled(J,B){return this.update(J,{enabled:B})}}var c0=P.getInstance();
2
- export{d as Ra,m1 as Sa,O as Ta,K1 as Ua,h as Va,u as Wa,H1 as Xa,R1 as Ya,f as Za,A as _a,_1 as $a,a1 as ab,C as bb,$0 as cb,Z0 as db,k0 as eb,X0 as fb,Q0 as gb,W0 as hb,_ as ib,b0 as jb,G0 as kb,V0 as lb,w0 as mb,D0 as nb,z0 as ob,v0 as pb,P as qb,c0 as rb};
@@ -1 +0,0 @@
1
- import{gg as a}from"./chunk-acsfh1cw.js";import"./chunk-jb8stg10.js";import"./chunk-g7h0peka.js";import"./chunk-s3a017q7.js";import"./chunk-bdtpq7j9.js";import"./chunk-na3nregt.js";import"./chunk-ntd69c0k.js";export{a as createChatServiceAsync};
@@ -1 +0,0 @@
1
- import{a,b as i,c as l,d as m}from"./chunk-qjydadex.js";import"./chunk-1pmvyqed.js";import"./chunk-r51afpkk.js";import"./chunk-9z9v8v4j.js";import"./chunk-46jmq302.js";import"./chunk-g4vgnxh4.js";import"./chunk-sy0vxdc3.js";import"./chunk-24rsvr6e.js";import"./chunk-hx10bph0.js";import"./chunk-gq7fdc8c.js";import"./chunk-c5rfnzhf.js";import"./chunk-wzkh3e6a.js";import"./chunk-mxe4pr8t.js";import"./chunk-z3hpstky.js";import"./chunk-mq1mk3v5.js";import"./chunk-fnc97xg7.js";import{pf as n}from"./chunk-v2qxszks.js";import"./chunk-kbnxbb23.js";import{Lf as s}from"./chunk-0qq64xqm.js";import"./chunk-v508x7cg.js";import"./chunk-q0s3gcjm.js";import"./chunk-acsfh1cw.js";import"./chunk-tev70rzj.js";import"./chunk-vvawhvea.js";import"./chunk-82x77b2p.js";import"./chunk-1cbaqh71.js";import"./chunk-5sknjz9b.js";import"./chunk-f7hsagj6.js";import"./chunk-sv5z5sna.js";import"./chunk-qm96k94k.js";import"./chunk-77x1rrz9.js";import"./chunk-mm1atkae.js";import"./chunk-gdnyt8a7.js";import"./chunk-vptn8fhx.js";import"./chunk-jc28ddt0.js";import"./chunk-nfzad4te.js";import"./chunk-jb8stg10.js";import"./chunk-g7h0peka.js";import"./chunk-s3a017q7.js";import"./chunk-bdtpq7j9.js";import"./chunk-w2n1vwzg.js";import"./chunk-zy2etr3v.js";import"./chunk-1p9sjb8d.js";import"./chunk-na3nregt.js";import"./chunk-ntd69c0k.js";import v from"chalk";var C={command:"serve",describe:"Start a headless Blade server (no browser)",builder:a,handler:async(p)=>{let r=i(p);if(await s(),!process.env.BLADE_SERVER_PASSWORD)console.log(v.yellow("Warning: BLADE_SERVER_PASSWORD is not set; server is unsecured."));let e=await m.listenAsync(r);if(console.log(`Blade server listening on http://${e.hostname}:${e.port}`),r.hostname==="0.0.0.0"){let o=l();for(let g of o)console.log(` Network: http://${g}:${e.port}`)}let t,c=new Promise((o)=>{t=o}),d=n(async()=>{await e.stop(),t()});try{await c}finally{d(),await e.stop()}}};export{C as serveCommand};
@@ -1,2 +0,0 @@
1
- import d from"typebox/schema";import o from"typebox/value";class u extends Error{issues;constructor(r){super(r.map((t)=>{return`${t.path.length>0?t.path.join("."):"root"}: ${t.message}`}).join("; "));this.issues=r;this.name="SchemaValidationError"}}function p(r){if(!r)return[];return r.split("/").slice(1).map((t)=>t.replace(/~1/g,"/").replace(/~0/g,"~")).map((t)=>/^(0|[1-9]\d*)$/.test(t)?Number(t):t)}function g(r,t){let n=r;for(let e of t){if(n===null||typeof n!=="object")return;n=n[e]}return n}function i(r,t){let[,n]=d.Errors(r,t);return n.map((e)=>{let s=p(e.instancePath);return{code:e.keyword,path:s,message:e.message,value:g(t,s)}})}function a(r,t){let n=o.Default(r,o.Clone(t)),e=i(r,n);if(e.length>0)return{success:!1,error:new u(e)};let s=o.Clean(r,n),c=i(r,s);if(c.length>0)return{success:!1,error:new u(c)};return{success:!0,data:s}}function f(r,t){let n=a(r,t);if(!n.success)throw n.error;return n.data}import l from"typebox";function x(r){return Object.defineProperties(r,{parse:{value:(t)=>f(r,t),enumerable:!1},safeParse:{value:(t)=>a(r,t),enumerable:!1}}),r}function b(r,t){return l.Optional({...r,default:t})}function V(r,t={}){return l.Unsafe({type:"string",enum:[...r],...t})}
2
- export{a as Ri,f as Si,l as Ti,x as Ui,b as Vi,V as Wi};
@@ -1 +0,0 @@
1
- import{Ig as a,Jg as b,Kg as c,Lg as d,Mg as e,Ng as f,Og as g,Pg as h,Qg as i,Rg as j,Sg as k}from"./chunk-1cbaqh71.js";import"./chunk-5sknjz9b.js";import"./chunk-f7hsagj6.js";import"./chunk-sv5z5sna.js";import"./chunk-qm96k94k.js";import"./chunk-77x1rrz9.js";import"./chunk-mm1atkae.js";import"./chunk-gdnyt8a7.js";import"./chunk-vptn8fhx.js";import"./chunk-jc28ddt0.js";import"./chunk-nfzad4te.js";import"./chunk-jb8stg10.js";import"./chunk-g7h0peka.js";import"./chunk-s3a017q7.js";import"./chunk-bdtpq7j9.js";import"./chunk-w2n1vwzg.js";import"./chunk-zy2etr3v.js";import"./chunk-1p9sjb8d.js";import"./chunk-na3nregt.js";import"./chunk-ntd69c0k.js";export{g as withWorkspaceAgentResources,i as snapshotWorkspaceAgentResources,f as resolveWorkspaceAgentResources,k as resetWorkspaceAgentResources,d as refreshWorkspaceCommunicationStyles,h as getWorkspaceAgentResourceCacheStats,j as createEmptySessionAgentResources,e as configureInvocationPluginDirs,c as WorkspaceAgentResourceCapacityError,a as MAX_RESIDENT_WORKSPACE_AGENT_RESOURCES,b as MAX_ACTIVE_WORKSPACE_AGENT_RESOURCES};
@@ -1 +0,0 @@
1
- import{kf as a,lf as b,mf as c}from"./chunk-t6cajkaj.js";import"./chunk-13sdjfks.js";import"./chunk-0qq64xqm.js";import"./chunk-v508x7cg.js";import"./chunk-q0s3gcjm.js";import"./chunk-sv5z5sna.js";import"./chunk-mm1atkae.js";import"./chunk-gdnyt8a7.js";import"./chunk-vptn8fhx.js";import"./chunk-jc28ddt0.js";import"./chunk-nfzad4te.js";import"./chunk-jb8stg10.js";import"./chunk-g7h0peka.js";import"./chunk-s3a017q7.js";import"./chunk-bdtpq7j9.js";import"./chunk-w2n1vwzg.js";import"./chunk-zy2etr3v.js";import"./chunk-1p9sjb8d.js";import"./chunk-na3nregt.js";import"./chunk-ntd69c0k.js";export{a as validatePermissions,c as validateOutput,b as loadConfiguration};
@@ -1 +0,0 @@
1
- import{He as a,Ie as b,Je as c,Ke as d,Le as e,Me as f,Ne as g,Oe as h,Pe as i,Qe as j,Re as k,Se as l,Te as m,Ue as n,Ve as o,We as p,Xe as q,Ye as r}from"./chunk-mq1mk3v5.js";import"./chunk-fnc97xg7.js";import"./chunk-77x1rrz9.js";import"./chunk-nfzad4te.js";import"./chunk-g7h0peka.js";import"./chunk-na3nregt.js";import"./chunk-ntd69c0k.js";export{h as syncSession,j as syncAllAcpRemoteScopes,k as syncAll,i as syncAcpRemoteScope,r as searchProjectionText,f as resetProjectionDbCache,l as removeSessionFromProjection,m as rebuildProjectionIndex,q as readSessionSurfaceHistoryPage,o as readSessionSurfaceCatalogRevision,p as readSessionSurfaceCatalogPage,n as readSessionSurfaceCandidates,g as projectSessionSurfaceSummaryFields,c as getSessionSurfaceHistoryByteLimit,e as getProjectionDb,d as getIndexDbPath,a as __setProjectionIOForTesting,b as __resetProjectionIOForTesting};
@@ -1,6 +0,0 @@
1
- import{nf as v}from"./chunk-13sdjfks.js";import{Gf as e}from"./chunk-0qq64xqm.js";import{Ei as i,Fi as t,Th as y,Vh as D,Wh as h,Yh as A,di as P,ei as T,gi as E,ii as _,ji as f,li as C,pi as S,qi as m,ri as c,si as p,ui as u,vi as d,zi as l}from"./chunk-mm1atkae.js";import{Gi as Y}from"./chunk-gdnyt8a7.js";import{Oi as X}from"./chunk-jc28ddt0.js";import{Ri as x,Ti as k,Wi as Z}from"./chunk-nfzad4te.js";import{Yi as U,Zi as L,dj as M,ej as O,gj as $,hj as I,ij as G,kj as N,lj as j,nj as F,oj as R}from"./chunk-jb8stg10.js";import{wj as s}from"./chunk-g7h0peka.js";import{promises as a}from"node:fs";import g from"node:path";var r=["systemPrompt","appendSystemPrompt","initialMessage","resumeSessionId","forkSession","allowedTools","disallowedTools","mcpConfigPaths","strictMcpConfig","model","addDirs","outputFormat","inputFormat","print","includePartialMessages","replayUserMessages","agentsConfig","settingSources"],kk=new Set([...Object.keys(l),...r,"providerRequestConcurrency","providerGlobalConcurrency","providerOwnerConcurrency"]),W=k.Number({exclusiveMinimum:0}),z=k.String({minLength:1}),b=k.Array(k.String()),qk=k.Object({currentModelId:k.Optional(k.String()),modelProviders:k.Optional(k.Record(z,k.Object({name:z,baseUrl:z,wireApi:Z(["openai-completions","anthropic-messages"]),apiKeyEnv:k.Optional(z)}))),models:k.Optional(k.Array(k.Object({id:z,displayName:k.Optional(z),provider:z,model:z,overrides:k.Optional(k.Object({baseUrl:k.Optional(k.String()),temperature:k.Optional(k.Number()),maxOutputTokens:k.Optional(W),timeout:k.Optional(W),streamIdleTimeout:k.Optional(k.Number({minimum:1000})),apiVersion:k.Optional(k.String()),customHeaders:k.Optional(k.Record(k.String(),k.String())),maxRetries:k.Optional(k.Integer({minimum:0})),enablePromptCaching:k.Optional(k.Boolean())})),fallbackModels:k.Optional(k.Array(k.Object({provider:z,model:z,configId:k.Optional(z)})))}))),temperature:k.Optional(k.Number()),maxOutputTokens:k.Optional(W),stream:k.Optional(k.Boolean()),topP:k.Optional(k.Number()),topK:k.Optional(k.Number()),timeout:k.Optional(W),bashForegroundHandoffMs:k.Optional(k.Union([k.Literal(0),k.Integer({minimum:P,maximum:T})])),providerForegroundRecoveryMs:k.Optional(k.Union([k.Literal(0),k.Integer({minimum:U,maximum:L})])),providerCircuitBreakerOpenMs:k.Optional(k.Union([k.Literal(0),k.Integer({minimum:M,maximum:O})])),providerRequestConcurrency:k.Optional(k.Integer({minimum:$,maximum:I})),providerGlobalConcurrency:k.Optional(k.Integer({minimum:$,maximum:G})),providerOwnerConcurrency:k.Optional(k.Integer({minimum:$,maximum:G})),providerRequestAdmissionMs:k.Optional(k.Union([k.Literal(0),k.Integer({minimum:N,maximum:j})])),providerRequestPendingBytes:k.Optional(k.Integer({minimum:F,maximum:R})),agentTeamsEnabled:k.Optional(k.Boolean()),codeTheme:k.Optional(k.String()),uiTheme:k.Optional(Z(["light","dark","system"])),language:k.Optional(k.String()),fontSize:k.Optional(W),autoSaveSessions:k.Optional(k.Boolean()),notifyBuild:k.Optional(k.Boolean()),notifyErrors:k.Optional(k.Boolean()),notifySounds:k.Optional(k.Boolean()),privacyTelemetry:k.Optional(k.Boolean()),privacyCrash:k.Optional(k.Boolean()),debug:k.Optional(k.Union([k.Boolean(),k.String()])),mcpEnabled:k.Optional(k.Boolean()),mcpServers:k.Optional(k.Record(k.String(),k.Record(k.String(),k.Unknown()))),lspServers:k.Optional(k.Record(z,k.Object({command:z,args:k.Optional(k.Array(k.String())),extensionToLanguage:k.Record(z,z),env:k.Optional(k.Record(k.String(),k.String())),initializationOptions:k.Optional(k.Unknown()),settings:k.Optional(k.Unknown()),enabled:k.Optional(k.Boolean()),priority:k.Optional(k.Integer()),startupTimeout:k.Optional(k.Integer({minimum:100})),shutdownTimeout:k.Optional(k.Integer({minimum:100})),requestTimeout:k.Optional(k.Integer({minimum:100})),diagnosticWaitTimeout:k.Optional(k.Integer({minimum:0})),maxRestarts:k.Optional(k.Integer({minimum:0,maximum:10}))}))),permissionMode:k.Optional(k.Enum(Y)),maxTurns:k.Optional(k.Integer({minimum:-1})),maxConcurrentTasks:k.Optional(k.Integer({minimum:S,maximum:m})),maxQueuedTasks:k.Optional(k.Integer({minimum:c,maximum:p})),maxQueuedTaskBytes:k.Optional(k.Integer({minimum:u,maximum:d})),maxResidentSessionRuntimes:k.Optional(k.Integer({minimum:E,maximum:_})),sessionRuntimeIdleMs:k.Optional(k.Integer({minimum:f,maximum:C})),maxResidentSessionProjections:k.Optional(k.Integer({minimum:y,maximum:D})),sessionProjectionIdleMs:k.Optional(k.Integer({minimum:h,maximum:A})),systemPrompt:k.Optional(k.String()),appendSystemPrompt:k.Optional(k.String()),initialMessage:k.Optional(k.String()),resumeSessionId:k.Optional(k.String()),forkSession:k.Optional(k.Boolean()),allowedTools:k.Optional(k.Array(z)),disallowedTools:k.Optional(k.Array(z)),mcpConfigPaths:k.Optional(k.Array(z)),strictMcpConfig:k.Optional(k.Boolean()),model:k.Optional(z),addDirs:k.Optional(k.Array(z)),outputFormat:k.Optional(Z(["text","json","stream-json","jsonl"])),inputFormat:k.Optional(Z(["text","stream-json"])),print:k.Optional(k.Boolean()),includePartialMessages:k.Optional(k.Boolean()),replayUserMessages:k.Optional(k.Boolean()),agentsConfig:k.Optional(k.String()),settingSources:k.Optional(k.String()),permissions:k.Optional(k.Object({allow:k.Optional(b),ask:k.Optional(b),deny:k.Optional(b)})),env:k.Optional(k.Record(k.String(),k.String())),hooks:k.Optional(k.Record(k.String(),k.Unknown())),enabledPlugins:k.Optional(k.Record(z,k.Boolean())),pluginSourcePolicy:k.Optional(k.Object({restrictToAllowedSources:k.Optional(k.Boolean()),requireGitCommitSha:k.Optional(k.Boolean()),allowedGitHosts:k.Optional(k.Array(z)),allowedMarketplaces:k.Optional(k.Array(z)),allowedLocalRoots:k.Optional(k.Array(z))})),disableAllHooks:k.Optional(k.Boolean())}),wk=[["systemPrompt","systemPrompt"],["appendSystemPrompt","appendSystemPrompt"],["initialMessage","initialMessage"],["resumeSessionId","sessionId"],["forkSession","forkSession"],["allowedTools","allowedTools"],["disallowedTools","disallowedTools"],["mcpConfigPaths","mcpConfig"],["strictMcpConfig","strictMcpConfig"],["model","model"],["addDirs","addDir"],["outputFormat","outputFormat"],["inputFormat","inputFormat"],["print","print"],["includePartialMessages","includePartialMessages"],["replayUserMessages","replayUserMessages"],["agentsConfig","agents"],["settingSources","settingSources"],["permissionMode","permissionMode"],["maxTurns","maxTurns"],["maxConcurrentTasks","maxConcurrentTasks"],["maxQueuedTasks","maxQueuedTasks"],["maxQueuedTaskBytes","maxQueuedTaskBytes"],["maxResidentSessionRuntimes","maxResidentSessionRuntimes"],["sessionRuntimeIdleMs","sessionRuntimeIdleMs"],["maxResidentSessionProjections","maxResidentSessionProjections"],["sessionProjectionIdleMs","sessionProjectionIdleMs"]];function V(q,B){let w;try{w=JSON.parse(q)}catch(H){let K=H instanceof Error?`: ${H.message}`:"";throw Error(`Invalid JSON provided to --settings (${B})${K}`)}if(!w||typeof w!=="object"||Array.isArray(w))throw Error("--settings must contain a JSON object");for(let H of Object.keys(w))if(!kk.has(H))throw Error(`Unknown --settings field: ${H}`);let J=x(qk,w);if(!J.success){let H=J.error.issues.map((K)=>`${K.path.join(".")||"settings"}: ${K.message}`).join("; ");throw Error(`Invalid --settings value: ${H}`)}return J.data}async function n(q){if(q===void 0)return;let B=q.trim();if(!B)throw Error("--settings requires a JSON object or file path");if(B.startsWith("{"))return V(B,"inline JSON");let w=g.resolve(X(),B),J;try{J=await a.readFile(w,"utf8")}catch(H){let K=H instanceof Error?`: ${H.message}`:"";throw Error(`Unable to read --settings file ${w}${K}`)}return V(J,w)}function o(q,B){if(!B)return;let w=B;for(let[J,H]of wk){if(J==="permissionMode"&&q.yolo===!0)continue;if(q[H]===void 0&&w[J]!==void 0)q[H]=w[J]}}var Q=s("General"),Uk=(q)=>{if(q.yolo){if(q.permissionMode&&q.permissionMode!=="yolo")throw Error("Cannot use both --yolo and --permission-mode with different values");q.permissionMode="yolo"}if(Array.isArray(q.allowedTools))q.allowedTools=q.allowedTools.flatMap((B)=>B.split(",").map((w)=>w.trim()).filter((w)=>w.length>0));if(Array.isArray(q.disallowedTools))q.disallowedTools=q.disallowedTools.flatMap((B)=>B.split(",").map((w)=>w.trim()).filter((w)=>w.length>0));if(Array.isArray(q.allowedTools)&&Array.isArray(q.disallowedTools)){let B=q.allowedTools.filter((w)=>q.disallowedTools.includes(w));if(B.length>0)throw Error(`Tools cannot be both allowed and disallowed: ${B.join(", ")}`)}},Lk=async(q)=>{let B=await n(typeof q.settings==="string"?q.settings:void 0);if(o(q,B),typeof q.agents==="string")v(q.agents);zk(q);try{let J=await i.getInstance().initialize(B),H=t(J,q);if(e().config.actions.setConfig(H),q.debug)Q.info("[CLI] 配置已加载到 Store")}catch(w){Q.error("[CLI] [FAIL] 配置初始化失败",w instanceof Error?w.message:w),console.error(`
2
- [FAIL] 配置初始化失败
3
- `),console.error("原因:",w instanceof Error?w.message:"未知错误"),console.error(`
4
- 请检查:`),console.error(" 1. 配置文件格式是否正确 (~/.blade/config.json)"),console.error(" 2. 是否需要运行 blade 进行首次配置"),console.error(` 3. 配置文件权限是否正确
5
- `),process.exit(1)}};function zk(q){if(q.continue&&q.resume)throw Error("Cannot use both --continue and --resume flags simultaneously");if(q.forkSession&&!q.continue&&!q.resume)throw Error("--fork-session requires --resume or --continue");if(q.sessionId&&(q.continue||q.resume)&&!q.forkSession)throw Error("--session-id can only be combined with --resume or --continue when --fork-session is set")}var Mk=(q)=>{if(q.jsonSchema&&q.outputSchema)throw Error("--json-schema cannot be combined with --output-schema");if((q.jsonSchema||q.outputSchema)&&!q.print&&!q.headless)throw Error("--json-schema and --output-schema can only be used with --print or --headless");if(q.outputFormat&&q.outputFormat!=="text"&&!q.print&&!q.headless)throw Error("--output-format can only be used with --print or --headless");if(q.headless&&q.outputFormat&&!["text","jsonl"].includes(q.outputFormat))throw Error(`--headless only supports --output-format text|jsonl, but got "${q.outputFormat}". Use --print for json|stream-json support.`);if(q.print&&q.outputFormat&&!["text","json","stream-json"].includes(q.outputFormat))throw Error(`--print only supports --output-format text|json|stream-json, but got "${q.outputFormat}". Use --headless for jsonl support.`);if(q.inputFormat==="stream-json"&&q.print)Q.warn("[WARN] Warning: stream-json input format may not work as expected with --print")};
6
- export{Uk as kf,Lk as lf,Mk as mf};
@@ -1 +0,0 @@
1
- import{Ff as a,Gf as b,Hf as c,If as d,Jf as e,Kf as f,Lf as g,Mf as h,Nf as i,Of as j,Pf as k,Qf as l,Rf as m,Sf as n,Tf as o,Uf as p,Vf as q}from"./chunk-0qq64xqm.js";import"./chunk-v508x7cg.js";import"./chunk-q0s3gcjm.js";import"./chunk-mm1atkae.js";import"./chunk-gdnyt8a7.js";import"./chunk-vptn8fhx.js";import"./chunk-jc28ddt0.js";import"./chunk-nfzad4te.js";import"./chunk-jb8stg10.js";import"./chunk-g7h0peka.js";import"./chunk-s3a017q7.js";import"./chunk-bdtpq7j9.js";import"./chunk-w2n1vwzg.js";import"./chunk-zy2etr3v.js";import"./chunk-1p9sjb8d.js";import"./chunk-na3nregt.js";import"./chunk-ntd69c0k.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 +0,0 @@
1
- import{if as a,jf as b}from"./chunk-hqwpnb0x.js";import"./chunk-w2n1vwzg.js";import"./chunk-ntd69c0k.js";export{a as globalOptions,b as cliConfig};
@@ -1 +0,0 @@
1
- import{k as a,l as b,m as c,n as d,o as e}from"./chunk-91pb41e7.js";import"./chunk-w2n1vwzg.js";import"./chunk-ntd69c0k.js";export{b as setSkipUntilVersion,d as performUpgrade,c as getUpgradeCommand,e as checkVersionOnStartup,a as checkVersion};
@@ -1,2 +0,0 @@
1
- var _=20,E=5242880,T=32768,A=1e6,S=4194304;
2
- export{_ as Ii,E as Ji,T as Ki,A as Li,S as Mi};
@@ -1 +0,0 @@
1
- import{hg as a,ig as b,jg as c}from"./chunk-tev70rzj.js";import"./chunk-vvawhvea.js";import"./chunk-s3a017q7.js";import"./chunk-bdtpq7j9.js";import"./chunk-na3nregt.js";import"./chunk-ntd69c0k.js";export{b as resolveModelConfig,c as getModelDisplayName,a as getModelApiKeyEnvironmentVariable};
@@ -1,63 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownRenderer-BMAuTkc6.js","assets/index-DiRs2_w4.js","assets/vendor-react-DofNRwfy.js","assets/vendor-radix-D6QrtXqd.js","assets/session-events-BqQQkbAN.js","assets/index-CPpIFWLG.css","assets/copy-d9M8JUfQ.js"])))=>i.map(i=>d[i]);
2
- import{r as h,j as e}from"./vendor-react-DofNRwfy.js";import{c as J,u as U,a as p,s as Oe,b as it,d as le,H as Fe,P as ot,G as Ve,L as P,S as He,T as re,C as pe,D as Qe,e as Ke,f as lt,g as ze,h as qe,i as Ge,j as $,k as ct,l as ee,B as dt,m as ye,n as ce,R as me,F as ut,_ as We,o as mt,p as Je,q as ht,r as Ye,t as xt,X as Xe,v as pt,A as Ce,w as ft,W as bt,x as vt,y as gt}from"./index-DiRs2_w4.js";import{_ as Ee,M as ae,Z as L,a2 as kt,A as jt,a3 as yt,Q as wt,X as Nt,Y as St}from"./session-events-BqQQkbAN.js";import{A as Ct,E as Et}from"./external-link-GRAtjoO2.js";import{S as Tt}from"./ScrollArea-DJq2Kdpi.js";import{C as Ze}from"./copy-d9M8JUfQ.js";import{C as ne}from"./chevron-right-Brb1rhaA.js";import{A as Te,a as Mt,C as At}from"./chevrons-up-down-N-VshXV_.js";import{f as Ft,g as Rt,h as Dt,i as et}from"./vendor-radix-D6QrtXqd.js";import{P as $t}from"./pause-BqsFgQi0.js";import{P as It}from"./play-DmEPnYDS.js";import{P as tt}from"./pencil-Ca9289F-.js";import{C as Bt}from"./clock-3-gdZEKe2U.js";import{t as _}from"./team-QZ9byb3E.js";import{teamService as Re}from"./teamService-B7Fp8Oyg.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 _t=J("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"}]]);/**
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 Pt=J("Gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]);/**
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 Ut=J("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"}]]);/**
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 Lt=J("ListOrdered",[["line",{x1:"10",x2:"21",y1:"6",y2:"6",key:"76qw6h"}],["line",{x1:"10",x2:"21",y1:"12",y2:"12",key:"16nom4"}],["line",{x1:"10",x2:"21",y1:"18",y2:"18",key:"u3jurt"}],["path",{d:"M4 6h1v4",key:"cnovpq"}],["path",{d:"M4 10h2",key:"16xx2s"}],["path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1",key:"m9a95d"}]]);/**
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 Ot=J("LockKeyhole",[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]]);/**
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 Vt=J("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"}]]);/**
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 Ht=J("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"}]]);/**
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 Qt=J("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"}]]);/**
43
- * @license lucide-react v0.300.0 - ISC
44
- *
45
- * This source code is licensed under the ISC license.
46
- * See the LICENSE file in the root directory of this source tree.
47
- */const Kt=J("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 De(t){return t.split("/").filter(Boolean).at(-1)||t}function zt(){const t=U(),s=p(k=>k.sessions),r=p(k=>k.currentSessionRef),a=p(k=>k.historySurfaceSelection),o=p(k=>k.taskDeliveryActions),n=p(k=>k.deliverTask),u=Ee(k=>k.openFilePreview),[x,v]=h.useState(!1),l=s.find(k=>Oe({sessionId:k.sessionId,projectPath:k.projectPath},r));if(ae(a)||!(l!=null&&l.taskIsolation))return null;const f=l.taskDiffStat,b=l.taskIsolation==="worktree",c=it(l),j=o[le(c)],m=l.taskDelivery,w=(m==null?void 0:m.status)==="conflicted",i=!!(f&&(f.changedFiles>0||f.commits>0)),C=!["queued","running"].includes(l.taskStatus),g=(m==null?void 0:m.status)==="applied"||(m==null?void 0:m.status)==="discarded",T=b&&i&&C&&!g,d=f?f.additions+f.deletions:0,E=d>0&&f?f.additions/d*100:0,S=k=>{L(p.getState())||n(c,k).catch(()=>{})},D=()=>{L(p.getState())||u({tab:"diff"})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex min-h-10 flex-wrap items-center gap-x-3 gap-y-1.5 border-b border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))]/60 px-3 py-1.5 font-mono text-[10.5px] text-[hsl(var(--deck-ink-muted))] backdrop-blur-sm sm:px-5",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[e.jsx(Fe,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"truncate text-[hsl(var(--deck-ink))]",children:De(l.taskSourceProjectPath||l.projectPath)})]}),e.jsx("span",{className:"text-[hsl(var(--deck-ink-faint))]/60",children:"/"}),e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[b?e.jsx(ot,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-accent))]"}):e.jsx(Fe,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:b?"text-[hsl(var(--deck-accent))]":void 0,children:t(b?"artifact.env.isolated":"artifact.env.local")})]}),l.taskWorktreeBranch&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[hsl(var(--deck-ink-faint))]/60",children:"/"}),e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 truncate",title:l.taskWorktreeBranch,children:[e.jsx(Ve,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"truncate",children:l.taskWorktreeBranch})]})]})]}),f&&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(_t,{className:"h-3 w-3 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"tabular-nums",children:f.changedFiles})]}),d>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:`${E}%`}}),e.jsx("span",{className:"h-full bg-red-500/80",style:{width:`${100-E}%`}})]}),e.jsxs("span",{className:"tabular-nums text-[hsl(var(--deck-accent))]",children:["+",f.additions]}),e.jsxs("span",{className:"tabular-nums text-red-600 dark:text-red-400",children:["-",f.deletions]}),f.commits>0&&e.jsx("span",{className:"hidden tabular-nums text-[hsl(var(--deck-ink-faint))] sm:inline",children:t("artifact.commits",{count:f.commits})}),i&&(m==null?void 0:m.status)!=="discarded"&&e.jsx("button",{type:"button",onClick:D,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")}),T&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",disabled:!!j,onClick:()=>S("apply"),className:"inline-flex items-center gap-1 rounded-md bg-[hsl(var(--deck-accent))] px-2 py-1 font-semibold text-white transition hover:brightness-95 disabled:cursor-wait disabled:opacity-65",children:[j==="apply"?e.jsx(P,{className:"h-3 w-3 animate-spin"}):e.jsx(He,{className:"h-3 w-3"}),t(j==="apply"?"artifact.applying":w?"artifact.retryApply":"artifact.apply")]}),e.jsx("button",{type:"button",disabled:!!j,onClick:()=>v(!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:j==="discard"?e.jsx(P,{className:"h-3 w-3 animate-spin"}):e.jsx(re,{className:"h-3 w-3"})})]}),(m==null?void 0:m.status)==="applied"&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-emerald-500/10 px-2 py-1 font-semibold text-emerald-700 dark:text-emerald-300",children:[e.jsx(pe,{className:"h-3 w-3"}),t("artifact.applied")]}),(m==null?void 0:m.status)==="discarded"&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-[hsl(var(--deck-surface-2))] px-2 py-1 text-[hsl(var(--deck-ink-faint))]",children:[e.jsx(re,{className:"h-3 w-3"}),t("artifact.discarded")]})]}),(m==null?void 0:m.status)==="conflicted"&&e.jsxs("div",{className:"flex w-full items-start gap-1.5 border-t border-amber-500/20 pt-1.5 text-amber-700 dark:text-amber-300",role:"alert",children:[e.jsx(Ct,{className:"mt-0.5 h-3 w-3 shrink-0"}),e.jsxs("span",{className:"min-w-0 flex-1 space-y-0.5",children:[e.jsx("span",{className:"block",children:m.message||t("artifact.conflict")}),e.jsx("span",{className:"block text-[hsl(var(--deck-ink-faint))]",children:t("artifact.conflictHint")})]})]})]}),e.jsx(Qe,{open:x,onOpenChange:v,children:e.jsxs(Ke,{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(lt,{children:[e.jsx(ze,{children:t("artifact.discardDialog.title")}),e.jsx(qe,{className:"text-[hsl(var(--deck-ink-muted))]",children:t("artifact.discardDialog.description",{project:De(l.taskSourceProjectPath||l.projectPath),count:(f==null?void 0:f.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(Ge,{className:"gap-2 sm:space-x-0",children:[e.jsx("button",{type:"button",onClick:()=>v(!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:()=>{v(!1),S("discard")},className:"inline-flex items-center justify-center gap-1.5 rounded-md bg-red-600 px-3 py-2 text-sm font-semibold text-white hover:bg-red-700",children:[e.jsx(re,{className:"h-3.5 w-3.5"}),t("artifact.discardDialog.confirm")]})]})]})})]})}const qt=new Set(["completed","stale","failed","aborted","interrupted"]),Gt={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"},Wt={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 he(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:void 0}function Jt(t){const s=he(t),r=he(s==null?void 0:s.codeLocation),a=s==null?void 0:s.priority,o=s==null?void 0:s.confidenceScore,n=r==null?void 0:r.lineStart,u=r==null?void 0:r.lineEnd;if(!(typeof(s==null?void 0:s.title)!="string"||typeof s.body!="string"||a!==0&&a!==1&&a!==2&&a!==3||typeof o!="number"||!Number.isFinite(o)||typeof(r==null?void 0:r.path)!="string"||!Number.isInteger(n)||!Number.isInteger(u)))return{title:s.title,body:s.body,priority:a,confidenceScore:o,codeLocation:{path:r.path,lineStart:n,lineEnd:u}}}function Yt(t){const s=he(t),r=he(s==null?void 0:s.target);if((s==null?void 0:s.phase)!=="completed"||typeof s.status!="string"||!qt.has(s.status)||typeof(r==null?void 0:r.label)!="string"||r.kind!=="uncommitted"&&r.kind!=="base"&&r.kind!=="commit"||typeof s.overallExplanation!="string"||!Array.isArray(s.findings))return;const a=s.findings.map(Jt);if(!a.some(o=>o===void 0))return{status:s.status,target:{kind:r.kind,label:r.label,...typeof r.reference=="string"?{reference:r.reference}:{}},overallExplanation:s.overallExplanation,findings:a,...typeof s.error=="string"?{error:s.error}:{}}}function Xt(t){const{path:s,lineStart:r,lineEnd:a}=t.codeLocation;return r===a?`${s}:L${r}`:`${s}:L${r}-${a}`}function Zt({report:t}){const s=U(),r=t.target.kind==="uncommitted"?s("chat.review.target.uncommitted"):t.target.kind==="base"?s("chat.review.target.base",{ref:t.target.reference??t.target.label}):s("chat.review.target.commit",{ref:t.target.reference??t.target.label});return e.jsxs("section",{"data-code-review-report":!0,className:"overflow-hidden rounded-xl border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsxs("header",{className:"flex flex-wrap items-center justify-between gap-3 border-b border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-surface-2))]/60 px-4 py-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-[13px] font-semibold text-[hsl(var(--deck-ink))]",children:s("chat.review.title")}),e.jsxs("p",{className:"mt-0.5 font-mono text-[10.5px] text-[hsl(var(--deck-ink-faint))]",children:[s("chat.review.target"),": ",r]})]}),e.jsxs("span",{className:$("rounded-full border px-2.5 py-1 font-mono text-[10.5px] font-medium",Wt[t.status]),children:[s("chat.review.status"),": ",s(Gt[t.status])]})]}),e.jsxs("div",{className:"space-y-4 px-4 py-3.5",children:[e.jsx("p",{className:"whitespace-pre-wrap text-[13px] leading-6 text-[hsl(var(--deck-ink-muted))]",children:t.overallExplanation}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("h4",{className:"deck-eyebrow text-[hsl(var(--deck-ink-faint))]",children:s("chat.review.findings")}),e.jsx("span",{className:"font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:t.findings.length})]}),t.findings.length===0?e.jsx("div",{className:"rounded-lg bg-[hsl(var(--deck-surface-2))] px-3 py-2.5 text-[12px] text-[hsl(var(--deck-ink-muted))]",children:s("chat.review.noFindings")}):e.jsx("ol",{className:"space-y-2",children:t.findings.map((a,o)=>e.jsxs("li",{className:"rounded-lg border border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))] px-3 py-2.5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[e.jsx("h5",{className:"text-[12.5px] font-medium leading-5 text-[hsl(var(--deck-ink))]",children:a.title}),e.jsx("span",{className:"shrink-0 font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:s("chat.review.confidence",{value:a.confidenceScore.toFixed(2)})})]}),e.jsx("code",{className:"mt-1 block text-[10.5px] text-[hsl(var(--deck-accent))]",children:Xt(a)}),e.jsx("p",{className:"mt-1.5 whitespace-pre-wrap text-[12px] leading-5 text-[hsl(var(--deck-ink-muted))]",children:a.body})]},`${a.codeLocation.path}:${a.codeLocation.lineStart}:${o}`))})]}),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 es({elicitation:t,messageId:s}){const r=U(),a=p(g=>g.currentSessionRef),o=p(g=>g.setElicitation),[n,u]=h.useState(()=>ss(t.details.fields??[])),[x,v]=h.useState(()=>rs(t.details.fields??[])),[l,f]=h.useState(!1),[b,c]=h.useState(),j=t.details.fields??[],m=h.useMemo(()=>j.every(g=>{var d;if(!g.required)return!0;if(fe(g))return!!((d=x[g.name])!=null&&d.trim()||g.defaultValue!==void 0);const T=n[g.name]??g.defaultValue;return Array.isArray(T)?T.length>0:T!==void 0}),[j,x,n]);if(t.status!=="pending")return e.jsx("div",{className:"rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-3 py-2 font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:r(t.status==="cancelled"?"interaction.elicitation.cancelled":"interaction.elicitation.responded")});const w=async(g,T)=>{if(!L(p.getState())&&!(!a||l)){f(!0),c(void 0);try{await ee.respondToElicitation(a,t.toolCallId,{action:g,...T?{content:T}:{}}),o(s,{...t,status:"responded"})}catch(d){c(d instanceof Error?d.message:r("interaction.elicitation.failed"))}finally{f(!1)}}},i=async()=>{try{await w("accept",as(j,n,x))}catch(g){c(g instanceof Error?g.message:String(g))}},C=()=>{if(L(p.getState()))return;const g=t.details.url;if(!g){c("MCP URL is unavailable");return}if(!window.open(g,"_blank","noopener,noreferrer")){c("The browser blocked the external window");return}w("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(ct,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400"}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("div",{className:"font-mono text-[12px] font-semibold text-[hsl(var(--deck-ink))]",children:[r("interaction.elicitation.title")," · ",t.details.serverName]}),e.jsx("div",{className:"font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:t.details.message}),e.jsx("div",{className:"font-mono text-[11px] text-amber-700 dark:text-amber-300",children:r("interaction.elicitation.warning")})]})]}),t.details.mode==="url"?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] p-3 font-mono text-[11px]",children:[e.jsx("div",{className:"text-[hsl(var(--deck-ink-muted))]",children:t.details.domain}),e.jsx("div",{className:"mt-1 break-all text-[hsl(var(--deck-ink))]",children:t.details.url})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(se,{onClick:C,disabled:l,primary:!0,label:r("interaction.elicitation.open"),icon:e.jsx(Et,{className:"h-3.5 w-3.5"})}),e.jsx(se,{onClick:()=>void w("decline"),disabled:l,label:r("interaction.elicitation.decline")}),e.jsx(se,{onClick:()=>void w("cancel"),disabled:l,label:r("interaction.elicitation.cancel")})]})]}):e.jsxs("div",{className:"space-y-4",children:[j.map(g=>e.jsx(ts,{field:g,value:n[g.name],rawValue:x[g.name]??"",onValueChange:T=>u(d=>({...d,[g.name]:T})),onRawChange:T=>v(d=>({...d,[g.name]:T}))},g.name)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(se,{onClick:()=>void i(),disabled:l||!m,primary:!0,label:r("interaction.elicitation.submit"),icon:l?e.jsx(P,{className:"h-3.5 w-3.5 animate-spin"}):null}),e.jsx(se,{onClick:()=>void w("decline"),disabled:l,label:r("interaction.elicitation.decline")}),e.jsx(se,{onClick:()=>void w("cancel"),disabled:l,label:r("interaction.elicitation.cancel")})]})]}),b&&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:b})]})}function ts({field:t,value:s,rawValue:r,onValueChange:a,onRawChange:o}){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:ns(t).map(n=>{const u=Array.isArray(s)?s.includes(n.value):s===n.typedValue;return e.jsx("button",{type:"button","aria-pressed":u,onClick:()=>{if(t.type==="multi-select"){const x=Array.isArray(s)?s:[];a(x.includes(n.value)?x.filter(v=>v!==n.value):[...x,n.value])}else a(n.typedValue)},className:$("rounded-md border px-3 py-2 font-mono text-[12px] transition-colors",u?"border-emerald-500 bg-emerald-50 text-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-200":"border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] text-[hsl(var(--deck-ink-muted))] hover:text-[hsl(var(--deck-ink))]"),children:n.label},n.value)})}):e.jsx("input",{id:`mcp-elicitation-${t.name}`,type:is(t),value:r,onChange:n=>o(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 se({onClick:t,disabled:s,primary:r=!1,label:a,icon:o}){return e.jsxs("button",{type:"button",onClick:t,disabled:s,className:$("inline-flex min-h-8 items-center gap-1.5 rounded-md px-3 py-1.5 font-mono text-[12px] transition-colors disabled:cursor-wait disabled:opacity-50",r?"bg-amber-600 text-white hover:bg-amber-700":"border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] text-[hsl(var(--deck-ink-muted))] hover:text-[hsl(var(--deck-ink))]"),children:[o,a]})}function ss(t){return Object.fromEntries(t.filter(s=>!fe(s)&&s.defaultValue!==void 0).map(s=>[s.name,Array.isArray(s.defaultValue)?[...s.defaultValue]:s.defaultValue]))}function rs(t){return Object.fromEntries(t.filter(s=>fe(s)&&s.defaultValue!==void 0).map(s=>[s.name,String(s.defaultValue)]))}function as(t,s,r){var o;const a={};for(const n of t){if(fe(n)){const x=((o=r[n.name])==null?void 0:o.trim())??"";if(!x){if(n.defaultValue!==void 0)a[n.name]=n.defaultValue;else if(n.required)throw new Error(`${n.title} is required`);continue}if(n.type==="number"||n.type==="integer"){const v=Number(x);if(!Number.isFinite(v))throw new Error(`${n.title} must be a finite number`);if(n.type==="integer"&&!Number.isSafeInteger(v))throw new Error(`${n.title} must be a safe integer`);a[n.name]=v}else a[n.name]=x;continue}const u=s[n.name]??n.defaultValue;if(u===void 0){if(n.required)throw new Error(`${n.title} is required`);continue}if(Array.isArray(u)){if(n.minItems!==void 0&&u.length<n.minItems)throw new Error(`${n.title} requires at least ${n.minItems} choices`);if(n.maxItems!==void 0&&u.length>n.maxItems)throw new Error(`${n.title} allows at most ${n.maxItems} choices`)}a[n.name]=u}return a}function ns(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 fe(t){return t.type==="string"||t.type==="number"||t.type==="integer"}function is(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 os(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 ls({report:t}){const s=U(),[r,a]=h.useState(!1),o=JSON.stringify(t.output,null,2),n=async()=>{try{await navigator.clipboard.writeText(o),a(!0),window.setTimeout(()=>a(!1),1400)}catch{}};return e.jsxs("section",{"data-structured-output":!0,className:"overflow-hidden rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsxs("header",{className:"flex min-h-9 items-center justify-between gap-3 border-b border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(dt,{className:"h-3.5 w-3.5 shrink-0 text-[hsl(var(--deck-accent))]"}),e.jsx("span",{className:"font-mono text-[11px] font-semibold text-[hsl(var(--deck-ink))]",children:s("chat.structuredOutput.title")}),t.schemaDigest&&e.jsxs("span",{title:t.schemaDigest,className:"truncate font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:["sha256:",t.schemaDigest.slice(0,10)]})]}),e.jsx("button",{type:"button",onClick:n,"aria-label":s("chat.structuredOutput.copy"),title:s("chat.structuredOutput.copy"),className:"flex h-6 w-6 shrink-0 items-center justify-center rounded text-[hsl(var(--deck-ink-faint))] hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:r?e.jsx(pe,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}):e.jsx(Ze,{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:o})]})}const cs=h.lazy(()=>We(()=>import("./MarkdownRenderer-BMAuTkc6.js").then(t=>t.M),__vite__mapDeps([0,1,2,3,4,5,6])).then(t=>({default:t.MarkdownRenderer})));function $e({text:t,label:s}){const[r,a]=h.useState(!1);if(!t.trim())return null;const o=async()=>{try{await navigator.clipboard.writeText(t),a(!0),window.setTimeout(()=>a(!1),1400)}catch{}};return e.jsx("button",{type:"button","aria-label":s,title:s,onClick:o,className:"flex h-6 w-6 items-center justify-center rounded-md text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:r?e.jsx(pe,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}):e.jsx(Ze,{className:"h-3.5 w-3.5"})})}function ds(){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(ye,{size:20,pulse:!1})})}function us(){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 Ie(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 ms(t){if(typeof t=="string")return{text:Ie(t),images:[]};const s=t.filter(a=>a.type==="text").map(a=>a.text).join(`
48
- `),r=t.filter(a=>a.type==="image_url").map(a=>a.image_url.url);return{text:Ie(s),images:r}}function Me(t){return typeof t=="string"?t:t.filter(s=>s.type==="text").map(s=>s.text).join(`
49
- `)}function hs(t){const s=t.agentContent;return s?kt(s):Me(t.content)}function Be({content:t,syntaxHighlight:s=!0}){return e.jsx(h.Suspense,{fallback:e.jsx("pre",{className:"text-[14px] text-[hsl(var(--deck-ink))] font-mono whitespace-pre-wrap",children:t}),children:e.jsx(cs,{content:t,syntaxHighlight:s})})}function Ae({status:t}){if(!t)return null;const s={running:"bg-[#FEF3C7] text-[#92400E] dark:bg-[#F59E0B]/20 dark:text-[#FBBF24]",success:"bg-[#DCFCE7] text-[#15803D] dark:bg-[#22C55E]/20 dark:text-[#22C55E]",error:"bg-[#FEE2E2] text-[#b91c1c] dark:bg-[#EF4444]/20 dark:text-[#fca5a5]",pending:"bg-[#E5E7EB] text-[#6B7280] dark:bg-[#27272a] dark:text-[#a1a1aa]",info:"bg-[#DBEAFE] text-[#1D4ED8] dark:bg-[#3B82F6]/20 dark:text-[#60A5FA]"},r={running:"Running",success:"Success",error:"Error",pending:"Pending",info:"Info"};return e.jsx("span",{className:$("text-[11px] px-2 py-0.5 rounded-full font-mono",s[t]),children:r[t]})}function xs(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 _e=500;function st(t,s){if(t.length<=s)return t;let r=Math.max(0,s);return r>0&&/[\uD800-\uDBFF]/.test(t.charAt(r-1))&&(r-=1),t.slice(0,r)}function Pe(t,s){if(t.length<=s)return t;let r=Math.max(0,t.length-s);return/[\uDC00-\uDFFF]/.test(t.charAt(r))&&(r+=1),t.slice(r)}function ve(t,s){if(t.length<=s)return t;if(s<=0)return"";const r=`
50
- ... (display clipped) ...
51
- `,a=s-r.length;if(a<=0)return Pe(t,s);const o=Math.floor(a/3);return`${st(t,o)}${r}${Pe(t,a-o)}`}function ps(t){const s=t.split(`
52
- `),r=s.at(-1),a=r!=null&&r.startsWith("Output truncated")?r:void 0,o=a?s.slice(0,-1).join(`
53
- `):t,n=a?`
54
- ${a}`:"",u=Math.max(0,_e-n.length),v=o.indexOf(`
55
- stderr:
56
- `);let l;if(v>=0&&o.includes(`
57
- stdout:
58
- `)){const f=o.slice(0,v),b=o.slice(v+1),c=Math.max(0,u-1),j=Math.floor(c/2);l=`${ve(f,j)}
59
- ${ve(b,c-j)}`}else l=ve(o,u);return{body:st(l,u),...a?{notice:a}:{},truncated:!!a||t.length>_e}}function fs({tool:t}){const[s,r]=h.useState(!1),a=xs(t.arguments),o=t.output?ps(t.output):void 0;return e.jsxs("div",{"data-tool-name":t.toolName,"data-tool-status":t.status,"data-tool-truncated":o!=null&&o.truncated?"true":"false",className:"bg-white dark:bg-[#18181b] border border-[hsl(var(--deck-border))] rounded-lg overflow-hidden",children:[e.jsxs("button",{type:"button","aria-expanded":s,"data-tool-call-id":t.toolCallId,onClick:()=>r(n=>!n),className:"w-full flex items-center justify-between px-3 py-2 bg-[hsl(var(--deck-surface-2))] hover:bg-[hsl(var(--deck-surface))] transition-colors",children:[e.jsxs("div",{className:"flex gap-2 items-center min-w-0",children:[s?e.jsx(ce,{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(Ae,{status:t.status})]}),t.status==="running"&&t.progressMessage&&e.jsxs("div",{className:"border-t border-[hsl(var(--deck-border))] px-3 py-2 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 font-mono text-[10px] text-[hsl(var(--deck-ink-muted))]",children:[e.jsx("span",{className:"truncate",children:t.progressMessage}),t.progressTotal!==void 0&&t.progress!==void 0&&e.jsxs("span",{className:"shrink-0",children:[Math.max(0,Math.min(100,Math.round(t.progress/t.progressTotal*100))),"%"]})]}),t.progressTotal!==void 0&&t.progress!==void 0&&e.jsx("div",{role:"progressbar","aria-label":`${t.toolName} progress`,"aria-valuemin":0,"aria-valuemax":t.progressTotal,"aria-valuenow":Math.min(t.progress,t.progressTotal),className:"h-1 overflow-hidden rounded-full bg-[hsl(var(--deck-border))]",children:e.jsx("div",{className:"h-full rounded-full bg-amber-500 transition-[width] duration-150",style:{width:`${Math.max(0,Math.min(100,t.progress/t.progressTotal*100))}%`}})})]}),s&&e.jsxs("div",{className:"px-3 py-2 space-y-2 border-t border-[hsl(var(--deck-border))]",children:[a&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono",children:"Arguments"}),e.jsx("pre",{className:"text-[11px] text-[hsl(var(--deck-ink))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[120px] overflow-y-auto",children:a})]}),o&&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:[o.body,o.notice&&e.jsxs(e.Fragment,{children:[`
60
- `,e.jsx("span",{"data-tool-truncation-notice":!0,children:o.notice})]})]})]})]})]})}function rt({toolCalls:t}){return t.length===0?null:e.jsx("div",{className:"space-y-2",children:t.map(s=>e.jsx(fs,{tool:s},s.toolCallId))})}function bs({toolCalls:t,toolCallIds:s}){const r=U(),[a,o]=h.useState(!1),n=h.useMemo(()=>new Map(t.map(b=>[b.toolCallId,b])),[t]),u=s.flatMap(b=>{const c=n.get(b);return c?[c]:[]});if(u.length===0)return null;const x=u.filter(b=>b.status==="running").length,v=u.filter(b=>b.status==="error").length,l=[...u].reverse().find(b=>b.status==="running"&&!!b.progressMessage),f=x>0?r(u.length===1?"chat.timeline.tools.runningOne":"chat.timeline.tools.running",{count:u.length}):v>0?r(u.length===1?"chat.timeline.tools.completedOneWithError":"chat.timeline.tools.completedWithErrors",{count:u.length,errors:v}):r(u.length===1?"chat.timeline.tools.completedOne":"chat.timeline.tools.completed",{count:u.length});return e.jsxs("div",{"data-agent-tool-group":!0,className:"py-0.5",children:[e.jsxs("button",{type:"button","aria-expanded":a,onClick:()=>o(b=>!b),className:"group flex min-h-7 w-full items-center gap-1.5 rounded-md px-1.5 text-left font-mono text-[11.5px] text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-surface))]/65 hover:text-[hsl(var(--deck-ink-muted))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:[a?e.jsx(ce,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(ne,{className:"h-3.5 w-3.5 shrink-0"}),x>0&&e.jsx(P,{className:"h-3 w-3 shrink-0 animate-spin text-[hsl(var(--deck-accent))]"}),e.jsx("span",{children:f}),(l==null?void 0:l.progressMessage)&&e.jsxs("span",{className:"min-w-0 truncate text-[10.5px] text-[hsl(var(--deck-ink-muted))]",children:[l.progressMessage,l.progress!==void 0&&l.progressTotal!==void 0&&` · ${Math.max(0,Math.min(100,Math.round(l.progress/l.progressTotal*100)))}%`]})]}),(l==null?void 0:l.progress)!==void 0&&l.progressTotal!==void 0&&e.jsx("div",{role:"progressbar","aria-label":`${l.toolName} progress`,"aria-valuemin":0,"aria-valuemax":l.progressTotal,"aria-valuenow":Math.min(l.progress,l.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,l.progress/l.progressTotal*100))}%`}})}),a&&e.jsx("div",{"data-agent-tool-group-details":!0,className:"mt-2 space-y-2 pl-1",children:e.jsx(rt,{toolCalls:u})})]})}function vs({content:t}){const s=U(),[r,a]=h.useState(!1);return t?e.jsxs("div",{"data-agent-thinking":!0,className:"py-0.5",children:[e.jsxs("button",{type:"button","aria-expanded":r,onClick:()=>a(o=>!o),className:"flex min-h-7 w-full items-center gap-1.5 rounded-md px-1.5 text-left font-mono text-[11.5px] text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-surface))]/65 hover:text-[hsl(var(--deck-ink-muted))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:[r?e.jsx(ce,{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")})]}),r&&e.jsx("div",{className:"ml-1 mt-1 border-l border-[hsl(var(--deck-border))] py-1 pl-3",children:e.jsx("pre",{className:"whitespace-pre-wrap font-mono text-[11px] leading-5 text-[hsl(var(--deck-ink-muted))]",children:t})})]}):null}function gs({tasks:t}){if(t.length===0)return null;const s=t.filter(a=>a.status==="completed").length,r=s===t.length;return e.jsx("div",{className:"bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-lg px-3 py-2",children:e.jsx("div",{className:"flex gap-2 items-center",children:e.jsx("span",{className:"text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:r?"✓ All tasks done":`Tasks: ${s}/${t.length}`})})})}function ks({toolCalls:t}){const s=Ee(n=>n.openFilePreview),r=p(n=>ae(n.historySurfaceSelection)),a=h.useMemo(()=>{const n=new Map,u=["Write","SearchReplace","Edit","ApplyPatch"];for(const x of t){if(x.status!=="success")continue;const v=x.metadata;if(x.toolName==="ApplyPatch"&&Array.isArray(v==null?void 0:v.changes)){for(const f of v.changes)f&&typeof f=="object"&&"path"in f&&typeof f.path=="string"&&n.set(f.path,{path:f.path,toolName:x.toolName});continue}const l=v==null?void 0:v.file_path;l&&u.includes(x.toolName)&&n.set(l,{path:l,toolName:x.toolName})}return Array.from(n.values())},[t]);if(r||a.length===0)return null;const o=n=>{L(p.getState())||s({tab:"diff",targetPath:n})};return e.jsxs("div",{className:"bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-lg px-3 py-2",children:[e.jsxs("div",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono mb-1.5",children:["Changed files (",a.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:a.map(({path:n})=>{const u=n.split("/").pop()||n;return e.jsxs("button",{onClick:()=>o(n),className:"flex items-center gap-1 px-2 py-1 text-[11px] font-mono bg-[#E5E7EB] dark:bg-[#27272a] text-[hsl(var(--deck-ink))] rounded hover:bg-[#D1D5DB] dark:hover:bg-[#3f3f46] transition-colors",title:n,children:[e.jsx(ut,{className:"w-3 h-3"}),u]},n)})})]})}function js({subagent:t}){var Y,G,X,W;const s=U(),[r,a]=h.useState(null),[o,n]=h.useState(!1),[u,x]=h.useState(null),[v,l]=h.useState(!1),[f,b]=h.useState(""),[c,j]=h.useState(!1),[m,w]=h.useState(null),[i,C]=h.useState(null),[g,T]=h.useState(null),d=p(F=>F.currentSessionRef),E=p(F=>F.isStreaming),S=p(F=>F.isTemporarySession),D=p(F=>ae(F.historySurfaceSelection));if(!t)return null;const k=t.status==="running",I=r!==null?r:k,z=t.toolCalls||u||[],N=t.output||t.thinking||z.length>0||t.sessionId,M=i&&i.status!=="running"?i:g,R=(M==null?void 0:M.id)??t.sessionId,B=((Y=M==null?void 0:M.restartRecovery)==null?void 0:Y.outcome)==="failed",H=!k&&!E&&!S&&!D&&!B&&(i==null?void 0:i.status)!=="running"&&!!(R&&d);h.useEffect(()=>{if(D||!I||k||!t.sessionId||!(d!=null&&d.projectPath)||u!==null||t.toolCalls&&t.toolCalls.length>0)return;let F=!0;return n(!0),ee.getMessages({sessionId:t.sessionId,projectPath:d.projectPath}).then(Q=>{var V,A;if(!F)return;const q=wt(Q),K=new Map;for(const O of q)if((A=(V=O.agentContent)==null?void 0:V.toolCalls)!=null&&A.length)for(const y of O.agentContent.toolCalls)K.has(y.toolCallId)||K.set(y.toolCallId,y);x(Array.from(K.values()))}).finally(()=>{F&&n(!1)}),()=>{F=!1}},[I,D,k,t.sessionId,t.toolCalls,u,d==null?void 0:d.projectPath]),h.useEffect(()=>{if(D||!t.sessionId||!d)return;let F=!0;const Q=t.rootAgentId??t.sessionId,q=t.resumeDepth??0;return ee.listSubagents(d).then(K=>{if(!F)return;T(K.find(A=>A.id===t.sessionId)??null);const V=K.filter(A=>A.id!==t.sessionId&&A.rootAgentId===Q&&A.resumeDepth>q).sort((A,O)=>O.resumeDepth-A.resumeDepth||O.lastActiveAt-A.lastActiveAt)[0];V&&C(V)}).catch(()=>{}),()=>{F=!1}},[d==null?void 0:d.sessionId,d==null?void 0:d.projectPath,D,t.sessionId,t.rootAgentId,t.resumeDepth]),h.useEffect(()=>{if(D||!i||i.status!=="running"||!d)return;let F=!0;const Q=async()=>{try{const V=(await ee.listSubagents(d)).find(A=>A.id===i.id);F&&V&&C(V)}catch{}},q=window.setInterval(()=>{Q()},1e3);return()=>{F=!1,window.clearInterval(q)}},[d,D,i==null?void 0:i.id,i==null?void 0:i.status]);const te=async()=>{if(!L(p.getState())&&!(!d||!R||!f.trim()||c)){j(!0),w(null);try{const F=await ee.resumeSubagent(d,R,f.trim());C(F.session),b(""),l(!1),a(!0)}catch(F){w(F instanceof Error?F.message:s("chat.subagent.resumeFailed"))}finally{j(!1)}}};return e.jsxs("div",{"data-subagent-id":t.id,"data-subagent-session-id":t.sessionId,className:"bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-lg px-3 py-2",children:[e.jsxs("button",{type:"button",onClick:()=>a(!I),className:"flex gap-2 justify-between items-center w-full transition-opacity cursor-pointer hover:opacity-80",children:[e.jsxs("div",{className:"flex gap-2 items-center",children:[k&&e.jsx(P,{className:"h-3 w-3 animate-spin text-[hsl(var(--deck-ink-muted))]"}),e.jsxs("span",{className:"text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:[t.type,": ",t.description]}),e.jsx(Ae,{status:t.status==="completed"?"success":t.status==="failed"?"error":"running"}),t.type==="verification"&&t.verificationVerdict&&e.jsx("span",{"data-verification-verdict":t.verificationVerdict,className:$("rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide",t.verificationVerdict==="pass"?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":t.verificationVerdict==="fail"?"bg-red-500/10 text-red-600 dark:text-red-400":"bg-amber-500/10 text-amber-600 dark:text-amber-400"),children:t.verificationVerdict}),t.resumedFrom&&e.jsx("span",{className:"rounded bg-[#EDE9FE] px-1.5 py-0.5 text-[10px] font-mono text-[#6D28D9] dark:bg-[#2E1065] dark:text-[#C4B5FD]",title:s("chat.subagent.resumedFromTitle",{id:t.resumedFrom}),children:s("chat.subagent.resumedDepth",{depth:t.resumeDepth??1})})]}),N&&e.jsx(ce,{className:$("h-3.5 w-3.5 text-[hsl(var(--deck-ink-muted))] transition-transform",I&&"rotate-180")})]}),!I&&!k&&t.output&&e.jsx("div",{"data-subagent-output-summary":!0,className:"mt-2 max-h-10 overflow-hidden whitespace-pre-wrap break-words font-mono text-[11px] text-[hsl(var(--deck-ink))]",children:t.output}),I&&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})]}),o&&e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono",children:[e.jsx(P,{className:"w-3 h-3 animate-spin"}),s("chat.subagent.loadingLogs")]}),!o&&z.length>0&&e.jsx(rt,{toolCalls:z}),i&&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:i.id,status:i.status,depth:i.resumeDepth??1})}),(((G=i.result)==null?void 0:G.message)||((X=i.result)==null?void 0:X.error))&&e.jsx("div",{className:"mt-1 whitespace-pre-wrap text-[hsl(var(--deck-ink))]",children:i.result.message||i.result.error})]}),B&&((W=M==null?void 0:M.result)==null?void 0:W.error)&&e.jsx("div",{role:"alert",className:"text-[11px] text-red-600",children:M.result.error}),H&&e.jsxs("div",{className:"space-y-2",children:[v?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:f,onChange:F=>b(F.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:()=>{l(!1),w(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 te(),disabled:!f.trim()||c,className:"flex items-center gap-1 rounded bg-[#7C3AED] px-2 py-1 text-[11px] font-medium text-white disabled:opacity-50",children:[c&&e.jsx(P,{className:"w-3 h-3 animate-spin"}),s("chat.subagent.resumeAgent")]})]})]}):e.jsxs("button",{type:"button","aria-label":s("chat.subagent.resumeAria"),onClick:()=>l(!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(me,{className:"w-3 h-3"}),s("chat.subagent.resume")]}),m&&e.jsx("div",{role:"alert",className:"text-[11px] text-red-600",children:m})]})]})]})}function ys({confirmation:t,messageId:s}){const r=U(),[a,o]=h.useState(!1),[n,u]=h.useState(null),x=p(f=>f.currentSessionRef),v=p(f=>f.setConfirmation);if(!t)return null;const l=async(f,b)=>{if(!L(p.getState())&&!(!x||a)){o(!0),u(null);try{await ee.respondPermission(x,t.toolCallId,{approved:f,scope:b}),v(s,{...t,status:f?"approved":"denied"})}catch(c){u(c instanceof Error?c.message:r("interaction.permission.failed"))}finally{o(!1)}}};return t.status!=="pending"?null:e.jsxs("div",{"data-pending-interaction":"permission",tabIndex:-1,role:"alert",className:"space-y-3 rounded-lg border border-amber-300/70 bg-amber-50/70 p-4 outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-800/70 dark:bg-amber-950/25",children:[e.jsx("div",{className:"text-[13px] text-[hsl(var(--deck-ink))] font-mono",children:r("interaction.permission.title",{tool:t.toolName})}),e.jsx("div",{className:"text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:t.description}),t.diff&&e.jsx("pre",{className:"text-[11px] text-[hsl(var(--deck-ink))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[200px] overflow-y-auto",children:t.diff}),n&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-300/70 bg-red-50 px-2.5 py-2 font-mono text-[11px] text-red-700 dark:border-red-900/70 dark:bg-red-950/35 dark:text-red-300",children:n}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:()=>void l(!0,"once"),disabled:a,className:"min-h-8 px-3 py-1.5 text-[12px] font-mono bg-[#22C55E] text-white rounded-md hover:bg-[#16A34A] disabled:cursor-wait disabled:opacity-50",children:a?e.jsx(P,{className:"h-3.5 w-3.5 animate-spin"}):r("interaction.permission.once")}),t.allowRemember!==!1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>void l(!0,"session"),disabled:a,className:"min-h-8 px-3 py-1.5 text-[12px] font-mono bg-[#3B82F6] text-white rounded-md hover:bg-[#2563EB] disabled:cursor-wait disabled:opacity-50",children:r("interaction.permission.session")}),e.jsx("button",{type:"button",onClick:()=>void l(!0,"project"),disabled:a,className:"min-h-8 px-3 py-1.5 text-[12px] font-mono bg-[#6366F1] text-white rounded-md hover:bg-[#4F46E5] disabled:cursor-wait disabled:opacity-50",children:r("interaction.permission.project")})]}),e.jsx("button",{type:"button",onClick:()=>void l(!1),disabled:a,className:"min-h-8 px-3 py-1.5 text-[12px] font-mono bg-[#EF4444] text-white rounded-md hover:bg-[#DC2626] disabled:cursor-wait disabled:opacity-50",children:r("interaction.permission.deny")})]})]})}function ws({question:t,messageId:s}){const r=U(),[a,o]=h.useState({}),[n,u]=h.useState({}),[x,v]=h.useState(!1),[l,f]=h.useState(null),b=p(i=>i.currentSessionRef),c=p(i=>i.setQuestion),j=h.useMemo(()=>t?t.questions.reduce((i,C)=>{var E;const g=(E=n[C.header])==null?void 0:E.trim(),T=a[C.header];if(C.multiSelect){const S=Array.isArray(T)?[...T]:[];return g&&S.push(g),S.length>0&&(i[C.header]=S),i}const d=g||(typeof T=="string"?T:"");return d&&(i[C.header]=d),i},{}):{},[a,n,t]),m=(t==null?void 0:t.questions.every(i=>i.header in j))??!1;if(!t)return null;const w=async()=>{if(!L(p.getState())&&!(!b||x||!m)){v(!0),f(null);try{await ee.respondToQuestion(b,t.toolCallId,j),c(s,{...t,status:"answered",answers:j})}catch(i){f(i instanceof Error?i.message:r("interaction.question.failed"))}finally{v(!1)}}};return t.status!=="pending"?e.jsx("div",{className:"bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-lg px-3 py-2",children:e.jsx("div",{className:"text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:r("interaction.question.answered")})}):e.jsxs("div",{"data-pending-interaction":"question",tabIndex:-1,role:"alert",className:"space-y-4 rounded-lg border border-amber-300/70 bg-amber-50/70 p-4 outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-800/70 dark:bg-amber-950/25",children:[t.questions.map((i,C)=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-[13px] text-[hsl(var(--deck-ink))] font-mono",children:i.question}),e.jsxs("div",{className:"space-y-1",children:[i.options.map((g,T)=>e.jsxs("button",{type:"button",onClick:()=>{if(i.multiSelect){const d=a[i.header]||[],E=d.includes(g.label)?d.filter(S=>S!==g.label):[...d,g.label];o({...a,[i.header]:E})}else o({...a,[i.header]:g.label}),u({...n,[i.header]:""})},className:$("w-full text-left px-3 py-2 rounded-md border text-[12px] font-mono transition-colors","border-[hsl(var(--deck-border))]",(i.multiSelect?(a[i.header]||[]).includes(g.label):a[i.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})]},T)),e.jsx("input",{"aria-label":`${i.header} other response`,value:n[i.header]??"",onChange:g=>u({...n,[i.header]:g.target.value}),placeholder:r("interaction.question.other"),className:"w-full rounded-md border border-[#E5E7EB] bg-white px-3 py-2 text-[12px] text-[#111827] outline-none focus:border-[#22C55E] dark:border-[#27272a] dark:bg-[#111113] dark:text-[#E5E5E5]"})]})]},C)),l&&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:l}),e.jsxs("button",{type:"button",onClick:()=>void w(),disabled:x||!m,className:"inline-flex min-h-8 items-center gap-1.5 px-3 py-1.5 text-[12px] font-mono bg-[#22C55E] text-white rounded-md hover:bg-[#16A34A] disabled:cursor-wait disabled:opacity-50",children:[x&&e.jsx(P,{className:"h-3.5 w-3.5 animate-spin"}),r("interaction.question.submit")]})]})}function Ns({message:t}){const s=t.agentContent,r=p(m=>m.isStreaming&&m.currentAssistantMessageId===t.id);if(!s){const m=Me(t.content);return m?e.jsx(Be,{content:m}):null}const{toolCalls:a,tasks:o,confirmation:n,question:u,elicitation:x}=s,v=jt(s),l=yt(s);if(!(l.length>0||o.length>0||v.length>0||n||u||x)&&r)return e.jsxs("div",{className:"flex items-center gap-2 text-[hsl(var(--deck-ink-muted))]",children:[e.jsx(P,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{className:"text-[12px] font-mono",children:"Thinking..."})]});const c=a.length>0&&a.every(m=>m.status==="success"||m.status==="error")&&!r,j=!r;return e.jsxs("div",{className:"space-y-3",children:[l.map(m=>m.type==="thinking"?e.jsx("div",{"data-agent-timeline-block":"thinking",children:e.jsx(vs,{content:m.content})},m.id):m.type==="text"?e.jsx("div",{"data-agent-timeline-block":"text",children:e.jsx(Be,{content:m.content,syntaxHighlight:j})},m.id):e.jsx("div",{"data-agent-timeline-block":"tool_group",children:e.jsx(bs,{toolCalls:a,toolCallIds:m.toolCallIds})},m.id)),o.length>0&&e.jsx(gs,{tasks:o}),v.map(m=>e.jsx(js,{subagent:m},m.id)),n&&e.jsx(ys,{confirmation:n,messageId:t.id}),u&&e.jsx(ws,{question:u,messageId:t.id}),x&&e.jsx(es,{elicitation:x,messageId:t.id}),c&&e.jsx(ks,{toolCalls:a})]})}function Ss({message:t,showAvatar:s=!0}){var x,v,l,f;const r=t.role==="user";if(t.role==="system"){const b=Me(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:b})})}if(r){const b=(x=t.metadata)!=null&&x.userShellCommand&&typeof t.metadata.userShellCommand=="object"?t.metadata.userShellCommand:(v=t.metadata)!=null&&v.userShellExecution&&typeof t.metadata.userShellExecution=="object"?t.metadata.userShellExecution:void 0;if(b){const m=typeof b.command=="string"?b.command:"",w=b.status==="running"?"running":b.status==="completed"?"success":"error",i=typeof b.output=="string"?b.output:[typeof b.stdout=="string"?b.stdout:"",typeof b.stderr=="string"&&b.stderr?`stderr:
61
- ${b.stderr}`:""].filter(Boolean).join(`
62
- `);return e.jsx("div",{"data-chat-message-id":t.id,"data-chat-role":"user","data-user-shell-command":!0,className:"flex w-full justify-end p-4",children:e.jsxs("div",{className:"w-full max-w-[85%] overflow-hidden rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-3 py-2",children:[e.jsxs("div",{className:"min-w-0 truncate font-mono text-[12px] text-[hsl(var(--deck-ink))]",children:[e.jsx("span",{className:"mr-2 text-amber-600 dark:text-amber-400",children:"$"}),m]}),e.jsx(Ae,{status:w})]}),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:i||"(no output)"}),typeof b.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 ",b.exitCode,typeof b.durationMs=="number"?` · ${(b.durationMs/1e3).toFixed(3)}s`:"",b.truncated===!0?" · truncated":""]})]})})}const{text:c,images:j}=ms(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($e,{text:c,label:"Copy message"})}),e.jsxs("div",{className:"bg-[hsl(var(--deck-surface-2))] rounded-lg px-4 py-3 max-w-[85%]",children:[c&&e.jsx("p",{className:"text-[14px] text-[hsl(var(--deck-ink))] font-mono leading-relaxed whitespace-pre-wrap",children:c}),j.length>0&&e.jsx("div",{className:$("grid gap-2",j.length===1?"grid-cols-1 mt-0":"grid-cols-2 mt-3"),children:j.map((m,w)=>e.jsx("img",{src:m,alt:`attachment-${w+1}`,className:"object-cover w-full max-h-64 rounded-md"},`${m}-${w}`))})]}),e.jsx(us,{})]})}const o=hs(t),n=Yt((l=t.metadata)==null?void 0:l.codeReview),u=os((f=t.metadata)==null?void 0:f.structuredOutput);return e.jsxs("div",{"data-chat-message-id":t.id,"data-chat-role":"assistant",className:$("group flex gap-4 justify-start w-full",s?"p-4":"px-4 pt-0 pb-3"),children:[s?e.jsx(ds,{}):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}):u?e.jsx(ls,{report:u}):e.jsx(Ns,{message:t}),!u&&o.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($e,{text:o,label:"Copy response"})})]})]})}const Cs=h.memo(Ss);function Es(t,s,r){return Math.max(0,t+(r-s))}function Ts(t,s,r){return Math.min(s,Math.max(0,t)+Math.max(0,r))}function Ms(t,s,r,a){const o=new Map(t.filter(u=>!!u.id).map(u=>[u.id,u])),n=new Set(r);for(const u of s){if(!u.id)continue;const x=o.get(u.id);x!==u&&(!x||!a||a(x)!==a(u))&&n.add(u.id)}return n}function Ue(t,s){return t?t.querySelector(`[data-chat-message-id="${CSS.escape(s)}"]`):null}function As({turns:t,viewportRef:s,containerRef:r,onRevealTurn:a}){const o=U(),[n,u]=h.useState(null),[x,v]=h.useState(!1),l=h.useRef(null),f=h.useCallback(()=>{var i;const c=s.current,j=r.current;if(!c||!j||t.length===0)return;const m=c.getBoundingClientRect().top;let w=((i=t[0])==null?void 0:i.id)??null;for(const C of t){const g=Ue(j,C.id);if(g)if(g.getBoundingClientRect().top-m<=24)w=C.id;else break}u(w)},[t,s,r]);h.useEffect(()=>{const c=s.current;if(!c)return;const j=()=>{l.current===null&&(l.current=window.requestAnimationFrame(()=>{l.current=null,f()}))};return f(),c.addEventListener("scroll",j,{passive:!0}),()=>{c.removeEventListener("scroll",j),l.current!==null&&(window.cancelAnimationFrame(l.current),l.current=null)}},[f,s]);const b=h.useCallback(c=>{const j=()=>{const w=Ue(r.current,c.id);w&&(w.scrollIntoView({behavior:"smooth",block:"start"}),u(c.id))};a(c.index)?j():window.requestAnimationFrame(()=>window.requestAnimationFrame(j))},[r,a]);return t.length<2?null:e.jsx("nav",{"aria-label":o("chat.turns.aria"),className:"absolute right-1 top-1/2 z-20 hidden -translate-y-1/2 sm:block",onMouseEnter:()=>v(!0),onMouseLeave:()=>v(!1),onFocusCapture:()=>v(!0),onBlurCapture:c=>{c.currentTarget.contains(c.relatedTarget)||v(!1)},children:e.jsxs("div",{className:"relative flex items-center justify-end",children:[e.jsx("ul",{className:$("flex flex-col items-center gap-2 py-2 transition-opacity",x?"opacity-0":"opacity-100"),"aria-hidden":x,children:t.map(c=>e.jsx("li",{children:e.jsx("span",{className:$("block rounded-full transition-all",c.id===n?"h-2 w-2 bg-[hsl(var(--deck-accent))]":"h-1.5 w-1.5 bg-[hsl(var(--deck-ink-faint))]/40")})},c.id))}),e.jsx("div",{className:$("absolute right-0 max-h-[min(70vh,520px)] w-[280px] overflow-y-auto rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]/95 p-1 shadow-xl backdrop-blur transition-all",x?"pointer-events-auto translate-x-0 opacity-100":"pointer-events-none translate-x-2 opacity-0"),children:t.map((c,j)=>e.jsxs("button",{type:"button",onClick:()=>b(c),className:$("flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left transition-colors",c.id===n?"bg-[hsl(var(--deck-hairline))]/70 text-[hsl(var(--deck-ink))]":"text-[hsl(var(--deck-ink-muted))] hover:bg-[hsl(var(--deck-hairline))]/50 hover:text-[hsl(var(--deck-ink))]"),children:[e.jsx("span",{className:$("mt-1 h-1.5 w-1.5 shrink-0 rounded-full",c.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:o("chat.turns.label",{n:j+1})}),e.jsx("span",{className:"line-clamp-2 text-[12px] leading-4",children:c.preview})]})]},c.id))})]})})}const Le=80;function Fs(t){return typeof t=="string"?t:Array.isArray(t)?t.filter(s=>s.type==="text").map(s=>s.text).join(" "):""}function Rs(t){const s=Fs(t).replace(/\s+/g," ").trim();return s?s.length>Le?`${s.slice(0,Le-1)}…`:s:""}function Ds(t){const s=[];for(let r=0;r<t.length;r+=1){const a=t[r];if(a.role!=="user"||!a.id)continue;const o=Rs(a.content);o&&s.push({id:a.id,index:r,preview:o})}return s}const ge=120,ke=80,$s=96;function ie(t){return(t==null?void 0:t.querySelector("[data-radix-scroll-area-viewport]"))??null}function Is(t){return JSON.stringify([t.role,t.content,t.metadata,t.agentContent])}function Bs({messages:t,isLoading:s}){const r=U(),a=h.useRef(null),o=h.useRef(null),n=h.useRef(!0),u=h.useRef(!1),x=h.useRef(t),v=h.useRef(t),l=h.useRef(new Set),f=h.useRef(t.length),b=h.useRef(null),[c,j]=h.useState(ge),[m,w]=h.useState(!1),[i,C]=h.useState(0),g=t.length>0;x.current=t,h.useEffect(()=>{const N=ie(a.current);if(!N||u.current&&!n.current)return;const M=window.requestAnimationFrame(()=>{N.scrollTop=N.scrollHeight,u.current=!0,n.current=!0,l.current=new Set,C(0),w(!1)});return()=>window.cancelAnimationFrame(M)},[t]),h.useEffect(()=>{const N=ie(a.current);if(!N)return;o.current=N;const M=()=>{if(!u.current)return;const B=N.scrollHeight-N.scrollTop-N.clientHeight<=$s,H=n.current;n.current=B,w(!B),B?(l.current=new Set,C(0)):H&&(v.current=x.current,l.current=new Set,C(0))};return M(),N.addEventListener("scroll",M,{passive:!0}),()=>N.removeEventListener("scroll",M)},[g,s]),h.useEffect(()=>{const N=v.current;if(v.current=t,n.current){l.current.size>0&&(l.current=new Set,C(0));return}const M=Ms(N,t,l.current,Is);l.current=M,C(M.size)},[t]),h.useEffect(()=>{const N=f.current;f.current=t.length,j(M=>M>=N&&t.length>N?t.length:Math.min(Math.max(M,ge),t.length||ge))},[t.length]);const T=Math.max(t.length-c,0),d=T,E=h.useMemo(()=>t.slice(d),[t,d]),S=h.useMemo(()=>Ds(t),[t]);if(h.useLayoutEffect(()=>{var R;const N=b.current;if(!N)return;const M=ie(a.current);if(b.current=null,!!M){if((R=N.element)!=null&&R.isConnected){const B=N.element.getBoundingClientRect().top-N.viewportTop;M.scrollTop+=B;return}M.scrollTop=Es(N.scrollTop,N.scrollHeight,M.scrollHeight)}},[c]),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(ye,{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(mt,{className:"w-3 h-3"}),r("chat.list.loading.eyebrow")]}),e.jsx("h2",{className:"mt-2 text-[15px] font-medium text-[hsl(var(--deck-ink))]",children:r("chat.list.loading.title")}),e.jsx("p",{className:"mt-1 max-w-sm text-[11.5px] leading-5 text-[hsl(var(--deck-ink-faint))]",children:r("chat.list.loading.hint")})]}),e.jsx("div",{"aria-hidden":"true",className:"mt-7 space-y-4 rounded-xl border border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-surface))]/45 px-4 py-5",children:[72,88,64].map((N,M)=>e.jsxs("div",{className:$("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:`${N}%`,animationDelay:`${M*120}ms`}})]},N))})]})});if(t.length===0&&!s)return e.jsx("div",{className:"flex flex-1 justify-center items-center",children:e.jsxs("div",{className:"flex flex-col gap-4 items-center text-center",children:[e.jsx(ye,{size:44}),e.jsxs("div",{children:[e.jsx("div",{className:"deck-eyebrow text-[hsl(var(--deck-accent))]",children:r("chat.list.empty.eyebrow")}),e.jsx("div",{className:"mt-2 text-[15px] font-medium text-[hsl(var(--deck-ink))]",children:r("chat.list.empty.title")}),e.jsx("div",{className:"mt-1 max-w-xs text-[12px] text-[hsl(var(--deck-ink-muted))]",children:r("chat.list.empty.hint")})]})]})});const D=()=>{const N=ie(a.current);N&&(N.scrollTop=N.scrollHeight,n.current=!0,u.current=!0,l.current=new Set,C(0),w(!1))},k=()=>{var M;const N=ie(a.current);if(N){const R=((M=a.current)==null?void 0:M.querySelector("[data-chat-message-id]"))??null;b.current={element:R,viewportTop:(R==null?void 0:R.getBoundingClientRect().top)??0,scrollHeight:N.scrollHeight,scrollTop:N.scrollTop}}j(R=>Ts(R,t.length,ke))},I=N=>N>=d?!0:(j(t.length),!1),z=i===1?r("chat.list.unreadMessage"):r("chat.list.unreadMessages",{count:i});return e.jsxs("div",{ref:a,className:"relative flex-1 min-h-0",children:[e.jsx(Tt,{className:"h-full",children:e.jsxs("div",{className:"flex flex-col px-4 pb-4 w-full md:px-6",children:[T>0&&e.jsx("div",{className:"flex justify-center py-3",children:e.jsx("button",{type:"button",onClick:k,"aria-label":r("chat.list.showEarlierWithRemaining",{count:Math.min(T,ke),remaining:T}),className:"rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-3 py-1.5 font-mono text-[12px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:border-[hsl(var(--deck-border-strong))] hover:text-[hsl(var(--deck-ink))]",children:r("chat.list.showEarlier",{count:Math.min(T,ke)})})}),E.map((N,M)=>{const R=d+M,B=R>0?t[R-1]:null,H=!B||B.role!==N.role||B.role==="user";return e.jsx(Cs,{message:N,showAvatar:H},N.id||`msg-${R}`)})]})}),e.jsx(As,{turns:S,viewportRef:o,containerRef:a,onRevealTurn:I}),m&&e.jsxs("button",{type:"button",onClick:D,"aria-live":"polite","aria-label":i>0?z:r("chat.list.jumpLatest"),className:"absolute bottom-4 left-1/2 z-10 inline-flex -translate-x-1/2 items-center gap-1.5 rounded-full border border-[hsl(var(--deck-border-strong))] bg-[hsl(var(--deck-surface))]/95 px-3 py-1.5 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] shadow-lg backdrop-blur transition-colors hover:text-[hsl(var(--deck-ink))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:[e.jsx(Te,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}),i>0?z:r("chat.list.jumpLatest")]})]})}const at=h.memo(Bs);function _s({queue:t,mutation:s,onMutate:r,onRefresh:a}){const o=U(),[n,u]=h.useState(!1),x=h.useRef(null),v=h.useRef(null),l=h.useRef(null);h.useLayoutEffect(()=>{var m,w,i;if(s.pending||!x.current)return;const c=x.current;x.current=null,(i=Array.from(((m=v.current)==null?void 0:m.querySelectorAll("[data-follow-up-focus-id]"))??[]).find(C=>C.dataset.followUpFocusId===c)??((w=v.current)==null?void 0:w.querySelector("button")))==null||i.focus()},[s.pending,t==null?void 0:t.version]);const f=h.useCallback(async c=>{x.current=c.messageId,await r(c)},[r]),b=h.useCallback((c,j)=>{f({type:"move",messageId:c,toPosition:j})},[f]);return!t||t.pending===0&&!s.errorMessage?null:e.jsxs("section",{ref:v,"data-blade-follow-up-queue":!0,className:"mx-4 mb-2 overflow-hidden rounded-lg border border-amber-300/70 bg-amber-50/70 shadow-sm dark:border-amber-900/60 dark:bg-amber-950/25 md:mx-6","aria-label":o("chat.followUpQueue.title"),children:[e.jsxs("button",{type:"button","aria-label":o(n?"chat.followUpQueue.hide":"chat.followUpQueue.show"),"aria-expanded":n,onClick:()=>u(c=>!c),className:"flex min-h-10 w-full items-center gap-2 px-3 text-left font-mono text-[11px] text-amber-950 transition-colors hover:bg-amber-100/70 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-amber-500 dark:text-amber-100 dark:hover:bg-amber-900/35",children:[e.jsx(Lt,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"font-semibold",children:o("chat.followUpQueue.count",{count:t.pending})}),t.locked>0&&e.jsx("span",{className:"text-amber-700/80 dark:text-amber-300/75",children:o("chat.followUpQueue.lockedCount",{count:t.locked})}),e.jsx(ne,{className:`ml-auto h-3.5 w-3.5 transition-transform ${n?"rotate-90":""}`,"aria-hidden":!0})]}),n&&e.jsxs("div",{className:"border-t border-amber-300/60 px-2 py-2 dark:border-amber-900/50",children:[s.errorMessage&&e.jsxs("div",{role:"alert",className:"mb-2 flex items-center gap-2 rounded-md border border-red-200 bg-red-50 px-2.5 py-2 text-[11px] text-red-700 dark:border-red-900/60 dark:bg-red-950/35 dark:text-red-300",children:[e.jsx("span",{className:"min-w-0 flex-1",children:s.errorCode==="revision_conflict"?o("chat.followUpQueue.stale"):s.errorMessage}),a&&e.jsx("button",{type:"button","aria-label":o("chat.followUpQueue.refresh"),onClick:()=>void a(),className:"rounded p-1 hover:bg-red-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-red-500 dark:hover:bg-red-900/60",children:e.jsx(Je,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx("ol",{className:"space-y-1.5",children:t.items.map((c,j)=>{const m=t.items[j-1],w=t.items[j+1],i=c.mutable&&(m==null?void 0:m.mutable)===!0,C=c.mutable&&(w==null?void 0:w.mutable)===!0,g=s.pending;return e.jsxs("li",{"data-follow-up-id":c.id,"data-follow-up-state":c.state,"data-follow-up-focus-id":c.id,tabIndex:-1,draggable:c.mutable&&!s.pending,onDragStart:()=>{l.current=c.mutable?c.id:null},onDragOver:T=>{const d=l.current,E=t.items.find(S=>S.id===d);E!=null&&E.mutable&&c.mutable&&T.preventDefault()},onDrop:T=>{T.preventDefault();const d=l.current;l.current=null;const E=t.items.find(k=>k.id===d);if(!(E!=null&&E.mutable)||!c.mutable||E.id===c.id)return;const S=Math.min(E.position,c.position),D=Math.max(E.position,c.position);t.items.slice(S,D+1).some(k=>!k.mutable)||b(E.id,c.position)},onDragEnd:()=>{l.current=null},className:"flex min-w-0 items-center gap-2 rounded-md border border-amber-200/70 bg-white/75 px-2.5 py-2 dark:border-amber-900/50 dark:bg-zinc-950/45",children:[e.jsx("span",{className:"w-5 shrink-0 text-center font-mono text-[10px] text-amber-700 dark:text-amber-400",children:j+1}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-xs text-[hsl(var(--deck-ink))]",children:c.kind==="internal"?o("chat.followUpQueue.internal"):c.preview||o("chat.followUpQueue.attachmentOnly")}),e.jsxs("div",{className:"mt-0.5 flex items-center gap-2 font-mono text-[9px] uppercase tracking-[0.08em] text-[hsl(var(--deck-ink-faint))]",children:[e.jsx("span",{children:o(`chat.followUpQueue.delivery.${c.delivery}`)}),!c.mutable&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Ot,{className:"h-2.5 w-2.5","aria-hidden":!0}),o("chat.followUpQueue.locked")]}),c.attachmentCount>0&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(ht,{className:"h-2.5 w-2.5","aria-hidden":!0}),c.attachmentCount]})]})]}),g&&s.messageId===c.id?e.jsx(P,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-amber-600"}):e.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[e.jsx("button",{type:"button","aria-label":o("chat.followUpQueue.moveUp",{id:c.id}),disabled:g||!i,onClick:()=>b(c.id,j-1),className:"rounded p-1 text-amber-800 transition-colors hover:bg-amber-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-amber-500 disabled:opacity-30 dark:text-amber-300 dark:hover:bg-amber-900/50",children:e.jsx(Mt,{className:"h-3.5 w-3.5","aria-hidden":!0})}),e.jsx("button",{type:"button","aria-label":o("chat.followUpQueue.moveDown",{id:c.id}),disabled:g||!C,onClick:()=>b(c.id,j+1),className:"rounded p-1 text-amber-800 transition-colors hover:bg-amber-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-amber-500 disabled:opacity-30 dark:text-amber-300 dark:hover:bg-amber-900/50",children:e.jsx(Te,{className:"h-3.5 w-3.5","aria-hidden":!0})}),e.jsx("button",{type:"button","aria-label":o("chat.followUpQueue.remove",{id:c.id}),disabled:g||!c.mutable,onClick:()=>void f({type:"remove",messageId:c.id}),className:"rounded p-1 text-red-600 transition-colors hover:bg-red-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-red-500 disabled:opacity-30 dark:text-red-400 dark:hover:bg-red-950/60",children:e.jsx(re,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})]},c.id)})})]})]})}const we=Ft,Ne=Rt,Se=Dt,xe=h.forwardRef(({className:t,sideOffset:s=4,...r},a)=>e.jsx(et,{ref:a,sideOffset:s,className:$("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",t),...r}));xe.displayName=et.displayName;const Ps={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 de(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t)}function Us(t){if(t<60)return`${t}s`;const s=Math.floor(t/60),r=t%60;return r===0?`${s}m`:`${s}m ${r}s`}function Ls(){var N,M,R,B,H,te,Y,G,X,W,F,Q,q,K,V;const t=U(),{locale:s}=Ye(),r=p(A=>A.goal),a=p(A=>A.pauseGoal),o=p(A=>A.resumeGoal),n=p(A=>A.editGoal),u=p(A=>A.clearGoal),x=p(A=>ae(A.historySurfaceSelection)),[v,l]=h.useState(!1),[f,b]=h.useState(!1),[c,j]=h.useState(""),[m,w]=h.useState(null),[i,C]=h.useState(!1);if(h.useEffect(()=>{l(!1),b(!1),j((r==null?void 0:r.objective)??""),C(!1)},[r==null?void 0:r.goalId]),x||!r)return null;const g=Ps[r.status],T=["active","verifying","paused","blocked"].includes(r.status),d=r.status==="active"||r.status==="verifying",E=r.status==="paused"||r.status==="blocked",S=m!==null,D=async(A,O)=>{if(!L(p.getState())){w(A);try{await O()}finally{w(null)}}},k=()=>{j(r.objective),b(!0),l(!0)},I=async A=>{A.preventDefault();const O=c.trim();if(!O||O===r.objective){b(!1);return}await D("edit",()=>n(O)),b(!1)},z=async()=>{await D("delete",u),C(!1)};return e.jsxs(e.Fragment,{children:[e.jsx(we,{delayDuration:250,children:e.jsxs("section",{"aria-label":t("goal.aria.section"),className:"mx-3 mb-1 shrink-0","data-blade-goal-status":r.status,"data-blade-goal-recovery":(N=r.prematureStop)==null?void 0:N.consecutiveCount,"data-blade-goal-recovery-pattern":(M=r.prematureStop)==null?void 0:M.pattern,"data-blade-goal-verification-stall":(R=r.verificationStall)==null?void 0:R.consecutiveCount,"data-blade-goal-frontier-task-list":(B=r.executionFrontier)==null?void 0:B.taskListId,"data-blade-goal-frontier-total":(H=r.executionFrontier)==null?void 0:H.total,"data-blade-goal-frontier-completed":(te=r.executionFrontier)==null?void 0:te.completed,"data-blade-goal-frontier-in-progress":(Y=r.executionFrontier)==null?void 0:Y.inProgress,"data-blade-goal-frontier-pending":(G=r.executionFrontier)==null?void 0:G.pending,"data-blade-goal-frontier-blocked":(X=r.executionFrontier)==null?void 0:X.blocked,"data-blade-goal-frontier-next-task":(F=(W=r.executionFrontier)==null?void 0:W.nextTask)==null?void 0:F.id,"data-blade-goal-frontier-digest":(Q=r.executionFrontier)==null?void 0:Q.digestSha256.slice(0,16),"data-blade-goal-frontier-stall":(q=r.frontierStall)==null?void 0:q.category,"data-blade-goal-frontier-stall-count":(K=r.frontierStall)==null?void 0:K.consecutiveCount,children:[e.jsxs("div",{className:$("flex h-9 items-center gap-2 rounded-lg border px-3 transition-colors","border-[hsl(var(--deck-border))]/60 bg-[hsl(var(--deck-surface))]/80 backdrop-blur-sm",v&&"rounded-b-none border-b-0"),children:[r.status==="complete"?e.jsx(xt,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500"}):e.jsx(Ht,{className:$("h-3.5 w-3.5 shrink-0",g.accent)}),e.jsx("span",{className:$("h-1.5 w-1.5 shrink-0 rounded-full",g.dot)}),e.jsx("span",{className:$("shrink-0 text-[10px] font-medium leading-none",g.accent),children:r.status==="verifying"?s==="zh"?"验证中":"Verifying":t(g.labelKey)}),e.jsx("span",{className:"h-3 w-px shrink-0 bg-[hsl(var(--deck-hairline))]"}),e.jsx("button",{type:"button","aria-label":t(v?"goal.action.collapse":"goal.action.expand"),className:"min-w-0 flex-1 truncate text-left text-[12px] leading-5 text-[hsl(var(--deck-ink))]/85 outline-none transition-colors hover:text-[hsl(var(--deck-ink))]",onClick:()=>l(A=>!A),"aria-expanded":v,title:r.objective,children:r.objective}),r.tokensUsed>0&&e.jsxs("span",{className:"hidden shrink-0 text-[10px] tabular-nums text-[hsl(var(--deck-ink-muted))] sm:inline",children:[de(r.tokensUsed),r.tokenBudget!==void 0&&`/${de(r.tokenBudget)}`]}),e.jsxs("div",{className:"flex shrink-0 items-center",children:[d&&e.jsx(ue,{label:t("goal.action.pause"),disabled:S,onClick:()=>void D("pause",a),children:m==="pause"?e.jsx(P,{className:"animate-spin"}):e.jsx($t,{})}),E&&e.jsx(ue,{label:t("goal.action.resume"),disabled:S,onClick:()=>void D("resume",o),children:m==="resume"?e.jsx(P,{className:"animate-spin"}):e.jsx(It,{})}),e.jsx(ue,{label:t(T?"goal.action.edit":"goal.action.expand"),disabled:!T&&!v,onClick:T?k:()=>l(A=>!A),children:T?e.jsx(tt,{}):e.jsx(At,{})}),e.jsx(ue,{label:t("goal.action.delete"),disabled:S,destructive:!0,onClick:()=>C(!0),children:e.jsx(re,{})})]})]}),v&&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:f?e.jsxs("form",{onSubmit:I,children:[e.jsx("textarea",{id:"goal-objective",value:c,onChange:A=>j(A.target.value),onKeyDown:A=>{A.key==="Escape"&&b(!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:()=>b(!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(Xe,{className:"h-3 w-3"}),t("goal.action.cancel")]}),e.jsxs("button",{type:"submit",disabled:!c.trim()||m==="edit",className:"inline-flex h-7 items-center gap-1 rounded-md bg-[hsl(var(--deck-accent))] px-2.5 text-[11px] font-medium text-white transition-colors hover:bg-[hsl(var(--deck-accent))]/90 disabled:cursor-not-allowed disabled:opacity-50",children:[m==="edit"?e.jsx(P,{className:"h-3 w-3 animate-spin"}):e.jsx(pe,{className:"h-3 w-3"}),t("goal.action.save")]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"whitespace-pre-wrap text-[12px] leading-5 text-[hsl(var(--deck-ink))]/90",children:r.objective}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1.5 text-[10px] text-[hsl(var(--deck-ink-muted))]",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Pt,{className:"h-3 w-3"}),de(r.tokensUsed),r.tokenBudget!==void 0&&` / ${de(r.tokenBudget)}`," ",t("goal.metrics.tokens")]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Qt,{className:"h-3 w-3"}),Us(r.timeUsedSeconds)]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(me,{className:"h-3 w-3"}),r.continuationCount===1?t("goal.metrics.continuationOne",{n:r.continuationCount}):t("goal.metrics.continuationMany",{n:r.continuationCount})]})]}),r.prematureStop&&e.jsxs("div",{className:"mt-2 inline-flex items-center gap-1.5 font-mono text-[10px] text-amber-700 dark:text-amber-300",children:[e.jsx(me,{className:"h-3 w-3"}),s==="zh"?"恢复提示":"Recovery nudge"," ",r.prematureStop.consecutiveCount," ·"," ",r.prematureStop.pattern.replaceAll("_"," ")]}),r.completionVerification&&e.jsxs("div",{"data-goal-verification":r.completionVerification.status,className:"mt-2 rounded-md border border-sky-200/50 bg-sky-50/60 px-2.5 py-2 text-[11px] text-sky-900 dark:border-sky-400/15 dark:bg-sky-400/[0.05] dark:text-sky-100",children:[e.jsxs("p",{className:"font-mono font-medium",children:["#",r.completionVerification.attempt," ·"," ",r.completionVerification.status.toUpperCase()," ·"," ",((V=r.completionVerification.verifierSessionId)==null?void 0:V.slice(0,12))??"-",r.verificationStall?s==="zh"?` · 重复 ${r.verificationStall.consecutiveCount}/3`:` · repeat ${r.verificationStall.consecutiveCount}/3`:""]}),r.completionVerification.summary&&e.jsx("p",{className:"mt-1 line-clamp-3 whitespace-pre-wrap opacity-80",children:r.completionVerification.summary}),r.completionVerification.evidenceSha256&&e.jsxs("p",{className:"mt-1 font-mono text-[10px] opacity-60",children:["sha256:",r.completionVerification.evidenceSha256.slice(0,12)]})]}),r.statusReason&&e.jsx("div",{className:"mt-2 rounded-md border border-amber-200/50 bg-amber-50/60 px-2.5 py-1.5 text-[11px] text-amber-800 dark:border-amber-400/15 dark:bg-amber-400/[0.05] dark:text-amber-200",children:r.statusReason})]})})]})}),e.jsx(Qe,{open:i,onOpenChange:C,children:e.jsxs(Ke,{className:"max-w-[400px] border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsx(ze,{children:t("goal.dialog.title")}),e.jsx(qe,{children:t("goal.dialog.description")}),e.jsxs(Ge,{className:"mt-2",children:[e.jsx("button",{type:"button",onClick:()=>C(!1),className:"inline-flex h-8 items-center justify-center rounded-md border border-[hsl(var(--deck-border))] px-3 text-[12px] text-[hsl(var(--deck-ink))] hover:bg-[hsl(var(--deck-hairline))]/60",children:t("goal.action.cancel")}),e.jsxs("button",{type:"button",disabled:m==="delete",onClick:()=>void 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:[m==="delete"&&e.jsx(P,{className:"w-3.5 h-3.5 animate-spin"}),t("goal.action.delete")]})]})]})})]})}function ue({label:t,children:s,disabled:r,destructive:a,onClick:o}){return e.jsxs(Ne,{children:[e.jsx(Se,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":t,disabled:r,onClick:o,className:$("flex h-6 w-6 items-center justify-center rounded-md text-[hsl(var(--deck-ink-muted))] outline-none transition-colors focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent-glow))]/50 disabled:cursor-not-allowed disabled:opacity-35 [&_svg]:h-3.5 [&_svg]:w-3.5",a?"hover:bg-rose-500/10 hover:text-rose-500":"hover:bg-[hsl(var(--deck-hairline))]/60 hover:text-[hsl(var(--deck-ink))]"),children:s})}),e.jsx(xe,{side:"top",className:"text-[10px]",children:t})]})}function Os(){const t=U(),s=p(l=>l.currentSessionRef),r=p(l=>l.sessions),a=p(l=>l.messages),o=p(l=>ae(l.historySurfaceSelection)),n=h.useMemo(()=>{var f,b,c,j,m;const l=s?(f=pt(r,s))==null?void 0:f.pendingInteraction:void 0;if(l)return l.type;for(let w=a.length-1;w>=0;w-=1){const i=(b=a[w])==null?void 0:b.agentContent;if(((c=i==null?void 0:i.confirmation)==null?void 0:c.status)==="pending")return"permission";if(((j=i==null?void 0:i.question)==null?void 0:j.status)==="pending")return"question";if(((m=i==null?void 0:i.elicitation)==null?void 0:m.status)==="pending")return"elicitation"}return null},[s,a,r]);if(o||!n)return null;const u=()=>{const l=document.querySelector(`[data-pending-interaction="${n}"]`);l==null||l.scrollIntoView({block:"center",behavior:"smooth"}),window.setTimeout(()=>l==null?void 0:l.focus(),250)},x=n==="question",v=n==="elicitation";return e.jsxs("div",{role:"alert",className:"mx-3 mb-2 flex flex-wrap items-center gap-2 rounded-lg border border-amber-300/80 bg-amber-50/95 px-3 py-2 font-mono text-amber-950 shadow-sm backdrop-blur dark:border-amber-800/80 dark:bg-amber-950/90 dark:text-amber-100 sm:mx-5",children:[e.jsx(Ce,{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(x?"interaction.bar.questionTitle":v?"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(x?"interaction.bar.questionHint":v?"interaction.bar.elicitationHint":"interaction.bar.permissionHint")})]}),e.jsxs("button",{type:"button",onClick:u,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(Te,{className:"h-3 w-3"}),t("interaction.bar.review")]})]})}const Vs=h.lazy(()=>We(()=>import("./MarkdownRenderer-BMAuTkc6.js").then(t=>t.M),__vite__mapDeps([0,1,2,3,4,5,6])).then(t=>({default:t.MarkdownRenderer})));function Hs(t){return t<1e3?`${t}ms`:`${(t/1e3).toFixed(1)}s`}function Qs(){const t=U(),s=p(a=>a.sideConversation),r=p(a=>a.dismissSideConversation);return s?e.jsx("section",{"aria-label":t("chat.side.title"),"data-blade-side-conversation":!0,"data-status":s.status,className:"shrink-0 border-y border-[hsl(var(--deck-accent)/0.28)] bg-[hsl(var(--deck-accent-soft)/0.42)]",children:e.jsxs("div",{className:"px-4 py-3 md:px-6",children:[e.jsxs("header",{className:"flex min-h-7 items-start gap-2",children:[e.jsx(Vt,{"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(Bt,{"aria-hidden":!0,className:"h-3 w-3"}),Hs(s.durationMs)]})]}),e.jsx("p",{className:"mt-0.5 break-words font-mono text-[11px] leading-4 text-[hsl(var(--deck-ink-muted))]",children:s.question})]}),e.jsx("button",{type:"button",onClick:r,"aria-label":t("chat.side.dismiss"),title:t("chat.side.dismiss"),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:e.jsx(Xe,{"aria-hidden":!0,className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{"aria-live":"polite","aria-busy":s.status==="loading",className:"mt-2 max-h-[min(36vh,320px)] overflow-y-auto border-l-2 border-[hsl(var(--deck-accent)/0.42)] pl-3 pr-1",children:[s.status==="loading"&&e.jsxs("div",{role:"status",className:"flex min-h-9 items-center gap-2 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))]",children:[e.jsx(P,{"aria-hidden":!0,className:"h-3.5 w-3.5 animate-spin text-[hsl(var(--deck-accent))]"}),t("chat.side.loading")]}),s.status==="error"&&e.jsxs("div",{role:"alert",className:"flex min-h-9 items-start gap-2 font-mono text-[11px] leading-5 text-red-700 dark:text-red-300",children:[e.jsx(Ce,{"aria-hidden":!0,className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"break-words",children:s.error??t("chat.side.failed")})]}),s.status==="completed"&&s.response&&e.jsx(h.Suspense,{fallback:e.jsx("div",{className:"whitespace-pre-wrap break-words font-mono text-[12px] leading-5 text-[hsl(var(--deck-ink))]",children:s.response}),children:e.jsx(Vs,{content:s.response,className:"text-[12px] leading-5 [&_h1]:text-[14px] [&_h2]:text-[13px] [&_h3]:text-[12px]"})})]})]})}):null}function je(t){return Number.isFinite(t)?Math.max(0,t):0}function Ks(t){const s=je(t.totalInputTokens),r=je(t.cacheReadTokens),a=je(t.cacheWriteTokens),o=Math.min(r,s),n=Math.min(a,Math.max(0,s-o)),u=Math.max(0,s-o-n),x=s>0&&(r>0||a>0);return{totalInputTokens:s,cacheReadTokens:o,cacheWriteTokens:n,uncachedInputTokens:u,...x?{hitRate:o/s}:{}}}function zs(t){return t===void 0||!Number.isFinite(t)?"—":`${Math.round(Math.max(0,Math.min(1,t))*100)}%`}const qs={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:""},Gs={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"},Z=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString(),oe=t=>{const s=Math.max(0,Math.ceil(t/1e3)),r=Math.floor(s/60),a=s%60;return r>0?`${r}m ${a}s`:`${a}s`};function nt(){const t=U(),s=p(S=>S.tokenUsage),r=p(S=>S.isStreaming),a=p(S=>S.agentPhase),o=p(S=>S.providerAdmission),n=p(S=>S.providerCircuit),u=p(S=>S.providerRetry),x=p(S=>S.pendingResume),v=p(S=>S.providerStall),l=p(S=>S.actionStationarity),f=p(S=>S.turnRecovery),b=qs[a]??"",c=(u==null?void 0:u.delayMs)!==void 0?` · ${Math.max(0,Math.ceil(u.delayMs/1e3))}s`:"",j=(x==null?void 0:x.delayMs)!==void 0?` · retry in ${oe(x.delayMs)}`:"",m=(f==null?void 0:f.state)==="requires_attention"?t("status.recovery.review"):"",w=(f==null?void 0:f.state)==="requires_attention"?t(f.reason==="interrupted_tool_call"?"status.recovery.interruptedTool":"status.recovery.successfulTool"):"",i=m||(l?`${t(l.phase==="halted"?"status.phase.actionStationarityStopped":"status.phase.actionStationarityRecovering")} · ${l.toolName} · ${l.runLength}/${l.haltThreshold}`:n?n.phase==="probe"?"Provider · Recovery probe":`Provider · Circuit open${n.retryAfterMs!==void 0?` · probe in ${oe(n.retryAfterMs)}`:""}${n.recoveryRemainingMs!==void 0?` · ${oe(n.recoveryRemainingMs)}`:""}`:o?`Provider · Capacity queue ${o.queuePosition}/${Math.max(o.queueDepth,o.queuePosition)} · ${o.scope} · ${oe(o.waitMs)}`:u?u.mode==="bounded_foreground"?`Provider · Bounded recovery · ${u.attempt}/${u.maxRetries} · ${oe(u.recoveryRemainingMs??0)}`:`Provider · ${t("chat.error.action.retryingTask")} · ${u.attempt}/${u.maxRetries}${c}`:x?`Recovery attempt ${x.attempt}/${x.maxAttempts}${j}`:v?`${t("status.phase.providerStall")} · ${Math.ceil(v.durationMs/1e3)}s / ${Math.ceil(v.timeoutMs/1e3)}s`:b?t(b):""),C=s.maxContextTokens>0?Math.round(s.totalTokens/s.maxContextTokens*100):0,g=Ks(s),T=zs(g.hitRate),d=Math.min(C,100),E=C>95?"danger":C>80?"warn":"safe";return e.jsxs("div",{"data-chat-status-bar":!0,className:"flex items-center gap-2 border-t border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))]/70 px-3 py-2 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] backdrop-blur-sm sm:gap-4 sm:px-5",children:[e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[e.jsx("span",{className:"deck-eyebrow text-[hsl(var(--deck-ink-faint))]",children:t("status.context")}),e.jsxs("span",{className:"flex gap-1 items-baseline tabular-nums",children:[e.jsx("span",{className:$("text-[12px] font-medium",E==="safe"&&"text-[hsl(var(--deck-ink))]",E==="warn"&&"text-amber-600 dark:text-amber-400",E==="danger"&&"text-red-600 dark:text-red-400"),children:Z(s.totalTokens)}),e.jsxs("span",{className:"text-[hsl(var(--deck-ink-faint))]",children:["/ ",Z(s.maxContextTokens)]})]}),s.isDefaultMaxTokens&&e.jsx(we,{children:e.jsxs(Ne,{children:[e.jsx(Se,{asChild:!0,children:e.jsx(Ut,{className:"h-3 w-3 cursor-help text-[hsl(var(--deck-ink-faint))]"})}),e.jsx(xe,{side:"top",className:"max-w-[220px]",children:e.jsx("p",{className:"text-xs",children:t("status.tokenLimitTooltip")})})]})}),e.jsxs("div",{className:"relative hidden h-2 w-32 overflow-hidden rounded-sm border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] sm:block","aria-hidden":"true",children:[e.jsx("div",{className:$("absolute inset-y-0 left-0 transition-[width] duration-300",E==="safe"&&"bg-[hsl(var(--deck-accent))]",E==="warn"&&"bg-amber-500",E==="danger"&&"bg-red-500"),style:{width:`${d}%`}}),e.jsx("div",{className:"flex absolute inset-0 pointer-events-none",children:[25,50,75].map(S=>e.jsx("span",{className:"absolute inset-y-0 w-px bg-[hsl(var(--deck-canvas-veil))]/60",style:{left:`${S}%`}},S))})]}),e.jsxs("span",{className:$("w-10 text-right tabular-nums text-[hsl(var(--deck-ink-faint))]",E==="warn"&&"text-amber-600 dark:text-amber-400",E==="danger"&&"text-red-600 dark:text-red-400"),children:[C,"%"]})]}),e.jsx(we,{children:e.jsxs(Ne,{children:[e.jsx(Se,{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")} ${T}`,children:[e.jsx("span",{className:"deck-eyebrow text-[hsl(var(--deck-ink-faint))]",children:t("status.cache")}),e.jsx("span",{className:$("tabular-nums",g.hitRate===void 0?"text-[hsl(var(--deck-ink-faint))]":"font-medium text-[hsl(var(--deck-accent))]"),children:T})]})}),e.jsx(xe,{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:Z(g.cacheReadTokens),write:Z(g.cacheWriteTokens),uncached:Z(g.uncachedInputTokens)})}),s.cacheBreak&&e.jsx("p",{className:"text-[hsl(var(--deck-accent))]",children:t("status.cacheBreak",{reason:t(Gs[s.cacheBreak.reason]??"status.cacheBreak.server"),previous:Z(s.cacheBreak.previousCacheReadTokens),current:Z(s.cacheBreak.cacheReadTokens)})})]})})]})}),e.jsx("div",{className:"flex-1"}),(m||r&&i)&&e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:$("shrink-0",m?"h-2 w-2 rounded-sm bg-amber-500":"deck-pulse-dot")}),e.jsxs("span",{className:$("truncate",m?"text-amber-600 dark:text-amber-400":"text-[hsl(var(--deck-accent))]"),children:[i,w?e.jsxs("span",{className:"hidden sm:inline",children:[" · ",w]}):null]})]})]})}function Ws(){const{locale:t}=Ye(),s=ft(d=>d.agentTeamsEnabled),r=p(d=>d.teams),a=p(d=>d.currentSessionRef),o=p(d=>ae(d.historySurfaceSelection)),n=p(d=>d.loadTeams),[u,x]=h.useState({}),[v,l]=h.useState({}),[f,b]=h.useState({}),[c,j]=h.useState(null),[m,w]=h.useState(null),[i,C]=h.useState(null);if(h.useEffect(()=>{o||n(a??void 0)},[s,a,o,n]),o||!s||!a||r.length===0)return null;const g=async d=>{var S;if(L(p.getState()))return;const E=(S=f[d])==null?void 0:S.trim();if(!(!E||c)){j(d),C(null);try{await Re.sendMessage(a,d,v[d]??"*",E),b(D=>({...D,[d]:""})),await n(a)}catch(D){C(D instanceof Error?D.message:_(t,"actionFailed"))}finally{j(null)}}},T=async d=>{if(!L(p.getState())&&!m){w(d),C(null);try{await Re.delete(a,d),await n(a)}catch(E){C(E instanceof Error?E.message:_(t,"actionFailed"))}finally{w(null)}}};return e.jsxs("section",{"aria-label":_(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:[i&&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:i}),r.filter(d=>d.status!=="deleted").map(d=>{var D;const E=u[d.name]??d.status==="running",S=d.tasks.filter(k=>k.status==="completed").length;return e.jsxs("div",{className:"border-b border-emerald-200/40 last:border-0 dark:border-emerald-900/40",children:[e.jsxs("div",{className:"flex min-h-11 items-center gap-2 px-4 py-2 md:px-6",children:[e.jsx("button",{type:"button",onClick:()=>x(k=>({...k,[d.name]:!E})),"aria-label":E?_(t,"collapse"):_(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:E?e.jsx(ce,{className:"h-4 w-4"}):e.jsx(ne,{className:"h-4 w-4"})}),e.jsx(Kt,{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:d.name}),e.jsxs("span",{className:"font-mono text-[9.5px] text-[hsl(var(--deck-ink-faint))]",children:[d.status," · ",d.members.length-1," ",_(t,"members")," · ",S,"/",d.tasks.length," ",_(t,"tasks")]})]}),d.description&&e.jsx("p",{className:"truncate font-mono text-[10px] text-[hsl(var(--deck-ink-muted))]",children:d.description})]}),e.jsx("button",{type:"button",onClick:()=>void T(d.name),disabled:m===d.name,"aria-label":_(t,"delete"),title:_(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(re,{className:"h-3.5 w-3.5"})})]}),E&&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:_(t,"members")}),d.members.map(k=>e.jsxs("div",{className:"flex min-h-7 items-center gap-2 border-b border-[hsl(var(--deck-hairline)/0.55)] py-1 last:border-0",children:[e.jsx("span",{"aria-label":k.status,className:`h-1.5 w-1.5 shrink-0 rounded-full ${k.status==="running"?"bg-emerald-500":k.status==="completed"||k.status==="leader"?"bg-sky-500":k.status==="failed"?"bg-red-500":"bg-zinc-400"}`}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[10.5px] text-[hsl(var(--deck-ink))]",children:k.name}),e.jsx("span",{className:"font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:k.subagentType}),k.worktreePath&&e.jsx(Ve,{className:"h-3 w-3 text-[hsl(var(--deck-ink-faint))]","aria-label":_(t,"worktree")})]},k.id))]}),e.jsxs("div",{children:[e.jsx("h3",{className:"mb-1 font-mono text-[9.5px] font-semibold uppercase text-[hsl(var(--deck-ink-faint))]",children:_(t,"tasks")}),d.tasks.length===0?e.jsx("p",{className:"font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:_(t,"noTasks")}):d.tasks.map(k=>e.jsxs("div",{className:"flex min-h-7 items-center gap-2 border-b border-[hsl(var(--deck-hairline)/0.55)] py-1 last:border-0",children:[e.jsxs("span",{className:"w-5 shrink-0 font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:["#",k.id]}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[10.5px] text-[hsl(var(--deck-ink))]",children:k.subject}),e.jsx("span",{className:"font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:k.status})]},k.id))]})]}),d.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":_(t,"recipient"),value:v[d.name]??"*",onChange:k=>l(I=>({...I,[d.name]:k.target.value})),className:"h-8 max-w-32 rounded-md border border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-surface))] px-2 font-mono text-[10px]",children:[e.jsx("option",{value:"*",children:_(t,"broadcast")}),d.members.filter(k=>k.status!=="leader").map(k=>e.jsx("option",{value:k.name,children:k.name},k.id))]}),e.jsx("input",{value:f[d.name]??"",onChange:k=>b(I=>({...I,[d.name]:k.target.value})),onKeyDown:k=>{k.key==="Enter"&&g(d.name)},placeholder:_(t,"messagePlaceholder"),className:"h-8 min-w-0 flex-1 rounded-md border border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-surface))] px-2 font-mono text-[10.5px] outline-none focus:border-emerald-500"}),e.jsx("button",{type:"button",onClick:()=>void g(d.name),disabled:!((D=f[d.name])!=null&&D.trim())||c===d.name,"aria-label":_(t,"send"),title:_(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(He,{className:"h-3.5 w-3.5"})})]})]})]},d.name)})]})}function Js(t){const s=[...t].reverse().find(o=>o.role==="user");if(!s)return null;if(typeof s.content=="string")return{content:s.content,attachments:[]};const r=s.content.filter(o=>o.type==="text").map(o=>o.text).join(`
63
- `),a=s.content.filter(o=>o.type==="image_url").map((o,n)=>{var x;const u=((x=o.image_url.url.match(/^data:([^;,]+)[;,]/))==null?void 0:x[1])??"application/octet-stream";return{id:`recovery-${s.id}-${n}`,name:`attachment-${n+1}`,mimeType:u,dataUrl:o.image_url.url}});return{content:r,attachments:a}}function Ys({messages:t,isLoading:s,isStreaming:r,isStopping:a,errorMessage:o}){const n=U(),[u,x]=h.useState(!1),v=n(o?"status.phase.error":a?"chat.input.action.stopping":r?"status.phase.running":"preview.files.status.ready");return e.jsxs("details",{"data-preview-status-disclosure":!0,open:u,onToggle:l=>x(l.currentTarget.open),className:"group hidden",children:[e.jsxs("summary",{className:"flex h-9 cursor-pointer list-none items-center gap-2 px-3 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[hsl(var(--deck-accent))]",children:[r&&e.jsx("span",{className:"deck-pulse-dot"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:v}),e.jsx(ne,{className:"h-3.5 w-3.5 shrink-0 transition-transform group-open:rotate-90"})]}),u&&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:[o&&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:o}),e.jsx(at,{messages:t,isLoading:s}),e.jsx(nt,{})]})]})}function hr(){var O;const t=U(),s=p(y=>y.messages),r=p(y=>y.currentSessionRef),a=p(y=>y.isStreaming),o=p(y=>y.isStopping),n=p(y=>y.sessionEventConnectionState),u=p(y=>y.pendingSteeringCount),x=p(y=>y.pendingInputDelivery),v=p(y=>y.recoveredSteeringCount),l=p(y=>y.followUpQueue),f=p(y=>y.followUpQueueMutation),b=p(y=>y.mutateFollowUpQueue),c=p(y=>y.refreshFollowUpQueue),j=p(y=>!!y.historySurfaceSelection),m=p(y=>y.isLoading),w=p(y=>y.error),i=p(y=>y.errorContext),C=p(y=>y.sessions),g=p(y=>y.sendMessage),T=p(y=>y.abortSession),d=p(y=>y.retryTask),E=p(y=>y.retryingTaskKeys),S=Ee(y=>y.openSettings),D=p(y=>y.reconnectSessionEvents),k=p(y=>y.clearError),[I,z]=h.useState(null),N=r?C.find(y=>y.sessionId===r.sessionId&&y.projectPath===r.projectPath):void 0,M=!!w&&((i==null?void 0:i.kind)==="navigation"||!(i!=null&&i.sessionRef)||Oe(i.sessionRef,r)),R=(i==null?void 0:i.failureCode)??((O=N==null?void 0:N.taskFailure)==null?void 0:O.code),B=((i==null?void 0:i.kind)==="execution"||i!=null&&i.failureCode)&&R?t(Nt(R)):w==="queue_full"?t("chat.error.queueFull"):w==="turn_unavailable"||w==="turn_active"?t("chat.error.turnChanged"):w,H=n==="connecting"||n==="reconnecting",te=a&&n!=="connected",Y=r?`session:${le(r)}`:"session:temporary",G=h.useMemo(()=>Js(s),[s]),X=r?le(r):"temporary-session",W=!!(r&&(N!=null&&N.taskRetryAvailable)&&(!R||St(R)))&&((i==null?void 0:i.kind)==="execution"||(i==null?void 0:i.kind)==="task_action"),F=(i==null?void 0:i.kind)==="execution"&&(R==="authentication"||R==="permission"||R==="model_unavailable"),Q=r?E.includes(le(r)):!1;h.useEffect(()=>{z(null)},[X]);const q=async y=>L(p.getState())?!1:g({content:y.content,modelId:y.modelId,reasoningEffort:y.reasoningEffort,serviceTier:y.serviceTier,responseVerbosity:y.responseVerbosity,communicationStyle:y.communicationStyle,...y.outputSchema?{outputSchema:y.outputSchema}:{},attachments:y.attachments.map(be=>({type:"image",content:be.dataUrl,mimeType:be.mimeType,name:be.name}))}),K=()=>{if(!L(p.getState()))return T()},V=async()=>{if(!L(p.getState())){if(F){k(),S("models");return}if(W&&r){k(),await d(r).catch(()=>{});return}if((i==null?void 0:i.kind)==="execution"&&G){z({...G,revision:Date.now()}),k();return}k(),requestAnimationFrame(()=>gt())}},A=W?t(Q?"chat.error.action.retryingTask":"chat.error.action.retryTask"):F?t("chat.error.action.checkModels"):(i==null?void 0:i.kind)==="execution"&&G?t("chat.error.action.editResend"):(i==null?void 0:i.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:[M&&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(Ce,{className:"h-3.5 w-3.5 shrink-0"}),e.jsxs("span",{className:"min-w-0 flex-1 break-words",children:[e.jsx("span",{className:"font-semibold",children:t((i==null?void 0:i.kind)==="submission"?"chat.error.title.submission":(i==null?void 0:i.kind)==="execution"?"chat.error.title.execution":(i==null?void 0:i.kind)==="navigation"?"chat.error.title.navigation":"chat.error.title.generic")})," ",B]}),A&&e.jsxs("button",{type:"button",onClick:()=>void V(),disabled:Q,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:[W?Q?e.jsx(P,{className:"h-3 w-3 animate-spin"}):e.jsx(me,{className:"h-3 w-3"}):e.jsx(tt,{className:"h-3 w-3"}),A]}),e.jsx("button",{type:"button",onClick:k,"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:"✕"})]}),(H||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:[H?e.jsx(P,{className:"h-3.5 w-3.5 shrink-0 animate-spin"}):e.jsx(bt,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1",children:t(H?"chat.connection.reconnecting":"chat.connection.offline")}),n==="offline"&&e.jsxs("button",{type:"button",onClick:()=>{L(p.getState())||D().catch(()=>{})},className:"inline-flex min-h-7 items-center gap-1.5 rounded-md border border-amber-400/70 bg-white/60 px-2.5 font-medium transition-colors hover:bg-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-700 dark:bg-amber-950/50 dark:hover:bg-amber-900/50",children:[e.jsx(Je,{className:"h-3 w-3"}),t("chat.connection.retry")]})]}),e.jsx(zt,{}),e.jsx(at,{messages:s,isLoading:m},r?le(r):"temporary-session"),e.jsx(Ws,{}),e.jsx(Qs,{})]}),e.jsxs("div",{"data-chat-composer-dock":!0,className:"contents",children:[e.jsx(Ys,{messages:s,isLoading:m,isStreaming:a,isStopping:o,errorMessage:M?B:null},X),e.jsx(Os,{}),e.jsx(Ls,{}),e.jsx(_s,{queue:j?null:l,mutation:f,onMutate:b,onRefresh:c}),e.jsx(vt,{draftKey:Y,draft:I==null?void 0:I.content,draftAttachments:I==null?void 0:I.attachments,draftRevision:I==null?void 0:I.revision,onSend:q,onAbort:K,disabled:m||te,isStreaming:a,isStopping:o,pendingSteeringCount:u,pendingInputDelivery:x,recoveredSteeringCount:v,workspacePath:r==null?void 0:r.projectPath},Y),e.jsx("div",{"data-chat-primary-status":!0,className:"contents",children:e.jsx(nt,{})})]})]})}export{hr as ChatView};