@bigduu/lotus 2026.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 +105 -0
- package/dist/assets/SettingsConfigService-R1F6YYRt.js +1 -0
- package/dist/assets/core-Cfh-QHsP.js +1 -0
- package/dist/assets/index-BVq3nR2i.js +5 -0
- package/dist/assets/index-BmjFP0ha.js +1 -0
- package/dist/assets/index-Duac2kP8.js +1 -0
- package/dist/assets/index-DzHbgzzW.css +1 -0
- package/dist/assets/index-NorSG5v2.js +1 -0
- package/dist/assets/index-_XI0Qq6F.js +1 -0
- package/dist/assets/index-tyDAO-Rv.js +1 -0
- package/dist/assets/index-xDR7WD86.js +1 -0
- package/dist/assets/index-xYaVUSFx.js +1 -0
- package/dist/assets/index.es-ksd75ldm.js +18 -0
- package/dist/assets/katex-ChWnQ-fc.js +261 -0
- package/dist/assets/main-CiAWoLS2.css +1 -0
- package/dist/assets/main-D-vCV98n.js +282 -0
- package/dist/assets/vendor-chart-hXvGMOW0.js +2558 -0
- package/dist/assets/vendor-pdf-6UhwjNJe.js +190 -0
- package/dist/assets/vendor-react-BK4ieJpD.js +108 -0
- package/dist/assets/vendor-ui-B6snAd4S.css +1 -0
- package/dist/assets/vendor-ui-BecvStzI.js +414 -0
- package/dist/index.html +19 -0
- package/dist/tauri.svg +6 -0
- package/dist/vite.svg +1 -0
- package/package.json +87 -0
package/README.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Lotus Frontend
|
|
2
|
+
|
|
3
|
+
Lotus is the standalone React/Vite frontend for the Bodhi desktop shell and Bamboo HTTP backend.
|
|
4
|
+
|
|
5
|
+
## What Lotus Owns
|
|
6
|
+
|
|
7
|
+
- Frontend UI (`src/`)
|
|
8
|
+
- Frontend unit/integration tests (Vitest)
|
|
9
|
+
- End-to-end browser tests (`e2e/`, Playwright)
|
|
10
|
+
|
|
11
|
+
## Related Projects
|
|
12
|
+
|
|
13
|
+
- `bodhi/`: Tauri shell and native desktop integrations
|
|
14
|
+
- `bamboo/`: Rust HTTP backend (`bamboo serve`)
|
|
15
|
+
|
|
16
|
+
## Prerequisites
|
|
17
|
+
|
|
18
|
+
- Node.js (LTS)
|
|
19
|
+
- npm
|
|
20
|
+
- Rust (for running the backend locally during integration/E2E)
|
|
21
|
+
|
|
22
|
+
## Install
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
cd lotus
|
|
26
|
+
npm install
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Development
|
|
30
|
+
|
|
31
|
+
### Frontend only
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
cd lotus
|
|
35
|
+
npm run dev
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Frontend + real backend
|
|
39
|
+
|
|
40
|
+
Terminal 1:
|
|
41
|
+
```bash
|
|
42
|
+
cd bamboo
|
|
43
|
+
cargo run --bin bamboo -- serve --port 9562 --bind 127.0.0.1 --data-dir /tmp/bamboo-data
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Terminal 2:
|
|
47
|
+
```bash
|
|
48
|
+
cd lotus
|
|
49
|
+
npm run dev
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Build
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
cd lotus
|
|
56
|
+
npm run build
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Package For Bodhi
|
|
60
|
+
|
|
61
|
+
Lotus can be distributed as an npm package that contains built frontend assets (`dist/`).
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
cd lotus
|
|
65
|
+
npm run pack:dry-run
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Notes:
|
|
69
|
+
- `npm pack`/`npm publish` automatically triggers `prepack` (`npm run build`).
|
|
70
|
+
- `bodhi` can consume this package by setting `LOTUS_SOURCE=package` and `LOTUS_PACKAGE_NAME=<package-name>` when building.
|
|
71
|
+
- Current package target is `@bigduu/lotus` (public).
|
|
72
|
+
|
|
73
|
+
## Tests
|
|
74
|
+
|
|
75
|
+
### Unit/integration (Vitest)
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
cd lotus
|
|
79
|
+
npm run test:run
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### E2E (Playwright)
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
cd lotus
|
|
86
|
+
npm run test:e2e
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### E2E with auto-started backend
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
cd lotus
|
|
93
|
+
npm run test:e2e:with-server
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Project Structure
|
|
97
|
+
|
|
98
|
+
```text
|
|
99
|
+
lotus/
|
|
100
|
+
├── src/ # React app
|
|
101
|
+
├── e2e/ # Playwright tests
|
|
102
|
+
├── scripts/ # Build/rebrand tooling
|
|
103
|
+
├── public/ # Static assets
|
|
104
|
+
└── vite.config.ts # Vite config
|
|
105
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var a=Object.defineProperty;var p=(n,t,c)=>t in n?a(n,t,{enumerable:!0,configurable:!0,writable:!0,value:c}):n[t]=c;var e=(n,t,c)=>p(n,typeof t!="symbol"?t+"":t,c);const s=class s{constructor(){}static getInstance(){return s.instance||(s.instance=new s),s.instance}async getSystemPrompts(){return{prompts:[]}}async getTools(){return{tools:[]}}};e(s,"instance");let r=s;export{r as BambooConfigService};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function t(e,r,o,n){if(typeof r=="function"?e!==r||!n:!r.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return o==="m"?n:o==="a"?n.call(e):n?n.value:r.get(e)}function i(e,r,o,n,u){if(typeof r=="function"?e!==r||!0:!r.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r.set(e,o),o}var s;async function a(e,r={},o){return window.__TAURI_INTERNALS__.invoke(e,r,o)}class c{get rid(){return t(this,s,"f")}constructor(r){s.set(this,void 0),i(this,s,r)}async close(){return a("plugin:resources|close",{rid:this.rid})}}s=new WeakMap;export{c as R,a as i};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{m as i,a6 as C,a7 as R,r as g,a as E}from"./vendor-react-BK4ieJpD.js";import{aq as f,az as I}from"./vendor-ui-BecvStzI.js";import{n as B,m as x,r as H,o as $}from"./main-D-vCV98n.js";import"./vendor-chart-hXvGMOW0.js";const X=({error:s,className:n,style:a,token:e,onFix:d,isFixing:o,fixError:r})=>{const l=s.split(`
|
|
2
|
+
|
|
3
|
+
`);return i.jsxs("div",{className:n,style:{color:e.colorError,padding:`${e.paddingXS}px ${e.paddingSM}px`,fontSize:e.fontSizeSM,background:e.colorErrorBg,borderRadius:e.borderRadiusSM,border:`1px solid ${e.colorErrorBorder}`,margin:`${e.marginXS}px 0`,minHeight:"60px",maxHeight:"120px",display:"flex",flexDirection:"column",alignItems:"flex-start",justifyContent:"flex-start",overflow:"auto",position:"relative",maxWidth:"100%",boxSizing:"border-box",...a},title:`Mermaid Error: ${s}
|
|
4
|
+
|
|
5
|
+
Check browser console for detailed error information.`,children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:e.marginXXS},children:[i.jsx("span",{style:{marginRight:e.marginXS,fontSize:"14px",flexShrink:0,lineHeight:1},children:"⚠️"}),i.jsx("span",{style:{fontWeight:600,color:e.colorError},children:"Mermaid Diagram Error"})]}),i.jsx("div",{style:{fontSize:e.fontSizeSM,lineHeight:1.4,wordBreak:"break-word",flex:1,width:"100%"},children:l.map((t,c)=>i.jsx("div",{style:{marginBottom:c<l.length-1?e.marginXS:0,...t.startsWith("💡")?{backgroundColor:e.colorInfoBg,border:`1px solid ${e.colorInfoBorder}`,borderRadius:e.borderRadiusSM,padding:e.paddingXS,marginTop:e.marginXS,color:e.colorInfo,fontWeight:500}:{}},children:t},`${c}-${t.substring(0,12)}`))}),d&&i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:e.marginXS,marginTop:e.marginXS,width:"100%"},children:[i.jsx(f,{size:"small",type:"primary",onClick:d,loading:o,children:"Fix Mermaid"}),r&&i.jsx("span",{style:{color:e.colorError,fontSize:e.fontSizeSM,wordBreak:"break-word",flex:1},children:r})]}),i.jsx("div",{style:{fontSize:e.fontSizeSM,color:e.colorTextSecondary,marginTop:e.marginXS,fontStyle:"italic"},children:"💡 Check browser console (F12) for detailed error information"})]})},W=({svg:s,height:n,isLoading:a,initialScale:e,className:d,style:o,token:r,containerRef:l})=>i.jsxs("div",{ref:l,className:d,style:{textAlign:"center",margin:`${r.marginXS}px 0`,padding:r.padding,background:r.colorBgContainer,borderRadius:r.borderRadiusSM,border:`1px solid ${r.colorBorder}`,overflow:"hidden",height:`${Math.min(n,800)}px`,minHeight:"300px",maxHeight:"80vh",display:"flex",alignItems:"center",justifyContent:"center",position:"relative",willChange:"auto",contain:"layout style paint",...o},children:[a&&i.jsx("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",color:r.colorTextSecondary,fontSize:r.fontSizeSM,zIndex:2},children:"Rendering diagram..."}),i.jsx("div",{style:{width:"100%",height:"100%",opacity:a?0:1,position:"relative"},children:i.jsx(C,{initialScale:e,minScale:.1,maxScale:10,centerOnInit:!0,limitToBounds:!1,wheel:{step:.1},panning:{disabled:!1},pinch:{disabled:!1},doubleClick:{disabled:!1,mode:"zoomIn",step:.5},children:({zoomIn:t,zoomOut:c,resetTransform:m})=>i.jsxs(i.Fragment,{children:[i.jsxs("div",{style:{position:"absolute",top:8,right:8,zIndex:10,display:"flex",flexDirection:"column",gap:4,background:r.colorBgContainer,borderRadius:r.borderRadiusSM,border:`1px solid ${r.colorBorder}`,padding:4,boxShadow:r.boxShadowSecondary},children:[i.jsx(f,{size:"small",type:"text",onClick:()=>t(),style:{fontSize:12,padding:"2px 6px"},children:"+"}),i.jsx(f,{size:"small",type:"text",onClick:()=>c(),style:{fontSize:12,padding:"2px 6px"},children:"-"}),i.jsx(f,{size:"small",type:"text",onClick:()=>m(),style:{fontSize:10,padding:"2px 6px"},children:"⌂"})]}),i.jsx(R,{wrapperStyle:{width:"100%",height:"100%"},contentStyle:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%"},children:i.jsx("div",{style:{display:"inline-block",lineHeight:0},dangerouslySetInnerHTML:{__html:s.replace(/<svg([^>]*)>/,'<svg$1 style="display: block; max-width: 100%; max-height: 100%;">')}})})]})})})]});function T(s){let n=2166136261;for(let a=0;a<s.length;a++)n=(n^s.charCodeAt(a))*16777619;return(n>>>0).toString(36)}const L=(s,n)=>{const a=g.useMemo(()=>B(s),[s]),e=g.useMemo(()=>T(a),[a]),[d,o]=g.useState(()=>{const r=x(e);return r?{svg:r.svg,height:r.height+80,svgWidth:r.width,svgHeight:r.height,error:"",isLoading:!1}:{svg:"",height:200,svgWidth:800,svgHeight:200,error:"",isLoading:n}});return g.useEffect(()=>{const r=x(e);o(r?{svg:r.svg,height:r.height+80,svgWidth:r.width,svgHeight:r.height,error:"",isLoading:!1}:{svg:"",height:200,svgWidth:800,svgHeight:200,error:"",isLoading:!1})},[e]),g.useEffect(()=>{if(x(e))return;let l=!1;return o(t=>({...t,isLoading:!0})),H(e,a).then(t=>{l||o({svg:t.svg,height:t.height+80,svgWidth:t.width,svgHeight:t.height,error:"",isLoading:!1})}).catch(t=>{if(!l){console.error("[MermaidState] Render error:",t);const c=t instanceof Error?t.message:String(t);o(m=>({...m,error:c||"Failed to render Mermaid diagram",isLoading:!1}))}}),()=>{l=!0}},[e,a,n]),{renderState:d,chartKey:e}},{useToken:F}=I,D=E.memo(({chart:s,id:n,className:a,style:e,onFix:d})=>{const{token:o}=F(),r=$(),[l,t]=g.useState(!1),[c,m]=g.useState(""),u=g.useRef(null),{renderState:y}=L(s,!0),{svg:v,height:b,svgWidth:p,error:S,isLoading:M}=y,j=(()=>{const h=r.defaultScale;return p>1200?h*.8:p>800?h*1:h*1.2})(),z=async()=>{if(!(!d||l)){t(!0),m("");try{await d(s)}catch(h){const w=h instanceof Error?h.message:String(h);m(w||"Failed to fix Mermaid diagram")}finally{t(!1)}}};return S?i.jsx(X,{error:S,className:a,style:e,token:o,onFix:d?z:void 0,isFixing:l,fixError:c}):i.jsx(W,{svg:v,height:b,isLoading:M,initialScale:j,className:a,style:e,token:o,containerRef:u})});D.displayName="MermaidChart";export{D as MermaidChart,D as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as a}from"./core-Cfh-QHsP.js";async function r(e={}){return typeof e=="object"&&Object.freeze(e),await a("plugin:dialog|save",{options:e})}export{r as save};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{m as e}from"./vendor-react-BK4ieJpD.js";import{as as x,at as n,ap as s,ar as m,av as a,aq as d,az as p}from"./vendor-ui-BecvStzI.js";import{c as g,d as h}from"./main-D-vCV98n.js";import"./vendor-chart-hXvGMOW0.js";const{Text:l}=m,{useToken:u}=p,b=({files:i,onRemove:c,onClear:o})=>{const{token:r}=u();return i.length===0?null:e.jsx(x,{size:"small",style:{marginBottom:r.marginXS,background:r.colorBgElevated,borderRadius:r.borderRadiusSM,border:`1px solid ${r.colorBorderSecondary}`},bodyStyle:{padding:r.paddingSM},title:e.jsxs(s,{align:"center",size:r.marginXS,children:[e.jsx(h,{}),e.jsx(l,{strong:!0,children:"Attached Files"}),e.jsx(a,{color:"geekblue",children:i.length})]}),extra:o?e.jsx(d,{type:"text",size:"small",onClick:o,children:"Clear All"}):null,children:e.jsx(n,{dataSource:i,renderItem:t=>e.jsx(n.Item,{style:{alignItems:"flex-start",padding:`${r.paddingXS}px 0`},actions:[e.jsx(d,{type:"text",size:"small",icon:e.jsx(g,{}),onClick:()=>c(t.id),children:"Remove"},"remove")],children:e.jsx(n.Item.Meta,{title:e.jsxs(s,{direction:"vertical",size:r.marginXXS,children:[e.jsx(l,{strong:!0,children:t.name}),e.jsxs(s,{size:r.marginXS,children:[e.jsx(a,{children:t.type||"unknown"}),e.jsxs(a,{color:"purple",children:[(t.size/1024).toFixed(1)," KB"]}),e.jsx(a,{color:"cyan",children:t.kind==="text"?"Text":"Binary"})]})]}),description:e.jsx("div",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"var(--ant-font-family-code)",background:r.colorFillTertiary,borderRadius:r.borderRadiusSM,padding:r.paddingXS,maxHeight:160,overflowY:"auto"},children:t.preview})})},t.id)})})};export{b as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.command-selector-container{position:absolute;bottom:100%;left:0;right:0;max-height:300px;overflow-y:auto;z-index:1000;margin-bottom:4px}.command-selector-item{padding:8px 16px;cursor:pointer;border-bottom:1px solid rgba(0,0,0,.06);transition:background-color .2s}.command-selector-item:last-child{border-bottom:none}.command-selector-item.selected{background-color:#1677ff14}.command-selector-item:hover{background-color:#00000005}.command-selector-item.selected:hover{background-color:#1677ff1f}.command-selector-item-header{display:flex;justify-content:space-between;align-items:center;gap:8px}.command-selector-item-name{font-weight:600;font-family:monospace;font-size:13px;flex-shrink:0}.command-selector-item-description{font-size:13px;margin-top:4px;line-height:1.4;overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}.command-selector-item-category{font-size:12px;margin-top:4px}.command-selector-item-tags{display:flex;gap:4px;flex-wrap:wrap;margin-top:6px}.command-selector-item-tags .ant-tag{margin:0;font-size:11px;padding:0 4px;line-height:18px}@media (prefers-color-scheme: dark){.command-selector-item{border-bottom-color:#ffffff0f}.command-selector-item:hover{background-color:#ffffff05}.command-selector-item.selected{background-color:#1677ff26}.command-selector-item.selected:hover{background-color:#1677ff33}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var ee=Object.defineProperty;var te=(r,t,s)=>t in r?ee(r,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[t]=s;var B=(r,t,s)=>te(r,typeof t!="symbol"?t+"":t,s);import{r as l,m as e}from"./vendor-react-BK4ieJpD.js";import{I as J,w as z,e as se,f as re,g as P,h as ae,i as ie,j as ne,k as le}from"./main-D-vCV98n.js";import{b5 as oe,b6 as ce,az as Y,ar as E,aw as F,ax as L,ap as w,aq as I,b7 as U,as as de,aH as N,ay as R,at as W,aA as T,aG as D,aD as ue,aJ as he}from"./vendor-ui-BecvStzI.js";import"./vendor-chart-hXvGMOW0.js";function O(){return O=Object.assign?Object.assign.bind():function(r){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&(r[i]=s[i])}return r},O.apply(this,arguments)}const pe=(r,t)=>l.createElement(J,O({},r,{ref:t,icon:oe})),K=l.forwardRef(pe);function G(){return G=Object.assign?Object.assign.bind():function(r){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&(r[i]=s[i])}return r},G.apply(this,arguments)}const ge=(r,t)=>l.createElement(J,G({},r,{ref:t,icon:ce})),X=l.forwardRef(ge),fe=({visible:r,onClose:t,onSelect:s})=>{const{token:i}=Y.useToken(),{Text:a}=E,[n,c]=l.useState(!1),[o,y]=l.useState(""),[f,p]=l.useState(),[k,j]=l.useState([]),[b,x]=l.useState([]);l.useEffect(()=>{r&&m()},[r]);const m=async d=>{c(!0);try{const u=await z.browseFolder(d);y(u.current_path),p(u.parent_path),j(u.folders)}catch(u){console.error("Failed to load directory:",u),F.error("Unable to read folder")}finally{c(!1)}},g=d=>{x([...b,o]),m(d.path)},_=()=>{f&&(x(b.slice(0,-1)),m(f))},C=()=>{x([]),m()},v=()=>{s(o),t()},S=()=>{if(!o)return[];const d=o.split(/[/\\]/).filter(Boolean);return o.startsWith("/")&&d.unshift("/"),d},M=d=>{const V=S().slice(0,d+1).join("/"),$=(o.startsWith("/"),V);m($)};return e.jsx(L,{title:"Select Workspace Folder",open:r,onCancel:t,width:700,footer:null,children:e.jsxs(w,{direction:"vertical",size:"middle",style:{width:"100%"},children:[e.jsxs(w,{children:[e.jsx(I,{icon:e.jsx(X,{}),onClick:C,size:"small",children:"Home"}),e.jsx(I,{icon:e.jsx(se,{}),onClick:_,disabled:!f,size:"small",children:"Parent Directory"}),e.jsx(I,{type:"primary",icon:e.jsx(re,{}),onClick:v,size:"small",children:"Select Current Folder"})]}),e.jsx(U,{children:S().map((d,u)=>e.jsx(U.Item,{children:e.jsx(I,{type:"link",size:"small",onClick:()=>M(u),style:{padding:0},children:d==="/"?e.jsx(X,{}):d})},u))}),e.jsxs(de,{size:"small",styles:{body:{padding:i.paddingXS}},children:[e.jsx(a,{type:"secondary",style:{fontSize:12},children:"Current Path:"})," ",e.jsx(a,{code:!0,children:o})]}),e.jsx(N,{spinning:n,children:k.length===0&&!n?e.jsx(R,{image:R.PRESENTED_IMAGE_SIMPLE,description:e.jsx(a,{type:"secondary",children:"This folder is empty"})}):e.jsx(W,{dataSource:k,style:{maxHeight:400,overflowY:"auto"},renderItem:d=>e.jsx(W.Item,{style:{padding:0},children:e.jsx(I,{type:"text",icon:e.jsx(P,{}),onClick:()=>g(d),style:{width:"100%",textAlign:"left",padding:`${i.paddingXS}px ${i.paddingSM}px`},children:d.name})})})}),e.jsx(a,{type:"secondary",style:{fontSize:12},children:'💡 Tip: Click a folder to enter, click "Select Current Folder" to confirm'})]})})};class xe{constructor(t={}){B(this,"cache",new Map);B(this,"pendingValidations",new Map);B(this,"options");this.options={debounceMs:t.debounceMs??300,cacheTimeoutMs:t.cacheTimeoutMs??5*60*1e3,maxRetries:t.maxRetries??3}}async validateWorkspace(t){if(!t||t.trim().length===0)return{path:"",is_valid:!1,error_message:"Path cannot be empty"};const s=t.trim(),i=this.getCachedResult(s);if(i)return i;const a=this.pendingValidations.get(s);if(a)return a;const n=this.performValidation(s);this.pendingValidations.set(s,n);try{const c=await n;return this.setCachedResult(s,c),c}finally{this.pendingValidations.delete(s)}}validateWorkspaceDebounced(t,s){let i;return i=setTimeout(async()=>{try{const n=await this.validateWorkspace(t);s(n)}catch(n){const c={path:t,is_valid:!1,error_message:n instanceof Error?n.message:"Validation failed"};s(c)}},this.options.debounceMs),()=>{clearTimeout(i)}}clearCache(){this.cache.clear()}getCachedResult(t){const s=this.cache.get(t);return s?Date.now()-s.timestamp>this.options.cacheTimeoutMs?(this.cache.delete(t),null):s.result:null}setCachedResult(t,s){this.cache.set(t,{result:s,timestamp:Date.now()})}async performValidation(t,s=0){try{return await ae.post("workspace/validate",{path:t})}catch(i){if(s<this.options.maxRetries&&this.isRetryableError(i))return await this.delay(Math.pow(2,s)*1e3),this.performValidation(t,s+1);throw i}}isRetryableError(t){return t instanceof Error?t.message.includes("Failed to fetch")||t.message.includes("HTTP error! status: 5"):!1}delay(t){return new Promise(s=>setTimeout(s,t))}async validateMultiplePaths(t){const i=[];for(let a=0;a<t.length;a+=5){const n=t.slice(a,a+5),c=await Promise.all(n.map(o=>this.validateWorkspace(o)));i.push(...c),a+5<t.length&&await this.delay(100)}return i}}const me=new xe,ye=({value:r="",onChange:t,showRecentWorkspaces:s,showSuggestions:i,onValidationChange:a})=>{const[n,c]=l.useState(r),[o,y]=l.useState({isValidating:!1,result:null}),[f,p]=l.useState([]),[k,j]=l.useState(!1),[b,x]=l.useState([]),[m,g]=l.useState(!1),[_,C]=l.useState(!1),v=l.useRef(null),S=l.useRef(null);l.useEffect(()=>{c(r)},[r]),l.useEffect(()=>(s&&M(),i&&d(),()=>{v.current&&v.current.abort(),S.current&&S.current()}),[s,i]);const M=l.useCallback(async()=>{g(!0);try{const h=await z.getRecentWorkspaces();p(h.slice(0,5))}catch(h){console.error("Failed to load recent workspaces:",h),p([])}finally{g(!1)}},[]),d=l.useCallback(async()=>{C(!0);try{const h=await z.getPathSuggestions();x(h.suggestions.slice(0,8))}catch(h){console.error("Failed to load suggestions:",h),x([])}finally{C(!1)}},[]),u=l.useCallback(h=>{c(h),t&&t(h),v.current&&v.current.abort(),S.current&&S.current(),h.trim()?(y({isValidating:!0,result:null}),S.current=me.validateWorkspaceDebounced(h.trim(),Z=>{y({isValidating:!1,result:Z}),a&&a(Z)})):(y({isValidating:!1,result:null}),a&&a(null))},[t,a]),V=l.useCallback(()=>{j(!0)},[]),$=l.useCallback(h=>{u(h),F.success("Folder selected successfully")},[u]),Q=l.useCallback(h=>{u(h)},[u]);return{path:n,validationStatus:o,recentWorkspaces:f,suggestions:b,isLoadingRecent:m,isLoadingSuggestions:_,folderBrowserVisible:k,setFolderBrowserVisible:j,handlePathChange:u,handleBrowseClick:V,handleFolderSelect:$,handleWorkspaceSelect:Q}},{Text:A}=E,je=({show:r,isLoading:t,recentWorkspaces:s,onSelect:i,token:a})=>r?e.jsxs(T,{vertical:!0,gap:a.marginXS,style:{marginTop:a.marginMD},children:[e.jsxs(w,{style:{paddingInline:a.paddingSM},children:[e.jsx(K,{}),e.jsx(A,{strong:!0,children:"Recent Workspaces"})]}),t?e.jsx(T,{justify:"center",style:{padding:a.paddingSM},children:e.jsx(N,{size:"small"})}):s.length===0?e.jsx(R,{description:"No recent workspaces",image:R.PRESENTED_IMAGE_SIMPLE,style:{padding:a.paddingSM}}):e.jsx(W,{size:"small",dataSource:s,style:{paddingInline:a.paddingSM},renderItem:n=>e.jsx(W.Item,{style:{padding:0},children:e.jsx(I,{type:"text",onClick:()=>i(n.path),style:{width:"100%",textAlign:"left",padding:`${a.paddingXS}px 0`,height:"auto"},children:e.jsxs(T,{justify:"space-between",align:"center",style:{width:"100%"},children:[e.jsxs(w,{children:[e.jsx(P,{style:{color:a.colorWarning}}),e.jsx(A,{strong:!0,children:n.workspace_name||n.path.split("/").pop()||"Workspace"})]}),e.jsx(A,{type:"secondary",ellipsis:{tooltip:n.path},style:{fontSize:12,maxWidth:"55%",textAlign:"right"},children:n.path})]})})})})]}):null,{Text:H}=E,Se=(r,t)=>{switch(r.suggestion_type){case"home":return e.jsx(X,{style:{color:t.colorPrimary}});case"documents":case"desktop":case"downloads":return e.jsx(P,{style:{color:t.colorSuccess}});case"recent":return e.jsx(K,{style:{color:t.colorWarning}});default:return e.jsx(P,{})}},we=({show:r,isLoading:t,suggestions:s,onSelect:i,token:a})=>r?e.jsxs(T,{vertical:!0,gap:a.marginXS,style:{marginTop:a.marginMD},children:[e.jsxs(w,{style:{paddingInline:a.paddingSM},children:[e.jsx(P,{}),e.jsx(H,{strong:!0,children:"Suggested Workspaces"})]}),t?e.jsx(T,{justify:"center",style:{padding:a.paddingSM},children:e.jsx(N,{size:"small"})}):s.length===0?e.jsx(R,{description:"No suggestions available",image:R.PRESENTED_IMAGE_SIMPLE,style:{padding:a.paddingSM}}):e.jsx(W,{size:"small",dataSource:s,style:{paddingInline:a.paddingSM},renderItem:n=>e.jsx(W.Item,{style:{padding:0},children:e.jsx(I,{type:"text",onClick:()=>i(n.path),style:{width:"100%",textAlign:"left",padding:`${a.paddingXS}px 0`,height:"auto"},children:e.jsxs(T,{justify:"space-between",align:"center",style:{width:"100%"},children:[e.jsxs(w,{children:[Se(n,a),e.jsx(H,{strong:!0,children:n.name})]}),e.jsx(H,{type:"secondary",ellipsis:{tooltip:n.path},style:{fontSize:12,maxWidth:"55%",textAlign:"right"},children:n.path})]})})})})]}):null,ke=({isValidating:r,result:t,token:s})=>r?e.jsx(ie,{style:{color:s.colorPrimary}}):t?t.is_valid?e.jsx(ne,{style:{color:s.colorSuccess}}):e.jsx(le,{style:{color:s.colorError}}):null,{Text:q}=E,be=({result:r,token:t})=>r?e.jsx("div",{style:{marginTop:t.marginXS},children:r.is_valid?e.jsx(D,{type:"success",message:e.jsxs(w,{children:[e.jsx("span",{children:"Valid Workspace"}),r.workspace_name&&e.jsxs(q,{type:"secondary",children:["(",r.workspace_name,")"]}),r.file_count!==void 0&&e.jsxs(q,{type:"secondary",children:["- ",r.file_count," files"]})]}),showIcon:!0}):e.jsx(D,{type:"error",message:r.error_message||"Invalid workspace path",showIcon:!0})}):null,{Text:ve}=E,Ie=({value:r="",onChange:t,placeholder:s="e.g. /Users/alice/Workspace/MyProject",disabled:i=!1,allowBrowse:a=!0,showRecentWorkspaces:n=!0,showSuggestions:c=!0,onValidationChange:o,className:y,style:f})=>{const{token:p}=Y.useToken(),{path:k,validationStatus:j,recentWorkspaces:b,suggestions:x,isLoadingRecent:m,isLoadingSuggestions:g,folderBrowserVisible:_,setFolderBrowserVisible:C,handlePathChange:v,handleBrowseClick:S,handleFolderSelect:M,handleWorkspaceSelect:d}=ye({value:r,onChange:t,showRecentWorkspaces:n,showSuggestions:c,onValidationChange:o});return e.jsxs("div",{className:y,style:f,children:[e.jsx(ue,{value:k,onChange:u=>v(u.target.value),placeholder:s,disabled:i,size:"middle",style:{width:"100%"},suffix:e.jsx(ke,{isValidating:j.isValidating,result:j.result,token:p}),addonBefore:e.jsxs(w,{children:[e.jsx(P,{}),e.jsx(ve,{children:"Workspace"})]}),addonAfter:a?e.jsx(I,{"aria-label":"Browse folder",title:"Browse folder",icon:e.jsx(P,{}),onClick:S,disabled:i,type:"text",size:"middle",style:{display:"inline-flex",alignItems:"center"}}):void 0}),e.jsx(be,{result:j.result,token:p}),(n||c)&&e.jsxs(e.Fragment,{children:[e.jsx(he,{style:{margin:"16px 0 12px 0"}}),e.jsx(je,{show:n,isLoading:m,recentWorkspaces:b,onSelect:d,token:p}),e.jsx(we,{show:c,isLoading:g,suggestions:x,onSelect:d,token:p})]}),e.jsx(fe,{visible:_,onClose:()=>C(!1),onSelect:M})]})},{Title:Pe}=E,_e=({open:r,initialPath:t="",loading:s=!1,onSubmit:i,onCancel:a})=>{const[n,c]=l.useState(t),[o,y]=l.useState(null),[f,p]=l.useState(!1);l.useEffect(()=>{r&&(c(t),y(null))},[r,t]);const k=g=>{c(g)},j=g=>{y(g)},b=async()=>{if(!n.trim()){F.error("Please enter a workspace path");return}o&&!o.is_valid?L.confirm({title:"Invalid Workspace Path",content:e.jsxs("div",{children:[e.jsx("p",{children:"Potential issues detected with the workspace path:"}),e.jsx("p",{children:o.error_message||"Invalid path"}),e.jsx("p",{children:"Do you still want to save this path?"})]}),okText:"Save Anyway",cancelText:"Cancel",onOk:()=>x()}):x()},x=async()=>{p(!0);try{o!=null&&o.is_valid&&await z.addRecentWorkspace(n.trim(),{workspace_name:o.workspace_name}),i(n.trim())}catch(g){console.error("Failed to save workspace path:",g),F.error("Failed to save workspace path")}finally{p(!1)}},m=!n.trim()||s||f;return e.jsx(L,{open:r,title:e.jsx(w,{children:e.jsx(Pe,{level:4,style:{margin:0},children:"Set Workspace Path"})}),okText:"Save",cancelText:"Cancel",onOk:b,onCancel:a,okButtonProps:{disabled:m,loading:f||s},width:600,destroyOnClose:!0,children:e.jsxs(w,{direction:"vertical",size:"middle",style:{width:"100%"},children:[e.jsx(D,{message:"Workspace Path Description",description:e.jsxs("div",{children:[e.jsx("p",{children:"Specify the project root directory associated with the current Chat. The backend will provide file listings based on this directory for @ file references."}),e.jsx("p",{children:"It is recommended to select the root directory containing project source code, such as a Git repository root."})]}),type:"info",showIcon:!0}),e.jsx(Ie,{value:n,onChange:k,onValidationChange:j,placeholder:"e.g. /Users/alice/Workspace/MyProject",disabled:f,allowBrowse:!0,showRecentWorkspaces:!0,showSuggestions:!0}),o&&!o.is_valid&&e.jsx(D,{message:"Workspace Path Check",description:o.error_message||"Path may be invalid, please check if the directory exists and is accessible",type:"warning",showIcon:!0})]})})};export{_e as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as o,R as d}from"./core-Cfh-QHsP.js";var u;(function(n){n[n.Audio=1]="Audio",n[n.Cache=2]="Cache",n[n.Config=3]="Config",n[n.Data=4]="Data",n[n.LocalData=5]="LocalData",n[n.Document=6]="Document",n[n.Download=7]="Download",n[n.Picture=8]="Picture",n[n.Public=9]="Public",n[n.Video=10]="Video",n[n.Resource=11]="Resource",n[n.Temp=12]="Temp",n[n.AppConfig=13]="AppConfig",n[n.AppData=14]="AppData",n[n.AppLocalData=15]="AppLocalData",n[n.AppCache=16]="AppCache",n[n.AppLog=17]="AppLog",n[n.Desktop=18]="Desktop",n[n.Executable=19]="Executable",n[n.Font=20]="Font",n[n.Home=21]="Home",n[n.Runtime=22]="Runtime",n[n.Template=23]="Template"})(u||(u={}));var f;(function(n){n[n.Start=0]="Start",n[n.Current=1]="Current",n[n.End=2]="End"})(f||(f={}));function p(n){return{isFile:n.isFile,isDirectory:n.isDirectory,isSymlink:n.isSymlink,size:n.size,mtime:n.mtime!==null?new Date(n.mtime):null,atime:n.atime!==null?new Date(n.atime):null,birthtime:n.birthtime!==null?new Date(n.birthtime):null,readonly:n.readonly,fileAttributes:n.fileAttributes,dev:n.dev,ino:n.ino,mode:n.mode,nlink:n.nlink,uid:n.uid,gid:n.gid,rdev:n.rdev,blksize:n.blksize,blocks:n.blocks}}function w(n){const t=new Uint8ClampedArray(n),i=t.byteLength;let e=0;for(let l=0;l<i;l++){const a=t[l];e*=256,e+=a}return e}class m extends d{async read(t){if(t.byteLength===0)return 0;const i=await o("plugin:fs|read",{rid:this.rid,len:t.byteLength}),e=w(i.slice(-8)),l=i instanceof ArrayBuffer?new Uint8Array(i):i;return t.set(l.slice(0,l.length-8)),e===0?null:e}async seek(t,i){return await o("plugin:fs|seek",{rid:this.rid,offset:t,whence:i})}async stat(){const t=await o("plugin:fs|fstat",{rid:this.rid});return p(t)}async truncate(t){await o("plugin:fs|ftruncate",{rid:this.rid,len:t})}async write(t){return await o("plugin:fs|write",{rid:this.rid,data:t})}}async function c(n,t){if(n instanceof URL&&n.protocol!=="file:")throw new TypeError("Must be a file URL.");const i=await o("plugin:fs|open",{path:n instanceof URL?n.toString():n,options:t});return new m(i)}async function b(n,t,i){if(n instanceof URL&&n.protocol!=="file:")throw new TypeError("Must be a file URL.");if(t instanceof ReadableStream){const e=await c(n,i),l=t.getReader();try{for(;;){const{done:a,value:s}=await l.read();if(a)break;await e.write(s)}}finally{l.releaseLock(),await e.close()}}else await o("plugin:fs|write_file",t,{headers:{path:encodeURIComponent(n instanceof URL?n.toString():n),options:JSON.stringify(i)}})}async function L(n,t,i){if(n instanceof URL&&n.protocol!=="file:")throw new TypeError("Must be a file URL.");const e=new TextEncoder;await o("plugin:fs|write_text_file",e.encode(t),{headers:{path:encodeURIComponent(n instanceof URL?n.toString():n),options:JSON.stringify(i)}})}export{u as BaseDirectory,m as FileHandle,f as SeekMode,c as open,b as writeFile,L as writeTextFile};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as l,m as s}from"./vendor-react-BK4ieJpD.js";import{C as v,p as E}from"./main-D-vCV98n.js";import{aH as $,az as B,av as L}from"./vendor-ui-BecvStzI.js";import"./vendor-chart-hXvGMOW0.js";const M=({visible:i,searchText:w,onSelect:j,onCancel:g,onAutoComplete:f})=>{const[o,k]=l.useState([]),[n,N]=l.useState([]),[c,d]=l.useState(0),[R,I]=l.useState(!1),y=l.useRef(null),t=l.useRef(null);l.useEffect(()=>{if(!i)return;const a=v.getInstance();(async()=>{I(!0);try{const r=await a.listCommands();console.log("[CommandSelector] Fetched commands:",r),k(r),d(0)}catch(r){console.error("[CommandSelector] Failed to fetch commands:",r),k([])}finally{I(!1)}})()},[i]),l.useEffect(()=>{const a=o.filter(e=>{var u,S,x,b,h;const r=w.toLowerCase(),p=(e.displayName??"").toLowerCase();return e.name.toLowerCase().includes(r)||p.includes(r)||e.description.toLowerCase().includes(r)||e.type==="mcp"&&[(u=e.metadata)==null?void 0:u.serverId,(S=e.metadata)==null?void 0:S.serverName,(x=e.metadata)==null?void 0:x.originalName].filter(C=>typeof C=="string").some(C=>C.toLowerCase().includes(r))||(((b=e.category)==null?void 0:b.toLowerCase().includes(r))??!1)||(((h=e.tags)==null?void 0:h.some(C=>C.toLowerCase().includes(r)))??!1)});N(a),d(0)},[o,w]),l.useEffect(()=>{if(!t.current||!y.current)return;const a=y.current,e=t.current,r=a.getBoundingClientRect(),p=e.getBoundingClientRect();p.top<r.top?e.scrollIntoView({block:"start",behavior:"smooth"}):p.bottom>r.bottom&&e.scrollIntoView({block:"end",behavior:"smooth"})},[c,n]);const m=async a=>{try{j({name:a.name,type:a.type,id:a.id})}catch(e){console.error(`[CommandSelector] Failed to select command '${a.name}':`,e)}};return l.useEffect(()=>{const a=e=>{if(i)switch(e.key){case"ArrowDown":case"n":if(e.key==="n"&&!e.ctrlKey)break;e.preventDefault(),e.stopPropagation(),d(r=>r<n.length-1?r+1:0);break;case"ArrowUp":case"p":if(e.key==="p"&&!e.ctrlKey)break;e.preventDefault(),e.stopPropagation(),d(r=>r>0?r-1:n.length-1);break;case"Enter":e.preventDefault(),e.stopPropagation(),n[c]&&m(n[c]);break;case" ":case"Tab":e.preventDefault(),e.stopPropagation(),n[c]&&f&&f(n[c].name);break;case"Escape":e.preventDefault(),e.stopPropagation(),g();break}};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[i,n,c,g,f]),{containerRef:y,selectedItemRef:t,filteredCommands:n,selectedIndex:c,setSelectedIndex:d,isLoading:R,handleCommandSelect:m}},{useToken:T}=B,D={workflow:{color:"blue",icon:"📁",label:"Workflow"},skill:{color:"green",icon:"⚡",label:"Skill"},mcp:{color:"purple",icon:"🔌",label:"MCP"}},A=({visible:i,onSelect:w,onCancel:j,searchText:g,onAutoComplete:f})=>{const{token:o}=T(),{containerRef:k,selectedItemRef:n,filteredCommands:N,selectedIndex:c,setSelectedIndex:d,isLoading:R,handleCommandSelect:I}=M({visible:i,searchText:g,onSelect:w,onCancel:j,onAutoComplete:f});if(!i)return null;if(R)return s.jsxs("div",{style:{position:"absolute",bottom:"100%",left:0,right:0,background:o.colorBgContainer,border:`1px solid ${o.colorBorderSecondary}`,borderRadius:o.borderRadiusSM,boxShadow:o.boxShadowSecondary,padding:`${o.paddingSM}px ${o.paddingMD}px`,zIndex:1e3,marginBottom:o.marginXS,textAlign:"center"},children:[s.jsx($,{size:"small"})," Loading commands..."]});if(N.length===0)return s.jsx("div",{style:{position:"absolute",bottom:"100%",left:0,right:0,background:o.colorBgContainer,border:`1px solid ${o.colorBorderSecondary}`,borderRadius:o.borderRadiusSM,boxShadow:o.boxShadowSecondary,padding:`${o.paddingSM}px ${o.paddingMD}px`,zIndex:1e3,marginBottom:o.marginXS,textAlign:"center",color:o.colorTextSecondary},children:g?`No commands found matching "${g}"`:"No commands available."});const y=(t,m)=>{var S,x,b;const a=D[t.type],e=m===c,r=t.type==="mcp"?E(t.name):null,p=t.type==="mcp"?((S=t.metadata)==null?void 0:S.originalName)||(r==null?void 0:r.toolName)||t.displayName||t.name:null,u=t.type==="mcp"&&(((x=t.metadata)==null?void 0:x.serverName)||((b=t.metadata)==null?void 0:b.serverId)||(r==null?void 0:r.serverId))||null;return s.jsxs("div",{ref:e?n:null,className:`command-selector-item ${e?"selected":""}`,onClick:()=>I(t),onMouseEnter:()=>d(m),children:[s.jsxs("div",{className:"command-selector-item-header",children:[s.jsxs("div",{className:"command-selector-item-name",style:{color:o.colorPrimary},children:["/",t.type==="mcp"&&p?p:t.name]}),s.jsxs("div",{style:{display:"flex",gap:o.marginXS},children:[t.type==="mcp"&&u&&s.jsx(L,{color:"geekblue",children:u}),s.jsxs(L,{color:a.color,children:[a.icon," ",a.label]})]})]}),s.jsx("div",{className:"command-selector-item-description",style:{color:o.colorTextSecondary},children:t.description}),t.type==="mcp"&&u&&s.jsxs("div",{className:"command-selector-item-category",style:{color:o.colorTextTertiary},children:["Server: ",u]}),t.category&&s.jsxs("div",{className:"command-selector-item-category",style:{color:o.colorTextTertiary},children:["Category: ",t.category]}),t.tags&&t.tags.length>0&&s.jsx("div",{className:"command-selector-item-tags",children:t.tags.slice(0,3).map(h=>s.jsx(L,{children:h},h))})]},t.id)};return s.jsxs("div",{ref:k,className:"command-selector-container",style:{background:o.colorBgContainer,border:`1px solid ${o.colorBorderSecondary}`,borderRadius:o.borderRadiusSM,boxShadow:o.boxShadowSecondary},children:[s.jsx("div",{style:{padding:`${o.paddingXXS}px ${o.paddingSM}px`,borderBottom:`1px solid ${o.colorBorderSecondary}`,background:o.colorFillQuaternary,fontSize:o.fontSizeSM,color:o.colorTextTertiary},children:"Navigation: Up/Down or Ctrl+P/N | Select: Enter | Complete: Space/Tab | Cancel: Esc"}),N.map((t,m)=>y(t,m))]})};export{A as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as i,m as e}from"./vendor-react-BK4ieJpD.js";import{as as R,aG as I,ay as S,at as w,ap as m,ar as z,aq as k,aH as D,az as b}from"./vendor-ui-BecvStzI.js";import{g as X,d as C,l as L}from"./main-D-vCV98n.js";import"./vendor-chart-hXvGMOW0.js";const{Text:y}=z,{useToken:M}=b,_=({visible:a,files:d,searchText:l,loading:x,error:h,onSelect:c,onCancel:f,onChangeWorkspace:g})=>{const{token:s}=M(),[n,u]=i.useState(0),E=i.useRef(null),j=i.useRef(null),o=i.useMemo(()=>{const t=l.trim().toLowerCase();return t?d.filter(r=>r.name.toLowerCase().startsWith(t)):d},[d,l]);return i.useEffect(()=>{u(0)},[l,d]),i.useEffect(()=>{if(!a)return;const t=r=>{a&&(r.key==="ArrowDown"||r.key==="n"&&r.ctrlKey?(r.preventDefault(),u(p=>o.length===0?0:(p+1)%o.length)):r.key==="ArrowUp"||r.key==="p"&&r.ctrlKey?(r.preventDefault(),u(p=>o.length===0?0:(p-1+o.length)%o.length)):r.key==="Enter"||r.key==="Tab"?o[n]&&(r.preventDefault(),c(o[n])):r.key==="Escape"&&(r.preventDefault(),f()))};return window.addEventListener("keydown",t),()=>{window.removeEventListener("keydown",t)}},[a,o,n,c,f]),i.useEffect(()=>{if(!a)return;const t=j.current;t&&t.scrollIntoView({block:"nearest"})},[n,a]),a?e.jsx("div",{style:{position:"absolute",bottom:"100%",left:0,right:0,zIndex:1e3,marginBottom:s.marginXS},children:e.jsx(R,{size:"small",style:{borderRadius:s.borderRadius,border:`1px solid ${s.colorBorderSecondary}`,boxShadow:s.boxShadowSecondary},bodyStyle:{padding:s.paddingXS,maxHeight:240,overflowY:"auto"},title:e.jsxs(m,{align:"center",size:s.marginXS,children:[e.jsx(y,{strong:!0,children:"@ File Reference"}),x&&e.jsx(D,{size:"small"})]}),extra:e.jsxs(m,{size:s.marginXS,children:[g&&e.jsx(k,{type:"text",size:"small",icon:e.jsx(L,{}),onClick:g,children:"Set Workspace"}),e.jsx(k,{type:"text",size:"small",onClick:f,children:"Close"})]}),children:h?e.jsx(I,{type:"error",message:h,showIcon:!0}):o.length===0&&!x?e.jsx(S,{image:S.PRESENTED_IMAGE_SIMPLE,description:l?"No matching files found":"Directory is empty"}):e.jsx("div",{ref:E,children:e.jsx(w,{dataSource:o,renderItem:(t,r)=>e.jsx(w.Item,{onMouseEnter:()=>u(r),onClick:()=>c(t),ref:r===n?j:void 0,style:{cursor:"pointer",backgroundColor:r===n?s.colorPrimaryBg:"transparent",borderRadius:s.borderRadiusSM,padding:`${s.paddingXXS}px ${s.paddingXS}px`},children:e.jsxs(m,{size:s.marginXS,align:"center",children:[t.is_directory?e.jsx(X,{}):e.jsx(C,{}),e.jsxs("div",{children:[e.jsx(y,{children:t.name}),e.jsx("div",{children:e.jsx(y,{type:"secondary",style:{fontSize:s.fontSizeSM},children:t.is_directory?"Directory":"File"})})]})]})},t.path)})})})}):null};export{_ as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as y,m as t}from"./vendor-react-BK4ieJpD.js";import{u as a,R as w,a as F,b as M}from"./main-D-vCV98n.js";import{aO as s,aq as i,at as c,av as b,aM as v,ax as C,aD as m,aw as r}from"./vendor-ui-BecvStzI.js";import"./vendor-chart-hXvGMOW0.js";const R=()=>{const h=a(e=>e.systemPrompts),f=a(e=>e.addSystemPrompt),P=a(e=>e.updateSystemPrompt),j=a(e=>e.deleteSystemPrompt),[g,d]=y.useState(!1),[n,p]=y.useState(null),[o]=s.useForm(),u=(e=null)=>{p(e),o.setFieldsValue(e||{name:"",description:"",content:""}),d(!0)},x=()=>{d(!1),p(null),o.resetFields()},S=async()=>{try{const e=await o.validateFields();n?(await P({...n,...e}),r.success("Prompt updated successfully")):(await f(e),r.success("Prompt added successfully")),x()}catch(e){console.error("Failed to save prompt:",e),r.error(e instanceof Error?e.message:"Failed to save prompt. Please try again.")}},I=async e=>{try{await j(e),r.success("Prompt deleted successfully")}catch(l){console.error("Failed to delete prompt:",l),r.error(l instanceof Error?l.message:"Failed to delete prompt. Please try again.")}};return t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[t.jsx("h2",{children:"System Prompt Management"}),t.jsx(i,{type:"primary",icon:t.jsx(w,{}),onClick:()=>u(),children:"Add Prompt"})]}),t.jsx(c,{itemLayout:"horizontal",dataSource:h,renderItem:e=>t.jsxs(c.Item,{actions:[t.jsx(i,{type:"text",icon:t.jsx(F,{}),onClick:()=>u(e)}),e.isDefault?null:t.jsx(v,{title:"Are you sure to delete this prompt?",onConfirm:()=>I(e.id),okText:"Yes",cancelText:"No",children:t.jsx(i,{type:"text",danger:!0,icon:t.jsx(M,{})})})],children:[t.jsx(c.Item.Meta,{title:e.name,description:e.description||e.content.substring(0,200)+(e.content.length>200?"...":"")}),e.isDefault&&t.jsx(b,{children:"Default"})]})}),t.jsx(C,{title:n?"Edit System Prompt":"Add New System Prompt",open:g,onOk:S,onCancel:x,width:"60%",children:t.jsxs(s,{form:o,layout:"vertical",name:"system_prompt_form",children:[t.jsx(s.Item,{name:"name",label:"Prompt Name",rules:[{required:!0,message:"Please input the name of the prompt!"}],children:t.jsx(m,{})}),t.jsx(s.Item,{name:"description",label:"Prompt Description",rules:[{required:!1,message:"Please input the description of the prompt!"}],children:t.jsx(m.TextArea,{rows:3})}),t.jsx(s.Item,{name:"content",label:"Prompt Content",rules:[{required:!0,message:"Please input the content of the prompt!"}],children:t.jsx(m.TextArea,{rows:10})})]})})]})};export{R as default};
|