crewx 0.8.6-rc.7 → 0.8.6-rc.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/dist/assets/{MarketPage-B9p1jCZM.js → MarketPage-BmG_PcyX.js} +1 -1
- package/dist/assets/PromptTab-CNPxh5XQ.js +37 -0
- package/dist/assets/{arc-BnOowx7b.js → arc-DYQ67OQ6.js} +1 -1
- package/dist/assets/{architectureDiagram-UYN6MBPD-DpWepWlq.js → architectureDiagram-UYN6MBPD-D9PrySsE.js} +1 -1
- package/dist/assets/{blockDiagram-ZHA2E4KO-D4dQzhTw.js → blockDiagram-ZHA2E4KO-DXHX-VC-.js} +1 -1
- package/dist/assets/{c4Diagram-6F5ED5ID-BOFHPGH4.js → c4Diagram-6F5ED5ID-JpKBEbr9.js} +1 -1
- package/dist/assets/channel-B9lRVjUy.js +1 -0
- package/dist/assets/{chunk-5HRBRIJM-Izr_7J6b.js → chunk-5HRBRIJM-CV3mFPzX.js} +1 -1
- package/dist/assets/{chunk-7U56Z5CX-4pCO3vUT.js → chunk-7U56Z5CX-pap97-3I.js} +1 -1
- package/dist/assets/{chunk-ASOPGD6M-341SL8LK.js → chunk-ASOPGD6M-CpKjHGpQ.js} +1 -1
- package/dist/assets/{chunk-KFBOBJHC-DA3_U6Ss.js → chunk-KFBOBJHC-mE7-_5nD.js} +1 -1
- package/dist/assets/{chunk-T2TOU4HS-C3Eves8b.js → chunk-T2TOU4HS-EOfXOjK8.js} +1 -1
- package/dist/assets/{chunk-TMUBEWPD-De4j_N23.js → chunk-TMUBEWPD-Cu1KWeZI.js} +1 -1
- package/dist/assets/classDiagram-LNE6IOMH-xn1nGSR7.js +1 -0
- package/dist/assets/classDiagram-v2-MQ7JQ4JX-xn1nGSR7.js +1 -0
- package/dist/assets/{dagre-4EVJKHTY-4pLPU8fC.js → dagre-4EVJKHTY-DbjnHZ6Y.js} +1 -1
- package/dist/assets/{diagram-QW4FP2JN-C2G2AfKZ.js → diagram-QW4FP2JN-CHq7cL1V.js} +1 -1
- package/dist/assets/{erDiagram-6RL3IURR-O6W9AKEL.js → erDiagram-6RL3IURR-CGSZ93zS.js} +1 -1
- package/dist/assets/{flowDiagram-7ASYPVHJ-CU2ThLkX.js → flowDiagram-7ASYPVHJ-BYFBCuaf.js} +1 -1
- package/dist/assets/{ganttDiagram-NTVNEXSI-Cygfk2I9.js → ganttDiagram-NTVNEXSI-B9qhrlsc.js} +1 -1
- package/dist/assets/{gitGraph-YCYPL57B-GW6UyAl1.js → gitGraph-YCYPL57B-BK1Amlpn.js} +1 -1
- package/dist/assets/{gitGraphDiagram-NRZ2UAAF-CYiwmB3t.js → gitGraphDiagram-NRZ2UAAF-BcU2fB4j.js} +1 -1
- package/dist/assets/{infoDiagram-A4XQUW5V-CgybL7D6.js → infoDiagram-A4XQUW5V-DWiUGll7.js} +1 -1
- package/dist/assets/{journeyDiagram-G5WM74LC-BGtGSh98.js → journeyDiagram-G5WM74LC-24_Oq-iI.js} +1 -1
- package/dist/assets/{kanban-definition-QRCXZQQD-DWHExtnz.js → kanban-definition-QRCXZQQD-CDjAI_dw.js} +1 -1
- package/dist/assets/{linear-CMGNzu-C.js → linear-Dlfsn8XR.js} +1 -1
- package/dist/assets/{main-DgXktCKZ.js → main-BMCdGsOk.js} +159 -159
- package/dist/assets/main-BT5_pdVW.css +10 -0
- package/dist/assets/{mindmap-definition-GWI6TPTV-BY1fpgzu.js → mindmap-definition-GWI6TPTV-BDCjSh-Y.js} +1 -1
- package/dist/assets/{pieDiagram-YF2LJOPJ-DO04PFao.js → pieDiagram-YF2LJOPJ-DiC4tihf.js} +1 -1
- package/dist/assets/{quadrantDiagram-OS5C2QUG-CaEXe7D8.js → quadrantDiagram-OS5C2QUG-Brr_yKw8.js} +1 -1
- package/dist/assets/{requirementDiagram-MIRIMTAZ-CcYJEXCA.js → requirementDiagram-MIRIMTAZ-D7Pt7__P.js} +1 -1
- package/dist/assets/{sankeyDiagram-Y46BX6SQ-BLjO2tfL.js → sankeyDiagram-Y46BX6SQ-D9vvcbhq.js} +1 -1
- package/dist/assets/{sequenceDiagram-G6AWOVSC-DakpjQoP.js → sequenceDiagram-G6AWOVSC-CTN50svo.js} +1 -1
- package/dist/assets/{stateDiagram-MAYHULR4-DTYPjV3D.js → stateDiagram-MAYHULR4-DqA89evf.js} +1 -1
- package/dist/assets/stateDiagram-v2-4JROLMXI-9_rwPhWc.js +1 -0
- package/dist/assets/{timeline-definition-U7ZMHBDA-CfD6vbfv.js → timeline-definition-U7ZMHBDA-C4iZhjLH.js} +1 -1
- package/dist/assets/{xychartDiagram-6QU3TZC5-Bq7bgIBm.js → xychartDiagram-6QU3TZC5-ms-19mgI.js} +1 -1
- package/dist/index.html +2 -2
- package/dist-server/domain/task/task.service.js +31 -4
- package/dist-server/domain/usage/usage.service.js +18 -3
- package/dist-server/modules/crewx-pool.service.js +1 -1
- package/dist-server/repository/task.repository.js +0 -1
- package/package.json +6 -6
- package/packages/cli/package.json +1 -1
- package/dist/assets/PromptTab-B6alya5Y.js +0 -37
- package/dist/assets/channel-B5-t1F_R.js +0 -1
- package/dist/assets/classDiagram-LNE6IOMH-BP2EiNBf.js +0 -1
- package/dist/assets/classDiagram-v2-MQ7JQ4JX-BP2EiNBf.js +0 -1
- package/dist/assets/main-q38TAmrV.css +0 -10
- package/dist/assets/stateDiagram-v2-4JROLMXI-DvqQAajG.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{aB as v,aC as we,aD as b,aE as k,aF as Se,aG as u,aH as e,aI as ae,aJ as se,aK as Y,aL as N,aM as re,aN as Ie,aO as le,aP as O,aQ as ze,aR as Ce,aS as ie,aT as Re,aU as Me}from"./main-
|
|
1
|
+
import{aB as v,aC as we,aD as b,aE as k,aF as Se,aG as u,aH as e,aI as ae,aJ as se,aK as Y,aL as N,aM as re,aN as Ie,aO as le,aP as O,aQ as ze,aR as Ce,aS as ie,aT as Re,aU as Me}from"./main-BMCdGsOk.js";/**
|
|
2
2
|
* @license lucide-react v0.563.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import{aB as F,aE as B,aG as u,aH as r,aV as ke,aL as X,aQ as we,aW as je,aD as V,aX as de,aK as ue,aY as K,aS as Ne,aZ as Ce,a_ as Le,a$ as _e,aO as Ee,b0 as pe,b1 as Se,b2 as De,b3 as Me,b4 as Ae,b5 as $e,b6 as Te,b7 as Ie,b8 as Pe,b9 as Re,ba as Be,bb as ze,bc as Oe,bd as qe,be as Ve,bf as Fe,bg as He,bh as Ke,bi as Qe,bj as We,bk as Ue,bl as Xe,bm as Je,bn as Ge,bo as Y}from"./main-BMCdGsOk.js";/**
|
|
2
|
+
* @license lucide-react v0.563.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 Ze=[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]],Ye=F("braces",Ze);/**
|
|
7
|
+
* @license lucide-react v0.563.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 et=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],tt=F("eye",et);/**
|
|
12
|
+
* @license lucide-react v0.563.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 nt=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],rt=F("link-2",nt);/**
|
|
17
|
+
* @license lucide-react v0.563.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 st=[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]],at=F("refresh-ccw",st);function ee(e,s){return(e??"").toLowerCase().includes(s)}function me(e,s){const n=s.trim().toLowerCase();if(!n)return{nodes:e,autoExpanded:new Set};const t=new Set;return{nodes:e.flatMap(l=>{const c=ee(l.name,n)||ee(l.path,n);if(l.type==="file")return c?[l]:[];if(c)return t.add(l.path),[{...l,children:l.children}];const p=me(l.children??[],n);return p.nodes.length>0?(t.add(l.path),p.autoExpanded.forEach(m=>t.add(m)),[{...l,children:p.nodes}]):[]}),autoExpanded:t}}function fe(e){return e instanceof Error?/HTTP (404|405|501|503)\b|Failed to fetch|NetworkError/i.test(e.message):!1}const R={id:"agent_id",name:"에이전트 이름",role:"에이전트 역할",team:"팀",description:"에이전트 설명"};function ot(e){return{id:e.id.trim()||R.id,name:e.name.trim()||R.name,role:e.role.trim()||R.role,team:e.team.trim()||R.team,description:e.description.trim()||R.description}}function it(e,s,n){let t=!1;return e.state.doc.descendants(i=>i.type.name==="documentBlock"&&i.attrs.key===s&&i.attrs.variant===n?(t=!0,!1):!t),t}const he=["[&_h1]:mt-0","[&_h1]:mb-3","[&_h1]:text-2xl","[&_h1]:font-bold","[&_h2]:mt-0","[&_h2]:mb-2","[&_h2]:text-xl","[&_h2]:font-semibold","[&_h3]:mt-0","[&_h3]:mb-2","[&_h3]:text-lg","[&_h3]:font-semibold","[&_p]:my-2","[&_p]:leading-7","[&_ul]:my-2","[&_ol]:my-2","[&_ul]:list-disc","[&_ol]:list-decimal","[&_ul]:pl-6","[&_ol]:pl-6","[&_li]:my-1","[&_blockquote]:my-3","[&_blockquote]:border-l-4","[&_blockquote]:border-gray-300","[&_blockquote]:pl-4","[&_blockquote]:text-gray-600","[&_blockquote]:italic","[&_blockquote_p]:my-0","[&_a]:text-blue-600","[&_a]:underline","[&_hr]:my-4","[&_hr]:border-gray-300","[&_code]:rounded","[&_code]:bg-gray-100","[&_code]:px-1.5","[&_code]:py-0.5","[&_code]:font-mono","[&_code]:text-[13px]","[&_pre]:my-3","[&_pre]:overflow-x-auto","[&_pre]:rounded-lg","[&_pre]:bg-gray-900","[&_pre]:p-4","[&_pre]:text-sm","[&_pre]:text-gray-100","[&_pre_code]:bg-transparent","[&_pre_code]:p-0","[&_pre_code]:text-inherit"].join(" "),lt=["min-h-[420px]","rounded-xl","border","border-gray-200","bg-white","px-4","py-3","text-sm","text-gray-900","shadow-sm","focus:outline-none","prose","prose-sm","max-w-none",he,"[&_.is-editor-empty:first-child::before]:pointer-events-none","[&_.is-editor-empty:first-child::before]:float-left","[&_.is-editor-empty:first-child::before]:h-0","[&_.is-editor-empty:first-child::before]:text-gray-400","[&_.is-editor-empty:first-child::before]:content-[attr(data-placeholder)]"].join(" ");function ct({open:e,request:s,onClose:n}){const{t}=B(),i=u.useRef(null),l=u.useRef(s),[c,p]=u.useState(""),[m,x]=u.useState(!1),[o,y]=u.useState(null),[b,k]=u.useState(!1),w=t("agent.prompt.preview.error");l.current=s;const h=async()=>{var g;if((g=i.current)==null||g.abort(),!l.current.template.trim()){p(""),y(null),k(!1),x(!1);return}const d=new AbortController;i.current=d,x(!0),y(null),k(!1);try{const v=await V.previewPrompt(l.current,{signal:d.signal});if(d.signal.aborted)return;p(v.rendered),y(null),k(!1)}catch(v){if(d.signal.aborted)return;if(fe(v)){p(""),y(null),k(!0);return}p(""),k(!1),y(v instanceof Error?v.message:w)}finally{i.current===d&&(i.current=null),x(!1)}};return u.useEffect(()=>{var d;if(!e){(d=i.current)==null||d.abort();return}h()},[e]),u.useEffect(()=>{if(!e)return;const d=g=>{g.key==="Escape"&&(g.preventDefault(),n())};return window.addEventListener("keydown",d),()=>{window.removeEventListener("keydown",d)}},[n,e]),u.useEffect(()=>()=>{var d;(d=i.current)==null||d.abort()},[]),e?r.jsx("div",{"data-testid":"preview-modal-backdrop",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",onClick:n,children:r.jsxs("div",{role:"dialog","aria-modal":"true","data-testid":"preview-modal",onClick:d=>d.stopPropagation(),className:"flex max-h-[85vh] w-full max-w-4xl flex-col overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-xl",children:[r.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-gray-200 px-6 py-5",children:[r.jsx("div",{children:r.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:t("agent.prompt.preview.title")})}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("button",{type:"button",onClick:()=>{h()},disabled:m,className:"inline-flex items-center gap-2 rounded-lg bg-gray-100 px-4 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-200 disabled:cursor-not-allowed disabled:opacity-50",children:[r.jsx(at,{size:14,className:m?"animate-spin":""}),t("agent.prompt.preview.refresh")]}),r.jsxs("button",{type:"button",onClick:n,className:"inline-flex items-center gap-2 rounded-lg bg-gray-100 px-4 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-200",children:[r.jsx(ke,{size:14}),t("common.close")]})]})]}),r.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 py-5",children:s.template.trim()?m?r.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[r.jsx(X,{size:16,className:"animate-spin"}),r.jsx("span",{children:t("agent.prompt.preview.loading")})]}):b?r.jsx("div",{className:"text-sm text-gray-500",children:t("agent.prompt.preview.unavailable")}):o?r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"text-sm font-medium text-red-600",children:t("agent.prompt.preview.error")}),r.jsx("div",{className:"text-sm text-red-500",children:o})]}):r.jsx(we,{content:c,className:he}):r.jsx("div",{className:"text-sm text-gray-500",children:t("agent.prompt.preview.empty")})}),r.jsxs("div",{className:"flex justify-end gap-2 border-t border-gray-200 px-6 py-4",children:[r.jsxs("button",{type:"button",onClick:()=>{var d;return void((d=navigator.clipboard)==null?void 0:d.writeText(c))},disabled:!c,className:"inline-flex items-center gap-2 rounded-lg bg-gray-100 px-4 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-200 disabled:cursor-not-allowed disabled:opacity-50",children:[r.jsx(je,{size:14}),t("agent.prompt.preview.copy")]}),r.jsx("button",{type:"button",onClick:n,className:"rounded-lg bg-blue-500 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-blue-600",children:t("common.close")})]})]})}):null}function dt({trigger:e,items:s,searchable:n=!1,searchPlaceholder:t,emptyLabel:i}){const l=u.useRef(null),c=u.useRef(null),[p,m]=u.useState(!1),[x,o]=u.useState(""),[y,b]=u.useState(0),k=u.useMemo(()=>{const d=x.trim().toLowerCase();return d?s.filter(g=>g.label.toLowerCase().includes(d)?!0:g.actions.some(v=>v.label.toLowerCase().includes(d))):s},[s,x]),w=u.useMemo(()=>k.flatMap(d=>d.actions.map(g=>({itemLabel:d.label,actionLabel:g.label,onClick:g.onClick}))),[k]);u.useEffect(()=>{var d;if(!p){o(""),b(0);return}n&&((d=c.current)==null||d.focus())},[p,n]),u.useEffect(()=>{y<w.length||b(Math.max(w.length-1,0))},[w.length,y]),u.useEffect(()=>{if(!p)return;const d=v=>{var _;(_=l.current)!=null&&_.contains(v.target)||m(!1)},g=v=>{var _;if(v.key==="Escape"){v.preventDefault(),m(!1);return}if(w.length!==0){if(v.key==="ArrowDown"){v.preventDefault(),b(M=>(M+1)%w.length);return}if(v.key==="ArrowUp"){v.preventDefault(),b(M=>(M-1+w.length)%w.length);return}v.key==="Enter"&&(v.preventDefault(),(_=w[y])==null||_.onClick(),m(!1))}};return window.addEventListener("mousedown",d),window.addEventListener("keydown",g),()=>{window.removeEventListener("mousedown",d),window.removeEventListener("keydown",g)}},[w,y,p]);let h=-1;return r.jsxs("div",{ref:l,className:"relative",children:[r.jsxs("button",{type:"button",onMouseDown:d=>d.preventDefault(),onClick:()=>m(d=>!d),className:"inline-flex items-center gap-1 rounded-md border border-gray-200 bg-white px-2.5 py-1.5 text-xs font-medium text-gray-700 transition hover:border-gray-300 hover:bg-gray-100",children:[r.jsx("span",{children:e}),r.jsx(de,{size:14})]}),p?r.jsxs("div",{className:"absolute left-0 top-[calc(100%+0.5rem)] z-20 w-72 rounded-xl border border-gray-200 bg-white p-2 shadow-lg",children:[n?r.jsxs("label",{className:"mb-2 flex items-center gap-2 rounded-lg border border-gray-200 bg-gray-50 px-3 py-2 text-xs text-gray-500",children:[r.jsx(ue,{size:14}),r.jsx("input",{ref:c,value:x,onChange:d=>{o(d.target.value),b(0)},className:"w-full bg-transparent text-sm text-gray-700 outline-none","aria-label":t,placeholder:t})]}):null,r.jsx("div",{className:"max-h-80 space-y-1 overflow-y-auto",children:k.length===0?r.jsx("div",{className:"rounded-lg px-3 py-2 text-sm text-gray-500",children:i??""}):k.map(d=>r.jsxs("div",{className:"rounded-lg border border-gray-100 px-3 py-2",children:[r.jsx("div",{className:"text-sm font-medium text-gray-900",children:d.label}),d.actions.length>0?r.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:d.actions.map(g=>{h+=1;const v=h===y;return r.jsx("button",{type:"button",onMouseDown:_=>_.preventDefault(),onClick:()=>{g.onClick(),m(!1)},className:`rounded-md px-2.5 py-1 text-xs font-medium transition ${v?"bg-blue-500 text-white":"border border-gray-200 bg-white text-gray-700 hover:border-gray-300 hover:bg-gray-100"}`,children:g.label},`${d.label}-${g.label}`)})}):r.jsx("div",{className:"mt-1 text-xs text-gray-500",children:i??d.label})]},d.label))})]}):null]})}function te(e){return e.replace(/\\/g,"/").replace(/^\.?\//,"")}function ne(e,s){return(e??"").toLowerCase().includes(s)}function ut({documents:e,documentsLoading:s,documentsError:n,documentsUnavailable:t,onInsertDocument:i,onRefetchDocuments:l}){const{t:c}=B(),p=u.useRef(null),m=u.useRef(null),[x,o]=u.useState(!1),[y,b]=u.useState(""),[k,w]=u.useState([]),[h,d]=u.useState(!1),[g,v]=u.useState(null),[_,M]=u.useState(new Set),[a,j]=u.useState(!1),[C,D]=u.useState(null);u.useEffect(()=>{var N;if(!x||((N=m.current)==null||N.focus(),k.length>0||h))return;let f=!1;return(async()=>{d(!0),v(null);try{const S=await V.getDocTree();f||w(S)}catch(S){f||v(S instanceof Error?S.message:c("agent.prompt.documentPicker.treeError"))}finally{f||d(!1)}})(),()=>{f=!0}},[x,k.length]),u.useEffect(()=>{x||(b(f=>f&&""),M(f=>f.size>0?new Set:f))},[x]),u.useEffect(()=>{if(!x)return;const f=N=>{var S;(S=p.current)!=null&&S.contains(N.target)||o(!1)},L=N=>{N.key==="Escape"&&(N.preventDefault(),o(!1))};return window.addEventListener("mousedown",f),window.addEventListener("keydown",L),()=>{window.removeEventListener("mousedown",f),window.removeEventListener("keydown",L)}},[x]);const E=y.trim().toLowerCase(),$=u.useMemo(()=>e.filter(f=>f.type==="inline"),[e]),z=u.useMemo(()=>{const f=e.filter(L=>L.type==="file"&&L.path);return L=>{const N=te(L),S=f.find(ve=>te(ve.path??"")===N);return S==null?void 0:S.key}},[e]),T=u.useMemo(()=>E?$.filter(f=>ne(f.key,E)||ne(f.summary,E)):$,[$,E]),P=u.useMemo(()=>me(k,E),[E,k]),be=u.useMemo(()=>{if(!E)return _;const f=new Set(_);return P.autoExpanded.forEach(L=>f.add(L)),f},[_,P.autoExpanded,E]),H=f=>{i(f,"content"),o(!1)},ye=async f=>{D(null);const L=z(f);if(L){H(L);return}try{j(!0);const N=await V.registerDocument({path:f});H(N.key),l==null||l()}catch(N){D(N instanceof Error?N.message:c("agent.prompt.documentPicker.registerError"))}finally{j(!1)}},G=s||n||t||T.length>0,Z=h||g||P.nodes.length>0;return r.jsxs("div",{ref:p,className:"relative",children:[r.jsxs("button",{type:"button",onMouseDown:f=>f.preventDefault(),onClick:()=>o(f=>!f),className:"inline-flex items-center gap-1 rounded-md border border-gray-200 bg-white px-2.5 py-1.5 text-xs font-medium text-gray-700 transition hover:border-gray-300 hover:bg-gray-100","aria-label":c("agent.prompt.documentInsert"),children:[r.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[r.jsx(K,{className:"h-4 w-4"}),r.jsx("span",{children:c("agent.prompt.documentInsert")})]}),r.jsx(de,{size:14})]}),x?r.jsxs("div",{className:"absolute left-0 top-[calc(100%+0.5rem)] z-20 w-80 rounded-xl border border-gray-200 bg-white p-2 shadow-lg","data-testid":"document-picker-popover",children:[r.jsxs("label",{className:"mb-2 flex items-center gap-2 rounded-lg border border-gray-200 bg-gray-50 px-3 py-2 text-xs text-gray-500",children:[r.jsx(ue,{size:14}),r.jsx("input",{ref:m,value:y,onChange:f=>b(f.target.value),className:"w-full bg-transparent text-sm text-gray-700 outline-none","aria-label":c("agent.prompt.documentPicker.searchPlaceholder"),placeholder:c("agent.prompt.documentPicker.searchPlaceholder")})]}),r.jsxs("div",{className:"max-h-96 space-y-3 overflow-y-auto",children:[G?r.jsxs("section",{children:[r.jsxs("div",{className:"mb-1 flex items-center gap-2 px-2 py-1 text-xs font-semibold uppercase tracking-wide text-gray-400",children:[r.jsx(Ne,{className:"h-3.5 w-3.5"}),r.jsx("span",{children:c("agent.prompt.documentPicker.inlineSection")})]}),s?r.jsx("div",{className:"rounded-lg px-3 py-2 text-sm text-gray-500",children:c("agent.prompt.documentInsertLoading")}):n?r.jsx("div",{className:"rounded-lg px-3 py-2 text-sm text-red-500",children:n}):t?r.jsx("div",{className:"rounded-lg px-3 py-2 text-sm text-gray-500",children:c("agent.prompt.documentInsertUnavailable")}):T.length===0?r.jsx("div",{className:"rounded-lg px-3 py-2 text-sm text-gray-500",children:c("agent.prompt.documentPicker.noInlineResults")}):r.jsx("div",{className:"space-y-1",children:T.map(f=>r.jsxs("button",{type:"button",onMouseDown:L=>L.preventDefault(),onClick:()=>H(f.key),className:"flex w-full items-center gap-2 rounded-lg px-3 py-2 text-left text-sm text-gray-700 transition hover:bg-gray-100",children:[r.jsx(K,{className:"h-4 w-4 shrink-0 text-gray-400"}),r.jsx("span",{className:"truncate",children:f.key})]},f.key))})]}):null,Z?r.jsxs("section",{children:[r.jsxs("div",{className:"mb-1 flex items-center gap-2 px-2 py-1 text-xs font-semibold uppercase tracking-wide text-gray-400",children:[r.jsx(K,{className:"h-3.5 w-3.5"}),r.jsx("span",{children:c("agent.prompt.documentPicker.docsSection")})]}),h?r.jsxs("div",{className:"flex items-center gap-2 rounded-lg px-3 py-2 text-sm text-gray-500",children:[r.jsx(X,{className:"h-4 w-4 animate-spin"}),r.jsx("span",{children:c("agent.prompt.documentPicker.treeLoading")})]}):g?r.jsx("div",{className:"rounded-lg px-3 py-2 text-sm text-red-500",children:g}):P.nodes.length===0?r.jsx("div",{className:"rounded-lg px-3 py-2 text-sm text-gray-500",children:c("agent.prompt.documentPicker.noTreeResults")}):r.jsxs(r.Fragment,{children:[r.jsx(Ce,{nodes:P.nodes,expandedFolders:be,onToggle:f=>M(L=>{const N=new Set(L);return N.has(f)?N.delete(f):N.add(f),N}),onSelect:f=>{a||ye(f)},selectedPath:null,isFileDisabled:()=>a,renderFileSuffix:f=>z(f.path)?r.jsx(rt,{className:"h-3.5 w-3.5 shrink-0 text-blue-500","aria-label":c("agent.prompt.documentPicker.linked")}):a?r.jsx(X,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-gray-400"}):null}),C?r.jsx("div",{className:"mt-1 rounded-lg px-3 py-2 text-sm text-red-500",role:"alert",children:C}):null]})]}):null,!G&&!Z?r.jsx("div",{className:"rounded-lg px-3 py-2 text-sm text-gray-500",children:c("agent.prompt.documentInsertEmpty")}):null]})]}):null]})}function pt({deleteNode:e,extension:s,node:n,updateAttributes:t}){const{t:i}=B(),l=u.useRef(null),[c,p]=u.useState(!1),m=String(n.attrs.key??""),x=String(n.attrs.variant??"content"),o=s.options.getVariantLabel;u.useEffect(()=>{if(!c)return;const b=w=>{var h;(h=l.current)!=null&&h.contains(w.target)||p(!1)},k=w=>{w.key==="Escape"&&(w.preventDefault(),p(!1))};return window.addEventListener("mousedown",b),window.addEventListener("keydown",k),()=>{window.removeEventListener("mousedown",b),window.removeEventListener("keydown",k)}},[c]);const y=[{value:"content",label:o("content")},{value:"toc",label:o("toc")}];return r.jsxs(Le,{as:"span",ref:l,className:"relative inline-flex","data-testid":"document-block-node",children:[r.jsx("button",{type:"button","data-testid":"document-block-trigger",onMouseDown:b=>b.preventDefault(),onClick:()=>p(b=>!b),className:"inline-flex items-center rounded-lg border border-amber-200 bg-amber-50 px-2 py-0.5 text-xs font-medium text-amber-700",children:`📄 ${m} · ${o(x)}`}),c?r.jsxs("span",{className:"absolute left-0 top-[calc(100%+0.375rem)] z-20 min-w-32 rounded-lg border border-gray-200 bg-white p-1 shadow-lg","data-testid":"document-block-popover",children:[y.map(b=>{const k=b.value===x;return r.jsxs("button",{type:"button","data-testid":`document-block-option-${b.value}`,onMouseDown:w=>w.preventDefault(),onClick:()=>{t({variant:b.value}),p(!1)},className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-gray-700 transition hover:bg-gray-100",children:[r.jsx("span",{className:"inline-flex h-4 w-4 items-center justify-center",children:k?r.jsx(_e,{className:"h-4 w-4 text-blue-500"}):null}),r.jsx("span",{children:b.label})]},b.value)}),r.jsx("div",{className:"my-1 border-t border-gray-100"}),r.jsxs("button",{type:"button","data-testid":"document-block-delete",onMouseDown:b=>b.preventDefault(),onClick:()=>{e(),p(!1)},className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-red-600 transition hover:bg-red-50",children:[r.jsx(Ee,{className:"h-4 w-4"}),r.jsx("span",{children:i("agent.prompt.documentChip.delete")})]})]}):null]})}const mt=pe.create({name:"documentBlock",addOptions(){return{getVariantLabel:e=>String(e)}},inline:!0,group:"inline",atom:!0,draggable:!0,selectable:!0,addAttributes(){return{key:{default:""},variant:{default:"content"}}},parseHTML(){return[{tag:"span[data-doc-block]"}]},renderHTML({HTMLAttributes:e,node:s}){const n=String(s.attrs.key??""),t=String(s.attrs.variant??"content"),i=this.options.getVariantLabel(t);return["span",De(e,{"data-doc-block":"true","data-key":n,"data-variant":t,"data-testid":"document-block",class:"inline-flex items-center rounded-lg border border-amber-200 bg-amber-50 px-2 py-0.5 text-xs font-medium text-amber-700"}),`📄 ${n} · ${i}`]},addNodeView(){return Se(pt)}}),ft=Me.extend({name:"variableMention",addAttributes(){return{variable:{default:"",parseHTML:e=>e.getAttribute("data-variable")??"",renderHTML:e=>({"data-variable":e.variable})}}},renderText({node:e}){return`{{${String(e.attrs.variable??"")}}}`},renderHTML({node:e,HTMLAttributes:s}){return["span",{...s,class:"inline-flex items-center rounded-full bg-blue-500 px-2 py-0.5 text-xs font-semibold text-white","data-testid":"variable-chip"},String(e.attrs.variable??"")]}}),ge=["agent.id","agent.name","agent.role","agent.team","agent.description"],re=["bold","italic","strike","code"],se={bold:{open:"**",close:"**"},italic:{open:"*",close:"*"},strike:{open:"~~",close:"~~"},code:{open:"`",close:"`"}};function ht(e){return ge.includes(e)}function xe(e,s){return s&&s.length>0?{type:"text",text:e,marks:s}:{type:"text",text:e}}function Q(e,s,n){if(!s)return;const t=e[e.length-1],i=JSON.stringify(n??[]),l=JSON.stringify((t==null?void 0:t.marks)??[]);if((t==null?void 0:t.type)==="text"&&i===l){t.text=`${t.text??""}${s}`;return}e.push(xe(s,n))}function O(e,...s){return e.map(n=>{if(n.type!=="text")return n;const t=new Set((n.marks??[]).map(l=>l.type)),i=s.filter(l=>!t.has(l)).map(l=>({type:l}));return{...n,marks:[...n.marks??[],...i]}})}function gt(e){const s=e.match(/^\{\{(agent\.(?:id|name|role|team|description))\}\}$/);return!s||!ht(s[1])?null:{type:"variableMention",attrs:{variable:s[1]}}}function J(e){const s=e.match(/^\{\{\{documents\.([^.\s}]+)\.(content|toc)\}\}\}$/);return s?{type:"documentBlock",attrs:{key:s[1],variant:s[2]}}:null}function xt(e,s){const n=e[s].match(/^<document\b[^>]*>\s*(\{\{\{documents\.([^.\s}]+)\.(content|toc)\}\}\})\s*<\/document>\s*$/);if(n){const m=J(n[1]);if(m)return{node:{type:"paragraph",content:[m]},nextIndex:s+1}}if(!/^<document\b[^>]*>\s*$/.test(e[s]??""))return null;let t=s+1;for(;t<e.length&&(e[t]??"").trim()==="";)t+=1;const l=(e[t]??"").trim();for(t+=1;t<e.length&&(e[t]??"").trim()==="";)t+=1;if((e[t]??"").trim()!=="</document>")return null;const p=J(l);return p?{node:{type:"paragraph",content:[p]},nextIndex:t+1}:null}function W(e,s,n,t){return e.startsWith(s,t)?e.indexOf(n,t+s.length):-1}function bt(e,s){const n=[e.indexOf("{{{documents.",s),e.indexOf("{{agent.",s),e.indexOf("**",s),e.indexOf("~~",s),e.indexOf("`",s),e.indexOf("*",s)].filter(t=>t>=0);return n.length>0?Math.min(...n):-1}function A(e,s=!1){const n=[];let t=0;for(;t<e.length;){const i=W(e,"***","***",t);if(i>t){const o=e.slice(t+3,i);n.push(...O(A(o,s),"bold","italic")),t=i+3;continue}if(!s&&e.startsWith("{{{documents.",t)){const o=e.indexOf("}}}",t);if(o>t){const y=e.slice(t,o+3),b=J(y);if(b){n.push(b),t=o+3;continue}}}if(!s&&e.startsWith("{{agent.",t)){const o=e.indexOf("}}",t);if(o>t){const y=e.slice(t,o+2),b=gt(y);if(b){n.push(b),t=o+2;continue}}}const l=W(e,"**","**",t);if(l>t){const o=e.slice(t+2,l);n.push(...O(A(o,s),"bold")),t=l+2;continue}const c=W(e,"~~","~~",t);if(c>t){const o=e.slice(t+2,c);n.push(...O(A(o,s),"strike")),t=c+2;continue}const p=e[t]==="*"&&!e.startsWith("**",t)?e.indexOf("*",t+1):-1;if(p>t){const o=e.slice(t+1,p);n.push(...O(A(o,s),"italic")),t=p+1;continue}if(e[t]==="`"){const o=e.indexOf("`",t+1);if(o>t){Q(n,e.slice(t+1,o),[{type:"code"}]),t=o+1;continue}}const m=bt(e,t),x=m>=0?m:e.length;if(x===t){Q(n,e[t]),t+=1;continue}Q(n,e.slice(t,x)),t=x}return n}function yt(e){const s=e.split(`
|
|
22
|
+
`),n=[];return s.forEach((t,i)=>{n.push(...A(t)),i<s.length-1&&n.push({type:"hardBreak"})}),{type:"paragraph",content:n}}function ae(e,s){const n=s?"orderedList":"bulletList",t=s?/^\d+\.\s+/:/^[-*]\s+/;return{type:n,content:e.map(i=>({type:"listItem",content:[{type:"paragraph",content:A(i.replace(t,""))}]}))}}function vt(e){return/^#{1,3}\s+/.test(e)||/^```/.test(e)||/^---+$/.test(e)||/^[-*]\s+/.test(e)||/^\d+\.\s+/.test(e)}function kt(e){const s=new Set((e??[]).map(n=>n.type).filter(n=>re.includes(n)));return re.filter(n=>s.has(n))}function wt(e,s){let n=0;for(;n<e.length&&n<s.length&&e[n]===s[n];)n+=1;return n}function oe(e){return e.replace(/&/g,"&").replace(/"/g,""").trim()}function jt(e,s,n){var t,i,l,c;if(e.type==="hardBreak")return`
|
|
23
|
+
`;if(e.type==="variableMention"){const p=String(((t=e.attrs)==null?void 0:t.variable)??"");return s==="preview"?`**{{${p}}}**`:`{{${p}}}`}if(e.type==="documentBlock"){const p=String(((i=e.attrs)==null?void 0:i.key)??""),m=String(((l=e.attrs)==null?void 0:l.variant)??"content"),x=`{{{documents.${p}.${m}}}}`,o=((c=n==null?void 0:n.getDocumentMeta)==null?void 0:c.call(n,p))??{name:p},y=[`name="${oe(o.name)}"`];return o.path&&y.push(`path="${oe(o.path)}"`),y.push(`type="${m}"`),`<document ${y.join(" ")}>
|
|
24
|
+
|
|
25
|
+
${x}
|
|
26
|
+
|
|
27
|
+
</document>`}return I(e.content,s,n)}function I(e,s,n){let t="",i=[];const l=c=>{const p=wt(i,c);for(let m=i.length-1;m>=p;m-=1)t+=se[i[m]].close;for(let m=p;m<c.length;m+=1)t+=se[c[m]].open;i=c};for(const c of e??[]){if(c.type==="text"){l(kt(c.marks)),t+=c.text??"";continue}l([]),t+=jt(c,s,n)}return l([]),t}function U(e){const s=e.replace(/\r\n?/g,`
|
|
28
|
+
`);if(!s.trim())return{type:"doc",content:[]};const n=s.split(`
|
|
29
|
+
`),t=[];let i=0;for(;i<n.length;){const l=n[i];if(!l.trim()){i+=1;continue}const c=xt(n,i);if(c){t.push(c.node),i=c.nextIndex;continue}const p=l.match(/^```(\S+)?\s*$/);if(p){const o=p[1]??null,y=[];for(i+=1;i<n.length&&!/^```/.test(n[i]);)y.push(n[i]),i+=1;i<n.length&&(i+=1),t.push({type:"codeBlock",attrs:o?{language:o}:{},content:[xe(y.join(`
|
|
30
|
+
`))]});continue}const m=l.match(/^(#{1,3})\s+(.*)$/);if(m){t.push({type:"heading",attrs:{level:m[1].length},content:A(m[2])}),i+=1;continue}if(/^---+$/.test(l)){t.push({type:"horizontalRule"}),i+=1;continue}if(/^[-*]\s+/.test(l)){const o=[];for(;i<n.length&&/^[-*]\s+/.test(n[i]);)o.push(n[i]),i+=1;t.push(ae(o,!1));continue}if(/^\d+\.\s+/.test(l)){const o=[];for(;i<n.length&&/^\d+\.\s+/.test(n[i]);)o.push(n[i]),i+=1;t.push(ae(o,!0));continue}const x=[l];for(i+=1;i<n.length&&n[i].trim()&&!vt(n[i]);)x.push(n[i]),i+=1;t.push(yt(x.join(`
|
|
31
|
+
`)))}return{type:"doc",content:t}}function Nt(e,s,n){var t,i,l,c;switch(e.type){case"heading":{const p=Number(((t=e.attrs)==null?void 0:t.level)??1);return`${"#".repeat(Math.max(1,Math.min(3,p)))} ${I(e.content,s,n)}`}case"bulletList":return(e.content??[]).map(p=>{var m,x;return`- ${I((x=(m=p.content)==null?void 0:m[0])==null?void 0:x.content,s,n)}`}).join(`
|
|
32
|
+
`);case"orderedList":return(e.content??[]).map((p,m)=>{var x,o;return`${m+1}. ${I((o=(x=p.content)==null?void 0:x[0])==null?void 0:o.content,s,n)}`}).join(`
|
|
33
|
+
`);case"codeBlock":{const p=typeof((i=e.attrs)==null?void 0:i.language)=="string"?e.attrs.language:"",m=((c=(l=e.content)==null?void 0:l[0])==null?void 0:c.text)??"";return`\`\`\`${p}
|
|
34
|
+
${m}
|
|
35
|
+
\`\`\``}case"horizontalRule":return"---";case"paragraph":return I(e.content,s,n);default:return I(e.content,s,n)}}function ie(e,s){return(e.content??[]).map(n=>Nt(n,"hbs",s)).join(`
|
|
36
|
+
|
|
37
|
+
`)}function Ct(e){return/\{\{agent\.(?:id|name|role|team|description)\}\}|\{\{\{documents\.[^.\s}]+\.(?:content|toc)\}\}\}|<document\b[^>]*>/.test(e)}function Lt(e,s){return{type:"documentBlock",attrs:{key:e,variant:s}}}function le(e){return{type:"variableMention",attrs:{variable:e}}}function q(e){return!e.isActive("codeBlock")&&!e.isActive("code")}function ce(e,s,n){return q(e)?it(e,s,n)?!1:(e.chain().focus().insertContent(Lt(s,n)).run(),!0):(e.chain().focus().insertContent(`{{{documents.${s}.${n}}}}`).run(),!0)}const _t=u.forwardRef(function({value:s,onChange:n,documents:t,documentsLoading:i,documentsError:l,documentsUnavailable:c,onPreview:p,onRefetchDocuments:m},x){const{t:o}=B(),y=u.useRef(null),b=u.useMemo(()=>({content:o("agent.prompt.variantContent"),toc:o("agent.prompt.variantToc")}),[o]),k=u.useMemo(()=>a=>{var C;const j=t.find(D=>D.key===a);if((j==null?void 0:j.type)==="file"&&j.path){const D=j.path.split("/").filter(Boolean);return{name:D[D.length-1]??a,path:j.path}}return{name:((C=j==null?void 0:j.summary)==null?void 0:C.trim())||a}},[t]),w=u.useMemo(()=>[{key:"headings",buttons:[{key:"h1",label:o("agent.prompt.toolbar.h1"),icon:Ae,shortcut:"Cmd+Alt+1",action:a=>{a.chain().focus().toggleHeading({level:1}).run()},isActive:a=>a.isActive("heading",{level:1})},{key:"h2",label:o("agent.prompt.toolbar.h2"),icon:$e,shortcut:"Cmd+Alt+2",action:a=>{a.chain().focus().toggleHeading({level:2}).run()},isActive:a=>a.isActive("heading",{level:2})},{key:"h3",label:o("agent.prompt.toolbar.h3"),icon:Te,shortcut:"Cmd+Alt+3",action:a=>{a.chain().focus().toggleHeading({level:3}).run()},isActive:a=>a.isActive("heading",{level:3})}]},{key:"text",buttons:[{key:"bold",label:o("agent.prompt.toolbar.bold"),icon:Ie,shortcut:"Cmd+B",action:a=>{a.chain().focus().toggleBold().run()},isActive:a=>a.isActive("bold")},{key:"italic",label:o("agent.prompt.toolbar.italic"),icon:Pe,shortcut:"Cmd+I",action:a=>{a.chain().focus().toggleItalic().run()},isActive:a=>a.isActive("italic")},{key:"strike",label:o("agent.prompt.toolbar.strike"),icon:Re,shortcut:"Cmd+Shift+S",action:a=>{a.chain().focus().toggleStrike().run()},isActive:a=>a.isActive("strike")}]},{key:"lists",buttons:[{key:"bulletList",label:o("agent.prompt.toolbar.bulletList"),icon:Be,shortcut:"Cmd+Shift+8",action:a=>{a.chain().focus().toggleBulletList().run()},isActive:a=>a.isActive("bulletList")},{key:"orderedList",label:o("agent.prompt.toolbar.orderedList"),icon:ze,shortcut:"Cmd+Shift+7",action:a=>{a.chain().focus().toggleOrderedList().run()},isActive:a=>a.isActive("orderedList")},{key:"blockquote",label:o("agent.prompt.toolbar.blockquote"),icon:Oe,shortcut:"Cmd+Shift+B",action:a=>{a.chain().focus().toggleBlockquote().run()},isActive:a=>a.isActive("blockquote")}]},{key:"code",buttons:[{key:"code",label:o("agent.prompt.toolbar.code"),icon:qe,shortcut:"Cmd+E",action:a=>{a.chain().focus().toggleCode().run()},isActive:a=>a.isActive("code")},{key:"codeBlock",label:o("agent.prompt.toolbar.codeBlock"),icon:Ve,shortcut:"Cmd+Alt+C",action:a=>{a.chain().focus().toggleCodeBlock().run()},isActive:a=>a.isActive("codeBlock")},{key:"horizontalRule",label:o("agent.prompt.toolbar.horizontalRule"),icon:Fe,shortcut:"Cmd+Alt+-",action:a=>{a.chain().focus().setHorizontalRule().run()}}]},{key:"history",buttons:[{key:"undo",label:o("agent.prompt.toolbar.undo"),icon:He,shortcut:"Cmd+Z",action:a=>{a.chain().focus().undo().run()},isDisabled:a=>!a.can().chain().focus().undo().run()},{key:"redo",label:o("agent.prompt.toolbar.redo"),icon:Ke,shortcut:"Cmd+Shift+Z",action:a=>{a.chain().focus().redo().run()},isDisabled:a=>!a.can().chain().focus().redo().run()}]}],[o]),h=Qe({immediatelyRender:!1,extensions:[We.configure({heading:{levels:[1,2,3]}}),Ue.configure({placeholder:o("agent.prompt.placeholder")}),ft.configure({HTMLAttributes:{class:"inline-flex items-center rounded-full bg-blue-500 px-2 py-0.5 text-xs font-semibold text-white"}}),mt.configure({getVariantLabel:a=>a==="toc"?b.toc:b.content}),pe.create({name:"fallbackInline",inline:!0,group:"inline"})],content:U(s),editorProps:{attributes:{class:lt,"data-testid":"prompt-editor-content","aria-label":o("agent.prompt.editorLabel"),role:"textbox"}},onUpdate({editor:a}){const j=ie(a.getJSON(),{getDocumentMeta:k});y.current=j,n(j)}}),d=Xe({editor:h,selector:({editor:a})=>a?{active:{h1:a.isActive("heading",{level:1}),h2:a.isActive("heading",{level:2}),h3:a.isActive("heading",{level:3}),bold:a.isActive("bold"),italic:a.isActive("italic"),strike:a.isActive("strike"),bulletList:a.isActive("bulletList"),orderedList:a.isActive("orderedList"),blockquote:a.isActive("blockquote"),code:a.isActive("code"),codeBlock:a.isActive("codeBlock")},disabled:{undo:!a.can().chain().focus().undo().run(),redo:!a.can().chain().focus().redo().run()}}:{active:{},disabled:{}}}),g=u.useMemo(()=>ge.map(a=>({label:a,actions:[{label:o("agent.prompt.toolbar.insert"),onClick:()=>{if(h){if(q(h)){h.chain().focus().insertContent(le(a)).run();return}h.chain().focus().insertContent(`{{${a}}}`).run()}}}]})),[h,o]);u.useEffect(()=>{if(!h)return;const a=ie(h.getJSON(),{getDocumentMeta:k});s===a||s===y.current||(h.commands.setContent(U(s)),y.current=s)},[h,k,s]),u.useImperativeHandle(x,()=>({insertVariable(a){if(h){if(q(h)){h.chain().focus().insertContent(le(a)).run();return}h.chain().focus().insertContent(`{{${a}}}`).run()}},insertDocumentBlock(a,j){return h?ce(h,a,j):!1},selectAll(){h==null||h.chain().focus().selectAll().run()}}),[h]);const v=a=>{if(!h||!q(h))return;const j=a.clipboardData.getData("text/plain");if(!j||!Ct(j))return;a.preventDefault();const C=U(j);h.chain().focus().insertContent(C.content??[]).run()},_=a=>`${a.label} (${a.shortcut})`,M=(a,j)=>h?ce(h,a,j):!1;return r.jsxs("section",{className:"rounded-xl border border-gray-200 bg-gray-50 p-4 shadow-sm",children:[r.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-2 rounded-xl border border-gray-200 bg-white p-2 shadow-sm",children:[w.map((a,j)=>r.jsxs("div",{className:"flex items-center gap-1",children:[j>0?r.jsx("div",{className:"mx-1 h-6 border-l border-gray-300","aria-hidden":"true"}):null,a.buttons.map(C=>{var T;const D=_(C),E=(d==null?void 0:d.active[C.key])??!1,$=h?(((T=C.isDisabled)==null?void 0:T.call(C,h))??!1)||((d==null?void 0:d.disabled[C.key])??!1):!0,z=C.icon;return r.jsx("button",{type:"button",title:D,"aria-label":D,"data-testid":`prompt-toolbar-${C.key}`,disabled:$,onClick:()=>h&&C.action(h),className:`flex h-8 w-8 items-center justify-center rounded-md transition-colors ${E?"bg-gray-200 text-gray-900":"text-gray-600 hover:bg-gray-100 hover:text-gray-900"} ${$?"cursor-not-allowed opacity-40":""}`,children:r.jsx(z,{className:"h-4 w-4"})},C.key)})]},a.key)),r.jsxs("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:[r.jsx("div",{className:"mx-1 h-6 border-l border-gray-300","aria-hidden":"true"}),r.jsx(dt,{trigger:r.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[r.jsx(Ye,{className:"h-4 w-4"}),r.jsx("span",{children:o("agent.prompt.toolbar.variable")})]}),items:g,emptyLabel:o("agent.prompt.toolbar.empty")}),r.jsx(ut,{documents:t,documentsLoading:i,documentsError:l,documentsUnavailable:c,onInsertDocument:M,onRefetchDocuments:m}),r.jsx("button",{type:"button",title:`${o("agent.prompt.preview.button")} (Cmd+P)`,"aria-label":`${o("agent.prompt.preview.button")} (Cmd+P)`,"data-testid":"prompt-toolbar-preview",onClick:p,className:"flex h-8 w-8 items-center justify-center rounded-md text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900",children:r.jsx(tt,{className:"h-4 w-4"})})]})]}),r.jsx("div",{"data-testid":"prompt-editor",onPaste:v,children:r.jsx(Je,{editor:h})})]})});function St({previewAgentId:e=null}){const{t:s}=B(),n=Ge(g=>g.currentWorkspaceId),t=Y(g=>g.form),i=Y(g=>g.setField),[l,c]=u.useState([]),[p,m]=u.useState(!0),[x,o]=u.useState(null),[y,b]=u.useState(!1),[k,w]=u.useState(!1),h=u.useMemo(()=>{const g=ot(t);return{template:t.prompt,...e?{agentId:e}:{},context:{agent:g}}},[t,e]),d=u.useCallback(async()=>{m(!0),o(null),b(!1);try{const g=await V.getDocuments();c(g.documents)}catch(g){if(fe(g)){c([]),b(!0);return}o(g instanceof Error?g.message:s("agent.prompt.documentInsertError"))}finally{m(!1)}},[s]);return u.useEffect(()=>{d()},[n,d]),u.useEffect(()=>{const g=v=>{!(v.metaKey||v.ctrlKey)||v.key.toLowerCase()!=="p"||(v.preventDefault(),w(!0))};return window.addEventListener("keydown",g),()=>{window.removeEventListener("keydown",g)}},[]),r.jsxs("div",{className:"space-y-5",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"text-base font-semibold text-gray-900",children:s("agent.section.promptTitle")}),r.jsx("p",{className:"mt-1 text-sm text-gray-500",children:s("agent.section.promptDescription")})]}),r.jsx("div",{className:"grid grid-cols-1 gap-5",children:r.jsx(_t,{value:t.prompt,onChange:g=>i("prompt",g),documents:l,documentsLoading:p,documentsError:x,documentsUnavailable:y,onPreview:()=>w(!0),onRefetchDocuments:()=>void d()})}),r.jsx(ct,{open:k,request:h,onClose:()=>w(!1)})]})}export{St as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as ln,a0 as an,a1 as y,a2 as tn,a3 as G,a4 as q,a5 as _,a6 as un,a7 as rn,a8 as K,a9 as o,aa as z,ab as sn,ac as on,ad as fn}from"./main-
|
|
1
|
+
import{$ as ln,a0 as an,a1 as y,a2 as tn,a3 as G,a4 as q,a5 as _,a6 as un,a7 as rn,a8 as K,a9 as o,aa as z,ab as sn,ac as on,ad as fn}from"./main-BMCdGsOk.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,I,D,v,A,B,a){var O=I-l,i=D-h,n=B-v,d=a-A,u=d*O-n*i;if(!(u*u<y))return u=(n*(h-A)-d*(l-v))/u,[l+u*O,h+u*i]}function V(l,h,I,D,v,A,B){var a=l-I,O=h-D,i=(B?A:-A)/K(a*a+O*O),n=i*O,d=-i*a,u=l+n,s=h+d,f=I+n,c=D+d,C=(u+f)/2,t=(s+c)/2,m=f-u,g=c-s,R=m*m+g*g,T=v-A,P=u*c-f*s,S=(g<0?-1:1)*K(fn(0,T*T*R-P*P)),$=(P*g-m*S)/R,j=(-P*m-g*S)/R,w=(P*g+m*S)/R,p=(-P*m+g*S)/R,x=$-C,e=j-t,r=w-C,F=p-t;return x*x+e*e>r*r+F*F&&($=w,j=p),{cx:$,cy:j,x01:-n,y01:-d,x11:$*(v/T-1),y11:j*(v/T-1)}}function hn(){var l=cn,h=yn,I=z(0),D=null,v=gn,A=dn,B=mn,a=null,O=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-an,c=A.apply(this,arguments)-an,C=un(c-f),t=c>f;if(a||(a=n=O()),s<u&&(d=s,s=u,u=d),!(s>y))a.moveTo(0,0);else if(C>tn-y)a.moveTo(s*G(f),s*q(f)),a.arc(0,0,s,f,c,!t),u>y&&(a.moveTo(u*G(c),u*q(c)),a.arc(0,0,u,c,f,t));else{var m=f,g=c,R=f,T=c,P=C,S=C,$=B.apply(this,arguments)/2,j=$>y&&(D?+D.apply(this,arguments):K(u*u+s*s)),w=_(un(s-u)/2,+I.apply(this,arguments)),p=w,x=w,e,r;if(j>y){var F=sn(j/u*q($)),L=sn(j/s*q($));(P-=F*2)>y?(F*=t?1:-1,R+=F,T-=F):(P=0,R=T=(f+c)/2),(S-=L*2)>y?(L*=t?1:-1,m+=L,g-=L):(S=0,m=g=(f+c)/2)}var H=s*G(m),J=s*q(m),M=u*G(T),N=u*q(T);if(w>y){var Q=s*G(g),U=s*q(g),W=u*G(R),X=u*q(R),E;if(C<rn)if(E=pn(H,J,W,X,Q,U,M,N)){var Y=H-E[0],Z=J-E[1],b=Q-E[0],k=U-E[1],nn=1/q(on((Y*b+Z*k)/(K(Y*Y+Z*Z)*K(b*b+k*k)))/2),en=K(E[0]*E[0]+E[1]*E[1]);p=_(w,(u-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}S>y?x>y?(e=V(W,X,H,J,s,x,t),r=V(Q,U,M,N,s,x,t),a.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),a.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(a.moveTo(H,J),a.arc(0,0,s,m,g,!t)):a.moveTo(H,J),!(u>y)||!(P>y)?a.lineTo(M,N):p>y?(e=V(M,N,Q,U,u,-p,t),r=V(H,J,W,X,u,-p,t),a.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,u,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),a.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):a.arc(0,0,u,T,R,t)}if(a.closePath(),n)return a=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +A.apply(this,arguments))/2-rn/2;return[G(d)*n,q(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:z(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:z(+n),i):h},i.cornerRadius=function(n){return arguments.length?(I=typeof n=="function"?n:z(+n),i):I},i.padRadius=function(n){return arguments.length?(D=n==null?null:typeof n=="function"?n:z(+n),i):D},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:z(+n),i):v},i.endAngle=function(n){return arguments.length?(A=typeof n=="function"?n:z(+n),i):A},i.padAngle=function(n){return arguments.length?(B=typeof n=="function"?n:z(+n),i):B},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{hn as d};
|