meshy-node 0.5.6 → 0.5.8
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/README.md +1 -1
- package/dashboard/assets/DashboardPage-DZvoRYz2.js +134 -0
- package/dashboard/assets/{DashboardShared-DMrNrARk.js → DashboardShared-EIrXwlKQ.js} +2 -2
- package/dashboard/assets/{DiffTab-CPgg5BgU.js → DiffTab-RR71B7Td.js} +3 -3
- package/dashboard/assets/{FilesTab-Bd6A8nUE.js → FilesTab-BzAuq2V1.js} +7 -7
- package/dashboard/assets/{PreviewTab-kljCXeWP.js → PreviewTab-Dul4hiGt.js} +2 -2
- package/dashboard/assets/SharedConversationPage-DmimAj_x.js +7 -0
- package/dashboard/assets/{file-CPaJOnu-.js → file-CL1x0Gq_.js} +1 -1
- package/dashboard/assets/{folder-DgOi0nrN.js → folder-B7_msHnX.js} +1 -1
- package/dashboard/assets/index-BlCzIaoB.css +1 -0
- package/dashboard/assets/index-C8QVuMfU.js +301 -0
- package/dashboard/assets/{play-DQGsm6yq.js → play-IZPebZI4.js} +1 -1
- package/dashboard/index.html +2 -2
- package/main.cjs +267 -82
- package/package.json +1 -1
- package/runtime-metadata.json +5 -5
- package/dashboard/assets/DashboardPage-BSAt8kN_.js +0 -129
- package/dashboard/assets/SharedConversationPage-DmcJdyZj.js +0 -7
- package/dashboard/assets/index-DgDWjVGo.css +0 -1
- package/dashboard/assets/index-nG4cAWuh.js +0 -301
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as h,r as g,j as n,B as P,C as T,b as E,X as oe,q as ie,
|
|
1
|
+
import{c as h,r as g,j as n,B as P,C as T,b as E,X as oe,q as ie,E as Q,bb as ae,s as ce,K as le}from"./index-C8QVuMfU.js";/**
|
|
2
2
|
* @license lucide-react v1.7.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -45,7 +45,7 @@ import{c as h,r as g,j as n,B as P,C as T,b as E,X as oe,q as ie,A as Q,b9 as ae
|
|
|
45
45
|
* See the LICENSE file in the root directory of this source tree.
|
|
46
46
|
*/const $e=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],ee=h("wrench",$e);function I(e){return typeof e=="object"&&e!==null}function ve(e){if(!I(e))return null;if(e.type==="text"&&typeof e.text=="string"){const t=e.text.trim();return t?{type:"text",text:t}:null}if(e.type==="image"&&typeof e.mediaType=="string"&&typeof e.data=="string"){const t=e.mediaType.trim(),r=e.data;return!t||!r?null:{type:"image",mediaType:t,data:r,...typeof e.filename=="string"&&e.filename.trim()?{filename:e.filename.trim()}:{}}}if(e.type==="tool_result"&&typeof e.toolUseId=="string"&&typeof e.content=="string"){const t=e.toolUseId.trim(),r=e.content.trim();return!t||!r?null:{type:"tool_result",toolUseId:t,content:r,...typeof e.isError=="boolean"?{isError:e.isError}:{}}}return null}function Ce(e){if(!I(e))return null;if(e.type==="text"&&typeof e.text=="string"){const s=e.text.trim();return s?{type:"text",text:s}:null}if(e.type!=="image"||!I(e.source)){if(e.type==="tool_result"&&typeof e.tool_use_id=="string"&&typeof e.content=="string"){const s=e.tool_use_id.trim(),o=e.content.trim();return!s||!o?null:{type:"tool_result",toolUseId:s,content:o,...typeof e.is_error=="boolean"?{isError:e.is_error}:{}}}return null}const t=typeof e.source.media_type=="string"?e.source.media_type.trim():"",r=typeof e.source.data=="string"?e.source.data:"";return!t||!r?null:{type:"image",mediaType:t,data:r}}function U(e){if(typeof e=="string"){const t=e.trim();return t?[{type:"text",text:t}]:[]}return Array.isArray(e)?e.map(t=>ve(t)??Ce(t)).filter(t=>t!==null):[]}function mt(e,t){const r=e.trim();return[...r?[{type:"text",text:r}]:[],...t]}function Ae(e){return{role:"user",content:e.map(t=>t.type==="text"?{type:"text",text:t.text}:t.type==="tool_result"?{type:"tool_result",tool_use_id:t.toolUseId,content:t.content,...typeof t.isError=="boolean"?{is_error:t.isError}:{}}:{type:"image",source:{type:"base64",media_type:t.mediaType,data:t.data}})}}function ft(e,t=new Date().toISOString()){return{type:"user",message:Ae(e),timestamp:t}}function _(e){if(e.type!=="user"||e.isSynthetic===!0)return null;if(typeof e.message=="string"){const t=U(e.message);return t.length>0?t:null}if(I(e.message)&&Array.isArray(e.message.content)){const t=U(e.message.content);return t.length>0?t:null}if(Array.isArray(e.content)){const t=U(e.content);return t.length>0?t:null}return null}function pt(e){return U(e.payload.initialMessage)}function b(e){return e.map(t=>{if(t.type==="text")return`t:${t.text}`;if(t.type==="tool_result")return`r:${t.toolUseId}:${t.isError===!0?"1":"0"}:${t.content}`;const r=t.data.slice(0,32),s=t.data.slice(-32);return`i:${t.mediaType}:${t.data.length}:${r}:${s}`}).join("|")}function Te(e){return e.map(t=>t.type==="text"?t.text:t.type==="tool_result"?t.content:"").filter(Boolean).join(`
|
|
47
47
|
`)}function Me(e){return`data:${e.mediaType};base64,${e.data}`}function xt(e){var o,i;if(!e)return[];const t=[],r=e.items;if(r)for(const a of Array.from(r)){if((a==null?void 0:a.kind)!=="file"||!((o=a.type)!=null&&o.startsWith("image/")))continue;const c=(i=a.getAsFile)==null?void 0:i.call(a);c&&c.type.startsWith("image/")&&t.push(c)}if(t.length>0)return t;const s=e.files;return s?Array.from(s).filter(a=>a.type.startsWith("image/")):[]}function Ue(e){return new Promise((t,r)=>{const s=new FileReader;s.onload=()=>{if(typeof s.result!="string"){r(new Error(`Failed to read ${e.name}`));return}t(s.result)},s.onerror=()=>r(s.error??new Error(`Failed to read ${e.name}`)),s.readAsDataURL(e)})}async function gt(e){return Promise.all(Array.from(e).map(async t=>{if(!t.type.startsWith("image/"))throw new Error(`${t.name} is not an image`);const r=await Ue(t),s=r.indexOf(",");if(s===-1)throw new Error(`Failed to parse ${t.name}`);return{type:"image",mediaType:t.type||"image/png",data:r.slice(s+1),filename:t.name}}))}function M(e){return typeof e=="object"&&e!==null}function Pe(e){return M(e)&&typeof e.name=="string"&&e.name.toLowerCase()==="askuserquestion"}function Ee(e){return!M(e)||typeof e.label!="string"||!e.label.trim()?null:{label:e.label.trim(),description:typeof e.description=="string"?e.description.trim():""}}function Ie(e){if(!M(e)||typeof e.question!="string"||!e.question.trim())return null;const t=Array.isArray(e.options)?e.options.map(Ee).filter(r=>r!==null):[];return t.length===0?null:{header:typeof e.header=="string"&&e.header.trim()?e.header.trim():void 0,question:e.question.trim(),multiSelect:e.multiSelect===!0,options:t}}function z(e){if(!M(e)||!Array.isArray(e.questions))return null;const t=e.questions.map(Ie).filter(r=>r!==null);return t.length===0?null:{questions:t}}function S(e){return JSON.stringify({questions:e.questions})}function O(e){const t=z(e);if(t)return t;if(Pe(e)){const r=M(e.input)?e.input:void 0,s=z(r);return s?{...s,...typeof e.id=="string"&&e.id.trim()?{toolUseId:e.id.trim()}:{}}:null}return null}function Oe(e){var o;const t=e.trim();if(!t)return[];const r=[t],s=t.matchAll(/```(?:json)?\s*([\s\S]*?)```/gi);for(const i of s){const a=(o=i[1])==null?void 0:o.trim();a&&r.push(a)}return r}function B(e){for(const t of Oe(e))try{const r=JSON.parse(t),s=z(r);if(s)return s}catch{}return null}function Be(e){return e.questions.map(t=>t.options.length>0?[0]:[])}function qe(e,t){return e.questions.every((r,s)=>(t[s]??[]).length>0)}function Fe(e,t){const s=e.questions.map((o,i)=>{const a=[...new Set(t[i]??[])].sort((c,u)=>c-u).filter(c=>o.options[c]!==void 0);return{header:o.header??null,question:o.question,multiSelect:o.multiSelect,selectedOptions:a.map(c=>o.options[c]).filter(c=>c!==void 0)}}).map(o=>{const i=o.header??o.question,a=o.selectedOptions.map(c=>c.label).join(o.multiSelect?", ":"");return`${i}: ${a}`}).join(`
|
|
48
|
-
`);return e.toolUseId?[{type:"tool_result",toolUseId:e.toolUseId,content:s,isError:!1}]:[{type:"text",text:s}]}function C(e){return typeof e=="object"&&e!==null}function ze(e){if(!e)return;const t=["file_path","path","command"].map(r=>e[r]).find(r=>typeof r=="string"&&r.trim().length>0);return t==null?void 0:t.trim()}function Je(e){const t=e.toLowerCase();return t.includes(" permission to write ")?"Write":t.includes(" permission to edit ")?"Edit":t.includes(" permission to run ")||t.includes(" permission to execute ")?"Bash":"Action"}function J(e){const t=e.trim();if(!t.startsWith("Awaiting your permission to "))return null;const r=t.match(/`([^`]+)`/);return{requests:[{toolName:Je(t),target:r==null?void 0:r[1],summary:t}]}}function Le(e){if(!Array.isArray(e.permission_denials))return null;const t=[];for(const r of e.permission_denials){if(!C(r)||typeof r.tool_name!="string")continue;const s=C(r.tool_input)?r.tool_input:void 0,o=ze(s),i=typeof e.result=="string"&&e.result.trim().length>0?e.result.trim():`Awaiting your permission to use ${r.tool_name}${o?` on \`${o}\``:""}.`;t.push({toolName:r.tool_name,...typeof r.tool_use_id=="string"?{toolUseId:r.tool_use_id}:{},...o?{target:o}:{},summary:i})}return t.length>0?{requests:t}:null}function K(e){if(!Array.isArray(e))return null;for(const t of e){if(!C(t)||t.type!=="text"||typeof t.text!="string")continue;const r=J(t.text);if(r)return r}return null}function V(e){if(!C(e))return null;const t=Le(e);if(t)return t;if(typeof e.result=="string"){const s=J(e.result);if(s)return s}if(typeof e.message=="string"){const s=J(e.message);if(s)return s}if(C(e.message)){const s=V(e.message);if(s)return s;const o=K(e.message.content);if(o)return o}const r=K(e.content);return r||null}function Re(e){return JSON.stringify(e.requests.map(t=>({toolName:t.toolName,target:t.target??null,summary:t.summary})))}function We(e,t){return e.requests.map(r=>{const s=r.target?` for \`${r.target}\``:"",o=t==="approve"?`Approved. Proceed with the requested ${r.toolName} action${s}.`:`Denied. Do not proceed with the requested ${r.toolName} action${s}. Ask for another approach if needed.`;return r.toolUseId?{type:"tool_result",toolUseId:r.toolUseId,content:o,isError:t==="deny"}:t==="approve"?{type:"text",text:o}:{type:"text",text:o}})}function Ve(e){return _(e)!==null}function L(e){return typeof e=="object"&&e!==null}function X(e){if(e.type==="user"){const t=_(e),r=typeof e.timestamp=="string"?e.timestamp:"";if(t)return`user:${r}:${b(t)}`}return JSON.stringify(e)}function $(e){return Array.isArray(e)?e.map(t=>$(t)):L(e)?Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0).sort(([t],[r])=>t.localeCompare(r)).map(([t,r])=>[t,$(r)])):e}function Y(e){const t=_(e);if(t)return`user:${b(t)}`;if(e.type==="assistant"){if(typeof e.message=="string")return`assistant:${JSON.stringify(e.message)}`;if(L(e.message)&&"content"in e.message)return`assistant:${JSON.stringify($(e.message.content))}`;if(Array.isArray(e.content))return`assistant:${JSON.stringify($(e.content))}`;if(L(e.message))return`assistant:${JSON.stringify($(e.message))}`}return JSON.stringify(e)}function G(e){if(typeof e.timestamp!="string")return null;const t=Date.parse(e.timestamp);return Number.isNaN(t)?null:t}function R(e){const t=O(e);return t?`question:${S(t)}`:null}function De(e){const t=V(e);return t?`permission:${Re(t)}`:null}function Z(e){if(!Array.isArray(e))return null;const t=new Set;for(const r of e){const s=R(r);if(s){t.add(s);continue}if(typeof r=="object"&&r!==null&&r.type==="text"&&typeof r.text=="string"){const o=B(r.text);o&&t.add(S(o))}}return t.size===0?null:Array.from(t).sort().join("|")}function He(e){const t=R(e);if(t)return t;if(typeof e.message=="string"){const r=B(e.message);return r?S(r):null}if(typeof e.message=="object"&&e.message!==null){const r=R(e.message);return r||Z(e.message.content)}return Z(e.content)}function Ke(e){return De(e)}function ht(e,t,r){const s=typeof t.timestamp=="string"?t.timestamp:"";return`${e}-${s}-${r}`}function yt(e,t){const r=new Map;for(const o of t){const i=Y(o);r.set(i,(r.get(i)??0)+1)}const s=[];for(let o=e.length-1;o>=0;o-=1){const i=e[o];if(!i)continue;const a=Y(i),c=r.get(a)??0;if(c>0){r.set(a,c-1);continue}s.push({...i})}return[...s.reverse(),...t.map(o=>({...o}))].map((o,i)=>({event:o,order:i})).sort((o,i)=>{const a=G(o.event),c=G(i.event);return a!==null&&c!==null&&a!==c?a-c:o.order-i.order}).map(o=>o.event)}function bt(e,t){const r=X(t);return e.some(s=>X(s)===r)?e:[...e,{...t}]}function jt(e,t){const r=new Map;for(const s of t){const o=_(s);if(!o)continue;const i=b(o);r.set(i,(r.get(i)??0)+1)}return e.filter(s=>{const o=b(s.content),i=r.get(o)??0;return i<=0?!0:(r.set(o,i-1),!1)})}function Nt(e,t){const r=b(t),s=e.findIndex(o=>b(o.content)===r);return s===-1?e:e.filter((o,i)=>i!==s)}function wt(e,t){const r=b(t);return e.some(s=>{const o=_(s);return o!==null&&b(o)===r})}function kt(e){const t=[];let r=null;for(const s of e){if(Ve(s)){r=null,t.push(s);continue}const o=Ke(s)??He(s);o&&o===r||(t.push(s),o&&(r=o))}return t}function A({payload:e,disabled:t=!1,bypassEnabled:r=!1,onBypassChange:s,onSubmit:o}){const[i,a]=g.useState(()=>r?Be(e):e.questions.map(()=>[])),[c,u]=g.useState(!1),[d,m]=g.useState(!1);g.useEffect(()=>{r&&a(l=>l.map((f,y)=>{var p;return f.length>0?f:(p=e.questions[y])!=null&&p.options.length?[0]:[]}))},[r,e]);const x=qe(e,i)&&!t&&!c&&!d&&!!o,j=(l,f)=>{t||d||c||a(y=>y.map((p,N)=>{if(N!==l)return p;const w=e.questions[N];return w?w.multiSelect?p.includes(f)?p.filter(q=>q!==f):[...p,f].sort((q,se)=>q-se):[f]:p}))},H=async()=>{if(!x||!o)return;u(!0);const l=await o(Fe(e,i));u(!1),l&&m(!0)};return n.jsxs("div",{className:"rounded-[24px] border border-primary/20 bg-primary/5 p-4 shadow-[0_24px_80px_-60px_hsl(var(--primary)/0.9)]",children:[n.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx("div",{className:"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-[14px] border border-primary/20 bg-primary/10 text-primary shadow-sm",children:n.jsx(fe,{className:"h-4 w-4"})}),n.jsxs("div",{children:[n.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.22em] text-primary/80",children:"Ask User Question"}),n.jsx("div",{className:"mt-1 text-sm leading-6 text-muted-foreground",children:"Select the answer you want to send back to the agent."})]})]}),n.jsxs(P,{type:"button",variant:r?"secondary":"outline",size:"sm",onClick:()=>s==null?void 0:s(!r),className:"rounded-[14px]",children:[n.jsx(ke,{className:"h-4 w-4"}),r?"Bypass on":"Bypass future questions"]})]}),n.jsx("div",{className:"mt-4 space-y-4",children:e.questions.map((l,f)=>{const y=i[f]??[];return n.jsxs("div",{className:"space-y-3 rounded-[20px] border border-border/60 bg-background/75 p-4",children:[n.jsxs("div",{children:[l.header&&n.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.24em] text-muted-foreground",children:l.header}),n.jsx("div",{className:"mt-1 text-sm font-medium leading-6 text-foreground",children:l.question}),n.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:l.multiSelect?"Select one or more options.":"Select one option."})]}),n.jsx("div",{className:"space-y-2",children:l.options.map((p,N)=>{const w=y.includes(N);return n.jsxs("button",{type:"button",onClick:()=>j(f,N),disabled:t||c||d,"aria-pressed":w,className:E("flex w-full items-start gap-3 rounded-[18px] border px-4 py-3 text-left transition-colors",w?"border-primary/50 bg-primary/10 text-foreground":"border-border/60 bg-background/80 text-foreground hover:border-primary/30 hover:bg-primary/5"),children:[n.jsx("span",{className:E("mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border",w?"border-primary bg-primary text-primary-foreground":"border-border/70 bg-background text-transparent"),children:n.jsx(T,{className:"h-3.5 w-3.5"})}),n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"block text-sm font-medium leading-5",children:p.label}),p.description&&n.jsx("span",{className:"mt-1 block text-xs leading-5 text-muted-foreground",children:p.description})]})]},`${p.label}-${N}`)})})]},`${l.header??"question"}-${f}`)})}),n.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-between gap-3",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:r?"Bypass is enabled. New question cards will default to the first option.":"Enable bypass if you want future question cards to preselect the first option."}),n.jsx(P,{type:"button",onClick:()=>void H(),disabled:!x,className:"rounded-[16px] px-5",children:d?"Sent":c?"Sending...":e.questions.length>1?"Send answers":"Send answer"})]})]})}function Xe({payload:e,disabled:t=!1,onSubmit:r}){const[s,o]=g.useState(null),[i,a]=g.useState(!1),c=!t&&!i&&!!r,u=async d=>{if(!c||!r)return;o(d);const m=await r(We(e,d));o(null),m&&a(!0)};return n.jsxs("div",{className:"rounded-[24px] border border-amber-500/25 bg-amber-500/5 p-4 shadow-[0_24px_80px_-60px_rgba(245,158,11,0.8)]",children:[n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx("div",{className:"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-[14px] border border-amber-500/25 bg-amber-500/10 text-amber-600 shadow-sm dark:text-amber-400",children:n.jsx(Ne,{className:"h-4 w-4"})}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.22em] text-amber-700/80 dark:text-amber-300/80",children:"Permission Request"}),n.jsx("div",{className:"mt-1 space-y-3",children:e.requests.map((d,m)=>n.jsxs("div",{className:"rounded-[18px] border border-border/60 bg-background/75 px-4 py-3",children:[n.jsx("div",{className:"text-sm font-medium leading-6 text-foreground",children:d.summary}),(d.toolName||d.target)&&n.jsxs("div",{className:"mt-2 flex flex-wrap gap-2 text-[11px] uppercase tracking-[0.18em] text-muted-foreground",children:[n.jsx("span",{children:d.toolName}),d.target&&n.jsx("span",{className:"font-mono normal-case tracking-normal",children:d.target})]})]},`${d.toolUseId??d.toolName}-${m}`))})]})]}),n.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-end gap-2",children:[n.jsxs(P,{type:"button",variant:"outline",onClick:()=>void u("deny"),disabled:!c||s!==null,className:"rounded-[14px]",children:[n.jsx(oe,{className:"h-4 w-4"}),i?"Sent":s==="deny"?"Sending...":"Deny"]}),n.jsxs(P,{type:"button",onClick:()=>void u("approve"),disabled:!c||s!==null,className:"rounded-[14px]",children:[n.jsx(T,{className:"h-4 w-4"}),i?"Sent":s==="approve"?"Sending...":"Approve"]})]})]})}function _t({event:e,questionBypassEnabled:t=!1,onQuestionBypassChange:r,onSubmitQuestionResponse:s,questionResponseDisabled:o=!1}){const i=e.type,a=V(e),c=O(e);if(a)return n.jsx(v,{children:n.jsx(Xe,{payload:a,onSubmit:s,disabled:o})});if(c)return n.jsx(v,{children:n.jsx(A,{payload:c,bypassEnabled:t,onBypassChange:r,onSubmit:s,disabled:o})});if(i==="user"){const u=Ye(e),d=u.filter(x=>x.type==="tool_result");if(d.length>0&&u.every(x=>x.type==="tool_result"))return n.jsx(v,{children:d.map((x,j)=>n.jsx(ne,{block:x,questionBypassEnabled:t,onQuestionBypassChange:r,onSubmitQuestionResponse:s,questionResponseDisabled:o},j))});const m=_(e);return m?n.jsx(tt,{content:m}):null}return i==="assistant"?n.jsx(rt,{event:e,questionBypassEnabled:t,onQuestionBypassChange:r,onSubmitQuestionResponse:s,questionResponseDisabled:o}):null}function Ye(e){const t=e.message,r=t==null?void 0:t.content;if(Array.isArray(r))return r.filter(o=>typeof o=="object"&&o!==null);const s=e.content;return Array.isArray(s)?s.filter(o=>typeof o=="object"&&o!==null):[]}function F(e){var r;const t=e.replace(/\r\n/g,`
|
|
48
|
+
`);return e.toolUseId?[{type:"tool_result",toolUseId:e.toolUseId,content:s,isError:!1}]:[{type:"text",text:s}]}function C(e){return typeof e=="object"&&e!==null}function ze(e){if(!e)return;const t=["file_path","path","command"].map(r=>e[r]).find(r=>typeof r=="string"&&r.trim().length>0);return t==null?void 0:t.trim()}function Je(e){const t=e.toLowerCase();return t.includes(" permission to write ")?"Write":t.includes(" permission to edit ")?"Edit":t.includes(" permission to run ")||t.includes(" permission to execute ")?"Bash":"Action"}function J(e){const t=e.trim();if(!t.startsWith("Awaiting your permission to "))return null;const r=t.match(/`([^`]+)`/);return{requests:[{toolName:Je(t),target:r==null?void 0:r[1],summary:t}]}}function Le(e){if(!Array.isArray(e.permission_denials))return null;const t=[];for(const r of e.permission_denials){if(!C(r)||typeof r.tool_name!="string")continue;const s=C(r.tool_input)?r.tool_input:void 0,o=ze(s),i=typeof e.result=="string"&&e.result.trim().length>0?e.result.trim():`Awaiting your permission to use ${r.tool_name}${o?` on \`${o}\``:""}.`;t.push({toolName:r.tool_name,...typeof r.tool_use_id=="string"?{toolUseId:r.tool_use_id}:{},...o?{target:o}:{},summary:i})}return t.length>0?{requests:t}:null}function H(e){if(!Array.isArray(e))return null;for(const t of e){if(!C(t)||t.type!=="text"||typeof t.text!="string")continue;const r=J(t.text);if(r)return r}return null}function V(e){if(!C(e))return null;const t=Le(e);if(t)return t;if(typeof e.result=="string"){const s=J(e.result);if(s)return s}if(typeof e.message=="string"){const s=J(e.message);if(s)return s}if(C(e.message)){const s=V(e.message);if(s)return s;const o=H(e.message.content);if(o)return o}const r=H(e.content);return r||null}function Re(e){return JSON.stringify(e.requests.map(t=>({toolName:t.toolName,target:t.target??null,summary:t.summary})))}function We(e,t){return e.requests.map(r=>{const s=r.target?` for \`${r.target}\``:"",o=t==="approve"?`Approved. Proceed with the requested ${r.toolName} action${s}.`:`Denied. Do not proceed with the requested ${r.toolName} action${s}. Ask for another approach if needed.`;return r.toolUseId?{type:"tool_result",toolUseId:r.toolUseId,content:o,isError:t==="deny"}:t==="approve"?{type:"text",text:o}:{type:"text",text:o}})}function Ve(e){return _(e)!==null}function L(e){return typeof e=="object"&&e!==null}function X(e){if(e.type==="user"){const t=_(e),r=typeof e.timestamp=="string"?e.timestamp:"";if(t)return`user:${r}:${b(t)}`}return JSON.stringify(e)}function $(e){return Array.isArray(e)?e.map(t=>$(t)):L(e)?Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0).sort(([t],[r])=>t.localeCompare(r)).map(([t,r])=>[t,$(r)])):e}function Y(e){const t=_(e);if(t)return`user:${b(t)}`;if(e.type==="assistant"){if(typeof e.message=="string")return`assistant:${JSON.stringify(e.message)}`;if(L(e.message)&&"content"in e.message)return`assistant:${JSON.stringify($(e.message.content))}`;if(Array.isArray(e.content))return`assistant:${JSON.stringify($(e.content))}`;if(L(e.message))return`assistant:${JSON.stringify($(e.message))}`}return JSON.stringify(e)}function G(e){if(typeof e.timestamp!="string")return null;const t=Date.parse(e.timestamp);return Number.isNaN(t)?null:t}function R(e){const t=O(e);return t?`question:${S(t)}`:null}function De(e){const t=V(e);return t?`permission:${Re(t)}`:null}function Z(e){if(!Array.isArray(e))return null;const t=new Set;for(const r of e){const s=R(r);if(s){t.add(s);continue}if(typeof r=="object"&&r!==null&&r.type==="text"&&typeof r.text=="string"){const o=B(r.text);o&&t.add(S(o))}}return t.size===0?null:Array.from(t).sort().join("|")}function Ke(e){const t=R(e);if(t)return t;if(typeof e.message=="string"){const r=B(e.message);return r?S(r):null}if(typeof e.message=="object"&&e.message!==null){const r=R(e.message);return r||Z(e.message.content)}return Z(e.content)}function He(e){return De(e)}function ht(e,t,r){const s=typeof t.timestamp=="string"?t.timestamp:"";return`${e}-${s}-${r}`}function yt(e,t){const r=new Map;for(const o of t){const i=Y(o);r.set(i,(r.get(i)??0)+1)}const s=[];for(let o=e.length-1;o>=0;o-=1){const i=e[o];if(!i)continue;const a=Y(i),c=r.get(a)??0;if(c>0){r.set(a,c-1);continue}s.push({...i})}return[...s.reverse(),...t.map(o=>({...o}))].map((o,i)=>({event:o,order:i})).sort((o,i)=>{const a=G(o.event),c=G(i.event);return a!==null&&c!==null&&a!==c?a-c:o.order-i.order}).map(o=>o.event)}function bt(e,t){const r=X(t);return e.some(s=>X(s)===r)?e:[...e,{...t}]}function jt(e,t){const r=new Map;for(const s of t){const o=_(s);if(!o)continue;const i=b(o);r.set(i,(r.get(i)??0)+1)}return e.filter(s=>{const o=b(s.content),i=r.get(o)??0;return i<=0?!0:(r.set(o,i-1),!1)})}function Nt(e,t){const r=b(t),s=e.findIndex(o=>b(o.content)===r);return s===-1?e:e.filter((o,i)=>i!==s)}function wt(e,t){const r=b(t);return e.some(s=>{const o=_(s);return o!==null&&b(o)===r})}function kt(e){const t=[];let r=null;for(const s of e){if(Ve(s)){r=null,t.push(s);continue}const o=He(s)??Ke(s);o&&o===r||(t.push(s),o&&(r=o))}return t}function A({payload:e,disabled:t=!1,bypassEnabled:r=!1,onBypassChange:s,onSubmit:o}){const[i,a]=g.useState(()=>r?Be(e):e.questions.map(()=>[])),[c,u]=g.useState(!1),[d,m]=g.useState(!1);g.useEffect(()=>{r&&a(l=>l.map((f,y)=>{var p;return f.length>0?f:(p=e.questions[y])!=null&&p.options.length?[0]:[]}))},[r,e]);const x=qe(e,i)&&!t&&!c&&!d&&!!o,j=(l,f)=>{t||d||c||a(y=>y.map((p,N)=>{if(N!==l)return p;const w=e.questions[N];return w?w.multiSelect?p.includes(f)?p.filter(q=>q!==f):[...p,f].sort((q,se)=>q-se):[f]:p}))},K=async()=>{if(!x||!o)return;u(!0);const l=await o(Fe(e,i));u(!1),l&&m(!0)};return n.jsxs("div",{className:"rounded-[24px] border border-primary/20 bg-primary/5 p-4 shadow-[0_24px_80px_-60px_hsl(var(--primary)/0.9)]",children:[n.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx("div",{className:"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-[14px] border border-primary/20 bg-primary/10 text-primary shadow-sm",children:n.jsx(fe,{className:"h-4 w-4"})}),n.jsxs("div",{children:[n.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.22em] text-primary/80",children:"Ask User Question"}),n.jsx("div",{className:"mt-1 text-sm leading-6 text-muted-foreground",children:"Select the answer you want to send back to the agent."})]})]}),n.jsxs(P,{type:"button",variant:r?"secondary":"outline",size:"sm",onClick:()=>s==null?void 0:s(!r),className:"rounded-[14px]",children:[n.jsx(ke,{className:"h-4 w-4"}),r?"Bypass on":"Bypass future questions"]})]}),n.jsx("div",{className:"mt-4 space-y-4",children:e.questions.map((l,f)=>{const y=i[f]??[];return n.jsxs("div",{className:"space-y-3 rounded-[20px] border border-border/60 bg-background/75 p-4",children:[n.jsxs("div",{children:[l.header&&n.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.24em] text-muted-foreground",children:l.header}),n.jsx("div",{className:"mt-1 text-sm font-medium leading-6 text-foreground",children:l.question}),n.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:l.multiSelect?"Select one or more options.":"Select one option."})]}),n.jsx("div",{className:"space-y-2",children:l.options.map((p,N)=>{const w=y.includes(N);return n.jsxs("button",{type:"button",onClick:()=>j(f,N),disabled:t||c||d,"aria-pressed":w,className:E("flex w-full items-start gap-3 rounded-[18px] border px-4 py-3 text-left transition-colors",w?"border-primary/50 bg-primary/10 text-foreground":"border-border/60 bg-background/80 text-foreground hover:border-primary/30 hover:bg-primary/5"),children:[n.jsx("span",{className:E("mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border",w?"border-primary bg-primary text-primary-foreground":"border-border/70 bg-background text-transparent"),children:n.jsx(T,{className:"h-3.5 w-3.5"})}),n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"block text-sm font-medium leading-5",children:p.label}),p.description&&n.jsx("span",{className:"mt-1 block text-xs leading-5 text-muted-foreground",children:p.description})]})]},`${p.label}-${N}`)})})]},`${l.header??"question"}-${f}`)})}),n.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-between gap-3",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:r?"Bypass is enabled. New question cards will default to the first option.":"Enable bypass if you want future question cards to preselect the first option."}),n.jsx(P,{type:"button",onClick:()=>void K(),disabled:!x,className:"rounded-[16px] px-5",children:d?"Sent":c?"Sending...":e.questions.length>1?"Send answers":"Send answer"})]})]})}function Xe({payload:e,disabled:t=!1,onSubmit:r}){const[s,o]=g.useState(null),[i,a]=g.useState(!1),c=!t&&!i&&!!r,u=async d=>{if(!c||!r)return;o(d);const m=await r(We(e,d));o(null),m&&a(!0)};return n.jsxs("div",{className:"rounded-[24px] border border-amber-500/25 bg-amber-500/5 p-4 shadow-[0_24px_80px_-60px_rgba(245,158,11,0.8)]",children:[n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx("div",{className:"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-[14px] border border-amber-500/25 bg-amber-500/10 text-amber-600 shadow-sm dark:text-amber-400",children:n.jsx(Ne,{className:"h-4 w-4"})}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.22em] text-amber-700/80 dark:text-amber-300/80",children:"Permission Request"}),n.jsx("div",{className:"mt-1 space-y-3",children:e.requests.map((d,m)=>n.jsxs("div",{className:"rounded-[18px] border border-border/60 bg-background/75 px-4 py-3",children:[n.jsx("div",{className:"text-sm font-medium leading-6 text-foreground",children:d.summary}),(d.toolName||d.target)&&n.jsxs("div",{className:"mt-2 flex flex-wrap gap-2 text-[11px] uppercase tracking-[0.18em] text-muted-foreground",children:[n.jsx("span",{children:d.toolName}),d.target&&n.jsx("span",{className:"font-mono normal-case tracking-normal",children:d.target})]})]},`${d.toolUseId??d.toolName}-${m}`))})]})]}),n.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-end gap-2",children:[n.jsxs(P,{type:"button",variant:"outline",onClick:()=>void u("deny"),disabled:!c||s!==null,className:"rounded-[14px]",children:[n.jsx(oe,{className:"h-4 w-4"}),i?"Sent":s==="deny"?"Sending...":"Deny"]}),n.jsxs(P,{type:"button",onClick:()=>void u("approve"),disabled:!c||s!==null,className:"rounded-[14px]",children:[n.jsx(T,{className:"h-4 w-4"}),i?"Sent":s==="approve"?"Sending...":"Approve"]})]})]})}function _t({event:e,questionBypassEnabled:t=!1,onQuestionBypassChange:r,onSubmitQuestionResponse:s,questionResponseDisabled:o=!1}){const i=e.type,a=V(e),c=O(e);if(a)return n.jsx(v,{children:n.jsx(Xe,{payload:a,onSubmit:s,disabled:o})});if(c)return n.jsx(v,{children:n.jsx(A,{payload:c,bypassEnabled:t,onBypassChange:r,onSubmit:s,disabled:o})});if(i==="user"){const u=Ye(e),d=u.filter(x=>x.type==="tool_result");if(d.length>0&&u.every(x=>x.type==="tool_result"))return n.jsx(v,{children:d.map((x,j)=>n.jsx(ne,{block:x,questionBypassEnabled:t,onQuestionBypassChange:r,onSubmitQuestionResponse:s,questionResponseDisabled:o},j))});const m=_(e);return m?n.jsx(tt,{content:m}):null}return i==="assistant"?n.jsx(rt,{event:e,questionBypassEnabled:t,onQuestionBypassChange:r,onSubmitQuestionResponse:s,questionResponseDisabled:o}):null}function Ye(e){const t=e.message,r=t==null?void 0:t.content;if(Array.isArray(r))return r.filter(o=>typeof o=="object"&&o!==null);const s=e.content;return Array.isArray(s)?s.filter(o=>typeof o=="object"&&o!==null):[]}function F(e){var r;const t=e.replace(/\r\n/g,`
|
|
49
49
|
`).split(`
|
|
50
50
|
`);for(;t.length>0&&((r=t[0])==null?void 0:r.trim())==="";)t.shift();return t.join(`
|
|
51
51
|
`)}const Ge=/\b((?:https?:\/\/|www\.)[^\s<>()[\]{}'"`]+[^\s<>()[\]{}'"`.,;:!?])/gi;function te({text:e,className:t=""}){const r=[];let s=0;for(const o of e.matchAll(Ge)){const i=o.index??0;i>s&&r.push({kind:"text",value:e.slice(s,i)});const a=o[0],c=a.startsWith("www.")?`https://${a}`:a;r.push({kind:"link",value:a,href:c}),s=i+a.length}return s<e.length&&r.push({kind:"text",value:e.slice(s)}),r.length===0&&r.push({kind:"text",value:e}),n.jsx("div",{className:`whitespace-pre-wrap break-words [overflow-wrap:anywhere] ${t}`,children:r.map((o,i)=>o.kind==="link"?n.jsx("a",{href:o.href,target:"_blank",rel:"noreferrer noopener",className:"underline decoration-current/40 underline-offset-2 hover:decoration-current",onClick:a=>a.stopPropagation(),children:o.value},i):n.jsx("span",{children:o.value},i))})}function re({text:e,className:t=""}){const[r,s]=g.useState(!1);if(!e)return null;const o=async i=>{i.stopPropagation();try{await navigator.clipboard.writeText(e),s(!0),setTimeout(()=>s(!1),1500)}catch{}};return n.jsx("button",{type:"button",onClick:o,"aria-label":r?"Copied":"Copy message",className:`flex h-6 w-6 items-center justify-center rounded-[10px] border border-border/60 bg-background/86 text-muted-foreground opacity-0 shadow-sm backdrop-blur transition-all hover:-translate-y-px hover:text-foreground group-hover:opacity-100 focus-visible:opacity-100 ${t}`,children:r?n.jsx(T,{className:"h-3 w-3 text-emerald-500"}):n.jsx(Q,{className:"h-3 w-3"})})}async function Ze(e){let r=await(await fetch(e)).blob();r.type!=="image/png"&&(r=await Qe(r)),await navigator.clipboard.write([new ClipboardItem({[r.type]:r})])}async function Qe(e){const t=await createImageBitmap(e),r=document.createElement("canvas");r.width=t.width,r.height=t.height;const s=r.getContext("2d");if(!s)throw new Error("canvas 2d context unavailable");return s.drawImage(t,0,0),await new Promise((o,i)=>{r.toBlob(a=>a?o(a):i(new Error("toBlob failed")),"image/png")})}function et({dataUrl:e,className:t=""}){const[r,s]=g.useState(!1),o=async i=>{i.stopPropagation();try{await Ze(e),s(!0),setTimeout(()=>s(!1),1500)}catch(a){console.error("copy image failed",a)}};return n.jsx("button",{type:"button",onClick:o,"aria-label":r?"Copied":"Copy image",className:`flex h-6 w-6 items-center justify-center rounded-[10px] border border-border/60 bg-background/86 text-muted-foreground opacity-0 shadow-sm backdrop-blur transition-all hover:-translate-y-px hover:text-foreground group-hover:opacity-100 focus-visible:opacity-100 ${t}`,children:r?n.jsx(T,{className:"h-3 w-3 text-emerald-500"}):n.jsx(Q,{className:"h-3 w-3"})})}function tt({content:e}){const t=Te(e),r=e.filter(s=>s.type==="image");return n.jsx("div",{className:"animate-message-rise flex justify-end",children:n.jsxs("div",{className:"group relative flex max-w-[88%] items-start gap-3",children:[n.jsx(re,{text:t,className:"absolute -left-8 top-7"}),n.jsxs("div",{className:"flex min-w-0 flex-col items-end gap-1",children:[n.jsx("div",{className:"pr-1 text-[10px] font-semibold uppercase tracking-[0.28em] text-muted-foreground",children:"You"}),n.jsxs("div",{className:"space-y-1 rounded-[24px] rounded-br-[9px] border border-primary/20 bg-primary px-3.5 py-2.5 text-[12px] leading-[18px] text-primary-foreground shadow-[0_22px_72px_-44px_hsl(var(--primary)/0.95)]",children:[t&&n.jsx(te,{text:t}),r.length>0&&n.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:r.map((s,o)=>{const i=Me(s);return n.jsxs("div",{className:"relative",children:[n.jsx("img",{src:i,alt:s.filename??`attachment ${o+1}`,className:"max-h-72 w-full rounded-2xl border border-primary-foreground/15 object-cover"}),n.jsx(et,{dataUrl:i,className:"absolute right-2 top-2"})]},`${s.filename??"image"}-${o}`)})})]})]}),n.jsx("div",{className:"mt-6 flex h-8 w-8 shrink-0 items-center justify-center rounded-[14px] border border-primary/20 bg-primary/10 text-primary shadow-sm",children:n.jsx(Se,{className:"h-4 w-4"})})]})})}function v({children:e}){return n.jsx("div",{className:"animate-message-rise flex justify-start",children:n.jsxs("div",{className:"flex max-w-[92%] items-start gap-3",children:[n.jsx("div",{className:"mt-6 flex h-8 w-8 shrink-0 items-center justify-center rounded-[14px] border border-border/70 bg-muted/70 text-muted-foreground shadow-sm",children:n.jsx(ie,{className:"h-4 w-4"})}),n.jsxs("div",{className:"min-w-0 space-y-2",children:[n.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.28em] text-muted-foreground",children:"Agent"}),e]})]})})}function rt({event:e,questionBypassEnabled:t,onQuestionBypassChange:r,onSubmitQuestionResponse:s,questionResponseDisabled:o}){const i=e.message;if(!i)return null;const a=O(i);if(a)return n.jsx(v,{children:n.jsx(A,{payload:a,bypassEnabled:t,onBypassChange:r,onSubmit:s,disabled:o})});const c=i.content;if(!c||!Array.isArray(c))return null;const u=new Set,d=c.filter(l=>l.type==="text").map(l=>({...l,text:F(String(l.text??"")),questionPayload:B(F(String(l.text??"")))})).filter(l=>l.text.length>0||l.questionPayload),m=c.filter(l=>l.type==="thinking").map(l=>F(String(l.thinking??""))).filter(Boolean).join(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as l,
|
|
1
|
+
import{r as l,bj as P,bd as O,j as e,K as g,b as N,s as $,i as T}from"./index-C8QVuMfU.js";import{G as R}from"./DashboardPage-DZvoRYz2.js";import{F as _}from"./file-CL1x0Gq_.js";import{F as B}from"./folder-B7_msHnX.js";import"./DashboardShared-EIrXwlKQ.js";import"./play-IZPebZI4.js";function D(r,t){if(!(r!=null&&r.trim()))return[];const s=r.split(`
|
|
2
2
|
`),n=[];let a=[];const d=()=>{if(a.length===0)return;const c=a.join(`
|
|
3
|
-
`).trim();if(!c){a=[];return}const i=
|
|
4
|
-
`);return e.jsxs("div",{className:"rounded-[20px] border border-border/60 bg-background/55",children:[e.jsxs("div",{className:"border-b border-border/60 px-3 py-2",children:[e.jsx("div",{className:"text-[12px] font-medium text-foreground",children:"File diff"}),e.jsxs("div",{className:"mt-0.5 text-[10px] text-muted-foreground",children:[t.length," lines"]})]}),e.jsx("div",{className:"font-mono text-[11px] leading-5",children:t.map((s,n)=>e.jsxs("div",{className:N("grid grid-cols-[44px_minmax(0,1fr)] gap-3 px-3 py-0.5",
|
|
3
|
+
`).trim();if(!c){a=[];return}const i=J(a);if(!i){a=[];return}n.push({id:`${t}:${i}`,path:i,section:t,patch:c}),a=[]};for(const c of s)c.startsWith("diff --git ")&&a.length>0&&d(),a.push(c);return d(),n}function I(r){const t=[];for(const s of[...r].sort((n,a)=>n.path.localeCompare(a.path))){const n=s.path.split("/").filter(Boolean);let a=t,d="";n.forEach((c,i)=>{d=d?`${d}/${c}`:c;const h=i===n.length-1;let u=a.find(b=>b.name===c);u||(u=h?{type:"file",name:c,path:d,item:s}:{type:"folder",name:c,path:d,children:[]},a.push(u)),h||(u.children??(u.children=[]),a=u.children)})}return t}function G(r){const t=[];let s="";for(const n of r.split("/").filter(Boolean).slice(0,-1))s=s?`${s}/${n}`:n,t.push(s);return t}function A(r){return r.filter(t=>t&&!t.endsWith("/")).map(t=>({id:`untracked:${t}`,path:t,section:"untracked"}))}function J(r){var d,c;const t=(d=r.find(i=>i.startsWith("+++ ")))==null?void 0:d.slice(4).trim();if(t&&t!=="/dev/null")return w(t);const s=(c=r.find(i=>i.startsWith("--- ")))==null?void 0:c.slice(4).trim();if(s&&s!=="/dev/null")return w(s);const n=r.find(i=>i.startsWith("diff --git "));if(!n)return null;const a=n.match(/^diff --git a\/(.+?) b\/(.+)$/);return a?w(a[2]||a[1]||""):null}function w(r){return r.replace(/^[ab]\//,"")}const y={staged:"Staged",unstaged:"Unstaged",untracked:"Untracked"};function se({taskId:r}){const[t,s]=l.useState(null),[n,a]=l.useState(!0),[d,c]=l.useState(null),[i,h]=l.useState(null),[u,b]=l.useState(null),[L,v]=l.useState(!1),[M,k]=l.useState(null),S=l.useCallback(async()=>{a(!0),c(null),s(null);try{const o=await P(r);s(o)}catch(o){c(o instanceof Error?o.message:"Failed to load diff")}finally{a(!1)}},[r]);l.useEffect(()=>{S()},[S]);const F=l.useMemo(()=>D(t==null?void 0:t.staged,"staged"),[t==null?void 0:t.staged]),E=l.useMemo(()=>D(t==null?void 0:t.unstaged,"unstaged"),[t==null?void 0:t.unstaged]),C=l.useMemo(()=>A((t==null?void 0:t.untrackedFiles)??[]),[t==null?void 0:t.untrackedFiles]),j=l.useMemo(()=>[{section:"staged",items:F},{section:"unstaged",items:E},{section:"untracked",items:C}],[F,E,C]),p=l.useMemo(()=>j.flatMap(o=>o.items),[j]),f=l.useMemo(()=>p.find(o=>o.id===i)??p[0]??null,[p,i]);return l.useEffect(()=>{var o;(!i||!p.some(m=>m.id===i))&&h(((o=p[0])==null?void 0:o.id)??null)},[p,i]),l.useEffect(()=>{if(b(null),k(null),v(!1),!f||f.section!=="untracked")return;if(f.path.endsWith("/")){k("This untracked path is a directory. Open the Files tab to inspect its contents.");return}let o=!1;return v(!0),O(r,f.path).then(m=>{o||b(m)}).catch(m=>{o||k(m instanceof Error?m.message:"Failed to load file content")}).finally(()=>{o||v(!1)}),()=>{o=!0}},[f,r]),n?e.jsx(x,{tone:"muted",children:"Loading diff..."}):d?e.jsx(x,{tone:"destructive",children:d}):t!=null&&t.available?p.length>0?e.jsxs("div",{className:"grid h-full min-h-0 grid-cols-1 lg:grid-cols-[18rem_minmax(0,1fr)]",children:[e.jsxs("aside",{className:"flex min-h-0 flex-col border-b border-border/60 bg-background/30 lg:border-b-0 lg:border-r",children:[e.jsxs("div",{className:"shrink-0 border-b border-border/60 px-3 py-2.5",children:[e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.24em] text-muted-foreground",children:"Repository diff"}),e.jsx("div",{className:"mt-1.5 flex items-start justify-between gap-2",children:e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] font-semibold text-foreground",children:[e.jsx(R,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"truncate",children:t.branch??"detached HEAD"})]}),t.repoRoot&&e.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] text-muted-foreground",children:t.repoRoot})]})}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:j.map(o=>e.jsxs(g,{variant:"outline",className:"rounded-full border-border/70 bg-background/60 text-[10px]",children:[y[o.section]," ",o.items.length]},o.section))})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-1.5",children:e.jsx("div",{className:"space-y-1.5",children:j.map(({section:o,items:m})=>e.jsx(V,{section:o,items:m,selectedId:(f==null?void 0:f.id)??null,onSelect:h},o))})})]}),e.jsx("section",{className:"min-h-0 flex flex-col bg-card/10",children:f?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"shrink-0 border-b border-border/60 px-3 py-2.5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx(g,{variant:"outline",className:"rounded-full border-border/70 bg-background/60 text-[10px]",children:y[f.section]}),f.section==="untracked"?e.jsx(g,{variant:"secondary",className:"rounded-full text-[10px]",children:"File content"}):e.jsx(g,{variant:"secondary",className:"rounded-full text-[10px]",children:"Diff patch"})]}),e.jsx("div",{className:"mt-1.5 break-all font-mono text-[10px] text-muted-foreground",children:f.path})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-2.5",children:f.section==="untracked"?e.jsx(K,{loading:L,error:M,content:u}):e.jsx(H,{patch:f.patch??""})})]}):e.jsx(x,{tone:"muted",children:"Select a file to inspect."})})]}):e.jsx(x,{tone:"muted",children:"Working tree is clean."}):e.jsx(x,{tone:"muted",children:"Task working directory is not inside a Git repository."})}function V({section:r,items:t,selectedId:s,onSelect:n}){const a=l.useMemo(()=>I(t),[t]),d=l.useMemo(()=>t.find(u=>u.id===s)??null,[t,s]),c=l.useMemo(()=>new Set(d?G(d.path):[]),[d]),[i,h]=l.useState(!0);return e.jsxs("section",{className:"rounded-[16px] border border-border/60 bg-background/35",children:[e.jsxs("button",{type:"button",onClick:()=>h(u=>!u),"aria-expanded":i,className:N("flex w-full items-center justify-between gap-2 px-2.5 py-1.5 text-left transition-colors hover:bg-background/55",i?"border-b border-border/60":""),children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[i?e.jsx($,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):e.jsx(T,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"text-[12px] font-medium text-foreground",children:y[r]})]}),e.jsx(g,{variant:"outline",className:"rounded-full border-border/70 bg-background/60 text-[10px]",children:t.length})]}),i&&e.jsx("div",{className:"p-1.5",children:a.length>0?e.jsx("div",{className:"space-y-0.5",children:a.map(u=>e.jsx(U,{node:u,depth:0,selectedId:s,expandedAncestorPaths:c,onSelect:n},`${r}:${u.path}`))}):e.jsx("div",{className:"rounded-[12px] border border-dashed border-border/70 bg-background/30 px-2.5 py-1.5 text-[11px] text-muted-foreground",children:"No files."})})]})}function U({node:r,depth:t,selectedId:s,expandedAncestorPaths:n,onSelect:a}){var d;return r.type==="folder"?e.jsx(z,{node:r,depth:t,selectedId:s,expandedAncestorPaths:n,onSelect:a}):e.jsxs("button",{type:"button",onClick:()=>{r.item&&a(r.item.id)},className:N("flex w-full cursor-pointer items-center gap-1.5 rounded-[10px] px-1.5 py-1 text-left transition-colors",((d=r.item)==null?void 0:d.id)===s?"bg-primary/10 text-foreground":"text-foreground/90 hover:bg-background/55"),style:{paddingLeft:`${t*12+6}px`},children:[e.jsx(_,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate text-[12px]",children:r.name})]})}function z({node:r,depth:t,selectedId:s,expandedAncestorPaths:n,onSelect:a}){const[d,c]=l.useState(!0);return l.useEffect(()=>{n.has(r.path)&&c(!0)},[n,r.path]),e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>c(i=>!i),"aria-expanded":d,className:"flex w-full cursor-pointer select-none items-center gap-1.5 rounded-[10px] px-1.5 py-1 text-left text-[12px] text-muted-foreground transition-colors hover:bg-background/55 hover:text-foreground",style:{paddingLeft:`${t*12+6}px`},children:[d?e.jsx($,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(T,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx(B,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate",children:r.name})]}),d&&e.jsx("div",{className:"space-y-0.5",children:(r.children??[]).map(i=>e.jsx(U,{node:i,depth:t+1,selectedId:s,expandedAncestorPaths:n,onSelect:a},i.path))})]})}function H({patch:r}){const t=r.split(`
|
|
4
|
+
`);return e.jsxs("div",{className:"rounded-[20px] border border-border/60 bg-background/55",children:[e.jsxs("div",{className:"border-b border-border/60 px-3 py-2",children:[e.jsx("div",{className:"text-[12px] font-medium text-foreground",children:"File diff"}),e.jsxs("div",{className:"mt-0.5 text-[10px] text-muted-foreground",children:[t.length," lines"]})]}),e.jsx("div",{className:"font-mono text-[11px] leading-5",children:t.map((s,n)=>e.jsxs("div",{className:N("grid grid-cols-[44px_minmax(0,1fr)] gap-3 px-3 py-0.5",q(s)),children:[e.jsx("span",{className:"select-none text-right text-muted-foreground/55",children:n+1}),e.jsx("span",{className:"whitespace-pre-wrap break-all text-foreground",children:s||" "})]},`${n}-${s}`))})]})}function K({loading:r,error:t,content:s}){if(r)return e.jsx(x,{tone:"muted",children:"Loading file content..."});if(t)return e.jsx(x,{tone:"destructive",children:t});if(!s)return e.jsx(x,{tone:"muted",children:"Select an untracked file to preview its content."});if(s.kind==="image"){const n=s.content?`data:${s.mimeType};base64,${s.content}`:s.downloadUrl;return n?e.jsx("div",{className:"flex min-h-[20rem] items-center justify-center rounded-[28px] border border-border/60 bg-background/55 p-4",children:e.jsx("img",{src:n,alt:s.path,className:"max-h-full max-w-full rounded-[20px] object-contain shadow-[0_24px_90px_-52px_rgba(0,0,0,0.65)]"})}):e.jsx(x,{tone:"muted",children:"Image preview is not available."})}if(s.kind==="pdf"&&s.downloadUrl)return e.jsx("div",{className:"h-full min-h-[24rem] overflow-hidden rounded-[28px] border border-border/60 bg-background/55",children:e.jsx("iframe",{src:s.downloadUrl,title:s.path,className:"h-full w-full border-0"})});if(s.kind==="json"){let n=s.content;try{n=JSON.stringify(JSON.parse(s.content),null,2)}catch{}return e.jsx(W,{content:n,truncated:s.truncated})}return s.kind==="markdown"||s.kind==="text"||s.kind==="html"?e.jsx(W,{content:s.content,truncated:s.truncated}):e.jsx(x,{tone:"muted",children:"This file cannot be previewed inline."})}function W({content:r,truncated:t}){return e.jsxs("div",{className:"rounded-[20px] border border-border/60 bg-background/55",children:[e.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap px-3 py-3 font-mono text-[11px] leading-5 text-foreground",children:r}),t&&e.jsx("div",{className:"border-t border-border/60 px-3 py-2 text-[11px] text-muted-foreground",children:"Content truncated. Open the Files tab to inspect the full artifact."})]})}function x({children:r,tone:t}){return e.jsx("div",{className:N("flex h-full min-h-[12rem] items-center justify-center rounded-[20px] text-[12px]",t==="muted"?"text-muted-foreground":"text-destructive"),children:r})}function q(r){return r.startsWith("@@")?"bg-sky-500/10":r.startsWith("+")&&!r.startsWith("+++")?"bg-emerald-500/10":r.startsWith("-")&&!r.startsWith("---")?"bg-destructive/10":r.startsWith("diff ")||r.startsWith("index ")||r.startsWith("---")||r.startsWith("+++")?"bg-muted/45":""}export{se as DiffTab};
|