blade-code 0.10.70 → 0.10.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blade.js +2 -2
- package/dist/{chunk-832va1mp.js → chunk-06y3rada.js} +2 -2
- package/dist/{chunk-k0pa8874.js → chunk-0kat01bw.js} +1 -1
- package/dist/{chunk-th4jjfgm.js → chunk-0qj8jfj1.js} +1 -1
- package/dist/{chunk-w2gr97qt.js → chunk-11gdqmbm.js} +1 -1
- package/dist/chunk-139s7p91.js +1 -0
- package/dist/{chunk-zvz2cnt4.js → chunk-18atvz38.js} +1 -1
- package/dist/{chunk-ypgjqg23.js → chunk-28wsyv32.js} +1 -1
- package/dist/{chunk-b2p4kd07.js → chunk-2d2bcyn1.js} +1 -1
- package/dist/{chunk-31k6x4kn.js → chunk-2fd5trh8.js} +2 -2
- package/dist/{chunk-cdy9efgm.js → chunk-2sdnmxts.js} +1 -1
- package/dist/chunk-2vkzwqv0.js +1 -0
- package/dist/chunk-41smvqs8.js +1 -0
- package/dist/{chunk-hat9v5c5.js → chunk-4wvsg8cc.js} +1 -1
- package/dist/{chunk-6pyktfa4.js → chunk-4xpj0d6y.js} +1 -1
- package/dist/{chunk-d2vrbbvd.js → chunk-5va3hhfp.js} +1 -1
- package/dist/chunk-61arrvhp.js +1 -0
- package/dist/{chunk-yn51162x.js → chunk-6j3k4v08.js} +1 -1
- package/dist/{chunk-s7jsadnc.js → chunk-6j9t1xbh.js} +2 -2
- package/dist/{chunk-wkpacysr.js → chunk-6v7f2cv9.js} +53 -53
- package/dist/{chunk-20vj0npz.js → chunk-7am1z065.js} +1 -1
- package/dist/{chunk-r9n8y8m1.js → chunk-7hf1k2c9.js} +2 -2
- package/dist/chunk-8geywf8q.js +1 -0
- package/dist/{chunk-4md4sd4j.js → chunk-91qsjpm6.js} +2 -2
- package/dist/{chunk-p9vaaayr.js → chunk-a38chc6z.js} +18 -18
- package/dist/{chunk-728anavt.js → chunk-awj9aqjy.js} +2 -2
- package/dist/chunk-bqz8wera.js +1 -0
- package/dist/chunk-brm24s69.js +2 -0
- package/dist/chunk-bs77d8hn.js +2 -0
- package/dist/{chunk-f7yfcw8s.js → chunk-c4j2anbm.js} +2 -2
- package/dist/{chunk-b39p4f5r.js → chunk-ccgq8nrm.js} +2 -2
- package/dist/{chunk-sch01e04.js → chunk-cqeqjtxn.js} +1 -1
- package/dist/{chunk-4aam3qhk.js → chunk-cyjnza5n.js} +4 -4
- package/dist/chunk-d9a0g85f.js +1 -0
- package/dist/{chunk-g28pgqyn.js → chunk-e0hf1317.js} +1 -1
- package/dist/chunk-e4ynb9qf.js +1 -0
- package/dist/chunk-e6ezndyf.js +22 -0
- package/dist/chunk-eh4h7fmr.js +3 -0
- package/dist/chunk-eh9gdzk5.js +160 -0
- package/dist/chunk-emqbb5xh.js +1 -0
- package/dist/{chunk-h0ft81a3.js → chunk-g8425xh4.js} +1 -1
- package/dist/{chunk-d808m826.js → chunk-gv3ed5gw.js} +2 -2
- package/dist/chunk-gzysna9c.js +1 -0
- package/dist/{chunk-wahhwjp9.js → chunk-hhk5ecpv.js} +2 -2
- package/dist/{chunk-z77c18j5.js → chunk-hhvkzn6m.js} +1 -1
- package/dist/{chunk-0kmrvxsz.js → chunk-hryhnmwv.js} +277 -262
- package/dist/{chunk-0p0e70cy.js → chunk-hwjmm2br.js} +2 -2
- package/dist/{chunk-8wea3qty.js → chunk-j0yvwrd7.js} +2 -2
- package/dist/{chunk-m57w4p91.js → chunk-jyds9m8p.js} +1 -1
- package/dist/{chunk-v0rsz1rt.js → chunk-m6qgme8k.js} +1 -1
- package/dist/{chunk-1z9k5dmz.js → chunk-mhyat4mq.js} +2 -2
- package/dist/{chunk-83b4vfjs.js → chunk-mp4bfn57.js} +1 -1
- package/dist/chunk-mrh3vs01.js +2 -0
- package/dist/chunk-ph5rn44j.js +1 -0
- package/dist/chunk-pqhjrdnq.js +10 -0
- package/dist/{chunk-0j22w4wh.js → chunk-q6daf441.js} +1 -1
- package/dist/{chunk-0wxkymqv.js → chunk-s9brgcgs.js} +1 -1
- package/dist/{chunk-1bcp0qc4.js → chunk-ss1znmv0.js} +1 -1
- package/dist/{chunk-bkajr86v.js → chunk-tms0pr01.js} +2 -2
- package/dist/chunk-v7phc78b.js +1 -0
- package/dist/{chunk-t8xmh4w2.js → chunk-wvg81sd9.js} +1 -1
- package/dist/{chunk-sh17gjxv.js → chunk-x4hh8yqg.js} +1 -1
- package/dist/{chunk-pw87f92g.js → chunk-xahapj98.js} +1 -1
- package/dist/{chunk-smjkx71w.js → chunk-xszsveq1.js} +1 -1
- package/dist/{chunk-y9d9nqnn.js → chunk-y858e8pb.js} +2 -2
- package/dist/{chunk-bjqjdw34.js → chunk-yhnr8vdb.js} +2 -2
- package/dist/{chunk-7b5s752s.js → chunk-yjj7q7hy.js} +1 -1
- package/dist/{chunk-q919ypcz.js → chunk-ypwjzw5x.js} +2 -2
- package/dist/{chunk-qm5c9wew.js → chunk-z7vj2xrg.js} +3 -3
- package/dist/{chunk-63121s4r.js → chunk-zac26wwd.js} +1 -1
- package/dist/{chunk-k6shq7rk.js → chunk-zf96d5we.js} +1 -1
- package/dist/chunk-zqxj65xc.js +1 -0
- package/dist/chunk-zssys78z.js +1 -0
- package/dist/web/assets/ChatView-CgUC5rxo.js +18 -0
- package/dist/web/assets/{CodeBlockHighlighter-Dy7QpAmC.js → CodeBlockHighlighter-B5DRAEhB.js} +1 -1
- package/dist/web/assets/{FilePreview-BI3nkxz1.js → FilePreview-DSpvLsjW.js} +1 -1
- package/dist/web/assets/{KanbanBoard-D5dYOyPH.js → KanbanBoard-6K7IeCXi.js} +1 -1
- package/dist/web/assets/{MarkdownRenderer-Da1vB81L.js → MarkdownRenderer-D6LiW9kF.js} +3 -3
- package/dist/web/assets/{SettingsModal-jcCFqLqS.js → SettingsModal-CFHxLfuL.js} +1 -1
- package/dist/web/assets/{TaskSwitcher-CQ--jOLB.js → TaskSwitcher-Bng9nDed.js} +1 -1
- package/dist/web/assets/{TerminalPanel-CWzjEXOb.js → TerminalPanel-BnyQZwkN.js} +1 -1
- package/dist/web/assets/index-CDdYV8kB.css +1 -0
- package/dist/web/assets/index-DId2GJVO.js +11 -0
- package/dist/web/assets/{vendor-icons-B63aW_OM.js → vendor-icons-C927DZlr.js} +41 -36
- package/dist/web/index.html +3 -3
- package/package.json +1 -1
- package/dist/chunk-0p95nha3.js +0 -1
- package/dist/chunk-2z75emht.js +0 -1
- package/dist/chunk-3j413cgh.js +0 -1
- package/dist/chunk-5wnx38ze.js +0 -1
- package/dist/chunk-8bsyhr4v.js +0 -1
- package/dist/chunk-brdxkp0y.js +0 -10
- package/dist/chunk-c0qm0wwk.js +0 -1
- package/dist/chunk-cmpj3a5a.js +0 -22
- package/dist/chunk-cx5s0rf3.js +0 -1
- package/dist/chunk-e3asq942.js +0 -1
- package/dist/chunk-ffym3kf3.js +0 -160
- package/dist/chunk-h94vfh7s.js +0 -1
- package/dist/chunk-jrr361h1.js +0 -2
- package/dist/chunk-nea4rcdf.js +0 -1
- package/dist/chunk-qstf0gpe.js +0 -1
- package/dist/chunk-rpfa4a56.js +0 -1
- package/dist/chunk-v3kkv21n.js +0 -1
- package/dist/chunk-wepvrnmh.js +0 -2
- package/dist/chunk-wj6t3tv2.js +0 -3
- package/dist/chunk-xz6y0w4n.js +0 -2
- package/dist/chunk-ysmqje92.js +0 -1
- package/dist/web/assets/ChatView-BVrhnE2j.js +0 -18
- package/dist/web/assets/index-BOgOL4hG.js +0 -11
- package/dist/web/assets/index-DbWgTuT3.css +0 -1
package/dist/chunk-h94vfh7s.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ih as a,jh as b,kh as c,lh as d,mh as e,nh as f}from"./chunk-y9d9nqnn.js";import"./chunk-k6shq7rk.js";export{b as getVersion,c as getPackageName,a as getPackageInfo,e as getFormattedVersion,d as getDescription,f as getCopyright};
|
package/dist/chunk-jrr361h1.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{promises as A}from"node:fs";import q from"node:path";var J=new Map;async function L(B){let b=B;while(!0){try{return await A.lstat(q.join(b,".git")),b}catch(H){if(H.code!=="ENOENT")return}let E=q.dirname(b);if(E===b)return;b=E}}async function M(B){let b=q.join(B,".git"),E=await A.lstat(b);if(E.isDirectory())return B;if(!E.isFile())return;let H=await A.readFile(b,"utf8"),F=/^gitdir:\s*(.+)\s*$/im.exec(H);if(!F)return;let z=await A.realpath(q.isAbsolute(F[1])?F[1]:q.resolve(B,F[1])),I=z;try{let x=(await A.readFile(q.join(z,"commondir"),"utf8")).trim();if(x)I=await A.realpath(q.resolve(z,x))}catch(x){if(x.code!=="ENOENT")throw x}return q.basename(I)===".git"?A.realpath(q.dirname(I)):void 0}async function S(B){if(!q.isAbsolute(B))throw Error("Workspace path must be absolute");let b=await A.realpath(B),E=J.get(b);if(E)return E;let H=b;try{let z=await L(b);if(z){let I=await M(z),x=q.relative(z,b);if(I&&(x===""||!x.startsWith(`..${q.sep}`)&&x!==".."&&!q.isAbsolute(x))){let K=q.resolve(I,x);H=await A.realpath(K).catch(()=>K)}}}catch{}let F={projectPath:b,trustRoot:H};if(J.size>=512){let z=J.keys().next().value;if(z)J.delete(z)}return J.set(b,F),F}
|
|
2
|
-
export{S as rh};
|
package/dist/chunk-nea4rcdf.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ld as a,md as b,nd as c}from"./chunk-r9n8y8m1.js";import"./chunk-s7jsadnc.js";import"./chunk-p9vaaayr.js";import"./chunk-v508x7cg.js";import"./chunk-0j22w4wh.js";import"./chunk-zvz2cnt4.js";import"./chunk-b39p4f5r.js";import"./chunk-h0ft81a3.js";import"./chunk-v0rsz1rt.js";import"./chunk-xz6y0w4n.js";import"./chunk-k0pa8874.js";import"./chunk-6pyktfa4.js";import"./chunk-d808m826.js";import"./chunk-0p0e70cy.js";import"./chunk-t8xmh4w2.js";import"./chunk-y9d9nqnn.js";import"./chunk-wj6t3tv2.js";import"./chunk-jrr361h1.js";import"./chunk-8wea3qty.js";import"./chunk-k6shq7rk.js";export{a as validatePermissions,c as validateOutput,b as loadConfiguration};
|
package/dist/chunk-qstf0gpe.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Hc as a,Ic as b,Jc as c,Kc as d,Lc as e,Mc as f,Nc as g}from"./chunk-1z9k5dmz.js";import"./chunk-0wxkymqv.js";import"./chunk-f7yfcw8s.js";import"./chunk-yn51162x.js";import"./chunk-cdy9efgm.js";import"./chunk-m57w4p91.js";import"./chunk-xz6y0w4n.js";import"./chunk-k0pa8874.js";import"./chunk-d808m826.js";import"./chunk-t8xmh4w2.js";import"./chunk-y9d9nqnn.js";import"./chunk-8wea3qty.js";import"./chunk-k6shq7rk.js";export{b as __setSessionSnapshotIOForTesting,c as __resetSessionSnapshotIOForTesting,g as SessionService,d as SessionMissingCreationError,e as SessionArchivedError,f as SessionArchiveConflictError,a as STALE_EMPTY_SESSION_AGE_MS};
|
package/dist/chunk-rpfa4a56.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Gd as a,Hd as b,Id as c,Jd as d,Kd as e,Ld as f,Md as g,Nd as h,Od as i,Pd as j,Qd as k,Rd as l,Sd as m,Td as n,Ud as o,Vd as p,Wd as q}from"./chunk-p9vaaayr.js";import"./chunk-v508x7cg.js";import"./chunk-0j22w4wh.js";import"./chunk-b39p4f5r.js";import"./chunk-h0ft81a3.js";import"./chunk-v0rsz1rt.js";import"./chunk-xz6y0w4n.js";import"./chunk-k0pa8874.js";import"./chunk-6pyktfa4.js";import"./chunk-d808m826.js";import"./chunk-0p0e70cy.js";import"./chunk-t8xmh4w2.js";import"./chunk-y9d9nqnn.js";import"./chunk-wj6t3tv2.js";import"./chunk-jrr361h1.js";import"./chunk-8wea3qty.js";import"./chunk-k6shq7rk.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};
|
package/dist/chunk-v3kkv21n.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{oh as a,ph as b,qh as c}from"./chunk-wj6t3tv2.js";import"./chunk-jrr361h1.js";import"./chunk-8wea3qty.js";import"./chunk-k6shq7rk.js";export{b as isWorkspaceTrusted,c as WorkspaceTrustService,a as MAX_RESIDENT_WORKSPACE_TRUST_STATUSES};
|
package/dist/chunk-wepvrnmh.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{mg as J,ng as $,og as U,pg as B}from"./chunk-v0rsz1rt.js";import{qg as v,rg as h,sg as u}from"./chunk-xz6y0w4n.js";import{Xg as i}from"./chunk-d808m826.js";import{Ah as s}from"./chunk-8wea3qty.js";var O=[{min:0,max:59},{min:0,max:23},{min:1,max:31},{min:1,max:12},{min:0,max:7}],r={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6},E=new Map;function D(Q,Z,W){let K=new Set;for(let X of Q.split(",")){let[Y,V]=X.split("/"),G=V?Number.parseInt(V,10):1;if(!Number.isInteger(G)||G<1)throw Error(`Invalid cron step in "${Q}"`);let j=Z,H=W;if(Y!=="*"&&Y!=="")if(Y.includes("-")){let[k,t]=Y.split("-");j=Number.parseInt(k,10),H=Number.parseInt(t,10)}else j=Number.parseInt(Y,10),H=j;if(!Number.isInteger(j)||!Number.isInteger(H)||j<Z||H>W||j>H)throw Error(`Invalid cron range "${Y}" in field "${Q}"`);for(let k=j;k<=H;k+=G)K.add(k)}return K}function R(Q){let Z=Q.trim().split(/\s+/);if(Z.length!==5)throw Error(`Cron expression must have 5 fields (min hour dom mon dow), got ${Z.length}`);let[W,K,X,Y,V]=Z,G=D(V,O[4].min,O[4].max),j=new Set([...G].map((H)=>H===7?0:H));return{minutes:D(W,O[0].min,O[0].max),hours:D(K,O[1].min,O[1].max),daysOfMonth:D(X,O[2].min,O[2].max),months:D(Y,O[3].min,O[3].max),daysOfWeek:j,domRestricted:X.trim()!=="*",dowRestricted:V.trim()!=="*"}}function T(Q,Z){if(!Z)return{minute:Q.getMinutes(),hour:Q.getHours(),dayOfMonth:Q.getDate(),month:Q.getMonth()+1,dayOfWeek:Q.getDay()};let W=E.get(Z);if(!W)W=new Intl.DateTimeFormat("en-US",{timeZone:Z,month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",weekday:"short",hourCycle:"h23"}),E.set(Z,W);let K=Object.fromEntries(W.formatToParts(Q).filter((X)=>X.type!=="literal").map((X)=>[X.type,X.value]));return{minute:Number(K.minute),hour:Number(K.hour),dayOfMonth:Number(K.day),month:Number(K.month),dayOfWeek:r[K.weekday]??-1}}function y(Q,Z,W){let K=T(Z,W);if(!Q.minutes.has(K.minute))return!1;if(!Q.hours.has(K.hour))return!1;if(!Q.months.has(K.month))return!1;let X=Q.daysOfMonth.has(K.dayOfMonth),Y=Q.daysOfWeek.has(K.dayOfWeek);if(Q.domRestricted&&Q.dowRestricted)return X||Y;if(Q.domRestricted)return X;if(Q.dowRestricted)return Y;return!0}function p(Q,Z,W){let K=R(Q),X=new Date(Z.getTime());X.setSeconds(0,0),X.setMinutes(X.getMinutes()+1);let Y=new Date(Z.getTime());Y.setFullYear(Y.getFullYear()+4);while(X.getTime()<=Y.getTime()){if(y(K,X,W))return new Date(X.getTime());X.setMinutes(X.getMinutes()+1)}return null}var S={s:1000,m:60000,h:3600000,d:86400000};function zJ(Q){let W=Q.trim().toLowerCase().match(/^(\d+)\s*([smhd]?)$/);if(!W)return null;let K=Number.parseInt(W[1],10);if(!Number.isInteger(K)||K<=0)return null;let X=W[2]||"m";return K*S[X]}function e(Q){for(let Z of["d","h","m","s"]){let W=S[Z];if(Q%W===0)return`${Q/W}${Z}`}return`${Math.round(Q/1000)}s`}function A(Q,Z,W){switch(Q.kind){case"cron":{if(!Q.cron)return null;try{return p(Q.cron,Z,Q.timezone)}catch{return null}}case"interval":{if(!Q.intervalMs||Q.intervalMs<=0)return null;let X=new Date((W??Z).getTime()+Q.intervalMs);return X.getTime()<=Z.getTime()?new Date(Z.getTime()+1000):X}case"once":{if(!Q.runAt)return null;let K=new Date(Q.runAt);if(Number.isNaN(K.getTime()))return null;return K.getTime()>Z.getTime()?K:null}default:return null}}function _(Q){switch(Q.kind){case"cron":if(!Q.cron)return"cron trigger requires a cron expression";try{if(R(Q.cron),Q.timezone)new Intl.DateTimeFormat("en-US",{timeZone:Q.timezone}).format();return null}catch(Z){return Z instanceof Error?Z.message:"invalid cron expression"}case"interval":if(!Q.intervalMs||Q.intervalMs<60000)return"interval trigger requires intervalMs >= 60000 (1 minute)";return null;case"once":{if(!Q.runAt)return"once trigger requires runAt timestamp";let Z=new Date(Q.runAt);if(Number.isNaN(Z.getTime()))return"once trigger runAt is not a valid date";return null}default:return"unknown trigger kind"}}function AJ(Q){switch(Q.kind){case"cron":return`cron: ${Q.cron??"?"}`;case"interval":return`every ${Q.intervalMs?e(Q.intervalMs):"?"}`;case"once":return`once at ${Q.runAt??"?"}`;default:return"unknown"}}import{mkdir as LJ,readFile as PJ}from"node:fs/promises";import a from"node:path";import{nanoid as MJ}from"nanoid";import IJ from"write-file-atomic";var w=$(B(["default","autoEdit","yolo","plan"]));var N=$(B(["user","assistant","system","tool"])),JJ=$(J.Union([J.Object({type:J.Literal("text"),text:J.String()}),J.Object({type:J.Literal("image_url"),image_url:J.Object({url:J.String()})})])),d=J.Union([J.String(),J.Array(JJ)]),xJ=$(J.Object({id:J.String(),role:N,content:d,timestamp:J.Number(),metadata:J.Optional(J.Record(J.String(),J.Unknown())),thinkingContent:J.Optional(J.String()),tool_call_id:J.Optional(J.String()),name:J.Optional(J.String()),tool_calls:J.Optional(J.Unknown())})),QJ=$(B(["queued","running","completed","failed","cancelled","interrupted"])),F=$(B(["local","worktree"])),q=$(B(["high","medium","low"])),x=$(B(["feature","bug","maintenance","research"])),ZJ=$(B(["applied","discarded","conflicted"])),$J=$(J.Object({status:ZJ,updatedAt:J.String(),sourceCommit:J.Optional(J.String()),changedFiles:J.Optional(J.Integer({minimum:0})),message:J.Optional(J.String())})),BJ=$(J.Object({changedFiles:J.Integer({minimum:0}),additions:J.Integer({minimum:0}),deletions:J.Integer({minimum:0}),commits:J.Integer({minimum:0})})),KJ=$(J.Object({path:J.String({minLength:1}),patch:J.String({maxLength:2097152}),additions:J.Integer({minimum:0}),deletions:J.Integer({minimum:0}),binary:J.Boolean(),truncated:J.Boolean()})),fJ=$(J.Object({sessionId:J.String(),projectPath:J.String(),baseCommit:J.String(),files:J.Array(KJ,{maxItems:100}),truncated:J.Boolean()})),WJ=J.Union([J.String(),J.Number(),J.Boolean(),J.Array(J.String())]),XJ=$(J.Object({name:J.String(),type:B(["string","number","integer","boolean","select","multi-select"]),title:J.String(),description:J.Optional(J.String()),required:J.Boolean(),defaultValue:J.Optional(WJ),options:J.Optional(J.Array(J.Object({value:J.String(),label:J.String()}))),format:J.Optional(B(["date","uri","email","date-time"])),minimum:J.Optional(J.Number()),maximum:J.Optional(J.Number()),minLength:J.Optional(J.Number()),maxLength:J.Optional(J.Number()),minItems:J.Optional(J.Number()),maxItems:J.Optional(J.Number())})),CJ=$(J.Object({serverName:J.String(),mode:B(["form","url"]),message:J.String(),fields:J.Optional(J.Array(XJ)),requestedSchema:J.Optional(J.Record(J.String(),J.Unknown())),url:J.Optional(J.String()),domain:J.Optional(J.String()),elicitationId:J.Optional(J.String())})),YJ=$(J.Object({type:B(["permission","question","elicitation"]),requestId:J.String()})),HJ=$(J.Object({code:B(["authentication","permission","rate_limit","timeout","network","model_unavailable","context_limit","unsupported_input","capacity","runtime"]),message:J.String({minLength:1,maxLength:500}),retryable:J.Boolean(),resource:J.Optional(B(["pending_count","pending_bytes","resident_runtimes"]))})),L=$(B(["auto","off","minimal","low","medium","high","xhigh","max"])),P=$(B(["auto","standard","fast","flex"])),M=$(B(["auto","low","medium","high"])),b=$(J.Union([B(["auto","pragmatic","friendly","explanatory"]),J.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})$"})])),z=$(J.Object({sessionId:J.String(),projectPath:J.String(),title:J.Optional(J.String()),gitBranch:J.Optional(J.String()),rootId:J.String(),parentId:J.Optional(J.String()),relationType:J.Optional(B(["subagent","fork"])),resumedFrom:J.Optional(J.String()),rootAgentId:J.Optional(J.String()),resumeDepth:J.Optional(J.Integer({minimum:0})),taskStatus:U(QJ,"completed"),taskStatusReason:J.Optional(J.String()),taskFailure:J.Optional(HJ),taskStartedAt:J.Optional(J.String()),taskCompletedAt:J.Optional(J.String()),taskPromptSummary:J.Optional(J.String()),taskPriority:J.Optional(q),taskKind:J.Optional(x),taskDueAt:J.Optional(J.String()),taskModelId:J.Optional(J.String()),selectedModelId:J.Optional(J.String()),permissionMode:J.Optional(w),reasoningEffort:J.Optional(L),serviceTier:J.Optional(P),responseVerbosity:J.Optional(M),communicationStyle:J.Optional(b),communicationStyleDigest:J.Optional(J.String({pattern:"^[a-f0-9]{64}$"})),projectInstructionsDigest:J.Optional(J.String({pattern:"^[a-f0-9]{64}$"})),taskRetryAvailable:J.Optional(J.Boolean()),taskRetriedFrom:J.Optional(J.Object({sessionId:J.String(),projectPath:J.String()})),taskDelivery:J.Optional($J),taskIsolation:J.Optional(F),taskSourceProjectPath:J.Optional(J.String()),taskWorktreePath:J.Optional(J.String()),taskWorktreeBranch:J.Optional(J.String()),taskBaseCommit:J.Optional(J.String()),taskDiffStat:J.Optional(BJ),taskQueuePosition:J.Optional(J.Integer({minimum:1})),taskQueueDepth:J.Optional(J.Integer({minimum:0})),taskConcurrencyLimit:J.Optional(J.Integer({minimum:1})),archivedAt:J.Optional(J.String()),archivedBySessionId:J.Optional(J.String()),pendingInteraction:J.Optional(YJ),messageCount:J.Number(),firstMessageTime:J.String(),lastMessageTime:J.String(),hasErrors:J.Boolean()})),EJ=$(J.Object({sessions:J.Array(z),nextCursor:J.Optional(J.String())})),RJ=$(J.Object({session:z,archivedSessionIds:J.Array(J.String())})),SJ=$(J.Object({session:z,restoredSessionIds:J.Array(J.String())})),lJ=$(J.Object({version:J.Literal(1),sessionId:J.String(),goalId:J.String(),objective:J.String(),status:B(["active","verifying","paused","blocked","usage_limited","budget_limited","complete"]),tokenBudget:J.Optional(J.Number()),tokensUsed:J.Number(),timeUsedSeconds:J.Number(),continuationCount:J.Number(),statusReason:J.Optional(J.String()),completionVerification:J.Optional(J.Object({attempt:J.Integer({minimum:1}),status:B(["pending","pass","fail","partial"]),requestedAt:J.String(),completedAt:J.Optional(J.String()),verifierSessionId:J.Optional(J.String()),summary:J.Optional(J.String()),evidenceSha256:J.Optional(J.String({pattern:"^[a-f0-9]{64}$"}))})),createdAt:J.String(),updatedAt:J.String()})),m=$(J.Object({role:N,content:d,metadata:J.Optional(J.Unknown()),reasoningContent:J.Optional(J.String()),thinkingContent:J.Optional(J.String()),tool_call_id:J.Optional(J.String()),name:J.Optional(J.String()),tool_calls:J.Optional(J.Unknown())})),hJ=$(J.Object({session:z,messages:J.Array(m)})),c=$(B(["conversation","code","both"])),jJ=$(J.Object({messageId:J.String(),preview:J.String(),createdAt:J.String(),fileCount:J.Integer({minimum:0})})),uJ=$(J.Object({targetMessageId:J.String({minLength:1}),mode:U(c,"conversation")})),dJ=$(J.Object({checkpoint:jJ,mode:c,removedTurns:J.Integer({minimum:1}),restoredFiles:J.Array(J.String()),messages:J.Array(m)})),UJ=B(["running","completed","failed","cancelled"]),l=$(J.Object({id:J.String(),subagentType:J.String(),description:J.String(),status:UJ,background:J.Boolean(),rootAgentId:J.String(),resumedFrom:J.Optional(J.String()),resumeDepth:J.Integer({minimum:0}),createdAt:J.Number(),lastActiveAt:J.Number(),completedAt:J.Optional(J.Number()),restartRecovery:J.Optional(J.Object({outcome:B(["completed","interrupted","failed"]),recoveredAt:J.Number()})),result:J.Optional(J.Object({success:J.Boolean(),message:J.String(),error:J.Optional(J.String()),verificationCommands:J.Optional(J.Array(J.String())),verificationVerdict:J.Optional(B(["pass","fail","partial"])),modifiedFiles:J.Optional(J.Array(J.String()))})),stats:J.Optional(J.Object({tokens:J.Optional(J.Number()),toolCalls:J.Optional(J.Number()),duration:J.Optional(J.Number())}))})),mJ=$(J.Object({prompt:J.String({minLength:1,maxLength:32000,pattern:"\\S"})})),cJ=$(J.Object({source:l,session:l})),gJ=$(J.Object({sessionId:J.String(),projectPath:J.String()})),nJ=$(J.Object({path:J.String(),name:J.String(),gitBranch:J.Optional(J.String()),available:J.Boolean(),isCurrent:J.Boolean(),boundAt:J.String()})),oJ=$(J.Union([J.Object({cancelled:J.Literal(!0)}),J.Object({cancelled:J.Literal(!1),path:J.String({minLength:1})})])),sJ=$(J.Object({type:J.String(),seq:J.Optional(J.Number()),properties:J.Record(J.String(),J.Unknown())})),g=J.Object({type:B(["file","image","url"]),path:J.Optional(J.String()),url:J.Optional(J.String()),content:J.Optional(J.String({maxLength:h})),mimeType:J.Optional(J.String()),name:J.Optional(J.String())}),n=J.Record(J.String(),J.Unknown()),iJ=$(J.Object({prompt:J.String({minLength:1,maxLength:32000,pattern:"\\S"}),title:J.Optional(J.String({minLength:1,maxLength:200})),taskPriority:U(q,"medium"),taskKind:U(x,"feature"),taskDueAt:J.Optional(J.String({minLength:1,maxLength:64})),projectPath:J.Optional(J.String()),modelId:J.Optional(J.String({minLength:1,maxLength:500})),reasoningEffort:J.Optional(L),serviceTier:J.Optional(P),responseVerbosity:J.Optional(M),communicationStyle:J.Optional(b),isolation:U(F,"worktree"),permissionMode:U(w,"default"),attachments:J.Optional(J.Array(g,{maxItems:v})),outputSchema:J.Optional(n)})),aJ=$(J.Object({title:J.Optional(J.String({minLength:1,maxLength:200})),taskPriority:J.Optional(q),taskKind:J.Optional(x),taskDueAt:J.Optional(J.Union([J.String({minLength:1,maxLength:64}),J.Null()]))})),tJ=$(J.Object({session:z,runId:J.String(),messageId:J.String(),status:B(["queued","running"]),queuePosition:J.Optional(J.Integer({minimum:1})),queueDepth:J.Optional(J.Integer({minimum:0})),maxConcurrentTasks:J.Optional(J.Integer({minimum:1}))})),rJ=$(J.Object({action:B(["apply","discard"])})),f=$(J.Object({kind:B(["cron","interval","once"]),cron:J.Optional(J.String({minLength:1,maxLength:120})),intervalMs:J.Optional(J.Integer({minimum:60000})),runAt:J.Optional(J.String({minLength:1,maxLength:40})),timezone:J.Optional(J.String({minLength:1,maxLength:80}))})),kJ=$(J.Object({modelId:J.Optional(J.String({minLength:1,maxLength:500})),reasoningEffort:J.Optional(L),serviceTier:J.Optional(P),responseVerbosity:J.Optional(M),communicationStyle:J.Optional(b),isolation:U(F,"worktree"),permissionMode:U(w,"default")})),C=$(J.Object({id:J.String(),title:J.Optional(J.String({minLength:1,maxLength:200})),prompt:J.String({minLength:1,maxLength:32000,pattern:"\\S"}),projectPath:J.String({minLength:1}),trigger:f,dispatch:kJ,enabled:J.Boolean(),createdAt:J.String(),updatedAt:J.String(),nextRunAt:J.Union([J.String(),J.Null()]),expiresAt:J.Union([J.String(),J.Null()]),lastRunAt:J.Optional(J.String()),lastRunSessionId:J.Optional(J.String()),lastStatus:J.Optional(B(["queued","running","completed","failed","cancelled","interrupted","error"])),lastError:J.Optional(J.String()),runCount:J.Integer({minimum:0})})),TJ=$(J.Object({title:J.Optional(J.String({minLength:1,maxLength:200})),prompt:J.String({minLength:1,maxLength:32000,pattern:"\\S"}),projectPath:J.String({minLength:1}),trigger:f,modelId:J.Optional(J.String({minLength:1,maxLength:500})),reasoningEffort:J.Optional(L),serviceTier:J.Optional(P),responseVerbosity:J.Optional(M),communicationStyle:J.Optional(b),isolation:U(F,"worktree"),permissionMode:U(w,"default"),enabled:U(J.Boolean(),!0)})),yJ=$(J.Object({title:J.Optional(J.String({minLength:1,maxLength:200})),prompt:J.Optional(J.String({minLength:1,maxLength:32000,pattern:"\\S"})),trigger:J.Optional(f),modelId:J.Optional(J.String({minLength:1,maxLength:500})),reasoningEffort:J.Optional(L),serviceTier:J.Optional(P),responseVerbosity:J.Optional(M),communicationStyle:J.Optional(b),isolation:J.Optional(F),permissionMode:J.Optional(w),enabled:J.Optional(J.Boolean())})),pJ=$(J.Object({schedules:J.Array(C)})),eJ=$(J.Object({content:J.String({maxLength:u}),projectPath:J.Optional(J.String()),modelId:J.Optional(J.String({minLength:1,maxLength:500})),reasoningEffort:J.Optional(L),serviceTier:J.Optional(P),responseVerbosity:J.Optional(M),communicationStyle:J.Optional(b),permissionMode:J.Optional(w),attachments:J.Optional(J.Array(g,{maxItems:v})),outputSchema:J.Optional(n)})),VJ=B(["completed","failed","aborted","timed_out","spawn_error"]),GJ=$(J.Object({version:J.Literal(1),command:J.String(),status:VJ,exitCode:J.Union([J.Integer(),J.Null()]),durationMs:J.Number({minimum:0}),stdout:J.String(),stderr:J.String(),stdoutOmittedBytes:J.Integer({minimum:0}),stderrOmittedBytes:J.Integer({minimum:0}),binaryOutput:J.Boolean(),truncated:J.Boolean()})),JQ=$(J.Object({command:J.String({minLength:1,maxLength:32768,pattern:"^(?![\\s\\S]*\\u0000)(?=[\\s\\S]*\\S)[\\s\\S]*$"}),projectPath:J.Optional(J.String())})),QQ=$(J.Object({executionId:J.String(),messageId:J.String(),record:GJ,auxiliary:J.Boolean(),delivery:J.Optional(B(["current_turn","next_turn"])),queued:J.Optional(J.Integer({minimum:0}))})),ZQ=$(J.Object({projectPath:J.String(),kind:B(["uncommitted","base","commit"]),ref:J.Optional(J.String({maxLength:200})),instructions:J.Optional(J.String({maxLength:4000})),modelId:J.Optional(J.String({minLength:1,maxLength:200}))})),$Q=$(J.Object({reviewId:J.String(),status:J.Literal("running")})),BQ=$(J.Object({messageId:J.String(),role:N,content:J.String(),timestamp:J.String()})),KQ=$(J.Object({approved:J.Boolean(),remember:J.Optional(J.Boolean()),scope:J.Optional(B(["once","session","project"])),targetMode:J.Optional(w),feedback:J.Optional(J.String()),answers:J.Optional(J.Record(J.String(),J.Union([J.String(),J.Array(J.String())]))),elicitation:J.Optional(J.Object({action:B(["accept","decline","cancel"]),content:J.Optional(J.Record(J.String(),J.Union([J.String({maxLength:4000}),J.Number(),J.Boolean(),J.Array(J.String({maxLength:1000}),{maxItems:100})]),{maxProperties:32}))}))})),OJ=$(J.Object({id:b,name:J.String({minLength:1,maxLength:80}),description:J.String({minLength:1,maxLength:256}),source:B(["built-in","user","project","plugin"]),contentSha256:J.Optional(J.String({pattern:"^[a-f0-9]{64}$"}))})),WQ=$(J.Object({id:J.String(),displayName:J.Optional(J.String()),provider:J.String(),model:J.String(),contextWindow:J.Optional(J.Number()),maxTokens:J.Optional(J.Number()),reasoning:J.Optional(J.Boolean()),supportedReasoningEfforts:J.Optional(J.Array(B(["off","minimal","low","medium","high","xhigh","max"]))),supportedServiceTiers:J.Optional(J.Array(B(["standard","fast","flex"]))),supportedResponseVerbosities:J.Optional(J.Array(B(["low","medium","high"]))),communicationStyles:J.Optional(J.Array(OJ,{maxItems:36})),input:J.Optional(J.Array(B(["text","image"]))),overrides:J.Optional(J.Object({baseUrl:J.Optional(J.String()),temperature:J.Optional(J.Number()),maxOutputTokens:J.Optional(J.Number()),timeout:J.Optional(J.Number()),streamIdleTimeout:J.Optional(J.Number({minimum:1000}))}))})),XQ=$(B(["vs-dark","vs-light","hc-black"])),bJ=$(B(["light","dark","system"])),wJ=$(J.Object({language:J.String(),codeTheme:J.String(),uiTheme:bJ,autoSaveSessions:J.Boolean(),notifyBuild:J.Boolean(),notifyErrors:J.Boolean(),notifySounds:J.Boolean(),privacyTelemetry:J.Boolean(),privacyCrash:J.Boolean(),communicationStyle:J.Optional(b)})),YQ=$(J.Partial(wJ));var o=i("Service"),DJ=1;function FJ(){return a.join(s(),"schedules.json")}class I{filePath;static instance;static getInstance(){if(!I.instance)I.instance=new I;return I.instance}writeChain=Promise.resolve();constructor(Q=FJ()){this.filePath=Q}async readFile(){try{let Q=await PJ(this.filePath,"utf-8"),Z=JSON.parse(Q);if(!Z||!Array.isArray(Z.schedules))return[];let W=[],K=0;for(let X of Z.schedules){let Y=C.safeParse(X);if(Y.success)W.push(Y.data);else K+=1}if(K>0)o.warn(`[ScheduleStore] Ignored ${K} invalid persisted schedule(s)`);return W}catch(Q){let Z=Q;if(Z.code!=="ENOENT")o.warn("[ScheduleStore] Failed to read schedules; treating as empty:",Z);return[]}}async writeFile(Q){await LJ(a.dirname(this.filePath),{recursive:!0,mode:493});let Z={version:DJ,schedules:Q};await IJ(this.filePath,JSON.stringify(Z,null,2),{mode:384})}serializeWrite(Q){let Z=this.writeChain.then(Q,Q);return this.writeChain=Z.then(()=>{return},()=>{return}),Z}async list(){return this.readFile()}async get(Q){return(await this.readFile()).find((W)=>W.id===Q)}async create(Q){return this.serializeWrite(async()=>{let Z=Q.trigger.kind==="cron"&&!Q.trigger.timezone?{...Q.trigger,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone}:Q.trigger,W=_(Z);if(W)throw Error(W);let K=new Date;if(Z.kind==="once"&&new Date(Z.runAt).getTime()<=K.getTime())throw Error("once trigger runAt must be in the future");let X=K.toISOString(),Y=A(Z,K),V={id:MJ(10),title:Q.title,prompt:Q.prompt,projectPath:Q.projectPath,trigger:Z,dispatch:{modelId:Q.modelId,reasoningEffort:Q.reasoningEffort,serviceTier:Q.serviceTier,responseVerbosity:Q.responseVerbosity,communicationStyle:Q.communicationStyle,isolation:Q.isolation??"worktree",permissionMode:Q.permissionMode??"default"},enabled:Q.enabled??!0,createdAt:X,updatedAt:X,nextRunAt:Y?Y.toISOString():null,expiresAt:null,runCount:0},G=await this.readFile();return G.push(V),await this.writeFile(G),V})}async update(Q,Z){return this.serializeWrite(async()=>{let W=await this.readFile(),K=W.findIndex((H)=>H.id===Q);if(K===-1)return;let X=W[K];if(Z.trigger){let H=Z.trigger.kind==="cron"&&!Z.trigger.timezone?{...Z.trigger,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone}:Z.trigger,k=_(H);if(k)throw Error(k);if(H.kind==="once"&&new Date(H.runAt).getTime()<=Date.now())throw Error("once trigger runAt must be in the future");Z={...Z,trigger:H}}let Y={...X,...Z,dispatch:Z.dispatch?{...X.dispatch,...Z.dispatch}:X.dispatch,updatedAt:new Date().toISOString()},V=!X.enabled,G=Y.enabled,j=Z.trigger!==void 0;if((j||V&&G)&&Z.nextRunAt===void 0){let H=new Date,k=A(Y.trigger,H);if(Y.nextRunAt=k?k.toISOString():null,j)Y.expiresAt=null}return W[K]=Y,await this.writeFile(W),Y})}async remove(Q){return this.serializeWrite(async()=>{let Z=await this.readFile(),W=Z.filter((K)=>K.id!==Q);if(W.length===Z.length)return!1;return await this.writeFile(W),!0})}async setEnabled(Q,Z){return this.update(Q,{enabled:Z})}}var IQ=I.getInstance();
|
|
2
|
-
export{zJ as xa,A as ya,_ as za,AJ as Aa,fJ as Ba,z as Ca,uJ as Da,mJ as Ea,iJ as Fa,aJ as Ga,tJ as Ha,rJ as Ia,C as Ja,TJ as Ka,yJ as La,pJ as Ma,eJ as Na,JQ as Oa,ZQ as Pa,I as Qa,IQ as Ra};
|
package/dist/chunk-wj6t3tv2.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{rh as X}from"./chunk-jrr361h1.js";import{Ah as T}from"./chunk-8wea3qty.js";import{createHash as _}from"node:crypto";import{constants as N,promises as B}from"node:fs";import A from"node:os";import F from"node:path";import{Mutex as w}from"async-mutex";import{LRUCache as k}from"lru-cache";import j from"write-file-atomic";var O=1,S=65536,D=1048576,U=100,R=64;function r(q){return q.state==="trusted"||q.state==="not_required"}function b(q){return q!==null&&typeof q==="object"&&!Array.isArray(q)}function C(q,Q=2048){return q.length<=Q?q:`${q.slice(0,Q-1)}…`}function M(q){if(typeof q!=="string"||!q.trim())return;try{let Q=new URL(q);return C(`${Q.origin}${Q.pathname}`)}catch{return C(q)}}function I(q){return Array.isArray(q)?q.filter((Q)=>typeof Q==="string"):[]}function m(q){if(!b(q))return[];return Object.entries(q).slice(0,U).map(([Q,Z])=>{let $=b(Z)?Z:{},H=typeof $.type==="string"?$.type:"unknown",G=typeof $.command==="string"?$.command:void 0,J=I($.args),L=H==="stdio"?C([G,...J].filter(Boolean).join(" ")):M($.url);return{kind:"mcp",name:`${Q} (${H})`,...L?{target:L}:{}}})}function E(q){if(!b(q))return[];return Object.entries(q).slice(0,U).map(([Q,Z])=>{let $=b(Z)?Z:{},H=typeof $.command==="string"?C($.command):void 0,G=b($.extensionToLanguage)?Object.keys($.extensionToLanguage).slice(0,12).join(", "):"unknown extensions";return{kind:"lsp",name:`${Q} (${G})`,...H?{target:H}:{}}})}function g(q){if(!Array.isArray(q))return[];return q.slice(0,U).flatMap((Q)=>{if(!b(Q))return[];let Z=typeof Q.id==="string"?Q.id:"unnamed",$=typeof Q.provider==="string"?Q.provider:"unknown",H=typeof Q.model==="string"?Q.model:"unknown",G=b(Q.overrides)?Q.overrides:{},J=M(G.baseUrl);return[{kind:"model",name:`${Z}: ${$}/${H}`,...J?{target:J}:{}}]})}function P(q){if(!b(q))return[];return Object.entries(q).slice(0,U).map(([Q,Z])=>{let $=b(Z)?Z:{},H=typeof $.wireApi==="string"?$.wireApi:"unknown",G=M($.baseUrl);return{kind:"model",name:`${Q} (${H})`,...G?{target:G}:{}}})}function y(q){if(!b(q))return[];let Q=[];for(let Z of["allow","ask","deny"])for(let $ of I(q[Z]).slice(0,U))Q.push({kind:"permission",name:`${Z}: ${C($,512)}`});return Q}function f(q){let Q=[...m(q.mcpServers),...E(q.lspServers),...g(q.models),...P(q.modelProviders),...y(q.permissions)];if(b(q.env))for(let Z of Object.keys(q.env).slice(0,U))Q.push({kind:"environment",name:Z});if(typeof q.permissionMode==="string")Q.push({kind:"permission",name:`permissionMode: ${q.permissionMode}`});return Q}function h(q){return q!=="hooks"&&q!=="disableAllHooks"}function v(q){return _("sha256").update(q).digest("hex")}function l(q,Q){let Z=F.relative(q,Q);return Z===""||!Z.startsWith(`..${F.sep}`)&&Z!==".."&&!F.isAbsolute(Z)}class x{storeDir;static instance=null;mutex=new w;statusCache=new k({max:R});constructor(q=F.join(T(),"workspace-trust")){this.storeDir=q}static getInstance(){if(!x.instance)x.instance=new x;return x.instance}static resetInstance(){x.instance=null}async getStatus(q){let Q=await X(q),Z;try{Z=await this.discoverSensitiveSources(Q.projectPath)}catch(Y){let V={...Q,state:"error",sensitiveSources:0,sources:[],decision:"undecided",error:Y instanceof Error?Y.message:"Workspace trust review failed"};return this.cacheStatus(q,V),V}if(Z.length===0){let Y={...Q,state:"not_required",sensitiveSources:0,sources:Z,decision:"undecided"};return this.cacheStatus(q,Y),Y}let $;try{$=await this.readDecisions()}catch(Y){let V={...Q,state:"error",sensitiveSources:Z.length,sources:Z,decision:"undecided",error:Y instanceof Error?Y.message:"Workspace trust store is unavailable"};return this.cacheStatus(q,V),V}let H=$.filter((Y)=>l(Y.path,Q.trustRoot)),G=Math.max(-1,...H.map((Y)=>Y.path.split(F.sep).length)),J=H.filter((Y)=>Y.path.split(F.sep).length===G),L=J.length>0&&J.every((Y)=>Y.trusted),z=J[0],K=z?.path===Q.trustRoot,W={...Q,state:L?"trusted":"untrusted",sensitiveSources:Z.length,sources:Z,decision:z?K?z.trusted?"trusted":"untrusted":"inherited":"undecided",...z?.decidedAt?{decidedAt:z.decidedAt}:{},...!K&&z?.path?{inheritedFrom:z.path}:{}};return this.cacheStatus(q,W),W}cacheStatus(q,Q){this.statusCache.set(F.resolve(q),Q),this.statusCache.set(Q.projectPath,Q)}getCachedStatus(q){return this.statusCache.get(F.resolve(q))}isTrustedCached(q){return this.getCachedStatus(q)?.state==="trusted"}getCacheStats(){return{capacity:R,entries:this.statusCache.size}}async trust(q){return this.recordDecision(q,!0)}async revoke(q){return this.recordDecision(q,!1)}async recordDecision(q,Q){return this.mutex.runExclusive(async()=>{let Z=await X(q);await this.assertSafeTrustRoot(Z);let $={version:O,path:Z.trustRoot,trusted:Q,decidedAt:new Date().toISOString()};return await this.writeDecision($),this.statusCache.clear(),this.getStatus(q)})}async assertSafeTrustRoot(q){let Q=F.parse(q.trustRoot).root,Z=await B.realpath(A.homedir()).catch(()=>F.resolve(A.homedir()));if(!F.isAbsolute(q.trustRoot)||q.trustRoot===Q||q.trustRoot===Z)throw Error("Refusing to trust the filesystem root or user home directory")}async discoverSensitiveSources(q){let Q=[],Z=await this.reviewPackageScripts(q);if(Z)Q.push(Z);for(let[$,H]of[[".blade/config.json","config"],[".blade/settings.json","settings"],[".blade/settings.local.json","settings"]]){let G=await this.reviewConfigFile(q,$,H);if(G)Q.push(G)}for(let $ of[".blade/plugins",".claude/plugins"]){let H=await this.reviewResourceDirectory(q,$,"plugins","plugin");if(H)Q.push(H)}for(let $ of[".blade/commands",".claude/commands"]){let H=await this.reviewResourceDirectory(q,$,"commands","command");if(H)Q.push(H)}for(let[$,H,G]of[[".blade/skills","skills","skill"],[".claude/skills","skills","skill"],[".blade/agents","agents","agent"],[".claude/agents","agents","agent"]]){let J=await this.reviewResourceDirectory(q,$,H,G);if(J)Q.push(J)}for(let $ of["CLAUDE.md","AGENTS.md","BLADE.md"]){let H=await this.reviewInstructionFile(q,$);if(H)Q.push(H)}return Q}async reviewPackageScripts(q){let Q=F.join(q,"package.json"),Z;try{Z=await B.stat(Q)}catch(J){if(J.code==="ENOENT")return;throw J}if(!Z.isFile())return;if(Z.size>D)throw Error("package.json exceeds the 1 MiB workspace review limit");let $;try{$=JSON.parse(await B.readFile(Q,"utf8"))}catch{return{path:"package.json",kind:"package",keys:[],effects:[],warning:"Invalid package.json; project scripts will remain blocked"}}if(!b($)||!b($.scripts))return;let H=$.scripts,G=Object.keys(H).filter((J)=>typeof H[J]==="string").sort().slice(0,U);if(G.length===0)return;return{path:"package.json",kind:"package",keys:G,effects:G.map((J)=>({kind:"command",name:`package script: ${J}`}))}}async reviewInstructionFile(q,Q){try{if(!(await B.stat(F.join(q,Q))).isFile())return}catch(Z){if(Z.code==="ENOENT")return;throw Z}return{path:Q,kind:"instructions",keys:[Q],effects:[{kind:"instruction",name:Q}]}}async reviewConfigFile(q,Q,Z){let $=F.join(q,Q),H;try{H=await B.stat($)}catch(K){if(K.code==="ENOENT")return;throw K}if(!H.isFile())return;if(H.size>D)throw Error(`${Q} exceeds the 1 MiB workspace review limit`);let G;try{G=JSON.parse(await B.readFile($,"utf8"))}catch{return{path:Q,kind:Z,keys:[],effects:[],warning:"Invalid JSON; the file will remain blocked"}}if(!b(G))return{path:Q,kind:Z,keys:[],effects:[],warning:"Configuration root is not an object"};let J=Object.keys(G).filter(h).sort();if(J.length===0)return;let L=f(G),z=new Set(["mcpServers","lspServers","models","modelProviders","permissions","env","permissionMode"]);for(let K of J)if(!z.has(K))L.push({kind:"configuration",name:K});return{path:Q,kind:Z,keys:J,effects:L}}async reviewResourceDirectory(q,Q,Z,$){let H=F.join(q,Q),G;try{G=await B.readdir(H,{withFileTypes:!0})}catch(L){if(L.code==="ENOENT")return;throw L}let J=G.filter((L)=>Z==="plugins"||Z==="skills"?L.isDirectory()||L.isSymbolicLink():L.isFile()||L.isDirectory()||L.isSymbolicLink()).slice(0,U);if(J.length===0)return;return{path:Q,kind:Z,keys:J.map((L)=>L.name),effects:J.map((L)=>({kind:$,name:L.name}))}}async readDecisions(){let q;try{q=await B.lstat(this.storeDir)}catch($){if($.code==="ENOENT")return[];throw $}if(!q.isDirectory()||q.isSymbolicLink())throw Error("Workspace trust store must be a regular directory");if(process.getuid&&q.uid!==process.getuid())throw Error("Workspace trust store must be owned by the current user");if((q.mode&511)!==448)throw Error("Workspace trust store permissions must be 0700");let Q=await B.readdir(this.storeDir,{withFileTypes:!0}),Z=[];for(let $ of Q){if(!$.name.endsWith(".json"))continue;if(!$.isFile())throw Error("Workspace trust store entries must be regular files");Z.push(await this.readDecision(F.join(this.storeDir,$.name)))}return Z}async readDecision(q){let Q;try{Q=await B.open(q,N.O_RDONLY|N.O_NOFOLLOW)}catch{throw Error("Workspace trust decision must be a regular file")}try{let Z=await Q.stat();if(!Z.isFile()||Z.size>S)throw Error("Workspace trust decision is invalid");if(process.getuid&&Z.uid!==process.getuid())throw Error("Workspace trust decisions must be owned by the current user");if((Z.mode&511)!==384)throw Error("Workspace trust decision permissions must be 0600");let $=JSON.parse(await Q.readFile("utf8"));if(!b($)||$.version!==O||typeof $.path!=="string"||!F.isAbsolute($.path)||typeof $.trusted!=="boolean"||typeof $.decidedAt!=="string"||!Number.isFinite(Date.parse($.decidedAt))||Object.keys($).some((H)=>H!=="version"&&H!=="path"&&H!=="trusted"&&H!=="decidedAt"))throw Error("Workspace trust decision schema is invalid");return{version:O,path:$.path,trusted:$.trusted,decidedAt:$.decidedAt}}finally{await Q.close()}}async writeDecision(q){await this.ensureStoreDirectoryForWrite();let Q=F.join(this.storeDir,`${v(q.path)}.json`);try{let Z=await B.lstat(Q);if(!Z.isFile()||Z.isSymbolicLink())throw Error("Workspace trust decision must be a regular file");if(process.getuid&&Z.uid!==process.getuid())throw Error("Workspace trust decisions must be owned by the current user");if((Z.mode&511)!==384)throw Error("Workspace trust decision permissions must be 0600")}catch(Z){if(Z.code!=="ENOENT")throw Z}await j(Q,`${JSON.stringify(q,null,2)}
|
|
2
|
-
`,{mode:384}),await B.chmod(Q,384)}async ensureStoreDirectoryForWrite(){try{let q=await B.lstat(this.storeDir);if(!q.isDirectory()||q.isSymbolicLink())throw Error("Workspace trust store must be a regular directory");if(process.getuid&&q.uid!==process.getuid())throw Error("Workspace trust store must be owned by the current user");if((q.mode&511)!==448)throw Error("Workspace trust store permissions must be 0700")}catch(q){if(q.code!=="ENOENT")throw q;await B.mkdir(this.storeDir,{recursive:!0,mode:448}),await B.chmod(this.storeDir,448)}}}
|
|
3
|
-
export{R as oh,r as ph,x as qh};
|
package/dist/chunk-xz6y0w4n.js
DELETED
package/dist/chunk-ysmqje92.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{bd as a,cd as b,dd as c,ed as d,fd as e,gd as f,hd as g,id as h}from"./chunk-f7yfcw8s.js";import"./chunk-d808m826.js";import"./chunk-8wea3qty.js";import"./chunk-k6shq7rk.js";export{d as syncSession,e as syncAll,h as searchProjectionText,c as resetProjectionDbCache,f as removeSessionFromProjection,g as rebuildProjectionIndex,b as getProjectionDb,a as getIndexDbPath};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownRenderer-Da1vB81L.js","assets/index-BOgOL4hG.js","assets/vendor-react-DG5dkZ_t.js","assets/vendor-radix-DXRuAJHH.js","assets/vendor-icons-B63aW_OM.js","assets/session-events-BvtUOaNG.js","assets/index-DbWgTuT3.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as b,j as e}from"./vendor-react-DG5dkZ_t.js";import{u as F,a as y,b as ge,s as Fe,c as qe,d as Q,D as $e,e as De,f as ze,g as Be,h as Ie,i as _e,j as T,k as U,B as xe,_ as Ge,S as We,l as Je,m as Qe,C as Ye,n as Xe}from"./index-BOgOL4hG.js";import{U as we,Q as Ze,G as et,Z as tt,L as R,E as st,T as se,C as ne,_ as at,w as rt,$ as nt,B as it,a0 as Pe,z as ie,n as ve,R as ke,t as ot,H as ct,a1 as Ve,V as lt,a2 as dt,a3 as ut,a4 as mt,P as Le,a5 as ht,X as xt,a6 as pt,a7 as ft,f as Oe,a8 as bt,W as gt,a as vt}from"./vendor-icons-B63aW_OM.js";import{k as kt,g as jt,l as yt,e as wt,t as Nt,j as St}from"./session-events-BvtUOaNG.js";import{j as Ct,k as Et,l as Tt,m as Ue}from"./vendor-radix-DXRuAJHH.js";function Ne(t){return t.split("/").filter(Boolean).at(-1)||t}function Mt(){const t=F(),s=y(S=>S.sessions),a=y(S=>S.currentSessionRef),r=y(S=>S.taskDeliveryActions),i=y(S=>S.deliverTask),n=ge(S=>S.openFilePreview),[d,f]=b.useState(!1),l=s.find(S=>Fe({sessionId:S.sessionId,projectPath:S.projectPath},a));if(!(l!=null&&l.taskIsolation))return null;const c=l.taskDiffStat,k=l.taskIsolation==="worktree",o=qe(l),h=r[Q(o)],u=l.taskDelivery,j=(u==null?void 0:u.status)==="conflicted",N=!!(c&&(c.changedFiles>0||c.commits>0)),m=!["queued","running"].includes(l.taskStatus),w=(u==null?void 0:u.status)==="applied"||(u==null?void 0:u.status)==="discarded",v=k&&N&&m&&!w,p=c?c.additions+c.deletions:0,x=p>0&&c?c.additions/p*100:0,E=S=>{i(o,S).catch(()=>{})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex min-h-10 flex-wrap items-center gap-x-3 gap-y-1.5 border-b border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))]/60 px-3 py-1.5 font-mono text-[10.5px] text-[hsl(var(--deck-ink-muted))] backdrop-blur-sm sm:px-5",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[e.jsx(we,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"truncate text-[hsl(var(--deck-ink))]",children:Ne(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:[k?e.jsx(Ze,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-accent))]"}):e.jsx(we,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:k?"text-[hsl(var(--deck-accent))]":void 0,children:t(k?"artifact.env.isolated":"artifact.env.local")})]}),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(et,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"truncate",children:l.taskWorktreeBranch})]})]})]}),c&&e.jsxs("div",{className:"ml-auto flex max-w-full items-center gap-2",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 text-[hsl(var(--deck-ink-muted))]",children:[e.jsx(tt,{className:"h-3 w-3 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"tabular-nums",children:c.changedFiles})]}),p>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:`${x}%`}}),e.jsx("span",{className:"h-full bg-red-500/80",style:{width:`${100-x}%`}})]}),e.jsxs("span",{className:"tabular-nums text-[hsl(var(--deck-accent))]",children:["+",c.additions]}),e.jsxs("span",{className:"tabular-nums text-red-600 dark:text-red-400",children:["-",c.deletions]}),c.commits>0&&e.jsx("span",{className:"hidden tabular-nums text-[hsl(var(--deck-ink-faint))] sm:inline",children:t("artifact.commits",{count:c.commits})}),N&&(u==null?void 0:u.status)!=="discarded"&&e.jsx("button",{type:"button",onClick:()=>n({tab:"diff"}),className:"inline-flex items-center gap-1 rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-2 py-1 text-[hsl(var(--deck-ink))] transition hover:border-[hsl(var(--deck-accent)/0.55)] hover:text-[hsl(var(--deck-accent))]",children:t("artifact.review")}),v&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",disabled:!!h,onClick:()=>E("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:[h==="apply"?e.jsx(R,{className:"h-3 w-3 animate-spin"}):e.jsx(st,{className:"h-3 w-3"}),t(h==="apply"?"artifact.applying":j?"artifact.retryApply":"artifact.apply")]}),e.jsx("button",{type:"button",disabled:!!h,onClick:()=>f(!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:h==="discard"?e.jsx(R,{className:"h-3 w-3 animate-spin"}):e.jsx(se,{className:"h-3 w-3"})})]}),(u==null?void 0:u.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(ne,{className:"h-3 w-3"}),t("artifact.applied")]}),(u==null?void 0:u.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(se,{className:"h-3 w-3"}),t("artifact.discarded")]})]}),(u==null?void 0:u.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(at,{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:u.message||t("artifact.conflict")}),e.jsx("span",{className:"block text-[hsl(var(--deck-ink-faint))]",children:t("artifact.conflictHint")})]})]})]}),e.jsx($e,{open:d,onOpenChange:f,children:e.jsxs(De,{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(ze,{children:[e.jsx(Be,{children:t("artifact.discardDialog.title")}),e.jsx(Ie,{className:"text-[hsl(var(--deck-ink-muted))]",children:t("artifact.discardDialog.description",{project:Ne(l.taskSourceProjectPath||l.projectPath),count:(c==null?void 0:c.changedFiles)??0})})]}),e.jsx("div",{className:"rounded-lg border border-red-500/20 bg-red-500/5 px-3 py-2 text-xs leading-relaxed text-red-700 dark:text-red-300",children:t("artifact.discardDialog.warning")}),e.jsxs(_e,{className:"gap-2 sm:space-x-0",children:[e.jsx("button",{type:"button",onClick:()=>f(!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:()=>{f(!1),E("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(se,{className:"h-3.5 w-3.5"}),t("artifact.discardDialog.confirm")]})]})]})})]})}const At=new Set(["completed","stale","failed","aborted","interrupted"]),Rt={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"},Ft={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 ae(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:void 0}function $t(t){const s=ae(t),a=ae(s==null?void 0:s.codeLocation),r=s==null?void 0:s.priority,i=s==null?void 0:s.confidenceScore,n=a==null?void 0:a.lineStart,d=a==null?void 0:a.lineEnd;if(!(typeof(s==null?void 0:s.title)!="string"||typeof s.body!="string"||r!==0&&r!==1&&r!==2&&r!==3||typeof i!="number"||!Number.isFinite(i)||typeof(a==null?void 0:a.path)!="string"||!Number.isInteger(n)||!Number.isInteger(d)))return{title:s.title,body:s.body,priority:r,confidenceScore:i,codeLocation:{path:a.path,lineStart:n,lineEnd:d}}}function Dt(t){const s=ae(t),a=ae(s==null?void 0:s.target);if((s==null?void 0:s.phase)!=="completed"||typeof s.status!="string"||!At.has(s.status)||typeof(a==null?void 0:a.label)!="string"||a.kind!=="uncommitted"&&a.kind!=="base"&&a.kind!=="commit"||typeof s.overallExplanation!="string"||!Array.isArray(s.findings))return;const r=s.findings.map($t);if(!r.some(i=>i===void 0))return{status:s.status,target:{kind:a.kind,label:a.label,...typeof a.reference=="string"?{reference:a.reference}:{}},overallExplanation:s.overallExplanation,findings:r,...typeof s.error=="string"?{error:s.error}:{}}}function Bt(t){const{path:s,lineStart:a,lineEnd:r}=t.codeLocation;return a===r?`${s}:L${a}`:`${s}:L${a}-${r}`}function It({report:t}){const s=F(),a=t.target.kind==="uncommitted"?s("chat.review.target.uncommitted"):t.target.kind==="base"?s("chat.review.target.base",{ref:t.target.reference??t.target.label}):s("chat.review.target.commit",{ref:t.target.reference??t.target.label});return e.jsxs("section",{"data-code-review-report":!0,className:"overflow-hidden rounded-xl border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsxs("header",{className:"flex flex-wrap items-center justify-between gap-3 border-b border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-surface-2))]/60 px-4 py-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-[13px] font-semibold text-[hsl(var(--deck-ink))]",children:s("chat.review.title")}),e.jsxs("p",{className:"mt-0.5 font-mono text-[10.5px] text-[hsl(var(--deck-ink-faint))]",children:[s("chat.review.target"),": ",a]})]}),e.jsxs("span",{className:T("rounded-full border px-2.5 py-1 font-mono text-[10.5px] font-medium",Ft[t.status]),children:[s("chat.review.status"),": ",s(Rt[t.status])]})]}),e.jsxs("div",{className:"space-y-4 px-4 py-3.5",children:[e.jsx("p",{className:"whitespace-pre-wrap text-[13px] leading-6 text-[hsl(var(--deck-ink-muted))]",children:t.overallExplanation}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("h4",{className:"deck-eyebrow text-[hsl(var(--deck-ink-faint))]",children:s("chat.review.findings")}),e.jsx("span",{className:"font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:t.findings.length})]}),t.findings.length===0?e.jsx("div",{className:"rounded-lg bg-[hsl(var(--deck-surface-2))] px-3 py-2.5 text-[12px] text-[hsl(var(--deck-ink-muted))]",children:s("chat.review.noFindings")}):e.jsx("ol",{className:"space-y-2",children:t.findings.map((r,i)=>e.jsxs("li",{className:"rounded-lg border border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))] px-3 py-2.5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[e.jsx("h5",{className:"text-[12.5px] font-medium leading-5 text-[hsl(var(--deck-ink))]",children:r.title}),e.jsx("span",{className:"shrink-0 font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:s("chat.review.confidence",{value:r.confidenceScore.toFixed(2)})})]}),e.jsx("code",{className:"mt-1 block text-[10.5px] text-[hsl(var(--deck-accent))]",children:Bt(r)}),e.jsx("p",{className:"mt-1.5 whitespace-pre-wrap text-[12px] leading-5 text-[hsl(var(--deck-ink-muted))]",children:r.body})]},`${r.codeLocation.path}:${r.codeLocation.lineStart}:${i}`))})]}),t.error&&e.jsxs("div",{className:"rounded-lg border border-red-500/20 bg-red-500/5 px-3 py-2 text-[11px] text-red-700 dark:text-red-300",children:[e.jsxs("span",{className:"font-medium",children:[s("chat.review.error"),":"]})," ",t.error]})]})]})}function _t({elicitation:t,messageId:s}){const a=F(),r=y(v=>v.currentSessionRef),i=y(v=>v.setElicitation),[n,d]=b.useState(()=>Vt(t.details.fields??[])),[f,l]=b.useState(()=>Lt(t.details.fields??[])),[c,k]=b.useState(!1),[o,h]=b.useState(),u=t.details.fields??[],j=b.useMemo(()=>u.every(v=>{var x;if(!v.required)return!0;if(oe(v))return!!((x=f[v.name])!=null&&x.trim()||v.defaultValue!==void 0);const p=n[v.name]??v.defaultValue;return Array.isArray(p)?p.length>0:p!==void 0}),[u,f,n]);if(t.status!=="pending")return e.jsx("div",{className:"rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-3 py-2 font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:a(t.status==="cancelled"?"interaction.elicitation.cancelled":"interaction.elicitation.responded")});const N=async(v,p)=>{if(!(!r||c)){k(!0),h(void 0);try{await U.respondToElicitation(r,t.toolCallId,{action:v,...p?{content:p}:{}}),i(s,{...t,status:"responded"})}catch(x){h(x instanceof Error?x.message:a("interaction.elicitation.failed"))}finally{k(!1)}}},m=async()=>{try{await N("accept",Ot(u,n,f))}catch(v){h(v instanceof Error?v.message:String(v))}},w=()=>{const v=t.details.url;if(!v){h("MCP URL is unavailable");return}if(!window.open(v,"_blank","noopener,noreferrer")){h("The browser blocked the external window");return}N("accept")};return e.jsxs("div",{"data-pending-interaction":"elicitation",tabIndex:-1,role:"alert",className:"space-y-4 rounded-lg border border-amber-300/70 bg-amber-50/70 p-4 outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-800/70 dark:bg-amber-950/25",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(rt,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400"}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("div",{className:"font-mono text-[12px] font-semibold text-[hsl(var(--deck-ink))]",children:[a("interaction.elicitation.title")," · ",t.details.serverName]}),e.jsx("div",{className:"font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:t.details.message}),e.jsx("div",{className:"font-mono text-[11px] text-amber-700 dark:text-amber-300",children:a("interaction.elicitation.warning")})]})]}),t.details.mode==="url"?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] p-3 font-mono text-[11px]",children:[e.jsx("div",{className:"text-[hsl(var(--deck-ink-muted))]",children:t.details.domain}),e.jsx("div",{className:"mt-1 break-all text-[hsl(var(--deck-ink))]",children:t.details.url})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(q,{onClick:w,disabled:c,primary:!0,label:a("interaction.elicitation.open"),icon:e.jsx(nt,{className:"h-3.5 w-3.5"})}),e.jsx(q,{onClick:()=>void N("decline"),disabled:c,label:a("interaction.elicitation.decline")}),e.jsx(q,{onClick:()=>void N("cancel"),disabled:c,label:a("interaction.elicitation.cancel")})]})]}):e.jsxs("div",{className:"space-y-4",children:[u.map(v=>e.jsx(Pt,{field:v,value:n[v.name],rawValue:f[v.name]??"",onValueChange:p=>d(x=>({...x,[v.name]:p})),onRawChange:p=>l(x=>({...x,[v.name]:p}))},v.name)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(q,{onClick:()=>void m(),disabled:c||!j,primary:!0,label:a("interaction.elicitation.submit"),icon:c?e.jsx(R,{className:"h-3.5 w-3.5 animate-spin"}):null}),e.jsx(q,{onClick:()=>void N("decline"),disabled:c,label:a("interaction.elicitation.decline")}),e.jsx(q,{onClick:()=>void N("cancel"),disabled:c,label:a("interaction.elicitation.cancel")})]})]}),o&&e.jsx("div",{className:"rounded-md border border-red-300/70 bg-red-50 px-2.5 py-2 font-mono text-[11px] text-red-700 dark:border-red-900/70 dark:bg-red-950/35 dark:text-red-300",children:o})]})}function Pt({field:t,value:s,rawValue:a,onValueChange:r,onRawChange:i}){return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{htmlFor:`mcp-elicitation-${t.name}`,className:"block font-mono text-[12px] font-medium text-[hsl(var(--deck-ink))]",children:[t.title,t.required?" *":""]}),t.description&&e.jsx("div",{className:"font-mono text-[11px] text-[hsl(var(--deck-ink-faint))]",children:t.description}),t.type==="select"||t.type==="multi-select"||t.type==="boolean"?e.jsx("div",{id:`mcp-elicitation-${t.name}`,className:"flex flex-wrap gap-2",children:Ut(t).map(n=>{const d=Array.isArray(s)?s.includes(n.value):s===n.typedValue;return e.jsx("button",{type:"button","aria-pressed":d,onClick:()=>{if(t.type==="multi-select"){const f=Array.isArray(s)?s:[];r(f.includes(n.value)?f.filter(l=>l!==n.value):[...f,n.value])}else r(n.typedValue)},className:T("rounded-md border px-3 py-2 font-mono text-[12px] transition-colors",d?"border-emerald-500 bg-emerald-50 text-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-200":"border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] text-[hsl(var(--deck-ink-muted))] hover:text-[hsl(var(--deck-ink))]"),children:n.label},n.value)})}):e.jsx("input",{id:`mcp-elicitation-${t.name}`,type:Ht(t),value:a,onChange:n=>i(n.target.value),min:t.minimum,max:t.maximum,minLength:t.minLength,maxLength:t.maxLength,required:t.required,placeholder:t.defaultValue===void 0?t.required?"Required":"Optional":String(t.defaultValue),className:"w-full rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-3 py-2 font-mono text-[12px] text-[hsl(var(--deck-ink))] outline-none transition-colors focus:border-amber-500 focus:ring-1 focus:ring-amber-500"})]})}function q({onClick:t,disabled:s,primary:a=!1,label:r,icon:i}){return e.jsxs("button",{type:"button",onClick:t,disabled:s,className:T("inline-flex min-h-8 items-center gap-1.5 rounded-md px-3 py-1.5 font-mono text-[12px] transition-colors disabled:cursor-wait disabled:opacity-50",a?"bg-amber-600 text-white hover:bg-amber-700":"border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] text-[hsl(var(--deck-ink-muted))] hover:text-[hsl(var(--deck-ink))]"),children:[i,r]})}function Vt(t){return Object.fromEntries(t.filter(s=>!oe(s)&&s.defaultValue!==void 0).map(s=>[s.name,Array.isArray(s.defaultValue)?[...s.defaultValue]:s.defaultValue]))}function Lt(t){return Object.fromEntries(t.filter(s=>oe(s)&&s.defaultValue!==void 0).map(s=>[s.name,String(s.defaultValue)]))}function Ot(t,s,a){var i;const r={};for(const n of t){if(oe(n)){const f=((i=a[n.name])==null?void 0:i.trim())??"";if(!f){if(n.defaultValue!==void 0)r[n.name]=n.defaultValue;else if(n.required)throw new Error(`${n.title} is required`);continue}if(n.type==="number"||n.type==="integer"){const l=Number(f);if(!Number.isFinite(l))throw new Error(`${n.title} must be a finite number`);if(n.type==="integer"&&!Number.isSafeInteger(l))throw new Error(`${n.title} must be a safe integer`);r[n.name]=l}else r[n.name]=f;continue}const d=s[n.name]??n.defaultValue;if(d===void 0){if(n.required)throw new Error(`${n.title} is required`);continue}if(Array.isArray(d)){if(n.minItems!==void 0&&d.length<n.minItems)throw new Error(`${n.title} requires at least ${n.minItems} choices`);if(n.maxItems!==void 0&&d.length>n.maxItems)throw new Error(`${n.title} allows at most ${n.maxItems} choices`)}r[n.name]=d}return r}function Ut(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 oe(t){return t.type==="string"||t.type==="number"||t.type==="integer"}function Ht(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 Kt(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 qt({report:t}){const s=F(),[a,r]=b.useState(!1),i=JSON.stringify(t.output,null,2),n=async()=>{try{await navigator.clipboard.writeText(i),r(!0),window.setTimeout(()=>r(!1),1400)}catch{}};return e.jsxs("section",{"data-structured-output":!0,className:"overflow-hidden rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsxs("header",{className:"flex min-h-9 items-center justify-between gap-3 border-b border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(it,{className:"h-3.5 w-3.5 shrink-0 text-[hsl(var(--deck-accent))]"}),e.jsx("span",{className:"font-mono text-[11px] font-semibold text-[hsl(var(--deck-ink))]",children:s("chat.structuredOutput.title")}),t.schemaDigest&&e.jsxs("span",{title:t.schemaDigest,className:"truncate font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:["sha256:",t.schemaDigest.slice(0,10)]})]}),e.jsx("button",{type:"button",onClick:n,"aria-label":s("chat.structuredOutput.copy"),title:s("chat.structuredOutput.copy"),className:"flex h-6 w-6 shrink-0 items-center justify-center rounded text-[hsl(var(--deck-ink-faint))] hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:a?e.jsx(ne,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}):e.jsx(Pe,{className:"h-3.5 w-3.5"})})]}),e.jsx("pre",{className:"max-h-[440px] overflow-auto whitespace-pre p-3 font-mono text-[11px] leading-5 text-[hsl(var(--deck-ink))]",children:i})]})}const zt=b.lazy(()=>Ge(()=>import("./MarkdownRenderer-Da1vB81L.js").then(t=>t.M),__vite__mapDeps([0,1,2,3,4,5,6])).then(t=>({default:t.MarkdownRenderer})));function Se({text:t,label:s}){const[a,r]=b.useState(!1);if(!t.trim())return null;const i=async()=>{try{await navigator.clipboard.writeText(t),r(!0),window.setTimeout(()=>r(!1),1400)}catch{}};return e.jsx("button",{type:"button","aria-label":s,title:s,onClick:i,className:"flex h-6 w-6 items-center justify-center rounded-md text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:a?e.jsx(ne,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}):e.jsx(Pe,{className:"h-3.5 w-3.5"})})}function Gt(){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(xe,{size:20,pulse:!1})})}function Wt(){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 Ce(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 Jt(t){if(typeof t=="string")return{text:Ce(t),images:[]};const s=t.filter(r=>r.type==="text").map(r=>r.text).join(`
|
|
3
|
-
`),a=t.filter(r=>r.type==="image_url").map(r=>r.image_url.url);return{text:Ce(s),images:a}}function je(t){return typeof t=="string"?t:t.filter(s=>s.type==="text").map(s=>s.text).join(`
|
|
4
|
-
`)}function Qt(t){const s=t.agentContent;return s?kt(s):je(t.content)}function Ee({content:t,syntaxHighlight:s=!0}){return e.jsx(b.Suspense,{fallback:e.jsx("pre",{className:"text-[14px] text-[hsl(var(--deck-ink))] font-mono whitespace-pre-wrap",children:t}),children:e.jsx(zt,{content:t,syntaxHighlight:s})})}function ye({status:t}){if(!t)return null;const s={running:"bg-[#FEF3C7] text-[#92400E] dark:bg-[#F59E0B]/20 dark:text-[#FBBF24]",success:"bg-[#DCFCE7] text-[#15803D] dark:bg-[#22C55E]/20 dark:text-[#22C55E]",error:"bg-[#FEE2E2] text-[#b91c1c] dark:bg-[#EF4444]/20 dark:text-[#fca5a5]",pending:"bg-[#E5E7EB] text-[#6B7280] dark:bg-[#27272a] dark:text-[#a1a1aa]",info:"bg-[#DBEAFE] text-[#1D4ED8] dark:bg-[#3B82F6]/20 dark:text-[#60A5FA]"},a={running:"Running",success:"Success",error:"Error",pending:"Pending",info:"Info"};return e.jsx("span",{className:T("text-[11px] px-2 py-0.5 rounded-full font-mono",s[t]),children:a[t]})}function Yt(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 Te=500;function He(t,s){if(t.length<=s)return t;let a=Math.max(0,s);return a>0&&/[\uD800-\uDBFF]/.test(t.charAt(a-1))&&(a-=1),t.slice(0,a)}function Me(t,s){if(t.length<=s)return t;let a=Math.max(0,t.length-s);return/[\uDC00-\uDFFF]/.test(t.charAt(a))&&(a+=1),t.slice(a)}function de(t,s){if(t.length<=s)return t;if(s<=0)return"";const a=`
|
|
5
|
-
... (display clipped) ...
|
|
6
|
-
`,r=s-a.length;if(r<=0)return Me(t,s);const i=Math.floor(r/3);return`${He(t,i)}${a}${Me(t,r-i)}`}function Xt(t){const s=t.split(`
|
|
7
|
-
`),a=s.at(-1),r=a!=null&&a.startsWith("Output truncated")?a:void 0,i=r?s.slice(0,-1).join(`
|
|
8
|
-
`):t,n=r?`
|
|
9
|
-
${r}`:"",d=Math.max(0,Te-n.length),l=i.indexOf(`
|
|
10
|
-
stderr:
|
|
11
|
-
`);let c;if(l>=0&&i.includes(`
|
|
12
|
-
stdout:
|
|
13
|
-
`)){const k=i.slice(0,l),o=i.slice(l+1),h=Math.max(0,d-1),u=Math.floor(h/2);c=`${de(k,u)}
|
|
14
|
-
${de(o,h-u)}`}else c=de(i,d);return{body:He(c,d),...r?{notice:r}:{},truncated:!!r||t.length>Te}}function Zt({tool:t}){const[s,a]=b.useState(!1),r=Yt(t.arguments),i=t.output?Xt(t.output):void 0;return e.jsxs("div",{"data-tool-name":t.toolName,"data-tool-status":t.status,"data-tool-truncated":i!=null&&i.truncated?"true":"false",className:"bg-white dark:bg-[#18181b] border border-[hsl(var(--deck-border))] rounded-lg overflow-hidden",children:[e.jsxs("button",{type:"button","aria-expanded":s,"data-tool-call-id":t.toolCallId,onClick:()=>a(n=>!n),className:"w-full flex items-center justify-between px-3 py-2 bg-[hsl(var(--deck-surface-2))] hover:bg-[hsl(var(--deck-surface))] transition-colors",children:[e.jsxs("div",{className:"flex gap-2 items-center min-w-0",children:[s?e.jsx(ie,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))] shrink-0"}):e.jsx(ve,{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(ye,{status:t.status})]}),t.status==="running"&&t.progressMessage&&e.jsxs("div",{className:"border-t border-[hsl(var(--deck-border))] px-3 py-2 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 font-mono text-[10px] text-[hsl(var(--deck-ink-muted))]",children:[e.jsx("span",{className:"truncate",children:t.progressMessage}),t.progressTotal!==void 0&&t.progress!==void 0&&e.jsxs("span",{className:"shrink-0",children:[Math.max(0,Math.min(100,Math.round(t.progress/t.progressTotal*100))),"%"]})]}),t.progressTotal!==void 0&&t.progress!==void 0&&e.jsx("div",{role:"progressbar","aria-label":`${t.toolName} progress`,"aria-valuemin":0,"aria-valuemax":t.progressTotal,"aria-valuenow":Math.min(t.progress,t.progressTotal),className:"h-1 overflow-hidden rounded-full bg-[hsl(var(--deck-border))]",children:e.jsx("div",{className:"h-full rounded-full bg-amber-500 transition-[width] duration-150",style:{width:`${Math.max(0,Math.min(100,t.progress/t.progressTotal*100))}%`}})})]}),s&&e.jsxs("div",{className:"px-3 py-2 space-y-2 border-t border-[hsl(var(--deck-border))]",children:[r&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono",children:"Arguments"}),e.jsx("pre",{className:"text-[11px] text-[hsl(var(--deck-ink))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[120px] overflow-y-auto",children:r})]}),i&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono",children:"Output"}),e.jsxs("pre",{"data-tool-output":!0,className:"text-[11px] text-[hsl(var(--deck-ink))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[120px] overflow-y-auto",children:[i.body,i.notice&&e.jsxs(e.Fragment,{children:[`
|
|
15
|
-
`,e.jsx("span",{"data-tool-truncation-notice":!0,children:i.notice})]})]})]})]})]})}function Ke({toolCalls:t}){return t.length===0?null:e.jsx("div",{className:"space-y-2",children:t.map(s=>e.jsx(Zt,{tool:s},s.toolCallId))})}function es({toolCalls:t,toolCallIds:s}){const a=F(),[r,i]=b.useState(!1),n=b.useMemo(()=>new Map(t.map(o=>[o.toolCallId,o])),[t]),d=s.flatMap(o=>{const h=n.get(o);return h?[h]:[]});if(d.length===0)return null;const f=d.filter(o=>o.status==="running").length,l=d.filter(o=>o.status==="error").length,c=[...d].reverse().find(o=>o.status==="running"&&!!o.progressMessage),k=f>0?a(d.length===1?"chat.timeline.tools.runningOne":"chat.timeline.tools.running",{count:d.length}):l>0?a(d.length===1?"chat.timeline.tools.completedOneWithError":"chat.timeline.tools.completedWithErrors",{count:d.length,errors:l}):a(d.length===1?"chat.timeline.tools.completedOne":"chat.timeline.tools.completed",{count:d.length});return e.jsxs("div",{"data-agent-tool-group":!0,className:"py-0.5",children:[e.jsxs("button",{type:"button","aria-expanded":r,onClick:()=>i(o=>!o),className:"group flex min-h-7 w-full items-center gap-1.5 rounded-md px-1.5 text-left font-mono text-[11.5px] text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-surface))]/65 hover:text-[hsl(var(--deck-ink-muted))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:[r?e.jsx(ie,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(ve,{className:"h-3.5 w-3.5 shrink-0"}),f>0&&e.jsx(R,{className:"h-3 w-3 shrink-0 animate-spin text-[hsl(var(--deck-accent))]"}),e.jsx("span",{children:k}),(c==null?void 0:c.progressMessage)&&e.jsxs("span",{className:"min-w-0 truncate text-[10.5px] text-[hsl(var(--deck-ink-muted))]",children:[c.progressMessage,c.progress!==void 0&&c.progressTotal!==void 0&&` · ${Math.max(0,Math.min(100,Math.round(c.progress/c.progressTotal*100)))}%`]})]}),(c==null?void 0:c.progress)!==void 0&&c.progressTotal!==void 0&&e.jsx("div",{role:"progressbar","aria-label":`${c.toolName} progress`,"aria-valuemin":0,"aria-valuemax":c.progressTotal,"aria-valuenow":Math.min(c.progress,c.progressTotal),className:"mx-1.5 h-0.5 overflow-hidden rounded-full bg-[hsl(var(--deck-border))]",children:e.jsx("div",{className:"h-full rounded-full bg-amber-500 transition-[width] duration-150",style:{width:`${Math.max(0,Math.min(100,c.progress/c.progressTotal*100))}%`}})}),r&&e.jsx("div",{"data-agent-tool-group-details":!0,className:"mt-2 space-y-2 pl-1",children:e.jsx(Ke,{toolCalls:d})})]})}function ts({content:t}){const s=F(),[a,r]=b.useState(!1);return t?e.jsxs("div",{"data-agent-thinking":!0,className:"py-0.5",children:[e.jsxs("button",{type:"button","aria-expanded":a,onClick:()=>r(i=>!i),className:"flex min-h-7 w-full items-center gap-1.5 rounded-md px-1.5 text-left font-mono text-[11.5px] text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-surface))]/65 hover:text-[hsl(var(--deck-ink-muted))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:[a?e.jsx(ie,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))]"}):e.jsx(ve,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{children:s("chat.timeline.thinking")})]}),a&&e.jsx("div",{className:"ml-1 mt-1 border-l border-[hsl(var(--deck-border))] py-1 pl-3",children:e.jsx("pre",{className:"whitespace-pre-wrap font-mono text-[11px] leading-5 text-[hsl(var(--deck-ink-muted))]",children:t})})]}):null}function ss({tasks:t}){if(t.length===0)return null;const s=t.filter(r=>r.status==="completed").length,a=s===t.length;return e.jsx("div",{className:"bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-lg px-3 py-2",children:e.jsx("div",{className:"flex gap-2 items-center",children:e.jsx("span",{className:"text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:a?"✓ All tasks done":`Tasks: ${s}/${t.length}`})})})}function as({toolCalls:t}){const s=ge(r=>r.openFilePreview),a=b.useMemo(()=>{const r=new Map,i=["Write","SearchReplace","Edit","ApplyPatch"];for(const n of t){if(n.status!=="success")continue;const d=n.metadata;if(n.toolName==="ApplyPatch"&&Array.isArray(d==null?void 0:d.changes)){for(const l of d.changes)l&&typeof l=="object"&&"path"in l&&typeof l.path=="string"&&r.set(l.path,{path:l.path,toolName:n.toolName});continue}const f=d==null?void 0:d.file_path;f&&i.includes(n.toolName)&&r.set(f,{path:f,toolName:n.toolName})}return Array.from(r.values())},[t]);return a.length===0?null:e.jsxs("div",{className:"bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-lg px-3 py-2",children:[e.jsxs("div",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono mb-1.5",children:["Changed files (",a.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:a.map(({path:r})=>{const i=r.split("/").pop()||r;return e.jsxs("button",{onClick:()=>s({tab:"diff",targetPath:r}),className:"flex items-center gap-1 px-2 py-1 text-[11px] font-mono bg-[#E5E7EB] dark:bg-[#27272a] text-[hsl(var(--deck-ink))] rounded hover:bg-[#D1D5DB] dark:hover:bg-[#3f3f46] transition-colors",title:r,children:[e.jsx(ot,{className:"w-3 h-3"}),i]},r)})})]})}function rs({subagent:t}){var G,K,Y,X;const s=F(),[a,r]=b.useState(null),[i,n]=b.useState(!1),[d,f]=b.useState(null),[l,c]=b.useState(!1),[k,o]=b.useState(""),[h,u]=b.useState(!1),[j,N]=b.useState(null),[m,w]=b.useState(null),[v,p]=b.useState(null),x=y(M=>M.currentSessionRef),E=y(M=>M.isStreaming),S=y(M=>M.isTemporarySession);if(!t)return null;const D=t.status==="running",A=a!==null?a:D,L=t.toolCalls||d||[],_=t.output||t.thinking||L.length>0||t.sessionId,C=m&&m.status!=="running"?m:v,B=(C==null?void 0:C.id)??t.sessionId,H=((G=C==null?void 0:C.restartRecovery)==null?void 0:G.outcome)==="failed",ce=!D&&!E&&!S&&!H&&(m==null?void 0:m.status)!=="running"&&!!(B&&x);b.useEffect(()=>{if(!A||D||!t.sessionId||!(x!=null&&x.projectPath)||d!==null||t.toolCalls&&t.toolCalls.length>0)return;let M=!0;return n(!0),U.getMessages({sessionId:t.sessionId,projectPath:x.projectPath}).then(P=>{var I,$;if(!M)return;const V=wt(P),g=new Map;for(const W of V)if(($=(I=W.agentContent)==null?void 0:I.toolCalls)!=null&&$.length)for(const le of W.agentContent.toolCalls)g.has(le.toolCallId)||g.set(le.toolCallId,le);f(Array.from(g.values()))}).finally(()=>{M&&n(!1)}),()=>{M=!1}},[A,D,t.sessionId,t.toolCalls,d,x==null?void 0:x.projectPath]),b.useEffect(()=>{if(!t.sessionId||!x)return;let M=!0;const P=t.rootAgentId??t.sessionId,V=t.resumeDepth??0;return U.listSubagents(x).then(g=>{if(!M)return;p(g.find($=>$.id===t.sessionId)??null);const I=g.filter($=>$.id!==t.sessionId&&$.rootAgentId===P&&$.resumeDepth>V).sort(($,W)=>W.resumeDepth-$.resumeDepth||W.lastActiveAt-$.lastActiveAt)[0];I&&w(I)}).catch(()=>{}),()=>{M=!1}},[x==null?void 0:x.sessionId,x==null?void 0:x.projectPath,t.sessionId,t.rootAgentId,t.resumeDepth]),b.useEffect(()=>{if(!m||m.status!=="running"||!x)return;let M=!0;const P=async()=>{try{const I=(await U.listSubagents(x)).find($=>$.id===m.id);M&&I&&w(I)}catch{}},V=window.setInterval(()=>{P()},1e3);return()=>{M=!1,window.clearInterval(V)}},[x,m==null?void 0:m.id,m==null?void 0:m.status]);const z=async()=>{if(!(!x||!B||!k.trim()||h)){u(!0),N(null);try{const M=await U.resumeSubagent(x,B,k.trim());w(M.session),o(""),c(!1),r(!0)}catch(M){N(M instanceof Error?M.message:s("chat.subagent.resumeFailed"))}finally{u(!1)}}};return e.jsxs("div",{"data-subagent-id":t.id,"data-subagent-session-id":t.sessionId,className:"bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-lg px-3 py-2",children:[e.jsxs("button",{type:"button",onClick:()=>r(!A),className:"flex gap-2 justify-between items-center w-full transition-opacity cursor-pointer hover:opacity-80",children:[e.jsxs("div",{className:"flex gap-2 items-center",children:[D&&e.jsx(R,{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(ye,{status:t.status==="completed"?"success":t.status==="failed"?"error":"running"}),t.type==="verification"&&t.verificationVerdict&&e.jsx("span",{"data-verification-verdict":t.verificationVerdict,className:T("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})})]}),_&&e.jsx(ie,{className:T("h-3.5 w-3.5 text-[hsl(var(--deck-ink-muted))] transition-transform",A&&"rotate-180")})]}),!A&&!D&&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}),A&&e.jsxs("div",{className:"mt-2 space-y-2",children:[(t.output||t.thinking)&&e.jsxs(e.Fragment,{children:[t.output&&e.jsx("pre",{className:"text-[11px] text-[hsl(var(--deck-ink))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[160px] overflow-y-auto",children:t.output}),t.thinking&&e.jsx("pre",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[120px] overflow-y-auto",children:t.thinking})]}),i&&e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono",children:[e.jsx(R,{className:"w-3 h-3 animate-spin"}),s("chat.subagent.loadingLogs")]}),!i&&L.length>0&&e.jsx(Ke,{toolCalls:L}),m&&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:m.id,status:m.status,depth:m.resumeDepth??1})}),(((K=m.result)==null?void 0:K.message)||((Y=m.result)==null?void 0:Y.error))&&e.jsx("div",{className:"mt-1 whitespace-pre-wrap text-[hsl(var(--deck-ink))]",children:m.result.message||m.result.error})]}),H&&((X=C==null?void 0:C.result)==null?void 0:X.error)&&e.jsx("div",{role:"alert",className:"text-[11px] text-red-600",children:C.result.error}),ce&&e.jsxs("div",{className:"space-y-2",children:[l?e.jsxs("div",{className:"space-y-2 rounded-md border border-[#E5E7EB] bg-white p-2 dark:border-[#27272a] dark:bg-[#111113]",children:[e.jsx("textarea",{"aria-label":s("chat.subagent.followUpAria"),value:k,onChange:M=>o(M.target.value),placeholder:s("chat.subagent.followUpPlaceholder"),rows:3,className:"w-full resize-y rounded border border-[#D1D5DB] bg-white p-2 text-[11px] text-[#111827] outline-none focus:border-[#8B5CF6] dark:border-[#3f3f46] dark:bg-[#18181b] dark:text-[#f4f4f5]"}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{type:"button",onClick:()=>{c(!1),N(null)},className:"rounded px-2 py-1 text-[11px] text-[#6B7280] hover:bg-[#F3F4F6] dark:hover:bg-[#27272a]",children:s("chat.subagent.cancel")}),e.jsxs("button",{type:"button",onClick:()=>void z(),disabled:!k.trim()||h,className:"flex items-center gap-1 rounded bg-[#7C3AED] px-2 py-1 text-[11px] font-medium text-white disabled:opacity-50",children:[h&&e.jsx(R,{className:"w-3 h-3 animate-spin"}),s("chat.subagent.resumeAgent")]})]})]}):e.jsxs("button",{type:"button","aria-label":s("chat.subagent.resumeAria"),onClick:()=>c(!0),className:"flex items-center gap-1.5 rounded-md border border-[#D1D5DB] px-2 py-1 text-[11px] font-medium text-[#374151] transition-colors hover:bg-[#F3F4F6] dark:border-[#3f3f46] dark:text-[#d4d4d8] dark:hover:bg-[#27272a]",children:[e.jsx(ke,{className:"w-3 h-3"}),s("chat.subagent.resume")]}),j&&e.jsx("div",{role:"alert",className:"text-[11px] text-red-600",children:j})]})]})]})}function ns({confirmation:t,messageId:s}){const a=F(),[r,i]=b.useState(!1),[n,d]=b.useState(null),f=y(k=>k.currentSessionRef),l=y(k=>k.setConfirmation);if(!t)return null;const c=async(k,o)=>{if(!(!f||r)){i(!0),d(null);try{await U.respondPermission(f,t.toolCallId,{approved:k,scope:o}),l(s,{...t,status:k?"approved":"denied"})}catch(h){d(h instanceof Error?h.message:a("interaction.permission.failed"))}finally{i(!1)}}};return t.status!=="pending"?null:e.jsxs("div",{"data-pending-interaction":"permission",tabIndex:-1,role:"alert",className:"space-y-3 rounded-lg border border-amber-300/70 bg-amber-50/70 p-4 outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-800/70 dark:bg-amber-950/25",children:[e.jsx("div",{className:"text-[13px] text-[hsl(var(--deck-ink))] font-mono",children:a("interaction.permission.title",{tool:t.toolName})}),e.jsx("div",{className:"text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:t.description}),t.diff&&e.jsx("pre",{className:"text-[11px] text-[hsl(var(--deck-ink))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[200px] overflow-y-auto",children:t.diff}),n&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-300/70 bg-red-50 px-2.5 py-2 font-mono text-[11px] text-red-700 dark:border-red-900/70 dark:bg-red-950/35 dark:text-red-300",children:n}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:()=>void c(!0,"once"),disabled:r,className:"min-h-8 px-3 py-1.5 text-[12px] font-mono bg-[#22C55E] text-white rounded-md hover:bg-[#16A34A] disabled:cursor-wait disabled:opacity-50",children:r?e.jsx(R,{className:"h-3.5 w-3.5 animate-spin"}):a("interaction.permission.once")}),t.allowRemember!==!1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>void c(!0,"session"),disabled:r,className:"min-h-8 px-3 py-1.5 text-[12px] font-mono bg-[#3B82F6] text-white rounded-md hover:bg-[#2563EB] disabled:cursor-wait disabled:opacity-50",children:a("interaction.permission.session")}),e.jsx("button",{type:"button",onClick:()=>void c(!0,"project"),disabled:r,className:"min-h-8 px-3 py-1.5 text-[12px] font-mono bg-[#6366F1] text-white rounded-md hover:bg-[#4F46E5] disabled:cursor-wait disabled:opacity-50",children:a("interaction.permission.project")})]}),e.jsx("button",{type:"button",onClick:()=>void c(!1),disabled:r,className:"min-h-8 px-3 py-1.5 text-[12px] font-mono bg-[#EF4444] text-white rounded-md hover:bg-[#DC2626] disabled:cursor-wait disabled:opacity-50",children:a("interaction.permission.deny")})]})]})}function is({question:t,messageId:s}){const a=F(),[r,i]=b.useState({}),[n,d]=b.useState({}),[f,l]=b.useState(!1),[c,k]=b.useState(null),o=y(m=>m.currentSessionRef),h=y(m=>m.setQuestion),u=b.useMemo(()=>t?t.questions.reduce((m,w)=>{var E;const v=(E=n[w.header])==null?void 0:E.trim(),p=r[w.header];if(w.multiSelect){const S=Array.isArray(p)?[...p]:[];return v&&S.push(v),S.length>0&&(m[w.header]=S),m}const x=v||(typeof p=="string"?p:"");return x&&(m[w.header]=x),m},{}):{},[r,n,t]),j=(t==null?void 0:t.questions.every(m=>m.header in u))??!1;if(!t)return null;const N=async()=>{if(!(!o||f||!j)){l(!0),k(null);try{await U.respondToQuestion(o,t.toolCallId,u),h(s,{...t,status:"answered",answers:u})}catch(m){k(m instanceof Error?m.message:a("interaction.question.failed"))}finally{l(!1)}}};return t.status!=="pending"?e.jsx("div",{className:"bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-lg px-3 py-2",children:e.jsx("div",{className:"text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:a("interaction.question.answered")})}):e.jsxs("div",{"data-pending-interaction":"question",tabIndex:-1,role:"alert",className:"space-y-4 rounded-lg border border-amber-300/70 bg-amber-50/70 p-4 outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-800/70 dark:bg-amber-950/25",children:[t.questions.map((m,w)=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-[13px] text-[hsl(var(--deck-ink))] font-mono",children:m.question}),e.jsxs("div",{className:"space-y-1",children:[m.options.map((v,p)=>e.jsxs("button",{type:"button",onClick:()=>{if(m.multiSelect){const x=r[m.header]||[],E=x.includes(v.label)?x.filter(S=>S!==v.label):[...x,v.label];i({...r,[m.header]:E})}else i({...r,[m.header]:v.label}),d({...n,[m.header]:""})},className:T("w-full text-left px-3 py-2 rounded-md border text-[12px] font-mono transition-colors","border-[hsl(var(--deck-border))]",(m.multiSelect?(r[m.header]||[]).includes(v.label):r[m.header]===v.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:v.label}),e.jsx("div",{className:"text-[11px] text-[hsl(var(--deck-ink-faint))] mt-1",children:v.description})]},p)),e.jsx("input",{"aria-label":`${m.header} other response`,value:n[m.header]??"",onChange:v=>d({...n,[m.header]:v.target.value}),placeholder:a("interaction.question.other"),className:"w-full rounded-md border border-[#E5E7EB] bg-white px-3 py-2 text-[12px] text-[#111827] outline-none focus:border-[#22C55E] dark:border-[#27272a] dark:bg-[#111113] dark:text-[#E5E5E5]"})]})]},w)),c&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-300/70 bg-red-50 px-2.5 py-2 font-mono text-[11px] text-red-700 dark:border-red-900/70 dark:bg-red-950/35 dark:text-red-300",children:c}),e.jsxs("button",{type:"button",onClick:()=>void N(),disabled:f||!j,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:[f&&e.jsx(R,{className:"h-3.5 w-3.5 animate-spin"}),a("interaction.question.submit")]})]})}function os({message:t}){const s=t.agentContent,a=y(j=>j.isStreaming&&j.currentAssistantMessageId===t.id);if(!s){const j=je(t.content);return j?e.jsx(Ee,{content:j}):null}const{toolCalls:r,tasks:i,confirmation:n,question:d,elicitation:f}=s,l=jt(s),c=yt(s);if(!(c.length>0||i.length>0||l.length>0||n||d||f)&&a)return e.jsxs("div",{className:"flex items-center gap-2 text-[hsl(var(--deck-ink-muted))]",children:[e.jsx(R,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{className:"text-[12px] font-mono",children:"Thinking..."})]});const h=r.length>0&&r.every(j=>j.status==="success"||j.status==="error")&&!a,u=!a;return e.jsxs("div",{className:"space-y-3",children:[c.map(j=>j.type==="thinking"?e.jsx("div",{"data-agent-timeline-block":"thinking",children:e.jsx(ts,{content:j.content})},j.id):j.type==="text"?e.jsx("div",{"data-agent-timeline-block":"text",children:e.jsx(Ee,{content:j.content,syntaxHighlight:u})},j.id):e.jsx("div",{"data-agent-timeline-block":"tool_group",children:e.jsx(es,{toolCalls:r,toolCallIds:j.toolCallIds})},j.id)),i.length>0&&e.jsx(ss,{tasks:i}),l.map(j=>e.jsx(rs,{subagent:j},j.id)),n&&e.jsx(ns,{confirmation:n,messageId:t.id}),d&&e.jsx(is,{question:d,messageId:t.id}),f&&e.jsx(_t,{elicitation:f,messageId:t.id}),h&&e.jsx(as,{toolCalls:r})]})}function cs({message:t,showAvatar:s=!0}){var f,l,c,k;const a=t.role==="user";if(t.role==="system"){const o=je(t.content);return e.jsx("div",{"data-chat-message-id":t.id,"data-chat-role":"system",className:"flex justify-center p-2 w-full",children:e.jsx("div",{className:"text-xs text-[hsl(var(--deck-ink-muted))] bg-[#F3F4F6] dark:bg-[#18181b] px-3 py-1 rounded-full font-mono",children:o})})}if(a){const o=(f=t.metadata)!=null&&f.userShellCommand&&typeof t.metadata.userShellCommand=="object"?t.metadata.userShellCommand:(l=t.metadata)!=null&&l.userShellExecution&&typeof t.metadata.userShellExecution=="object"?t.metadata.userShellExecution:void 0;if(o){const j=typeof o.command=="string"?o.command:"",N=o.status==="running"?"running":o.status==="completed"?"success":"error",m=typeof o.output=="string"?o.output:[typeof o.stdout=="string"?o.stdout:"",typeof o.stderr=="string"&&o.stderr?`stderr:
|
|
16
|
-
${o.stderr}`:""].filter(Boolean).join(`
|
|
17
|
-
`);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:"$"}),j]}),e.jsx(ye,{status:N})]}),e.jsx("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap px-3 py-2 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))]",children:m||"(no output)"}),typeof o.exitCode=="number"&&e.jsxs("div",{className:"border-t border-[hsl(var(--deck-border))] px-3 py-1.5 font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:["exit ",o.exitCode,typeof o.durationMs=="number"?` · ${(o.durationMs/1e3).toFixed(3)}s`:"",o.truncated===!0?" · truncated":""]})]})})}const{text:h,images:u}=Jt(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(Se,{text:h,label:"Copy message"})}),e.jsxs("div",{className:"bg-[hsl(var(--deck-surface-2))] rounded-lg px-4 py-3 max-w-[85%]",children:[h&&e.jsx("p",{className:"text-[14px] text-[hsl(var(--deck-ink))] font-mono leading-relaxed whitespace-pre-wrap",children:h}),u.length>0&&e.jsx("div",{className:T("grid gap-2",u.length===1?"grid-cols-1 mt-0":"grid-cols-2 mt-3"),children:u.map((j,N)=>e.jsx("img",{src:j,alt:`attachment-${N+1}`,className:"object-cover w-full max-h-64 rounded-md"},`${j}-${N}`))})]}),e.jsx(Wt,{})]})}const i=Qt(t),n=Dt((c=t.metadata)==null?void 0:c.codeReview),d=Kt((k=t.metadata)==null?void 0:k.structuredOutput);return e.jsxs("div",{"data-chat-message-id":t.id,"data-chat-role":"assistant",className:T("group flex gap-4 justify-start w-full",s?"p-4":"px-4 pt-0 pb-3"),children:[s?e.jsx(Gt,{}):e.jsx("div",{className:"w-8 shrink-0"}),e.jsxs("div",{className:"overflow-hidden flex-1 min-w-0",children:[n?e.jsx(It,{report:n}):d?e.jsx(qt,{report:d}):e.jsx(os,{message:t}),!d&&i.trim()&&e.jsx("div",{className:"mt-1.5 flex opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100",children:e.jsx(Se,{text:i,label:"Copy response"})})]})]})}const ls=b.memo(cs);function ds(t,s,a){return Math.max(0,t+(a-s))}function us(t,s,a){return Math.min(s,Math.max(0,t)+Math.max(0,a))}function Ae(t,s){return t?t.querySelector(`[data-chat-message-id="${CSS.escape(s)}"]`):null}function ms({turns:t,viewportRef:s,containerRef:a,onRevealTurn:r}){const i=F(),[n,d]=b.useState(null),[f,l]=b.useState(!1),c=b.useRef(null),k=b.useCallback(()=>{var m;const h=s.current,u=a.current;if(!h||!u||t.length===0)return;const j=h.getBoundingClientRect().top;let N=((m=t[0])==null?void 0:m.id)??null;for(const w of t){const v=Ae(u,w.id);if(v)if(v.getBoundingClientRect().top-j<=24)N=w.id;else break}d(N)},[t,s,a]);b.useEffect(()=>{const h=s.current;if(!h)return;const u=()=>{c.current===null&&(c.current=window.requestAnimationFrame(()=>{c.current=null,k()}))};return k(),h.addEventListener("scroll",u,{passive:!0}),()=>{h.removeEventListener("scroll",u),c.current!==null&&(window.cancelAnimationFrame(c.current),c.current=null)}},[k,s]);const o=b.useCallback(h=>{const u=()=>{const N=Ae(a.current,h.id);N&&(N.scrollIntoView({behavior:"smooth",block:"start"}),d(h.id))};r(h.index)?u():window.requestAnimationFrame(()=>window.requestAnimationFrame(u))},[a,r]);return t.length<2?null:e.jsx("nav",{"aria-label":i("chat.turns.aria"),className:"absolute right-1 top-1/2 z-20 hidden -translate-y-1/2 sm:block",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),onFocusCapture:()=>l(!0),onBlurCapture:h=>{h.currentTarget.contains(h.relatedTarget)||l(!1)},children:e.jsxs("div",{className:"relative flex items-center justify-end",children:[e.jsx("ul",{className:T("flex flex-col items-center gap-2 py-2 transition-opacity",f?"opacity-0":"opacity-100"),"aria-hidden":f,children:t.map(h=>e.jsx("li",{children:e.jsx("span",{className:T("block rounded-full transition-all",h.id===n?"h-2 w-2 bg-[hsl(var(--deck-accent))]":"h-1.5 w-1.5 bg-[hsl(var(--deck-ink-faint))]/40")})},h.id))}),e.jsx("div",{className:T("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",f?"pointer-events-auto translate-x-0 opacity-100":"pointer-events-none translate-x-2 opacity-0"),children:t.map((h,u)=>e.jsxs("button",{type:"button",onClick:()=>o(h),className:T("flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left transition-colors",h.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:T("mt-1 h-1.5 w-1.5 shrink-0 rounded-full",h.id===n?"bg-[hsl(var(--deck-accent))]":"bg-[hsl(var(--deck-ink-faint))]/40")}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block font-mono text-[9.5px] uppercase tracking-[0.12em] text-[hsl(var(--deck-ink-faint))]",children:i("chat.turns.label",{n:u+1})}),e.jsx("span",{className:"line-clamp-2 text-[12px] leading-4",children:h.preview})]})]},h.id))})]})})}const Re=80;function hs(t){return typeof t=="string"?t:Array.isArray(t)?t.filter(s=>s.type==="text").map(s=>s.text).join(" "):""}function xs(t){const s=hs(t).replace(/\s+/g," ").trim();return s?s.length>Re?`${s.slice(0,Re-1)}…`:s:""}function ps(t){const s=[];for(let a=0;a<t.length;a+=1){const r=t[a];if(r.role!=="user"||!r.id)continue;const i=xs(r.content);i&&s.push({id:r.id,index:a,preview:i})}return s}const ue=120,me=80,fs=96;function J(t){return(t==null?void 0:t.querySelector("[data-radix-scroll-area-viewport]"))??null}function bs({messages:t,isLoading:s}){const a=F(),r=b.useRef(null),i=b.useRef(null),n=b.useRef(!0),d=b.useRef(t.length),f=b.useRef(null),[l,c]=b.useState(ue),[k,o]=b.useState(!1);b.useEffect(()=>{const p=J(r.current);if(!p||!n.current)return;const x=window.requestAnimationFrame(()=>{p.scrollTop=p.scrollHeight});return()=>window.cancelAnimationFrame(x)},[t]),b.useEffect(()=>{const p=J(r.current);if(!p)return;i.current=p;const x=()=>{const S=p.scrollHeight-p.scrollTop-p.clientHeight<=fs;n.current=S,o(!S)};return x(),p.addEventListener("scroll",x,{passive:!0}),()=>p.removeEventListener("scroll",x)},[]),b.useEffect(()=>{const p=d.current;d.current=t.length,c(x=>x>=p&&t.length>p?t.length:Math.min(Math.max(x,ue),t.length||ue))},[t.length]);const h=Math.max(t.length-l,0),u=h,j=b.useMemo(()=>t.slice(u),[t,u]),N=b.useMemo(()=>ps(t),[t]);if(b.useLayoutEffect(()=>{var E;const p=f.current;if(!p)return;const x=J(r.current);if(f.current=null,!!x){if((E=p.element)!=null&&E.isConnected){const S=p.element.getBoundingClientRect().top-p.viewportTop;x.scrollTop+=S;return}x.scrollTop=ds(p.scrollTop,p.scrollHeight,x.scrollHeight)}},[l]),s)return e.jsx("div",{role:"status","aria-live":"polite","aria-busy":"true",className:"flex overflow-hidden flex-1 justify-center items-center px-5 py-8 min-h-0",children:e.jsxs("div",{className:"w-full max-w-[560px]",children:[e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 animate-pulse rounded-full bg-[hsl(var(--deck-accent-soft))] blur-xl"}),e.jsx(xe,{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(ct,{className:"w-3 h-3"}),a("chat.list.loading.eyebrow")]}),e.jsx("h2",{className:"mt-2 text-[15px] font-medium text-[hsl(var(--deck-ink))]",children:a("chat.list.loading.title")}),e.jsx("p",{className:"mt-1 max-w-sm text-[11.5px] leading-5 text-[hsl(var(--deck-ink-faint))]",children:a("chat.list.loading.hint")})]}),e.jsx("div",{"aria-hidden":"true",className:"mt-7 space-y-4 rounded-xl border border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-surface))]/45 px-4 py-5",children:[72,88,64].map((p,x)=>e.jsxs("div",{className:T("flex gap-3",x%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:`${p}%`,animationDelay:`${x*120}ms`}})]},p))})]})});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(xe,{size:44}),e.jsxs("div",{children:[e.jsx("div",{className:"deck-eyebrow text-[hsl(var(--deck-accent))]",children:a("chat.list.empty.eyebrow")}),e.jsx("div",{className:"mt-2 text-[15px] font-medium text-[hsl(var(--deck-ink))]",children:a("chat.list.empty.title")}),e.jsx("div",{className:"mt-1 max-w-xs text-[12px] text-[hsl(var(--deck-ink-muted))]",children:a("chat.list.empty.hint")})]})]})});const m=()=>{const p=J(r.current);p&&(n.current=!0,o(!1),p.scrollTo({top:p.scrollHeight,behavior:"smooth"}))},w=()=>{var x;const p=J(r.current);if(p){const E=((x=r.current)==null?void 0:x.querySelector("[data-chat-message-id]"))??null;f.current={element:E,viewportTop:(E==null?void 0:E.getBoundingClientRect().top)??0,scrollHeight:p.scrollHeight,scrollTop:p.scrollTop}}c(E=>us(E,t.length,me))},v=p=>p>=u?!0:(c(t.length),!1);return e.jsxs("div",{ref:r,className:"relative flex-1 min-h-0",children:[e.jsx(We,{className:"h-full",children:e.jsxs("div",{className:"flex flex-col px-4 pb-4 w-full md:px-6",children:[h>0&&e.jsx("div",{className:"flex justify-center py-3",children:e.jsx("button",{type:"button",onClick:w,"aria-label":a("chat.list.showEarlierWithRemaining",{count:Math.min(h,me),remaining:h}),className:"rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-3 py-1.5 font-mono text-[12px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:border-[hsl(var(--deck-border-strong))] hover:text-[hsl(var(--deck-ink))]",children:a("chat.list.showEarlier",{count:Math.min(h,me)})})}),j.map((p,x)=>{const E=u+x,S=E>0?t[E-1]:null,D=!S||S.role!==p.role||S.role==="user";return e.jsx(ls,{message:p,showAvatar:D},p.id||`msg-${E}`)})]})}),e.jsx(ms,{turns:N,viewportRef:i,containerRef:r,onRevealTurn:v}),k&&e.jsxs("button",{type:"button",onClick:m,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(Ve,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}),a("chat.list.jumpLatest")]})]})}const gs=b.memo(bs),pe=Ct,fe=Et,be=Tt,re=b.forwardRef(({className:t,sideOffset:s=4,...a},r)=>e.jsx(Ue,{ref:r,sideOffset:s,className:T("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",t),...a}));re.displayName=Ue.displayName;const vs={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 Z(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t)}function ks(t){if(t<60)return`${t}s`;const s=Math.floor(t/60),a=t%60;return a===0?`${s}m`:`${s}m ${a}s`}function js(){var _;const t=F(),{locale:s}=Je(),a=y(C=>C.goal),r=y(C=>C.pauseGoal),i=y(C=>C.resumeGoal),n=y(C=>C.editGoal),d=y(C=>C.clearGoal),[f,l]=b.useState(!1),[c,k]=b.useState(!1),[o,h]=b.useState(""),[u,j]=b.useState(null),[N,m]=b.useState(!1);if(b.useEffect(()=>{l(!1),k(!1),h((a==null?void 0:a.objective)??""),m(!1)},[a==null?void 0:a.goalId]),!a)return null;const w=vs[a.status],v=["active","verifying","paused","blocked"].includes(a.status),p=a.status==="active"||a.status==="verifying",x=a.status==="paused"||a.status==="blocked",E=u!==null,S=async(C,B)=>{j(C);try{await B()}finally{j(null)}},D=()=>{h(a.objective),k(!0),l(!0)},A=async C=>{C.preventDefault();const B=o.trim();if(!B||B===a.objective){k(!1);return}await S("edit",()=>n(B)),k(!1)},L=async()=>{await S("delete",d),m(!1)};return e.jsxs(e.Fragment,{children:[e.jsx(pe,{delayDuration:250,children:e.jsxs("section",{"aria-label":t("goal.aria.section"),className:"mx-3 mb-1 shrink-0","data-blade-goal-status":a.status,children:[e.jsxs("div",{className:T("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",f&&"rounded-b-none border-b-0"),children:[a.status==="complete"?e.jsx(lt,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500"}):e.jsx(dt,{className:T("h-3.5 w-3.5 shrink-0",w.accent)}),e.jsx("span",{className:T("h-1.5 w-1.5 shrink-0 rounded-full",w.dot)}),e.jsx("span",{className:T("shrink-0 text-[10px] font-medium leading-none",w.accent),children:a.status==="verifying"?s==="zh"?"验证中":"Verifying":t(w.labelKey)}),e.jsx("span",{className:"h-3 w-px shrink-0 bg-[hsl(var(--deck-hairline))]"}),e.jsx("button",{type:"button","aria-label":t(f?"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(C=>!C),"aria-expanded":f,title:a.objective,children:a.objective}),a.tokensUsed>0&&e.jsxs("span",{className:"hidden shrink-0 text-[10px] tabular-nums text-[hsl(var(--deck-ink-muted))] sm:inline",children:[Z(a.tokensUsed),a.tokenBudget!==void 0&&`/${Z(a.tokenBudget)}`]}),e.jsxs("div",{className:"flex shrink-0 items-center",children:[p&&e.jsx(ee,{label:t("goal.action.pause"),disabled:E,onClick:()=>void S("pause",r),children:u==="pause"?e.jsx(R,{className:"animate-spin"}):e.jsx(ut,{})}),x&&e.jsx(ee,{label:t("goal.action.resume"),disabled:E,onClick:()=>void S("resume",i),children:u==="resume"?e.jsx(R,{className:"animate-spin"}):e.jsx(mt,{})}),e.jsx(ee,{label:t(v?"goal.action.edit":"goal.action.expand"),disabled:!v&&!f,onClick:v?D:()=>l(C=>!C),children:v?e.jsx(Le,{}):e.jsx(ht,{})}),e.jsx(ee,{label:t("goal.action.delete"),disabled:E,destructive:!0,onClick:()=>m(!0),children:e.jsx(se,{})})]})]}),f&&e.jsx("div",{className:"rounded-b-lg border border-t-0 border-[hsl(var(--deck-border))]/60 bg-[hsl(var(--deck-surface))]/80 px-4 py-3 backdrop-blur-sm",children:c?e.jsxs("form",{onSubmit:A,children:[e.jsx("textarea",{id:"goal-objective",value:o,onChange:C=>h(C.target.value),onKeyDown:C=>{C.key==="Escape"&&k(!1)},rows:3,autoFocus:!0,className:"w-full resize-none rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-canvas))] px-3 py-2 text-[12px] leading-5 text-[hsl(var(--deck-ink))] outline-none transition-shadow focus:border-[hsl(var(--deck-accent))] focus:ring-1 focus:ring-[hsl(var(--deck-accent-glow))]"}),e.jsxs("div",{className:"mt-2 flex items-center justify-end gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>k(!1),className:"inline-flex h-7 items-center gap-1 rounded-md px-2.5 text-[11px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:bg-[hsl(var(--deck-hairline))]/60",children:[e.jsx(xt,{className:"h-3 w-3"}),t("goal.action.cancel")]}),e.jsxs("button",{type:"submit",disabled:!o.trim()||u==="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:[u==="edit"?e.jsx(R,{className:"h-3 w-3 animate-spin"}):e.jsx(ne,{className:"h-3 w-3"}),t("goal.action.save")]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"whitespace-pre-wrap text-[12px] leading-5 text-[hsl(var(--deck-ink))]/90",children:a.objective}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1.5 text-[10px] text-[hsl(var(--deck-ink-muted))]",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(pt,{className:"h-3 w-3"}),Z(a.tokensUsed),a.tokenBudget!==void 0&&` / ${Z(a.tokenBudget)}`," ",t("goal.metrics.tokens")]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(ft,{className:"h-3 w-3"}),ks(a.timeUsedSeconds)]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(ke,{className:"h-3 w-3"}),a.continuationCount===1?t("goal.metrics.continuationOne",{n:a.continuationCount}):t("goal.metrics.continuationMany",{n:a.continuationCount})]})]}),a.completionVerification&&e.jsxs("div",{"data-goal-verification":a.completionVerification.status,className:"mt-2 rounded-md border border-sky-200/50 bg-sky-50/60 px-2.5 py-2 text-[11px] text-sky-900 dark:border-sky-400/15 dark:bg-sky-400/[0.05] dark:text-sky-100",children:[e.jsxs("p",{className:"font-mono font-medium",children:["#",a.completionVerification.attempt," ·"," ",a.completionVerification.status.toUpperCase()," ·"," ",((_=a.completionVerification.verifierSessionId)==null?void 0:_.slice(0,12))??"-"]}),a.completionVerification.summary&&e.jsx("p",{className:"mt-1 line-clamp-3 whitespace-pre-wrap opacity-80",children:a.completionVerification.summary}),a.completionVerification.evidenceSha256&&e.jsxs("p",{className:"mt-1 font-mono text-[10px] opacity-60",children:["sha256:",a.completionVerification.evidenceSha256.slice(0,12)]})]}),a.statusReason&&e.jsx("div",{className:"mt-2 rounded-md border border-amber-200/50 bg-amber-50/60 px-2.5 py-1.5 text-[11px] text-amber-800 dark:border-amber-400/15 dark:bg-amber-400/[0.05] dark:text-amber-200",children:a.statusReason})]})})]})}),e.jsx($e,{open:N,onOpenChange:m,children:e.jsxs(De,{className:"max-w-[400px] border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsx(Be,{children:t("goal.dialog.title")}),e.jsx(Ie,{children:t("goal.dialog.description")}),e.jsxs(_e,{className:"mt-2",children:[e.jsx("button",{type:"button",onClick:()=>m(!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:u==="delete",onClick:()=>void L(),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:[u==="delete"&&e.jsx(R,{className:"w-3.5 h-3.5 animate-spin"}),t("goal.action.delete")]})]})]})})]})}function ee({label:t,children:s,disabled:a,destructive:r,onClick:i}){return e.jsxs(fe,{children:[e.jsx(be,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":t,disabled:a,onClick:i,className:T("flex h-6 w-6 items-center justify-center rounded-md text-[hsl(var(--deck-ink-muted))] outline-none transition-colors focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent-glow))]/50 disabled:cursor-not-allowed disabled:opacity-35 [&_svg]:h-3.5 [&_svg]:w-3.5",r?"hover:bg-rose-500/10 hover:text-rose-500":"hover:bg-[hsl(var(--deck-hairline))]/60 hover:text-[hsl(var(--deck-ink))]"),children:s})}),e.jsx(re,{side:"top",className:"text-[10px]",children:t})]})}function ys(){const t=F(),s=y(l=>l.currentSessionRef),a=y(l=>l.sessions),r=y(l=>l.messages),i=b.useMemo(()=>{var c,k,o,h,u;const l=s?(c=Qe(a,s))==null?void 0:c.pendingInteraction:void 0;if(l)return l.type;for(let j=r.length-1;j>=0;j-=1){const N=(k=r[j])==null?void 0:k.agentContent;if(((o=N==null?void 0:N.confirmation)==null?void 0:o.status)==="pending")return"permission";if(((h=N==null?void 0:N.question)==null?void 0:h.status)==="pending")return"question";if(((u=N==null?void 0:N.elicitation)==null?void 0:u.status)==="pending")return"elicitation"}return null},[s,r,a]);if(!i)return null;const n=()=>{const l=document.querySelector(`[data-pending-interaction="${i}"]`);l==null||l.scrollIntoView({block:"center",behavior:"smooth"}),window.setTimeout(()=>l==null?void 0:l.focus(),250)},d=i==="question",f=i==="elicitation";return e.jsxs("div",{role:"alert",className:"mx-3 mb-2 flex flex-wrap items-center gap-2 rounded-lg border border-amber-300/80 bg-amber-50/95 px-3 py-2 font-mono text-amber-950 shadow-sm backdrop-blur dark:border-amber-800/80 dark:bg-amber-950/90 dark:text-amber-100 sm:mx-5",children:[e.jsx(Oe,{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(d?"interaction.bar.questionTitle":f?"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(d?"interaction.bar.questionHint":f?"interaction.bar.elicitationHint":"interaction.bar.permissionHint")})]}),e.jsxs("button",{type:"button",onClick:n,className:"inline-flex min-h-8 shrink-0 items-center gap-1.5 rounded-md border border-amber-400/80 bg-white/80 px-2.5 text-[10.5px] font-medium transition-colors hover:bg-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-700 dark:bg-amber-950/70 dark:hover:bg-amber-900",children:[e.jsx(Ve,{className:"h-3 w-3"}),t("interaction.bar.review")]})]})}function he(t){return Number.isFinite(t)?Math.max(0,t):0}function ws(t){const s=he(t.totalInputTokens),a=he(t.cacheReadTokens),r=he(t.cacheWriteTokens),i=Math.min(a,s),n=Math.min(r,Math.max(0,s-i)),d=Math.max(0,s-i-n),f=s>0&&(a>0||r>0);return{totalInputTokens:s,cacheReadTokens:i,cacheWriteTokens:n,uncachedInputTokens:d,...f?{hitRate:i/s}:{}}}function Ns(t){return t===void 0||!Number.isFinite(t)?"—":`${Math.round(Math.max(0,Math.min(1,t))*100)}%`}const Ss={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:""},Cs={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"},O=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString(),te=t=>{const s=Math.max(0,Math.ceil(t/1e3)),a=Math.floor(s/60),r=s%60;return a>0?`${a}m ${r}s`:`${r}s`};function Es(){const t=F(),s=y(w=>w.tokenUsage),a=y(w=>w.isStreaming),r=y(w=>w.agentPhase),i=y(w=>w.providerAdmission),n=y(w=>w.providerCircuit),d=y(w=>w.providerRetry),f=y(w=>w.providerStall),l=y(w=>w.actionStationarity),c=Ss[r]??"",k=(d==null?void 0:d.delayMs)!==void 0?` · ${Math.max(0,Math.ceil(d.delayMs/1e3))}s`:"",o=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 ${te(n.retryAfterMs)}`:""}${n.recoveryRemainingMs!==void 0?` · ${te(n.recoveryRemainingMs)}`:""}`:i?`Provider · Capacity queue ${i.queuePosition}/${Math.max(i.queueDepth,i.queuePosition)} · ${i.scope} · ${te(i.waitMs)}`:d?d.mode==="bounded_foreground"?`Provider · Bounded recovery · ${d.attempt}/${d.maxRetries} · ${te(d.recoveryRemainingMs??0)}`:`Provider · ${t("chat.error.action.retryingTask")} · ${d.attempt}/${d.maxRetries}${k}`:f?`${t("status.phase.providerStall")} · ${Math.ceil(f.durationMs/1e3)}s / ${Math.ceil(f.timeoutMs/1e3)}s`:c?t(c):"",h=s.maxContextTokens>0?Math.round(s.totalTokens/s.maxContextTokens*100):0,u=ws(s),j=Ns(u.hitRate),N=Math.min(h,100),m=h>95?"danger":h>80?"warn":"safe";return e.jsxs("div",{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:T("text-[12px] font-medium",m==="safe"&&"text-[hsl(var(--deck-ink))]",m==="warn"&&"text-amber-600 dark:text-amber-400",m==="danger"&&"text-red-600 dark:text-red-400"),children:O(s.totalTokens)}),e.jsxs("span",{className:"text-[hsl(var(--deck-ink-faint))]",children:["/ ",O(s.maxContextTokens)]})]}),s.isDefaultMaxTokens&&e.jsx(pe,{children:e.jsxs(fe,{children:[e.jsx(be,{asChild:!0,children:e.jsx(bt,{className:"h-3 w-3 cursor-help text-[hsl(var(--deck-ink-faint))]"})}),e.jsx(re,{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:T("absolute inset-y-0 left-0 transition-[width] duration-300",m==="safe"&&"bg-[hsl(var(--deck-accent))]",m==="warn"&&"bg-amber-500",m==="danger"&&"bg-red-500"),style:{width:`${N}%`}}),e.jsx("div",{className:"flex absolute inset-0 pointer-events-none",children:[25,50,75].map(w=>e.jsx("span",{className:"absolute inset-y-0 w-px bg-[hsl(var(--deck-canvas-veil))]/60",style:{left:`${w}%`}},w))})]}),e.jsxs("span",{className:T("w-10 text-right tabular-nums text-[hsl(var(--deck-ink-faint))]",m==="warn"&&"text-amber-600 dark:text-amber-400",m==="danger"&&"text-red-600 dark:text-red-400"),children:[h,"%"]})]}),e.jsx(pe,{children:e.jsxs(fe,{children:[e.jsx(be,{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")} ${j}`,children:[e.jsx("span",{className:"deck-eyebrow text-[hsl(var(--deck-ink-faint))]",children:t("status.cache")}),e.jsx("span",{className:T("tabular-nums",u.hitRate===void 0?"text-[hsl(var(--deck-ink-faint))]":"font-medium text-[hsl(var(--deck-accent))]"),children:j})]})}),e.jsx(re,{side:"top",className:"max-w-[280px]",children:u.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:O(u.cacheReadTokens),write:O(u.cacheWriteTokens),uncached:O(u.uncachedInputTokens)})}),s.cacheBreak&&e.jsx("p",{className:"text-[hsl(var(--deck-accent))]",children:t("status.cacheBreak",{reason:t(Cs[s.cacheBreak.reason]??"status.cacheBreak.server"),previous:O(s.cacheBreak.previousCacheReadTokens),current:O(s.cacheBreak.cacheReadTokens)})})]})})]})}),e.jsx("div",{className:"flex-1"}),a&&o&&e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("span",{className:"deck-pulse-dot"}),e.jsx("span",{className:"text-[hsl(var(--deck-accent))]",children:o})]})]})}function Ts(t){const s=[...t].reverse().find(i=>i.role==="user");if(!s)return null;if(typeof s.content=="string")return{content:s.content,attachments:[]};const a=s.content.filter(i=>i.type==="text").map(i=>i.text).join(`
|
|
18
|
-
`),r=s.content.filter(i=>i.type==="image_url").map((i,n)=>{var f;const d=((f=i.image_url.url.match(/^data:([^;,]+)[;,]/))==null?void 0:f[1])??"application/octet-stream";return{id:`recovery-${s.id}-${n}`,name:`attachment-${n+1}`,mimeType:d,dataUrl:i.image_url.url}});return{content:a,attachments:r}}function Ds(){var V;const t=F(),s=y(g=>g.messages),a=y(g=>g.currentSessionRef),r=y(g=>g.isStreaming),i=y(g=>g.isStopping),n=y(g=>g.sessionEventConnectionState),d=y(g=>g.pendingSteeringCount),f=y(g=>g.pendingInputDelivery),l=y(g=>g.recoveredSteeringCount),c=y(g=>g.isLoading),k=y(g=>g.error),o=y(g=>g.errorContext),h=y(g=>g.sessions),u=y(g=>g.sendMessage),j=y(g=>g.abortSession),N=y(g=>g.retryTask),m=y(g=>g.retryingTaskKeys),w=ge(g=>g.openSettings),v=y(g=>g.reconnectSessionEvents),p=y(g=>g.clearError),[x,E]=b.useState(null),S=a?h.find(g=>g.sessionId===a.sessionId&&g.projectPath===a.projectPath):void 0,D=!!k&&((o==null?void 0:o.kind)==="navigation"||!(o!=null&&o.sessionRef)||Fe(o.sessionRef,a)),A=(o==null?void 0:o.failureCode)??((V=S==null?void 0:S.taskFailure)==null?void 0:V.code),L=(o==null?void 0:o.kind)==="execution"&&A?t(Nt(A)):k==="queue_full"?t("chat.error.queueFull"):k==="turn_unavailable"||k==="turn_active"?t("chat.error.turnChanged"):k,_=n==="connecting"||n==="reconnecting",C=r&&n!=="connected",B=a?`session:${Q(a)}`:"session:temporary",H=b.useMemo(()=>Ts(s),[s]),ce=a?Q(a):"temporary-session",z=!!(a&&(S!=null&&S.taskRetryAvailable)&&(!A||St(A)))&&((o==null?void 0:o.kind)==="execution"||(o==null?void 0:o.kind)==="task_action"),G=(o==null?void 0:o.kind)==="execution"&&(A==="authentication"||A==="permission"||A==="model_unavailable"),K=a?m.includes(Q(a)):!1;b.useEffect(()=>{E(null)},[ce]);const Y=async g=>u({content:g.content,modelId:g.modelId,reasoningEffort:g.reasoningEffort,serviceTier:g.serviceTier,responseVerbosity:g.responseVerbosity,communicationStyle:g.communicationStyle,...g.outputSchema?{outputSchema:g.outputSchema}:{},attachments:g.attachments.map(I=>({type:"image",content:I.dataUrl,mimeType:I.mimeType,name:I.name}))}),X=()=>j(),M=async()=>{if(G){p(),w("models");return}if(z&&a){p(),await N(a).catch(()=>{});return}if((o==null?void 0:o.kind)==="execution"&&H){E({...H,revision:Date.now()}),p();return}p(),requestAnimationFrame(()=>Xe())},P=z?t(K?"chat.error.action.retryingTask":"chat.error.action.retryTask"):G?t("chat.error.action.checkModels"):(o==null?void 0:o.kind)==="execution"&&H?t("chat.error.action.editResend"):(o==null?void 0:o.kind)==="submission"?t("chat.error.action.returnDraft"):null;return e.jsxs("div",{className:"flex h-full flex-col bg-[hsl(var(--deck-canvas))]",children:[D&&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(Oe,{className:"h-3.5 w-3.5 shrink-0"}),e.jsxs("span",{className:"min-w-0 flex-1 break-words",children:[e.jsx("span",{className:"font-semibold",children:t((o==null?void 0:o.kind)==="submission"?"chat.error.title.submission":(o==null?void 0:o.kind)==="execution"?"chat.error.title.execution":(o==null?void 0:o.kind)==="navigation"?"chat.error.title.navigation":"chat.error.title.generic")})," ",L]}),P&&e.jsxs("button",{type:"button",onClick:()=>void M(),disabled:K,className:"inline-flex min-h-7 shrink-0 items-center gap-1.5 rounded-md border border-red-300/70 bg-white/65 px-2.5 font-medium transition-colors hover:bg-white focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-red-500 disabled:cursor-wait disabled:opacity-60 dark:border-red-800 dark:bg-red-950/45 dark:hover:bg-red-900/60",children:[z?K?e.jsx(R,{className:"h-3 w-3 animate-spin"}):e.jsx(ke,{className:"h-3 w-3"}):e.jsx(Le,{className:"h-3 w-3"}),P]}),e.jsx("button",{type:"button",onClick:p,"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:"✕"})]}),(_||n==="offline")&&e.jsxs("div",{role:n==="offline"?"alert":"status","aria-live":"polite",className:"flex min-h-10 flex-wrap items-center gap-2 border-b border-amber-300/60 bg-amber-50/80 px-4 py-2 font-mono text-[11px] text-amber-900 dark:border-amber-800/60 dark:bg-amber-950/35 dark:text-amber-200 sm:px-5",children:[_?e.jsx(R,{className:"h-3.5 w-3.5 shrink-0 animate-spin"}):e.jsx(gt,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1",children:t(_?"chat.connection.reconnecting":"chat.connection.offline")}),n==="offline"&&e.jsxs("button",{type:"button",onClick:()=>void v().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(vt,{className:"h-3 w-3"}),t("chat.connection.retry")]})]}),e.jsx(Mt,{}),e.jsx(gs,{messages:s,isLoading:c},a?Q(a):"temporary-session"),e.jsx(ys,{}),e.jsx(js,{}),e.jsx(Ye,{draftKey:B,draft:x==null?void 0:x.content,draftAttachments:x==null?void 0:x.attachments,draftRevision:x==null?void 0:x.revision,onSend:Y,onAbort:X,disabled:c||C,isStreaming:r,isStopping:i,pendingSteeringCount:d,pendingInputDelivery:f,recoveredSteeringCount:l,workspacePath:a==null?void 0:a.projectPath},B),e.jsx(Es,{})]})}export{Ds as ChatView};
|