maestro-agent 0.0.1 → 0.0.3
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 +316 -2
- package/bin/maestro.ts +5 -0
- package/dist/maestro +0 -0
- package/dist/web/apple-touch-icon.png +0 -0
- package/dist/web/assets/Connections-BMA04Ycg.js +11 -0
- package/dist/web/assets/GanttView-DXjh0gxg.js +49 -0
- package/dist/web/assets/Home-Ct3Ho0Qt.js +1 -0
- package/dist/web/assets/HooksCrons--0kyVJcR.js +11 -0
- package/dist/web/assets/ProjectDetail-B_IqEpFu.js +1 -0
- package/dist/web/assets/Roles-D1tIQzto.js +24 -0
- package/dist/web/assets/Settings-yts4LUmH.js +11 -0
- package/dist/web/assets/Skills-DbuNLjIV.js +12 -0
- package/dist/web/assets/Wizard-vJol8-Y4.js +11 -0
- package/dist/web/assets/WorkspaceChat-DrsLs4m2.js +56 -0
- package/dist/web/assets/WorkspaceDashboard-B9vgrd2Z.js +6 -0
- package/dist/web/assets/WorkspaceNew-DoNGYHCG.js +1 -0
- package/dist/web/assets/WorkspaceProjects-DDp3mUse.js +6 -0
- package/dist/web/assets/WorkspaceSchedules-BTjmCbYG.js +1 -0
- package/dist/web/assets/WorkspaceTasks-mPU-bhKR.js +41 -0
- package/dist/web/assets/activity-CIA8bIA4.js +6 -0
- package/dist/web/assets/addon-fit-BlxrFPDK.js +1 -0
- package/dist/web/assets/arrow-right-S7ID7nDp.js +6 -0
- package/dist/web/assets/badge-DDTUzWIi.js +1 -0
- package/dist/web/assets/circle-check-B3P1qK0Z.js +6 -0
- package/dist/web/assets/clock-f9aYZox0.js +6 -0
- package/dist/web/assets/index-BRo4Du_s.js +11 -0
- package/dist/web/assets/index-C7kx39S9.js +196 -0
- package/dist/web/assets/index-D6LSdZea.css +1 -0
- package/dist/web/assets/plus-BHnOxbns.js +6 -0
- package/dist/web/assets/refresh-cw-BWX04Hg3.js +6 -0
- package/dist/web/assets/save-BLbb_9xz.js +6 -0
- package/dist/web/assets/sparkles-CDr6Dw1e.js +6 -0
- package/dist/web/assets/trash-2-9-ThEdey.js +6 -0
- package/dist/web/assets/useEventStream-DXt2Hmei.js +1 -0
- package/dist/web/assets/x-DVdKPXXy.js +6 -0
- package/dist/web/assets/xterm-DYP7pi_n.css +32 -0
- package/dist/web/assets/xterm-DlVFs1Kw.js +9 -0
- package/dist/web/favicon-512.png +0 -0
- package/dist/web/favicon.png +0 -0
- package/dist/web/index.html +15 -0
- package/package.json +49 -6
- package/src/api/agents.ts +76 -0
- package/src/api/audit.ts +19 -0
- package/src/api/autopilot.ts +73 -0
- package/src/api/chat.ts +801 -0
- package/src/api/chief.ts +84 -0
- package/src/api/config.ts +39 -0
- package/src/api/gantt.ts +72 -0
- package/src/api/hooks.ts +54 -0
- package/src/api/inbox.ts +125 -0
- package/src/api/lark.ts +32 -0
- package/src/api/memory.ts +37 -0
- package/src/api/ops.ts +89 -0
- package/src/api/projects.ts +105 -0
- package/src/api/roles.ts +123 -0
- package/src/api/runtimes.ts +62 -0
- package/src/api/scheduled-tasks.ts +203 -0
- package/src/api/sessions.ts +479 -0
- package/src/api/skills.ts +386 -0
- package/src/api/tasks.ts +457 -0
- package/src/api/telegram.ts +94 -0
- package/src/api/templates.ts +36 -0
- package/src/api/webhooks.ts +20 -0
- package/src/api/workspaces.ts +150 -0
- package/src/bridges/lark/index.ts +213 -0
- package/src/bridges/telegram/index.ts +273 -0
- package/src/bridges/telegram/polling.ts +185 -0
- package/src/chat/index.ts +86 -0
- package/src/chief/index.ts +461 -0
- package/src/core/cli.ts +333 -0
- package/src/core/db.ts +53 -0
- package/src/core/event-bus.ts +33 -0
- package/src/core/index.ts +6 -0
- package/src/core/migrations.ts +303 -0
- package/src/core/router.ts +69 -0
- package/src/core/schema.sql +232 -0
- package/src/core/server.ts +308 -0
- package/src/core/validate.ts +22 -0
- package/src/discovery/index.ts +194 -0
- package/src/gateway/adapters/telegram.ts +148 -0
- package/src/gateway/index.ts +31 -0
- package/src/gateway/manager.ts +176 -0
- package/src/gateway/types.ts +77 -0
- package/src/inbox/index.ts +500 -0
- package/src/ops/artifact-sync.ts +65 -0
- package/src/ops/autopilot.ts +338 -0
- package/src/ops/gc.ts +252 -0
- package/src/ops/index.ts +226 -0
- package/src/ops/project-serial.ts +52 -0
- package/src/ops/role-dispatch.ts +111 -0
- package/src/ops/runtime-scheduler.ts +447 -0
- package/src/ops/task-blocking.ts +65 -0
- package/src/ops/task-deps.ts +37 -0
- package/src/ops/task-workspace.ts +60 -0
- package/src/roles/index.ts +258 -0
- package/src/roles/prompt-assembler.ts +85 -0
- package/src/roles/workspace-role.ts +155 -0
- package/src/scheduler/index.ts +461 -0
- package/src/session/output-parser.ts +75 -0
- package/src/session/realtime-parser.ts +40 -0
- package/src/skills/builtin.ts +155 -0
- package/src/skills/skill-extractor.ts +452 -0
- package/src/skills/skill-md.ts +282 -0
- package/src/transport/http-api.ts +75 -0
- package/src/transport/index.ts +4 -0
- package/src/transport/local-pty.ts +119 -0
- package/src/transport/ssh.ts +176 -0
- package/src/transport/types.ts +20 -0
- package/src/workflows/index.ts +231 -0
- package/index.js +0 -1
- package/maestro-agent-0.0.1.tgz +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{L as n,z as o,s as l,v as e}from"./index-C7kx39S9.js";const r="maestro_last_workspace";function i(){const s=n();return o.useEffect(()=>{l("/workspaces").then(a=>{if(a.length===0){s("/workspaces/new",{replace:!0});return}const t=localStorage.getItem(r);t&&a.some(c=>c.id===t)?s(`/space/${t}/dashboard`,{replace:!0}):(localStorage.setItem(r,a[0].id),s(`/space/${a[0].id}/dashboard`,{replace:!0}))}).catch(()=>{})},[s]),e.jsx("div",{className:"flex items-center justify-center h-screen bg-[hsl(var(--background))]",children:e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-[hsl(var(--primary))] animate-pulse"}),e.jsx("span",{className:"font-mono text-xs font-bold tracking-widest text-[hsl(var(--foreground))]",children:"MAESTRO"})]}),e.jsx("p",{className:"text-xs text-[hsl(var(--muted-foreground))]",children:"加载工作区..."})]})})}export{i as default};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{q as d,z as s,v as e,i as p,Z as u,s as f,x as v,r as g}from"./index-C7kx39S9.js";import{P as b}from"./plus-BHnOxbns.js";import{T as j}from"./trash-2-9-ThEdey.js";/**
|
|
2
|
+
* @license lucide-react v1.16.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 N=[["circle",{cx:"9",cy:"12",r:"3",key:"u3jwor"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],y=d("toggle-left",N);/**
|
|
7
|
+
* @license lucide-react v1.16.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 k=[["circle",{cx:"15",cy:"12",r:"3",key:"1afu0r"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],w=d("toggle-right",k);function E(){const[c,x]=s.useState([]),[n,a]=s.useState(""),[C,l]=s.useState(!1),r=()=>f("/hooks").then(x).catch(t=>a(t.message));s.useEffect(()=>{r()},[]);const i=(t,o)=>v(`/hooks/${t}`,{enabled:o?0:1}).then(r).catch(h=>a(h.message)),m=t=>g(`/hooks/${t}`).then(r).catch(o=>a(o.message));return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsxs("div",{className:"h-[52px] border-b border-[var(--border)] flex items-center justify-between px-6 shrink-0 bg-[var(--surface)/0.92] backdrop-blur-xl",children:[e.jsx("h1",{className:"text-lg font-semibold tracking-tight",children:"Webhooks"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-[var(--muted)] font-mono",children:"定时任务已移至 Tasks → Schedules"}),e.jsxs("button",{onClick:()=>l(!0),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-[var(--accent)] text-white text-xs font-medium hover:opacity-90 transition-opacity",children:[e.jsx(b,{className:"w-3.5 h-3.5"}),"新建 Hook"]})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[n&&e.jsx("div",{className:"p-3 rounded-lg bg-[var(--danger-soft)] border border-[var(--danger)]/20 text-sm text-[var(--danger)] mb-4",children:n}),c.length===0?e.jsxs("div",{className:"bg-[var(--surface)] border border-[var(--border)] rounded-xl p-12 text-center",children:[e.jsx(p,{className:"w-10 h-10 text-[var(--muted)] mx-auto mb-3 opacity-40"}),e.jsx("p",{className:"text-sm text-[var(--muted)]",children:"暂无 Webhook 绑定"}),e.jsx("p",{className:"text-xs text-[var(--muted)] mt-1",children:"Webhook 在特定事件发生时触发任务或动作"})]}):e.jsx("div",{className:"bg-[var(--surface)] border border-[var(--border)] rounded-xl overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-[var(--border)]",children:[e.jsx("th",{className:"text-left px-4 py-2.5 text-[11px] font-mono uppercase tracking-wider text-[var(--muted)] font-medium",children:"Scope"}),e.jsx("th",{className:"text-left px-4 py-2.5 text-[11px] font-mono uppercase tracking-wider text-[var(--muted)] font-medium",children:"事件"}),e.jsx("th",{className:"text-left px-4 py-2.5 text-[11px] font-mono uppercase tracking-wider text-[var(--muted)] font-medium",children:"条件"}),e.jsx("th",{className:"text-left px-4 py-2.5 text-[11px] font-mono uppercase tracking-wider text-[var(--muted)] font-medium",children:"动作"}),e.jsx("th",{className:"text-left px-4 py-2.5 text-[11px] font-mono uppercase tracking-wider text-[var(--muted)] font-medium",children:"状态"}),e.jsx("th",{className:"w-[80px]"})]})}),e.jsx("tbody",{className:"divide-y divide-[var(--border)]",children:c.map(t=>e.jsxs("tr",{className:"hover:bg-[var(--fg-soft)] transition-colors",children:[e.jsxs("td",{className:"px-4 py-3 text-xs font-mono text-[var(--muted)]",children:[t.scope,":",t.scope_id.slice(0,8)]}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded text-[11px] font-mono bg-[var(--info-soft)] text-[var(--info)]",children:[e.jsx(u,{className:"w-3 h-3"}),t.event||"—"]})}),e.jsx("td",{className:"px-4 py-3 text-xs text-[var(--muted)]",children:t.when_expr||"—"}),e.jsx("td",{className:"px-4 py-3 text-xs max-w-[300px] truncate font-mono",children:t.action}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("button",{onClick:()=>i(t.id,t.enabled),className:"inline-flex items-center gap-1 text-[11px] font-medium cursor-pointer hover:opacity-70 transition-opacity",style:{color:t.enabled?"var(--accent)":"var(--muted)"},children:[t.enabled?e.jsx(w,{className:"w-4 h-4"}):e.jsx(y,{className:"w-4 h-4"}),t.enabled?"启用":"禁用"]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("button",{onClick:()=>m(t.id),className:"p-1.5 rounded hover:bg-[var(--danger-soft)] text-[var(--muted)] hover:text-[var(--danger)] transition-colors",children:e.jsx(j,{className:"w-3.5 h-3.5"})})})]},t.id))})]})})]})]})}export{E as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{N as E,L as $,z as a,v as e,s as i,w as P}from"./index-C7kx39S9.js";import{G as _}from"./GanttView-DXjh0gxg.js";import{u as T}from"./useEventStream-DXt2Hmei.js";function z(){const{id:s}=E(),g=$(),[o,c]=a.useState(null),[m,j]=a.useState([]),[N,k]=a.useState([]),[u,x]=a.useState(""),[h,n]=a.useState(""),[y,f]=a.useState(!1),[d,p]=a.useState("board"),{lastEvent:v}=T("task.*,session.*"),l=a.useRef(null),b=()=>{s&&Promise.all([i(`/projects/${s}`),i(`/tasks?project_id=${s}`),i(`/tasks/workflow/statuses?project_id=${s}`)]).then(([r,t,C])=>{c(r),n(r.workdir||""),j(t),k(C)}).catch(r=>x(r.message))};a.useEffect(()=>{b()},[s]),a.useEffect(()=>{if(v)return l.current&&clearTimeout(l.current),l.current=setTimeout(b,300),()=>{l.current&&clearTimeout(l.current)}},[v,s]);const w=()=>{s&&(f(!0),P(`/projects/${s}`,{workdir:h.trim()||null}).then(r=>{c(r),n(r.workdir||"")}).catch(r=>x(r.message)).finally(()=>f(!1)))},S=r=>r==="completed"||r==="done"?"pill-success":r==="in_progress"||r==="active"?"pill-info":r==="blocked"?"pill-danger":"pill-neutral";return u?e.jsx("div",{className:"p-4",children:e.jsx("div",{className:"rounded-md border border-red-300 bg-red-50 dark:bg-red-950/20 dark:border-red-800 px-4 py-3 text-sm text-red-700 dark:text-red-400",children:u})}):o?e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsxs("div",{className:"h-[52px] border-b border-[hsl(var(--border))] flex items-center justify-between px-6 bg-[hsl(var(--card)/0.92)] backdrop-blur-xl sticky top-0 z-5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:()=>g(-1),className:"text-sm text-[hsl(var(--muted-foreground))] hover:text-[hsl(var(--foreground))] transition-colors",children:"←"}),e.jsx("h1",{className:"text-base font-semibold tracking-tight truncate",children:o.name}),e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-mono font-medium ${S(o.status)}`,children:o.status})]}),e.jsx("span",{className:"font-mono tabular-nums text-xs text-[hsl(var(--muted-foreground))]",children:o.id.slice(0,8)})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-4",children:[e.jsxs("div",{className:"rounded-lg border border-[hsl(var(--border))] bg-[hsl(var(--card))] p-4",children:[e.jsx("label",{className:"text-sm font-medium text-[hsl(var(--muted-foreground))]",children:"Project workdir"}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx("input",{value:h,onChange:r=>n(r.target.value),placeholder:"Use agent workspace",className:"flex-1 border border-[hsl(var(--border))] rounded-md px-3 py-2 bg-[hsl(var(--card))] text-sm focus:outline-none focus:ring-1 focus:ring-[hsl(var(--primary))]"}),e.jsx("button",{onClick:w,disabled:y,className:"bg-[hsl(var(--primary))] text-white rounded-md px-4 py-2 text-sm font-medium hover:opacity-90 disabled:opacity-50",children:"Save"})]})]}),e.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[e.jsxs("div",{className:"flex gap-1 border-b border-[hsl(var(--border))] mb-4",children:[e.jsx("button",{onClick:()=>p("board"),className:`px-3 py-2 text-sm font-medium border-b-2 transition-colors ${d==="board"?"border-[hsl(var(--primary))] text-[hsl(var(--foreground))]":"border-transparent text-[hsl(var(--muted-foreground))] hover:text-[hsl(var(--foreground))]"}`,children:"Board"}),e.jsx("button",{onClick:()=>p("gantt"),className:`px-3 py-2 text-sm font-medium border-b-2 transition-colors ${d==="gantt"?"border-[hsl(var(--primary))] text-[hsl(var(--foreground))]":"border-transparent text-[hsl(var(--muted-foreground))] hover:text-[hsl(var(--foreground))]"}`,children:"Gantt"})]}),d==="board"&&e.jsx("div",{className:"grid gap-4",style:{gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))"},children:N.map(r=>e.jsxs("section",{className:"bg-[hsl(var(--muted))] rounded-lg border border-[hsl(var(--border))] p-3",children:[e.jsx("h2",{className:"font-semibold text-sm uppercase tracking-wide text-[hsl(var(--muted-foreground))] mb-3",children:r.label||r.id}),e.jsxs("div",{className:"space-y-2",children:[m.filter(t=>t.status===r.id).map(t=>e.jsxs("div",{className:"rounded-lg border border-[hsl(var(--border))] bg-[hsl(var(--card))] p-3",children:[e.jsx("div",{className:"font-medium text-sm",children:t.title}),e.jsxs("div",{className:"flex items-center justify-between mt-1",children:[e.jsx("span",{className:"text-xs text-[hsl(var(--muted-foreground))]",children:t.assignee_agent_id||"unassigned"}),e.jsx("span",{className:"font-mono tabular-nums text-[10px] text-[hsl(var(--muted-foreground))]",children:t.id.slice(0,6)})]})]},t.id)),m.filter(t=>t.status===r.id).length===0&&e.jsx("p",{className:"text-xs text-[hsl(var(--muted-foreground))]",children:"No tasks"})]})]},r.id))}),d==="gantt"&&e.jsx("div",{className:"flex-1 min-h-0",style:{minHeight:"400px"},children:s&&o&&e.jsx(_,{workspaceId:o.workspace_id,projectFilter:s})})]})]})]}):e.jsx("p",{className:"p-6 text-sm text-[hsl(var(--muted-foreground))]",children:"Loading..."})}export{z as default};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BRo4Du_s.js","assets/index-C7kx39S9.js","assets/index-D6LSdZea.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{q as b,N as Z,z as t,v as e,U as ee,C as se,s as v,x as U,y as re,_ as te}from"./index-C7kx39S9.js";import{u as ae}from"./useEventStream-DXt2Hmei.js";import{R as ne}from"./refresh-cw-BWX04Hg3.js";import{P as oe}from"./plus-BHnOxbns.js";import{S as le}from"./save-BLbb_9xz.js";/**
|
|
3
|
+
* @license lucide-react v1.16.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 de=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],ie=b("chevron-right",de);/**
|
|
8
|
+
* @license lucide-react v1.16.0 - ISC
|
|
9
|
+
*
|
|
10
|
+
* This source code is licensed under the ISC license.
|
|
11
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
12
|
+
*/const ce=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],me=b("eye-off",ce);/**
|
|
13
|
+
* @license lucide-react v1.16.0 - ISC
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the ISC license.
|
|
16
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/const ue=[["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"}]],he=b("eye",ue);/**
|
|
18
|
+
* @license lucide-react v1.16.0 - ISC
|
|
19
|
+
*
|
|
20
|
+
* This source code is licensed under the ISC license.
|
|
21
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
22
|
+
*/const xe=[["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"}]],pe=b("shield",xe),fe=t.lazy(()=>te(()=>import("./index-BRo4Du_s.js"),__vite__mapDeps([0,1,2])));function ge(o){const m=o.match(/^---\s*\n([\s\S]*?)\n---/);if(!m)return null;const d=m[1].match(/^extends:\s*(.+)$/m);return d?d[1].trim():null}const ve={chief:"hsl(var(--warning))",engineer:"hsl(var(--info))",critic:"hsl(var(--destructive))",researcher:"hsl(var(--purple))",writer:"hsl(var(--success))"};function ke(){const{id:o}=Z(),[m,_]=t.useState([]),[d,V]=t.useState([]),[J,T]=t.useState([]),[S,i]=t.useState(""),[l,x]=t.useState(null),[N,j]=t.useState(""),[G,E]=t.useState(""),[R,P]=t.useState(!1),[p,$]=t.useState(!1),[M,A]=t.useState(!1),[y,O]=t.useState(!1),[f,z]=t.useState(""),[w,L]=t.useState(""),[k,F]=t.useState(""),[D,H]=t.useState(1),[C,I]=t.useState(""),{lastEvent:g}=ae("role.*,agent.*"),c=()=>{const s=o?`/workspaces/${o}/roles`:"/roles";return Promise.all([v(s),v("/agents"),v("/runtimes")]).then(([r,n,u])=>{_(r),V(n),T(u),!C&&u.length>0&&I(u[0].id)}).catch(r=>i(r.message))};t.useEffect(()=>{c(),x(null)},[o]),t.useEffect(()=>{g&&(!g.type.startsWith("role.")&&!g.type.startsWith("agent.")||c())},[g,o]);const K=()=>{(o?c():U("/roles/reload",{}).then(()=>c())).catch(r=>i(r.message))},Q=s=>{if(l===s){x(null);return}x(s),$(!1);const r=m.find(n=>n.id===s);if(!(r!=null&&r.role_md_path)){j(`# ${(r==null?void 0:r.name)||s}
|
|
23
|
+
|
|
24
|
+
No role.md file is attached to this role yet.`),E("");return}v(`/roles/${s}/content`).then(n=>{j(n.content),E(n.full_prompt)}).catch(n=>i(n.message))},X=()=>{l&&(P(!0),re(`/roles/${l}/content`,{content:N}).then(()=>c()).catch(s=>i(s.message)).finally(()=>P(!1)))},Y=async s=>{if(s.preventDefault(),!(!o||!f.trim()||y)){O(!0),i("");try{await U(`/workspaces/${o}/roles`,{name:f.trim(),runtime_id:C||null,capabilities:w?w.split(",").map(r=>r.trim()).filter(Boolean):[],preferred_runtimes:k?k.split(",").map(r=>r.trim()).filter(Boolean):[],headcount:Math.max(1,Number(D||1))}),z(""),L(""),F(""),H(1),A(!1),c()}catch(r){i(r.message)}finally{O(!1)}}},W=l?ge(N):null,q=t.useMemo(()=>l?d.filter(s=>s.role_id===l&&s.status!=="offline"):[],[d,l]);return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsxs("div",{className:"h-[52px] border-b border-[hsl(var(--border))] flex items-center justify-between px-6 shrink-0 bg-[hsl(var(--card))/0.92] backdrop-blur-xl",children:[e.jsx("h1",{className:"text-lg font-semibold tracking-tight",children:o?"角色":"全局角色"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:K,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border border-[hsl(var(--border))] bg-[hsl(var(--card))] text-xs font-medium hover:border-[hsl(var(--muted-foreground))] transition-colors",children:[e.jsx(ne,{className:"w-3.5 h-3.5"}),"重载 role.md"]}),o&&e.jsxs("button",{onClick:()=>A(!M),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))] text-xs font-medium hover:opacity-90 transition-opacity",children:[e.jsx(oe,{className:"w-3.5 h-3.5"}),"创建角色"]})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[S&&e.jsx("div",{className:"mb-4 p-3 rounded-lg bg-[hsl(var(--destructive))/0.08] border border-[hsl(var(--destructive))/0.2] text-sm text-[hsl(var(--destructive))]",children:S}),e.jsx("p",{className:"text-sm text-[hsl(var(--muted-foreground))] mb-5",children:"角色是主要抽象层。Agent 是绑定到角色的执行实例 — 同一角色可以有多个 Agent 水平扩展。"}),M&&o&&e.jsxs("form",{onSubmit:Y,className:"mb-5 p-4 bg-[hsl(var(--card))] border border-[hsl(var(--border))] rounded-xl",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-3 mb-3",children:[e.jsx("input",{value:f,onChange:s=>z(s.target.value),placeholder:"角色名称",className:"px-3 py-2 rounded-md border border-[hsl(var(--border))] bg-[hsl(var(--background))] text-sm focus:outline-none focus:ring-1 focus:ring-[hsl(var(--ring))]",autoFocus:!0}),e.jsx("input",{value:w,onChange:s=>L(s.target.value),placeholder:"能力(逗号分隔)",className:"px-3 py-2 rounded-md border border-[hsl(var(--border))] bg-[hsl(var(--background))] text-sm focus:outline-none focus:ring-1 focus:ring-[hsl(var(--ring))]"}),e.jsx("select",{value:C,onChange:s=>I(s.target.value),className:"px-3 py-2 rounded-md border border-[hsl(var(--border))] bg-[hsl(var(--background))] text-sm focus:outline-none focus:ring-1 focus:ring-[hsl(var(--ring))]",children:J.map(s=>e.jsxs("option",{value:s.id,children:[s.type," / ",s.id]},s.id))}),e.jsx("input",{type:"number",min:1,value:D,onChange:s=>H(Number(s.target.value||1)),placeholder:"Headcount",className:"px-3 py-2 rounded-md border border-[hsl(var(--border))] bg-[hsl(var(--background))] text-sm font-mono focus:outline-none focus:ring-1 focus:ring-[hsl(var(--ring))]"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{value:k,onChange:s=>F(s.target.value),placeholder:"首选运行时(逗号分隔)",className:"flex-1 px-3 py-2 rounded-md border border-[hsl(var(--border))] bg-[hsl(var(--background))] text-sm focus:outline-none focus:ring-1 focus:ring-[hsl(var(--ring))]"}),e.jsx("button",{type:"submit",disabled:y||!f.trim(),className:"inline-flex items-center gap-1.5 px-4 py-2 rounded-md bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))] text-sm font-medium hover:opacity-90 transition-opacity disabled:opacity-50",children:y?"创建中...":"创建"})]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-3",children:m.map(s=>{var B;const r=ve[(B=s.name)==null?void 0:B.toLowerCase()]||"hsl(var(--muted-foreground))",n=l===s.id,u=d.filter(a=>a.role_id===s.id&&a.status!=="offline");let h=[];try{h=JSON.parse(s.capabilities_json||"[]")}catch{}return e.jsxs("div",{className:`bg-[hsl(var(--card))] border rounded-xl transition-colors cursor-pointer ${n?"border-[hsl(var(--primary))] col-span-full":"border-[hsl(var(--border))] hover:border-[hsl(var(--muted-foreground))]"}`,onClick:()=>!n&&Q(s.id),children:[e.jsxs("div",{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center shrink-0",style:{background:`color-mix(in oklch, ${r} 15%, transparent)`},children:e.jsx(pe,{className:"w-4 h-4",style:{color:r}})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm",children:s.name||s.id}),s.role_md_path&&e.jsx("span",{className:"text-[10px] font-mono text-[hsl(var(--muted-foreground))]",children:s.role_md_path.split("/").pop()})]}),h.length>0&&e.jsxs("div",{className:"flex gap-1 mt-1 flex-wrap",children:[h.slice(0,3).map(a=>e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-mono bg-[hsl(var(--muted))] text-[hsl(var(--muted-foreground))]",children:a},a)),h.length>3&&e.jsxs("span",{className:"text-[10px] text-[hsl(var(--muted-foreground))]",children:["+",h.length-3]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-mono text-[hsl(var(--muted-foreground))]",children:[e.jsx(ee,{className:"w-3.5 h-3.5"}),u.length]}),n?e.jsx(se,{className:"w-4 h-4 text-[hsl(var(--muted-foreground))]"}):e.jsx(ie,{className:"w-4 h-4 text-[hsl(var(--muted-foreground))]"})]})]}),n&&e.jsxs("div",{className:"border-t border-[hsl(var(--border))] p-4 space-y-4",onClick:a=>a.stopPropagation(),children:[W&&e.jsxs("div",{className:"text-xs text-[hsl(var(--muted-foreground))]",children:[e.jsx("span",{className:"font-medium text-[hsl(var(--foreground))]",children:"继承链:"})," ",s.name||s.id," → ",W]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium text-[hsl(var(--muted-foreground))] uppercase tracking-wider font-mono mb-2",children:"绑定的 Agent"}),q.length===0?e.jsx("div",{className:"text-xs text-[hsl(var(--muted-foreground))]",children:"暂无活跃 Agent"}):e.jsx("div",{className:"flex gap-2 flex-wrap",children:q.map(a=>e.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-1.5 rounded-md border border-[hsl(var(--border))] bg-[hsl(var(--background))] text-xs",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${a.status==="working"?"bg-[hsl(var(--warning))]":"bg-[hsl(var(--success))]"}`}),e.jsx("span",{className:"font-medium",children:a.name}),a.runtime_id&&e.jsx("span",{className:"text-[hsl(var(--muted-foreground))] font-mono",children:a.runtime_id})]},a.id))})]}),e.jsx("div",{className:"rounded-lg overflow-hidden border border-[hsl(var(--border))]",children:e.jsx(t.Suspense,{fallback:e.jsx("div",{className:"h-64 bg-[hsl(var(--muted))] animate-pulse"}),children:e.jsx(fe,{height:"320px",language:"markdown",theme:"vs-dark",value:N,onChange:a=>j(a||""),options:{minimap:{enabled:!1},wordWrap:"on",fontSize:13}})})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:X,disabled:R,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))] text-xs font-medium hover:opacity-90 disabled:opacity-50",children:[e.jsx(le,{className:"w-3.5 h-3.5"}),R?"保存中...":"保存"]}),e.jsxs("button",{onClick:()=>$(!p),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border border-[hsl(var(--border))] text-xs font-medium hover:border-[hsl(var(--muted-foreground))] transition-colors",children:[p?e.jsx(me,{className:"w-3.5 h-3.5"}):e.jsx(he,{className:"w-3.5 h-3.5"}),p?"隐藏完整 Prompt":"查看完整 Prompt"]}),e.jsx("button",{onClick:()=>x(null),className:"ml-auto inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border border-[hsl(var(--border))] text-xs font-medium hover:border-[hsl(var(--muted-foreground))] transition-colors",children:"收起"})]}),p&&e.jsx("pre",{className:"text-xs font-mono bg-[hsl(var(--sidebar-background))] text-[hsl(var(--sidebar-foreground))] p-4 rounded-lg overflow-auto max-h-64 whitespace-pre-wrap",children:G})]})]},s.id)})})]})]})}export{ke as default};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{q as N,z as n,v as e,Z as M,M as R,s as i,x as m,w as E}from"./index-C7kx39S9.js";import{A as L}from"./activity-CIA8bIA4.js";import{R as $}from"./refresh-cw-BWX04Hg3.js";import{C as p}from"./circle-check-B3P1qK0Z.js";/**
|
|
2
|
+
* @license lucide-react v1.16.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 z=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],j=N("database",z);/**
|
|
7
|
+
* @license lucide-react v1.16.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 B=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],q=N("server",B);function U(){const[x,k]=n.useState([]),[r,y]=n.useState(null),[l,h]=n.useState({}),[c,w]=n.useState(null),[u,_]=n.useState(""),[v,d]=n.useState(""),f=()=>Promise.all([i("/runtimes"),i("/ops/stats"),i("/config")]).then(([s,a,t])=>{k(s),y(a),h(t)}).catch(s=>d(s.message));n.useEffect(()=>{f()},[]);const C=s=>m(`/runtimes/${s}/healthcheck`,{}).then(f).catch(a=>d(a.message)),S=()=>m("/bridges/lark/events",{text:"/status"}).then(w).catch(s=>d(s.message)),o=(s,a)=>{E("/config",{[s]:a}).then(t=>h(t)).catch(t=>d(t.message))},A=()=>m("/ops/backup",{}).then(s=>_(s.path)).catch(s=>d(s.message));return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsx("div",{className:"h-[52px] border-b border-[hsl(var(--border))] flex items-center px-6 shrink-0 bg-[hsl(var(--card))/0.92] backdrop-blur-xl",children:e.jsx("h1",{className:"text-lg font-semibold tracking-tight",children:"设置"})}),e.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:e.jsxs("div",{className:"max-w-3xl mx-auto space-y-6",children:[v&&e.jsx("div",{className:"p-3 rounded-lg bg-[hsl(var(--destructive))/0.08] border border-[hsl(var(--destructive))/0.2] text-sm text-[hsl(var(--destructive))]",children:v}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(L,{className:"w-4 h-4 text-[hsl(var(--muted-foreground))]"}),e.jsx("h2",{className:"text-sm font-semibold",children:"用量统计"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"bg-[hsl(var(--card))] border border-[hsl(var(--border))] rounded-xl p-4",children:[e.jsx("div",{className:"text-xs font-mono uppercase tracking-wider text-[hsl(var(--muted-foreground))] mb-1",children:"Sessions"}),e.jsx("div",{className:"text-2xl font-semibold font-mono tabular-nums",children:(r==null?void 0:r.cost.sessions)??0})]}),e.jsxs("div",{className:"bg-[hsl(var(--card))] border border-[hsl(var(--border))] rounded-xl p-4",children:[e.jsx("div",{className:"text-xs font-mono uppercase tracking-wider text-[hsl(var(--muted-foreground))] mb-1",children:"Est. Tokens"}),e.jsx("div",{className:"text-2xl font-semibold font-mono tabular-nums",children:((r==null?void 0:r.cost.estimated_tokens)??0).toLocaleString()})]}),e.jsxs("div",{className:"bg-[hsl(var(--card))] border border-[hsl(var(--border))] rounded-xl p-4",children:[e.jsx("div",{className:"text-xs font-mono uppercase tracking-wider text-[hsl(var(--muted-foreground))] mb-1",children:"Est. USD"}),e.jsxs("div",{className:"text-2xl font-semibold font-mono tabular-nums",children:["$",(r==null?void 0:r.cost.estimated_usd)??0]})]})]})]}),e.jsxs("section",{className:"bg-[hsl(var(--card))] border border-[hsl(var(--border))] rounded-xl p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(M,{className:"w-4 h-4 text-[hsl(var(--warning))]"}),e.jsx("h2",{className:"text-sm font-semibold",children:"Chief Agent"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("label",{className:"w-28 shrink-0 text-xs font-medium text-[hsl(var(--muted-foreground))]",children:"间隔 (分钟)"}),e.jsx("input",{type:"range",min:5,max:60,step:1,value:Number(l.chief_interval_min||"15"),onChange:s=>o("chief_interval_min",s.target.value),className:"flex-1 h-1.5 rounded-full appearance-none bg-[hsl(var(--muted))] accent-[hsl(var(--primary))]"}),e.jsx("span",{className:"text-sm font-mono w-8 text-right tabular-nums",children:l.chief_interval_min||"15"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("label",{className:"w-28 shrink-0 text-xs font-medium text-[hsl(var(--muted-foreground))]",children:"API Key"}),e.jsx("input",{type:"password",value:l.chief_api_key||"",onChange:s=>o("chief_api_key",s.target.value),placeholder:"sk-ant-...",className:"flex-1 px-3 py-2 rounded-md border border-[hsl(var(--border))] bg-[hsl(var(--background))] text-sm font-mono focus:outline-none focus:ring-1 focus:ring-[hsl(var(--ring))]"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("label",{className:"w-28 shrink-0 text-xs font-medium text-[hsl(var(--muted-foreground))]",children:"Base URL"}),e.jsx("input",{value:l.chief_base_url||"",onChange:s=>o("chief_base_url",s.target.value),placeholder:"https://api.anthropic.com",className:"flex-1 px-3 py-2 rounded-md border border-[hsl(var(--border))] bg-[hsl(var(--background))] text-sm font-mono focus:outline-none focus:ring-1 focus:ring-[hsl(var(--ring))]"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("label",{className:"w-28 shrink-0 text-xs font-medium text-[hsl(var(--muted-foreground))]",children:"Model"}),e.jsx("input",{value:l.chief_model||"",onChange:s=>o("chief_model",s.target.value),placeholder:"claude-sonnet-4-20250514",className:"flex-1 px-3 py-2 rounded-md border border-[hsl(var(--border))] bg-[hsl(var(--background))] text-sm font-mono focus:outline-none focus:ring-1 focus:ring-[hsl(var(--ring))]"})]})]})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(q,{className:"w-4 h-4 text-[hsl(var(--muted-foreground))]"}),e.jsx("h2",{className:"text-sm font-semibold",children:"Agent 运行时"})]}),e.jsxs("div",{className:"space-y-3",children:[x.map(s=>{var b,g;const a=((b=s.waterline)==null?void 0:b.utilization)??0,t=Math.round(a*100);return e.jsxs("div",{className:"bg-[hsl(var(--card))] border border-[hsl(var(--border))] rounded-xl p-4",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm",children:s.type}),e.jsx("span",{className:"text-[10px] font-mono px-1.5 py-0.5 rounded bg-[hsl(var(--muted))] text-[hsl(var(--muted-foreground))]",children:s.transport}),e.jsx("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-mono font-medium ${s.status==="healthy"?"pill-success":"pill-warning"}`,children:s.status})]}),e.jsxs("div",{className:"text-xs text-[hsl(var(--muted-foreground))] mt-0.5 font-mono",children:["容量 ",s.capacity," · 运行中 ",((g=s.waterline)==null?void 0:g.running)??0," · ",s.target||"local"]})]}),e.jsxs("button",{onClick:()=>C(s.id),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border border-[hsl(var(--border))] text-xs font-medium hover:border-[hsl(var(--muted-foreground))] transition-colors",children:[e.jsx($,{className:"w-3 h-3"}),"健康检查"]})]}),s.capacity>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-[11px] text-[hsl(var(--muted-foreground))] mb-1 font-mono",children:[e.jsx("span",{children:"利用率"}),e.jsxs("span",{className:"tabular-nums",children:[t,"%"]})]}),e.jsx("div",{className:"h-1.5 bg-[hsl(var(--muted))] rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all ${a>.8?"bg-[hsl(var(--destructive))]":a>.5?"bg-[hsl(var(--warning))]":"bg-[hsl(var(--success))]"}`,style:{width:`${Math.min(100,t)}%`}})})]})]},s.id)}),x.length===0&&e.jsx("div",{className:"text-center py-8 text-sm text-[hsl(var(--muted-foreground))]",children:"暂无运行时"})]})]}),e.jsxs("section",{className:"bg-[hsl(var(--card))] border border-[hsl(var(--border))] rounded-xl p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(j,{className:"w-4 h-4 text-[hsl(var(--muted-foreground))]"}),e.jsx("h2",{className:"text-sm font-semibold",children:"备份与恢复"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:A,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border border-[hsl(var(--border))] text-xs font-medium hover:border-[hsl(var(--muted-foreground))] transition-colors",children:[e.jsx(j,{className:"w-3.5 h-3.5"}),"创建备份"]}),u&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-[hsl(var(--success))]",children:[e.jsx(p,{className:"w-3.5 h-3.5"}),"已保存: ",e.jsx("span",{className:"font-mono",children:u})]})]})]}),e.jsxs("section",{className:"bg-[hsl(var(--card))] border border-[hsl(var(--border))] rounded-xl p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(R,{className:"w-4 h-4 text-[hsl(var(--muted-foreground))]"}),e.jsx("h2",{className:"text-sm font-semibold",children:"IM 桥接"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[hsl(var(--muted-foreground))] mb-1.5",children:"飞书 Webhook URL"}),e.jsx("input",{value:l.lark_webhook_url||"",onChange:s=>o("lark_webhook_url",s.target.value),placeholder:"https://open.larksuite.com/open-apis/bot/v2/hook/...",className:"w-full px-3 py-2 rounded-md border border-[hsl(var(--border))] bg-[hsl(var(--background))] text-sm font-mono focus:outline-none focus:ring-1 focus:ring-[hsl(var(--ring))]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[hsl(var(--muted-foreground))] mb-1.5",children:"Telegram Bot Token"}),e.jsx("input",{type:"password",value:l.telegram_bot_token||"",onChange:s=>o("telegram_bot_token",s.target.value),placeholder:"123456:ABC-DEF...",className:"w-full px-3 py-2 rounded-md border border-[hsl(var(--border))] bg-[hsl(var(--background))] text-sm font-mono focus:outline-none focus:ring-1 focus:ring-[hsl(var(--ring))]"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:S,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border border-[hsl(var(--border))] text-xs font-medium hover:border-[hsl(var(--muted-foreground))] transition-colors",children:"测试飞书 /status"}),c&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-[hsl(var(--success))]",children:[e.jsx(p,{className:"w-3.5 h-3.5"}),"已发送"]})]}),c&&e.jsx("pre",{className:"text-xs font-mono bg-[hsl(var(--sidebar-background))] text-[hsl(var(--sidebar-foreground))] p-3 rounded-lg overflow-auto max-h-32",children:JSON.stringify(c,null,2)})]})]})]})})]})}export{U as default};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import{q as D,z as t,v as e,x as i,s as U,r as Z}from"./index-C7kx39S9.js";import{R as J}from"./refresh-cw-BWX04Hg3.js";import{P as K}from"./plus-BHnOxbns.js";import{X as g}from"./x-DVdKPXXy.js";import{S as Q}from"./sparkles-CDr6Dw1e.js";import{T as W}from"./trash-2-9-ThEdey.js";/**
|
|
2
|
+
* @license lucide-react v1.16.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 Y=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],ee=D("circle",Y);/**
|
|
7
|
+
* @license lucide-react v1.16.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 se=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],re=D("download",se),j=["claude","codex","gemini","opencode","hermes"],n={claude:"#e87040",codex:"#4a9eff",gemini:"#34a853",opencode:"#9b59b6",hermes:"#6c757d"};function ce(){const[d,I]=t.useState([]),[f,P]=t.useState([]),[m,N]=t.useState("all"),[L,x]=t.useState(!1),[F,b]=t.useState(!1),[p,y]=t.useState([]),[G,w]=t.useState(!1),[k,S]=t.useState(!1),[C,l]=t.useState(""),[h,A]=t.useState(""),[$,_]=t.useState(""),[u,M]=t.useState("local"),[z,E]=t.useState(""),[v,R]=t.useState({claude:!0,codex:!1,gemini:!1,opencode:!1,hermes:!1}),o=()=>{Promise.all([U("/skills"),U("/skills/agents")]).then(([s,r])=>{I(s),P(r)}).catch(s=>l(s.message))};t.useEffect(()=>{o()},[]);const O=()=>{h.trim()&&i("/skills",{name:h.trim(),description:$.trim()||null,source:u,source_url:z.trim()||null,agents:v}).then(()=>{x(!1),A(""),_(""),E(""),R({claude:!0,codex:!1,gemini:!1,opencode:!1,hermes:!1}),o()}).catch(s=>l(s.message))},q=(s,r,a)=>{i(`/skills/${s}/toggle`,{agent:r,enabled:a}).then(o).catch(c=>l(c.message))},B=(s,r)=>{confirm(`确认卸载 skill "${r}"? 文件将移入回收站。`)&&Z(`/skills/${s}`).then(o).catch(a=>l(a.message))},H=()=>{S(!0),i("/skills/sync",{}).then(s=>{var r;(r=s.errors)!=null&&r.length&&l(s.errors.join(`
|
|
12
|
+
`)),o()}).catch(s=>l(s.message)).finally(()=>S(!1))},V=()=>{w(!0),i("/skills/scan",{}).then(s=>{y(s),b(!0)}).catch(s=>l(s.message)).finally(()=>w(!1))},T=m==="all"?d:d.filter(s=>s.agents[m]),X=s=>d.filter(r=>r.agents[s]).length;return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsxs("div",{className:"h-[52px] border-b border-[hsl(var(--border))] flex items-center justify-between px-6 shrink-0 bg-[hsl(var(--card))/0.92] backdrop-blur-xl",children:[e.jsx("h1",{className:"text-lg font-semibold tracking-tight",children:"Skills"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:H,disabled:k,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border border-[hsl(var(--border))] bg-[hsl(var(--card))] text-xs font-medium hover:border-[hsl(var(--muted-foreground))] transition-colors disabled:opacity-50",children:[e.jsx(J,{className:`w-3.5 h-3.5 ${k?"animate-spin":""}`}),"全量同步"]}),e.jsxs("button",{onClick:V,disabled:G,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border border-[hsl(var(--border))] bg-[hsl(var(--card))] text-xs font-medium hover:border-[hsl(var(--muted-foreground))] transition-colors disabled:opacity-50",children:[e.jsx(re,{className:"w-3.5 h-3.5"}),"导入已有"]}),e.jsxs("button",{onClick:()=>x(!0),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))] text-xs font-medium hover:opacity-90 transition-opacity",children:[e.jsx(K,{className:"w-3.5 h-3.5"}),"添加 Skill"]})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[C&&e.jsxs("div",{className:"mb-4 p-3 rounded-lg bg-[hsl(var(--destructive))/0.08] border border-[hsl(var(--destructive))/0.2] text-sm text-[hsl(var(--destructive))] flex items-center justify-between",children:[e.jsx("span",{children:C}),e.jsx("button",{onClick:()=>l(""),className:"p-1 hover:bg-[hsl(var(--muted))] rounded",children:e.jsx(g,{className:"w-3.5 h-3.5"})})]}),e.jsx("p",{className:"text-sm text-[hsl(var(--muted-foreground))] mb-4",children:"Skills 从完成的会话中自动提取,或手动定义。每个 Skill 可以独立启用到不同的 Agent。"}),e.jsxs("div",{className:"flex gap-2 mb-5 flex-wrap items-center",children:[e.jsxs("button",{onClick:()=>N("all"),className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-[11px] font-medium border transition-colors ${m==="all"?"border-[hsl(var(--primary))] bg-[hsl(var(--primary))/0.1] text-[hsl(var(--primary))]":"border-[hsl(var(--border))] text-[hsl(var(--muted-foreground))] hover:border-[hsl(var(--muted-foreground))]"}`,children:["已安装 ",e.jsx("span",{className:"font-mono",children:d.length})]}),j.map(s=>{const r=f.find(c=>c.name===s),a=m===s;return e.jsxs("button",{onClick:()=>N(s),className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-[11px] font-medium border transition-colors",style:{borderColor:a?n[s]:"hsl(var(--border))",background:a?`${n[s]}15`:"transparent",color:n[s]},title:(r==null?void 0:r.dir)||"",children:[e.jsx(ee,{className:"w-2 h-2 fill-current"}),s.charAt(0).toUpperCase()+s.slice(1),": ",e.jsx("span",{className:"font-mono",children:X(s)})]},s)})]}),e.jsx("div",{className:"bg-[hsl(var(--card))] border border-[hsl(var(--border))] rounded-xl overflow-hidden",children:T.length===0?e.jsxs("div",{className:"p-12 text-center text-[hsl(var(--muted-foreground))]",children:[e.jsx(Q,{className:"w-8 h-8 mx-auto mb-2 opacity-40"}),e.jsx("p",{className:"text-sm",children:d.length===0?"尚未安装任何 Skill":"当前筛选无结果"})]}):e.jsx("div",{className:"divide-y divide-[hsl(var(--border))]",children:T.map(s=>e.jsxs("div",{className:"px-4 py-3 flex items-center justify-between hover:bg-[hsl(var(--muted))/0.5] transition-colors",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm font-mono",children:s.name}),e.jsx("span",{className:`inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-mono font-medium ${s.source==="local"?"bg-[hsl(var(--muted))] text-[hsl(var(--muted-foreground))]":s.source==="url"?"pill-info":"pill-neutral"}`,children:s.source}),!s.dir_exists&&e.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-mono font-medium bg-[hsl(var(--warning))/0.1] text-[hsl(var(--warning))]",children:"目录缺失"})]}),s.description&&e.jsx("div",{className:"text-xs text-[hsl(var(--muted-foreground))] mt-0.5 truncate max-w-[550px]",children:s.description})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0 ml-4",children:[j.map(r=>e.jsx("button",{onClick:()=>q(s.id,r,!s.agents[r]),className:"w-[22px] h-[22px] rounded-full flex items-center justify-center text-[10px] transition-all",style:{border:`2px solid ${s.agents[r]?n[r]:"hsl(var(--border))"}`,background:s.agents[r]?n[r]:"transparent",color:s.agents[r]?"#fff":"hsl(var(--muted-foreground))"},title:`${r}: ${s.agents[r]?"已启用":"未启用"}`,children:s.agents[r]?"✓":""},r)),e.jsx("button",{onClick:()=>B(s.id,s.name),className:"ml-2 p-1.5 rounded-md text-[hsl(var(--muted-foreground))] hover:text-[hsl(var(--destructive))] hover:bg-[hsl(var(--destructive))/0.08] transition-colors",title:"卸载",children:e.jsx(W,{className:"w-3.5 h-3.5"})})]})]},s.id))})}),f.length>0&&e.jsxs("div",{className:"mt-6",children:[e.jsx("h3",{className:"text-xs font-medium text-[hsl(var(--muted-foreground))] mb-2 font-mono uppercase tracking-wider",children:"Agent 目录"}),e.jsx("div",{className:"bg-[hsl(var(--card))] border border-[hsl(var(--border))] rounded-xl overflow-hidden divide-y divide-[hsl(var(--border))]",children:f.map(s=>e.jsxs("div",{className:"px-4 py-2.5 flex items-center justify-between text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${s.available?"bg-[hsl(var(--success))]":"bg-[hsl(var(--destructive))]"}`}),e.jsx("span",{className:"font-medium",style:{color:n[s.name]},children:s.name})]}),e.jsx("span",{className:"text-[hsl(var(--muted-foreground))] font-mono text-[11px]",children:s.dir})]},s.name))})]})]}),L&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-sm",children:e.jsxs("div",{className:"w-full max-w-md bg-[hsl(var(--card))] border border-[hsl(var(--border))] rounded-xl shadow-2xl",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-[hsl(var(--border))]",children:[e.jsx("h2",{className:"font-semibold text-sm",children:"添加 Skill"}),e.jsx("button",{onClick:()=>x(!1),className:"p-1 rounded hover:bg-[hsl(var(--muted))]",children:e.jsx(g,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[hsl(var(--muted-foreground))] mb-1.5",children:"名称 *"}),e.jsx("input",{value:h,onChange:s=>A(s.target.value),placeholder:"e.g. brainstorming",className:"w-full px-3 py-2 rounded-md border border-[hsl(var(--border))] bg-[hsl(var(--background))] text-sm font-mono focus:outline-none focus:ring-1 focus:ring-[hsl(var(--ring))]",autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[hsl(var(--muted-foreground))] mb-1.5",children:"描述"}),e.jsx("textarea",{value:$,onChange:s=>_(s.target.value),placeholder:"Skill 的功能描述...",rows:2,className:"w-full px-3 py-2 rounded-md border border-[hsl(var(--border))] bg-[hsl(var(--background))] text-sm resize-none focus:outline-none focus:ring-1 focus:ring-[hsl(var(--ring))]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[hsl(var(--muted-foreground))] mb-1.5",children:"来源"}),e.jsxs("select",{value:u,onChange:s=>M(s.target.value),className:"w-full px-3 py-2 rounded-md border border-[hsl(var(--border))] bg-[hsl(var(--background))] text-sm focus:outline-none focus:ring-1 focus:ring-[hsl(var(--ring))]",children:[e.jsx("option",{value:"local",children:"本地"}),e.jsx("option",{value:"url",children:"URL"}),e.jsx("option",{value:"zip",children:"ZIP"})]})]}),u!=="local"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[hsl(var(--muted-foreground))] mb-1.5",children:"来源地址"}),e.jsx("input",{value:z,onChange:s=>E(s.target.value),placeholder:u==="url"?"https://github.com/...":"/path/to/skill.zip",className:"w-full px-3 py-2 rounded-md border border-[hsl(var(--border))] bg-[hsl(var(--background))] text-sm font-mono focus:outline-none focus:ring-1 focus:ring-[hsl(var(--ring))]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[hsl(var(--muted-foreground))] mb-1.5",children:"启用到哪些 Agent"}),e.jsx("div",{className:"flex gap-3 flex-wrap mt-1",children:j.map(s=>e.jsxs("label",{className:"flex items-center gap-1.5 text-xs cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:v[s],onChange:r=>R({...v,[s]:r.target.checked}),className:"rounded border-[hsl(var(--border))]"}),e.jsx("span",{className:"font-medium",style:{color:n[s]},children:s})]},s))})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 px-5 py-4 border-t border-[hsl(var(--border))]",children:[e.jsx("button",{onClick:()=>x(!1),className:"px-3 py-1.5 rounded-md border border-[hsl(var(--border))] text-xs font-medium hover:border-[hsl(var(--muted-foreground))] transition-colors",children:"取消"}),e.jsx("button",{onClick:O,disabled:!h.trim(),className:"px-3 py-1.5 rounded-md bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))] text-xs font-medium hover:opacity-90 disabled:opacity-50",children:"安装"})]})]})}),F&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-sm",children:e.jsxs("div",{className:"w-full max-w-lg max-h-[80vh] bg-[hsl(var(--card))] border border-[hsl(var(--border))] rounded-xl shadow-2xl flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-[hsl(var(--border))] shrink-0",children:[e.jsx("h2",{className:"font-semibold text-sm",children:"发现未管理的 Skills"}),e.jsx("button",{onClick:()=>b(!1),className:"p-1 rounded hover:bg-[hsl(var(--muted))]",children:e.jsx(g,{className:"w-4 h-4"})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-5",children:p.length===0?e.jsx("p",{className:"text-sm text-[hsl(var(--muted-foreground))] text-center py-8",children:"所有 Agent 目录中的 Skills 均已被管理。"}):e.jsx("div",{className:"space-y-2",children:p.map((s,r)=>e.jsxs("div",{className:"border border-[hsl(var(--border))] rounded-lg p-3 flex justify-between items-start gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-sm",children:s.name}),e.jsxs("div",{className:"text-xs text-[hsl(var(--muted-foreground))] mt-0.5",children:["来自 ",e.jsx("span",{style:{color:n[s.agent]||"#666"},children:s.agent})]}),s.description&&e.jsxs("div",{className:"text-xs text-[hsl(var(--muted-foreground))] mt-1 line-clamp-2",children:[s.description.slice(0,200),s.description.length>200?"…":""]})]}),e.jsx("button",{onClick:()=>{i("/skills",{name:s.name,description:s.description||null,source:"local",agents:{[s.agent]:!0}}).then(()=>{y(p.filter((a,c)=>c!==r)),o()}).catch(a=>l(a.message))},className:"shrink-0 px-3 py-1.5 rounded-md border border-[hsl(var(--border))] text-xs font-medium hover:border-[hsl(var(--primary))] hover:text-[hsl(var(--primary))] transition-colors",children:"导入"})]},r))})}),e.jsx("div",{className:"flex justify-end px-5 py-4 border-t border-[hsl(var(--border))] shrink-0",children:e.jsx("button",{onClick:()=>b(!1),className:"px-3 py-1.5 rounded-md border border-[hsl(var(--border))] text-xs font-medium hover:border-[hsl(var(--muted-foreground))] transition-colors",children:"关闭"})})]})})]})}export{ce as default};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{q,N as se,L as re,z as l,s as C,v as e,x as b}from"./index-C7kx39S9.js";import{A as _}from"./arrow-right-S7ID7nDp.js";import{S as te}from"./sparkles-CDr6Dw1e.js";import{S as ae}from"./save-BLbb_9xz.js";/**
|
|
2
|
+
* @license lucide-react v1.16.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 ne=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],G=q("arrow-left",ne);/**
|
|
7
|
+
* @license lucide-react v1.16.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 le=[["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}],["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09",key:"u4xsad"}],["path",{d:"M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z",key:"676m9"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05",key:"92ym6u"}]],T=q("rocket",le);function me(){var E,H;const{workspaceId:u}=se(),B=re(),[x,m]=l.useState(1),[p,R]=l.useState([]),[j,F]=l.useState([]),[h,I]=l.useState([]),[o,N]=l.useState(u||""),[y,L]=l.useState(""),[z,A]=l.useState(""),[c,w]=l.useState(new Map),[v,O]=l.useState(""),[k,f]=l.useState(!1),[M,n]=l.useState(""),[$,W]=l.useState(!1),[U,V]=l.useState(!1),[S,D]=l.useState(null);l.useEffect(()=>{C("/workspaces").then(R).catch(s=>n(s.message)),C("/roles").then(F).catch(s=>n(s.message)),C("/runtimes").then(I).catch(s=>n(s.message))},[]),l.useEffect(()=>{u&&p.length>0&&p.find(s=>s.id===u)&&(N(u),m(2))},[u,p]);const d=p.find(s=>s.id===o),J=async()=>{if(y.trim()){f(!0);try{const s=await b("/workspaces",{name:y,goal:z});R(a=>[...a,s]),N(s.id),L(""),A(""),m(2)}catch(s){n(s.message)}finally{f(!1)}}},K=()=>{if(!o){n("Please select a workspace");return}n(""),m(2)},Q=(s,a)=>{w(t=>{const r=new Map(t);return r.has(s)?r.delete(s):r.set(s,{role_id:s,runtime_id:h.length>0?h[0].id:"",headcount:a.headcount||1}),r})},P=(s,a,t)=>{w(r=>{const i=new Map(r),g=i.get(s);return g&&i.set(s,{...g,[a]:t}),i})},X=async()=>{if(o){W(!0);try{const s=await b(`/workspaces/${o}/recommend-roles`,{});w(a=>{const t=new Map(a);for(const r of s){const i=j.find(g=>g.id===r.role_id);i&&!t.has(r.role_id)&&t.set(r.role_id,{role_id:r.role_id,runtime_id:h.length>0?h[0].id:"",headcount:i.headcount||1})}return t})}catch(s){n(s.message)}finally{W(!1)}}},Y=()=>{if(c.size===0){n("Please select at least one role");return}n(""),m(3)},Z=async()=>{if(!v.trim()){n("Please enter a project name");return}f(!0),n("");try{const s=await b(`/workspaces/${o}/wizard`,{project_name:v,roles:Array.from(c.values())});D(s),V(!0)}catch(s){n(s.message)}finally{f(!1)}},ee=["Workspace","Roles","Launch"];return U&&S?e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsx("div",{className:"h-[52px] border-b border-[hsl(var(--border))] flex items-center justify-between px-6 bg-[hsl(var(--card)/0.92)] backdrop-blur-xl sticky top-0 z-5 shrink-0",children:e.jsx("h1",{className:"text-lg font-semibold tracking-tight",children:"Launch Wizard"})}),e.jsx("div",{className:"flex-1 overflow-auto flex items-center justify-center p-6",children:e.jsxs("div",{className:"max-w-md w-full p-8 rounded-xl border border-[hsl(var(--success)/0.3)] bg-[hsl(var(--success)/0.05)] text-center",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-full bg-[hsl(var(--success)/0.12)] mb-4",children:e.jsx(T,{className:"w-6 h-6 text-[hsl(var(--success))]"})}),e.jsx("h2",{className:"text-xl font-semibold tracking-tight text-[hsl(var(--foreground))] mb-2",children:"Workspace Launched!"}),e.jsxs("p",{className:"text-sm text-[hsl(var(--muted-foreground))] mb-6",children:["Project ",e.jsx("span",{className:"font-medium text-[hsl(var(--foreground))]",children:((E=S.project)==null?void 0:E.name)||v})," created with ",e.jsx("span",{className:"font-medium text-[hsl(var(--foreground))]",children:((H=S.agents)==null?void 0:H.length)||0})," agent(s)."]}),e.jsxs("button",{onClick:()=>B("/runtimes"),className:"inline-flex items-center gap-2 px-4 py-2 rounded-md bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))] text-sm font-medium hover:opacity-90 transition-opacity",children:["View Agent Runtimes",e.jsx(_,{className:"w-3.5 h-3.5"})]})]})})]}):e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsx("div",{className:"h-[52px] border-b border-[hsl(var(--border))] flex items-center justify-between px-6 bg-[hsl(var(--card)/0.92)] backdrop-blur-xl sticky top-0 z-5 shrink-0",children:e.jsx("h1",{className:"text-lg font-semibold tracking-tight",children:"Launch Wizard"})}),e.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsx("div",{className:"flex items-center mb-8",children:ee.map((s,a)=>{const t=a+1,r=t===x,i=t<x;return e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:`w-7 h-7 rounded-full flex items-center justify-center font-mono text-xs font-semibold transition-colors ${r?"bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))]":i?"bg-[hsl(var(--primary)/0.15)] text-[hsl(var(--primary))]":"bg-[hsl(var(--muted))] text-[hsl(var(--muted-foreground))]"}`,children:t}),e.jsx("span",{className:`ml-2 text-sm ${r?"font-medium text-[hsl(var(--foreground))]":"text-[hsl(var(--muted-foreground))]"}`,children:s}),t<3&&e.jsx("div",{className:"w-10 h-px bg-[hsl(var(--border))] mx-3"})]},t)})}),M&&e.jsx("div",{className:"mb-4 p-3 rounded-lg bg-[hsl(var(--destructive)/0.08)] border border-[hsl(var(--destructive)/0.2)] text-sm text-[hsl(var(--destructive))]",children:M}),x===1&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold tracking-tight mb-4",children:"Select a Workspace"}),e.jsx("div",{className:"space-y-2 mb-6",children:p.map(s=>e.jsxs("label",{className:`flex items-center gap-3 p-3 border rounded-lg cursor-pointer transition-colors ${o===s.id?"border-[hsl(var(--primary))] bg-[hsl(var(--primary)/0.05)]":"border-[hsl(var(--border))] hover:border-[hsl(var(--muted-foreground))]"}`,children:[e.jsx("input",{type:"radio",name:"workspace",checked:o===s.id,onChange:()=>N(s.id),className:"accent-[hsl(var(--primary))]"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm text-[hsl(var(--foreground))]",children:s.name}),s.goal&&e.jsx("div",{className:"text-xs text-[hsl(var(--muted-foreground))]",children:s.goal})]})]},s.id))}),e.jsxs("div",{className:"border-t border-[hsl(var(--border))] pt-4",children:[e.jsx("h3",{className:"text-sm font-medium text-[hsl(var(--foreground))] mb-3",children:"Or create a new workspace"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{placeholder:"Name",value:y,onChange:s=>L(s.target.value),className:"px-3 py-2 rounded-md border border-[hsl(var(--border))] bg-[hsl(var(--background))] text-sm focus:outline-none focus:ring-1 focus:ring-[hsl(var(--ring))] w-40"}),e.jsx("input",{placeholder:"Goal",value:z,onChange:s=>A(s.target.value),className:"flex-1 px-3 py-2 rounded-md border border-[hsl(var(--border))] bg-[hsl(var(--background))] text-sm focus:outline-none focus:ring-1 focus:ring-[hsl(var(--ring))]"}),e.jsx("button",{onClick:J,disabled:k,className:"inline-flex items-center px-4 py-2 rounded-md border border-[hsl(var(--border))] bg-[hsl(var(--card))] text-sm font-medium hover:border-[hsl(var(--muted-foreground))] transition-colors disabled:opacity-50",children:"Create & Select"})]})]}),e.jsx("div",{className:"flex justify-end mt-8",children:e.jsxs("button",{onClick:K,className:"inline-flex items-center gap-1.5 px-4 py-2 rounded-md bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))] text-sm font-medium hover:opacity-90 transition-opacity",children:["Next",e.jsx(_,{className:"w-3.5 h-3.5"})]})})]}),x===2&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-base font-semibold tracking-tight",children:"Choose Roles & Headcount"}),e.jsxs("button",{onClick:X,disabled:$,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))] text-xs font-medium hover:opacity-90 transition-opacity disabled:opacity-50",children:[e.jsx(te,{className:"w-3.5 h-3.5"}),$?"Recommending...":"AI Recommend"]})]}),e.jsx("div",{className:"space-y-3 mb-6",children:j.map(s=>{const a=c.has(s.id),t=c.get(s.id);return e.jsxs("div",{className:`border rounded-lg p-4 transition-colors ${a?"border-[hsl(var(--primary))] bg-[hsl(var(--primary)/0.05)]":"border-[hsl(var(--border))]"}`,children:[e.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:a,onChange:()=>Q(s.id,s),className:"accent-[hsl(var(--primary))]"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm text-[hsl(var(--foreground))]",children:s.name}),e.jsxs("div",{className:"text-xs text-[hsl(var(--muted-foreground))]",children:[s.version&&`v${s.version}`,s.capabilities_json&&` · Capabilities: ${s.capabilities_json}`]})]})]}),a&&t&&e.jsxs("div",{className:"mt-3 ml-7 flex gap-4 items-center",children:[e.jsxs("label",{className:"text-xs text-[hsl(var(--muted-foreground))]",children:["Runtime:",e.jsx("select",{value:t.runtime_id,onChange:r=>P(s.id,"runtime_id",r.target.value),className:"ml-1 px-2 py-1 rounded border border-[hsl(var(--border))] bg-[hsl(var(--background))] text-xs focus:outline-none focus:ring-1 focus:ring-[hsl(var(--ring))]",children:h.map(r=>e.jsxs("option",{value:r.id,children:[r.name," (",r.provider,")"]},r.id))})]}),e.jsxs("label",{className:"text-xs text-[hsl(var(--muted-foreground))]",children:["Headcount:",e.jsx("input",{type:"number",min:1,value:t.headcount,onChange:r=>P(s.id,"headcount",Math.max(1,parseInt(r.target.value)||1)),className:"ml-1 w-16 px-2 py-1 rounded border border-[hsl(var(--border))] bg-[hsl(var(--background))] text-xs font-mono focus:outline-none focus:ring-1 focus:ring-[hsl(var(--ring))]"})]})]})]},s.id)})}),e.jsxs("div",{className:"flex justify-between mt-8",children:[e.jsxs("button",{onClick:()=>{n(""),m(1)},className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm text-[hsl(var(--muted-foreground))] hover:text-[hsl(var(--foreground))] transition-colors",children:[e.jsx(G,{className:"w-3.5 h-3.5"}),"Back"]}),e.jsxs("button",{onClick:Y,className:"inline-flex items-center gap-1.5 px-4 py-2 rounded-md bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))] text-sm font-medium hover:opacity-90 transition-opacity",children:["Next",e.jsx(_,{className:"w-3.5 h-3.5"})]})]})]}),x===3&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold tracking-tight mb-4",children:"Confirm & Launch"}),e.jsxs("div",{className:"mb-4 p-4 rounded-xl bg-[hsl(var(--muted))] border border-[hsl(var(--border))]",children:[e.jsx("div",{className:"text-xs text-[hsl(var(--muted-foreground))] mb-1",children:"Workspace"}),e.jsx("div",{className:"font-medium text-sm text-[hsl(var(--foreground))]",children:d==null?void 0:d.name}),(d==null?void 0:d.goal)&&e.jsx("div",{className:"text-xs text-[hsl(var(--muted-foreground))] mt-0.5",children:d.goal})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium text-[hsl(var(--foreground))] mb-1.5",children:"Project Name"}),e.jsx("input",{value:v,onChange:s=>O(s.target.value),placeholder:"Enter project name",className:"w-full px-3 py-2 rounded-md border border-[hsl(var(--border))] bg-[hsl(var(--background))] text-sm focus:outline-none focus:ring-1 focus:ring-[hsl(var(--ring))]"})]}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"text-sm font-medium text-[hsl(var(--foreground))] mb-2",children:["Roles (",c.size,")"]}),e.jsx("div",{className:"space-y-2",children:Array.from(c.values()).map(s=>{const a=j.find(r=>r.id===s.role_id),t=h.find(r=>r.id===s.runtime_id);return e.jsxs("div",{className:"flex items-center justify-between border border-[hsl(var(--border))] rounded-lg p-3 text-sm",children:[e.jsx("span",{className:"font-medium text-[hsl(var(--foreground))]",children:(a==null?void 0:a.name)||s.role_id}),e.jsxs("span",{className:"text-[hsl(var(--muted-foreground))] text-xs",children:["Runtime: ",(t==null?void 0:t.name)||"-"," · Headcount: ",e.jsx("span",{className:"font-mono",children:s.headcount})]})]},s.role_id)})})]}),e.jsx("div",{className:"mb-4",children:e.jsxs("button",{onClick:async()=>{try{await b("/templates",{name:v||"Untitled Template",roles:Array.from(c.values()),workspace_id:o}),n(""),alert("Template saved!")}catch(s){n(s.message)}},className:"inline-flex items-center gap-1.5 text-sm text-[hsl(var(--primary))] hover:underline",children:[e.jsx(ae,{className:"w-3.5 h-3.5"}),"Save as Template"]})}),e.jsxs("div",{className:"flex justify-between mt-8",children:[e.jsxs("button",{onClick:()=>{n(""),m(2)},className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm text-[hsl(var(--muted-foreground))] hover:text-[hsl(var(--foreground))] transition-colors",children:[e.jsx(G,{className:"w-3.5 h-3.5"}),"Back"]}),e.jsxs("button",{onClick:Z,disabled:k,className:"inline-flex items-center gap-1.5 px-4 py-2 rounded-md bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))] text-sm font-medium hover:opacity-90 transition-opacity disabled:opacity-50",children:[e.jsx(T,{className:"w-3.5 h-3.5"}),k?"Launching...":"Launch"]})]})]})]})})]})}export{me as default};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
var De=Object.defineProperty;var Ze=(u,e,t)=>e in u?De(u,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):u[e]=t;var w=(u,e,t)=>Ze(u,typeof e!="symbol"?e+"":e,t);import{z as x,s as K,x as He,v as h,N as Oe}from"./index-C7kx39S9.js";import{u as ve}from"./useEventStream-DXt2Hmei.js";function ie(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let E=ie();function Re(u){E=u}const O={exec:()=>null};function b(u,e=""){let t=typeof u=="string"?u:u.source;const n={replace:(r,s)=>{let i=typeof s=="string"?s:s.source;return i=i.replace(R.caret,"$1"),t=t.replace(r,i),n},getRegex:()=>new RegExp(t,e)};return n}const R={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:u=>new RegExp(`^( {0,3}${u})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:u=>new RegExp(`^ {0,${Math.min(3,u-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:u=>new RegExp(`^ {0,${Math.min(3,u-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:u=>new RegExp(`^ {0,${Math.min(3,u-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:u=>new RegExp(`^ {0,${Math.min(3,u-1)}}#`),htmlBeginRegex:u=>new RegExp(`^ {0,${Math.min(3,u-1)}}<(?:[a-z].*>|!--)`,"i")},Ge=/^(?:[ \t]*(?:\n|$))+/,Qe=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,We=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Q=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Fe=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,le=/(?:[*+-]|\d{1,9}[.)])/,je=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Te=b(je).replace(/bull/g,le).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Ue=b(je).replace(/bull/g,le).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),ae=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Xe=/^[^\n]+/,oe=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Ke=b(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",oe).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Ve=b(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,le).getRegex(),ee="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",ce=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Je=b("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",ce).replace("tag",ee).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ce=b(ae).replace("hr",Q).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ee).getRegex(),Ye=b(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Ce).getRegex(),he={blockquote:Ye,code:Qe,def:Ke,fences:We,heading:Fe,hr:Q,html:Je,lheading:Te,list:Ve,newline:Ge,paragraph:Ce,table:O,text:Xe},be=b("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Q).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ee).getRegex(),et={...he,lheading:Ue,table:be,paragraph:b(ae).replace("hr",Q).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",be).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ee).getRegex()},tt={...he,html:b(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ce).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:O,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:b(ae).replace("hr",Q).replace("heading",` *#{1,6} *[^
|
|
2
|
+
]`).replace("lheading",Te).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},nt=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,st=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ze=/^( {2,}|\\)\n(?!\s*$)/,rt=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,te=/[\p{P}\p{S}]/u,ue=/[\s\p{P}\p{S}]/u,Ae=/[^\s\p{P}\p{S}]/u,it=b(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,ue).getRegex(),_e=/(?!~)[\p{P}\p{S}]/u,lt=/(?!~)[\s\p{P}\p{S}]/u,at=/(?:[^\s\p{P}\p{S}]|~)/u,ot=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,Ne=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,ct=b(Ne,"u").replace(/punct/g,te).getRegex(),ht=b(Ne,"u").replace(/punct/g,_e).getRegex(),Le="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",ut=b(Le,"gu").replace(/notPunctSpace/g,Ae).replace(/punctSpace/g,ue).replace(/punct/g,te).getRegex(),pt=b(Le,"gu").replace(/notPunctSpace/g,at).replace(/punctSpace/g,lt).replace(/punct/g,_e).getRegex(),dt=b("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Ae).replace(/punctSpace/g,ue).replace(/punct/g,te).getRegex(),ft=b(/\\(punct)/,"gu").replace(/punct/g,te).getRegex(),gt=b(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),mt=b(ce).replace("(?:-->|$)","-->").getRegex(),xt=b("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",mt).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),V=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,kt=b(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",V).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Ee=b(/^!?\[(label)\]\[(ref)\]/).replace("label",V).replace("ref",oe).getRegex(),Ie=b(/^!?\[(ref)\](?:\[\])?/).replace("ref",oe).getRegex(),bt=b("reflink|nolink(?!\\()","g").replace("reflink",Ee).replace("nolink",Ie).getRegex(),pe={_backpedal:O,anyPunctuation:ft,autolink:gt,blockSkip:ot,br:ze,code:st,del:O,emStrongLDelim:ct,emStrongRDelimAst:ut,emStrongRDelimUnd:dt,escape:nt,link:kt,nolink:Ie,punctuation:it,reflink:Ee,reflinkSearch:bt,tag:xt,text:rt,url:O},wt={...pe,link:b(/^!?\[(label)\]\((.*?)\)/).replace("label",V).getRegex(),reflink:b(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",V).getRegex()},re={...pe,emStrongRDelimAst:pt,emStrongLDelim:ht,url:b(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},yt={...re,br:b(ze).replace("{2,}","*").getRegex(),text:b(re.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},X={normal:he,gfm:et,pedantic:tt},Z={normal:pe,gfm:re,breaks:yt,pedantic:wt},St={"&":"&","<":"<",">":">",'"':""","'":"'"},we=u=>St[u];function z(u,e){if(e){if(R.escapeTest.test(u))return u.replace(R.escapeReplace,we)}else if(R.escapeTestNoEncode.test(u))return u.replace(R.escapeReplaceNoEncode,we);return u}function ye(u){try{u=encodeURI(u).replace(R.percentDecode,"%")}catch{return null}return u}function Se(u,e){var s;const t=u.replace(R.findPipe,(i,l,c)=>{let o=!1,a=l;for(;--a>=0&&c[a]==="\\";)o=!o;return o?"|":" |"}),n=t.split(R.splitPipe);let r=0;if(n[0].trim()||n.shift(),n.length>0&&!((s=n.at(-1))!=null&&s.trim())&&n.pop(),e)if(n.length>e)n.splice(e);else for(;n.length<e;)n.push("");for(;r<n.length;r++)n[r]=n[r].trim().replace(R.slashPipe,"|");return n}function H(u,e,t){const n=u.length;if(n===0)return"";let r=0;for(;r<n&&u.charAt(n-r-1)===e;)r++;return u.slice(0,n-r)}function $t(u,e){if(u.indexOf(e[1])===-1)return-1;let t=0;for(let n=0;n<u.length;n++)if(u[n]==="\\")n++;else if(u[n]===e[0])t++;else if(u[n]===e[1]&&(t--,t<0))return n;return-1}function $e(u,e,t,n,r){const s=e.href,i=e.title||null,l=u[1].replace(r.other.outputLinkReplace,"$1");if(u[0].charAt(0)!=="!"){n.state.inLink=!0;const c={type:"link",raw:t,href:s,title:i,text:l,tokens:n.inlineTokens(l)};return n.state.inLink=!1,c}return{type:"image",raw:t,href:s,title:i,text:l}}function vt(u,e,t){const n=u.match(t.other.indentCodeCompensation);if(n===null)return e;const r=n[1];return e.split(`
|
|
3
|
+
`).map(s=>{const i=s.match(t.other.beginningSpace);if(i===null)return s;const[l]=i;return l.length>=r.length?s.slice(r.length):s}).join(`
|
|
4
|
+
`)}class J{constructor(e){w(this,"options");w(this,"rules");w(this,"lexer");this.options=e||E}space(e){const t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){const t=this.rules.block.code.exec(e);if(t){const n=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?n:H(n,`
|
|
5
|
+
`)}}}fences(e){const t=this.rules.block.fences.exec(e);if(t){const n=t[0],r=vt(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:r}}}heading(e){const t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){const r=H(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){const t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:H(t[0],`
|
|
6
|
+
`)}}blockquote(e){const t=this.rules.block.blockquote.exec(e);if(t){let n=H(t[0],`
|
|
7
|
+
`).split(`
|
|
8
|
+
`),r="",s="";const i=[];for(;n.length>0;){let l=!1;const c=[];let o;for(o=0;o<n.length;o++)if(this.rules.other.blockquoteStart.test(n[o]))c.push(n[o]),l=!0;else if(!l)c.push(n[o]);else break;n=n.slice(o);const a=c.join(`
|
|
9
|
+
`),g=a.replace(this.rules.other.blockquoteSetextReplace,`
|
|
10
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
|
|
11
|
+
${a}`:a,s=s?`${s}
|
|
12
|
+
${g}`:g;const d=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(g,i,!0),this.lexer.state.top=d,n.length===0)break;const f=i.at(-1);if((f==null?void 0:f.type)==="code")break;if((f==null?void 0:f.type)==="blockquote"){const y=f,m=y.raw+`
|
|
13
|
+
`+n.join(`
|
|
14
|
+
`),$=this.blockquote(m);i[i.length-1]=$,r=r.substring(0,r.length-y.raw.length)+$.raw,s=s.substring(0,s.length-y.text.length)+$.text;break}else if((f==null?void 0:f.type)==="list"){const y=f,m=y.raw+`
|
|
15
|
+
`+n.join(`
|
|
16
|
+
`),$=this.list(m);i[i.length-1]=$,r=r.substring(0,r.length-f.raw.length)+$.raw,s=s.substring(0,s.length-y.raw.length)+$.raw,n=m.substring(i.at(-1).raw.length).split(`
|
|
17
|
+
`);continue}}return{type:"blockquote",raw:r,tokens:i,text:s}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim();const r=n.length>1,s={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");const i=this.rules.other.listItemRegex(n);let l=!1;for(;e;){let o=!1,a="",g="";if(!(t=i.exec(e))||this.rules.block.hr.test(e))break;a=t[0],e=e.substring(a.length);let d=t[2].split(`
|
|
18
|
+
`,1)[0].replace(this.rules.other.listReplaceTabs,I=>" ".repeat(3*I.length)),f=e.split(`
|
|
19
|
+
`,1)[0],y=!d.trim(),m=0;if(this.options.pedantic?(m=2,g=d.trimStart()):y?m=t[1].length+1:(m=t[2].search(this.rules.other.nonSpaceChar),m=m>4?1:m,g=d.slice(m),m+=t[1].length),y&&this.rules.other.blankLine.test(f)&&(a+=f+`
|
|
20
|
+
`,e=e.substring(f.length+1),o=!0),!o){const I=this.rules.other.nextBulletRegex(m),F=this.rules.other.hrRegex(m),q=this.rules.other.fencesBeginRegex(m),D=this.rules.other.headingBeginRegex(m),N=this.rules.other.htmlBeginRegex(m);for(;e;){const B=e.split(`
|
|
21
|
+
`,1)[0];let _;if(f=B,this.options.pedantic?(f=f.replace(this.rules.other.listReplaceNesting," "),_=f):_=f.replace(this.rules.other.tabCharGlobal," "),q.test(f)||D.test(f)||N.test(f)||I.test(f)||F.test(f))break;if(_.search(this.rules.other.nonSpaceChar)>=m||!f.trim())g+=`
|
|
22
|
+
`+_.slice(m);else{if(y||d.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||q.test(d)||D.test(d)||F.test(d))break;g+=`
|
|
23
|
+
`+f}!y&&!f.trim()&&(y=!0),a+=B+`
|
|
24
|
+
`,e=e.substring(B.length+1),d=_.slice(m)}}s.loose||(l?s.loose=!0:this.rules.other.doubleBlankLine.test(a)&&(l=!0));let $=null,W;this.options.gfm&&($=this.rules.other.listIsTask.exec(g),$&&(W=$[0]!=="[ ] ",g=g.replace(this.rules.other.listReplaceTask,""))),s.items.push({type:"list_item",raw:a,task:!!$,checked:W,loose:!1,text:g,tokens:[]}),s.raw+=a}const c=s.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;s.raw=s.raw.trimEnd();for(let o=0;o<s.items.length;o++)if(this.lexer.state.top=!1,s.items[o].tokens=this.lexer.blockTokens(s.items[o].text,[]),!s.loose){const a=s.items[o].tokens.filter(d=>d.type==="space"),g=a.length>0&&a.some(d=>this.rules.other.anyLine.test(d.raw));s.loose=g}if(s.loose)for(let o=0;o<s.items.length;o++)s.items[o].loose=!0;return s}}html(e){const t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){const t=this.rules.block.def.exec(e);if(t){const n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",s=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:t[0],href:r,title:s}}}table(e){var l;const t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;const n=Se(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=(l=t[3])!=null&&l.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
25
|
+
`):[],i={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(const c of r)this.rules.other.tableAlignRight.test(c)?i.align.push("right"):this.rules.other.tableAlignCenter.test(c)?i.align.push("center"):this.rules.other.tableAlignLeft.test(c)?i.align.push("left"):i.align.push(null);for(let c=0;c<n.length;c++)i.header.push({text:n[c],tokens:this.lexer.inline(n[c]),header:!0,align:i.align[c]});for(const c of s)i.rows.push(Se(c,i.header.length).map((o,a)=>({text:o,tokens:this.lexer.inline(o),header:!1,align:i.align[a]})));return i}}lheading(e){const t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){const t=this.rules.block.paragraph.exec(e);if(t){const n=t[1].charAt(t[1].length-1)===`
|
|
26
|
+
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){const t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){const t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){const t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){const t=this.rules.inline.link.exec(e);if(t){const n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;const i=H(n.slice(0,-1),"\\");if((n.length-i.length)%2===0)return}else{const i=$t(t[2],"()");if(i>-1){const c=(t[0].indexOf("!")===0?5:4)+t[1].length+i;t[2]=t[2].substring(0,i),t[0]=t[0].substring(0,c).trim(),t[3]=""}}let r=t[2],s="";if(this.options.pedantic){const i=this.rules.other.pedanticHrefTitle.exec(r);i&&(r=i[1],s=i[3])}else s=t[3]?t[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),$e(t,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:s&&s.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){const r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),s=t[r.toLowerCase()];if(!s){const i=n[0].charAt(0);return{type:"text",raw:i,text:i}}return $e(n,s,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!r||r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))return;if(!(r[1]||r[2]||"")||!n||this.rules.inline.punctuation.exec(n)){const i=[...r[0]].length-1;let l,c,o=i,a=0;const g=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(g.lastIndex=0,t=t.slice(-1*e.length+i);(r=g.exec(t))!=null;){if(l=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!l)continue;if(c=[...l].length,r[3]||r[4]){o+=c;continue}else if((r[5]||r[6])&&i%3&&!((i+c)%3)){a+=c;continue}if(o-=c,o>0)continue;c=Math.min(c,c+o+a);const d=[...r[0]][0].length,f=e.slice(0,i+r.index+d+c);if(Math.min(i,c)%2){const m=f.slice(1,-1);return{type:"em",raw:f,text:m,tokens:this.lexer.inlineTokens(m)}}const y=f.slice(2,-2);return{type:"strong",raw:f,text:y,tokens:this.lexer.inlineTokens(y)}}}}codespan(e){const t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," ");const r=this.rules.other.nonSpaceChar.test(n),s=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&s&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){const t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){const t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){const t=this.rules.inline.autolink.exec(e);if(t){let n,r;return t[2]==="@"?(n=t[1],r="mailto:"+n):(n=t[1],r=n),{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(e){var n;let t;if(t=this.rules.inline.url.exec(e)){let r,s;if(t[2]==="@")r=t[0],s="mailto:"+r;else{let i;do i=t[0],t[0]=((n=this.rules.inline._backpedal.exec(t[0]))==null?void 0:n[0])??"";while(i!==t[0]);r=t[0],t[1]==="www."?s="http://"+t[0]:s=t[0]}return{type:"link",raw:t[0],text:r,href:s,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(e){const t=this.rules.inline.text.exec(e);if(t){const n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}}class T{constructor(e){w(this,"tokens");w(this,"options");w(this,"state");w(this,"tokenizer");w(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=e||E,this.options.tokenizer=this.options.tokenizer||new J,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const t={other:R,block:X.normal,inline:Z.normal};this.options.pedantic?(t.block=X.pedantic,t.inline=Z.pedantic):this.options.gfm&&(t.block=X.gfm,this.options.breaks?t.inline=Z.breaks:t.inline=Z.gfm),this.tokenizer.rules=t}static get rules(){return{block:X,inline:Z}}static lex(e,t){return new T(t).lex(e)}static lexInline(e,t){return new T(t).inlineTokens(e)}lex(e){e=e.replace(R.carriageReturn,`
|
|
27
|
+
`),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){const n=this.inlineQueue[t];this.inlineTokens(n.src,n.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){var r,s,i;for(this.options.pedantic&&(e=e.replace(R.tabCharGlobal," ").replace(R.spaceLine,""));e;){let l;if((s=(r=this.options.extensions)==null?void 0:r.block)!=null&&s.some(o=>(l=o.call({lexer:this},e,t))?(e=e.substring(l.raw.length),t.push(l),!0):!1))continue;if(l=this.tokenizer.space(e)){e=e.substring(l.raw.length);const o=t.at(-1);l.raw.length===1&&o!==void 0?o.raw+=`
|
|
28
|
+
`:t.push(l);continue}if(l=this.tokenizer.code(e)){e=e.substring(l.raw.length);const o=t.at(-1);(o==null?void 0:o.type)==="paragraph"||(o==null?void 0:o.type)==="text"?(o.raw+=`
|
|
29
|
+
`+l.raw,o.text+=`
|
|
30
|
+
`+l.text,this.inlineQueue.at(-1).src=o.text):t.push(l);continue}if(l=this.tokenizer.fences(e)){e=e.substring(l.raw.length),t.push(l);continue}if(l=this.tokenizer.heading(e)){e=e.substring(l.raw.length),t.push(l);continue}if(l=this.tokenizer.hr(e)){e=e.substring(l.raw.length),t.push(l);continue}if(l=this.tokenizer.blockquote(e)){e=e.substring(l.raw.length),t.push(l);continue}if(l=this.tokenizer.list(e)){e=e.substring(l.raw.length),t.push(l);continue}if(l=this.tokenizer.html(e)){e=e.substring(l.raw.length),t.push(l);continue}if(l=this.tokenizer.def(e)){e=e.substring(l.raw.length);const o=t.at(-1);(o==null?void 0:o.type)==="paragraph"||(o==null?void 0:o.type)==="text"?(o.raw+=`
|
|
31
|
+
`+l.raw,o.text+=`
|
|
32
|
+
`+l.raw,this.inlineQueue.at(-1).src=o.text):this.tokens.links[l.tag]||(this.tokens.links[l.tag]={href:l.href,title:l.title});continue}if(l=this.tokenizer.table(e)){e=e.substring(l.raw.length),t.push(l);continue}if(l=this.tokenizer.lheading(e)){e=e.substring(l.raw.length),t.push(l);continue}let c=e;if((i=this.options.extensions)!=null&&i.startBlock){let o=1/0;const a=e.slice(1);let g;this.options.extensions.startBlock.forEach(d=>{g=d.call({lexer:this},a),typeof g=="number"&&g>=0&&(o=Math.min(o,g))}),o<1/0&&o>=0&&(c=e.substring(0,o+1))}if(this.state.top&&(l=this.tokenizer.paragraph(c))){const o=t.at(-1);n&&(o==null?void 0:o.type)==="paragraph"?(o.raw+=`
|
|
33
|
+
`+l.raw,o.text+=`
|
|
34
|
+
`+l.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):t.push(l),n=c.length!==e.length,e=e.substring(l.raw.length);continue}if(l=this.tokenizer.text(e)){e=e.substring(l.raw.length);const o=t.at(-1);(o==null?void 0:o.type)==="text"?(o.raw+=`
|
|
35
|
+
`+l.raw,o.text+=`
|
|
36
|
+
`+l.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):t.push(l);continue}if(e){const o="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(o);break}else throw new Error(o)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){var l,c,o;let n=e,r=null;if(this.tokens.links){const a=Object.keys(this.tokens.links);if(a.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!=null;)a.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(n=n.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)n=n.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,r.index)+"++"+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let s=!1,i="";for(;e;){s||(i=""),s=!1;let a;if((c=(l=this.options.extensions)==null?void 0:l.inline)!=null&&c.some(d=>(a=d.call({lexer:this},e,t))?(e=e.substring(a.raw.length),t.push(a),!0):!1))continue;if(a=this.tokenizer.escape(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.tag(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.link(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(a.raw.length);const d=t.at(-1);a.type==="text"&&(d==null?void 0:d.type)==="text"?(d.raw+=a.raw,d.text+=a.text):t.push(a);continue}if(a=this.tokenizer.emStrong(e,n,i)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.codespan(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.br(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.del(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.autolink(e)){e=e.substring(a.raw.length),t.push(a);continue}if(!this.state.inLink&&(a=this.tokenizer.url(e))){e=e.substring(a.raw.length),t.push(a);continue}let g=e;if((o=this.options.extensions)!=null&&o.startInline){let d=1/0;const f=e.slice(1);let y;this.options.extensions.startInline.forEach(m=>{y=m.call({lexer:this},f),typeof y=="number"&&y>=0&&(d=Math.min(d,y))}),d<1/0&&d>=0&&(g=e.substring(0,d+1))}if(a=this.tokenizer.inlineText(g)){e=e.substring(a.raw.length),a.raw.slice(-1)!=="_"&&(i=a.raw.slice(-1)),s=!0;const d=t.at(-1);(d==null?void 0:d.type)==="text"?(d.raw+=a.raw,d.text+=a.text):t.push(a);continue}if(e){const d="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(d);break}else throw new Error(d)}}return t}}class Y{constructor(e){w(this,"options");w(this,"parser");this.options=e||E}space(e){return""}code({text:e,lang:t,escaped:n}){var i;const r=(i=(t||"").match(R.notSpaceStart))==null?void 0:i[0],s=e.replace(R.endingNewline,"")+`
|
|
37
|
+
`;return r?'<pre><code class="language-'+z(r)+'">'+(n?s:z(s,!0))+`</code></pre>
|
|
38
|
+
`:"<pre><code>"+(n?s:z(s,!0))+`</code></pre>
|
|
39
|
+
`}blockquote({tokens:e}){return`<blockquote>
|
|
40
|
+
${this.parser.parse(e)}</blockquote>
|
|
41
|
+
`}html({text:e}){return e}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
42
|
+
`}hr(e){return`<hr>
|
|
43
|
+
`}list(e){const t=e.ordered,n=e.start;let r="";for(let l=0;l<e.items.length;l++){const c=e.items[l];r+=this.listitem(c)}const s=t?"ol":"ul",i=t&&n!==1?' start="'+n+'"':"";return"<"+s+i+`>
|
|
44
|
+
`+r+"</"+s+`>
|
|
45
|
+
`}listitem(e){var n;let t="";if(e.task){const r=this.checkbox({checked:!!e.checked});e.loose?((n=e.tokens[0])==null?void 0:n.type)==="paragraph"?(e.tokens[0].text=r+" "+e.tokens[0].text,e.tokens[0].tokens&&e.tokens[0].tokens.length>0&&e.tokens[0].tokens[0].type==="text"&&(e.tokens[0].tokens[0].text=r+" "+z(e.tokens[0].tokens[0].text),e.tokens[0].tokens[0].escaped=!0)):e.tokens.unshift({type:"text",raw:r+" ",text:r+" ",escaped:!0}):t+=r+" "}return t+=this.parser.parse(e.tokens,!!e.loose),`<li>${t}</li>
|
|
46
|
+
`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
47
|
+
`}table(e){let t="",n="";for(let s=0;s<e.header.length;s++)n+=this.tablecell(e.header[s]);t+=this.tablerow({text:n});let r="";for(let s=0;s<e.rows.length;s++){const i=e.rows[s];n="";for(let l=0;l<i.length;l++)n+=this.tablecell(i[l]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
|
|
48
|
+
<thead>
|
|
49
|
+
`+t+`</thead>
|
|
50
|
+
`+r+`</table>
|
|
51
|
+
`}tablerow({text:e}){return`<tr>
|
|
52
|
+
${e}</tr>
|
|
53
|
+
`}tablecell(e){const t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
54
|
+
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${z(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){const r=this.parser.parseInline(n),s=ye(e);if(s===null)return r;e=s;let i='<a href="'+e+'"';return t&&(i+=' title="'+z(t)+'"'),i+=">"+r+"</a>",i}image({href:e,title:t,text:n}){const r=ye(e);if(r===null)return z(n);e=r;let s=`<img src="${e}" alt="${n}"`;return t&&(s+=` title="${z(t)}"`),s+=">",s}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:z(e.text)}}class de{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}}class C{constructor(e){w(this,"options");w(this,"renderer");w(this,"textRenderer");this.options=e||E,this.options.renderer=this.options.renderer||new Y,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new de}static parse(e,t){return new C(t).parse(e)}static parseInline(e,t){return new C(t).parseInline(e)}parse(e,t=!0){var r,s;let n="";for(let i=0;i<e.length;i++){const l=e[i];if((s=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&s[l.type]){const o=l,a=this.options.extensions.renderers[o.type].call({parser:this},o);if(a!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(o.type)){n+=a||"";continue}}const c=l;switch(c.type){case"space":{n+=this.renderer.space(c);continue}case"hr":{n+=this.renderer.hr(c);continue}case"heading":{n+=this.renderer.heading(c);continue}case"code":{n+=this.renderer.code(c);continue}case"table":{n+=this.renderer.table(c);continue}case"blockquote":{n+=this.renderer.blockquote(c);continue}case"list":{n+=this.renderer.list(c);continue}case"html":{n+=this.renderer.html(c);continue}case"paragraph":{n+=this.renderer.paragraph(c);continue}case"text":{let o=c,a=this.renderer.text(o);for(;i+1<e.length&&e[i+1].type==="text";)o=e[++i],a+=`
|
|
55
|
+
`+this.renderer.text(o);t?n+=this.renderer.paragraph({type:"paragraph",raw:a,text:a,tokens:[{type:"text",raw:a,text:a,escaped:!0}]}):n+=a;continue}default:{const o='Token with "'+c.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}parseInline(e,t=this.renderer){var r,s;let n="";for(let i=0;i<e.length;i++){const l=e[i];if((s=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&s[l.type]){const o=this.options.extensions.renderers[l.type].call({parser:this},l);if(o!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(l.type)){n+=o||"";continue}}const c=l;switch(c.type){case"escape":{n+=t.text(c);break}case"html":{n+=t.html(c);break}case"link":{n+=t.link(c);break}case"image":{n+=t.image(c);break}case"strong":{n+=t.strong(c);break}case"em":{n+=t.em(c);break}case"codespan":{n+=t.codespan(c);break}case"br":{n+=t.br(c);break}case"del":{n+=t.del(c);break}case"text":{n+=t.text(c);break}default:{const o='Token with "'+c.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}}class G{constructor(e){w(this,"options");w(this,"block");this.options=e||E}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}provideLexer(){return this.block?T.lex:T.lexInline}provideParser(){return this.block?C.parse:C.parseInline}}w(G,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class Rt{constructor(...e){w(this,"defaults",ie());w(this,"options",this.setOptions);w(this,"parse",this.parseMarkdown(!0));w(this,"parseInline",this.parseMarkdown(!1));w(this,"Parser",C);w(this,"Renderer",Y);w(this,"TextRenderer",de);w(this,"Lexer",T);w(this,"Tokenizer",J);w(this,"Hooks",G);this.use(...e)}walkTokens(e,t){var r,s;let n=[];for(const i of e)switch(n=n.concat(t.call(this,i)),i.type){case"table":{const l=i;for(const c of l.header)n=n.concat(this.walkTokens(c.tokens,t));for(const c of l.rows)for(const o of c)n=n.concat(this.walkTokens(o.tokens,t));break}case"list":{const l=i;n=n.concat(this.walkTokens(l.items,t));break}default:{const l=i;(s=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&s[l.type]?this.defaults.extensions.childTokens[l.type].forEach(c=>{const o=l[c].flat(1/0);n=n.concat(this.walkTokens(o,t))}):l.tokens&&(n=n.concat(this.walkTokens(l.tokens,t)))}}return n}use(...e){const t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{const r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(s=>{if(!s.name)throw new Error("extension name required");if("renderer"in s){const i=t.renderers[s.name];i?t.renderers[s.name]=function(...l){let c=s.renderer.apply(this,l);return c===!1&&(c=i.apply(this,l)),c}:t.renderers[s.name]=s.renderer}if("tokenizer"in s){if(!s.level||s.level!=="block"&&s.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const i=t[s.level];i?i.unshift(s.tokenizer):t[s.level]=[s.tokenizer],s.start&&(s.level==="block"?t.startBlock?t.startBlock.push(s.start):t.startBlock=[s.start]:s.level==="inline"&&(t.startInline?t.startInline.push(s.start):t.startInline=[s.start]))}"childTokens"in s&&s.childTokens&&(t.childTokens[s.name]=s.childTokens)}),r.extensions=t),n.renderer){const s=this.defaults.renderer||new Y(this.defaults);for(const i in n.renderer){if(!(i in s))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;const l=i,c=n.renderer[l],o=s[l];s[l]=(...a)=>{let g=c.apply(s,a);return g===!1&&(g=o.apply(s,a)),g||""}}r.renderer=s}if(n.tokenizer){const s=this.defaults.tokenizer||new J(this.defaults);for(const i in n.tokenizer){if(!(i in s))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;const l=i,c=n.tokenizer[l],o=s[l];s[l]=(...a)=>{let g=c.apply(s,a);return g===!1&&(g=o.apply(s,a)),g}}r.tokenizer=s}if(n.hooks){const s=this.defaults.hooks||new G;for(const i in n.hooks){if(!(i in s))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;const l=i,c=n.hooks[l],o=s[l];G.passThroughHooks.has(i)?s[l]=a=>{if(this.defaults.async)return Promise.resolve(c.call(s,a)).then(d=>o.call(s,d));const g=c.call(s,a);return o.call(s,g)}:s[l]=(...a)=>{let g=c.apply(s,a);return g===!1&&(g=o.apply(s,a)),g}}r.hooks=s}if(n.walkTokens){const s=this.defaults.walkTokens,i=n.walkTokens;r.walkTokens=function(l){let c=[];return c.push(i.call(this,l)),s&&(c=c.concat(s.call(this,l))),c}}this.defaults={...this.defaults,...r}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return T.lex(e,t??this.defaults)}parser(e,t){return C.parse(e,t??this.defaults)}parseMarkdown(e){return(n,r)=>{const s={...r},i={...this.defaults,...s},l=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&s.async===!1)return l(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof n>"u"||n===null)return l(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return l(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));i.hooks&&(i.hooks.options=i,i.hooks.block=e);const c=i.hooks?i.hooks.provideLexer():e?T.lex:T.lexInline,o=i.hooks?i.hooks.provideParser():e?C.parse:C.parseInline;if(i.async)return Promise.resolve(i.hooks?i.hooks.preprocess(n):n).then(a=>c(a,i)).then(a=>i.hooks?i.hooks.processAllTokens(a):a).then(a=>i.walkTokens?Promise.all(this.walkTokens(a,i.walkTokens)).then(()=>a):a).then(a=>o(a,i)).then(a=>i.hooks?i.hooks.postprocess(a):a).catch(l);try{i.hooks&&(n=i.hooks.preprocess(n));let a=c(n,i);i.hooks&&(a=i.hooks.processAllTokens(a)),i.walkTokens&&this.walkTokens(a,i.walkTokens);let g=o(a,i);return i.hooks&&(g=i.hooks.postprocess(g)),g}catch(a){return l(a)}}}onError(e,t){return n=>{if(n.message+=`
|
|
56
|
+
Please report this to https://github.com/markedjs/marked.`,e){const r="<p>An error occurred:</p><pre>"+z(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}}const L=new Rt;function k(u,e){return L.parse(u,e)}k.options=k.setOptions=function(u){return L.setOptions(u),k.defaults=L.defaults,Re(k.defaults),k};k.getDefaults=ie;k.defaults=E;k.use=function(...u){return L.use(...u),k.defaults=L.defaults,Re(k.defaults),k};k.walkTokens=function(u,e){return L.walkTokens(u,e)};k.parseInline=L.parseInline;k.Parser=C;k.parser=C.parse;k.Renderer=Y;k.TextRenderer=de;k.Lexer=T;k.lexer=T.lex;k.Tokenizer=J;k.Hooks=G;k.parse=k;k.options;k.setOptions;k.use;k.walkTokens;k.parseInline;C.parse;T.lex;function jt(u){const[e,t]=x.useState([]),[n,r]=x.useState(!0),[s,i]=x.useState(!1),[l,c]=x.useState(""),o=x.useRef(new Set),{lastEvent:a}=ve("chat.*");x.useEffect(()=>{u&&(r(!0),K(`/chat/messages?workspace_id=${u}&limit=50`).then(d=>{o.current=new Set(d.map(f=>f.id)),t(d),c("")}).catch(d=>c(d.message)).finally(()=>r(!1)))},[u]),x.useEffect(()=>{if(!a||a.type!=="chat.message")return;const d=a.payload;d.workspace_id===u&&(d.sender_type==="agent"&&i(!1),K(`/chat/messages?workspace_id=${u}&limit=50`).then(f=>{o.current=new Set(f.map(y=>y.id)),t(f)}).catch(()=>{}))},[a,u]);const g=x.useCallback(async d=>{i(!0);try{const f=await He("/chat/messages",{workspace_id:u,content:d});return o.current.has(f.id)||(o.current.add(f.id),t(y=>[...y,f])),f}catch(f){throw i(!1),f}},[u]);return{messages:e,sendMessage:g,loading:n,thinking:s,error:l}}function Tt(u,e,t){const n=e?Array.from(e):[],r=new Set(n);return r.size===0?[]:t&&t.length>0?t.filter(s=>r.has(s.id)).map(s=>{const l=u.filter(c=>c.role_id===s.id&&c.status!=="offline")[0];return{id:s.id,name:s.name,status:(l==null?void 0:l.status)||"offline",role_id:s.id}}):u.filter(s=>s.status==="offline"?!1:!!s.role_id&&r.has(s.role_id)).map(s=>({id:s.id,name:s.name,status:s.status,role_id:s.role_id}))}function Ct(u,e){const t=u.slice(0,e),n=t.lastIndexOf("@");if(n<0)return null;const r=n>0?t[n-1]:"";if(r&&!/\s/.test(r))return null;const s=t.slice(n+1);return/\s/.test(s)?null:s}function zt(u,e,t){const n=u.slice(0,e),r=n.lastIndexOf("@");if(r<0)return u;const s=r>0?n[r-1]:"";if(s&&!/\s/.test(s))return u;const i=u.slice(e);return`${n.slice(0,r)}@${t} ${i.replace(/^\s+/,"")}`}k.setOptions({breaks:!0,gfm:!0});function At({workspaceId:u}){const{messages:e,sendMessage:t,loading:n,thinking:r,error:s}=jt(u),[i,l]=x.useState(""),[c,o]=x.useState(!1),[a,g]=x.useState(!1),[d,f]=x.useState(""),[y,m]=x.useState(0),[$,W]=x.useState([]),[I,F]=x.useState([]),[q,D]=x.useState(!0),N=x.useRef(null),B=x.useRef(null),_=x.useRef(null),{lastEvent:fe}=ve("agent.*,role.*"),M=x.useCallback(()=>Promise.all([K(`/workspaces/${u}/roles`),K("/agents")]).then(([p,S])=>{W(Array.isArray(p)?p:[]),F(Array.isArray(S)?S:[])}).catch(()=>{}),[u]);x.useEffect(()=>{M()},[M]),x.useEffect(()=>{e.length&&M()},[e.length,M]),x.useEffect(()=>{fe&&M()},[fe,M]);const ge=x.useMemo(()=>new Set($.map(p=>p.id)),[$]),me=x.useMemo(()=>Tt(I,ge,$),[I,ge,$]),U=x.useMemo(()=>$.filter(p=>p.name.toLowerCase()!=="chief"),[$]),Be=x.useMemo(()=>U.map(p=>p.name),[U]),j=x.useMemo(()=>U.filter(p=>p.name.toLowerCase().includes(d.toLowerCase())),[U,d]);x.useEffect(()=>{var v;const p=_.current;if(!p)return;(p.scrollHeight-p.scrollTop-p.clientHeight<120||r)&&((v=B.current)==null||v.scrollIntoView({behavior:"smooth"}))},[e,r]);const xe=x.useCallback(()=>{const p=N.current;p&&(p.style.height="auto",p.style.height=Math.min(p.scrollHeight,160)+"px")},[]);x.useEffect(()=>{xe()},[i,xe]);const ne=j.length===0?0:Math.min(y,j.length-1),P=j[ne],Me=p=>{const S=p.target.value;l(S);const v=p.target.selectionStart||S.length,A=Ct(S,v);A!==null?(g(!0),f(A),m(0)):(g(!1),f(""),m(0))},se=p=>{var v,A;const S=((v=N.current)==null?void 0:v.selectionStart)||i.length;l(zt(i,S,p)),g(!1),f(""),m(0),(A=N.current)==null||A.focus()},ke=async()=>{const p=i.trim();if(!(!p||c)){o(!0),g(!1),m(0);try{await t(p),l("")}catch{}o(!1)}},Pe=p=>{if(a&&j.length>0&&(p.key==="ArrowDown"||p.key==="ArrowUp")){p.preventDefault(),m(S=>{const v=p.key==="ArrowDown"?1:-1;return(S+v+j.length)%j.length});return}if(a&&p.key==="Escape"){g(!1),m(0);return}if(a&&p.key==="Tab"&&j.length>0){p.preventDefault(),se((P==null?void 0:P.name)||j[0].name);return}if(p.key==="Enter"&&!p.shiftKey){if(a&&j.length>0){p.preventDefault(),se((P==null?void 0:P.name)||j[0].name);return}p.preventDefault(),ke()}},qe=x.useMemo(()=>{const p=[];let S="";for(const v of e){const A=new Date(v.created_at).toLocaleDateString("zh-CN",{month:"long",day:"numeric"});A!==S?(S=A,p.push({date:A,messages:[v]})):p[p.length-1].messages.push(v)}return p},[e]);return n?h.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:"var(--muted)"},children:h.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:"13px"},children:"加载中..."})}):h.jsxs("div",{className:"chat-panel",children:[h.jsxs("div",{className:"chat-main",children:[s&&h.jsxs("div",{className:"chat-error",children:[h.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[h.jsx("circle",{cx:"12",cy:"12",r:"10"}),h.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),h.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),s]}),h.jsxs("div",{className:"chat-messages",ref:_,children:[e.length===0&&h.jsxs("div",{className:"chat-empty",children:[h.jsx("div",{className:"chat-empty-icon",children:h.jsx("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:h.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),h.jsx("p",{className:"chat-empty-title",children:"开始对话"}),h.jsx("p",{className:"chat-empty-desc",children:"输入消息或 @ 提及角色来分配任务"})]}),qe.map(p=>h.jsxs("div",{children:[h.jsx("div",{className:"chat-date-divider",children:h.jsx("span",{children:p.date})}),p.messages.map(S=>h.jsx(Lt,{message:S,mentionNames:Be},S.id))]},p.date)),r&&h.jsx(_t,{}),h.jsx("div",{ref:B})]}),h.jsxs("div",{className:"chat-input-area",children:[a&&j.length>0&&h.jsxs("div",{className:"chat-mention-popup",role:"listbox",children:[h.jsx("div",{className:"chat-mention-header",children:"提及角色"}),j.map((p,S)=>{var v;return h.jsxs("button",{type:"button",role:"option",onClick:()=>se(p.name),onMouseEnter:()=>m(S),className:`chat-mention-item ${S===ne?"active":""}`,"aria-selected":S===ne,children:[h.jsx("span",{className:"chat-mention-avatar",children:(v=p.name[0])==null?void 0:v.toUpperCase()}),h.jsx("span",{className:"chat-mention-name",children:p.name})]},p.name)})]}),h.jsxs("div",{className:"chat-toolbar",children:[h.jsx("button",{className:"chat-tool-btn",title:"提及 @",onClick:()=>{var p;l(i+"@"),(p=N.current)==null||p.focus()},children:h.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[h.jsx("circle",{cx:"12",cy:"12",r:"4"}),h.jsx("path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-3.92 7.94"})]})}),h.jsx("button",{className:"chat-tool-btn",title:"表情",children:h.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[h.jsx("circle",{cx:"12",cy:"12",r:"10"}),h.jsx("path",{d:"M8 14s1.5 2 4 2 4-2 4-2"}),h.jsx("line",{x1:"9",y1:"9",x2:"9.01",y2:"9"}),h.jsx("line",{x1:"15",y1:"9",x2:"15.01",y2:"9"})]})}),h.jsx("button",{className:"chat-tool-btn",title:"附件",children:h.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:h.jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.49"})})}),h.jsx("div",{style:{flex:1}}),h.jsx("span",{className:"chat-input-hint",children:"Enter 发送,Shift+Enter 换行"})]}),h.jsxs("div",{className:"chat-input-wrapper",children:[h.jsx("textarea",{ref:N,value:i,onChange:Me,onKeyDown:Pe,placeholder:"输入消息... 使用 @ 提及角色",className:"chat-textarea",disabled:c,rows:1}),h.jsx("button",{className:`chat-send-btn ${i.trim()?"active":""}`,onClick:ke,disabled:!i.trim()||c,title:"发送",children:h.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[h.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),h.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]})]})]}),q&&h.jsxs("div",{className:"chat-members",children:[h.jsxs("div",{className:"chat-members-header",children:[h.jsx("span",{children:"成员"}),h.jsx("button",{className:"chat-tool-btn",onClick:()=>D(!1),title:"收起",children:h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:h.jsx("polyline",{points:"15 18 9 12 15 6"})})})]}),h.jsxs("div",{className:"chat-member-item",children:[h.jsx("div",{className:"chat-member-avatar you",children:"你"}),h.jsxs("div",{className:"chat-member-info",children:[h.jsx("span",{className:"chat-member-name",children:"你"}),h.jsx("span",{className:"chat-member-status online",children:"在线"})]})]}),h.jsx("div",{className:"chat-members-section",children:"角色"}),me.map(p=>{var S;return h.jsxs("div",{className:"chat-member-item",children:[h.jsx("div",{className:`chat-member-avatar ${p.status}`,children:(S=p.name[0])==null?void 0:S.toUpperCase()}),h.jsxs("div",{className:"chat-member-info",children:[h.jsx("span",{className:"chat-member-name",children:p.name}),h.jsx("span",{className:`chat-member-status ${p.status}`,children:p.status==="online"?"在线":p.status==="busy"?"忙碌":p.status==="idle"?"空闲":"离线"})]})]},p.id)}),me.length===0&&h.jsx("div",{className:"chat-members-empty",children:"暂无角色"})]}),!q&&h.jsx("button",{className:"chat-members-toggle",onClick:()=>D(!0),title:"显示成员",children:h.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[h.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),h.jsx("circle",{cx:"9",cy:"7",r:"4"}),h.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),h.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})})]})}function _t(){return h.jsxs("div",{className:"chat-msg-row",children:[h.jsx("div",{className:"chat-msg-avatar agent",children:h.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[h.jsx("path",{d:"M12 2a4 4 0 0 1 4 4v2H8V6a4 4 0 0 1 4-4z"}),h.jsx("rect",{x:"4",y:"8",width:"16",height:"12",rx:"2"}),h.jsx("circle",{cx:"9",cy:"14",r:"1"}),h.jsx("circle",{cx:"15",cy:"14",r:"1"})]})}),h.jsxs("div",{className:"chat-msg-body",children:[h.jsx("div",{className:"chat-msg-meta",children:h.jsx("span",{className:"chat-msg-sender",children:"Chief"})}),h.jsxs("div",{className:"chat-thinking",children:[h.jsx("span",{className:"chat-thinking-dot"}),h.jsx("span",{className:"chat-thinking-dot"}),h.jsx("span",{className:"chat-thinking-dot"})]})]})]})}function Nt(u,e){let t=u;for(const r of e){const s=new RegExp(`@${r}\\b`,"g");t=t.replace(s,`<span class="chat-mention-tag">@${r}</span>`)}return k.parse(t,{async:!1})}function Lt({message:u,mentionNames:e}){var s,i;const t=u.sender_type==="human",n=new Date(u.created_at).toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"}),r=x.useMemo(()=>Nt(u.content,e),[u.content,e]);return h.jsxs("div",{className:`chat-msg-row ${t?"human":"agent"}`,children:[h.jsx("div",{className:`chat-msg-avatar ${t?"human":"agent"}`,children:t?"你":((i=(s=u.sender_id)==null?void 0:s[0])==null?void 0:i.toUpperCase())||"A"}),h.jsxs("div",{className:"chat-msg-body",children:[h.jsxs("div",{className:"chat-msg-meta",children:[h.jsx("span",{className:"chat-msg-sender",children:t?"你":u.sender_id}),h.jsx("span",{className:"chat-msg-time",children:n})]}),h.jsx("div",{className:"chat-msg-content chat-markdown",dangerouslySetInnerHTML:{__html:r}})]})]})}function Mt(){const{id:u}=Oe();return u?h.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[h.jsx("div",{className:"h-[52px] border-b border-[hsl(var(--border))] flex items-center justify-between px-6 shrink-0 bg-[hsl(var(--card))/0.92] backdrop-blur-xl",children:h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx("h1",{className:"text-lg font-semibold tracking-tight",children:"对话"}),h.jsxs("span",{className:"text-xs text-[hsl(var(--muted-foreground))] font-mono px-2 py-0.5 rounded bg-[hsl(var(--foreground))/0.04]",children:["workspace/",u]})]})}),h.jsx("div",{className:"flex-1 overflow-hidden relative",children:h.jsx(At,{workspaceId:u})})]}):null}export{Mt as default};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{z as c,v as r,k as $,N as V,L as A,s as N}from"./index-C7kx39S9.js";import{u as L}from"./useEventStream-DXt2Hmei.js";import{d as B,C as j,a as k,B as z}from"./badge-DDTUzWIi.js";function G(e,t=[]){let s=[];function l(m,u){const o=c.createContext(u);o.displayName=m+"Context";const n=s.length;s=[...s,u];const x=v=>{var T;const{scope:i,children:p,...d}=v,h=((T=i==null?void 0:i[e])==null?void 0:T[n])||o,O=c.useMemo(()=>d,Object.values(d));return r.jsx(h.Provider,{value:O,children:p})};x.displayName=m+"Provider";function f(v,i){var h;const p=((h=i==null?void 0:i[e])==null?void 0:h[n])||o,d=c.useContext(p);if(d)return d;if(u!==void 0)return u;throw new Error(`\`${v}\` must be used within \`${m}\``)}return[x,f]}const a=()=>{const m=s.map(u=>c.createContext(u));return function(o){const n=(o==null?void 0:o[e])||m;return c.useMemo(()=>({[`__scope${e}`]:{...o,[e]:n}}),[o,n])}};return a.scopeName=e,[l,W(a,...t)]}function W(...e){const t=e[0];if(e.length===1)return t;const s=()=>{const l=e.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(m){const u=l.reduce((o,{useScope:n,scopeName:x})=>{const v=n(m)[`__scope${x}`];return{...o,...v}},{});return c.useMemo(()=>({[`__scope${t.scopeName}`]:u}),[u])}};return s.scopeName=t.scopeName,s}var X=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],y=X.reduce((e,t)=>{const s=B(`Primitive.${t}`),l=c.forwardRef((a,m)=>{const{asChild:u,...o}=a,n=u?s:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(n,{...o,ref:m})});return l.displayName=`Primitive.${t}`,{...e,[t]:l}},{}),P="Progress",w=100,[F]=G(P),[H,U]=F(P),_=c.forwardRef((e,t)=>{const{__scopeProgress:s,value:l=null,max:a,getValueLabel:m=q,...u}=e;(a||a===0)&&!S(a)&&console.error(J(`${a}`,"Progress"));const o=S(a)?a:w;l!==null&&!C(l,o)&&console.error(K(`${l}`,"Progress"));const n=C(l,o)?l:null,x=b(n)?m(n,o):void 0;return r.jsx(H,{scope:s,value:n,max:o,children:r.jsx(y.div,{"aria-valuemax":o,"aria-valuemin":0,"aria-valuenow":b(n)?n:void 0,"aria-valuetext":x,role:"progressbar","data-state":I(n,o),"data-value":n??void 0,"data-max":o,...u,ref:t})})});_.displayName=P;var E="ProgressIndicator",R=c.forwardRef((e,t)=>{const{__scopeProgress:s,...l}=e,a=U(E,s);return r.jsx(y.div,{"data-state":I(a.value,a.max),"data-value":a.value??void 0,"data-max":a.max,...l,ref:t})});R.displayName=E;function q(e,t){return`${Math.round(e/t*100)}%`}function I(e,t){return e==null?"indeterminate":e===t?"complete":"loading"}function b(e){return typeof e=="number"}function S(e){return b(e)&&!isNaN(e)&&e>0}function C(e,t){return b(e)&&!isNaN(e)&&e<=t&&e>=0}function J(e,t){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${t}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${w}\`.`}function K(e,t){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${t}\`. The \`value\` prop must be:
|
|
2
|
+
- a positive number
|
|
3
|
+
- less than the value passed to \`max\` (or ${w} if no \`max\` prop is set)
|
|
4
|
+
- \`null\` or \`undefined\` if the progress is indeterminate.
|
|
5
|
+
|
|
6
|
+
Defaulting to \`null\`.`}var M=_,Q=R;const D=c.forwardRef(({className:e,value:t,indicatorClassName:s,...l},a)=>r.jsx(M,{ref:a,className:$("relative h-4 w-full overflow-hidden rounded-full bg-[hsl(var(--secondary))]",e),...l,children:r.jsx(Q,{className:$("h-full w-full flex-1 bg-[hsl(var(--primary))] transition-all",s),style:{transform:`translateX(-${100-(t||0)}%)`}})}));D.displayName=M.displayName;function se(){const{id:e}=V(),t=A(),[s,l]=c.useState(null),[a,m]=c.useState([]),[u,o]=c.useState(""),{lastEvent:n}=L("task.*,project.*,session.*"),x=c.useRef(null),f=c.useCallback(()=>{e&&(N(`/workspaces/${e}`).then(i=>o(i.name)).catch(()=>{}),Promise.all([N(`/workspaces/${e}/projects`),N(`/tasks?workspace_id=${e}`)]).then(([i,p])=>{m(i),l({totalTasks:p.length,openTasks:p.filter(d=>d.status==="open").length,claimedTasks:p.filter(d=>d.status==="claimed"||d.status==="in_progress").length,doneTasks:p.filter(d=>d.status==="done").length,blockedTasks:p.filter(d=>d.status==="blocked").length,totalProjects:i.length,totalAgents:0})}).catch(()=>{}))},[e]);c.useEffect(()=>{f()},[f]),c.useEffect(()=>{if(n)return x.current&&clearTimeout(x.current),x.current=setTimeout(f,300),()=>{x.current&&clearTimeout(x.current)}},[n,f]);const v=s&&s.totalTasks>0?Math.round(s.doneTasks/s.totalTasks*100):0;return r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsx("div",{className:"h-[52px] border-b border-[hsl(var(--border))] flex items-center px-6 bg-white/90 backdrop-blur-sm shrink-0 sticky top-0 z-10",children:r.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:u||"Dashboard"})}),r.jsxs("div",{className:"flex-1 overflow-auto p-6 space-y-6",children:[r.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[r.jsx(g,{label:"Total Tasks",value:(s==null?void 0:s.totalTasks)??0}),r.jsx(g,{label:"Open",value:(s==null?void 0:s.openTasks)??0,color:"text-[hsl(var(--info))]"}),r.jsx(g,{label:"In Progress",value:(s==null?void 0:s.claimedTasks)??0,color:"text-amber-600"}),r.jsx(g,{label:"Done",value:(s==null?void 0:s.doneTasks)??0,color:"text-emerald-600"})]}),s&&s.blockedTasks>0&&r.jsx(j,{className:"border-[hsl(var(--destructive)/0.3)] bg-[hsl(var(--destructive)/0.05)]",children:r.jsxs(k,{className:"p-4 flex items-center gap-3",children:[r.jsx("span",{className:"w-2 h-2 rounded-full bg-[hsl(var(--destructive))] shrink-0"}),r.jsxs("span",{className:"text-sm text-[hsl(var(--destructive))] font-medium",children:[s.blockedTasks," task",s.blockedTasks>1?"s":""," blocked"]})]})}),s&&s.totalTasks>0&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center justify-between text-sm text-[hsl(var(--muted-foreground))]",children:[r.jsx("span",{children:"Overall Progress"}),r.jsxs("span",{className:"font-mono tabular-nums",children:[v,"%"]})]}),r.jsx(D,{value:v,className:"h-2.5"})]}),r.jsxs("div",{children:[r.jsx("h2",{className:"text-base font-semibold mb-3",children:"Projects"}),a.length===0?r.jsx("p",{className:"text-sm text-[hsl(var(--muted-foreground))]",children:"No projects yet."}):r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:a.map(i=>r.jsx(j,{className:"cursor-pointer hover:border-emerald-300 transition-colors",onClick:()=>t(`/projects/${i.id}`),children:r.jsxs(k,{className:"p-4",children:[r.jsx("div",{className:"font-medium text-sm",children:i.name}),r.jsx(z,{variant:"secondary",className:"mt-2 text-[11px]",children:i.status})]})},i.id))})]})]})]})}function g({label:e,value:t,color:s}){return r.jsx(j,{children:r.jsxs(k,{className:"p-4",children:[r.jsx("div",{className:"font-mono text-[11px] uppercase tracking-wider text-[hsl(var(--muted-foreground))] mb-1",children:e}),r.jsx("div",{className:`font-mono text-[28px] font-semibold tabular-nums tracking-tight ${s||""}`,children:t})]})})}export{se as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{L as h,z as a,v as e,x as p}from"./index-C7kx39S9.js";function b(){const i=h(),[r,c]=a.useState(""),[o,m]=a.useState(""),[l,u]=a.useState(""),[d,n]=a.useState(!1),x=s=>{s.preventDefault(),r.trim()&&(n(!0),p("/workspaces",{name:r,goal:o}).then(t=>{window.location.href=`/space/${t.id}/dashboard`}).catch(t=>u(t.message)).finally(()=>n(!1)))};return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsxs("div",{className:"h-[52px] border-b border-[hsl(var(--border))] flex items-center justify-between px-6 bg-[hsl(var(--card)/0.92)] backdrop-blur-xl sticky top-0 z-5",children:[e.jsx("h1",{className:"text-base font-semibold tracking-tight",children:"Create Workspace"}),e.jsx("button",{onClick:()=>i(-1),className:"text-sm text-[hsl(var(--muted-foreground))] hover:text-[hsl(var(--foreground))] transition-colors",children:"Cancel"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-6 flex items-start justify-center",children:e.jsxs("div",{className:"max-w-md w-full space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold tracking-tight",children:"New Workspace"}),e.jsx("p",{className:"text-sm text-[hsl(var(--muted-foreground))] mt-1",children:"A workspace is your team's collaboration space for projects, tasks, and agents."})]}),l&&e.jsx("div",{className:"rounded-md border border-red-300 bg-red-50 dark:bg-red-950/20 dark:border-red-800 px-4 py-3 text-sm text-red-700 dark:text-red-400",children:l}),e.jsxs("form",{onSubmit:x,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"name",className:"text-sm font-medium text-[hsl(var(--muted-foreground))]",children:"Name"}),e.jsx("input",{id:"name",value:r,onChange:s=>c(s.target.value),placeholder:"e.g. Launch v2.0",autoFocus:!0,className:"w-full border border-[hsl(var(--border))] rounded-md px-3 py-2 bg-[hsl(var(--card))] text-sm focus:outline-none focus:ring-1 focus:ring-[hsl(var(--primary))]"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"goal",className:"text-sm font-medium text-[hsl(var(--muted-foreground))]",children:"Goal (optional)"}),e.jsx("textarea",{id:"goal",value:o,onChange:s=>m(s.target.value),placeholder:"Describe what this workspace is for...",rows:3,className:"w-full border border-[hsl(var(--border))] rounded-md px-3 py-2 bg-[hsl(var(--card))] text-sm focus:outline-none focus:ring-1 focus:ring-[hsl(var(--primary))] resize-none"})]}),e.jsx("button",{type:"submit",disabled:d||!r.trim(),className:"w-full bg-[hsl(var(--primary))] text-white rounded-md px-4 py-2 text-sm font-medium hover:opacity-90 disabled:opacity-50",children:d?"Creating...":"Create Workspace"})]})]})})]})}export{b as default};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{q as N,N as y,L as w,z as t,s as v,v as e,x as k}from"./index-C7kx39S9.js";import{P as C}from"./plus-BHnOxbns.js";import{C as P}from"./circle-check-B3P1qK0Z.js";import{C as S}from"./clock-f9aYZox0.js";import{A as _}from"./arrow-right-S7ID7nDp.js";/**
|
|
2
|
+
* @license lucide-react v1.16.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 $=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],A=N("folder-open",$);function W(){const{id:o}=y(),g=w(),[a,d]=t.useState([]),[i,m]=t.useState(!1),[l,u]=t.useState(""),[x,h]=t.useState(""),[p,b]=t.useState("");t.useEffect(()=>{o&&v(`/workspaces/${o}/projects`).then(d).catch(()=>{})},[o]);const j=s=>{s.preventDefault(),l.trim()&&k(`/workspaces/${o}/projects`,{name:l,workdir:x.trim()||null}).then(()=>{u(""),h(""),m(!1),v(`/workspaces/${o}/projects`).then(d)}).catch(r=>b(r.message))};return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsxs("div",{className:"h-[52px] border-b border-[hsl(var(--border))] flex items-center justify-between px-6 shrink-0 bg-[hsl(var(--card))/0.92] backdrop-blur-xl",children:[e.jsx("h1",{className:"text-lg font-semibold tracking-tight",children:"项目"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs text-[hsl(var(--muted-foreground))] font-mono",children:[a.length," 个项目"]}),e.jsxs("button",{onClick:()=>m(!i),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))] text-xs font-medium hover:opacity-90 transition-opacity",children:[e.jsx(C,{className:"w-3.5 h-3.5"}),"新建项目"]})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[p&&e.jsx("div",{className:"mb-4 p-3 rounded-lg bg-[hsl(var(--destructive))/0.08] border border-[hsl(var(--destructive))/0.2] text-sm text-[hsl(var(--destructive))]",children:p}),i&&e.jsx("form",{onSubmit:j,className:"mb-5 p-4 bg-[hsl(var(--card))] border border-[hsl(var(--border))] rounded-xl",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-[1fr_1.5fr_auto] gap-3 items-end",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[hsl(var(--muted-foreground))] mb-1.5 font-mono uppercase tracking-wider",children:"项目名称"}),e.jsx("input",{value:l,onChange:s=>u(s.target.value),placeholder:"my-project",className:"w-full px-3 py-2 rounded-md border border-[hsl(var(--border))] bg-[hsl(var(--background))] text-sm font-mono focus:outline-none focus:ring-1 focus:ring-[hsl(var(--ring))]",autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[hsl(var(--muted-foreground))] mb-1.5 font-mono uppercase tracking-wider",children:"工作目录(可选)"}),e.jsx("input",{value:x,onChange:s=>h(s.target.value),placeholder:"/path/to/project",className:"w-full px-3 py-2 rounded-md border border-[hsl(var(--border))] bg-[hsl(var(--background))] text-sm font-mono focus:outline-none focus:ring-1 focus:ring-[hsl(var(--ring))]"})]}),e.jsx("button",{type:"submit",className:"inline-flex items-center gap-1.5 px-4 py-2 rounded-md bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))] text-sm font-medium hover:opacity-90 transition-opacity",children:"创建"})]})}),a.length===0?e.jsxs("div",{className:"text-center py-16 text-[hsl(var(--muted-foreground))]",children:[e.jsx(A,{className:"w-10 h-10 mx-auto mb-3 opacity-40"}),e.jsx("p",{className:"text-sm",children:"暂无项目"}),e.jsx("p",{className:"text-xs mt-1 opacity-70",children:"创建一个项目来组织任务"})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-3",children:a.map(s=>{const r=s.task_count||0,f=s.done_count||0,n=r>0?Math.round(f/r*100):0,c=s.status==="completed";return e.jsxs("div",{onClick:()=>g(`/projects/${s.id}`),className:"bg-[hsl(var(--card))] border border-[hsl(var(--border))] rounded-xl p-4 hover:border-[hsl(var(--muted-foreground))] transition-colors cursor-pointer group",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"font-medium text-sm",children:s.name}),e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full font-mono text-[10px] font-medium ${c?"pill-success":"pill-info"}`,children:[c?e.jsx(P,{className:"w-3 h-3"}):e.jsx(S,{className:"w-3 h-3"}),c?"已完成":"进行中"]})]}),r>0&&e.jsxs("div",{className:"mb-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-[hsl(var(--muted-foreground))] mb-1",children:[e.jsxs("span",{children:[f,"/",r," 任务完成"]}),e.jsxs("span",{className:"font-mono tabular-nums",children:[n,"%"]})]}),e.jsx("div",{className:"h-1 bg-[hsl(var(--muted))] rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all ${n===100?"bg-[hsl(var(--success))]":"bg-[hsl(var(--info))]"}`,style:{width:`${n}%`}})})]}),s.workdir&&e.jsx("div",{className:"text-xs text-[hsl(var(--muted-foreground))] font-mono truncate mt-2",children:s.workdir}),e.jsxs("div",{className:"flex items-center justify-between mt-3 pt-2 border-t border-[hsl(var(--border))]",children:[e.jsx("span",{className:"text-xs text-[hsl(var(--muted-foreground))]",children:s.created_at?new Date(Number(s.created_at)).toLocaleDateString("zh-CN"):"—"}),e.jsx(_,{className:"w-3.5 h-3.5 text-[hsl(var(--muted-foreground))] opacity-0 group-hover:opacity-100 transition-opacity"})]})]},s.id)})})]})]})}export{W as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{N as a,L as t,z as r}from"./index-C7kx39S9.js";function u(){const{id:e}=a(),s=t();return r.useEffect(()=>{e&&s(`/space/${e}/tasks?view=schedules`,{replace:!0})},[e,s]),null}export{u as default};
|