@saluzi/saluzi-edu 0.2.2 → 0.2.4

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.
Files changed (117) hide show
  1. package/dist/cli.js +47 -47
  2. package/dist/rcs-web/assets/Dashboard-ClYYELch.js +2 -0
  3. package/dist/rcs-web/assets/{SessionDetail-CWUE75ns.js → SessionDetail-D5dCDgDF.js} +3 -3
  4. package/{packages/remote-control-server/web/dist/assets/arc-4X1dRN53.js → dist/rcs-web/assets/arc-7lPfYTKR.js} +1 -1
  5. package/{packages/remote-control-server/web/dist/assets/architectureDiagram-3BPJPVTR-D3w_Tg5M.js → dist/rcs-web/assets/architectureDiagram-3BPJPVTR-CLhFlBW3.js} +1 -1
  6. package/dist/rcs-web/assets/{blockDiagram-GPEHLZMM-8wHRy2A9.js → blockDiagram-GPEHLZMM-CRxDmTyw.js} +1 -1
  7. package/{packages/remote-control-server/web/dist/assets/c4Diagram-AAUBKEIU-9bNKHWdC.js → dist/rcs-web/assets/c4Diagram-AAUBKEIU-GhUzyEB2.js} +1 -1
  8. package/dist/rcs-web/assets/channel-DqKk-agI.js +1 -0
  9. package/dist/rcs-web/assets/{chunk-2J33WTMH-DgoVnl2j.js → chunk-2J33WTMH-CdFwFvWI.js} +1 -1
  10. package/dist/rcs-web/assets/{chunk-4BX2VUAB-DvIfpz6o.js → chunk-4BX2VUAB-Bxyari7X.js} +1 -1
  11. package/dist/rcs-web/assets/{chunk-55IACEB6-BJXtiicU.js → chunk-55IACEB6-B6itQfF-.js} +1 -1
  12. package/{packages/remote-control-server/web/dist/assets/chunk-727SXJPM-BLXUmKhM.js → dist/rcs-web/assets/chunk-727SXJPM-28bp6QhF.js} +1 -1
  13. package/dist/rcs-web/assets/{chunk-AQP2D5EJ-xIzfWsyC.js → chunk-AQP2D5EJ-Cin2Flu9.js} +1 -1
  14. package/dist/rcs-web/assets/{chunk-FMBD7UC4-OXv4Udby.js → chunk-FMBD7UC4-Bgh51Lft.js} +1 -1
  15. package/dist/rcs-web/assets/{chunk-ND2GUHAM-CInuJb7w.js → chunk-ND2GUHAM-BmlO4Ydq.js} +1 -1
  16. package/dist/rcs-web/assets/{chunk-QZHKN3VN-D9OXcbtl.js → chunk-QZHKN3VN-sJrTY76r.js} +1 -1
  17. package/dist/rcs-web/assets/classDiagram-4FO5ZUOK-DXYJPE0n.js +1 -0
  18. package/dist/rcs-web/assets/classDiagram-v2-Q7XG4LA2-DXYJPE0n.js +1 -0
  19. package/dist/rcs-web/assets/{code-block-IT6T5CEO-DIoba4-y.js → code-block-IT6T5CEO-C_zrs-gT.js} +1 -1
  20. package/{packages/remote-control-server/web/dist/assets/cose-bilkent-S5V4N54A-Bs-352tg.js → dist/rcs-web/assets/cose-bilkent-S5V4N54A-B6rTlH08.js} +1 -1
  21. package/dist/rcs-web/assets/{dagre-BM42HDAG-B9mWsnfD.js → dagre-BM42HDAG-_wl_w4u8.js} +1 -1
  22. package/dist/rcs-web/assets/{diagram-2AECGRRQ-BiVjJxYN.js → diagram-2AECGRRQ-CAM1F0zx.js} +1 -1
  23. package/dist/rcs-web/assets/{diagram-5GNKFQAL-yAsJs_ln.js → diagram-5GNKFQAL-RsfXB4M5.js} +1 -1
  24. package/dist/rcs-web/assets/{diagram-KO2AKTUF-Dud1LRRq.js → diagram-KO2AKTUF-DgE4Jvy8.js} +1 -1
  25. package/dist/rcs-web/assets/{diagram-LMA3HP47-iPzKx6av.js → diagram-LMA3HP47-btrs7dz6.js} +1 -1
  26. package/{packages/remote-control-server/web/dist/assets/diagram-OG6HWLK6-DJgCZbOs.js → dist/rcs-web/assets/diagram-OG6HWLK6-B81c8jdJ.js} +1 -1
  27. package/dist/rcs-web/assets/{erDiagram-TEJ5UH35-BGznRS63.js → erDiagram-TEJ5UH35-DL-CzHVd.js} +1 -1
  28. package/dist/rcs-web/assets/{flowDiagram-I6XJVG4X-UfxMnrX8.js → flowDiagram-I6XJVG4X-Cl-2EwXo.js} +1 -1
  29. package/dist/rcs-web/assets/{ganttDiagram-6RSMTGT7-BkaC26kQ.js → ganttDiagram-6RSMTGT7-BEUqhgIP.js} +1 -1
  30. package/dist/rcs-web/assets/{gitGraphDiagram-PVQCEYII-mONxtC7R.js → gitGraphDiagram-PVQCEYII-DeeVgqUk.js} +1 -1
  31. package/dist/rcs-web/assets/{infoDiagram-5YYISTIA-8aruATa_.js → infoDiagram-5YYISTIA-DPqTmZOu.js} +1 -1
  32. package/{packages/remote-control-server/web/dist/assets/ishikawaDiagram-YF4QCWOH-DkJ7Cpbg.js → dist/rcs-web/assets/ishikawaDiagram-YF4QCWOH-5YBKCgSx.js} +1 -1
  33. package/dist/rcs-web/assets/{journeyDiagram-JHISSGLW-BiIIuQpY.js → journeyDiagram-JHISSGLW-AnSqa6Hq.js} +1 -1
  34. package/dist/rcs-web/assets/{kanban-definition-UN3LZRKU-D6wU_tk_.js → kanban-definition-UN3LZRKU-W7cAy0RU.js} +1 -1
  35. package/dist/rcs-web/assets/{linear-DjOGLk2Z.js → linear-QvmQRsBx.js} +1 -1
  36. package/dist/rcs-web/assets/main-UBLYspes.js +283 -0
  37. package/dist/rcs-web/assets/{mermaid-VLURNSYL-kyqcLTJM.js → mermaid-VLURNSYL-Dn1LM1yF.js} +4 -4
  38. package/dist/rcs-web/assets/{mermaid.core-slLRH1UY.js → mermaid.core-C0ceVHNj.js} +5 -5
  39. package/dist/rcs-web/assets/{mindmap-definition-RKZ34NQL-B8y1-NqM.js → mindmap-definition-RKZ34NQL-Crj88n-9.js} +1 -1
  40. package/dist/rcs-web/assets/{pieDiagram-4H26LBE5-DwiQtzbN.js → pieDiagram-4H26LBE5-Boh89MZl.js} +1 -1
  41. package/{packages/remote-control-server/web/dist/assets/quadrantDiagram-W4KKPZXB-Den6wpfP.js → dist/rcs-web/assets/quadrantDiagram-W4KKPZXB-B1hrNv25.js} +1 -1
  42. package/dist/rcs-web/assets/{requirementDiagram-4Y6WPE33-DBw4144P.js → requirementDiagram-4Y6WPE33-B6BlGzlU.js} +1 -1
  43. package/{packages/remote-control-server/web/dist/assets/sankeyDiagram-5OEKKPKP-C-wqrDCa.js → dist/rcs-web/assets/sankeyDiagram-5OEKKPKP-BdNcjCvy.js} +1 -1
  44. package/dist/rcs-web/assets/{sequenceDiagram-3UESZ5HK-D83w2C-G.js → sequenceDiagram-3UESZ5HK-J9khnYhK.js} +1 -1
  45. package/dist/rcs-web/assets/{stateDiagram-AJRCARHV-DLtB2UCO.js → stateDiagram-AJRCARHV-iaQJb8kI.js} +1 -1
  46. package/dist/rcs-web/assets/{stateDiagram-v2-BHNVJYJU-BHas-vfa.js → stateDiagram-v2-BHNVJYJU-CZgBPZ4e.js} +1 -1
  47. package/{packages/remote-control-server/web/dist/assets/timeline-definition-PNZ67QCA-BbEI1m1M.js → dist/rcs-web/assets/timeline-definition-PNZ67QCA-zpFpWKc3.js} +1 -1
  48. package/dist/rcs-web/assets/{vennDiagram-CIIHVFJN-C4fDmd1A.js → vennDiagram-CIIHVFJN-Ld8wzoVI.js} +1 -1
  49. package/{packages/remote-control-server/web/dist/assets/wardleyDiagram-YWT4CUSO-DkMeB_0t.js → dist/rcs-web/assets/wardleyDiagram-YWT4CUSO-iCj-ntht.js} +1 -1
  50. package/dist/rcs-web/assets/{xychartDiagram-2RQKCTM6-BG-VBnW8.js → xychartDiagram-2RQKCTM6-DAAD572L.js} +1 -1
  51. package/dist/rcs-web/index.html +1 -1
  52. package/package.json +2 -2
  53. package/packages/remote-control-server/src/auth/middleware.ts +24 -3
  54. package/packages/remote-control-server/src/services/disconnect-monitor.ts +32 -1
  55. package/packages/remote-control-server/src/services/session.ts +17 -0
  56. package/packages/remote-control-server/web/dist/assets/Dashboard-ClYYELch.js +2 -0
  57. package/packages/remote-control-server/web/dist/assets/{SessionDetail-CWUE75ns.js → SessionDetail-D5dCDgDF.js} +3 -3
  58. package/{dist/rcs-web/assets/arc-4X1dRN53.js → packages/remote-control-server/web/dist/assets/arc-7lPfYTKR.js} +1 -1
  59. package/{dist/rcs-web/assets/architectureDiagram-3BPJPVTR-D3w_Tg5M.js → packages/remote-control-server/web/dist/assets/architectureDiagram-3BPJPVTR-CLhFlBW3.js} +1 -1
  60. package/packages/remote-control-server/web/dist/assets/{blockDiagram-GPEHLZMM-8wHRy2A9.js → blockDiagram-GPEHLZMM-CRxDmTyw.js} +1 -1
  61. package/{dist/rcs-web/assets/c4Diagram-AAUBKEIU-9bNKHWdC.js → packages/remote-control-server/web/dist/assets/c4Diagram-AAUBKEIU-GhUzyEB2.js} +1 -1
  62. package/packages/remote-control-server/web/dist/assets/channel-DqKk-agI.js +1 -0
  63. package/packages/remote-control-server/web/dist/assets/{chunk-2J33WTMH-DgoVnl2j.js → chunk-2J33WTMH-CdFwFvWI.js} +1 -1
  64. package/packages/remote-control-server/web/dist/assets/{chunk-4BX2VUAB-DvIfpz6o.js → chunk-4BX2VUAB-Bxyari7X.js} +1 -1
  65. package/packages/remote-control-server/web/dist/assets/{chunk-55IACEB6-BJXtiicU.js → chunk-55IACEB6-B6itQfF-.js} +1 -1
  66. package/{dist/rcs-web/assets/chunk-727SXJPM-BLXUmKhM.js → packages/remote-control-server/web/dist/assets/chunk-727SXJPM-28bp6QhF.js} +1 -1
  67. package/packages/remote-control-server/web/dist/assets/{chunk-AQP2D5EJ-xIzfWsyC.js → chunk-AQP2D5EJ-Cin2Flu9.js} +1 -1
  68. package/packages/remote-control-server/web/dist/assets/{chunk-FMBD7UC4-OXv4Udby.js → chunk-FMBD7UC4-Bgh51Lft.js} +1 -1
  69. package/packages/remote-control-server/web/dist/assets/{chunk-ND2GUHAM-CInuJb7w.js → chunk-ND2GUHAM-BmlO4Ydq.js} +1 -1
  70. package/packages/remote-control-server/web/dist/assets/{chunk-QZHKN3VN-D9OXcbtl.js → chunk-QZHKN3VN-sJrTY76r.js} +1 -1
  71. package/packages/remote-control-server/web/dist/assets/classDiagram-4FO5ZUOK-DXYJPE0n.js +1 -0
  72. package/packages/remote-control-server/web/dist/assets/classDiagram-v2-Q7XG4LA2-DXYJPE0n.js +1 -0
  73. package/packages/remote-control-server/web/dist/assets/{code-block-IT6T5CEO-DIoba4-y.js → code-block-IT6T5CEO-C_zrs-gT.js} +1 -1
  74. package/{dist/rcs-web/assets/cose-bilkent-S5V4N54A-Bs-352tg.js → packages/remote-control-server/web/dist/assets/cose-bilkent-S5V4N54A-B6rTlH08.js} +1 -1
  75. package/packages/remote-control-server/web/dist/assets/{dagre-BM42HDAG-B9mWsnfD.js → dagre-BM42HDAG-_wl_w4u8.js} +1 -1
  76. package/packages/remote-control-server/web/dist/assets/{diagram-2AECGRRQ-BiVjJxYN.js → diagram-2AECGRRQ-CAM1F0zx.js} +1 -1
  77. package/packages/remote-control-server/web/dist/assets/{diagram-5GNKFQAL-yAsJs_ln.js → diagram-5GNKFQAL-RsfXB4M5.js} +1 -1
  78. package/packages/remote-control-server/web/dist/assets/{diagram-KO2AKTUF-Dud1LRRq.js → diagram-KO2AKTUF-DgE4Jvy8.js} +1 -1
  79. package/packages/remote-control-server/web/dist/assets/{diagram-LMA3HP47-iPzKx6av.js → diagram-LMA3HP47-btrs7dz6.js} +1 -1
  80. package/{dist/rcs-web/assets/diagram-OG6HWLK6-DJgCZbOs.js → packages/remote-control-server/web/dist/assets/diagram-OG6HWLK6-B81c8jdJ.js} +1 -1
  81. package/packages/remote-control-server/web/dist/assets/{erDiagram-TEJ5UH35-BGznRS63.js → erDiagram-TEJ5UH35-DL-CzHVd.js} +1 -1
  82. package/packages/remote-control-server/web/dist/assets/{flowDiagram-I6XJVG4X-UfxMnrX8.js → flowDiagram-I6XJVG4X-Cl-2EwXo.js} +1 -1
  83. package/packages/remote-control-server/web/dist/assets/{ganttDiagram-6RSMTGT7-BkaC26kQ.js → ganttDiagram-6RSMTGT7-BEUqhgIP.js} +1 -1
  84. package/packages/remote-control-server/web/dist/assets/{gitGraphDiagram-PVQCEYII-mONxtC7R.js → gitGraphDiagram-PVQCEYII-DeeVgqUk.js} +1 -1
  85. package/packages/remote-control-server/web/dist/assets/{infoDiagram-5YYISTIA-8aruATa_.js → infoDiagram-5YYISTIA-DPqTmZOu.js} +1 -1
  86. package/{dist/rcs-web/assets/ishikawaDiagram-YF4QCWOH-DkJ7Cpbg.js → packages/remote-control-server/web/dist/assets/ishikawaDiagram-YF4QCWOH-5YBKCgSx.js} +1 -1
  87. package/packages/remote-control-server/web/dist/assets/{journeyDiagram-JHISSGLW-BiIIuQpY.js → journeyDiagram-JHISSGLW-AnSqa6Hq.js} +1 -1
  88. package/packages/remote-control-server/web/dist/assets/{kanban-definition-UN3LZRKU-D6wU_tk_.js → kanban-definition-UN3LZRKU-W7cAy0RU.js} +1 -1
  89. package/packages/remote-control-server/web/dist/assets/{linear-DjOGLk2Z.js → linear-QvmQRsBx.js} +1 -1
  90. package/packages/remote-control-server/web/dist/assets/main-UBLYspes.js +283 -0
  91. package/packages/remote-control-server/web/dist/assets/{mermaid-VLURNSYL-kyqcLTJM.js → mermaid-VLURNSYL-Dn1LM1yF.js} +4 -4
  92. package/packages/remote-control-server/web/dist/assets/{mermaid.core-slLRH1UY.js → mermaid.core-C0ceVHNj.js} +5 -5
  93. package/packages/remote-control-server/web/dist/assets/{mindmap-definition-RKZ34NQL-B8y1-NqM.js → mindmap-definition-RKZ34NQL-Crj88n-9.js} +1 -1
  94. package/packages/remote-control-server/web/dist/assets/{pieDiagram-4H26LBE5-DwiQtzbN.js → pieDiagram-4H26LBE5-Boh89MZl.js} +1 -1
  95. package/{dist/rcs-web/assets/quadrantDiagram-W4KKPZXB-Den6wpfP.js → packages/remote-control-server/web/dist/assets/quadrantDiagram-W4KKPZXB-B1hrNv25.js} +1 -1
  96. package/packages/remote-control-server/web/dist/assets/{requirementDiagram-4Y6WPE33-DBw4144P.js → requirementDiagram-4Y6WPE33-B6BlGzlU.js} +1 -1
  97. package/{dist/rcs-web/assets/sankeyDiagram-5OEKKPKP-C-wqrDCa.js → packages/remote-control-server/web/dist/assets/sankeyDiagram-5OEKKPKP-BdNcjCvy.js} +1 -1
  98. package/packages/remote-control-server/web/dist/assets/{sequenceDiagram-3UESZ5HK-D83w2C-G.js → sequenceDiagram-3UESZ5HK-J9khnYhK.js} +1 -1
  99. package/packages/remote-control-server/web/dist/assets/{stateDiagram-AJRCARHV-DLtB2UCO.js → stateDiagram-AJRCARHV-iaQJb8kI.js} +1 -1
  100. package/packages/remote-control-server/web/dist/assets/{stateDiagram-v2-BHNVJYJU-BHas-vfa.js → stateDiagram-v2-BHNVJYJU-CZgBPZ4e.js} +1 -1
  101. package/{dist/rcs-web/assets/timeline-definition-PNZ67QCA-BbEI1m1M.js → packages/remote-control-server/web/dist/assets/timeline-definition-PNZ67QCA-zpFpWKc3.js} +1 -1
  102. package/packages/remote-control-server/web/dist/assets/{vennDiagram-CIIHVFJN-C4fDmd1A.js → vennDiagram-CIIHVFJN-Ld8wzoVI.js} +1 -1
  103. package/{dist/rcs-web/assets/wardleyDiagram-YWT4CUSO-DkMeB_0t.js → packages/remote-control-server/web/dist/assets/wardleyDiagram-YWT4CUSO-iCj-ntht.js} +1 -1
  104. package/packages/remote-control-server/web/dist/assets/{xychartDiagram-2RQKCTM6-BG-VBnW8.js → xychartDiagram-2RQKCTM6-DAAD572L.js} +1 -1
  105. package/packages/remote-control-server/web/dist/index.html +1 -1
  106. package/dist/rcs-web/assets/Dashboard-BiApZyPx.js +0 -2
  107. package/dist/rcs-web/assets/channel-D0E2lnim.js +0 -1
  108. package/dist/rcs-web/assets/classDiagram-4FO5ZUOK-CHy833tj.js +0 -1
  109. package/dist/rcs-web/assets/classDiagram-v2-Q7XG4LA2-CHy833tj.js +0 -1
  110. package/dist/rcs-web/assets/main-5uxJJ_sE.js +0 -283
  111. package/dist/rcs-web/assets/workerType-Bd-zteMi.js +0 -1
  112. package/packages/remote-control-server/web/dist/assets/Dashboard-BiApZyPx.js +0 -2
  113. package/packages/remote-control-server/web/dist/assets/channel-D0E2lnim.js +0 -1
  114. package/packages/remote-control-server/web/dist/assets/classDiagram-4FO5ZUOK-CHy833tj.js +0 -1
  115. package/packages/remote-control-server/web/dist/assets/classDiagram-v2-Q7XG4LA2-CHy833tj.js +0 -1
  116. package/packages/remote-control-server/web/dist/assets/main-5uxJJ_sE.js +0 -283
  117. package/packages/remote-control-server/web/dist/assets/workerType-Bd-zteMi.js +0 -1
@@ -0,0 +1,2 @@
1
+ import{j as e,e as a}from"./vendor-DE_-CLIE.js";import{J as v,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,P as M,N as _,o as F,p as O,M as R,n as B}from"./main-UBLYspes.js";import"./shiki-mEP5vQQu.js";import"./qr-C0jP9HcD.js";import"./motion-BILbV7YQ.js";function I({environments:n,onSelectEnvironment:i}){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:()=>i==null?void 0:i(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:i,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 i??[])t!=null&&t.id&&t.worker_type&&c.set(t.id,t.worker_type);const p=[...n].sort((t,l)=>(l.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 l=t.source==="acp"?"acp":(f=t.environment)==null?void 0:f.worker_type;!l&&t.environment_id&&(l=c.get(t.environment_id));const b=v(l);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:l=>{l.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:i,onClose:o,onCreated:d}){const[c,p]=a.useState(""),[t,l]=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(""),l(""),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=i.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=>l(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 --"}),i.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 z({onNavigateSession:n}){const[i,o]=a.useState([]),[d,c]=a.useState([]),[p,t]=a.useState(!1),l=a.useCallback(async()=>{try{const[s,m]=await Promise.all([F(),O()]),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(()=>{l();const s=setInterval(l,1e4);return()=>clearInterval(s)},[l]);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=i.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")}},[i]);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:i,environments:d,onSelect:g,onDelete:j})]}),e.jsx($,{open:p,environments:d,onClose:()=>t(!1),onCreated:b})]})}export{z as Dashboard};
@@ -1,4 +1,4 @@
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";/**
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 P,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,Q as _e,A as Se,F as Ce,R as Me,y as Ee,I as Te,n as $e,O as Ae,T as Z,c as Ie,C as Re,q as Pe,N as qe,M as De,b as Ue,K as Oe,i as Fe,a as Be,J as We}from"./main-UBLYspes.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.
@@ -47,5 +47,5 @@ var de=Object.defineProperty;var ue=(s,t,n)=>t in s?de(s,t,{enumerable:!0,config
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 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};
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 P(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(R,{selected:r==="yes-default",onClick:()=>c("yes-default"),label:"Yes"}),e.jsx(R,{selected:r==="no",onClick:()=>c("no"),label:"No"})]}):e.jsxs(e.Fragment,{children:[e.jsx(R,{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(R,{selected:r==="yes-default",onClick:()=>c("yes-default"),label:"Yes, manually approve edits",desc:"Approve plan but confirm each edit"}),e.jsx(R,{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 R({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 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,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 Pe(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 P(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 P(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 P(s,{type:"permission_response",approved:!1,request_id:m,...j?{message:j}:{}}):await P(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(Re,{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{Pt 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-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};
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-C0ceVHNj.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};