meshy-node 0.3.6 → 0.3.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-BGDwH7LG.js +119 -0
- package/dashboard/assets/DashboardShared-C3sx-Aj3.js +54 -0
- package/dashboard/assets/{DiffTab-D32e4GZ0.js → DiffTab-DF380dMh.js} +3 -3
- package/dashboard/assets/{FilesTab-JtS0K69s.js → FilesTab-DZ2CIfBe.js} +1 -1
- package/dashboard/assets/{PreviewTab-DjvNLJqk.js → PreviewTab-DGzp5vs_.js} +2 -2
- package/dashboard/assets/SharedConversationPage-6Y6HiGBv.js +7 -0
- package/dashboard/assets/{file-DEAybfOx.js → file-CkjhxpTi.js} +1 -1
- package/dashboard/assets/{folder-BgNe6kvb.js → folder-DcAuKKJN.js} +1 -1
- package/dashboard/assets/index-DfiptIs_.css +1 -0
- package/dashboard/assets/index-U21aiFFx.js +276 -0
- package/dashboard/assets/input-BA2z1FFh.js +1 -0
- package/dashboard/index.html +2 -2
- package/main.cjs +569 -309
- package/package.json +1 -1
- package/runtime-metadata.json +5 -5
- package/dashboard/assets/DashboardPage-CBz6UrRs.js +0 -119
- package/dashboard/assets/DashboardShared-CsdH5gbQ.js +0 -54
- package/dashboard/assets/SharedConversationPage-DkfDIi1Q.js +0 -12
- package/dashboard/assets/index-BZEpNAD0.css +0 -1
- package/dashboard/assets/index-CTmXIGF9.js +0 -271
- package/dashboard/assets/input-zoVCGkkt.js +0 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import{c as h,r as g,j as n,i as P,C as T,b as E,X as oe,x as ie,H as Q,aZ as ae,y as ce,B as le}from"./index-U21aiFFx.js";/**
|
|
2
|
+
* @license lucide-react v1.7.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const de=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],ue=h("brain",de);/**
|
|
7
|
+
* @license lucide-react v1.7.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const me=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],fe=h("circle-question-mark",me);/**
|
|
12
|
+
* @license lucide-react v1.7.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const pe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],xe=h("circle",pe);/**
|
|
17
|
+
* @license lucide-react v1.7.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const ge=[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}]],he=h("list-checks",ge);/**
|
|
22
|
+
* @license lucide-react v1.7.0 - ISC
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the ISC license.
|
|
25
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/const ye=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],be=h("loader-circle",ye);/**
|
|
27
|
+
* @license lucide-react v1.7.0 - ISC
|
|
28
|
+
*
|
|
29
|
+
* This source code is licensed under the ISC license.
|
|
30
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
+
*/const je=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],Ne=h("shield-alert",je);/**
|
|
32
|
+
* @license lucide-react v1.7.0 - ISC
|
|
33
|
+
*
|
|
34
|
+
* This source code is licensed under the ISC license.
|
|
35
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
+
*/const we=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],ke=h("shield-check",we);/**
|
|
37
|
+
* @license lucide-react v1.7.0 - ISC
|
|
38
|
+
*
|
|
39
|
+
* This source code is licensed under the ISC license.
|
|
40
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
+
*/const _e=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],Se=h("user",_e);/**
|
|
42
|
+
* @license lucide-react v1.7.0 - ISC
|
|
43
|
+
*
|
|
44
|
+
* This source code is licensed under the ISC license.
|
|
45
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
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
|
+
`)}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 Z(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 G(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||G(e.message.content)}return G(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=Z(o.event),c=Z(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,`
|
|
49
|
+
`).split(`
|
|
50
|
+
`);for(;t.length>0&&((r=t[0])==null?void 0:r.trim())==="";)t.shift();return t.join(`
|
|
51
|
+
`)}const Ze=/\b((?:https?:\/\/|www\.)[^\s<>()[\]{}'"`]+[^\s<>()[\]{}'"`.,;:!?])/gi;function te({text:e,className:t=""}){const r=[];let s=0;for(const o of e.matchAll(Ze)){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 Ge(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 Ge(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(`
|
|
52
|
+
|
|
53
|
+
`),x=c.filter(l=>l.type==="tool_use"),j=c.filter(l=>l.type==="tool_result");return d.length>0||m.length>0||x.length>0||j.length>0?n.jsxs(v,{children:[m.length>0&&n.jsx(it,{text:m}),d.map((l,f)=>{if(l.questionPayload){const y=S(l.questionPayload);return u.has(y)?null:(u.add(y),n.jsx(A,{payload:l.questionPayload,bypassEnabled:t,onBypassChange:r,onSubmit:s,disabled:o},f))}return n.jsxs("div",{className:"group relative rounded-[24px] rounded-bl-[9px] border border-border/70 bg-card/86 px-3.5 py-2.5 text-[12px] leading-[18px] text-foreground shadow-[0_20px_70px_-58px_rgba(15,23,42,0.75)] backdrop-blur-sm dark:shadow-[0_20px_70px_-58px_rgba(0,0,0,0.95)]",children:[n.jsx(re,{text:l.text,className:"absolute right-2 top-2"}),n.jsx(te,{text:l.text})]},f)}),x.map((l,f)=>n.jsx(at,{block:l,renderedQuestionSignatures:u,questionBypassEnabled:t,onQuestionBypassChange:r,onSubmitQuestionResponse:s,questionResponseDisabled:o},f)),j.map((l,f)=>n.jsx(ne,{block:l,renderedQuestionSignatures:u,questionBypassEnabled:t,onQuestionBypassChange:r,onSubmitQuestionResponse:s,questionResponseDisabled:o},f))]}):null}function nt(e){return e.replace(/\s+/g," ").trim()}function k(e,t=132){const r=nt(e);return r?r.length>t?`${r.slice(0,t-3)}...`:r:""}function W(e,t=84){if(typeof e=="string")return k(e,t);if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e)){const r=e.slice(0,3).map(s=>W(s,28)).filter(Boolean).join(", ");return k(r||JSON.stringify(e),t)}if(typeof e=="object"&&e!==null){const r=Object.entries(e).slice(0,3).map(([s,o])=>`${s}: ${W(o,32)}`).join(" · ");return k(r||JSON.stringify(e),t)}return""}function st(e){if(!e)return"No input";const t=Object.entries(e).slice(0,4).map(([r,s])=>`${r}: ${W(s,40)}`).filter(r=>r.trim().length>0).join(" · ");return k(t||JSON.stringify(e),156)||"No input"}function ot({expanded:e}){return n.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-[12px] border border-border/60 bg-background/70 px-2 py-1 text-[10px] font-medium uppercase tracking-[0.18em] text-muted-foreground shadow-sm",children:[e?"Less":"More",e?n.jsx(ae,{className:"h-3 w-3"}):n.jsx(ce,{className:"h-3 w-3"})]})}function D({title:e,preview:t,icon:r,children:s,accentClassName:o,previewClassName:i="font-mono text-[11px] text-muted-foreground/90"}){const[a,c]=g.useState(!1);return n.jsxs("div",{className:`overflow-hidden rounded-[20px] border border-border/60 shadow-sm ${o}`,children:[n.jsxs("button",{type:"button",onClick:()=>c(u=>!u),className:"flex w-full items-start gap-3 px-4 py-3 text-left transition-colors hover:bg-background/30",children:[n.jsx("div",{className:"mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-[12px] border border-border/60 bg-background/70 text-muted-foreground",children:r}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"flex flex-wrap items-center gap-2",children:n.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.22em] text-muted-foreground",children:e})}),n.jsx("div",{className:`mt-1 whitespace-pre-wrap break-words text-[12px] leading-5 ${i}`,children:t})]}),n.jsx(ot,{expanded:a})]}),a&&n.jsx("div",{className:"border-t border-border/60 px-4 py-3",children:s})]})}function it({text:e}){const t=k(e,156);return n.jsx(D,{title:"Thinking",preview:t,icon:n.jsx(ue,{className:"h-3.5 w-3.5"}),accentClassName:"bg-muted/35",previewClassName:"text-[12px] leading-5 text-muted-foreground/90",children:n.jsx("div",{className:"whitespace-pre-wrap text-[13px] leading-5 text-muted-foreground/90",children:e})})}function at({block:e,renderedQuestionSignatures:t,questionBypassEnabled:r,onQuestionBypassChange:s,onSubmitQuestionResponse:o,questionResponseDisabled:i}){const a=String(e.name??"tool"),c=e.input,u=O(e);if(u){const m=S(u);return t!=null&&t.has(m)?null:(t==null||t.add(m),n.jsx(A,{payload:u,bypassEnabled:r,onBypassChange:s,onSubmit:o,disabled:i}))}const d=st(c);if(a==="TodoWrite"){const m=ct(c==null?void 0:c.todos);if(m.length>0)return n.jsx(lt,{todos:m})}return n.jsx(D,{title:`Tool: ${a}`,preview:d,icon:n.jsx(ee,{className:"h-3.5 w-3.5"}),accentClassName:"bg-muted/25",children:n.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap text-xs leading-5 text-muted-foreground",children:JSON.stringify(c??{},null,2)})})}function ne({block:e,renderedQuestionSignatures:t,questionBypassEnabled:r,onQuestionBypassChange:s,onSubmitQuestionResponse:o,questionResponseDisabled:i}){const a=e.content,c=typeof a=="string"?a:Array.isArray(a)?a.map(m=>String(m.text??"")).join(`
|
|
54
|
+
`):"";if(!c)return null;const u=B(c);if(u){const m=S(u);return t!=null&&t.has(m)?null:(t==null||t.add(m),n.jsx(A,{payload:u,bypassEnabled:r,onBypassChange:s,onSubmit:o,disabled:i}))}const d=k(c,156);return n.jsx(D,{title:"Result",preview:d,icon:n.jsx(ee,{className:"h-3.5 w-3.5"}),accentClassName:"bg-background/65",children:n.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap text-xs leading-5 text-muted-foreground",children:c})})}function ct(e){return Array.isArray(e)?e.map(t=>{if(typeof t!="object"||t===null)return null;const r=t,s=typeof r.content=="string"?r.content:"";if(!s)return null;const o=typeof r.activeForm=="string"?r.activeForm:s,i=typeof r.status=="string"?r.status:"pending";return{content:s,activeForm:o,status:i==="completed"||i==="in_progress"?i:"pending"}}).filter(t=>t!==null):[]}function lt({todos:e}){const t=e.filter(o=>o.status==="completed").length,r=e.length,s=e.find(o=>o.status==="in_progress");return n.jsxs("div",{className:"overflow-hidden rounded-[20px] border border-border/60 bg-muted/20 shadow-sm",children:[n.jsxs("div",{className:"flex items-center gap-3 border-b border-border/50 px-4 py-3",children:[n.jsx("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-[12px] border border-border/60 bg-background/70 text-muted-foreground",children:n.jsx(he,{className:"h-3.5 w-3.5"})}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.22em] text-muted-foreground",children:"Todos"}),n.jsx("div",{className:"mt-0.5 truncate text-[12px] leading-5 text-muted-foreground/90",children:s?s.activeForm:r===0?"No items":t===r?"All complete":"Up next"})]}),n.jsxs("div",{className:"shrink-0 rounded-[11px] border border-border/60 bg-background/70 px-2 py-0.5 font-mono text-[10px] tracking-wide text-muted-foreground",children:[t,"/",r]})]}),n.jsx("ul",{className:"divide-y divide-border/40",children:e.map((o,i)=>n.jsxs("li",{className:"flex items-start gap-3 px-4 py-2.5",children:[n.jsx(dt,{status:o.status}),n.jsx("span",{className:o.status==="completed"?"text-[13px] leading-5 text-muted-foreground line-through decoration-muted-foreground/60":o.status==="in_progress"?"text-[13px] font-medium leading-5 text-foreground":"text-[13px] leading-5 text-foreground/85",children:o.status==="in_progress"?o.activeForm:o.content})]},`${i}-${o.content}`))})]})}function dt({status:e}){return e==="completed"?n.jsx("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-emerald-500/15 text-emerald-500 dark:text-emerald-400",children:n.jsx(T,{className:"h-3 w-3"})}):e==="in_progress"?n.jsx("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center text-primary",children:n.jsx(be,{className:"h-3.5 w-3.5 animate-spin"})}):n.jsx("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground/60",children:n.jsx(xe,{className:"h-3 w-3"})})}function St({label:e,value:t}){return n.jsxs("div",{className:"min-w-[5.5rem] flex-1 rounded-[16px] border border-border/60 bg-background/52 px-2.5 py-2 shadow-sm",children:[n.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:e}),n.jsx("div",{className:"mt-0.5 text-sm font-semibold tracking-tight text-foreground",children:t})]})}function $t({label:e}){return n.jsx("div",{className:"flex h-64 items-center justify-center text-sm text-muted-foreground",children:e})}function vt({label:e,value:t,mono:r,action:s}){return n.jsxs("div",{className:"grid grid-cols-[4.25rem,minmax(0,1fr)] items-start gap-2",children:[n.jsx("span",{className:"pt-0.5 text-[10px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:e}),n.jsxs("div",{className:"flex min-w-0 items-start gap-1.5",children:[n.jsx("span",{className:E("min-w-0 flex-1 break-all text-[12px] text-foreground",r&&"font-mono text-[11px] leading-5"),children:t}),s]})]})}function Ct({label:e,value:t,mono:r}){return n.jsxs("div",{className:"rounded-[15px] border border-border/60 bg-background/62 px-2.5 py-2 shadow-sm",children:[n.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:e}),n.jsx("div",{className:E("mt-0.5 text-[12px] font-medium text-foreground",r&&"font-mono text-[11px]"),children:t})]})}function At({capabilities:e,action:t}){return n.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between sm:gap-3",children:[n.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[n.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:"Capabilities"}),n.jsx("div",{className:"flex flex-wrap items-center gap-1.5 text-[11px]",children:e.length>0?e.map(r=>n.jsx(le,{variant:"secondary",className:"rounded-[11px]",children:r},r)):n.jsx("span",{className:"text-[12px] text-muted-foreground",children:"None declared"})})]}),t&&n.jsx("div",{className:"shrink-0 self-start",children:t})]})}export{_t as C,St as D,vt as I,be as L,Ct as M,$t as T,ht as a,mt as b,At as c,jt as d,xt as e,bt as f,_ as g,Nt as h,kt as i,ft as j,pt as k,wt as l,yt as m,U as n,gt as r,Me as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as l,
|
|
1
|
+
import{r as l,b4 as P,a$ as O,j as e,B as g,b as N,y as W}from"./index-U21aiFFx.js";import{G as R}from"./DashboardPage-BGDwH7LG.js";import{C as T,F as _}from"./folder-DcAuKKJN.js";import{F as B}from"./file-CkjhxpTi.js";import"./DashboardShared-C3sx-Aj3.js";import"./input-BA2z1FFh.js";function $(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=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(()
|
|
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(()=>$(t==null?void 0:t.staged,"staged"),[t==null?void 0:t.staged]),E=l.useMemo(()=>$(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(q,{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(W,{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(B,{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(W,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(T,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx(_,{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",K(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 q({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(D,{content:n,truncated:s.truncated})}return s.kind==="markdown"||s.kind==="text"||s.kind==="html"?e.jsx(D,{content:s.content,truncated:s.truncated}):e.jsx(x,{tone:"muted",children:"This file cannot be previewed inline."})}function D({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 K(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};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as Ze,
|
|
1
|
+
import{c as Ze,a_ as Dt,j as y,r as re,a$ as Ar,b0 as Pr,b1 as zr,B as rn,i as Me,b as Te}from"./index-U21aiFFx.js";import{F as jr,C as Lr}from"./folder-DcAuKKJN.js";import{F as Fr}from"./file-CkjhxpTi.js";/**
|
|
2
2
|
* @license lucide-react v1.7.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as k,j as e,i as u,
|
|
1
|
+
import{c as k,j as e,i as u,a9 as B,r as a,b2 as W,b1 as X,G as Y,D as Z,g as ee,b3 as se,B as D}from"./index-U21aiFFx.js";import{I as re}from"./input-BA2z1FFh.js";/**
|
|
2
2
|
* @license lucide-react v1.7.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -23,4 +23,4 @@ import{c as k,j as e,i as u,a5 as B,r as a,a_ as Q,aZ as W,G as X,D as Y,g as ee
|
|
|
23
23
|
*
|
|
24
24
|
* This source code is licensed under the ISC license.
|
|
25
25
|
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const de=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],ue=k("settings-2",de),xe={getOutput:
|
|
26
|
+
*/const de=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],ue=k("settings-2",de),xe={getOutput:X,createPreviewSession:W};function ve({taskId:s,api:n=xe,allowPortPreview:l=!0}){const[i,c]=a.useState(null),[r,v]=a.useState(null),[d,p]=a.useState(null),[b,h]=a.useState(""),[P,y]=a.useState(!1),[K,C]=a.useState(!0),[j,m]=a.useState(null),[V,E]=a.useState(!1),_=a.useCallback(async()=>{C(!0),m(null),c(null),v(null),p(null);try{const t=await n.getOutput(s);c(t),C(!1)}catch(t){m(t instanceof Error?t.message:"Failed to load output"),C(!1)}},[n,s]);a.useEffect(()=>{_()},[_]);const w=a.useCallback(async t=>{m(null);try{const o=await n.createPreviewSession(s,t!=null&&t.path?{path:t.path}:void 0);v(o),y(!1),t&&p(t)}catch(o){m(o instanceof Error?o.message:"Failed to create preview session")}},[n,s]),S=a.useCallback(async t=>{const o=t??Number.parseInt(b,10);if(!Number.isInteger(o)||o<1||o>65535){m("Enter a port between 1 and 65535");return}m(null);try{const M=await n.createPreviewSession(s,{port:o});v(M),p(null),h(String(o)),y(!0)}catch(M){m(M instanceof Error?M.message:"Failed to create preview session")}},[n,b,s]),g=a.useMemo(()=>R(i),[i]);a.useEffect(()=>{if(P||!(i!=null&&i.available)||g.length===0||r&&r.kind!=="service")return;const t=d??g[0];t&&w(t)},[d,i,g,P,r,w]);const f=a.useCallback(()=>{if((r==null?void 0:r.kind)==="service"&&typeof r.port=="number"){S(r.port);return}v(null);const t=d??R(i)[0];t&&w(t)},[d,i,r,S,w]);if(a.useEffect(()=>{if(!r)return;const t=r.expiresAt-Date.now()-5e3;if(t<=0){f();return}const o=window.setTimeout(f,t);return()=>window.clearTimeout(o)},[f,r]),K)return e.jsx(N,{children:"Loading preview..."});const x=l&&P;if(j&&r&&!x)return e.jsx(N,{children:e.jsxs("div",{className:"space-y-4 text-center",children:[e.jsx("div",{className:"text-sm text-destructive",children:j}),e.jsx("div",{className:"flex justify-center",children:e.jsxs(u,{variant:"outline",size:"sm",onClick:f,className:"rounded-full",children:[e.jsx(z,{className:"h-3.5 w-3.5"}),"Retry"]})})]})});const $=!!(i!=null&&i.available);if(!$&&!l)return e.jsx(N,{children:"Task output is not available yet."});if(!r)return e.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[e.jsxs("div",{className:"shrink-0 border-b border-border/60 px-4 py-2.5",children:[e.jsx(H,{session:null,serviceModeOpen:x,allowPortPreview:l,servicePort:b,onRefresh:f,onFullscreen:()=>E(!0),onServiceModeToggle:()=>y(t=>!t),onServicePortChange:h,onServiceStart:()=>void S()}),!x&&e.jsx(U,{entries:g,activeEntry:d,onEntrySelect:t=>void w(t)})]}),x?e.jsx(I,{serviceSession:null,error:j}):e.jsx(N,{children:j?e.jsx("span",{className:"text-sm text-destructive",children:j}):$?g.length>0?"Starting preview session...":"No HTML or Markdown files were found in this task output.":"Task output is not available yet."})]});const F=G(r),J=q(r),A=he(r),T=r.kind==="service"?r:null,Q=x?T:r,L=e.jsx("iframe",{src:r.previewUrl,className:"h-full w-full border-0",sandbox:A,title:"Task Preview"});return e.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[e.jsxs("div",{className:"shrink-0 border-b border-border/60 px-4 py-2.5",children:[e.jsx(H,{session:Q,serviceModeOpen:x,allowPortPreview:l,servicePort:b,onRefresh:f,onFullscreen:()=>E(!0),onServiceModeToggle:()=>y(t=>!t),onServicePortChange:h,onServiceStart:()=>void S()}),!x&&e.jsx(U,{entries:g,activeEntry:d,previewKind:r.kind,onEntrySelect:t=>void w(t)})]}),x?e.jsx(I,{serviceSession:T,error:j,children:T?L:null}):e.jsx("div",{className:"min-h-0 flex-1 p-2",children:e.jsx("div",{className:"h-full overflow-hidden rounded-2xl border border-border/60 bg-white shadow-sm",children:L})}),e.jsx(Y,{open:V,onOpenChange:E,children:e.jsxs(Z,{className:"flex h-[95vh] max-w-[95vw] flex-col gap-0 overflow-hidden p-0",children:[e.jsxs(ee,{className:"sr-only",children:["Preview: ",F]}),e.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-border/60 px-4 py-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm font-semibold text-foreground",children:F}),e.jsx("span",{className:"text-xs text-muted-foreground",children:O(r.expiresAt)})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(u,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded-full",onClick:f,title:"Refresh",children:e.jsx(z,{className:"h-3.5 w-3.5"})}),e.jsx(u,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded-full",asChild:!0,title:"Open in new tab",children:e.jsx("a",{href:J,target:"_blank",rel:"noopener noreferrer",children:e.jsx(B,{className:"h-3.5 w-3.5"})})}),e.jsx(se,{asChild:!0,children:e.jsxs(u,{variant:"outline",size:"sm",className:"rounded-full",title:"Exit fullscreen",children:[e.jsx(ae,{className:"h-3.5 w-3.5"}),"Exit fullscreen"]})})]})]}),e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx("iframe",{src:r.previewUrl,className:"h-full w-full border-0",sandbox:A,title:"Task Preview Fullscreen"})})]})})]})}function R(s){var i,c;const n=((i=s==null?void 0:s.summary)==null?void 0:i.htmlEntries)??[],l=((c=s==null?void 0:s.summary)==null?void 0:c.markdownEntries)??[];return[...n.map(r=>({...r,kind:"html"})),...l.map(r=>({...r,kind:"markdown"}))]}function U({entries:s,activeEntry:n,previewKind:l,onEntrySelect:i}){return e.jsx("div",{className:"mt-2 flex flex-wrap items-center justify-between gap-2",children:e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[s.map(c=>{const r=(n==null?void 0:n.path)===c.path;return e.jsx("button",{type:"button",onClick:()=>i(c),className:r?"rounded-full border border-primary/40 bg-primary/10 px-3 py-1 text-xs font-medium text-primary":"rounded-full border border-border/70 bg-background/55 px-3 py-1 text-xs text-muted-foreground transition-colors hover:text-foreground",children:c.label},`${c.kind}:${c.path}`)}),e.jsxs(D,{variant:"outline",className:"rounded-full border-border/70 bg-background/60",children:[s.length," ",s.length===1?"file":"files"]}),e.jsx(D,{variant:"outline",className:"rounded-full border-border/70 bg-background/60",children:l==="service"?"Service proxy":"Sandboxed iframe"})]})})}function H({session:s,serviceModeOpen:n,allowPortPreview:l,servicePort:i,onRefresh:c,onFullscreen:r,onServiceModeToggle:v,onServicePortChange:d,onServiceStart:p}){const b=s?q(s):null;return e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"flex min-w-0 items-center gap-3",children:n&&d&&p?e.jsxs("form",{className:"flex min-w-0 items-center gap-2",onSubmit:h=>{h.preventDefault(),p()},children:[e.jsx("span",{className:"shrink-0 text-sm font-semibold text-foreground",children:"Preview service"}),e.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:["Port",e.jsx(re,{type:"number",min:1,max:65535,inputMode:"numeric",value:i??"",onChange:h=>d(h.target.value),placeholder:"12345","aria-label":"Service preview port",className:"h-7 w-24 rounded-full px-3 text-xs"})]}),e.jsxs(u,{type:"submit",variant:"outline",size:"sm",className:"h-7 rounded-full px-2.5 text-xs",children:[e.jsx(ce,{className:"h-3.5 w-3.5"}),"Run"]}),s&&e.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:O(s.expiresAt)})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"truncate text-sm font-semibold text-foreground",children:s?G(s):"Preview"}),s&&e.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:O(s.expiresAt)})]})}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[s&&e.jsxs(e.Fragment,{children:[e.jsx(u,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded-full",onClick:c,title:"Refresh",children:e.jsx(z,{className:"h-3.5 w-3.5"})}),e.jsx(u,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded-full",asChild:!0,title:"Open in new tab",children:e.jsx("a",{href:b??s.previewUrl,target:"_blank",rel:"noopener noreferrer",children:e.jsx(B,{className:"h-3.5 w-3.5"})})}),e.jsx(u,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded-full",onClick:r,title:"Fullscreen",children:e.jsx(ne,{className:"h-3.5 w-3.5"})})]}),l&&e.jsxs(u,{type:"button",variant:n?"secondary":"ghost",size:"sm","aria-pressed":n,onClick:v,className:"h-7 shrink-0 rounded-full px-2.5 text-xs",children:[e.jsx(ue,{className:"h-3.5 w-3.5"}),"Advanced"]})]})]})}function I({serviceSession:s,error:n,children:l}){return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[n&&e.jsx("div",{className:"shrink-0 border-b border-destructive/20 bg-destructive/5 px-4 py-2 text-xs text-destructive",children:n}),e.jsx("div",{className:"min-h-0 flex-1 p-2",children:s&&l?e.jsx("div",{className:"h-full overflow-hidden rounded-2xl border border-border/60 bg-white shadow-sm",children:l}):e.jsx(N,{children:"No service preview running."})})]})}function q(s){return s.openUrl??s.previewUrl}function he(s){return s.kind==="service"?void 0:"allow-scripts allow-same-origin"}function G(s){if(s.kind==="service"&&typeof s.port=="number"){const n=s.entryPath?`/${s.entryPath.replace(/^\/+/,"")}`:"";return`127.0.0.1:${s.port}${n}`}return s.entryPath}function N({children:s}){return e.jsx("div",{className:"flex h-64 items-center justify-center text-muted-foreground",children:s})}function O(s){const n=Math.max(0,Math.round((s-Date.now())/1e3));if(n<60)return`${n}s`;const l=Math.floor(n/60),i=n%60;return`${l}m ${i}s`}export{H as PreviewHeader,I as PreviewServicePanel,ve as PreviewTab,U as PreviewToolbar,he as getPreviewIframeSandbox,q as getPreviewOpenUrl};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesTab-DZ2CIfBe.js","assets/index-U21aiFFx.js","assets/index-DfiptIs_.css","assets/folder-DcAuKKJN.js","assets/file-CkjhxpTi.js","assets/PreviewTab-DGzp5vs_.js","assets/input-BA2z1FFh.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as N,ax as k,r as s,j as e,L as S,P as T,O as C,a1 as P,aT as M,aU as _,aV as j,aW as L,aX as E,a0 as w,aY as O}from"./index-U21aiFFx.js";import{n as A,j as I,i as F,L as R,C as z,T as v,m as V}from"./DashboardShared-C3sx-Aj3.js";/**
|
|
3
|
+
* @license lucide-react v1.7.0 - ISC
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the ISC license.
|
|
6
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/const D=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]],q=N("message-square-text",D),B=s.lazy(async()=>({default:(await w(()=>import("./FilesTab-DZ2CIfBe.js"),__vite__mapDeps([0,1,2,3,4]))).FilesTab})),U=s.lazy(async()=>({default:(await w(()=>import("./PreviewTab-DGzp5vs_.js"),__vite__mapDeps([5,1,2,6]))).PreviewTab})),W={getOutput:j,getOutputTree:_,getOutputContent:M},G={getOutput:j,createPreviewSession:(t,r)=>O(t,typeof r=="string"?r:r==null?void 0:r.path)};function $(){const{shareId:t}=k(),[r,n]=s.useState(null),[c,a]=s.useState([]),[x,u]=s.useState(!0),[p,d]=s.useState(null),l=s.useRef(null);return s.useEffect(()=>{if(!t){n(null),a([]),d("Shared conversation not found"),u(!1);return}let o=!1;l.current=t,u(!0),d(null);const m=async h=>{try{const[f,b]=await Promise.all([L(t),E(t)]);if(o||l.current!==t)return;n(f),a(y=>h?b.logs:V(y,b.logs)),d(null)}catch(f){if(o||l.current!==t)return;h&&(n(null),a([]),d(f instanceof Error?f.message:"Failed to load shared conversation"))}finally{!o&&l.current===t&&h&&u(!1)}};m(!0);const i=window.setInterval(()=>{m(!1)},2500);return()=>{o=!0,window.clearInterval(i)}},[t]),e.jsx(H,{conversation:r,logs:c,loading:x,error:p})}function H({conversation:t,logs:r,loading:n,error:c}){const[a,x]=s.useState("transcript"),[u,p]=s.useState(!1),d=s.useMemo(()=>{if(!t)return null;const i=A(t.payload.initialMessage);return i.length>0?I(i,new Date(t.createdAt).toISOString()):null},[t]),l=s.useMemo(()=>F([...d?[d]:[],...r]),[d,r]),o=(t==null?void 0:t.scope)==="filesPreview",m=e.jsx("section",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain scroll-pb-16 px-4 py-5 sm:px-6",children:e.jsxs("div",{className:"mx-auto flex max-w-[72rem] flex-col gap-5 pb-16",children:[n&&e.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border/60 bg-background/60 px-4 py-3 text-sm text-muted-foreground",children:[e.jsx(R,{className:"h-4 w-4 animate-spin"}),"Loading shared conversation..."]}),!n&&c&&e.jsxs("div",{className:"rounded-lg border border-destructive/20 bg-destructive/10 px-5 py-8 text-center text-destructive",children:[e.jsx("div",{className:"text-base font-semibold",children:"Shared conversation unavailable"}),e.jsx("div",{className:"mt-2 text-sm",children:c})]}),!n&&!c&&l.length===0&&e.jsxs("div",{className:"rounded-lg border border-dashed border-border/70 bg-background/35 px-5 py-8 text-center",children:[e.jsx(q,{className:"mx-auto h-6 w-6 text-muted-foreground"}),e.jsx("div",{className:"mt-3 text-sm font-medium text-foreground",children:"No transcript output yet"})]}),!n&&!c&&l.map((i,h)=>e.jsx(z,{event:i,questionResponseDisabled:!0},`shared-${h}`))]})});return e.jsxs("div",{className:"relative flex h-full min-h-0 overflow-hidden bg-background text-foreground",children:[e.jsxs("aside",{className:"hidden w-64 shrink-0 flex-col border-r border-border/60 bg-muted/20 px-4 py-5 lg:flex xl:w-72",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl border border-border/70 bg-foreground text-xs font-semibold tracking-[0.24em] text-background shadow-sm",children:"M"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:"Meshy Workspace"}),e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.24em] text-muted-foreground",children:"Shared view"})]})]}),e.jsx("div",{className:"mt-7 text-[11px] font-medium uppercase tracking-[0.28em] text-muted-foreground",children:"Shared conversation"}),t&&e.jsxs("div",{className:"mt-3 space-y-3",children:[e.jsx("h1",{className:"max-h-28 overflow-hidden break-words text-base font-semibold leading-5 text-foreground [overflow-wrap:anywhere]",title:t.title,children:t.title}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(S,{status:t.status}),e.jsx(T,{priority:t.priority})]}),e.jsxs("div",{className:"space-y-1 text-xs text-muted-foreground",children:[e.jsxs("div",{children:["updated ",C(t.updatedAt)]}),e.jsx("div",{className:"font-mono",children:t.id.slice(0,8)})]})]}),e.jsxs("div",{className:"mt-auto space-y-2 pt-6",children:[u&&e.jsx("div",{className:"rounded-xl border border-border/70 bg-background/80 p-3 font-mono text-[11px] text-foreground shadow-sm",children:"npx -y meshy-node@latest start"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("a",{href:"https://github.com/ai-microsoft/meshy",target:"_blank",rel:"noreferrer","aria-label":"Open Meshy on GitHub",className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-border/70 bg-background/70 text-muted-foreground transition-colors hover:text-foreground",children:e.jsx(X,{className:"h-4 w-4"})}),e.jsxs("button",{type:"button",onClick:()=>p(i=>!i),"aria-expanded":u,className:"inline-flex h-9 items-center gap-2 rounded-full border border-border/70 bg-background/70 px-3 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground",children:[e.jsx(P,{className:"h-4 w-4"}),"Try it"]})]})]})]}),e.jsxs("main",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[e.jsxs("header",{className:"shrink-0 border-b border-border/60 bg-background/85 px-4 py-3 sm:px-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-xl border border-border/70 bg-foreground text-xs font-semibold tracking-[0.24em] text-background lg:hidden",children:"M"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.28em] text-muted-foreground",children:"Meshy Workspace"}),e.jsx("div",{className:"truncate text-base font-semibold text-foreground",children:(t==null?void 0:t.title)??"Shared conversation"})]})]}),o&&e.jsxs("div",{className:"mt-3 inline-flex h-auto rounded-full bg-muted/70 p-1 text-muted-foreground",children:[e.jsx("button",{type:"button",onClick:()=>x("transcript"),className:g(a==="transcript"),children:"Transcript"}),e.jsx("button",{type:"button",onClick:()=>x("files"),className:g(a==="files"),children:"Files"}),e.jsx("button",{type:"button",onClick:()=>x("preview"),className:g(a==="preview"),children:"Preview"})]})]}),o&&t?e.jsxs(e.Fragment,{children:[a==="transcript"&&m,a==="files"&&e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(s.Suspense,{fallback:e.jsx(v,{label:"Loading files..."}),children:e.jsx(B,{taskId:t.shareId,api:W})})}),a==="preview"&&e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(s.Suspense,{fallback:e.jsx(v,{label:"Loading preview..."}),children:e.jsx(U,{taskId:t.shareId,api:G,allowPortPreview:!1})})})]}):m]})]})}function g(t){return t?"inline-flex items-center justify-center whitespace-nowrap rounded-full bg-background px-3 py-1.5 text-sm font-medium text-foreground shadow-sm":"inline-flex items-center justify-center whitespace-nowrap rounded-full px-3 py-1.5 text-sm font-medium transition-colors hover:text-foreground"}function X({className:t}){return e.jsx("svg",{className:t,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{d:"M12 2C6.48 2 2 6.58 2 12.23c0 4.51 2.87 8.34 6.84 9.7.5.1.68-.22.68-.49 0-.24-.01-.88-.01-1.73-2.78.62-3.37-1.37-3.37-1.37-.45-1.18-1.11-1.49-1.11-1.49-.91-.64.07-.63.07-.63 1 .07 1.53 1.06 1.53 1.06.89 1.56 2.34 1.11 2.91.85.09-.66.35-1.11.63-1.37-2.22-.26-4.55-1.14-4.55-5.05 0-1.12.39-2.03 1.03-2.75-.1-.26-.45-1.31.1-2.71 0 0 .84-.27 2.75 1.05A9.3 9.3 0 0 1 12 6.96c.85 0 1.71.12 2.51.34 1.91-1.32 2.75-1.05 2.75-1.05.55 1.4.2 2.45.1 2.71.64.72 1.03 1.63 1.03 2.75 0 3.92-2.34 4.79-4.57 5.05.36.32.68.94.68 1.9 0 1.37-.01 2.47-.01 2.81 0 .27.18.59.69.49A10.05 10.05 0 0 0 22 12.23C22 6.58 17.52 2 12 2Z"})})}export{$ as SharedConversationPage,H as SharedConversationView};
|