@saluzi/saluzi-edu 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +46 -46
- package/dist/rcs-web/assets/Dashboard-BiApZyPx.js +2 -0
- package/{packages/remote-control-server/web/dist/assets/SessionDetail-B9rqUaDO.js → dist/rcs-web/assets/SessionDetail-CWUE75ns.js} +12 -12
- package/{packages/remote-control-server/web/dist/assets/arc-DmgdWIlf.js → dist/rcs-web/assets/arc-4X1dRN53.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/architectureDiagram-3BPJPVTR-DS9ZLEGd.js → dist/rcs-web/assets/architectureDiagram-3BPJPVTR-D3w_Tg5M.js} +1 -1
- package/dist/rcs-web/assets/{blockDiagram-GPEHLZMM-CEpINxWA.js → blockDiagram-GPEHLZMM-8wHRy2A9.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/c4Diagram-AAUBKEIU-B61spn_c.js → dist/rcs-web/assets/c4Diagram-AAUBKEIU-9bNKHWdC.js} +1 -1
- package/dist/rcs-web/assets/channel-D0E2lnim.js +1 -0
- package/dist/rcs-web/assets/{chunk-2J33WTMH-3Sos_YG1.js → chunk-2J33WTMH-DgoVnl2j.js} +1 -1
- package/dist/rcs-web/assets/{chunk-4BX2VUAB-C5yUkGky.js → chunk-4BX2VUAB-DvIfpz6o.js} +1 -1
- package/dist/rcs-web/assets/{chunk-55IACEB6-CodXkzoD.js → chunk-55IACEB6-BJXtiicU.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/chunk-727SXJPM-DN3UsPBJ.js → dist/rcs-web/assets/chunk-727SXJPM-BLXUmKhM.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/chunk-AQP2D5EJ-Bwbwzt31.js → dist/rcs-web/assets/chunk-AQP2D5EJ-xIzfWsyC.js} +1 -1
- package/dist/rcs-web/assets/{chunk-FMBD7UC4-DdZGGyPp.js → chunk-FMBD7UC4-OXv4Udby.js} +1 -1
- package/dist/rcs-web/assets/{chunk-ND2GUHAM-gHeg7axd.js → chunk-ND2GUHAM-CInuJb7w.js} +1 -1
- package/dist/rcs-web/assets/{chunk-QZHKN3VN-BFDxTJxi.js → chunk-QZHKN3VN-D9OXcbtl.js} +1 -1
- package/dist/rcs-web/assets/classDiagram-4FO5ZUOK-CHy833tj.js +1 -0
- package/dist/rcs-web/assets/classDiagram-v2-Q7XG4LA2-CHy833tj.js +1 -0
- package/dist/rcs-web/assets/{code-block-IT6T5CEO-C-s596_W.js → code-block-IT6T5CEO-DIoba4-y.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/cose-bilkent-S5V4N54A-C_KMwbf7.js → dist/rcs-web/assets/cose-bilkent-S5V4N54A-Bs-352tg.js} +1 -1
- package/dist/rcs-web/assets/{dagre-BM42HDAG-BQ1E50QU.js → dagre-BM42HDAG-B9mWsnfD.js} +1 -1
- package/dist/rcs-web/assets/{diagram-2AECGRRQ-CU2nW4TH.js → diagram-2AECGRRQ-BiVjJxYN.js} +1 -1
- package/dist/rcs-web/assets/{diagram-5GNKFQAL-CpT3Gpmm.js → diagram-5GNKFQAL-yAsJs_ln.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/diagram-KO2AKTUF-CNFA0Vuv.js → dist/rcs-web/assets/diagram-KO2AKTUF-Dud1LRRq.js} +1 -1
- package/dist/rcs-web/assets/{diagram-LMA3HP47-Cx4zSMpY.js → diagram-LMA3HP47-iPzKx6av.js} +1 -1
- package/dist/rcs-web/assets/{diagram-OG6HWLK6-BWC_jCla.js → diagram-OG6HWLK6-DJgCZbOs.js} +1 -1
- package/dist/rcs-web/assets/{erDiagram-TEJ5UH35-CSuUBiRO.js → erDiagram-TEJ5UH35-BGznRS63.js} +1 -1
- package/dist/rcs-web/assets/{flowDiagram-I6XJVG4X-BWPEqpf0.js → flowDiagram-I6XJVG4X-UfxMnrX8.js} +1 -1
- package/dist/rcs-web/assets/{ganttDiagram-6RSMTGT7-2jfQeqRo.js → ganttDiagram-6RSMTGT7-BkaC26kQ.js} +1 -1
- package/dist/rcs-web/assets/{gitGraphDiagram-PVQCEYII-BstRXOH0.js → gitGraphDiagram-PVQCEYII-mONxtC7R.js} +1 -1
- package/dist/rcs-web/assets/{infoDiagram-5YYISTIA-fpyXvcBU.js → infoDiagram-5YYISTIA-8aruATa_.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/ishikawaDiagram-YF4QCWOH-CKIBVciX.js → dist/rcs-web/assets/ishikawaDiagram-YF4QCWOH-DkJ7Cpbg.js} +1 -1
- package/dist/rcs-web/assets/{journeyDiagram-JHISSGLW-mEQGXLWs.js → journeyDiagram-JHISSGLW-BiIIuQpY.js} +1 -1
- package/dist/rcs-web/assets/{kanban-definition-UN3LZRKU-Dm6-lRPV.js → kanban-definition-UN3LZRKU-D6wU_tk_.js} +1 -1
- package/dist/rcs-web/assets/{linear-CY5phZrT.js → linear-DjOGLk2Z.js} +1 -1
- package/dist/rcs-web/assets/{main-cMKCMXV5.js → main-5uxJJ_sE.js} +3 -3
- package/dist/rcs-web/assets/{mermaid-VLURNSYL-DRG_-dmJ.js → mermaid-VLURNSYL-kyqcLTJM.js} +4 -4
- package/dist/rcs-web/assets/{mermaid.core-CZ0TEVpY.js → mermaid.core-slLRH1UY.js} +5 -5
- package/dist/rcs-web/assets/{mindmap-definition-RKZ34NQL-DMMAfq_q.js → mindmap-definition-RKZ34NQL-B8y1-NqM.js} +1 -1
- package/dist/rcs-web/assets/{pieDiagram-4H26LBE5-CclLma08.js → pieDiagram-4H26LBE5-DwiQtzbN.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/quadrantDiagram-W4KKPZXB-Dy4sNmSO.js → dist/rcs-web/assets/quadrantDiagram-W4KKPZXB-Den6wpfP.js} +1 -1
- package/dist/rcs-web/assets/{requirementDiagram-4Y6WPE33-DUhDkjra.js → requirementDiagram-4Y6WPE33-DBw4144P.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/sankeyDiagram-5OEKKPKP-DtOF0AAY.js → dist/rcs-web/assets/sankeyDiagram-5OEKKPKP-C-wqrDCa.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/sequenceDiagram-3UESZ5HK-BhZhk-4v.js → dist/rcs-web/assets/sequenceDiagram-3UESZ5HK-D83w2C-G.js} +1 -1
- package/dist/rcs-web/assets/{stateDiagram-AJRCARHV-D5E7Xqns.js → stateDiagram-AJRCARHV-DLtB2UCO.js} +1 -1
- package/dist/rcs-web/assets/{stateDiagram-v2-BHNVJYJU-BLNSVAaL.js → stateDiagram-v2-BHNVJYJU-BHas-vfa.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/timeline-definition-PNZ67QCA-8945PuXp.js → dist/rcs-web/assets/timeline-definition-PNZ67QCA-BbEI1m1M.js} +1 -1
- package/dist/rcs-web/assets/{vennDiagram-CIIHVFJN-BoIJSTO-.js → vennDiagram-CIIHVFJN-C4fDmd1A.js} +1 -1
- package/dist/rcs-web/assets/{wardleyDiagram-YWT4CUSO-coKPhznt.js → wardleyDiagram-YWT4CUSO-DkMeB_0t.js} +1 -1
- package/dist/rcs-web/assets/workerType-Bd-zteMi.js +1 -0
- package/dist/rcs-web/assets/{xychartDiagram-2RQKCTM6-DK2cmVtY.js → xychartDiagram-2RQKCTM6-BG-VBnW8.js} +1 -1
- package/dist/rcs-web/index.html +1 -1
- package/package.json +5 -3
- package/packages/remote-control-server/src/routes/acp/index.ts +16 -1
- package/packages/remote-control-server/src/routes/v1/environments.ts +5 -8
- package/packages/remote-control-server/src/routes/web/sessions.ts +23 -0
- package/packages/remote-control-server/src/services/environment.ts +45 -0
- package/packages/remote-control-server/src/services/session.ts +19 -0
- package/packages/remote-control-server/src/store.ts +19 -1
- package/packages/remote-control-server/src/transport/acp-ws-handler.ts +10 -1
- package/packages/remote-control-server/src/types/api.ts +7 -0
- package/packages/remote-control-server/web/dist/assets/Dashboard-BiApZyPx.js +2 -0
- package/{dist/rcs-web/assets/SessionDetail-B9rqUaDO.js → packages/remote-control-server/web/dist/assets/SessionDetail-CWUE75ns.js} +12 -12
- package/{dist/rcs-web/assets/arc-DmgdWIlf.js → packages/remote-control-server/web/dist/assets/arc-4X1dRN53.js} +1 -1
- package/{dist/rcs-web/assets/architectureDiagram-3BPJPVTR-DS9ZLEGd.js → packages/remote-control-server/web/dist/assets/architectureDiagram-3BPJPVTR-D3w_Tg5M.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{blockDiagram-GPEHLZMM-CEpINxWA.js → blockDiagram-GPEHLZMM-8wHRy2A9.js} +1 -1
- package/{dist/rcs-web/assets/c4Diagram-AAUBKEIU-B61spn_c.js → packages/remote-control-server/web/dist/assets/c4Diagram-AAUBKEIU-9bNKHWdC.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/channel-D0E2lnim.js +1 -0
- package/packages/remote-control-server/web/dist/assets/{chunk-2J33WTMH-3Sos_YG1.js → chunk-2J33WTMH-DgoVnl2j.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-4BX2VUAB-C5yUkGky.js → chunk-4BX2VUAB-DvIfpz6o.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-55IACEB6-CodXkzoD.js → chunk-55IACEB6-BJXtiicU.js} +1 -1
- package/{dist/rcs-web/assets/chunk-727SXJPM-DN3UsPBJ.js → packages/remote-control-server/web/dist/assets/chunk-727SXJPM-BLXUmKhM.js} +1 -1
- package/{dist/rcs-web/assets/chunk-AQP2D5EJ-Bwbwzt31.js → packages/remote-control-server/web/dist/assets/chunk-AQP2D5EJ-xIzfWsyC.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-FMBD7UC4-DdZGGyPp.js → chunk-FMBD7UC4-OXv4Udby.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-ND2GUHAM-gHeg7axd.js → chunk-ND2GUHAM-CInuJb7w.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-QZHKN3VN-BFDxTJxi.js → chunk-QZHKN3VN-D9OXcbtl.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/classDiagram-4FO5ZUOK-CHy833tj.js +1 -0
- package/packages/remote-control-server/web/dist/assets/classDiagram-v2-Q7XG4LA2-CHy833tj.js +1 -0
- package/packages/remote-control-server/web/dist/assets/{code-block-IT6T5CEO-C-s596_W.js → code-block-IT6T5CEO-DIoba4-y.js} +1 -1
- package/{dist/rcs-web/assets/cose-bilkent-S5V4N54A-C_KMwbf7.js → packages/remote-control-server/web/dist/assets/cose-bilkent-S5V4N54A-Bs-352tg.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{dagre-BM42HDAG-BQ1E50QU.js → dagre-BM42HDAG-B9mWsnfD.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-2AECGRRQ-CU2nW4TH.js → diagram-2AECGRRQ-BiVjJxYN.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-5GNKFQAL-CpT3Gpmm.js → diagram-5GNKFQAL-yAsJs_ln.js} +1 -1
- package/{dist/rcs-web/assets/diagram-KO2AKTUF-CNFA0Vuv.js → packages/remote-control-server/web/dist/assets/diagram-KO2AKTUF-Dud1LRRq.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-LMA3HP47-Cx4zSMpY.js → diagram-LMA3HP47-iPzKx6av.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-OG6HWLK6-BWC_jCla.js → diagram-OG6HWLK6-DJgCZbOs.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{erDiagram-TEJ5UH35-CSuUBiRO.js → erDiagram-TEJ5UH35-BGznRS63.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{flowDiagram-I6XJVG4X-BWPEqpf0.js → flowDiagram-I6XJVG4X-UfxMnrX8.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{ganttDiagram-6RSMTGT7-2jfQeqRo.js → ganttDiagram-6RSMTGT7-BkaC26kQ.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{gitGraphDiagram-PVQCEYII-BstRXOH0.js → gitGraphDiagram-PVQCEYII-mONxtC7R.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{infoDiagram-5YYISTIA-fpyXvcBU.js → infoDiagram-5YYISTIA-8aruATa_.js} +1 -1
- package/{dist/rcs-web/assets/ishikawaDiagram-YF4QCWOH-CKIBVciX.js → packages/remote-control-server/web/dist/assets/ishikawaDiagram-YF4QCWOH-DkJ7Cpbg.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{journeyDiagram-JHISSGLW-mEQGXLWs.js → journeyDiagram-JHISSGLW-BiIIuQpY.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{kanban-definition-UN3LZRKU-Dm6-lRPV.js → kanban-definition-UN3LZRKU-D6wU_tk_.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{linear-CY5phZrT.js → linear-DjOGLk2Z.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{main-cMKCMXV5.js → main-5uxJJ_sE.js} +3 -3
- package/packages/remote-control-server/web/dist/assets/{mermaid-VLURNSYL-DRG_-dmJ.js → mermaid-VLURNSYL-kyqcLTJM.js} +4 -4
- package/packages/remote-control-server/web/dist/assets/{mermaid.core-CZ0TEVpY.js → mermaid.core-slLRH1UY.js} +5 -5
- package/packages/remote-control-server/web/dist/assets/{mindmap-definition-RKZ34NQL-DMMAfq_q.js → mindmap-definition-RKZ34NQL-B8y1-NqM.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{pieDiagram-4H26LBE5-CclLma08.js → pieDiagram-4H26LBE5-DwiQtzbN.js} +1 -1
- package/{dist/rcs-web/assets/quadrantDiagram-W4KKPZXB-Dy4sNmSO.js → packages/remote-control-server/web/dist/assets/quadrantDiagram-W4KKPZXB-Den6wpfP.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{requirementDiagram-4Y6WPE33-DUhDkjra.js → requirementDiagram-4Y6WPE33-DBw4144P.js} +1 -1
- package/{dist/rcs-web/assets/sankeyDiagram-5OEKKPKP-DtOF0AAY.js → packages/remote-control-server/web/dist/assets/sankeyDiagram-5OEKKPKP-C-wqrDCa.js} +1 -1
- package/{dist/rcs-web/assets/sequenceDiagram-3UESZ5HK-BhZhk-4v.js → packages/remote-control-server/web/dist/assets/sequenceDiagram-3UESZ5HK-D83w2C-G.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{stateDiagram-AJRCARHV-D5E7Xqns.js → stateDiagram-AJRCARHV-DLtB2UCO.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{stateDiagram-v2-BHNVJYJU-BLNSVAaL.js → stateDiagram-v2-BHNVJYJU-BHas-vfa.js} +1 -1
- package/{dist/rcs-web/assets/timeline-definition-PNZ67QCA-8945PuXp.js → packages/remote-control-server/web/dist/assets/timeline-definition-PNZ67QCA-BbEI1m1M.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{vennDiagram-CIIHVFJN-BoIJSTO-.js → vennDiagram-CIIHVFJN-C4fDmd1A.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{wardleyDiagram-YWT4CUSO-coKPhznt.js → wardleyDiagram-YWT4CUSO-DkMeB_0t.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/workerType-Bd-zteMi.js +1 -0
- package/packages/remote-control-server/web/dist/assets/{xychartDiagram-2RQKCTM6-DK2cmVtY.js → xychartDiagram-2RQKCTM6-BG-VBnW8.js} +1 -1
- package/packages/remote-control-server/web/dist/index.html +1 -1
- package/scripts/acp-link.mjs +12 -0
- package/dist/rcs-web/assets/Dashboard-DaTU02_D.js +0 -2
- package/dist/rcs-web/assets/channel-BV97V8Sa.js +0 -1
- package/dist/rcs-web/assets/classDiagram-4FO5ZUOK-i5w4Lep9.js +0 -1
- package/dist/rcs-web/assets/classDiagram-v2-Q7XG4LA2-i5w4Lep9.js +0 -1
- package/packages/remote-control-server/web/dist/assets/Dashboard-DaTU02_D.js +0 -2
- package/packages/remote-control-server/web/dist/assets/channel-BV97V8Sa.js +0 -1
- package/packages/remote-control-server/web/dist/assets/classDiagram-4FO5ZUOK-i5w4Lep9.js +0 -1
- package/packages/remote-control-server/web/dist/assets/classDiagram-v2-Q7XG4LA2-i5w4Lep9.js +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{j as e,e as a}from"./vendor-DE_-CLIE.js";import{j as N,B as C,I as w,D as S,e as E,g as T,h as D,f as L,m as W,O as M,M as _,o as O,p as F,K as R,n as B}from"./main-5uxJJ_sE.js";import{g as v}from"./workerType-Bd-zteMi.js";import"./shiki-mEP5vQQu.js";import"./qr-C0jP9HcD.js";import"./motion-BILbV7YQ.js";function I({environments:n,onSelectEnvironment:l}){return!n||n.length===0?e.jsx("div",{className:"rounded-xl border border-border bg-surface-1 p-8 text-center text-text-muted",children:"No active environments"}):e.jsx("div",{className:"space-y-2",children:n.map(o=>{const d=o.worker_type==="acp",c=v(o.worker_type),p=c.fullLabel,t=c.colorClass;return e.jsxs("button",{type:"button",onClick:()=>l==null?void 0:l(o),disabled:d,className:`flex w-full items-center justify-between rounded-xl border border-border bg-surface-1 px-4 py-3 text-left transition-colors ${d?"cursor-default opacity-80":"hover:border-border-light cursor-pointer"}`,children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-text-primary",children:o.machine_name||o.id}),e.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${t}`,children:p})]}),e.jsx("div",{className:"text-sm text-text-muted",children:o.directory||""})]})}),e.jsxs("div",{className:"text-right",children:[e.jsx(N,{status:o.status}),e.jsx("div",{className:"mt-1 text-xs text-text-muted",children:o.branch||""})]})]},o.id)})})}function K({sessions:n,environments:l,onSelect:o,onDelete:d}){if(!n||n.length===0)return e.jsx("div",{className:"rounded-xl border border-border bg-surface-1 p-8 text-center text-text-muted",children:"No sessions"});const c=new Map;for(const t of l??[])t!=null&&t.id&&t.worker_type&&c.set(t.id,t.worker_type);const p=[...n].sort((t,i)=>(i.updated_at||0)-(t.updated_at||0));return e.jsx("div",{className:"space-y-2",children:p.map(t=>e.jsxs("div",{className:"group flex w-full items-center justify-between rounded-xl border border-border bg-surface-1 px-4 py-3 text-left transition-colors hover:border-border-light hover:bg-surface-2",children:[e.jsxs("button",{type:"button",onClick:()=>o(t.id),className:"min-w-0 flex-1 text-left",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-medium text-text-primary",children:t.title||t.id}),(()=>{var f;let i=t.source==="acp"?"acp":(f=t.environment)==null?void 0:f.worker_type;!i&&t.environment_id&&(i=c.get(t.environment_id));const b=v(i);return e.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${b.colorClass}`,children:b.fullLabel})})()]}),e.jsx("div",{className:"truncate text-xs text-text-muted",children:t.id})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(N,{status:t.status}),e.jsx("span",{className:"text-xs text-text-muted",children:C(t.created_at||t.updated_at)}),d&&e.jsx("button",{type:"button",onClick:i=>{i.stopPropagation(),d(t.id)},className:"rounded p-1 text-text-muted opacity-0 transition-all hover:text-status-error group-hover:opacity-100",title:"Delete session",children:e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]},t.id))})}function $({open:n,environments:l,onClose:o,onCreated:d}){const[c,p]=a.useState(""),[t,i]=a.useState(""),[b,f]=a.useState("same-dir"),[g,j]=a.useState(""),[s,m]=a.useState(""),[u,y]=a.useState(!1);a.useEffect(()=>{n&&(p(""),i(""),f("same-dir"),j(""),m(""))},[n]),a.useEffect(()=>{if(!t){j("");return}const r=w(t);j(r??"")},[t]);const x=async()=>{y(!0),m("");try{const r={};c.trim()&&(r.title=c.trim()),t&&(r.environment_id=t),r.spawn_mode=b,g.trim()&&(r.worker_token=g.trim());const k=await W(r);g.trim()&&t&&M(t,g.trim()),_(k.id,t||k.environment_id),d(k)}catch(r){m(r instanceof Error?r.message:"Failed to create session")}finally{y(!1)}},h=l.find(r=>r.id===t);return e.jsx(S,{open:n,onOpenChange:r=>{r||o()},children:e.jsxs(E,{className:"max-w-md rounded-2xl border-border bg-surface-1 p-6 shadow-2xl",children:[e.jsx(T,{children:e.jsx(D,{className:"font-display text-lg font-semibold text-text-primary",children:"New Session"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:"Title (optional)"}),e.jsx("input",{type:"text",value:c,onChange:r=>p(r.target.value),placeholder:"My session",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:"Environment"}),e.jsxs("select",{value:t,onChange:r=>i(r.target.value),className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-brand focus:outline-none",children:[e.jsx("option",{value:"",children:"-- None --"}),l.map(r=>{const k=v(r.worker_type).shortLabel;return e.jsxs("option",{value:r.id,children:[r.machine_name||r.id," (",r.branch||"no branch",") · ",k,r.has_worker_token?" · protected":""]},r.id)})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:"Workspace Mode"}),e.jsxs("select",{value:b,onChange:r=>f(r.target.value),className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-brand focus:outline-none",children:[e.jsx("option",{value:"same-dir",children:"工作区 (same-dir) — sessions share the directory"}),e.jsx("option",{value:"worktree",children:"工作树 (worktree) — each session gets an isolated git worktree"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:"Worker Token"}),e.jsx("input",{type:"password",value:g,onChange:r=>j(r.target.value),placeholder:h!=null&&h.has_worker_token?"RCS_WORKER_TOKENS value":"No token required (open environment)",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none font-mono"}),e.jsx("p",{className:"mt-1 text-xs text-text-muted",children:h!=null&&h.has_worker_token?"该 environment 受 RCS_WORKER_TOKENS 保护。输入后会自动保存,下次创建同 environment 的会话时自动填入。":"该 environment 未设置 worker token,留空即可。"})]}),s&&e.jsx("div",{className:"text-sm text-status-error",children:s})]}),e.jsxs(L,{children:[e.jsx("button",{onClick:o,className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Cancel"}),e.jsx("button",{onClick:x,disabled:u,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light disabled:opacity-50 transition-colors",children:u?"Creating...":"Create"})]})]})})}function J({onNavigateSession:n}){const[l,o]=a.useState([]),[d,c]=a.useState([]),[p,t]=a.useState(!1),i=a.useCallback(async()=>{try{const[s,m]=await Promise.all([O(),F()]),u=s||[],y=m||[];for(const x of u)_(x.id,x.environment_id);R(u),o(u),c(y)}catch(s){console.error("Dashboard render error:",s)}},[]);a.useEffect(()=>{i();const s=setInterval(i,1e4);return()=>clearInterval(s)},[i]);const b=s=>{t(!1),n(s.id)},f=a.useCallback(s=>{},[]),g=a.useCallback(s=>{n(s)},[n]),j=a.useCallback(async s=>{const m=l.find(x=>x.id===s),u=m==null?void 0:m.environment_id,y=w(u);if(u&&!y){alert(`该会话的 environment 受 worker token 保护,但本地未保存对应 token。
|
|
2
|
+
请点击导航栏 Token → Worker Tokens 添加该 environment 的 worker token 后再删除。`);return}if(window.confirm(`删除会话 ${s}?此操作不可恢复。`))try{await B(s),o(x=>x.filter(h=>h.id!==s))}catch(x){alert(x instanceof Error?x.message:"Failed to delete session")}},[l]);return e.jsxs("div",{className:"mx-auto max-w-5xl px-4 py-8",children:[e.jsx("h1",{className:"sr-only",children:"Dashboard"}),e.jsxs("section",{className:"mb-10",children:[e.jsx("h2",{className:"mb-4 font-display text-lg font-semibold text-text-primary",children:"Environments"}),e.jsx(I,{environments:d,onSelectEnvironment:f})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[e.jsx("h2",{className:"font-display text-lg font-semibold text-text-primary",children:"Sessions"}),e.jsx("button",{onClick:()=>t(!0),className:"rounded-lg bg-brand px-3 py-1.5 text-sm font-medium text-white hover:bg-brand-light transition-colors",children:"+ New Session"})]}),e.jsx(K,{sessions:l,environments:d,onSelect:g,onDelete:j})]}),e.jsx($,{open:p,environments:d,onClose:()=>t(!1),onCreated:b})]})}export{J as Dashboard};
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
var de=Object.defineProperty;var ue=(s,t,n)=>t in s?de(s,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[t]=n;var S=(s,t,n)=>ue(s,typeof t!="symbol"?t+"":t,n);import{e as h,j as e}from"./vendor-DE_-CLIE.js";import{x as A,l as me,r as xe,u as pe,E as he,t as R,s as fe,G as ye,H as B,D as ge,e as be,g as je,h as ke,j as Y,B as G,L as X,k as we,S as Ne,z as $,w as q,d as ve,P as _e,A as Se,F as Ce,Q as Me,y as Ee,I as Te,n as $e,N as Ae,T as Z,c as Ie,C as Pe,q as Re,M as qe,K as De,b as Ue,J as Oe,i as Fe,a as Be}from"./main-
|
|
1
|
+
var de=Object.defineProperty;var ue=(s,t,n)=>t in s?de(s,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[t]=n;var S=(s,t,n)=>ue(s,typeof t!="symbol"?t+"":t,n);import{e as h,j as e}from"./vendor-DE_-CLIE.js";import{x as A,l as me,r as xe,u as pe,E as he,t as R,s as fe,G as ye,H as B,D as ge,e as be,g as je,h as ke,j as Y,B as G,L as X,k as we,S as Ne,z as $,w as q,d as ve,P as _e,A as Se,F as Ce,Q as Me,y as Ee,I as Te,n as $e,N as Ae,T as Z,c as Ie,C as Pe,q as Re,M as qe,K as De,b as Ue,J as Oe,i as Fe,a as Be}from"./main-5uxJJ_sE.js";import{g as We}from"./workerType-Bd-zteMi.js";import"./shiki-mEP5vQQu.js";import"./qr-C0jP9HcD.js";import"./motion-BILbV7YQ.js";/**
|
|
2
2
|
* @license lucide-react v0.555.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const He=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],
|
|
6
|
+
*/const He=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],ze=A("activity",He);/**
|
|
7
7
|
* @license lucide-react v0.555.0 - ISC
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const
|
|
11
|
+
*/const Le=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Ke=A("chevron-right",Le);/**
|
|
12
12
|
* @license lucide-react v0.555.0 - ISC
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const
|
|
16
|
+
*/const Qe=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],L=A("clock",Qe);/**
|
|
17
17
|
* @license lucide-react v0.555.0 - ISC
|
|
18
18
|
*
|
|
19
19
|
* This source code is licensed under the ISC license.
|
|
20
20
|
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const
|
|
21
|
+
*/const Ve=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],Je=A("cpu",Ve);/**
|
|
22
22
|
* @license lucide-react v0.555.0 - ISC
|
|
23
23
|
*
|
|
24
24
|
* This source code is licensed under the ISC license.
|
|
25
25
|
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const
|
|
26
|
+
*/const Ye=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],Ge=A("hash",Ye);/**
|
|
27
27
|
* @license lucide-react v0.555.0 - ISC
|
|
28
28
|
*
|
|
29
29
|
* This source code is licensed under the ISC license.
|
|
30
30
|
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const
|
|
31
|
+
*/const Xe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Ze=A("info",Xe);/**
|
|
32
32
|
* @license lucide-react v0.555.0 - ISC
|
|
33
33
|
*
|
|
34
34
|
* This source code is licensed under the ISC license.
|
|
35
35
|
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
-
*/const
|
|
36
|
+
*/const et=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],tt=A("play",et);/**
|
|
37
37
|
* @license lucide-react v0.555.0 - ISC
|
|
38
38
|
*
|
|
39
39
|
* This source code is licensed under the ISC license.
|
|
40
40
|
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
-
*/const
|
|
41
|
+
*/const st=[["path",{d:"m10.852 14.772-.383.923",key:"11vil6"}],["path",{d:"M13.148 14.772a3 3 0 1 0-2.296-5.544l-.383-.923",key:"1v3clb"}],["path",{d:"m13.148 9.228.383-.923",key:"t2zzyc"}],["path",{d:"m13.53 15.696-.382-.924a3 3 0 1 1-2.296-5.544",key:"1bxfiv"}],["path",{d:"m14.772 10.852.923-.383",key:"k9m8cz"}],["path",{d:"m14.772 13.148.923.383",key:"1xvhww"}],["path",{d:"M4.5 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-.5",key:"tn8das"}],["path",{d:"M4.5 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-.5",key:"1g2pve"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M6 6h.01",key:"1utrut"}],["path",{d:"m9.228 10.852-.923-.383",key:"1wtb30"}],["path",{d:"m9.228 13.148-.923.383",key:"1a830x"}]],nt=A("server-cog",st);/**
|
|
42
42
|
* @license lucide-react v0.555.0 - ISC
|
|
43
43
|
*
|
|
44
44
|
* This source code is licensed under the ISC license.
|
|
45
45
|
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
-
*/const nt=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],rt=A("triangle-alert",nt);function ee(){return{tasks:{}}}const K=3e4;function U(s){const t=s.trim();if(!t)return"agent";const n=t.split(/\s+/).slice(0,2).join(" ");return n.length>40?n.slice(0,40)+"…":n}function ot(s,t){var x,u,d,i,l,a,p,y,f,g,b,k;const n=t.subtype;if(n!=="task_started"&&n!=="task_progress"&&n!=="task_notification")return s;const r=t.task_id;if(!r)return s;const c=Date.now(),o=s.tasks[r];if(n==="task_started"){if(o)return{tasks:{...s.tasks,[r]:{...o,description:t.description??o.description,name:U(t.description??o.description),taskType:t.task_type??o.taskType,workflowName:t.workflow_name??o.workflowName,prompt:t.prompt??o.prompt,toolUseId:t.tool_use_id??o.toolUseId,status:"running",startTime:c,evictAfter:void 0}}};const N=t.description??"";return{tasks:{...s.tasks,[r]:{taskId:r,name:U(N),description:N,taskType:t.task_type,workflowName:t.workflow_name,prompt:t.prompt,toolUseId:t.tool_use_id,status:"running",startTime:c}}}}if(n==="task_progress"){if(!o){const N=t.description??"";return{tasks:{...s.tasks,[r]:{taskId:r,name:U(N),description:N,toolUseId:t.tool_use_id,status:"running",startTime:c,tokenCount:(x=t.usage)==null?void 0:x.total_tokens,toolUseCount:(u=t.usage)==null?void 0:u.tool_uses,durationMs:(d=t.usage)==null?void 0:d.duration_ms,lastToolName:t.last_tool_name,summary:t.summary}}}}return{tasks:{...s.tasks,[r]:{...o,description:t.description??o.description,tokenCount:((i=t.usage)==null?void 0:i.total_tokens)??o.tokenCount,toolUseCount:((l=t.usage)==null?void 0:l.tool_uses)??o.toolUseCount,durationMs:((a=t.usage)==null?void 0:a.duration_ms)??o.durationMs,lastToolName:t.last_tool_name??o.lastToolName,summary:t.summary??o.summary}}}}return o?{tasks:{...s.tasks,[r]:{...o,status:t.status??"completed",endTime:c,finalSummary:t.summary??o.finalSummary,outputFile:t.output_file??o.outputFile,tokenCount:((g=t.usage)==null?void 0:g.total_tokens)??o.tokenCount,toolUseCount:((b=t.usage)==null?void 0:b.tool_uses)??o.toolUseCount,durationMs:((k=t.usage)==null?void 0:k.duration_ms)??o.durationMs,evictAfter:c+K}}}:{tasks:{...s.tasks,[r]:{taskId:r,name:U(t.summary??""),description:t.summary??"",status:t.status??"completed",startTime:c,endTime:c,finalSummary:t.summary,outputFile:t.output_file,tokenCount:(p=t.usage)==null?void 0:p.total_tokens,toolUseCount:(y=t.usage)==null?void 0:y.tool_uses,durationMs:(f=t.usage)==null?void 0:f.duration_ms,evictAfter:c+K}}}}function at(s,t=Date.now()){return Object.values(s.tasks).filter(n=>n.evictAfter===void 0||n.evictAfter>t).sort((n,r)=>n.startTime-r.startTime)}class it{constructor(){S(this,"listeners",new Set);S(this,"eventSource",null);S(this,"_lastSeqNum",0)}onEvent(t){return this.listeners.add(t),()=>this.listeners.delete(t)}connect(t){this.disconnect();const n=ye(),r=B(t),c=r?`&worker_token=${encodeURIComponent(r)}`:"",o=`/web/sessions/${t}/events?uuid=${encodeURIComponent(n)}${c}`,x=new EventSource(o);this.eventSource=x,x.addEventListener("message",u=>{try{const d=JSON.parse(u.data);if(d.seqNum!==void 0&&d.seqNum<=this._lastSeqNum)return;d.seqNum!==void 0&&(this._lastSeqNum=d.seqNum);for(const i of this.listeners)i(d)}catch{}})}disconnect(){this.eventSource&&(this.eventSource.close(),this.eventSource=null),this._lastSeqNum=0}}const F=new it;function Q(s){if(typeof s.content=="string")return s.content;if(s.message&&typeof s.message=="object"){const t=s.message;if(typeof t.content=="string")return t.content;if(Array.isArray(t.content))return t.content.filter(n=>n.type==="text"&&typeof n.text=="string").map(n=>n.text).join("")}return""}function V(s,t){for(let n=s.length-1;n>=0;n--){const r=s[n];if(r&&r.type==="tool_call"&&r.toolCall.id===t)return n}return-1}class lt{constructor(t,n,r){S(this,"sessionId");S(this,"setEntries");S(this,"unsub",null);S(this,"onStatusChange");S(this,"onError");S(this,"onPermissionRequest");S(this,"onModelsStateChange");S(this,"onSubagentUpdate");S(this,"subagentState",ee());this.sessionId=t,this.setEntries=n,this.onStatusChange=r==null?void 0:r.onStatusChange,this.onError=r==null?void 0:r.onError,this.onPermissionRequest=r==null?void 0:r.onPermissionRequest,this.onModelsStateChange=r==null?void 0:r.onModelsStateChange,this.onSubagentUpdate=r==null?void 0:r.onSubagentUpdate}async init(){try{await me(this.sessionId)}catch{}await this.loadHistory(),this.connectSSE()}async loadHistory(){var x;const{events:t}=await xe(this.sessionId);if(!t||t.length===0)return;const n=[];let r=null;const c=()=>{r&&(n.push(r),r=null)};for(const u of t){const d=u.payload||{};if(u.type==="user"){if(u.direction==="inbound")continue;c();const i=Q(d);i&&n.push({type:"user_message",id:u.id||`hist-user-${n.length}`,content:i})}else if(u.type==="assistant"){c();const i=Q(d),l=[],a=d.message;if(a&&typeof a=="object"&&Array.isArray(a.content))for(const p of a.content)p.type==="tool_use"&&l.push({type:"tool_call",toolCall:{id:p.id||`hist-tool-${n.length}`,title:p.name||"tool",status:"complete",rawInput:p.input||{}}});if(i||l.length>0){r={type:"assistant_message",id:u.id||`hist-asst-${n.length}`,chunks:i?[{type:"message",text:i}]:[]},n.push(r);for(const p of l)n.push(p);r=null}}else if(u.type==="tool_use"){const i=d,l={type:"tool_call",toolCall:{id:i.tool_call_id||`hist-tool-${n.length}`,title:i.tool_name||"tool",status:"complete",rawInput:i.tool_input||{}}};n.push(l)}else if(u.type==="tool_result"){const i=d,l=V(n,i.tool_call_id||"");if(l>=0){const a=n[l];n[l]={type:"tool_call",toolCall:{...a.toolCall,rawOutput:{output:i.content||i.output||""}}}}}}c(),this.setEntries(n);let o=null;for(const u of t){if(u.type!=="models_state")continue;const d=u.payload||{},i=d.raw,l=i&&typeof i=="object"?i.models_state:d.models_state;l&&Array.isArray(l.availableModels)&&typeof l.currentModelId=="string"&&(o=l)}o&&((x=this.onModelsStateChange)==null||x.call(this,o))}connectSSE(){F.connect(this.sessionId),this.unsub=F.onEvent(t=>this.handleEvent(t))}disconnect(){this.unsub&&(this.unsub(),this.unsub=null),F.disconnect()}handleEvent(t){var o,x,u,d,i;const n=t.type,r=t.payload||{},c=JSON.stringify(t);if(!/Remote Control connecting/i.test(c))switch(n){case"assistant":{const l=typeof r.content=="string"?r.content:"";this.setEntries(p=>{const y=p[p.length-1];if((y==null?void 0:y.type)==="assistant_message"){const f=y.chunks[y.chunks.length-1];return(f==null?void 0:f.type)==="message"?[...p.slice(0,-1),{...y,chunks:[...y.chunks.slice(0,-1),{type:"message",text:f.text+l}]}]:[...p.slice(0,-1),{...y,chunks:[...y.chunks,{type:"message",text:l}]}]}if(l&&l.trim()){const f={type:"assistant_message",id:`assistant-${Date.now()}`,chunks:[{type:"message",text:l}]};return[...p,f]}return p});const a=r.message;if(a&&typeof a=="object"&&Array.isArray(a.content)){const p=a.content.filter(y=>y.type==="tool_use");for(const y of p){const g={id:y.id||`call-${Date.now()}-${Math.random().toString(16).slice(2,8)}`,title:y.name||"tool",status:"running",rawInput:y.input||{}};this.setEntries(b=>[...b,{type:"tool_call",toolCall:g}])}}break}case"tool_use":{const l=r,p={id:l.tool_call_id||`call-${Date.now()}`,title:l.tool_name||"tool",status:"running",rawInput:l.tool_input||{}};this.setEntries(y=>[...y,{type:"tool_call",toolCall:p}]);break}case"tool_result":{const l=r,a=l.tool_call_id||"";this.setEntries(p=>{const y=V(p,a);if(y<0)return p;const f=p[y];return p.map((g,b)=>b===y?{type:"tool_call",toolCall:{...f.toolCall,status:"complete",rawOutput:{output:l.content||l.output||""}}}:g)});break}case"control_request":case"permission_request":{const l=r.request;if(l&&l.subtype==="can_use_tool"){const a=r.request_id||"",p=l.tool_name||"unknown",y=l.input||l.tool_input||{},f=l.description||"";this.setEntries(g=>{const b=[...g].reverse().findIndex(k=>k.type==="tool_call");if(b>=0){const k=g.length-1-b,N=g[k];if(N.toolCall.status==="running")return g.map((C,M)=>M===k?{type:"tool_call",toolCall:{...N.toolCall,status:"waiting_for_confirmation",permissionRequest:{requestId:a,options:[]}}}:C)}return g}),(o=this.onPermissionRequest)==null||o.call(this,{requestId:a,toolName:p,toolInput:y,description:f})}break}case"session_status":{typeof r.status=="string"&&((x=this.onStatusChange)==null||x.call(this,r.status));break}case"error":{const l=String(r.message||r.content||"Unknown error");(u=this.onError)==null||u.call(this,l);break}case"models_state":{const l=r.raw,a=typeof l=="object"&&l!==null?l.models_state:r.models_state;a&&Array.isArray(a.availableModels)&&typeof a.currentModelId=="string"&&((d=this.onModelsStateChange)==null||d.call(this,a));break}case"system":{const l=r.raw,a=l&&typeof l=="object"?l:r,p=typeof a.subtype=="string"?a.subtype:void 0;if(p==="task_started"||p==="task_progress"||p==="task_notification"){const y={subtype:p,task_id:typeof a.task_id=="string"?a.task_id:void 0,tool_use_id:typeof a.tool_use_id=="string"?a.tool_use_id:void 0,description:typeof a.description=="string"?a.description:void 0,task_type:typeof a.task_type=="string"?a.task_type:void 0,workflow_name:typeof a.workflow_name=="string"?a.workflow_name:void 0,prompt:typeof a.prompt=="string"?a.prompt:void 0,usage:a.usage&&typeof a.usage=="object"?a.usage:void 0,last_tool_name:typeof a.last_tool_name=="string"?a.last_tool_name:void 0,summary:typeof a.summary=="string"?a.summary:void 0,status:a.status==="completed"||a.status==="failed"||a.status==="stopped"?a.status:void 0,output_file:typeof a.output_file=="string"?a.output_file:void 0};this.subagentState=ot(this.subagentState,y),(i=this.onSubagentUpdate)==null||i.call(this,this.subagentState)}break}}}async sendMessage(t,n,r){const c=n&&n.length>0,o=r&&r.length>0;if(!t.trim()&&!c&&!o)return;const x={type:"user_message",id:`user-${Date.now()}`,content:t,images:c?n:void 0,attachments:o?r:void 0};this.setEntries(i=>[...i,x]);const u=[];if(t&&u.push({type:"text",text:t}),c)for(const i of n)u.push({type:"image",source:{type:"base64",media_type:i.mimeType,data:i.data}});if(o){for(const i of r)if(i.kind==="text"||i.kind==="table"){const l=`📎 ${i.name}${i.size!=null?` (${ct(i.size)})`:""}`,a=i.textContent||"(空文件)";u.push({type:"text",text:`${l}
|
|
46
|
+
*/const rt=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],ot=A("triangle-alert",rt);function ee(){return{tasks:{}}}const K=3e4;function U(s){const t=s.trim();if(!t)return"agent";const n=t.split(/\s+/).slice(0,2).join(" ");return n.length>40?n.slice(0,40)+"…":n}function at(s,t){var x,u,d,i,l,a,p,y,f,g,b,w;const n=t.subtype;if(n!=="task_started"&&n!=="task_progress"&&n!=="task_notification")return s;const r=t.task_id;if(!r)return s;const c=Date.now(),o=s.tasks[r];if(n==="task_started"){if(o)return{tasks:{...s.tasks,[r]:{...o,description:t.description??o.description,name:U(t.description??o.description),taskType:t.task_type??o.taskType,workflowName:t.workflow_name??o.workflowName,prompt:t.prompt??o.prompt,toolUseId:t.tool_use_id??o.toolUseId,status:"running",startTime:c,evictAfter:void 0}}};const N=t.description??"";return{tasks:{...s.tasks,[r]:{taskId:r,name:U(N),description:N,taskType:t.task_type,workflowName:t.workflow_name,prompt:t.prompt,toolUseId:t.tool_use_id,status:"running",startTime:c}}}}if(n==="task_progress"){if(!o){const N=t.description??"";return{tasks:{...s.tasks,[r]:{taskId:r,name:U(N),description:N,toolUseId:t.tool_use_id,status:"running",startTime:c,tokenCount:(x=t.usage)==null?void 0:x.total_tokens,toolUseCount:(u=t.usage)==null?void 0:u.tool_uses,durationMs:(d=t.usage)==null?void 0:d.duration_ms,lastToolName:t.last_tool_name,summary:t.summary}}}}return{tasks:{...s.tasks,[r]:{...o,description:t.description??o.description,tokenCount:((i=t.usage)==null?void 0:i.total_tokens)??o.tokenCount,toolUseCount:((l=t.usage)==null?void 0:l.tool_uses)??o.toolUseCount,durationMs:((a=t.usage)==null?void 0:a.duration_ms)??o.durationMs,lastToolName:t.last_tool_name??o.lastToolName,summary:t.summary??o.summary}}}}return o?{tasks:{...s.tasks,[r]:{...o,status:t.status??"completed",endTime:c,finalSummary:t.summary??o.finalSummary,outputFile:t.output_file??o.outputFile,tokenCount:((g=t.usage)==null?void 0:g.total_tokens)??o.tokenCount,toolUseCount:((b=t.usage)==null?void 0:b.tool_uses)??o.toolUseCount,durationMs:((w=t.usage)==null?void 0:w.duration_ms)??o.durationMs,evictAfter:c+K}}}:{tasks:{...s.tasks,[r]:{taskId:r,name:U(t.summary??""),description:t.summary??"",status:t.status??"completed",startTime:c,endTime:c,finalSummary:t.summary,outputFile:t.output_file,tokenCount:(p=t.usage)==null?void 0:p.total_tokens,toolUseCount:(y=t.usage)==null?void 0:y.tool_uses,durationMs:(f=t.usage)==null?void 0:f.duration_ms,evictAfter:c+K}}}}function it(s,t=Date.now()){return Object.values(s.tasks).filter(n=>n.evictAfter===void 0||n.evictAfter>t).sort((n,r)=>n.startTime-r.startTime)}class lt{constructor(){S(this,"listeners",new Set);S(this,"eventSource",null);S(this,"_lastSeqNum",0)}onEvent(t){return this.listeners.add(t),()=>this.listeners.delete(t)}connect(t){this.disconnect();const n=ye(),r=B(t),c=r?`&worker_token=${encodeURIComponent(r)}`:"",o=`/web/sessions/${t}/events?uuid=${encodeURIComponent(n)}${c}`,x=new EventSource(o);this.eventSource=x,x.addEventListener("message",u=>{try{const d=JSON.parse(u.data);if(d.seqNum!==void 0&&d.seqNum<=this._lastSeqNum)return;d.seqNum!==void 0&&(this._lastSeqNum=d.seqNum);for(const i of this.listeners)i(d)}catch{}})}disconnect(){this.eventSource&&(this.eventSource.close(),this.eventSource=null),this._lastSeqNum=0}}const F=new lt;function Q(s){if(typeof s.content=="string")return s.content;if(s.message&&typeof s.message=="object"){const t=s.message;if(typeof t.content=="string")return t.content;if(Array.isArray(t.content))return t.content.filter(n=>n.type==="text"&&typeof n.text=="string").map(n=>n.text).join("")}return""}function V(s,t){for(let n=s.length-1;n>=0;n--){const r=s[n];if(r&&r.type==="tool_call"&&r.toolCall.id===t)return n}return-1}class ct{constructor(t,n,r){S(this,"sessionId");S(this,"setEntries");S(this,"unsub",null);S(this,"onStatusChange");S(this,"onError");S(this,"onPermissionRequest");S(this,"onModelsStateChange");S(this,"onSubagentUpdate");S(this,"subagentState",ee());this.sessionId=t,this.setEntries=n,this.onStatusChange=r==null?void 0:r.onStatusChange,this.onError=r==null?void 0:r.onError,this.onPermissionRequest=r==null?void 0:r.onPermissionRequest,this.onModelsStateChange=r==null?void 0:r.onModelsStateChange,this.onSubagentUpdate=r==null?void 0:r.onSubagentUpdate}async init(){try{await me(this.sessionId)}catch{}await this.loadHistory(),this.connectSSE()}async loadHistory(){var x;const{events:t}=await xe(this.sessionId);if(!t||t.length===0)return;const n=[];let r=null;const c=()=>{r&&(n.push(r),r=null)};for(const u of t){const d=u.payload||{};if(u.type==="user"){if(u.direction==="inbound")continue;c();const i=Q(d);i&&n.push({type:"user_message",id:u.id||`hist-user-${n.length}`,content:i})}else if(u.type==="assistant"){c();const i=Q(d),l=[],a=d.message;if(a&&typeof a=="object"&&Array.isArray(a.content))for(const p of a.content)p.type==="tool_use"&&l.push({type:"tool_call",toolCall:{id:p.id||`hist-tool-${n.length}`,title:p.name||"tool",status:"complete",rawInput:p.input||{}}});if(i||l.length>0){r={type:"assistant_message",id:u.id||`hist-asst-${n.length}`,chunks:i?[{type:"message",text:i}]:[]},n.push(r);for(const p of l)n.push(p);r=null}}else if(u.type==="tool_use"){const i=d,l={type:"tool_call",toolCall:{id:i.tool_call_id||`hist-tool-${n.length}`,title:i.tool_name||"tool",status:"complete",rawInput:i.tool_input||{}}};n.push(l)}else if(u.type==="tool_result"){const i=d,l=V(n,i.tool_call_id||"");if(l>=0){const a=n[l];n[l]={type:"tool_call",toolCall:{...a.toolCall,rawOutput:{output:i.content||i.output||""}}}}}}c(),this.setEntries(n);let o=null;for(const u of t){if(u.type!=="models_state")continue;const d=u.payload||{},i=d.raw,l=i&&typeof i=="object"?i.models_state:d.models_state;l&&Array.isArray(l.availableModels)&&typeof l.currentModelId=="string"&&(o=l)}o&&((x=this.onModelsStateChange)==null||x.call(this,o))}connectSSE(){F.connect(this.sessionId),this.unsub=F.onEvent(t=>this.handleEvent(t))}disconnect(){this.unsub&&(this.unsub(),this.unsub=null),F.disconnect()}handleEvent(t){var o,x,u,d,i;const n=t.type,r=t.payload||{},c=JSON.stringify(t);if(!/Remote Control connecting/i.test(c))switch(n){case"assistant":{const l=typeof r.content=="string"?r.content:"";this.setEntries(p=>{const y=p[p.length-1];if((y==null?void 0:y.type)==="assistant_message"){const f=y.chunks[y.chunks.length-1];return(f==null?void 0:f.type)==="message"?[...p.slice(0,-1),{...y,chunks:[...y.chunks.slice(0,-1),{type:"message",text:f.text+l}]}]:[...p.slice(0,-1),{...y,chunks:[...y.chunks,{type:"message",text:l}]}]}if(l&&l.trim()){const f={type:"assistant_message",id:`assistant-${Date.now()}`,chunks:[{type:"message",text:l}]};return[...p,f]}return p});const a=r.message;if(a&&typeof a=="object"&&Array.isArray(a.content)){const p=a.content.filter(y=>y.type==="tool_use");for(const y of p){const g={id:y.id||`call-${Date.now()}-${Math.random().toString(16).slice(2,8)}`,title:y.name||"tool",status:"running",rawInput:y.input||{}};this.setEntries(b=>[...b,{type:"tool_call",toolCall:g}])}}break}case"tool_use":{const l=r,p={id:l.tool_call_id||`call-${Date.now()}`,title:l.tool_name||"tool",status:"running",rawInput:l.tool_input||{}};this.setEntries(y=>[...y,{type:"tool_call",toolCall:p}]);break}case"tool_result":{const l=r,a=l.tool_call_id||"";this.setEntries(p=>{const y=V(p,a);if(y<0)return p;const f=p[y];return p.map((g,b)=>b===y?{type:"tool_call",toolCall:{...f.toolCall,status:"complete",rawOutput:{output:l.content||l.output||""}}}:g)});break}case"control_request":case"permission_request":{const l=r.request;if(l&&l.subtype==="can_use_tool"){const a=r.request_id||"",p=l.tool_name||"unknown",y=l.input||l.tool_input||{},f=l.description||"";this.setEntries(g=>{const b=[...g].reverse().findIndex(w=>w.type==="tool_call");if(b>=0){const w=g.length-1-b,N=g[w];if(N.toolCall.status==="running")return g.map((C,M)=>M===w?{type:"tool_call",toolCall:{...N.toolCall,status:"waiting_for_confirmation",permissionRequest:{requestId:a,options:[]}}}:C)}return g}),(o=this.onPermissionRequest)==null||o.call(this,{requestId:a,toolName:p,toolInput:y,description:f})}break}case"session_status":{typeof r.status=="string"&&((x=this.onStatusChange)==null||x.call(this,r.status));break}case"error":{const l=String(r.message||r.content||"Unknown error");(u=this.onError)==null||u.call(this,l);break}case"models_state":{const l=r.raw,a=typeof l=="object"&&l!==null?l.models_state:r.models_state;a&&Array.isArray(a.availableModels)&&typeof a.currentModelId=="string"&&((d=this.onModelsStateChange)==null||d.call(this,a));break}case"system":{const l=r.raw,a=l&&typeof l=="object"?l:r,p=typeof a.subtype=="string"?a.subtype:void 0;if(p==="task_started"||p==="task_progress"||p==="task_notification"){const y={subtype:p,task_id:typeof a.task_id=="string"?a.task_id:void 0,tool_use_id:typeof a.tool_use_id=="string"?a.tool_use_id:void 0,description:typeof a.description=="string"?a.description:void 0,task_type:typeof a.task_type=="string"?a.task_type:void 0,workflow_name:typeof a.workflow_name=="string"?a.workflow_name:void 0,prompt:typeof a.prompt=="string"?a.prompt:void 0,usage:a.usage&&typeof a.usage=="object"?a.usage:void 0,last_tool_name:typeof a.last_tool_name=="string"?a.last_tool_name:void 0,summary:typeof a.summary=="string"?a.summary:void 0,status:a.status==="completed"||a.status==="failed"||a.status==="stopped"?a.status:void 0,output_file:typeof a.output_file=="string"?a.output_file:void 0};this.subagentState=at(this.subagentState,y),(i=this.onSubagentUpdate)==null||i.call(this,this.subagentState)}break}}}async sendMessage(t,n,r){const c=n&&n.length>0,o=r&&r.length>0;if(!t.trim()&&!c&&!o)return;const x={type:"user_message",id:`user-${Date.now()}`,content:t,images:c?n:void 0,attachments:o?r:void 0};this.setEntries(i=>[...i,x]);const u=[];if(t&&u.push({type:"text",text:t}),c)for(const i of n)u.push({type:"image",source:{type:"base64",media_type:i.mimeType,data:i.data}});if(o){for(const i of r)if(i.kind==="text"||i.kind==="table"){const l=`📎 ${i.name}${i.size!=null?` (${dt(i.size)})`:""}`,a=i.textContent||"(空文件)";u.push({type:"text",text:`${l}
|
|
47
47
|
\`\`\`
|
|
48
48
|
${a}
|
|
49
49
|
\`\`\``})}else if(i.kind==="directory"){const l=`📁 目录: ${i.name}${i.files!=null?` (${i.files.length} 个文件)`:""}`,a=i.textContent||"(空目录)";u.push({type:"text",text:`${l}
|
|
50
|
-
${a}`})}}const d=u.length===1&&u[0].type==="text"?u[0].text||t:u.length>0?u:t;await pe(this.sessionId,{type:"user",uuid:he(),content:t,message:{content:d}})}async respondPermission(t,n,r){await R(this.sessionId,{type:"permission_response",approved:n,request_id:t,...r}),this.setEntries(c=>c.map(o=>{var x;return o.type!=="tool_call"||((x=o.toolCall.permissionRequest)==null?void 0:x.requestId)!==t?o:{type:"tool_call",toolCall:{...o.toolCall,status:n?"running":"rejected",permissionRequest:void 0}}}))}async interrupt(){this.setEntries(t=>t.map(n=>n.type!=="tool_call"||n.toolCall.status!=="running"&&n.toolCall.status!=="waiting_for_confirmation"?n:{type:"tool_call",toolCall:{...n.toolCall,status:"canceled",permissionRequest:void 0}})),await fe(this.sessionId)}}function ct(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function dt(s){if(!s)return"never";const t=Math.max(0,Date.now()-s);return t<5e3?"just now":t<6e4?`${Math.floor(t/1e3)}s ago`:t<36e5?`${Math.floor(t/6e4)}m ago`:`${Math.floor(t/36e5)}h ago`}function ut(s){return s?Date.now()-s<6e4:!1}function mt({onClose:s,session:t,liveStatus:n,pendingPermissions:r,onInterrupt:c,onDelete:o}){const[x,u]=h.useState(!1),d=async()=>{await navigator.clipboard.writeText(t.id),u(!0),setTimeout(()=>u(!1),1500)},i=r.length,l=t.worker,a=t.work_item,p=t.environment;return e.jsx(ge,{open:!0,onOpenChange:y=>{y||s()},children:e.jsxs(be,{showCloseButton:!1,className:"fixed inset-y-0 right-0 top-auto left-auto translate-x-0 translate-y-0 w-full sm:w-96 h-full max-w-none max-h-none rounded-none border-l border-border bg-surface-1 p-4 sm:max-w-md overflow-y-auto",children:[e.jsx(je,{children:e.jsx(ke,{className:"font-display font-semibold text-text-primary",children:"Session Ops"})}),e.jsxs("div",{className:"mt-3 space-y-5 text-sm",children:[e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-text-muted",children:[e.jsx(We,{className:"h-3.5 w-3.5"}),"Status"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Y,{status:n||t.status||"unknown"}),e.jsx("span",{className:"text-xs text-text-muted",children:l&&(ut(l.last_heartbeat_at)?"· worker online":"· worker offline")})]}),e.jsxs("dl",{className:"space-y-1 text-xs text-text-muted",children:[l&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(L,{className:"h-3 w-3"}),"Heartbeat"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:dt(l.last_heartbeat_at)})]}),p&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(Ve,{className:"h-3 w-3"}),"Environment"]}),e.jsx("dd",{className:"truncate text-text-secondary",children:p.machine_name||p.id})]}),t.created_at&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(L,{className:"h-3 w-3"}),"Created"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:G(t.created_at)})]})]})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-text-muted",children:[e.jsx(X,{className:"h-3.5 w-3.5"}),"Pending Actions"]}),i>0?e.jsxs("div",{className:"rounded-md bg-status-warning/10 px-3 py-2 text-xs text-status-warning",children:[i," permission request",i>1?"s":""," awaiting your approval"]}):e.jsx("p",{className:"text-xs text-text-muted",children:"No pending actions"})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-text-muted",children:[e.jsx(st,{className:"h-3.5 w-3.5"}),"Quick Actions"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:c,className:"flex-1 rounded-md border border-border px-3 py-1.5 text-xs text-text-secondary hover:bg-surface-2 transition-colors",children:"Interrupt"}),e.jsxs("button",{onClick:o,className:"flex-1 rounded-md border border-status-error/30 px-3 py-1.5 text-xs text-status-error hover:bg-status-error/10 transition-colors",children:[e.jsx(we,{className:"mr-1 inline h-3 w-3"}),"Delete"]})]})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-text-muted",children:[e.jsx(Ye,{className:"h-3.5 w-3.5"}),"Session Info"]}),e.jsxs("dl",{className:"space-y-1 text-xs text-text-muted",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("dt",{children:"Session ID"}),e.jsxs("dd",{className:"flex items-center gap-1 min-w-0",children:[e.jsx("code",{className:"break-all font-mono text-text-secondary text-right",children:t.id}),e.jsx("button",{onClick:d,className:"text-text-muted hover:text-text-primary transition-colors flex-shrink-0",title:"Copy session id",children:x?"✓":"⧉"})]})]}),a&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Spawn mode"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:a.spawn_mode??"default"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Work state"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:a.state})]})]}),t.source&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Source"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:t.source})]}),p&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Worker type"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:p.worker_type})]})]})]})]})]})})}const J="rcs:subagent-panel:collapsed";function xt(s){if(s<1e3)return"0s";const t=Math.floor(s/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),r=t%60;if(n<60)return r?`${n}m${r}s`:`${n}m`;const c=Math.floor(n/60),o=n%60;return o?`${c}h${o}m`:`${c}h`}function pt(s){return s===void 0||s<=0?"":s<1e3?`${s}`:s<1e6?`${(s/1e3).toFixed(s<1e4?1:0)}k`:`${(s/1e6).toFixed(1)}M`}function ht({status:s}){return s==="running"?e.jsx(X,{className:"h-3 w-3 animate-spin text-brand"}):s==="completed"?e.jsx(et,{className:"h-3 w-3 text-status-success"}):s==="failed"||s==="stopped"?e.jsx(Ne,{className:"h-3 w-3 text-status-error"}):null}function ft({task:s}){const t=s.status==="running",n=t?s.durationMs??Date.now()-s.startTime:(s.endTime??Date.now())-s.startTime,r=pt(s.tokenCount),c=s.toolUseCount!==void 0&&s.toolUseCount>0?`${s.toolUseCount} tool${s.toolUseCount>1?"s":""}`:"",o=s.summary||s.description||"(no description)";return e.jsxs("div",{className:"flex items-start gap-2 rounded-md bg-surface-2 px-2.5 py-1.5 text-xs",children:[e.jsx("div",{className:"mt-0.5 flex-shrink-0",children:e.jsx(ht,{status:s.status})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("span",{className:"truncate font-medium text-text-primary",children:s.name}),e.jsx("span",{className:"flex-shrink-0 font-mono text-text-muted",children:xt(n)})]}),e.jsx("div",{className:"mt-0.5 truncate text-text-secondary",children:o}),(r||c||s.lastToolName)&&e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 font-mono text-[10px] text-text-muted",children:[r&&e.jsxs("span",{children:["↕ ",r," tok"]}),c&&e.jsxs("span",{children:["· ",c]}),s.lastToolName&&e.jsxs("span",{className:"truncate",children:["· last: ",s.lastToolName]})]}),!t&&s.finalSummary&&e.jsx("div",{className:"mt-1 rounded bg-status-success/10 px-1.5 py-0.5 text-[10px] text-status-success",children:s.finalSummary})]})]})}function yt({state:s}){const[t,n]=h.useState(()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(J)==="1"}catch{return!1}}),r=()=>{n(d=>{const i=!d;try{window.localStorage.setItem(J,i?"1":"0")}catch{}return i})},[,c]=h.useState(0);h.useEffect(()=>{const d=Object.values(s.tasks).some(a=>a.status==="running"),i=Object.values(s.tasks).some(a=>a.status!=="running"&&a.evictAfter!==void 0);if(!d&&!i)return;const l=setInterval(()=>{c(a=>a+1)},1e3);return()=>clearInterval(l)},[s]);const o=at(s);if(o.length===0)return null;const x=o.filter(d=>d.status==="running").length,u=x>0?`${x} running`:`${o.length} recent`;return e.jsx("section",{"aria-label":"Subagents",className:"border-t border-border bg-surface-1 px-4 py-2",children:e.jsxs("div",{className:"mx-auto max-w-3xl space-y-1.5",children:[e.jsxs("button",{type:"button",onClick:r,"aria-expanded":!t,"aria-controls":"subagent-list",className:"flex w-full items-center justify-between text-[10px] font-medium uppercase tracking-wide text-text-muted hover:text-text-secondary transition-colors",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Le,{className:`h-3 w-3 transition-transform ${t?"":"rotate-90"}`}),e.jsx("span",{children:"Subagents"})]}),e.jsx("span",{children:u})]}),!t&&e.jsx("div",{id:"subagent-list",className:"space-y-1.5",children:o.map(d=>e.jsx(ft,{task:d},d.taskId))})]})})}function gt({requestId:s,toolName:t,toolInput:n,description:r,onApprove:c,onReject:o}){const x=typeof n=="string"?n:JSON.stringify(n,null,2);return e.jsxs("div",{className:"rounded-xl border border-warning-border/30 bg-surface-1 p-4",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-warning-border/15 text-warning-text",children:e.jsx(rt,{className:"h-3 w-3"})}),e.jsx("span",{className:"text-sm font-semibold text-warning-text",children:"Permission Request"})]}),r&&e.jsx("div",{className:"mb-2 text-sm text-text-secondary",children:$(r)}),e.jsx("div",{className:"mb-2 font-mono text-xs font-bold text-text-primary",children:$(t)}),t!=="AskUserQuestion"&&e.jsx("pre",{className:"mb-3 max-h-40 overflow-auto rounded-lg bg-surface-1 p-2 text-xs text-text-secondary font-mono",children:_e(x,500)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:c,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light transition-colors",children:"Approve"}),e.jsx("button",{onClick:o,className:"rounded-lg bg-status-error/20 px-4 py-2 text-sm font-medium text-status-error hover:bg-status-error/30 transition-colors",children:"Reject"})]})]})}function bt({questions:s,description:t,onSubmit:n,onSkip:r}){const[c,o]=h.useState({}),[x,u]=h.useState({}),[d,i]=h.useState(0),l=(f,g,b)=>{if(b){const k=c[f]||[],N=k.includes(g)?k.filter(C=>C!==g):[...k,g];o({...c,[f]:N})}else o({...c,[f]:g})},a=f=>{var b;const g=(b=x[f])==null?void 0:b.trim();g&&(o({...c,[f]:g}),u({...x,[f]:""}))},p=()=>{var g,b;const f={};for(const[k,N]of Object.entries(c)){const C=s[parseInt(k,10)];C&&(typeof N=="number"?f[k]=((b=(g=C.options)==null?void 0:g[N])==null?void 0:b.label)||String(N):Array.isArray(N)?f[k]=N.map(M=>{var I,E;return((E=(I=C.options)==null?void 0:I[M])==null?void 0:E.label)||String(M)}):f[k]=N)}n(f)};if(s.length<=1){const f=s[0]||{question:t,options:[],multiSelect:!1},g=f.multiSelect||!1;return e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsx("div",{className:"mb-3 text-sm font-semibold text-text-primary",children:$(t||f.question||"Question")}),e.jsxs("div",{className:"space-y-2",children:[(f.options||[]).map((b,k)=>{const N=g?(c[0]||[]).includes(k):c[0]===k;return e.jsxs("button",{onClick:()=>l(0,k,g),className:q("w-full rounded-lg border px-4 py-2.5 text-left text-sm transition-colors",N?"border-brand bg-brand/10 text-text-primary":"border-border bg-surface-2 text-text-secondary hover:border-border-light"),children:[e.jsx("div",{className:"font-medium",children:$(b.label)}),b.description&&e.jsx("div",{className:"mt-0.5 text-xs text-text-muted",children:$(b.description)})]},k)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:x[0]||"",onChange:b=>u({...x,0:b.target.value}),placeholder:"Other...",className:"flex-1 rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none",onKeyDown:b=>b.key==="Enter"&&a(0)}),e.jsx("button",{onClick:()=>a(0),className:"rounded-lg border border-border px-3 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Send"})]})]}),e.jsxs("div",{className:"mt-4 flex gap-2",children:[e.jsx("button",{onClick:p,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light transition-colors",children:"Submit"}),e.jsx("button",{onClick:r,className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Skip"})]})]})}const y=s[d];return e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsx("div",{className:"mb-3 text-sm font-semibold text-text-primary",children:$(t||"Questions")}),e.jsx("div",{className:"mb-3 flex gap-1 overflow-x-auto",children:s.map((f,g)=>e.jsx("button",{onClick:()=>i(g),className:q("rounded-md px-3 py-1.5 text-xs whitespace-nowrap transition-colors",d===g?"bg-brand/20 text-brand":"text-text-muted hover:bg-surface-2"),children:f.header||`Q${g+1}`},g))}),y&&e.jsx(jt,{question:y,qIdx:d,answers:c,otherTexts:x,onSelect:l,onOtherTextChange:(f,g)=>u({...x,[f]:g}),onOtherSubmit:a}),e.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-text-muted",children:[d+1," / ",s.length]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:p,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light transition-colors",children:"Submit All"}),e.jsx("button",{onClick:r,className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Skip"})]})]})]})}function jt({question:s,qIdx:t,answers:n,otherTexts:r,onSelect:c,onOtherTextChange:o,onOtherSubmit:x}){const u=s.multiSelect||!1;return e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-sm text-text-secondary",children:$(s.question)}),e.jsxs("div",{className:"space-y-2",children:[(s.options||[]).map((d,i)=>{const l=u?(n[t]||[]).includes(i):n[t]===i;return e.jsxs("button",{onClick:()=>c(t,i,u),className:q("w-full rounded-lg border px-4 py-2.5 text-left text-sm transition-colors",l?"border-brand bg-brand/10 text-text-primary":"border-border bg-surface-2 text-text-secondary hover:border-border-light"),children:[e.jsx("div",{className:"font-medium",children:$(d.label)}),d.description&&e.jsx("div",{className:"mt-0.5 text-xs text-text-muted",children:$(d.description)})]},i)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:r[t]||"",onChange:d=>o(t,d.target.value),placeholder:"Other...",className:"flex-1 rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none",onKeyDown:d=>d.key==="Enter"&&x(t)}),e.jsx("button",{onClick:()=>x(t),className:"rounded-lg border border-border px-3 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Send"})]})]})]})}function kt({planContent:s,description:t,onSubmit:n}){const[r,c]=h.useState(null),[o,x]=h.useState(""),u=!s||!s.trim(),d=()=>{r&&n(r,r==="no"?o:void 0)};return e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-brand/15 text-brand",children:e.jsx(ve,{className:"h-3 w-3",strokeWidth:2.5})}),e.jsx("span",{className:"text-sm font-semibold text-text-primary",children:u?"Exit plan mode?":"Ready to code?"})]}),!u&&e.jsx("div",{className:"mb-4 max-h-64 overflow-auto rounded-lg bg-tool-card p-4 text-sm text-text-secondary",dangerouslySetInnerHTML:{__html:wt(s)}}),e.jsx("div",{className:"space-y-2",children:u?e.jsxs(e.Fragment,{children:[e.jsx(P,{selected:r==="yes-default",onClick:()=>c("yes-default"),label:"Yes"}),e.jsx(P,{selected:r==="no",onClick:()=>c("no"),label:"No"})]}):e.jsxs(e.Fragment,{children:[e.jsx(P,{selected:r==="yes-accept-edits",onClick:()=>c("yes-accept-edits"),label:"Yes, auto-accept edits",desc:"Approve plan and auto-accept file edits"}),e.jsx(P,{selected:r==="yes-default",onClick:()=>c("yes-default"),label:"Yes, manually approve edits",desc:"Approve plan but confirm each edit"}),e.jsx(P,{selected:r==="no",onClick:()=>c("no"),label:"No, keep planning",desc:"Provide feedback to refine the plan"})]})}),r==="no"&&e.jsx("textarea",{value:o,onChange:i=>x(i.target.value),placeholder:"Tell Saluzi what to change...",className:"mt-3 w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none",rows:3}),e.jsx("div",{className:"mt-4",children:e.jsx("button",{onClick:d,disabled:!r,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light disabled:opacity-50 transition-colors",children:"Submit"})})]})}function P({selected:s,onClick:t,label:n,desc:r}){return e.jsxs("button",{onClick:t,className:q("w-full rounded-lg border px-4 py-2.5 text-left text-sm transition-colors",s?"border-brand bg-brand/10 text-text-primary":"border-border bg-surface-2 text-text-secondary hover:border-border-light"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:q("flex h-4 w-4 items-center justify-center rounded-full border text-[10px] transition-colors",s?"border-brand bg-brand text-white":"border-border"),children:s&&"✓"}),e.jsx("span",{className:"font-medium",children:n})]}),r&&e.jsx("div",{className:"mt-0.5 pl-6 text-xs text-text-muted",children:r})]})}function wt(s){let t=$(s);return t=t.replace(/```(\w*)\n?([\s\S]*?)```/g,(n,r,c)=>`<pre class="my-2 overflow-x-auto rounded-lg bg-tool-card p-3 font-mono text-xs">${c.trim()}</pre>`),t=t.replace(/`([^`]+)`/g,'<code class="rounded bg-tool-card px-1.5 py-0.5 font-mono text-xs">$1</code>'),t=t.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),t}function Nt(s){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/acp/relay/${s}`}function vt(s){const t=Nt(s),n=Ce(),r=n?{proxyUrl:t,token:n}:{proxyUrl:t};return new Se(r)}function Pt({sessionId:s,onSessionLoaded:t}){const[n,r]=h.useState(null),[c,o]=h.useState(null),[x,u]=h.useState(""),[d,i]=h.useState(""),[l,a]=h.useState(0),[p,y]=h.useState(!1),[f,g]=h.useState(!1),[b,k]=h.useState([]),[N,C]=h.useState(!1),[M,I]=h.useState([]),[E,H]=h.useState(null),[te,se]=h.useState(()=>ee()),ne=h.useRef(null),W=h.useRef(b);W.current=b;const _=h.useMemo(()=>new lt(s,k,{onStatusChange:m=>{o(m)},onError:m=>{console.error("[RCSChatAdapter] error:",m)},onPermissionRequest:m=>{I(w=>w.some(j=>j.requestId===m.requestId)?w:[...w,m])},onModelsStateChange:m=>{H(m)},onSubagentUpdate:m=>{se(m)}}),[s]);h.useEffect(()=>(ne.current=_,()=>{_.disconnect()}),[_]),h.useEffect(()=>{let m=!1;async function w(){u(""),i("");try{const j=await Re(s);if(m)return;r(j),o(j.status),t==null||t(j),qe(j.id,j.environment_id),De([j])}catch(j){if(m)return;if(j instanceof Ue&&(j.type==="worker_token_required"||j.type==="worker_token_mismatch")){i(j.message);return}u(j instanceof Error?j.message:"Failed to load session");return}try{await _.init()}catch(j){console.warn("Failed to init adapter:",j)}}return w(),()=>{m=!0}},[s,_,l,t]);const D=Oe(c),re=h.useCallback(async m=>{const w=m.text.trim(),j=m.images&&m.images.length>0||m.attachments&&m.attachments.length>0;if(!w&&!j||D)return;const v=await Me(w,{sessionId:s,availableCommands:[],availableModels:(E==null?void 0:E.availableModels)??[],currentModel:E?{modelId:E.currentModelId,name:E.currentModelId}:null,supportsImages:!0,entries:W.current,setModel:async T=>{await R(s,{type:"control_request",request:{subtype:"set_model",model:T}}),H(O=>O&&{...O,currentModelId:T})},onNewSession:()=>{k([])}}).catch(()=>null);if(v){if(Ee("[SessionDetail] local command result",v),"clearEntries"in v&&v.clearEntries){k([]);return}if("newSession"in v&&v.newSession){k([]);return}if("userEntry"in v){k(T=>[...T,v.userEntry,v.cmdEntry]);return}}C(!0);try{await _.sendMessage(w,m.images,m.attachments)}catch(T){console.error("Send failed:",T)}},[_,D,s,E]),z=h.useCallback(async()=>{try{await _.interrupt()}catch(m){console.error("Interrupt failed:",m)}finally{C(!1)}},[_]),oe=h.useCallback(async()=>{if(!n||!window.confirm(`删除会话 ${n.title||n.id}?此操作不可恢复。`))return;const m=n.environment_id;if(m&&!Te(m)&&!B(n.id)){alert(`该会话的 environment 受 worker token 保护,但本地未保存对应 token。
|
|
51
|
-
请点击导航栏 Token → Worker Tokens 添加该 environment 的 token 后再删除。`);return}try{await $e(n.id),window.location.href="/code/"}catch(
|
|
50
|
+
${a}`})}}const d=u.length===1&&u[0].type==="text"?u[0].text||t:u.length>0?u:t;await pe(this.sessionId,{type:"user",uuid:he(),content:t,message:{content:d}})}async respondPermission(t,n,r){await R(this.sessionId,{type:"permission_response",approved:n,request_id:t,...r}),this.setEntries(c=>c.map(o=>{var x;return o.type!=="tool_call"||((x=o.toolCall.permissionRequest)==null?void 0:x.requestId)!==t?o:{type:"tool_call",toolCall:{...o.toolCall,status:n?"running":"rejected",permissionRequest:void 0}}}))}async interrupt(){this.setEntries(t=>t.map(n=>n.type!=="tool_call"||n.toolCall.status!=="running"&&n.toolCall.status!=="waiting_for_confirmation"?n:{type:"tool_call",toolCall:{...n.toolCall,status:"canceled",permissionRequest:void 0}})),await fe(this.sessionId)}}function dt(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function ut(s){if(!s)return"never";const t=Math.max(0,Date.now()-s);return t<5e3?"just now":t<6e4?`${Math.floor(t/1e3)}s ago`:t<36e5?`${Math.floor(t/6e4)}m ago`:`${Math.floor(t/36e5)}h ago`}function mt(s){return s?Date.now()-s<6e4:!1}function xt({onClose:s,session:t,liveStatus:n,pendingPermissions:r,onInterrupt:c,onDelete:o}){const[x,u]=h.useState(!1),d=async()=>{await navigator.clipboard.writeText(t.id),u(!0),setTimeout(()=>u(!1),1500)},i=r.length,l=t.worker,a=t.work_item,p=t.environment;return e.jsx(ge,{open:!0,onOpenChange:y=>{y||s()},children:e.jsxs(be,{showCloseButton:!1,className:"fixed inset-y-0 right-0 top-auto left-auto translate-x-0 translate-y-0 w-full sm:w-96 h-full max-w-none max-h-none rounded-none border-l border-border bg-surface-1 p-4 sm:max-w-md overflow-y-auto",children:[e.jsx(je,{children:e.jsx(ke,{className:"font-display font-semibold text-text-primary",children:"Session Ops"})}),e.jsxs("div",{className:"mt-3 space-y-5 text-sm",children:[e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-text-muted",children:[e.jsx(ze,{className:"h-3.5 w-3.5"}),"Status"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Y,{status:n||t.status||"unknown"}),e.jsx("span",{className:"text-xs text-text-muted",children:l&&(mt(l.last_heartbeat_at)?"· worker online":"· worker offline")})]}),e.jsxs("dl",{className:"space-y-1 text-xs text-text-muted",children:[l&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(L,{className:"h-3 w-3"}),"Heartbeat"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:ut(l.last_heartbeat_at)})]}),p&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(Je,{className:"h-3 w-3"}),"Environment"]}),e.jsx("dd",{className:"truncate text-text-secondary",children:p.machine_name||p.id})]}),t.created_at&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(L,{className:"h-3 w-3"}),"Created"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:G(t.created_at)})]})]})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-text-muted",children:[e.jsx(X,{className:"h-3.5 w-3.5"}),"Pending Actions"]}),i>0?e.jsxs("div",{className:"rounded-md bg-status-warning/10 px-3 py-2 text-xs text-status-warning",children:[i," permission request",i>1?"s":""," awaiting your approval"]}):e.jsx("p",{className:"text-xs text-text-muted",children:"No pending actions"})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-text-muted",children:[e.jsx(nt,{className:"h-3.5 w-3.5"}),"Quick Actions"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:c,className:"flex-1 rounded-md border border-border px-3 py-1.5 text-xs text-text-secondary hover:bg-surface-2 transition-colors",children:"Interrupt"}),e.jsxs("button",{onClick:o,className:"flex-1 rounded-md border border-status-error/30 px-3 py-1.5 text-xs text-status-error hover:bg-status-error/10 transition-colors",children:[e.jsx(we,{className:"mr-1 inline h-3 w-3"}),"Delete"]})]})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-text-muted",children:[e.jsx(Ge,{className:"h-3.5 w-3.5"}),"Session Info"]}),e.jsxs("dl",{className:"space-y-1 text-xs text-text-muted",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("dt",{children:"Session ID"}),e.jsxs("dd",{className:"flex items-center gap-1 min-w-0",children:[e.jsx("code",{className:"break-all font-mono text-text-secondary text-right",children:t.id}),e.jsx("button",{onClick:d,className:"text-text-muted hover:text-text-primary transition-colors flex-shrink-0",title:"Copy session id",children:x?"✓":"⧉"})]})]}),a&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Spawn mode"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:a.spawn_mode??"default"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Work state"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:a.state})]})]}),t.source&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Source"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:t.source})]}),p&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Worker type"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:p.worker_type})]})]})]})]})]})})}const J="rcs:subagent-panel:collapsed";function pt(s){if(s<1e3)return"0s";const t=Math.floor(s/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),r=t%60;if(n<60)return r?`${n}m${r}s`:`${n}m`;const c=Math.floor(n/60),o=n%60;return o?`${c}h${o}m`:`${c}h`}function ht(s){return s===void 0||s<=0?"":s<1e3?`${s}`:s<1e6?`${(s/1e3).toFixed(s<1e4?1:0)}k`:`${(s/1e6).toFixed(1)}M`}function ft({status:s}){return s==="running"?e.jsx(X,{className:"h-3 w-3 animate-spin text-brand"}):s==="completed"?e.jsx(tt,{className:"h-3 w-3 text-status-success"}):s==="failed"||s==="stopped"?e.jsx(Ne,{className:"h-3 w-3 text-status-error"}):null}function yt({task:s}){const t=s.status==="running",n=t?s.durationMs??Date.now()-s.startTime:(s.endTime??Date.now())-s.startTime,r=ht(s.tokenCount),c=s.toolUseCount!==void 0&&s.toolUseCount>0?`${s.toolUseCount} tool${s.toolUseCount>1?"s":""}`:"",o=s.summary||s.description||"(no description)";return e.jsxs("div",{className:"flex items-start gap-2 rounded-md bg-surface-2 px-2.5 py-1.5 text-xs",children:[e.jsx("div",{className:"mt-0.5 flex-shrink-0",children:e.jsx(ft,{status:s.status})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("span",{className:"truncate font-medium text-text-primary",children:s.name}),e.jsx("span",{className:"flex-shrink-0 font-mono text-text-muted",children:pt(n)})]}),e.jsx("div",{className:"mt-0.5 truncate text-text-secondary",children:o}),(r||c||s.lastToolName)&&e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 font-mono text-[10px] text-text-muted",children:[r&&e.jsxs("span",{children:["↕ ",r," tok"]}),c&&e.jsxs("span",{children:["· ",c]}),s.lastToolName&&e.jsxs("span",{className:"truncate",children:["· last: ",s.lastToolName]})]}),!t&&s.finalSummary&&e.jsx("div",{className:"mt-1 rounded bg-status-success/10 px-1.5 py-0.5 text-[10px] text-status-success",children:s.finalSummary})]})]})}function gt({state:s}){const[t,n]=h.useState(()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(J)==="1"}catch{return!1}}),r=()=>{n(d=>{const i=!d;try{window.localStorage.setItem(J,i?"1":"0")}catch{}return i})},[,c]=h.useState(0);h.useEffect(()=>{const d=Object.values(s.tasks).some(a=>a.status==="running"),i=Object.values(s.tasks).some(a=>a.status!=="running"&&a.evictAfter!==void 0);if(!d&&!i)return;const l=setInterval(()=>{c(a=>a+1)},1e3);return()=>clearInterval(l)},[s]);const o=it(s);if(o.length===0)return null;const x=o.filter(d=>d.status==="running").length,u=x>0?`${x} running`:`${o.length} recent`;return e.jsx("section",{"aria-label":"Subagents",className:"border-t border-border bg-surface-1 px-4 py-2",children:e.jsxs("div",{className:"mx-auto max-w-3xl space-y-1.5",children:[e.jsxs("button",{type:"button",onClick:r,"aria-expanded":!t,"aria-controls":"subagent-list",className:"flex w-full items-center justify-between text-[10px] font-medium uppercase tracking-wide text-text-muted hover:text-text-secondary transition-colors",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ke,{className:`h-3 w-3 transition-transform ${t?"":"rotate-90"}`}),e.jsx("span",{children:"Subagents"})]}),e.jsx("span",{children:u})]}),!t&&e.jsx("div",{id:"subagent-list",className:"space-y-1.5",children:o.map(d=>e.jsx(yt,{task:d},d.taskId))})]})})}function bt({requestId:s,toolName:t,toolInput:n,description:r,onApprove:c,onReject:o}){const x=typeof n=="string"?n:JSON.stringify(n,null,2);return e.jsxs("div",{className:"rounded-xl border border-warning-border/30 bg-surface-1 p-4",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-warning-border/15 text-warning-text",children:e.jsx(ot,{className:"h-3 w-3"})}),e.jsx("span",{className:"text-sm font-semibold text-warning-text",children:"Permission Request"})]}),r&&e.jsx("div",{className:"mb-2 text-sm text-text-secondary",children:$(r)}),e.jsx("div",{className:"mb-2 font-mono text-xs font-bold text-text-primary",children:$(t)}),t!=="AskUserQuestion"&&e.jsx("pre",{className:"mb-3 max-h-40 overflow-auto rounded-lg bg-surface-1 p-2 text-xs text-text-secondary font-mono",children:_e(x,500)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:c,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light transition-colors",children:"Approve"}),e.jsx("button",{onClick:o,className:"rounded-lg bg-status-error/20 px-4 py-2 text-sm font-medium text-status-error hover:bg-status-error/30 transition-colors",children:"Reject"})]})]})}function jt({questions:s,description:t,onSubmit:n,onSkip:r}){const[c,o]=h.useState({}),[x,u]=h.useState({}),[d,i]=h.useState(0),l=(f,g,b)=>{if(b){const w=c[f]||[],N=w.includes(g)?w.filter(C=>C!==g):[...w,g];o({...c,[f]:N})}else o({...c,[f]:g})},a=f=>{var b;const g=(b=x[f])==null?void 0:b.trim();g&&(o({...c,[f]:g}),u({...x,[f]:""}))},p=()=>{var g,b;const f={};for(const[w,N]of Object.entries(c)){const C=s[parseInt(w,10)];C&&(typeof N=="number"?f[w]=((b=(g=C.options)==null?void 0:g[N])==null?void 0:b.label)||String(N):Array.isArray(N)?f[w]=N.map(M=>{var I,E;return((E=(I=C.options)==null?void 0:I[M])==null?void 0:E.label)||String(M)}):f[w]=N)}n(f)};if(s.length<=1){const f=s[0]||{question:t,options:[],multiSelect:!1},g=f.multiSelect||!1;return e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsx("div",{className:"mb-3 text-sm font-semibold text-text-primary",children:$(t||f.question||"Question")}),e.jsxs("div",{className:"space-y-2",children:[(f.options||[]).map((b,w)=>{const N=g?(c[0]||[]).includes(w):c[0]===w;return e.jsxs("button",{onClick:()=>l(0,w,g),className:q("w-full rounded-lg border px-4 py-2.5 text-left text-sm transition-colors",N?"border-brand bg-brand/10 text-text-primary":"border-border bg-surface-2 text-text-secondary hover:border-border-light"),children:[e.jsx("div",{className:"font-medium",children:$(b.label)}),b.description&&e.jsx("div",{className:"mt-0.5 text-xs text-text-muted",children:$(b.description)})]},w)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:x[0]||"",onChange:b=>u({...x,0:b.target.value}),placeholder:"Other...",className:"flex-1 rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none",onKeyDown:b=>b.key==="Enter"&&a(0)}),e.jsx("button",{onClick:()=>a(0),className:"rounded-lg border border-border px-3 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Send"})]})]}),e.jsxs("div",{className:"mt-4 flex gap-2",children:[e.jsx("button",{onClick:p,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light transition-colors",children:"Submit"}),e.jsx("button",{onClick:r,className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Skip"})]})]})}const y=s[d];return e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsx("div",{className:"mb-3 text-sm font-semibold text-text-primary",children:$(t||"Questions")}),e.jsx("div",{className:"mb-3 flex gap-1 overflow-x-auto",children:s.map((f,g)=>e.jsx("button",{onClick:()=>i(g),className:q("rounded-md px-3 py-1.5 text-xs whitespace-nowrap transition-colors",d===g?"bg-brand/20 text-brand":"text-text-muted hover:bg-surface-2"),children:f.header||`Q${g+1}`},g))}),y&&e.jsx(kt,{question:y,qIdx:d,answers:c,otherTexts:x,onSelect:l,onOtherTextChange:(f,g)=>u({...x,[f]:g}),onOtherSubmit:a}),e.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-text-muted",children:[d+1," / ",s.length]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:p,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light transition-colors",children:"Submit All"}),e.jsx("button",{onClick:r,className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Skip"})]})]})]})}function kt({question:s,qIdx:t,answers:n,otherTexts:r,onSelect:c,onOtherTextChange:o,onOtherSubmit:x}){const u=s.multiSelect||!1;return e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-sm text-text-secondary",children:$(s.question)}),e.jsxs("div",{className:"space-y-2",children:[(s.options||[]).map((d,i)=>{const l=u?(n[t]||[]).includes(i):n[t]===i;return e.jsxs("button",{onClick:()=>c(t,i,u),className:q("w-full rounded-lg border px-4 py-2.5 text-left text-sm transition-colors",l?"border-brand bg-brand/10 text-text-primary":"border-border bg-surface-2 text-text-secondary hover:border-border-light"),children:[e.jsx("div",{className:"font-medium",children:$(d.label)}),d.description&&e.jsx("div",{className:"mt-0.5 text-xs text-text-muted",children:$(d.description)})]},i)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:r[t]||"",onChange:d=>o(t,d.target.value),placeholder:"Other...",className:"flex-1 rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none",onKeyDown:d=>d.key==="Enter"&&x(t)}),e.jsx("button",{onClick:()=>x(t),className:"rounded-lg border border-border px-3 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Send"})]})]})]})}function wt({planContent:s,description:t,onSubmit:n}){const[r,c]=h.useState(null),[o,x]=h.useState(""),u=!s||!s.trim(),d=()=>{r&&n(r,r==="no"?o:void 0)};return e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-brand/15 text-brand",children:e.jsx(ve,{className:"h-3 w-3",strokeWidth:2.5})}),e.jsx("span",{className:"text-sm font-semibold text-text-primary",children:u?"Exit plan mode?":"Ready to code?"})]}),!u&&e.jsx("div",{className:"mb-4 max-h-64 overflow-auto rounded-lg bg-tool-card p-4 text-sm text-text-secondary",dangerouslySetInnerHTML:{__html:Nt(s)}}),e.jsx("div",{className:"space-y-2",children:u?e.jsxs(e.Fragment,{children:[e.jsx(P,{selected:r==="yes-default",onClick:()=>c("yes-default"),label:"Yes"}),e.jsx(P,{selected:r==="no",onClick:()=>c("no"),label:"No"})]}):e.jsxs(e.Fragment,{children:[e.jsx(P,{selected:r==="yes-accept-edits",onClick:()=>c("yes-accept-edits"),label:"Yes, auto-accept edits",desc:"Approve plan and auto-accept file edits"}),e.jsx(P,{selected:r==="yes-default",onClick:()=>c("yes-default"),label:"Yes, manually approve edits",desc:"Approve plan but confirm each edit"}),e.jsx(P,{selected:r==="no",onClick:()=>c("no"),label:"No, keep planning",desc:"Provide feedback to refine the plan"})]})}),r==="no"&&e.jsx("textarea",{value:o,onChange:i=>x(i.target.value),placeholder:"Tell Saluzi what to change...",className:"mt-3 w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none",rows:3}),e.jsx("div",{className:"mt-4",children:e.jsx("button",{onClick:d,disabled:!r,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light disabled:opacity-50 transition-colors",children:"Submit"})})]})}function P({selected:s,onClick:t,label:n,desc:r}){return e.jsxs("button",{onClick:t,className:q("w-full rounded-lg border px-4 py-2.5 text-left text-sm transition-colors",s?"border-brand bg-brand/10 text-text-primary":"border-border bg-surface-2 text-text-secondary hover:border-border-light"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:q("flex h-4 w-4 items-center justify-center rounded-full border text-[10px] transition-colors",s?"border-brand bg-brand text-white":"border-border"),children:s&&"✓"}),e.jsx("span",{className:"font-medium",children:n})]}),r&&e.jsx("div",{className:"mt-0.5 pl-6 text-xs text-text-muted",children:r})]})}function Nt(s){let t=$(s);return t=t.replace(/```(\w*)\n?([\s\S]*?)```/g,(n,r,c)=>`<pre class="my-2 overflow-x-auto rounded-lg bg-tool-card p-3 font-mono text-xs">${c.trim()}</pre>`),t=t.replace(/`([^`]+)`/g,'<code class="rounded bg-tool-card px-1.5 py-0.5 font-mono text-xs">$1</code>'),t=t.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),t}function vt(s){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/acp/relay/${s}`}function _t(s){const t=vt(s),n=Ce(),r=n?{proxyUrl:t,token:n}:{proxyUrl:t};return new Se(r)}function qt({sessionId:s,onSessionLoaded:t}){const[n,r]=h.useState(null),[c,o]=h.useState(null),[x,u]=h.useState(""),[d,i]=h.useState(""),[l,a]=h.useState(0),[p,y]=h.useState(!1),[f,g]=h.useState(!1),[b,w]=h.useState([]),[N,C]=h.useState(!1),[M,I]=h.useState([]),[E,W]=h.useState(null),[te,se]=h.useState(()=>ee()),ne=h.useRef(null),H=h.useRef(b);H.current=b;const _=h.useMemo(()=>new ct(s,w,{onStatusChange:m=>{o(m)},onError:m=>{console.error("[RCSChatAdapter] error:",m)},onPermissionRequest:m=>{I(k=>k.some(j=>j.requestId===m.requestId)?k:[...k,m])},onModelsStateChange:m=>{W(m)},onSubagentUpdate:m=>{se(m)}}),[s]);h.useEffect(()=>(ne.current=_,()=>{_.disconnect()}),[_]),h.useEffect(()=>{let m=!1;async function k(){u(""),i("");try{const j=await Re(s);if(m)return;r(j),o(j.status),t==null||t(j),qe(j.id,j.environment_id),De([j])}catch(j){if(m)return;if(j instanceof Ue&&(j.type==="worker_token_required"||j.type==="worker_token_mismatch")){i(j.message);return}u(j instanceof Error?j.message:"Failed to load session");return}try{await _.init()}catch(j){console.warn("Failed to init adapter:",j)}}return k(),()=>{m=!0}},[s,_,l,t]);const D=Oe(c),re=h.useCallback(async m=>{const k=m.text.trim(),j=m.images&&m.images.length>0||m.attachments&&m.attachments.length>0;if(!k&&!j||D)return;const v=await Me(k,{sessionId:s,availableCommands:[],availableModels:(E==null?void 0:E.availableModels)??[],currentModel:E?{modelId:E.currentModelId,name:E.currentModelId}:null,supportsImages:!0,entries:H.current,setModel:async T=>{await R(s,{type:"control_request",request:{subtype:"set_model",model:T}}),W(O=>O&&{...O,currentModelId:T})},onNewSession:()=>{w([])}}).catch(()=>null);if(v){if(Ee("[SessionDetail] local command result",v),"clearEntries"in v&&v.clearEntries){w([]);return}if("newSession"in v&&v.newSession){w([]);return}if("userEntry"in v){w(T=>[...T,v.userEntry,v.cmdEntry]);return}}C(!0);try{await _.sendMessage(k,m.images,m.attachments)}catch(T){console.error("Send failed:",T)}},[_,D,s,E]),z=h.useCallback(async()=>{try{await _.interrupt()}catch(m){console.error("Interrupt failed:",m)}finally{C(!1)}},[_]),oe=h.useCallback(async()=>{if(!n||!window.confirm(`删除会话 ${n.title||n.id}?此操作不可恢复。`))return;const m=n.environment_id;if(m&&!Te(m)&&!B(n.id)){alert(`该会话的 environment 受 worker token 保护,但本地未保存对应 token。
|
|
51
|
+
请点击导航栏 Token → Worker Tokens 添加该 environment 的 token 后再删除。`);return}try{await $e(n.id),window.location.href="/code/"}catch(k){alert(k instanceof Error?k.message:"Failed to delete session")}},[n]);h.useEffect(()=>{if(b.length===0)return;const m=b[b.length-1];if((m==null?void 0:m.type)==="assistant_message"||(m==null?void 0:m.type)==="tool_call"){if(m.type==="tool_call"&&m.toolCall.status==="running")return;C(!1)}},[b]);const ae=h.useCallback(async m=>{try{await _.respondPermission(m,!0)}catch(k){console.error("Failed to approve:",k)}I(k=>k.filter(j=>j.requestId!==m))},[_]),ie=h.useCallback(async m=>{try{await _.respondPermission(m,!1)}catch(k){console.error("Failed to reject:",k)}I(k=>k.filter(j=>j.requestId!==m))},[_]),le=h.useCallback(async(m,k,j)=>{try{await R(s,{type:"permission_response",approved:!0,request_id:m,updated_input:{questions:j,answers:k}})}catch(v){console.error("Failed to submit answers:",v)}I(v=>v.filter(T=>T.requestId!==m))},[s]),ce=h.useCallback(async(m,k,j)=>{try{k==="no"?await R(s,{type:"permission_response",approved:!1,request_id:m,...j?{message:j}:{}}):await R(s,{type:"permission_response",approved:!0,request_id:m,updated_permissions:[{type:"setMode",mode:{"yes-accept-edits":"acceptEdits","yes-default":"default"}[k]||"default",destination:"session"}]})}catch(v){console.error("Failed to submit plan response:",v)}I(v=>v.filter(T=>T.requestId!==m))},[s]);return d?e.jsx(Ct,{sessionId:s,message:d,onSubmit:m=>{Ae(s,m),i(""),a(k=>k+1)}}):x?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-status-error",children:x}),e.jsx("a",{href:"/code/",className:"mt-4 inline-block text-brand hover:underline",children:"← Back to Dashboard"})]})}):n?n.source==="acp"&&n.environment_id?e.jsx(Mt,{sessionId:s,agentId:n.environment_id}):e.jsx(Z,{children:e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsx("h1",{className:"sr-only",children:n.title||n.id}),e.jsx("div",{className:"border-b bg-surface-1 px-4 py-3",children:e.jsxs("div",{className:"mx-auto max-w-5xl",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"font-display text-lg font-semibold text-text-primary",children:e.jsx("span",{className:"truncate",children:n.title||n.id})}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:[(()=>{var j;const m=n.source==="acp"?"acp":(j=n.environment)==null?void 0:j.worker_type,k=We(m);return e.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${k.colorClass}`,children:k.fullLabel})})(),c&&e.jsx(Y,{status:c}),e.jsx("span",{className:"text-xs text-text-muted",children:G(n.created_at)})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>g(!f),className:"flex items-center gap-1 rounded-md px-2 py-1 text-xs text-text-muted hover:bg-surface-2 hover:text-text-secondary transition-colors",title:"Session info",children:e.jsx(Ze,{className:"h-3.5 w-3.5"})}),e.jsxs("button",{onClick:()=>y(!p),className:"flex items-center gap-1 rounded-md px-3 py-1.5 text-sm text-text-primary font-bold hover:bg-brand-light hover:text-white transition-colors",children:["Tasks",M.length>0&&e.jsx("span",{className:"ml-1 rounded-full bg-status-warning px-1.5 py-0.5 text-[10px] font-medium text-white",children:M.length})]})]})]}),f&&e.jsxs("div",{className:"mt-2 rounded-md bg-surface-2 px-3 py-2 text-xs text-text-muted space-y-1 font-mono",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-text-primary font-bold font-sans",children:"Session"})," ",n.id]}),n.environment_id&&e.jsxs("div",{children:[e.jsx("span",{className:"text-text-primary font-bold font-sans",children:"Environment"})," ",n.environment_id]})]})]})}),e.jsx(Ie,{entries:b,isLoading:N,emptyTitle:"开始对话",emptyDescription:"输入消息开始聊天"}),e.jsx(gt,{state:te}),M.length>0&&e.jsx("div",{className:"border-t bg-surface-1 px-4 py-3",children:e.jsx("div",{className:"mx-auto max-w-3xl space-y-3",children:M.map(m=>e.jsx(St,{request:m,onApprove:()=>ae(m.requestId),onReject:()=>ie(m.requestId),onSubmitAnswers:le,onSubmitPlan:ce},m.requestId))})}),e.jsx(Pe,{onSubmit:re,isLoading:N,onInterrupt:z,disabled:D,placeholder:D?"会话已关闭":"输入消息...",supportsAttachments:!0}),p&&n&&e.jsx(xt,{onClose:()=>y(!1),session:n,liveStatus:c,pendingPermissions:M,onInterrupt:z,onDelete:oe})]})}):e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsx("div",{className:"text-text-muted",children:"Loading session..."})})}function St({request:s,onApprove:t,onReject:n,onSubmitAnswers:r,onSubmitPlan:c}){const o=s.toolName,x=s.toolInput,u=s.description||"";if(o==="AskUserQuestion"){const d=x.questions||[];return e.jsx(jt,{requestId:s.requestId,questions:d,description:u,onSubmit:i=>r(s.requestId,i,d),onSkip:n})}if(o==="ExitPlanMode"){const d=x.plan||"";return e.jsx(wt,{requestId:s.requestId,planContent:d,description:u,onSubmit:(i,l)=>c(s.requestId,i,l)})}return e.jsx(bt,{requestId:s.requestId,toolName:o,toolInput:x,description:u,onApprove:t,onReject:n})}function Ct({sessionId:s,message:t,onSubmit:n}){const[r,c]=h.useState(()=>B(s)??""),o=x=>{x.preventDefault();const u=r.trim();u&&n(u)};return e.jsx("div",{className:"flex flex-1 items-center justify-center px-4 py-8",children:e.jsxs("form",{onSubmit:o,className:"w-full max-w-md rounded-xl border border-border bg-surface-1 p-6 shadow-lg",children:[e.jsx("h2",{className:"mb-2 font-display text-lg font-semibold text-text-primary",children:"Worker Token Required"}),e.jsx("p",{className:"mb-4 text-sm text-status-error",children:t}),e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:"Worker Token"}),e.jsx("input",{type:"password",value:r,onChange:x=>c(x.target.value),autoFocus:!0,placeholder:"RCS_WORKER_TOKENS value",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none font-mono"}),e.jsx("p",{className:"mt-2 text-xs text-text-muted",children:"该会话的 environment 受 RCS_WORKER_TOKENS 保护。请向创建者索取对应的 token,输入后即可访问同一会话。"}),e.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2",children:[e.jsx("a",{href:"/code/",className:"text-sm text-text-muted hover:text-text-secondary hover:underline",children:"← Back to Dashboard"}),e.jsx("button",{type:"submit",disabled:!r.trim(),className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light disabled:opacity-50 transition-colors",children:"Submit"})]})]})})}function Mt({sessionId:s,agentId:t}){const[n,r]=h.useState(null),[c,o]=h.useState("disconnected"),[x,u]=h.useState(null),d=h.useRef(null);return h.useEffect(()=>{const i=_t(t);return i.setConnectionStateHandler((l,a)=>{o(l),u(a||null)}),d.current=i,r(i),i.connect().catch(l=>{l instanceof Fe||(u(l.message),o("error"))}),()=>{i.disconnect(),d.current=null,r(null),o("disconnected")}},[t]),e.jsx(Z,{children:e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[x&&c==="error"&&e.jsx("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-sm border-b",children:x}),c==="connecting"&&e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin h-8 w-8 border-2 border-brand border-t-transparent rounded-full mx-auto mb-3"}),e.jsx("p",{className:"text-text-muted text-sm",children:"Connecting to agent..."})]})}),c==="error"&&!n&&e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium mb-1",children:"Connection Failed"}),e.jsx("p",{className:"text-text-muted text-sm",children:x})]})}),n&&c==="connected"&&e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Be,{client:n,agentId:t})})]})})}export{qt as SessionDetail};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{bl as ln,aO as an,H as z,b8 as w,F as G,ah as un,W as y,bd as tn,b9 as J,aI as _,c as rn,m as o,aG as on,j as sn,d as fn}from"./mermaid.core-
|
|
1
|
+
import{bl as ln,aO as an,H as z,b8 as w,F as G,ah as un,W as y,bd as tn,b9 as J,aI as _,c as rn,m as o,aG as on,j as sn,d as fn}from"./mermaid.core-slLRH1UY.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,j,I,v,A,H,a){var q=j-l,i=I-h,n=H-v,d=a-A,u=d*q-n*i;if(!(u*u<y))return u=(n*(h-A)-d*(l-v))/u,[l+u*q,h+u*i]}function U(l,h,j,I,v,A,H){var a=l-j,q=h-I,i=(H?A:-A)/J(a*a+q*q),n=i*q,d=-i*a,u=l+n,s=h+d,f=j+n,c=I+d,S=(u+f)/2,t=(s+c)/2,m=f-u,g=c-s,R=m*m+g*g,T=v-A,P=u*c-f*s,D=(g<0?-1:1)*J(on(0,T*T*R-P*P)),E=(P*g-m*D)/R,F=(-P*m-g*D)/R,b=(P*g+m*D)/R,p=(-P*m+g*D)/R,x=E-S,e=F-t,r=b-S,W=p-t;return x*x+e*e>r*r+W*W&&(E=b,F=p),{cx:E,cy:F,x01:-n,y01:-d,x11:E*(v/T-1),y11:F*(v/T-1)}}function hn(){var l=cn,h=yn,j=G(0),I=null,v=gn,A=dn,H=mn,a=null,q=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-un,c=A.apply(this,arguments)-un,S=rn(c-f),t=c>f;if(a||(a=n=q()),s<u&&(d=s,s=u,u=d),!(s>y))a.moveTo(0,0);else if(S>tn-y)a.moveTo(s*z(f),s*w(f)),a.arc(0,0,s,f,c,!t),u>y&&(a.moveTo(u*z(c),u*w(c)),a.arc(0,0,u,c,f,t));else{var m=f,g=c,R=f,T=c,P=S,D=S,E=H.apply(this,arguments)/2,F=E>y&&(I?+I.apply(this,arguments):J(u*u+s*s)),b=_(rn(s-u)/2,+j.apply(this,arguments)),p=b,x=b,e,r;if(F>y){var W=sn(F/u*w(E)),K=sn(F/s*w(E));(P-=W*2)>y?(W*=t?1:-1,R+=W,T-=W):(P=0,R=T=(f+c)/2),(D-=K*2)>y?(K*=t?1:-1,m+=K,g-=K):(D=0,m=g=(f+c)/2)}var B=s*z(m),C=s*w(m),L=u*z(T),M=u*w(T);if(b>y){var N=s*z(g),Q=s*w(g),V=u*z(R),X=u*w(R),O;if(S<an)if(O=pn(B,C,V,X,N,Q,L,M)){var Y=B-O[0],Z=C-O[1],$=N-O[0],k=Q-O[1],nn=1/w(fn((Y*$+Z*k)/(J(Y*Y+Z*Z)*J($*$+k*k)))/2),en=J(O[0]*O[0]+O[1]*O[1]);p=_(b,(u-en)/(nn-1)),x=_(b,(s-en)/(nn+1))}else p=x=0}D>y?x>y?(e=U(V,X,B,C,s,x,t),r=U(N,Q,L,M,s,x,t),a.moveTo(e.cx+e.x01,e.cy+e.y01),x<b?a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),a.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(a.moveTo(B,C),a.arc(0,0,s,m,g,!t)):a.moveTo(B,C),!(u>y)||!(P>y)?a.lineTo(L,M):p>y?(e=U(L,M,N,Q,u,-p,t),r=U(B,C,V,X,u,-p,t),a.lineTo(e.cx+e.x01,e.cy+e.y01),p<b?a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,u,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),a.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):a.arc(0,0,u,T,R,t)}if(a.closePath(),n)return a=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +A.apply(this,arguments))/2-an/2;return[z(d)*n,w(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:G(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:G(+n),i):h},i.cornerRadius=function(n){return arguments.length?(j=typeof n=="function"?n:G(+n),i):j},i.padRadius=function(n){return arguments.length?(I=n==null?null:typeof n=="function"?n:G(+n),i):I},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:G(+n),i):v},i.endAngle=function(n){return arguments.length?(A=typeof n=="function"?n:G(+n),i):A},i.padAngle=function(n){return arguments.length?(H=typeof n=="function"?n:G(+n),i):H},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{hn as d};
|