@openork/cli 0.1.1 → 0.2.1

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 (178) hide show
  1. package/commands/doctor.d.ts +12 -0
  2. package/commands/doctor.d.ts.map +1 -0
  3. package/commands/doctor.js +110 -0
  4. package/commands/doctor.js.map +1 -0
  5. package/{dist/commands → commands}/gateway/start.d.ts.map +1 -1
  6. package/{dist/commands → commands}/gateway/start.js +14 -0
  7. package/commands/gateway/start.js.map +1 -0
  8. package/{dist/commands → commands}/setup.d.ts.map +1 -1
  9. package/{dist/commands → commands}/setup.js +19 -0
  10. package/commands/setup.js.map +1 -0
  11. package/externals.json +13 -0
  12. package/lib/doctor.d.ts +28 -0
  13. package/lib/doctor.d.ts.map +1 -0
  14. package/lib/doctor.js +227 -0
  15. package/lib/doctor.js.map +1 -0
  16. package/{dist/openapi.yml → openapi.yml} +770 -0
  17. package/package.json +14 -32
  18. package/prisma/migrations/20260401135027_add_auth_rbac_multitenancy/migration.sql +211 -0
  19. package/{dist/prisma → prisma}/schema.prisma +101 -0
  20. package/server.js +81901 -0
  21. package/server.js.map +1 -0
  22. package/{dist/web/assets/activity-feed-D_eonDKG.js → web/assets/activity-feed-CNgi7Qb_.js} +1 -1
  23. package/web/assets/agent-edit-CgbnHiT5.js +98 -0
  24. package/web/assets/agent-sessions-Bpay1_ZH.js +1 -0
  25. package/web/assets/agent-use-BaBxQ2fx.js +1 -0
  26. package/web/assets/agents-Dwbd6TQx.js +1 -0
  27. package/web/assets/api-DNWoqIPN.js +1 -0
  28. package/web/assets/arrow-down-upU5tcpi.js +1 -0
  29. package/web/assets/arrow-left-BiNeYcK0.js +1 -0
  30. package/web/assets/auth-client-ys1jC854.js +1 -0
  31. package/web/assets/chat-BP5H9CWl.js +4 -0
  32. package/{dist/web/assets/chat-input-BepRPV_L.js → web/assets/chat-input-CKAtAtgG.js} +2 -2
  33. package/{dist/web/assets/chat-message-CbcDeDcb.js → web/assets/chat-message-CW-HnO3f.js} +3 -3
  34. package/web/assets/chat-new-BQp9Bn7Q.js +1 -0
  35. package/web/assets/chat-sessions-D3bS5vba.js +1 -0
  36. package/web/assets/chats-DJolHH4e.js +1 -0
  37. package/{dist/web/assets/circle-alert-W8QX9LOG.js → web/assets/circle-alert-D040vPU_.js} +1 -1
  38. package/web/assets/circle-check-CW3adL8A.js +1 -0
  39. package/{dist/web/assets/circle-x-D_8Tcgt1.js → web/assets/circle-x-34c-1fVL.js} +1 -1
  40. package/web/assets/code-BFUT4gGT.js +1 -0
  41. package/{dist/web/assets/code-editor-x9L6nkh4.js → web/assets/code-editor-I6vK5q_W.js} +1 -1
  42. package/web/assets/commands-DBI4Bb2N.js +8 -0
  43. package/{dist/web/assets/copy-C87mjn_Y.js → web/assets/copy-DI5qjA1p.js} +1 -1
  44. package/web/assets/credentials-D8VN8A5M.js +1 -0
  45. package/{dist/web/assets/crown-BJEsQkh4.js → web/assets/crown-DWB5bSnq.js} +1 -1
  46. package/web/assets/dashboard-Cc6KWs62.js +1 -0
  47. package/{dist/web/assets/database-BohjTljV.js → web/assets/database-5jczNGML.js} +1 -1
  48. package/web/assets/debug-DewdHeoW.js +1 -0
  49. package/{dist/web/assets/download-B2UOiYAS.js → web/assets/download-CwO6xusv.js} +1 -1
  50. package/{dist/web/assets/eye-DN-Km5vf.js → web/assets/eye-BQGasWwb.js} +1 -1
  51. package/{dist/web/assets/file-plus-B8qWemgt.js → web/assets/file-plus-kHgvf9P8.js} +1 -1
  52. package/web/assets/file-tree-CTe61XCg.js +1 -0
  53. package/{dist/web/assets/folder-plus-DsmP6Mur.js → web/assets/folder-plus-mZAz-QpJ.js} +1 -1
  54. package/{dist/web/assets/globe-fwFSeXZn.js → web/assets/globe-C0WHVFW_.js} +1 -1
  55. package/{dist/web/assets/grip-vertical-Djo-yR-o.js → web/assets/grip-vertical-CdhrWSnV.js} +1 -1
  56. package/{dist/web/assets/history-CyBBboEp.js → web/assets/history-w7qYglj5.js} +1 -1
  57. package/web/assets/index-9X_UIor3.css +2 -0
  58. package/web/assets/index-DWNLSHpo.js +4 -0
  59. package/web/assets/key-DJEQ_jUi.js +1 -0
  60. package/{dist/web/assets/layers-ephyCrDm.js → web/assets/layers-KZu6CpGE.js} +1 -1
  61. package/{dist/web/assets/layout-grid-DCVGg8ZA.js → web/assets/layout-grid-U17jhSjz.js} +1 -1
  62. package/web/assets/login-DoSA7KtI.js +1 -0
  63. package/web/assets/mcp-setup-Cyj1YAiY.js +17 -0
  64. package/web/assets/memory-DWZU2Tfl.js +1 -0
  65. package/web/assets/new-chat-BRS3DM8Z.js +1 -0
  66. package/web/assets/play-BzkxV_O-.js +1 -0
  67. package/{dist/web/assets/refresh-cw-RFYUf5GB.js → web/assets/refresh-cw-D3_GZ86i.js} +1 -1
  68. package/web/assets/register-BS5OkCgS.js +1 -0
  69. package/web/assets/rotate-ccw-CkJIdGxi.js +1 -0
  70. package/{dist/web/assets/save-Dewm93H6.js → web/assets/save-BXEZF80P.js} +1 -1
  71. package/web/assets/search-BmZSwFnA.js +1 -0
  72. package/{dist/web/assets/send-FWvygYFQ.js → web/assets/send-CNiXC6KO.js} +1 -1
  73. package/web/assets/server-C5bKQLDi.js +1 -0
  74. package/web/assets/settings-CBAhSOZM.js +1 -0
  75. package/web/assets/shield-CMMTdOiM.js +1 -0
  76. package/{dist/web/assets/shield-check-Dt7sXtBF.js → web/assets/shield-check-BmphmMlD.js} +1 -1
  77. package/{dist/web/assets/shuffle-DjvBJ7XV.js → web/assets/shuffle-Dv_-PFl5.js} +1 -1
  78. package/web/assets/src-CaF63bXY.js +24 -0
  79. package/web/assets/sse-url-qohTy4Sw.js +1 -0
  80. package/web/assets/team-edit-BW1bePKn.js +1 -0
  81. package/web/assets/team-sessions-GspGc7zN.js +1 -0
  82. package/web/assets/team-use-BVC7nt9K.js +3 -0
  83. package/web/assets/terminal-CjSFIwMK.js +1 -0
  84. package/{dist/web/assets/timer-C9X20mTO.js → web/assets/timer-3siC9tpd.js} +1 -1
  85. package/{dist/web/assets/useMutation-BlOHt3MR.js → web/assets/useMutation-DA8-TvTt.js} +1 -1
  86. package/{dist/web/assets/utils-DHTPP40O.js → web/assets/utils-D1nRmcA6.js} +1 -1
  87. package/web/assets/workflow-edit-DkmsARCv.js +4 -0
  88. package/web/assets/workflow-runs-DcJPL7Bo.js +1 -0
  89. package/web/assets/workflows-Dnx0dwJn.js +1 -0
  90. package/{dist/web/assets/wrench-DZBtSPP8.js → web/assets/wrench-u8B_fDwT.js} +1 -1
  91. package/{dist/web/assets/zap-CbT5plGA.js → web/assets/zap-hOn7wkXe.js} +1 -1
  92. package/{dist/web → web}/index.html +9 -7
  93. package/README.md +0 -33
  94. package/dist/commands/gateway/start.js.map +0 -1
  95. package/dist/commands/setup.js.map +0 -1
  96. package/dist/server.js +0 -38234
  97. package/dist/server.js.map +0 -1
  98. package/dist/web/assets/agent-edit-CblZItU5.js +0 -98
  99. package/dist/web/assets/agent-sessions-COpCcffa.js +0 -1
  100. package/dist/web/assets/agent-use-F4pOt3KJ.js +0 -1
  101. package/dist/web/assets/agents-Av7w2wHE.js +0 -1
  102. package/dist/web/assets/arrow-down-XHN5PD1k.js +0 -1
  103. package/dist/web/assets/arrow-left-wtNmm6Le.js +0 -1
  104. package/dist/web/assets/chat-CQvfLy7Y.js +0 -4
  105. package/dist/web/assets/chat-new-BOtDuYij.js +0 -1
  106. package/dist/web/assets/chat-sessions-CaCaK_PC.js +0 -1
  107. package/dist/web/assets/chats-64IReeGV.js +0 -1
  108. package/dist/web/assets/circle-check-DLl9fl65.js +0 -1
  109. package/dist/web/assets/code-Brz4KHlI.js +0 -1
  110. package/dist/web/assets/commands-DT9K8bae.js +0 -8
  111. package/dist/web/assets/credentials-DC-HOVxW.js +0 -1
  112. package/dist/web/assets/dashboard-OfnNUjFX.js +0 -1
  113. package/dist/web/assets/debug-Et9rgBM8.js +0 -1
  114. package/dist/web/assets/file-tree-DkLQ1z0I.js +0 -1
  115. package/dist/web/assets/index-YgjFlLLv.css +0 -2
  116. package/dist/web/assets/index-dc8HGqTp.js +0 -2
  117. package/dist/web/assets/mcp-setup-BfMdYdsI.js +0 -17
  118. package/dist/web/assets/memory-DAQ474-p.js +0 -1
  119. package/dist/web/assets/new-chat-DtMw6FMg.js +0 -1
  120. package/dist/web/assets/play-DXJMtO-K.js +0 -1
  121. package/dist/web/assets/search-Ww0msJQz.js +0 -1
  122. package/dist/web/assets/settings-Auyn4Z5T.js +0 -1
  123. package/dist/web/assets/src-DUhGoAQb.js +0 -24
  124. package/dist/web/assets/team-edit-DO-RX3lC.js +0 -1
  125. package/dist/web/assets/team-sessions-DSw8MTtZ.js +0 -1
  126. package/dist/web/assets/team-use-BfNvsFcO.js +0 -3
  127. package/dist/web/assets/terminal-CIapYonS.js +0 -1
  128. package/dist/web/assets/workflow-edit-D0FNyl64.js +0 -4
  129. package/dist/web/assets/workflow-runs-CPVvaVzN.js +0 -1
  130. package/dist/web/assets/workflows-C9jurJiE.js +0 -1
  131. /package/{dist/commands → commands}/gateway/start.d.ts +0 -0
  132. /package/{dist/commands → commands}/gateway/stop.d.ts +0 -0
  133. /package/{dist/commands → commands}/gateway/stop.d.ts.map +0 -0
  134. /package/{dist/commands → commands}/gateway/stop.js +0 -0
  135. /package/{dist/commands → commands}/gateway/stop.js.map +0 -0
  136. /package/{dist/commands → commands}/setup.d.ts +0 -0
  137. /package/{dist/commands → commands}/setup.spec.d.ts +0 -0
  138. /package/{dist/commands → commands}/setup.spec.d.ts.map +0 -0
  139. /package/{dist/commands → commands}/setup.spec.js +0 -0
  140. /package/{dist/commands → commands}/setup.spec.js.map +0 -0
  141. /package/{dist/commands → commands}/uninstall.d.ts +0 -0
  142. /package/{dist/commands → commands}/uninstall.d.ts.map +0 -0
  143. /package/{dist/commands → commands}/uninstall.js +0 -0
  144. /package/{dist/commands → commands}/uninstall.js.map +0 -0
  145. /package/{dist/index.d.ts → index.d.ts} +0 -0
  146. /package/{dist/index.d.ts.map → index.d.ts.map} +0 -0
  147. /package/{dist/index.js → index.js} +0 -0
  148. /package/{dist/index.js.map → index.js.map} +0 -0
  149. /package/{dist/lib → lib}/gateway.d.ts +0 -0
  150. /package/{dist/lib → lib}/gateway.d.ts.map +0 -0
  151. /package/{dist/lib → lib}/gateway.js +0 -0
  152. /package/{dist/lib → lib}/gateway.js.map +0 -0
  153. /package/{dist/lib → lib}/shell-profile.d.ts +0 -0
  154. /package/{dist/lib → lib}/shell-profile.d.ts.map +0 -0
  155. /package/{dist/lib → lib}/shell-profile.js +0 -0
  156. /package/{dist/lib → lib}/shell-profile.js.map +0 -0
  157. /package/{dist/migrations → migrations}/0001-add-memory-enabled.js +0 -0
  158. /package/{dist/migrations → migrations}/lib/helpers.js +0 -0
  159. /package/{dist/migrations → migrations}/lib/template.js +0 -0
  160. /package/{dist/prisma → prisma}/migrations/20260318152538_add_trigger_type_and_source_workflow/migration.sql +0 -0
  161. /package/{dist/prisma → prisma}/migrations/20260318154232_drop_skill_and_emit_from_action/migration.sql +0 -0
  162. /package/{dist/prisma → prisma}/migrations/20260318160029_action_types_cli_bash_node_http/migration.sql +0 -0
  163. /package/{dist/prisma → prisma}/migrations/20260401085053_schema_sync/migration.sql +0 -0
  164. /package/{dist/prisma → prisma}/migrations/migration_lock.toml +0 -0
  165. /package/{dist/web/assets/api-docs-BQzn4-6U.js → web/assets/api-docs-DgRFxVfh.js} +0 -0
  166. /package/{dist/web/assets/bi-gM8sIAZV.js → web/assets/bi-Da3wz7XD.js} +0 -0
  167. /package/{dist/web/assets/cron-COUPKvGu.js → web/assets/cron-3VyztcE9.js} +0 -0
  168. /package/{dist/web → web}/assets/geist-cyrillic-wght-normal-CHSlOQsW.woff2 +0 -0
  169. /package/{dist/web → web}/assets/geist-latin-ext-wght-normal-DMtmJ5ZE.woff2 +0 -0
  170. /package/{dist/web → web}/assets/geist-latin-wght-normal-Dm3htQBi.woff2 +0 -0
  171. /package/{dist/web → web}/assets/rolldown-runtime-Dw2cE7zH.js +0 -0
  172. /package/{dist/web → web}/assets/useQuery-DvovkaPT.js +0 -0
  173. /package/{dist/web/assets/vendor-editor-BORFA-rZ.js → web/assets/vendor-editor-Cx3Ogh9u.js} +0 -0
  174. /package/{dist/web → web}/assets/vendor-react-BJ8SIkmN.js +0 -0
  175. /package/{dist/web → web}/assets/vendor-ui-CHpVij2M.css +0 -0
  176. /package/{dist/web/assets/vendor-ui-Dpw9mBc-.js → web/assets/vendor-ui-DnL9d3od.js} +0 -0
  177. /package/{dist/web → web}/docs.html +0 -0
  178. /package/{dist/web → web}/favicon.svg +0 -0
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{h as t,t as n}from"./vendor-react-BJ8SIkmN.js";import{U as r,V as i,b as a}from"./src-DUhGoAQb.js";import{y as o}from"./index-dc8HGqTp.js";var s=e(t(),1),c=n(),l=100,u=100;function d(e){switch(e){case`workflow-started`:return`Started`;case`workflow-completed`:return`Completed`;case`workflow-failed`:return`Failed`;case`agent-spawning`:return`Spawning`;case`agent-completed`:return`Agent Done`;case`agent-failed`:return`Agent Failed`;case`node-status`:return`Node`;default:return e}}function f(e){return e.includes(`failed`)?`destructive`:e.includes(`completed`)||e.includes(`done`)?`default`:`secondary`}var p=(0,s.memo)(function({event:e}){let t=(0,s.useMemo)(()=>new Date(e._timestamp).toLocaleTimeString(),[e._timestamp]);return(0,c.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md border p-3 animate-in fade-in slide-in-from-top-1 duration-300`,children:[(0,c.jsx)(r,{variant:f(e.type),children:d(e.type)}),(0,c.jsx)(`span`,{className:`text-sm font-medium`,children:e.workflowName??`Unknown workflow`}),e.order!==void 0&&(0,c.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Action #`,e.order+1]}),e.error&&(0,c.jsx)(`span`,{className:`text-xs text-destructive truncate max-w-[300px]`,children:e.error}),(0,c.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:t})]})});function m(){let{events:e,connectionStatus:t}=o(),[n,r]=(0,s.useState)(l),d=(0,s.useMemo)(()=>e.slice(0,n),[e,n]),f=e.length>n;return(0,c.jsxs)(`div`,{className:`p-6`,children:[(0,c.jsx)(`h1`,{className:`text-2xl font-bold mb-6`,children:`Activity Feed`}),e.length===0?(0,c.jsx)(`div`,{className:`text-muted-foreground text-center py-12`,children:t===`connected`?`Waiting for workflow events...`:`Connecting...`}):(0,c.jsx)(a,{className:`h-[calc(100vh-12rem)]`,children:(0,c.jsxs)(`div`,{className:`space-y-2`,children:[d.map(e=>(0,c.jsx)(p,{event:e},e._id)),f&&(0,c.jsx)(`div`,{className:`flex justify-center py-2`,children:(0,c.jsxs)(i,{variant:`outline`,size:`sm`,onClick:()=>r(e=>e+u),children:[`Show more (`,e.length-n,` remaining)`]})})]})})]})}export{m as ActivityFeed};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{h as t,t as n}from"./vendor-react-BJ8SIkmN.js";import{U as r,V as i,b as a}from"./src-CaF63bXY.js";import{b as o}from"./index-DWNLSHpo.js";var s=e(t(),1),c=n(),l=100,u=100;function d(e){switch(e){case`workflow-started`:return`Started`;case`workflow-completed`:return`Completed`;case`workflow-failed`:return`Failed`;case`agent-spawning`:return`Spawning`;case`agent-completed`:return`Agent Done`;case`agent-failed`:return`Agent Failed`;case`node-status`:return`Node`;default:return e}}function f(e){return e.includes(`failed`)?`destructive`:e.includes(`completed`)||e.includes(`done`)?`default`:`secondary`}var p=(0,s.memo)(function({event:e}){let t=(0,s.useMemo)(()=>new Date(e._timestamp).toLocaleTimeString(),[e._timestamp]);return(0,c.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md border p-3 animate-in fade-in slide-in-from-top-1 duration-300`,children:[(0,c.jsx)(r,{variant:f(e.type),children:d(e.type)}),(0,c.jsx)(`span`,{className:`text-sm font-medium`,children:e.workflowName??`Unknown workflow`}),e.order!==void 0&&(0,c.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Action #`,e.order+1]}),e.error&&(0,c.jsx)(`span`,{className:`text-xs text-destructive truncate max-w-[300px]`,children:e.error}),(0,c.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:t})]})});function m(){let{events:e,connectionStatus:t}=o(),[n,r]=(0,s.useState)(l),d=(0,s.useMemo)(()=>e.slice(0,n),[e,n]),f=e.length>n;return(0,c.jsxs)(`div`,{className:`p-6`,children:[(0,c.jsx)(`h1`,{className:`text-2xl font-bold mb-6`,children:`Activity Feed`}),e.length===0?(0,c.jsx)(`div`,{className:`text-muted-foreground text-center py-12`,children:t===`connected`?`Waiting for workflow events...`:`Connecting...`}):(0,c.jsx)(a,{className:`h-[calc(100vh-12rem)]`,children:(0,c.jsxs)(`div`,{className:`space-y-2`,children:[d.map(e=>(0,c.jsx)(p,{event:e},e._id)),f&&(0,c.jsx)(`div`,{className:`flex justify-center py-2`,children:(0,c.jsxs)(i,{variant:`outline`,size:`sm`,onClick:()=>r(e=>e+u),children:[`Show more (`,e.length-n,` remaining)`]})})]})})]})}export{m as ActivityFeed};
@@ -0,0 +1,98 @@
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{h as t,l as n,t as r,u as i}from"./vendor-react-BJ8SIkmN.js";import{r as a,t as o}from"./useQuery-DvovkaPT.js";import{t as s}from"./useMutation-DA8-TvTt.js";import{t as c}from"./api-DNWoqIPN.js";import{F as l,K as u,P as d,U as f,V as p,_ as m,f as ee,g as te,h as ne,j as re,m as h,v as g,w as _,y as ie}from"./src-CaF63bXY.js";import{t as ae}from"./arrow-left-BiNeYcK0.js";import{t as v}from"./circle-alert-D040vPU_.js";import{t as y}from"./database-5jczNGML.js";import{t as oe}from"./download-CwO6xusv.js";import{t as se}from"./eye-BQGasWwb.js";import{n as b,t as x}from"./shield-check-BmphmMlD.js";import{t as ce}from"./folder-plus-mZAz-QpJ.js";import{t as le}from"./globe-C0WHVFW_.js";import{t as ue}from"./save-BXEZF80P.js";import{t as de}from"./terminal-CjSFIwMK.js";import{t as S}from"./timer-3siC9tpd.js";import"./utils-D1nRmcA6.js";import{A as fe,F as pe,H as me,J as C,K as w,M as he,T as ge,o as _e,r as ve,t as T,z as E}from"./index-DWNLSHpo.js";import{t as ye}from"./code-editor-I6vK5q_W.js";var D=l(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),O=e(t(),1),k=r(),A=[{value:`claude-opus-4-6`,label:`Claude Opus 4.6`},{value:`claude-sonnet-4-6`,label:`Claude Sonnet 4.6`},{value:`claude-haiku-4-5-20251001`,label:`Claude Haiku 4.5`}],j=[{value:`composer-2-fast`,label:`Composer 2 Fast`},{value:`composer-2`,label:`Composer 2`},{value:`claude-4.6-opus-high-thinking`,label:`Opus 4.6 1M Thinking ★`},{value:`claude-4.6-opus-high`,label:`Opus 4.6 1M`},{value:`claude-4.6-opus-max-thinking`,label:`Opus 4.6 1M Max Thinking`},{value:`claude-4.6-sonnet-medium-thinking`,label:`Sonnet 4.6 1M Thinking`},{value:`claude-4.6-sonnet-medium`,label:`Sonnet 4.6 1M`},{value:`claude-4.5-sonnet-thinking`,label:`Sonnet 4.5 1M Thinking`},{value:`claude-4.5-sonnet`,label:`Sonnet 4.5 1M`},{value:`claude-4.5-opus-high-thinking`,label:`Opus 4.5 Thinking`},{value:`claude-4-sonnet-thinking`,label:`Sonnet 4 Thinking`},{value:`claude-4-sonnet`,label:`Sonnet 4`},{value:`gpt-5.4-medium`,label:`GPT-5.4 1M`},{value:`gpt-5.4-high`,label:`GPT-5.4 1M High`},{value:`gpt-5.4-mini-medium`,label:`GPT-5.4 Mini`},{value:`gpt-5.3-codex`,label:`GPT-5.3 Codex`},{value:`gpt-5.3-codex-high`,label:`GPT-5.3 Codex High`},{value:`gpt-5.2`,label:`GPT-5.2`},{value:`gpt-5.1`,label:`GPT-5.1`},{value:`gpt-5-mini`,label:`GPT-5 Mini`}],M={"claude-code":A,cursor:j},N=[{key:`soul`,icon:w,label:`SOUL`,description:`Personality, tone, communication style`},{key:`identity`,icon:b,label:`IDENTITY`,description:`Who the agent is, role, responsibilities`},{key:`rules`,icon:x,label:`AGENTS`,description:`Operating rules, safety constraints, business context`},{key:`user`,icon:D,label:`USER`,description:`Stable user/company context and preferences`},{key:`heartbeat`,icon:S,label:`HEARTBEAT`,description:`Scheduled automation tasks (natural language)`},{key:`memory`,icon:y,label:`MEMORY`,description:`Auto-managed dynamic context (agent-written)`},{key:`knowledge`,icon:C,label:`KNOWLEDGE`,description:`Domain knowledge, reference docs`}],be={soul:`# Personality & Tone
2
+
3
+ Direct, skip preamble. No exclamation marks unless truly warranted.
4
+ Default lowercase unless proper noun. Calm, methodical, slightly dry.
5
+ Efficiency-first — get to the point.
6
+
7
+ # Communication Style
8
+
9
+ - Bullet points for 3+ items
10
+ - TLDR for responses > 200 words
11
+ - Code blocks with language tags
12
+ - Tables for comparisons
13
+ `,identity:`# Agent Identity
14
+
15
+ Name: [Agent Name]
16
+ Title: [Role Title]
17
+
18
+ # Responsibilities
19
+
20
+ - ...
21
+ - ...
22
+
23
+ # NOT Responsible For
24
+
25
+ - ...
26
+ `,rules:`# Safety Rules
27
+
28
+ - Never send emails or messages without explicit approval
29
+ - Always confirm before deleting anything
30
+ - Never process payments or financial transactions autonomously
31
+
32
+ # Communication Rules
33
+
34
+ - Use bullet points for lists of 3+ items
35
+ - Include TLDR for responses over 200 words
36
+ - Default timezone: UTC
37
+
38
+ # Business Context
39
+
40
+ Company: [Company Name]
41
+ Role: [User Role]
42
+ Product: [Product Name]
43
+ `,user:`# Personal Info
44
+
45
+ Name: [Your Name]
46
+ Role: [Your Title]
47
+ Location: [City, Country]
48
+ Timezone: [e.g. Europe/Paris]
49
+
50
+ # Company Details
51
+
52
+ Company: [Company Name]
53
+ Sector: [Industry]
54
+ Key Metrics: [MRR, users, etc.]
55
+
56
+ # Preferences
57
+
58
+ - Preferred meeting times: [e.g. mornings]
59
+ - Report format: [e.g. bullet points, tables]
60
+ - Alert channel: [e.g. Slack, Telegram]
61
+ `,heartbeat:`# Daily Tasks
62
+
63
+ ### 8:00 AM — Morning Briefing
64
+ - Check calendar for today's meetings
65
+ - Review overnight metrics
66
+ - Compile summary and send to Slack #daily-standup
67
+
68
+ ### 6:00 PM — End of Day Recap
69
+ - Summarize tasks completed today
70
+ - Flag any blockers for tomorrow
71
+ - Send recap to Telegram
72
+
73
+ # Continuous Monitoring
74
+
75
+ ### Every 60 Minutes
76
+ - Check error rates in monitoring dashboard
77
+ - Alert if error rate > 5%
78
+
79
+ # Weekly Reviews
80
+
81
+ ### Every Monday 9:00 AM
82
+ - Pull weekly metrics report
83
+ - Compare with previous week
84
+ - Highlight trends and anomalies
85
+ `,knowledge:`# Domain Knowledge
86
+
87
+ ## Key Concepts
88
+
89
+ - ...
90
+
91
+ ## Important Rules
92
+
93
+ - ...
94
+
95
+ ## Reference Information
96
+
97
+ - ...
98
+ `};async function xe(e,t,n,r){try{let i=await c.fs.pickFolder();if(!i.path)return;if(t.some(e=>e.path===i.path)){T.info(r(`agentEdit.folderAlreadyAdded`));return}n(e===`cursor`?[{path:i.path,permission:`write`}]:e=>[...e,{path:i.path,permission:`read`}])}catch{T.error(r(`agentEdit.couldNotOpenFolder`))}}async function Se(e,t){if(e)try{let n=await c.agents.exportSoul(e);await navigator.clipboard.writeText(n),T.success(t(`agentEdit.exportedToClipboard`))}catch{T.error(t(`agentEdit.failedToExport`))}}function Ce(e,t){let{setInitialized:n,setName:r,setDescription:i,setAvatar:a,setSlug:o,setRuntime:s,setCli:c,setModel:l,setAdditionalFolders:u,setTemperature:d,setTagsStr:f,setMemoryEnabled:p,setSoul:m,setIdentity:ee,setRules:te,setUser:ne,setHeartbeat:re,setMemory:h,setKnowledge:g}=t;n(!0),r(e.name),i(e.description),a(e.avatar),o(e.slug??``),s(e.runtime??`cli`),c(e.cli??`claude-code`),l(e.model),u(e.additionalFolders??[]),d(e.temperature),f(e.tags.join(`, `)),p(e.memoryEnabled??!0),m(e.soul),ee(e.identity??``),te(e.rules??``),ne(e.user??``),re(e.heartbeat??``),h(e.memory??``),g(e.knowledge??``)}function we(e,t,n,r){if(clearTimeout(n.current),!e.trim()){r(`idle`);return}r(`checking`),n.current=setTimeout(()=>{P(e,t,r)},400)}async function P(e,t,n){try{n((await c.agents.checkSlug(e,t)).available?`available`:`taken`)}catch{n(`idle`)}}var Te=e=>e.normalize(`NFD`).replace(/[\u0300-\u036f]/g,``).toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``);function Ee({slug:e,slugStatus:t,isNew:n,onChange:r}){return(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground mb-1 block`,children:`Slug`}),(0,k.jsxs)(`div`,{className:`relative`,children:[(0,k.jsx)(_,{value:e,onChange:e=>r(e.target.value),placeholder:n?`auto-generated from name`:`agent-slug`,className:u(`pr-8 font-mono text-xs`,t===`taken`&&`border-destructive focus-visible:ring-destructive`)}),(0,k.jsxs)(`div`,{className:`absolute right-2 top-1/2 -translate-y-1/2`,children:[t===`checking`&&(0,k.jsx)(E,{className:`h-3.5 w-3.5 animate-spin text-muted-foreground`}),t===`available`&&(0,k.jsx)(d,{className:`h-3.5 w-3.5 text-emerald-500`}),t===`taken`&&(0,k.jsx)(v,{className:`h-3.5 w-3.5 text-destructive`})]})]}),t===`taken`&&(0,k.jsx)(`p`,{className:`text-[10px] text-destructive mt-0.5`,children:`This slug is already taken`}),(0,k.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-0.5`,children:(0,k.jsxs)(`code`,{className:`bg-muted px-1 py-0.5 rounded font-mono`,children:[`.local/agents/`,e||`...`,`/`]})})]})}function F(){let{id:e}=i(),t=n(),r=a(),{t:l}=ge(),d=!e||e===`new`,[v,y]=(0,O.useState)(``),[b,x]=(0,O.useState)(``),[S,C]=(0,O.useState)(`🤖`),[w,E]=(0,O.useState)(.7),[D,j]=(0,O.useState)(``),[P,F]=(0,O.useState)(!0),[De,Oe]=(0,O.useState)(``),[ke,Ae]=(0,O.useState)(`idle`),je=(0,O.useRef)(void 0),Me=(0,O.useCallback)(t=>{let n=Te(t);Oe(n),we(n,d?void 0:e,je,Ae)},[d,e]),[I,L]=(0,O.useState)(`cli`),[R,z]=(0,O.useState)(`claude-code`),[B,V]=(0,O.useState)(`claude-sonnet-4-6`),[H,U]=(0,O.useState)([]),[W,G]=(0,O.useState)(``),[K,q]=(0,O.useState)(``),[Ne,Pe]=(0,O.useState)(``),[Fe,Ie]=(0,O.useState)(``),[Le,Re]=(0,O.useState)(``),[J,ze]=(0,O.useState)(``),[Be,Ve]=(0,O.useState)(``),[Y,He]=(0,O.useState)(`soul`),[Ue,We]=(0,O.useState)(d),Ge={soul:{value:W,set:G},identity:{value:K,set:q},rules:{value:Ne,set:Pe},user:{value:Fe,set:Ie},heartbeat:{value:Le,set:Re},memory:{value:J,set:ze},knowledge:{value:Be,set:Ve}},{data:Ke}=o({queryKey:[`cli-agents`],queryFn:()=>c.settings.getCliAgents(),staleTime:6e4}),X=(Ke?.agents??[]).filter(e=>e.installed),{data:qe,isLoading:Je}=o({queryKey:[`agents`,e],queryFn:()=>c.agents.get(e),enabled:!d});qe&&!Ue&&Ce(qe,{setInitialized:We,setName:y,setDescription:x,setAvatar:C,setSlug:Oe,setRuntime:L,setCli:z,setModel:V,setAdditionalFolders:U,setTemperature:E,setTagsStr:j,setMemoryEnabled:F,setSoul:G,setIdentity:q,setRules:Pe,setUser:Ie,setHeartbeat:Re,setMemory:ze,setKnowledge:Ve});let Ye=s({mutationFn:e=>c.agents.create(e),onSuccess:e=>{r.invalidateQueries({queryKey:[`agents`]}),T.success(l(`agentEdit.agentCreated`)),t(`/agents/${e.id}`)},onError:e=>T.error(e.message)}),Xe=s({mutationFn:t=>c.agents.update(e,t),onSuccess:()=>{r.invalidateQueries({queryKey:[`agents`]}),T.success(l(`agentEdit.agentSaved`))},onError:e=>T.error(e.message)}),Ze=s({mutationFn:()=>c.agents.delete(e),onSuccess:()=>{r.invalidateQueries({queryKey:[`agents`]}),T.success(l(`agentEdit.agentDeleted`)),t(`/agents`)}}),Qe=()=>{let e=D.split(`,`).map(e=>e.trim()).filter(Boolean),t={name:v,slug:De||void 0,description:b,avatar:S,runtime:I,cli:I===`cli`?R:null,model:B,additionalFolders:H.length>0?H:[],temperature:w,tags:e,memoryEnabled:P,soul:W,identity:K,rules:Ne,user:Fe,heartbeat:Le,memory:J,knowledge:Be};(d?Ye:Xe).mutate(t)},$e=()=>Se(e,l),et=()=>xe(R,H,U,l),tt=e=>{U(t=>t.filter(t=>t.path!==e))},nt=e=>{U(t=>t.map(t=>{if(t.path!==e)return t;let n=t.permission===`read`?`write`:`read`;return{...t,permission:n}}))},rt=Ye.isPending||Xe.isPending,Z=Ge[Y],Q=N.find(e=>e.key===Y),it=D.split(`,`).map(e=>e.trim()).filter(Boolean);if(!d&&Je)return(0,k.jsx)(_e,{});let at=d?`New Agent`:v||`Untitled Agent`,ot=d?`Configure your agent's soul and behavior files`:`Edit agent configuration`,$=R===`cursor`,st=$?`Workspace`:`Project Folders`,ct=$?`The project directory Cursor will work in (--workspace)`:`Additional folders the agent can access (e.g. project repos with local MCP servers)`;return(0,k.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,k.jsxs)(`div`,{className:`shrink-0 border-b bg-background px-6 py-3 flex items-center justify-between gap-4`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,k.jsx)(p,{variant:`ghost`,size:`icon`,onClick:()=>t(`/agents`),children:(0,k.jsx)(ae,{className:`h-4 w-4`})}),(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(`span`,{className:`text-2xl`,children:S}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h1`,{className:`text-lg font-semibold leading-tight`,children:at}),(0,k.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:ot})]})]})]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!d&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(p,{variant:`ghost`,size:`sm`,onClick:$e,children:[(0,k.jsx)(oe,{className:`h-4 w-4 mr-1`}),` Export`]}),(0,k.jsxs)(p,{variant:`ghost`,size:`sm`,onClick:()=>Ze.mutate(),className:`text-destructive hover:text-destructive`,children:[(0,k.jsx)(fe,{className:`h-4 w-4 mr-1`}),` Delete`]})]}),(0,k.jsxs)(p,{onClick:Qe,disabled:!v.trim()||rt||ke===`taken`,children:[(0,k.jsx)(ue,{className:`h-4 w-4 mr-1`}),rt?`Saving...`:`Save`]})]})]}),(0,k.jsxs)(`div`,{className:`flex-1 flex overflow-hidden`,children:[(0,k.jsxs)(`div`,{className:`w-[280px] shrink-0 border-r overflow-auto p-4 space-y-4`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground mb-1 block`,children:`Avatar`}),(0,k.jsx)(_,{value:S,onChange:e=>C(e.target.value),className:`w-20 text-center text-3xl h-12`,maxLength:2})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground mb-1 block`,children:`Name`}),(0,k.jsx)(_,{value:v,onChange:e=>y(e.target.value),placeholder:l(`agentEdit.namePlaceholder`)})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground mb-1 block`,children:`Description`}),(0,k.jsx)(_,{value:b,onChange:e=>x(e.target.value),placeholder:l(`agentEdit.descriptionPlaceholder`)})]}),(0,k.jsx)(h,{}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground mb-2 block`,children:`Runtime`}),(0,k.jsxs)(`div`,{className:`grid grid-cols-2 gap-1.5`,children:[(0,k.jsxs)(`button`,{onClick:()=>L(`cli`),className:u(`flex items-center gap-1.5 rounded-md border px-3 py-2 text-sm transition-colors`,I===`cli`?`border-primary bg-primary/5 font-medium`:`border-border hover:border-muted-foreground/30`),children:[(0,k.jsx)(de,{className:`h-3.5 w-3.5`}),` CLI Agent`]}),(0,k.jsxs)(`button`,{onClick:()=>L(`api`),className:u(`flex items-center gap-1.5 rounded-md border px-3 py-2 text-sm transition-colors`,I===`api`?`border-primary bg-primary/5 font-medium`:`border-border hover:border-muted-foreground/30`),children:[(0,k.jsx)(le,{className:`h-3.5 w-3.5`}),` API Agent`]})]})]}),I===`cli`&&(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground mb-1 block`,children:`CLI`}),X.length>0?(0,k.jsx)(`div`,{className:`space-y-1.5`,children:X.map(e=>{let t=ve(e.icon??e.id);return(0,k.jsxs)(`button`,{onClick:()=>{z(e.id);let t=M[e.id]??A;t.some(e=>e.value===B)||V(t[0].value)},className:u(`w-full flex items-center gap-2 rounded-md border px-3 py-2 text-sm transition-colors text-left`,R===e.id?`border-primary bg-primary/5 font-medium`:`border-border hover:border-muted-foreground/30`),children:[(0,k.jsx)(t,{className:`h-4 w-4 shrink-0`}),(0,k.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,k.jsx)(`div`,{className:`truncate`,children:e.label}),e.version&&(0,k.jsxs)(`div`,{className:`text-[10px] text-muted-foreground`,children:[`v`,e.version]})]})]},e.id)})}):(0,k.jsx)(`p`,{className:`text-xs text-muted-foreground italic`,children:l(`agentEdit.noCliAgents`)})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground mb-1 block`,children:`Model`}),(0,k.jsxs)(ne,{value:B,onValueChange:e=>{e&&V(e)},children:[(0,k.jsx)(g,{children:(0,k.jsx)(ie,{})}),(0,k.jsx)(te,{children:(M[R]??A).map(e=>(0,k.jsx)(m,{value:e.value,children:e.label},e.value))})]})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground mb-1 block`,children:l(`agentEdit.temperature`,{value:w})}),(0,k.jsx)(`input`,{type:`range`,min:0,max:1,step:.1,value:w,onChange:e=>E(Number(e.target.value)),className:`w-full accent-primary`}),(0,k.jsxs)(`div`,{className:`flex justify-between text-[10px] text-muted-foreground mt-0.5`,children:[(0,k.jsx)(`span`,{children:l(`agentEdit.precise`)}),(0,k.jsx)(`span`,{children:l(`agentEdit.creative`)})]})]}),(0,k.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:l(`agentEdit.memoryEnabled`)}),(0,k.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:l(`agentEdit.memoryEnabledHelp`)})]}),(0,k.jsx)(ee,{checked:P,onCheckedChange:F})]}),(0,k.jsx)(h,{}),(0,k.jsx)(Ee,{slug:De,slugStatus:ke,isNew:d,onChange:Me}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground mb-1 block`,children:st}),(0,k.jsx)(`p`,{className:`text-[10px] text-muted-foreground mb-1.5`,children:ct}),H.length>0&&(0,k.jsx)(`div`,{className:`space-y-1.5 mb-2`,children:H.map(e=>(0,k.jsxs)(`div`,{className:`flex items-center gap-1.5 bg-muted/50 rounded-md px-2 py-1.5`,children:[(0,k.jsx)(me,{className:`h-3 w-3 text-muted-foreground shrink-0`}),(0,k.jsx)(`span`,{className:`text-[11px] font-mono text-foreground truncate flex-1`,title:e.path,children:e.path}),(0,k.jsx)(p,{variant:`ghost`,size:`icon`,className:`h-5 w-5 shrink-0`,onClick:()=>nt(e.path),title:e.permission===`read`?`Read only — click to allow write`:`Read & Write — click to restrict to read`,children:e.permission===`read`?(0,k.jsx)(se,{className:`h-3 w-3 text-blue-400`}):(0,k.jsx)(pe,{className:`h-3 w-3 text-amber-400`})}),(0,k.jsx)(f,{variant:`outline`,className:u(`text-[8px] px-1 py-0 shrink-0 cursor-pointer select-none`,e.permission===`write`?`text-amber-400 border-amber-400/30`:`text-blue-400 border-blue-400/30`),onClick:()=>nt(e.path),children:e.permission===`read`?`R`:`RW`}),(0,k.jsx)(p,{variant:`ghost`,size:`icon`,className:`h-5 w-5 shrink-0 text-muted-foreground hover:text-destructive`,onClick:()=>tt(e.path),children:(0,k.jsx)(re,{className:`h-3 w-3`})})]},e.path))}),(!$||H.length===0)&&(0,k.jsxs)(p,{variant:`outline`,size:`sm`,className:`text-xs gap-1.5`,onClick:et,children:[(0,k.jsx)(ce,{className:`h-3.5 w-3.5`}),l($?`agentEdit.setWorkspace`:`agentEdit.addFolder`)]})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground mb-1 block`,children:l(`agentEdit.tags`)}),(0,k.jsx)(_,{value:D,onChange:e=>j(e.target.value),placeholder:l(`agentEdit.tagsPlaceholder`)}),it.length>0&&(0,k.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-1.5`,children:it.map(e=>(0,k.jsx)(f,{variant:`secondary`,className:`text-xs`,children:e},e))})]})]}),(0,k.jsxs)(`div`,{className:`w-[180px] shrink-0 border-r overflow-auto py-2`,children:[(0,k.jsx)(`div`,{className:`px-3 pb-2`,children:(0,k.jsx)(`p`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:`Config Files`})}),N.map(({key:e,icon:t,label:n})=>{let r=Ge[e].value.length>0;return(0,k.jsxs)(`button`,{onClick:()=>He(e),className:u(`w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors text-left`,Y===e?`bg-accent text-accent-foreground font-medium`:`text-muted-foreground hover:bg-muted hover:text-foreground`),children:[(0,k.jsx)(t,{className:`h-3.5 w-3.5 shrink-0`}),(0,k.jsx)(`span`,{className:`flex-1`,children:n}),r&&(0,k.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary shrink-0`})]},e)})]}),(0,k.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden min-w-0`,children:[(0,k.jsxs)(`div`,{className:`shrink-0 px-6 py-3 border-b flex items-center justify-between`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(Q.icon,{className:`h-4 w-4 text-muted-foreground`}),(0,k.jsxs)(`h2`,{className:`text-sm font-semibold`,children:[Q.label,`.md`]})]}),(0,k.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:Q.description})]}),!Z.value&&be[Y]&&(0,k.jsxs)(p,{variant:`outline`,size:`sm`,onClick:()=>Z.set(be[Y]),children:[(0,k.jsx)(he,{className:`h-3 w-3 mr-1`}),` Use template`]})]}),(0,k.jsx)(`div`,{className:`flex-1 overflow-auto p-4`,children:(0,k.jsx)(ye,{value:Z.value,onChange:Z.set,language:`markdown`,placeholder:`Write ${Q.label}.md content...`,minHeight:`calc(100vh - 200px)`,onSave:Qe,readOnly:Y===`memory`&&!d&&!!J},Y)})]})]})]})}export{F as AgentEdit};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{h as t,l as n,r,t as i,u as a}from"./vendor-react-BJ8SIkmN.js";import{t as o}from"./api-DNWoqIPN.js";import{U as s,V as c}from"./src-CaF63bXY.js";import{t as l}from"./arrow-left-BiNeYcK0.js";import{n as u,t as d}from"./zap-hOn7wkXe.js";import{t as f}from"./layers-KZu6CpGE.js";import{t as p}from"./play-BzkxV_O-.js";import{t as m}from"./terminal-CjSFIwMK.js";import{G as h,U as g,W as _,j as v,q as y,t as b}from"./index-DWNLSHpo.js";var x=e(t(),1),S=i();function C(e){switch(e){case`completed`:return`default`;case`failed`:return`destructive`;case`cancelled`:return`outline`;default:return`secondary`}}function w(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function T(e){return new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function E(e,t){if(!t)return`—`;let n=new Date(t).getTime()-new Date(e).getTime();if(n<1e3)return`${n}ms`;let r=Math.round(n/1e3);return r<60?`${r}s`:`${Math.floor(r/60)}m ${r%60}s`}function D({stats:e}){return(0,S.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[(0,S.jsxs)(`div`,{className:`rounded-lg border bg-card p-4`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,S.jsx)(f,{className:`h-3.5 w-3.5`}),`Sessions`]}),(0,S.jsx)(`p`,{className:`mt-1 text-2xl font-semibold`,children:e.totalSessions})]}),(0,S.jsxs)(`div`,{className:`rounded-lg border bg-card p-4`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,S.jsx)(d,{className:`h-3.5 w-3.5`}),`Total Tokens`]}),(0,S.jsx)(`p`,{className:`mt-1 text-2xl font-semibold`,children:w(e.totalTokens)})]}),(0,S.jsxs)(`div`,{className:`rounded-lg border bg-card p-4`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,S.jsx)(u,{className:`h-3.5 w-3.5`}),`Input`]}),(0,S.jsx)(`p`,{className:`mt-1 text-2xl font-semibold`,children:w(e.totalInputTokens)})]}),(0,S.jsxs)(`div`,{className:`rounded-lg border bg-card p-4`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,S.jsx)(u,{className:`h-3.5 w-3.5`}),`Output`]}),(0,S.jsx)(`p`,{className:`mt-1 text-2xl font-semibold`,children:w(e.totalOutputTokens)})]})]})}function O({session:e}){let t=n(),r=e.inputTokens+e.outputTokens;return(0,S.jsxs)(`div`,{className:`space-y-6`,children:[(0,S.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h2`,{className:`text-lg font-semibold`,children:e.agentName}),(0,S.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2`,children:e.prompt})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsxs)(c,{size:`sm`,variant:`outline`,onClick:()=>t(`/agents/${e.agentId}/use/${e.id}`),children:[(0,S.jsx)(g,{className:`mr-1.5 h-3.5 w-3.5`}),`Continue in agent`]}),(0,S.jsx)(s,{variant:C(e.status),children:e.status})]})]}),(0,S.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[(0,S.jsxs)(`div`,{className:`text-sm`,children:[(0,S.jsx)(`span`,{className:`text-muted-foreground`,children:`Model`}),(0,S.jsx)(`p`,{className:`font-medium`,children:e.model??`—`})]}),(0,S.jsxs)(`div`,{className:`text-sm`,children:[(0,S.jsx)(`span`,{className:`text-muted-foreground`,children:`CLI`}),(0,S.jsx)(`p`,{className:`font-medium`,children:e.cli??`—`})]}),(0,S.jsxs)(`div`,{className:`text-sm`,children:[(0,S.jsx)(`span`,{className:`text-muted-foreground`,children:`Duration`}),(0,S.jsx)(`p`,{className:`font-medium`,children:E(e.startedAt,e.completedAt)})]}),(0,S.jsxs)(`div`,{className:`text-sm`,children:[(0,S.jsx)(`span`,{className:`text-muted-foreground`,children:`Tokens`}),(0,S.jsx)(`p`,{className:`font-medium`,children:w(r)})]})]}),(0,S.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[(0,S.jsxs)(`div`,{className:`text-sm`,children:[(0,S.jsx)(`span`,{className:`text-muted-foreground`,children:`Input Tokens`}),(0,S.jsx)(`p`,{className:`font-medium`,children:w(e.inputTokens)})]}),(0,S.jsxs)(`div`,{className:`text-sm`,children:[(0,S.jsx)(`span`,{className:`text-muted-foreground`,children:`Output Tokens`}),(0,S.jsx)(`p`,{className:`font-medium`,children:w(e.outputTokens)})]}),(0,S.jsxs)(`div`,{className:`text-sm`,children:[(0,S.jsx)(`span`,{className:`text-muted-foreground`,children:`Cache Read`}),(0,S.jsx)(`p`,{className:`font-medium`,children:w(e.cacheReadTokens)})]}),(0,S.jsxs)(`div`,{className:`text-sm`,children:[(0,S.jsx)(`span`,{className:`text-muted-foreground`,children:`Cache Write`}),(0,S.jsx)(`p`,{className:`font-medium`,children:w(e.cacheWriteTokens)})]})]}),e.error&&(0,S.jsx)(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/5 p-3 text-sm text-destructive`,children:e.error}),e.output&&(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h3`,{className:`mb-2 text-sm font-medium text-muted-foreground`,children:`Output`}),(0,S.jsx)(`pre`,{className:`max-h-96 overflow-auto rounded-lg border bg-muted/50 p-4 text-xs whitespace-pre-wrap`,children:e.output})]})]})}function k(){let e=n(),{id:t}=a(),[i,u]=(0,x.useState)([]),[f,k]=(0,x.useState)([]),[A,j]=(0,x.useState)(0),[M,N]=(0,x.useState)(null),[P,F]=(0,x.useState)(null),[I,L]=(0,x.useState)(!0),[R,z]=(0,x.useState)(1);(0,x.useEffect)(()=>{let e=!1;return Promise.resolve().then(()=>{e||L(!0)}),Promise.all([o.agentSessions.list({limit:20,offset:(R-1)*20}),o.agentSessions.stats(14),o.agentSessions.listActive()]).then(([t,n,r])=>{e||(u(t.data),j(t.total),N(n),k(r.data.filter(e=>e.status===`running`)))}).finally(()=>{e||L(!1)}),()=>{e=!0}},[R]),(0,x.useEffect)(()=>{t?o.agentSessions.get(t).then(F).catch(()=>F(null)):Promise.resolve().then(()=>F(null))},[t]);let B=async e=>{await o.chat.stopStream(e),k(t=>t.filter(t=>t.streamId!==e)),b.success(`Session stopped`)},V=Math.ceil(A/20);return P?(0,S.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4 p-6`,children:[(0,S.jsxs)(r,{to:`/agent-sessions`,className:`inline-flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground`,children:[(0,S.jsx)(l,{className:`h-3.5 w-3.5`}),` Back to sessions`]}),(0,S.jsx)(O,{session:P})]}):(0,S.jsxs)(`div`,{className:`mx-auto max-w-6xl space-y-6 p-6`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h1`,{className:`text-xl font-semibold`,children:`Agent Sessions`}),(0,S.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`History of all single-agent chat sessions with token consumption analytics`})]}),M&&(0,S.jsx)(D,{stats:M}),M&&M.byAgent.length>0&&(0,S.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:(0,S.jsxs)(`div`,{className:`rounded-lg border bg-card p-4`,children:[(0,S.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-sm font-medium`,children:[(0,S.jsx)(y,{className:`h-4 w-4`}),` Top Agents (14d)`]}),(0,S.jsx)(`div`,{className:`space-y-2`,children:M.byAgent.slice(0,5).map(e=>(0,S.jsxs)(`div`,{className:`flex items-center justify-between text-sm`,children:[(0,S.jsx)(`span`,{className:`truncate`,children:e.agentName}),(0,S.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground`,children:[(0,S.jsxs)(`span`,{children:[e.sessions,` runs`]}),(0,S.jsxs)(`span`,{children:[w(e.totalTokens),` tok`]})]})]},e.agentId))})]})}),f.length>0&&(0,S.jsxs)(`div`,{className:`rounded-lg border border-yellow-500/30`,children:[(0,S.jsx)(`div`,{className:`border-b border-yellow-500/30 px-4 py-3`,children:(0,S.jsxs)(`h3`,{className:`text-sm font-medium flex items-center gap-2`,children:[(0,S.jsxs)(`span`,{className:`relative flex h-2 w-2`,children:[(0,S.jsx)(`span`,{className:`animate-ping absolute inline-flex h-full w-full rounded-full bg-yellow-400 opacity-75`}),(0,S.jsx)(`span`,{className:`relative inline-flex rounded-full h-2 w-2 bg-yellow-500`})]}),`Running (`,f.length,`)`]})}),(0,S.jsx)(`div`,{className:`divide-y`,children:f.map(t=>(0,S.jsxs)(`div`,{className:`flex items-center gap-4 px-4 py-3 hover:bg-muted/50 transition-colors`,children:[(0,S.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(`span`,{className:`font-medium text-sm truncate`,children:t.agentName}),(0,S.jsx)(s,{variant:`secondary`,className:`text-xs`,children:`running`})]}),(0,S.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground line-clamp-1`,children:t.prompt})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,S.jsxs)(c,{size:`sm`,variant:`outline`,onClick:()=>e(`/agents/${t.agentId}/use`),children:[(0,S.jsx)(p,{className:`mr-1.5 h-3.5 w-3.5`}),`Open`]}),(0,S.jsxs)(c,{size:`sm`,variant:`outline`,onClick:()=>B(t.streamId),children:[(0,S.jsx)(v,{className:`mr-1.5 h-3.5 w-3.5`}),`Stop`]})]})]},t.streamId))})]}),(0,S.jsxs)(`div`,{className:`rounded-lg border`,children:[(0,S.jsx)(`div`,{className:`border-b px-4 py-3`,children:(0,S.jsxs)(`h3`,{className:`text-sm font-medium`,children:[`All Sessions (`,A,`)`]})}),I&&(0,S.jsx)(`div`,{className:`p-8 text-center text-sm text-muted-foreground`,children:`Loading...`}),!I&&i.length===0&&(0,S.jsx)(`div`,{className:`p-8 text-center text-sm text-muted-foreground`,children:`No sessions yet. Run an agent to see history here.`}),!I&&i.length>0&&(0,S.jsx)(`div`,{className:`divide-y`,children:i.map(t=>{let n=t.inputTokens+t.outputTokens;return(0,S.jsxs)(`div`,{className:`flex items-center gap-4 px-4 py-3 hover:bg-muted/50 transition-colors cursor-pointer`,onClick:()=>e(`/agent-sessions/${t.id}`),children:[(0,S.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(`span`,{className:`font-medium text-sm truncate`,children:t.agentName}),(0,S.jsx)(s,{variant:C(t.status),className:`text-xs`,children:t.status}),t.model&&(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t.model}),t.cli&&(0,S.jsxs)(`span`,{className:`text-xs text-muted-foreground flex items-center gap-1`,children:[(0,S.jsx)(m,{className:`h-3 w-3`}),t.cli]})]}),(0,S.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground line-clamp-1`,children:t.prompt})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-4 text-xs text-muted-foreground shrink-0`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,S.jsx)(_,{className:`h-3 w-3`}),T(t.startedAt)]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,S.jsx)(d,{className:`h-3 w-3`}),w(n)]}),(0,S.jsx)(`span`,{children:E(t.startedAt,t.completedAt)}),(0,S.jsxs)(c,{size:`sm`,variant:`ghost`,className:`h-7 px-2`,onClick:n=>{n.stopPropagation(),e(`/agents/${t.agentId}/use/${t.id}`)},children:[(0,S.jsx)(g,{className:`mr-1 h-3.5 w-3.5`}),`Continue`]}),(0,S.jsx)(h,{className:`h-4 w-4`})]})]},t.id)})}),V>1&&(0,S.jsxs)(`div`,{className:`flex items-center justify-between border-t px-4 py-3`,children:[(0,S.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Page `,R,` of `,V]}),(0,S.jsxs)(`div`,{className:`flex gap-2`,children:[(0,S.jsx)(c,{size:`sm`,variant:`outline`,disabled:R<=1,onClick:()=>z(e=>e-1),children:`Previous`}),(0,S.jsx)(c,{size:`sm`,variant:`outline`,disabled:R>=V,onClick:()=>z(e=>e+1),children:`Next`})]})]})]})]})}export{k as AgentSessions};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{h as t,l as n,t as r,u as i}from"./vendor-react-BJ8SIkmN.js";import{t as a}from"./useQuery-DvovkaPT.js";import{t as o}from"./api-DNWoqIPN.js";import{S as s,_ as c,h as l,p as u,v as d}from"./vendor-ui-DnL9d3od.js";import{K as f,U as p,V as m,t as h}from"./src-CaF63bXY.js";import{t as g}from"./arrow-down-upU5tcpi.js";import{t as _}from"./arrow-left-BiNeYcK0.js";import{t as v}from"./chat-message-CW-HnO3f.js";import{n as y,t as b}from"./shield-check-BmphmMlD.js";import{t as ee}from"./history-w7qYglj5.js";import{n as te,r as x,t as S}from"./send-CNiXC6KO.js";import{t as C}from"./timer-3siC9tpd.js";import"./utils-D1nRmcA6.js";import{J as w,K as T,T as E,_ as ne,i as D,j as O,q as k,r as A,t as j,v as M,z as N}from"./index-DWNLSHpo.js";var P=e(t(),1),F=r();function I({cli:e,className:t}){return(0,P.createElement)(A(e),{className:t})}var re={agentDisplay:(0,P.memo)(function({data:e}){let{t}=E(),n=e.agent;return(0,F.jsxs)(`div`,{className:f(`rounded-xl border-2 w-[300px] transition-all duration-300`,{idle:`border-violet-500/50 bg-violet-500/5`,running:`border-emerald-500/60 bg-emerald-500/5 ring-2 ring-emerald-500/30`,done:`border-emerald-500/50 bg-emerald-500/5`,error:`border-red-500/50 bg-red-500/5`}[e.status],e.status===`running`&&`agent-node-active`),style:e.status===`running`?{boxShadow:`0 0 20px 4px rgba(16, 185, 129, 0.25), 0 0 40px 8px rgba(16, 185, 129, 0.10)`}:void 0,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-4`,children:[(0,F.jsx)(`span`,{className:`text-3xl`,children:n.avatar}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,F.jsx)(`div`,{className:`text-base font-semibold truncate`,children:n.name}),(0,F.jsxs)(`div`,{className:`text-xs text-muted-foreground flex items-center gap-1.5`,children:[n.runtime===`cli`&&n.cli&&(0,F.jsx)(I,{cli:n.cli,className:`h-3 w-3`}),n.runtime===`cli`?D(n.cli??void 0):`API`,(0,F.jsx)(`span`,{className:`text-muted-foreground/40`,children:`·`}),(0,F.jsx)(`span`,{children:n.model})]})]}),e.status===`running`&&(0,F.jsx)(`div`,{className:`h-2.5 w-2.5 rounded-full bg-emerald-500 animate-pulse`}),e.status===`done`&&(0,F.jsx)(p,{variant:`secondary`,className:`text-[10px] bg-emerald-500/15 text-emerald-500`,children:t(`common.done`)}),e.status===`error`&&(0,F.jsx)(p,{variant:`secondary`,className:`text-[10px] bg-red-500/15 text-red-500`,children:t(`common.error`)})]}),n.description&&(0,F.jsx)(`div`,{className:`px-4 pb-3 border-t border-border/30 pt-2`,children:(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground line-clamp-2`,children:n.description})}),(0,F.jsxs)(`div`,{className:`flex flex-wrap gap-1 px-4 pb-3`,children:[n.soul&&(0,F.jsxs)(p,{variant:`secondary`,className:`text-[10px]`,children:[(0,F.jsx)(T,{className:`h-2.5 w-2.5 mr-0.5`}),`SOUL`]}),n.identity&&(0,F.jsxs)(p,{variant:`secondary`,className:`text-[10px]`,children:[(0,F.jsx)(y,{className:`h-2.5 w-2.5 mr-0.5`}),`Identity`]}),n.rules&&(0,F.jsxs)(p,{variant:`secondary`,className:`text-[10px]`,children:[(0,F.jsx)(b,{className:`h-2.5 w-2.5 mr-0.5`}),`Rules`]}),n.heartbeat&&(0,F.jsxs)(p,{variant:`secondary`,className:`text-[10px]`,children:[(0,F.jsx)(C,{className:`h-2.5 w-2.5 mr-0.5`}),`Heartbeat`]}),n.knowledge&&(0,F.jsxs)(p,{variant:`secondary`,className:`text-[10px]`,children:[(0,F.jsx)(w,{className:`h-2.5 w-2.5 mr-0.5`}),`Knowledge`]})]}),(0,F.jsx)(c,{type:`source`,position:s.Right,className:`!bg-transparent !border-0 !w-0 !h-0`})]})})};function L(){let{id:e,sessionId:t}=i(),r=n(),{t:s}=E(),{data:c,isLoading:y}=a({queryKey:[`agents`,e],queryFn:()=>o.agents.get(e),enabled:!!e}),[b,C]=(0,P.useState)([]),[w,T]=(0,P.useState)(``),[D,A]=(0,P.useState)(`idle`),[I,L]=(0,P.useState)(),R=(0,P.useRef)(null),z=(0,P.useRef)(null),B=(0,P.useRef)(null),[V,H]=(0,P.useState)(!0),[U,W]=(0,P.useState)(`side`),{streamingContent:G,streamingThinking:K,streamingToolCalls:q,isStreaming:J,error:Y,stopStream:X,consumeStream:Z}=ne(I),Q=(0,P.useCallback)(()=>{R.current?.scrollIntoView({behavior:`smooth`})},[]),ie=(0,P.useCallback)(()=>{let e=z.current;e&&H(e.scrollHeight-e.scrollTop-e.clientHeight<100)},[]);(0,P.useEffect)(()=>{(G||q.length>0)&&V&&Q()},[G,q,Q,V]),(0,P.useEffect)(()=>{b.length>0&&b[b.length-1].role===`user`&&setTimeout(Q,0)},[b.length,Q]);let ae=(0,P.useMemo)(()=>{let e=[],t={user:null,replies:[]};for(let n of b)n.role===`user`?((t.user||t.replies.length>0)&&e.push(t),t={user:n,replies:[]}):t.replies.push(n);return(t.user||t.replies.length>0)&&e.push(t),e},[b]);(0,P.useEffect)(()=>{J&&D!==`running`&&A(`running`)},[J,D]),(0,P.useEffect)(()=>{if(!J&&(G||q.length>0)&&(D===`running`||D===`done`)){let e=Z();e&&(e.content||e.toolCalls.length>0)&&(C(t=>[...t,{id:crypto.randomUUID(),role:`assistant`,content:e.content,timestamp:new Date,thinking:e.thinking||void 0,toolCalls:e.toolCalls.map(e=>({id:e.id,name:e.name,input:e.input,output:e.output}))}]),A(`done`))}},[J,G,q,D,Z]),(0,P.useEffect)(()=>{if(Y&&D===`running`){if(G||q.length>0)return;A(`error`),C(e=>[...e,{id:crypto.randomUUID(),role:`system`,content:`Error: ${Y}`,timestamp:new Date}])}},[Y,D,G,q]);let $=(0,P.useCallback)(async()=>{let e=w.trim();if(!e||!c||J)return;let t={id:crypto.randomUUID(),role:`user`,content:e,timestamp:new Date};C(e=>[...e,t]),T(``),A(`running`);try{let t=c.additionalFolders?.map(e=>e.path),n=await o.chat.startNew(c.dir,e,c.cli??void 0,t?.length?t:void 0,c.model||void 0),r=`agent-use/${c.id}/${n.streamId}`;L(r),M(n.streamId,r),o.agentSessions.track({agentId:c.id,agentName:c.name,streamId:n.streamId,prompt:e,cli:c.cli??void 0,model:c.model||void 0}).catch(()=>{})}catch(e){A(`error`),j.error(s(`agentUse.failedToStart`)),C(t=>[...t,{id:crypto.randomUUID(),role:`system`,content:`Failed to start session: ${e}`,timestamp:new Date}])}},[w,c,J,s]),oe=(0,P.useCallback)(()=>{X(),A(`idle`)},[X]),se=(0,P.useCallback)(e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),$())},[$]);(0,P.useEffect)(()=>{!t||!c||o.agentSessions.get(t).then(e=>{let t=[{id:crypto.randomUUID(),role:`user`,content:e.prompt,timestamp:new Date(e.startedAt)}];e.output&&t.push({id:crypto.randomUUID(),role:`assistant`,content:e.output,timestamp:new Date(e.completedAt??e.startedAt)}),e.error&&t.push({id:crypto.randomUUID(),role:`system`,content:`Error: ${e.error}`,timestamp:new Date(e.completedAt??e.startedAt)}),C(t),A(`done`)}).catch(()=>{})},[t,c?.id]),(0,P.useEffect)(()=>{!c||I||t||o.agentSessions.listActive(c.id).then(({data:e})=>{let t=e.find(e=>e.status===`running`);if(t){let e=`agent-use/${c.id}/${t.streamId}`;L(e),M(t.streamId,e),A(`running`),C([{id:crypto.randomUUID(),role:`user`,content:t.prompt,timestamp:new Date(t.startedAt)}]),j.info(`Reconnected to active session`)}}).catch(()=>{})},[c?.id]);let ce=c?[{id:`agent-node`,type:`agentDisplay`,position:{x:100,y:100},data:{agent:c,status:D},draggable:!0,selectable:!1}]:[];return y?(0,F.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,F.jsx)(N,{className:`h-8 w-8 animate-spin text-muted-foreground`})}):c?(0,F.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2 border-b bg-background/95 backdrop-blur shrink-0`,children:[(0,F.jsx)(m,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>r(`/agents`),children:(0,F.jsx)(_,{className:`h-4 w-4`})}),(0,F.jsx)(`span`,{className:`text-xl`,children:c.avatar}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h1`,{className:`text-sm font-semibold`,children:c.name}),(0,F.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:s(`agentUse.interactiveSession`)})]}),(0,F.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[D===`running`&&(0,F.jsx)(p,{className:`bg-emerald-500/15 text-emerald-500 border-emerald-500/30 animate-pulse`,children:s(`common.running`)}),(0,F.jsxs)(m,{variant:`ghost`,size:`sm`,className:`h-7 text-xs gap-1`,onClick:()=>r(`/agent-sessions?agentId=${c.id}`),children:[(0,F.jsx)(ee,{className:`h-3.5 w-3.5`}),` History`]}),(0,F.jsxs)(`div`,{className:`flex items-center border rounded-lg p-0.5 bg-muted/50`,children:[(0,F.jsx)(m,{variant:U===`side`?`secondary`:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>W(`side`),title:s(`common.sideBySide`),children:(0,F.jsx)(x,{className:`h-3.5 w-3.5`})}),(0,F.jsx)(m,{variant:U===`stack`?`secondary`:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>W(`stack`),title:s(`common.stacked`),children:(0,F.jsx)(te,{className:`h-3.5 w-3.5`})})]})]})]}),(0,F.jsxs)(`div`,{className:f(`flex-1 min-h-0`,U===`side`?`flex`:`flex flex-col`),children:[(0,F.jsx)(`div`,{className:f(`bg-muted/30`,U===`side`?`w-[45%] border-r`:`h-[280px] border-b shrink-0`),children:(0,F.jsxs)(d,{nodes:ce,edges:[],nodeTypes:re,fitView:!0,fitViewOptions:{padding:.5},proOptions:{hideAttribution:!0},panOnScroll:!0,zoomOnScroll:!0,minZoom:.5,maxZoom:1.5,children:[(0,F.jsx)(u,{gap:20,size:1}),(0,F.jsx)(l,{showInteractive:!1})]})}),(0,F.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0 min-h-0`,children:[(0,F.jsx)(`div`,{className:`relative flex-1 overflow-y-auto min-h-0`,ref:z,onScroll:ie,children:(0,F.jsxs)(`div`,{className:`p-3`,children:[b.length===0&&!G&&!J&&(0,F.jsxs)(`div`,{className:`text-center py-16 text-muted-foreground`,children:[(0,F.jsx)(k,{className:`h-12 w-12 mx-auto mb-3 opacity-30`}),(0,F.jsx)(`p`,{className:`font-medium`,children:s(`agentUse.startConversation`)}),(0,F.jsx)(`p`,{className:`text-sm mt-1`,children:s(`agentUse.sendMessageTo`,{name:c.name})})]}),ae.map((e,t)=>(0,F.jsxs)(`div`,{children:[e.user&&(0,F.jsx)(`div`,{className:`sticky top-0 z-10 py-1`,children:(0,F.jsx)(v,{role:e.user.role,content:e.user.content,compact:!0})}),(0,F.jsx)(`div`,{className:`flex flex-col gap-1 pt-1`,children:e.replies.map(e=>(0,F.jsx)(v,{role:e.role,content:e.content,thinking:e.thinking,toolCalls:e.toolCalls},e.id))})]},e.user?.id??`group-${t}`)),J&&(G||K||q.length>0)&&(0,F.jsx)(v,{role:`assistant`,content:G,thinking:K,toolCalls:q?.map(e=>({id:e.id,name:e.name,input:e.input,output:e.pending?void 0:e.output}))}),J&&!G&&!K&&q.length===0&&(0,F.jsx)(`div`,{className:`flex justify-start`,children:(0,F.jsx)(`div`,{className:`bg-muted rounded-lg px-4 py-2 text-sm text-muted-foreground`,children:s(`common.thinking`)})}),Y&&D===`error`&&(0,F.jsx)(`div`,{className:`text-center text-destructive text-sm`,children:Y}),(0,F.jsx)(`div`,{ref:R})]})}),!V&&(0,F.jsx)(`div`,{className:`pointer-events-none flex justify-end px-4 -mt-12 mb-1 relative z-10`,children:(0,F.jsx)(m,{variant:`secondary`,size:`icon`,className:`pointer-events-auto rounded-full shadow-lg h-8 w-8 opacity-80 hover:opacity-100 transition-opacity`,onClick:Q,children:(0,F.jsx)(g,{className:`h-4 w-4`})})}),(0,F.jsx)(`div`,{className:`border-t p-4 shrink-0`,children:(0,F.jsxs)(`div`,{className:`flex gap-2 max-w-2xl mx-auto`,children:[(0,F.jsx)(h,{ref:B,value:w,onChange:e=>T(e.target.value),onKeyDown:se,placeholder:`Message ${c.name}...`,className:`min-h-[44px] max-h-[200px] resize-none`,rows:1,disabled:J}),J?(0,F.jsx)(m,{variant:`destructive`,size:`icon`,className:`h-[44px] w-[44px] shrink-0`,onClick:oe,children:(0,F.jsx)(O,{className:`h-4 w-4`})}):(0,F.jsx)(m,{size:`icon`,className:`h-[44px] w-[44px] shrink-0`,onClick:$,disabled:!w.trim(),children:(0,F.jsx)(S,{className:`h-4 w-4`})})]})})]})]})]}):(0,F.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4`,children:[(0,F.jsx)(`p`,{className:`text-muted-foreground`,children:s(`agentUse.agentNotFound`)}),(0,F.jsxs)(m,{variant:`outline`,onClick:()=>r(`/agents`),children:[(0,F.jsx)(_,{className:`h-4 w-4 mr-1`}),` `,s(`agentUse.backToAgents`)]})]})}export{L as AgentUse};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{d as t,h as n,l as r,t as i}from"./vendor-react-BJ8SIkmN.js";import{r as a,t as o}from"./useQuery-DvovkaPT.js";import{t as s}from"./useMutation-DA8-TvTt.js";import{t as c}from"./api-DNWoqIPN.js";import{B as l,I as u,L as d,R as f,U as p,V as m,a as h,i as g,n as _,r as v,w as y,z as b}from"./src-CaF63bXY.js";import{n as x,r as S,t as C}from"./shuffle-Dv_-PFl5.js";import{t as w}from"./download-CwO6xusv.js";import{n as T,t as E}from"./shield-check-BmphmMlD.js";import{t as D}from"./globe-C0WHVFW_.js";import{t as O}from"./history-w7qYglj5.js";import{t as k}from"./play-BzkxV_O-.js";import{t as A}from"./search-BmZSwFnA.js";import{t as j}from"./timer-3siC9tpd.js";import{A as M,J as N,K as P,L as F,N as I,O as L,T as R,a as z,i as B,m as V,q as H,r as U,t as W}from"./index-DWNLSHpo.js";var G=e(n(),1),K=i(),q={"claude-opus-4-6":`Opus 4.6`,"claude-sonnet-4-6":`Sonnet 4.6`,"claude-haiku-4-5-20251001":`Haiku 4.5`,"composer-2-fast":`Composer 2 Fast`,"composer-2":`Composer 2`,"claude-4.6-opus-high-thinking":`Opus 4.6 Thinking`,"claude-4.6-opus-high":`Opus 4.6`,"claude-4.6-sonnet-medium-thinking":`Sonnet 4.6 Thinking`,"claude-4.6-sonnet-medium":`Sonnet 4.6`,"claude-4.5-sonnet-thinking":`Sonnet 4.5 Thinking`,"claude-4.5-sonnet":`Sonnet 4.5`,"claude-4-sonnet-thinking":`Sonnet 4 Thinking`,"claude-4-sonnet":`Sonnet 4`,"gpt-5.4-medium":`GPT-5.4`,"gpt-5.4-high":`GPT-5.4 High`,"gpt-5.3-codex":`GPT-5.3 Codex`,"gpt-5.2":`GPT-5.2`,"gpt-5-mini":`GPT-5 Mini`},J={sequential:{icon:S,label:`Sequential`,description:`Agents run one after another, passing output forward`},parallel:{icon:x,label:`Parallel`,description:`All agents run simultaneously on the same input`},router:{icon:C,label:`Router`,description:`A router agent decides which agent handles the task`},debate:{icon:F,label:`Debate`,description:`Agents discuss and reach consensus`}};function Y({cli:e,className:t}){return(0,G.createElement)(U(e),{className:t})}function X({agent:e,onEdit:t,onDelete:n,onExport:r,onUse:i}){let{t:a}=R(),o=q[e.model]??e.model,s=null;return e.runtime===`cli`&&e.cli?s=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Y,{cli:e.cli,className:`h-3 w-3`}),B(e.cli??void 0)]}):e.runtime===`api`&&(s=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(D,{className:`h-3 w-3`}),`API`]})),(0,K.jsxs)(u,{className:`group flex flex-col h-full hover:shadow-md transition-shadow cursor-pointer`,onClick:t,children:[(0,K.jsx)(b,{className:`pb-2`,children:(0,K.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-2xl`,children:e.avatar}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(l,{className:`text-base`,children:e.name}),(0,K.jsxs)(f,{className:`text-xs flex items-center gap-1.5`,children:[s,(0,K.jsx)(`span`,{className:`text-muted-foreground/40`,children:`·`}),o]})]})]}),(0,K.jsxs)(`div`,{className:`flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,K.jsx)(m,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:e=>{e.stopPropagation(),r()},title:a(`agents.exportSoulMd`),children:(0,K.jsx)(w,{className:`h-3.5 w-3.5`})}),(0,K.jsx)(m,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:e=>{e.stopPropagation(),n()},title:a(`common.delete`),children:(0,K.jsx)(M,{className:`h-3.5 w-3.5 text-destructive`})})]})]})}),(0,K.jsxs)(d,{className:`pt-0 flex-1`,children:[e.description&&(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground mb-2 line-clamp-2`,children:e.description}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[e.soul&&(0,K.jsxs)(p,{variant:`secondary`,className:`text-xs`,children:[(0,K.jsx)(P,{className:`h-2.5 w-2.5 mr-1`}),`SOUL`]}),e.identity&&(0,K.jsxs)(p,{variant:`secondary`,className:`text-xs`,children:[(0,K.jsx)(T,{className:`h-2.5 w-2.5 mr-1`}),`Identity`]}),e.rules&&(0,K.jsxs)(p,{variant:`secondary`,className:`text-xs`,children:[(0,K.jsx)(E,{className:`h-2.5 w-2.5 mr-1`}),`Rules`]}),e.heartbeat&&(0,K.jsxs)(p,{variant:`secondary`,className:`text-xs`,children:[(0,K.jsx)(j,{className:`h-2.5 w-2.5 mr-1`}),`Heartbeat`]}),e.knowledge&&(0,K.jsxs)(p,{variant:`secondary`,className:`text-xs`,children:[(0,K.jsx)(N,{className:`h-2.5 w-2.5 mr-1`}),`Knowledge`]}),e.tags.map(e=>(0,K.jsx)(p,{variant:`outline`,className:`text-xs`,children:e},e))]}),(0,K.jsx)(`div`,{className:`mt-auto pt-3 flex justify-end`,children:(0,K.jsxs)(m,{size:`sm`,onClick:e=>{e.stopPropagation(),i()},children:[(0,K.jsx)(k,{className:`h-3.5 w-3.5 mr-1`}),`Use`]})})]})]})}function Z({team:e,allAgents:t,onEdit:n,onDelete:r,onUse:i}){let{t:a}=R(),o=J[e.strategy],s=o.icon;return(0,K.jsxs)(u,{className:`group flex flex-col h-full hover:shadow-md transition-shadow cursor-pointer`,onClick:n,children:[(0,K.jsx)(b,{className:`pb-2`,children:(0,K.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`div`,{className:`h-9 w-9 rounded-lg bg-primary/10 flex items-center justify-center`,children:(0,K.jsx)(L,{className:`h-4 w-4 text-primary`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(l,{className:`text-base`,children:e.name}),(0,K.jsxs)(f,{className:`text-xs flex items-center gap-1`,children:[(0,K.jsx)(s,{className:`h-3 w-3`}),o.label]})]})]}),(0,K.jsx)(`div`,{className:`flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,K.jsx)(m,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:e=>{e.stopPropagation(),r()},title:a(`common.delete`),children:(0,K.jsx)(M,{className:`h-3.5 w-3.5 text-destructive`})})})]})}),(0,K.jsxs)(d,{className:`pt-0 flex-1`,children:[e.description&&(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground mb-2 line-clamp-2`,children:e.description}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 flex-wrap`,children:[e.agents.map((e,n)=>{let r=t.find(t=>t.id===e.agentId);return(0,K.jsxs)(`div`,{className:`flex items-center gap-1 rounded-full bg-muted px-2 py-0.5 text-xs`,title:e.role||r?.name,children:[(0,K.jsx)(`span`,{children:r?.avatar??`?`}),(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:r?.name??`Unknown`}),e.role&&(0,K.jsxs)(`span`,{className:`text-primary/70 font-medium`,children:[`(`,e.role,`)`]})]},n)}),e.agents.length===0&&(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground italic`,children:a(`agents.noMembersYet`)})]}),e.tags.length>0&&(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-2`,children:e.tags.map(e=>(0,K.jsx)(p,{variant:`outline`,className:`text-xs`,children:e},e))}),(0,K.jsx)(`div`,{className:`mt-auto pt-3 flex justify-end`,children:(0,K.jsxs)(m,{size:`sm`,onClick:e=>{e.stopPropagation(),i()},children:[(0,K.jsx)(k,{className:`h-3.5 w-3.5 mr-1`}),`Use`]})})]})]})}function Q(){let e=r(),n=a(),{t:i}=R(),[l,u]=t(),d=l.get(`tab`)===`teams`?`teams`:`agents`,f=e=>u(e===`agents`?{}:{tab:e},{replace:!0}),[b,x]=(0,G.useState)(``),S=o({queryKey:[`agents`],queryFn:()=>c.agents.list({page:1,pageSize:100})}),C=o({queryKey:[`teams`],queryFn:()=>c.teams.list({page:1,pageSize:100})}),w=s({mutationFn:e=>c.agents.delete(e),onSuccess:()=>{n.invalidateQueries({queryKey:[`agents`]}),W.success(i(`agentEdit.agentDeleted`))}}),T=s({mutationFn:e=>c.teams.delete(e),onSuccess:()=>{n.invalidateQueries({queryKey:[`teams`]}),W.success(i(`agents.teamDeleted`))}}),E=S.data?.data??[],D=C.data?.data??[],k=E.filter(e=>!b||e.name.toLowerCase().includes(b.toLowerCase())||e.description.toLowerCase().includes(b.toLowerCase())||e.tags.some(e=>e.toLowerCase().includes(b.toLowerCase()))),j=D.filter(e=>!b||e.name.toLowerCase().includes(b.toLowerCase())||e.description.toLowerCase().includes(b.toLowerCase())),M=(0,G.useCallback)(async e=>{try{let t=await c.agents.exportSoul(e.id);await navigator.clipboard.writeText(t),W.success(i(`agents.soulMdCopied`))}catch{W.error(i(`agentEdit.failedToExport`))}},[i]);return(0,K.jsxs)(`div`,{className:`p-6 max-w-6xl mx-auto space-y-6`,children:[(0,K.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Agents`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Create and manage AI agents with SOUL files, then compose them into teams`})]})}),(0,K.jsxs)(_,{value:d,onValueChange:f,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,K.jsxs)(g,{children:[(0,K.jsxs)(h,{value:`agents`,className:`gap-1.5`,children:[(0,K.jsx)(H,{className:`h-4 w-4`}),` Agents`,E.length>0&&(0,K.jsx)(p,{variant:`secondary`,className:`ml-1 text-xs h-5 px-1.5`,children:E.length})]}),(0,K.jsxs)(h,{value:`teams`,className:`gap-1.5`,children:[(0,K.jsx)(L,{className:`h-4 w-4`}),` Teams`,D.length>0&&(0,K.jsx)(p,{variant:`secondary`,className:`ml-1 text-xs h-5 px-1.5`,children:D.length})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(A,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground`}),(0,K.jsx)(y,{value:b,onChange:e=>x(e.target.value),placeholder:i(`common.search`),className:`pl-9 w-52`})]}),d===`agents`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(m,{variant:`outline`,onClick:()=>e(`/agent-sessions`),children:[(0,K.jsx)(O,{className:`h-4 w-4 mr-1`}),` History`]}),(0,K.jsxs)(m,{onClick:()=>e(`/agents/new`),children:[(0,K.jsx)(I,{className:`h-4 w-4 mr-1`}),` New Agent`]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(m,{variant:`outline`,onClick:()=>e(`/team-sessions`),children:[(0,K.jsx)(O,{className:`h-4 w-4 mr-1`}),` History`]}),(0,K.jsxs)(m,{onClick:()=>e(`/agents/teams/new`),children:[(0,K.jsx)(I,{className:`h-4 w-4 mr-1`}),` New Team`]})]})]})]}),(0,K.jsxs)(v,{value:`agents`,className:`mt-4`,children:[S.isLoading&&(0,K.jsx)(z,{count:6}),!S.isLoading&&k.length===0&&(0,K.jsxs)(`div`,{className:`text-center py-16 text-muted-foreground`,children:[(0,K.jsx)(H,{className:`h-12 w-12 mx-auto mb-3 opacity-30`}),(0,K.jsx)(`p`,{className:`font-medium`,children:i(`agents.noAgentsYet`)}),(0,K.jsx)(`p`,{className:`text-sm mt-1`,children:i(`agents.createFirstAgent`)}),(0,K.jsxs)(m,{className:`mt-4`,onClick:()=>e(`/agents/new`),children:[(0,K.jsx)(I,{className:`h-4 w-4 mr-1`}),` Create Agent`]})]}),!S.isLoading&&k.length>0&&(0,K.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:k.map(t=>(0,K.jsx)(X,{agent:t,onEdit:()=>e(`/agents/${t.id}`),onDelete:()=>w.mutate(t.id),onExport:()=>M(t),onUse:()=>e(`/agents/${t.id}/use`)},t.id))})]}),(0,K.jsxs)(v,{value:`teams`,className:`mt-4`,children:[C.isLoading&&(0,K.jsx)(V,{count:4}),!C.isLoading&&j.length===0&&(0,K.jsxs)(`div`,{className:`text-center py-16 text-muted-foreground`,children:[(0,K.jsx)(L,{className:`h-12 w-12 mx-auto mb-3 opacity-30`}),(0,K.jsx)(`p`,{className:`font-medium`,children:i(`agents.noTeamsYet`)}),(0,K.jsx)(`p`,{className:`text-sm mt-1`,children:`Compose agents into teams with different orchestration strategies`}),(0,K.jsxs)(m,{className:`mt-4`,onClick:()=>e(`/agents/teams/new`),disabled:E.length===0,children:[(0,K.jsx)(I,{className:`h-4 w-4 mr-1`}),` Create Team`]}),E.length===0&&(0,K.jsx)(`p`,{className:`text-xs mt-2 text-muted-foreground`,children:i(`agents.createAgentsFirst`)})]}),!C.isLoading&&j.length>0&&(0,K.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:j.map(t=>(0,K.jsx)(Z,{team:t,allAgents:E,onEdit:()=>e(`/agents/teams/${t.id}`),onDelete:()=>T.mutate(t.id),onUse:()=>e(`/agents/teams/${t.id}/use`)},t.id))})]})]})]})}export{Q as Agents};
@@ -0,0 +1 @@
1
+ var e=`/api`;function t(e,t){return t?`${e}?${t}`:e}async function n(t,n){let r={...n?.headers};n?.body&&(r[`Content-Type`]??=`application/json`);let i=sessionStorage.getItem(`gatewayToken`);i&&(r.Authorization??=`Bearer ${i}`);let a=await fetch(`${e}${t}`,{...n,headers:r,credentials:`include`});if(!a.ok)throw a.status===401?(sessionStorage.removeItem(`gatewayToken`),window.location.href=`/login`,Error(`Unauthorized`)):Error(`API error ${a.status}: ${await a.text()}`);return a.json()}function r(e){if(!e)return``;let t=new URLSearchParams;e.page&&t.set(`page`,String(e.page)),e.pageSize&&t.set(`pageSize`,String(e.pageSize));let n=t.toString();return n?`?${n}`:``}function i(e,t){if(!t)return e;let n=new URLSearchParams(e);t.page&&n.set(`page`,String(t.page)),t.pageSize&&n.set(`pageSize`,String(t.pageSize));let r=n.toString();return r?`?${r}`:``}function a(e){return`url`in e&&!(`command`in e)}var o={chat:{getWorkspaces:e=>n(`/chat/workspaces${r(e)}`),getRecent:e=>n(`/chat/recent${i(`excludeWorkflow=true`,e)}`),lookupWorkspace:e=>n(`/chat/lookup/${encodeURIComponent(e)}`),getSessions:(e,t)=>n(`/chat/${e}/sessions${r(t)}`),getMessages:(e,r,i)=>{let a=new URLSearchParams;i?.offset&&a.set(`offset`,String(i.offset)),i?.limit&&a.set(`limit`,String(i.limit));let o=a.toString();return n(t(`/chat/${e}/${r}/messages`,o))},sendMessage:(e,t,r,i)=>n(`/chat/${e}/${t}/send`,{method:`POST`,body:JSON.stringify({message:r,cli:i})}),startNew:(e,t,r,i,a)=>n(`/chat/new`,{method:`POST`,body:JSON.stringify({workspacePath:e,message:t,cli:r,additionalDirs:i,model:a})}),stopStream:e=>n(`/chat/stream/${e}`,{method:`DELETE`}),deleteSession:(e,t)=>n(`/chat/${e}/${t}`,{method:`DELETE`}),getGitBranches:e=>n(`/chat/git-branches`,{method:`POST`,body:JSON.stringify({paths:e})}),getCommands:async e=>{let[r,i]=await Promise.all([n(t(`/chat/commands`,e?`workspace=${encodeURIComponent(e)}`:``)),n(`/skill-preferences`)]),a=new Set(i.disabled);return r.map(e=>({...e,enabled:!a.has(e.name)}))},getModifiedFiles:(e,t)=>n(`/chat/${e}/${t}/modified-files`),getFileChanges:(e,t,r)=>n(`/chat/${e}/${t}/file-changes?file=${encodeURIComponent(r)}`),resumeSession:(e,t,r,i)=>n(`/chat/${e}/${t}/resume`,{method:`POST`,body:JSON.stringify({message:r,cli:i})}),browse:e=>n(t(`/chat/browse`,e?`path=${encodeURIComponent(e)}`:``))},sessions:{getActive:()=>n(`/sessions/active`),getRecent:()=>n(`/sessions/recent`),getFolders:()=>n(`/sessions/folders`),getTranscript:(e,t)=>n(`/sessions/${encodeURIComponent(e)}/${t}/transcript`)},workflows:{getWorkspaces:()=>n(`/workflows/workspaces`),list:e=>n(`/workflows${r(e)}`),get:e=>n(`/workflows/${e}`),create:e=>n(`/workflows`,{method:`POST`,body:JSON.stringify(e)}),update:(e,t)=>n(`/workflows/${e}`,{method:`PUT`,body:JSON.stringify(t)}),delete:e=>n(`/workflows/${e}`,{method:`DELETE`}),trigger:(e,t)=>n(`/workflows/${e}/trigger`,{method:`POST`,body:JSON.stringify({payload:t})}),toggle:e=>n(`/workflows/${e}/toggle`,{method:`PATCH`}),clone:e=>n(`/workflows/${e}/clone`,{method:`POST`}),getActiveCounts:()=>n(`/workflows/active-counts`),getRecentRuns:e=>n(`/workflows/recent-runs${r(e)}`),getRuns:(e,t)=>n(`/workflows/${e}/runs${r(t)}`),getRun:e=>n(`/workflows/runs/${e}`),cancelRun:e=>n(`/workflows/runs/${e}`,{method:`DELETE`}),getRunLogs:(e,t)=>n(`/workflows/runs/${e}/logs${r(t)}`),getPendingActions:()=>n(`/workflows/pending-actions`),approveHumanAction:(e,t,r)=>n(`/workflows/runs/${e}/approve/${t}`,{method:`POST`,body:JSON.stringify({approved:!0,response:r})}),rejectHumanAction:(e,t,r)=>n(`/workflows/runs/${e}/approve/${t}`,{method:`POST`,body:JSON.stringify({approved:!1,reason:r})}),getRunSummary:(e,t)=>n(`/workflows/runs/${e}/summary/${t}`,{method:`POST`}),replayRun:e=>n(`/workflows/runs/${e}/replay`,{method:`POST`})},skillPreferences:{get:()=>n(`/skill-preferences`),toggle:e=>n(`/skill-preferences/toggle`,{method:`POST`,body:JSON.stringify({name:e})})},analytics:{getOverview:()=>n(`/analytics/overview`),getRunsPerHour:()=>n(`/analytics/runs-per-hour`),getDailyTrend:()=>n(`/analytics/daily-trend`),getTopWorkflows:()=>n(`/analytics/top-workflows`),getActionTypes:()=>n(`/analytics/action-types`),getRecentErrors:()=>n(`/analytics/recent-errors`),getContextUsage:()=>n(`/analytics/context-usage`),getContextDaily:()=>n(`/analytics/context-daily`),getTokensByModel:()=>n(`/analytics/tokens-by-model`),getTokensByCli:()=>n(`/analytics/tokens-by-cli`),getClaudeCodeUsage:()=>n(`/analytics/claude-code-usage`),getTeamRunsUsage:()=>n(`/analytics/team-runs-usage`)},credentials:{list:e=>n(`/credentials${r(e)}`),get:e=>n(`/credentials/${e}`),create:e=>n(`/credentials`,{method:`POST`,body:JSON.stringify(e)}),update:(e,t)=>n(`/credentials/${e}`,{method:`PUT`,body:JSON.stringify(t)}),delete:e=>n(`/credentials/${e}`,{method:`DELETE`})},commands:{list:e=>n(`/commands${r(e)}`),get:e=>n(`/commands/${encodeURIComponent(e)}`),save:(e,t)=>n(`/commands/${encodeURIComponent(e)}`,{method:`PUT`,body:JSON.stringify({content:t})}),delete:e=>n(`/commands/${encodeURIComponent(e)}`,{method:`DELETE`})},fs:{tree:(e,t=1)=>n(`/fs/tree?path=${encodeURIComponent(e)}&depth=${t}`),readFile:(e,t)=>{let r={};return t&&(r[`if-none-match`]=t),n(`/fs/file?path=${encodeURIComponent(e)}`,{headers:r})},writeFile:(e,t)=>n(`/fs/file?path=${encodeURIComponent(e)}`,{method:`PUT`,body:JSON.stringify({content:t})}),deleteFile:e=>n(`/fs/file?path=${encodeURIComponent(e)}`,{method:`DELETE`}),mkdir:e=>n(`/fs/mkdir?path=${encodeURIComponent(e)}`,{method:`POST`}),move:(e,t)=>n(`/fs/move`,{method:`POST`,body:JSON.stringify({from:e,to:t})}),pickFolder:()=>n(`/fs/pick-folder`,{method:`POST`})},settings:{getCliAgents:()=>n(`/settings/cli-agents`)},mcpConfigs:{detectClis:()=>n(`/mcp-configs`),getServers:e=>n(`/mcp-configs/${e}`),putServer:(e,t,r)=>n(`/mcp-configs/${e}/${encodeURIComponent(t)}`,{method:`PUT`,body:JSON.stringify(r)}),deleteServer:(e,t,r)=>{let i=r?`?project=${encodeURIComponent(r)}`:``;return n(`/mcp-configs/${e}/${encodeURIComponent(t)}${i}`,{method:`DELETE`})}},debug:{getWatchers:()=>n(`/debug/watchers`)},agents:{list:e=>n(`/agents${r(e)}`),get:e=>n(`/agents/${e}`),create:e=>n(`/agents`,{method:`POST`,body:JSON.stringify(e)}),update:(e,t)=>n(`/agents/${e}`,{method:`PUT`,body:JSON.stringify(t)}),delete:e=>n(`/agents/${e}`,{method:`DELETE`}),exportSoul:t=>fetch(`${e}/agents/${t}/soul`).then(e=>e.text()),checkSlug:(e,t)=>{let r=t?`&excludeId=${encodeURIComponent(t)}`:``;return n(`/agents/check-slug?slug=${encodeURIComponent(e)}${r}`)}},teams:{list:e=>n(`/agents/teams${r(e)}`),get:e=>n(`/agents/teams/${e}`),create:e=>n(`/agents/teams`,{method:`POST`,body:JSON.stringify(e)}),update:(e,t)=>n(`/agents/teams/${e}`,{method:`PUT`,body:JSON.stringify(t)}),delete:e=>n(`/agents/teams/${e}`,{method:`DELETE`}),startRun:(e,t,r)=>n(`/team-runs/${e}/run`,{method:`POST`,body:JSON.stringify({prompt:t,maxRounds:r})}),getRun:e=>n(`/team-runs/${e}`),cancelRun:e=>n(`/team-runs/${e}`,{method:`DELETE`}),listActiveRuns:()=>n(`/team-runs`)},agentSessions:{list:e=>{let r=new URLSearchParams;return e?.agentId&&r.set(`agentId`,e.agentId),e?.status&&r.set(`status`,e.status),e?.limit&&r.set(`limit`,String(e.limit)),e?.offset&&r.set(`offset`,String(e.offset)),n(t(`/agent-sessions`,r.toString()))},get:e=>n(`/agent-sessions/${e}`),stats:e=>n(t(`/agent-sessions/stats`,e?`days=${e}`:``)),track:e=>n(`/agent-sessions/track`,{method:`POST`,body:JSON.stringify(e)}),listActive:e=>n(t(`/agent-sessions/active`,e?`agentId=${e}`:``))},teamSessions:{list:e=>{let r=new URLSearchParams;return e?.teamId&&r.set(`teamId`,e.teamId),e?.agentId&&r.set(`agentId`,e.agentId),e?.status&&r.set(`status`,e.status),e?.limit&&r.set(`limit`,String(e.limit)),e?.offset&&r.set(`offset`,String(e.offset)),n(t(`/team-sessions`,r.toString()))},get:e=>n(`/team-sessions/${e}`),stats:e=>n(t(`/team-sessions/stats`,e?`days=${e}`:``))},memory:{search:e=>{let r=new URLSearchParams;return e.text&&r.set(`text`,e.text),e.keywords&&r.set(`keywords`,e.keywords),e.scope&&r.set(`scope`,e.scope),e.agentId&&r.set(`agentId`,e.agentId),e.teamId&&r.set(`teamId`,e.teamId),e.tiers&&r.set(`tiers`,e.tiers),e.category&&r.set(`category`,e.category),e.limit&&r.set(`limit`,String(e.limit)),e.minImportance&&r.set(`minImportance`,String(e.minImportance)),n(t(`/memory/search`,r.toString()))},create:e=>n(`/memory/entries`,{method:`POST`,body:JSON.stringify(e)}),delete:(e,t,r)=>{let i=new URLSearchParams({scope:t});return r&&i.set(`scopeId`,r),n(`/memory/entries/${e}?${i.toString()}`,{method:`DELETE`})},listAgent:(e,t=100)=>n(`/memory/agent/${e}?limit=${t}`),listTeam:(e,t=100)=>n(`/memory/team/${e}?limit=${t}`),listGlobal:(e=100)=>n(`/memory/global?limit=${e}`),promote:e=>n(`/memory/promote/${e}`,{method:`POST`}),demote:(e,t,r)=>n(`/memory/demote/${e}`,{method:`POST`,body:JSON.stringify({scope:t,scopeId:r})}),getPending:()=>n(`/memory/pending`),getConfig:()=>n(`/memory/config`),rebuildIndex:()=>n(`/memory/rebuild-index`,{method:`POST`})},users:{list:()=>n(`/users`),get:e=>n(`/users/${e}`),update:(e,t)=>n(`/users/${e}`,{method:`PUT`,body:JSON.stringify(t)}),delete:e=>n(`/users/${e}`,{method:`DELETE`}),invite:e=>n(`/users/invite`,{method:`POST`,body:JSON.stringify(e)})},roles:{list:()=>n(`/roles`),get:e=>n(`/roles/${e}`),create:e=>n(`/roles`,{method:`POST`,body:JSON.stringify(e)}),update:(e,t)=>n(`/roles/${e}`,{method:`PUT`,body:JSON.stringify(t)}),delete:e=>n(`/roles/${e}`,{method:`DELETE`})},auth:{me:()=>n(`/me`)},gateway:{getConfig:(e=!1)=>n(`/settings/gateway${e?`?reveal=true`:``}`),updateConfig:e=>n(`/settings/gateway`,{method:`PUT`,body:JSON.stringify(e)}),getStatus:()=>n(`/settings/gateway/status`),restart:()=>n(`/settings/gateway/restart`,{method:`POST`})}};export{a as n,o as t};
@@ -0,0 +1 @@
1
+ import{F as e}from"./src-CaF63bXY.js";var t=e(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]);export{t};
@@ -0,0 +1 @@
1
+ import{F as e}from"./src-CaF63bXY.js";var t=e(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]);export{t};
@@ -0,0 +1 @@
1
+ import{n as e}from"./index-DWNLSHpo.js";export{e as authClient};
@@ -0,0 +1,4 @@
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{h as t,l as n,t as r,u as i}from"./vendor-react-BJ8SIkmN.js";import{r as a,t as o}from"./useQuery-DvovkaPT.js";import{t as s}from"./api-DNWoqIPN.js";import{t as c}from"./sse-url-qohTy4Sw.js";import{A as l,D as u,F as d,K as f,N as p,T as m,U as h,V as g,f as _,j as v}from"./src-CaF63bXY.js";import{t as y}from"./arrow-down-upU5tcpi.js";import{n as ee,t as b}from"./chat-message-CW-HnO3f.js";import{n as x,t as S}from"./file-tree-CTe61XCg.js";import{t as C}from"./save-BXEZF80P.js";import"./utils-D1nRmcA6.js";import{A as w,G as T,H as te,T as ne,U as E,V as D,_ as O,t as k,u as A,w as j,z as M}from"./index-DWNLSHpo.js";import{n as N,t as P}from"./code-editor-I6vK5q_W.js";import{t as F}from"./chat-input-CKAtAtgG.js";var I=d(`code-xml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),L=d(`git-compare`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`path`,{d:`M11 18H8a2 2 0 0 1-2-2V9`,key:`19pyzm`}]]),R=d(`radio`,[[`path`,{d:`M16.247 7.761a6 6 0 0 1 0 8.478`,key:`1fwjs5`}],[`path`,{d:`M19.075 4.933a10 10 0 0 1 0 14.134`,key:`ehdyv1`}],[`path`,{d:`M4.925 19.067a10 10 0 0 1 0-14.134`,key:`1q22gi`}],[`path`,{d:`M7.753 16.239a6 6 0 0 1 0-8.478`,key:`r2q7qm`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),z=e(t(),1);function B(e,t,n,r,i){let a=(0,z.useRef)(i);(0,z.useEffect)(()=>{a.current=i});let o=(0,z.useRef)(r);(0,z.useEffect)(()=>{o.current=r},[r]);let[s,l]=(0,z.useState)(!1),u=(0,z.useRef)(null),d=n&&e&&t?`${e}/${t}`:null;return(0,z.useEffect)(()=>{if(!d){u.current&&=(u.current.close(),null);return}let[e,t]=d.split(`/`),n=`/api/chat/${e}/${t}/watch?knownCount=${o.current}`,r=new EventSource(c(n));return u.current=r,r.addEventListener(`new-message`,e=>{try{let t=JSON.parse(e.data);a.current(t)}catch{}}),r.addEventListener(`watch-status`,e=>{try{let{active:t}=JSON.parse(e.data);l(t)}catch{}}),r.onerror=()=>{l(!1)},()=>{r.close(),u.current=null,l(!1)}},[d]),{isActive:s}}var V=r();function H({ops:e}){return e.length===0?(0,V.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:`No change operations found in transcript`}):(0,V.jsx)(`div`,{className:`h-full overflow-auto font-mono text-[13px] leading-5 bg-[#1e1e2e] p-0`,children:e.map((e,t)=>(0,V.jsxs)(`div`,{className:`border-b border-white/5`,children:[(0,V.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-2 px-4 py-1.5 bg-blue-500/10 text-blue-400 text-[11px] font-medium`,children:[(0,V.jsx)(`span`,{className:`uppercase`,children:e.tool}),(0,V.jsxs)(`span`,{className:`text-blue-400/50`,children:[`#`,t+1]})]}),e.tool===`Write`||e.tool===`write_to_file`?(0,V.jsx)(`div`,{children:(e.content??``).split(`
2
+ `).map((e,t)=>(0,V.jsxs)(`div`,{className:`flex`,children:[(0,V.jsx)(`span`,{className:`w-12 shrink-0 text-right pr-3 select-none text-green-400/40 bg-green-500/5`,children:t+1}),(0,V.jsxs)(`span`,{className:`flex-1 px-3 whitespace-pre bg-green-500/10 text-green-300`,children:[(0,V.jsx)(`span`,{className:`select-none text-green-400/50 mr-2`,children:`+`}),e||`\xA0`]})]},t))}):(0,V.jsxs)(`div`,{children:[(e.oldString??``).split(`
3
+ `).map((e,t)=>(0,V.jsxs)(`div`,{className:`flex`,children:[(0,V.jsx)(`span`,{className:`w-12 shrink-0 text-right pr-3 select-none text-red-400/40 bg-red-500/5`,children:t+1}),(0,V.jsxs)(`span`,{className:`flex-1 px-3 whitespace-pre bg-red-500/10 text-red-300`,children:[(0,V.jsx)(`span`,{className:`select-none text-red-400/50 mr-2`,children:`-`}),e||`\xA0`]})]},`r-${t}`)),(e.newString??``).split(`
4
+ `).map((e,t)=>(0,V.jsxs)(`div`,{className:`flex`,children:[(0,V.jsx)(`span`,{className:`w-12 shrink-0 text-right pr-3 select-none text-green-400/40 bg-green-500/5`,children:t+1}),(0,V.jsxs)(`span`,{className:`flex-1 px-3 whitespace-pre bg-green-500/10 text-green-300`,children:[(0,V.jsx)(`span`,{className:`select-none text-green-400/50 mr-2`,children:`+`}),e||`\xA0`]})]},`a-${t}`))]})]},t))})}function re({open:e,onOpenChange:t,workspacePath:n,modifiedFiles:r,projectHash:i,sessionId:a}){let{t:c}=ne(),d=r.length>0,[p,h]=(0,z.useState)(d),[y,b]=(0,z.useState)([]),[w,T]=(0,z.useState)(null),[te,E]=(0,z.useState)(!1),[D,O]=(0,z.useState)(`diff`),A=y.find(e=>e.path===w)??null,j=(0,z.useRef)(new Set),F=(0,z.useRef)(y);F.current=y;let I=w?r.find(e=>(e.path.startsWith(`/`)?e.path:`${n}/${e.path}`)===w):null,R=!!I,{data:B,isLoading:re}=o({queryKey:[`file-changes`,i,a,I?.path],queryFn:()=>s.chat.getFileChanges(i,a,I.path),enabled:!!I&&D===`diff`,staleTime:6e4}),U=(0,z.useCallback)(async e=>{if(F.current.some(t=>t.path===e)){T(e);return}if(!j.current.has(e)){j.current.add(e);try{let t=await s.fs.readFile(e),n=e.split(`/`).pop()??e;b(r=>r.some(t=>t.path===e)?r:[...r,{path:e,name:n,content:t.content,dirty:!1,etag:t.etag}]),T(e)}catch{k.error(c(`fileEditor.failedToOpen`))}finally{j.current.delete(e)}}},[c]),ie=(0,z.useCallback)((e,t)=>{t?.stopPropagation();let n=y.find(t=>t.path===e);if(!(n?.dirty&&!confirm(c(`fileEditor.unsavedChanges`,{name:n.name})))&&(b(t=>t.filter(t=>t.path!==e)),w===e)){let t=y.filter(t=>t.path!==e);T(t.length>0?t[t.length-1].path:null)}},[y,w,c]),W=(0,z.useCallback)((e,t)=>{b(n=>n.map(n=>n.path===e?{...n,content:t,dirty:!0}:n))},[]),G=(0,z.useCallback)(async()=>{if(!(!A||!A.dirty)){E(!0);try{let e=await s.fs.writeFile(A.path,A.content);b(t=>t.map(t=>t.path===A.path?{...t,dirty:!1,etag:e.etag}:t)),k.success(c(`common.saved`))}catch{k.error(c(`common.failedToSave`))}finally{E(!1)}}},[A,c]),K=e=>e.startsWith(n+`/`)?e.slice(n.length+1):e,ae=D===`diff`&&R&&B&&B.length>0,oe=re&&D===`diff`&&R,q=D===`diff`&&R&&B&&B.length===0,J;return A?ae?J=(0,V.jsx)(H,{ops:B}):oe?J=(0,V.jsxs)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm gap-2`,children:[(0,V.jsx)(M,{className:`h-4 w-4 animate-spin`}),`Loading changes...`]}):q?J=(0,V.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:`No change operations found in transcript`}):A&&(J=(0,V.jsx)(P,{value:A.content,onChange:e=>W(A.path,e),language:N(A.name),onSave:G,minHeight:`100%`,className:`h-full border-0 rounded-none [&_.cm-editor]:h-full [&_.cm-scroller]:!overflow-auto`})):J=(0,V.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:p&&d?`Select a modified file to view`:`Select a file to edit`}),(0,V.jsx)(m,{open:e,onOpenChange:t,children:(0,V.jsxs)(u,{showCloseButton:!1,className:`!max-w-[96vw] !w-[96vw] !h-[94vh] !max-h-[94vh] !p-0 flex flex-col overflow-hidden !translate-x-0 !translate-y-0 !top-[3vh] !left-[2vw] !gap-0`,children:[(0,V.jsx)(l,{className:`sr-only`,children:`Workspace Editor`}),(0,V.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2.5 border-b shrink-0`,children:[(0,V.jsx)(ee,{className:`h-4 w-4 text-muted-foreground`}),(0,V.jsx)(`h2`,{className:`text-sm font-medium truncate flex-1`,children:n.split(`/`).pop()}),R&&(0,V.jsxs)(`div`,{className:`flex items-center gap-1 border rounded-md overflow-hidden text-xs`,children:[(0,V.jsxs)(`button`,{className:f(`px-2 py-1 transition-colors`,D===`diff`?`bg-primary text-primary-foreground`:`hover:bg-muted`),onClick:()=>O(`diff`),children:[(0,V.jsx)(L,{className:`h-3 w-3 inline mr-1`}),`Changes`]}),(0,V.jsx)(`button`,{className:f(`px-2 py-1 transition-colors`,D===`edit`?`bg-primary text-primary-foreground`:`hover:bg-muted`),onClick:()=>O(`edit`),children:`Edit`})]}),d&&(0,V.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,V.jsx)(`span`,{children:`Modified only`}),(0,V.jsx)(_,{checked:p,onCheckedChange:h,size:`sm`})]}),(0,V.jsx)(g,{variant:`ghost`,size:`icon-sm`,onClick:()=>t(!1),children:(0,V.jsx)(v,{className:`h-4 w-4`})})]}),(0,V.jsxs)(`div`,{className:`flex flex-1 min-h-0`,children:[(0,V.jsx)(`div`,{className:`w-60 shrink-0 border-r flex flex-col bg-muted/30 overflow-hidden`,children:p&&d?(0,V.jsxs)(`div`,{className:`flex-1 overflow-auto py-1`,children:[(0,V.jsxs)(`div`,{className:`px-2 py-1 text-[11px] font-medium text-muted-foreground uppercase tracking-wider`,children:[`Modified files (`,r.length,`)`]}),r.map(e=>{let t=e.path.startsWith(`/`)?e.path:`${n}/${e.path}`,r=e.path.split(`/`).pop()??e.path;return(0,V.jsxs)(`button`,{className:f(`w-full flex items-center gap-2 px-3 py-1.5 text-left text-[13px] hover:bg-muted/80 transition-colors`,w===t&&`bg-accent text-accent-foreground`),onClick:()=>U(t),title:`${e.path} (${e.tool} ×${e.count})`,children:[(0,V.jsx)(x,{className:`h-3.5 w-3.5 shrink-0 text-orange-400`}),(0,V.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,V.jsx)(`span`,{className:`truncate font-mono text-[12px]`,children:r}),(0,V.jsx)(`span`,{className:`truncate text-[11px] text-muted-foreground`,children:e.path.includes(`/`)?e.path.split(`/`).slice(0,-1).join(`/`):``})]}),e.count>1&&(0,V.jsxs)(`span`,{className:`text-[10px] text-muted-foreground shrink-0`,children:[`×`,e.count]})]},e.path)})]}):(0,V.jsx)(`div`,{className:`flex-1 overflow-auto py-1`,children:(0,V.jsx)(S,{rootPath:n,selectedFile:w,onSelectFile:U})})}),(0,V.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0`,children:[y.length>0&&(0,V.jsxs)(`div`,{className:`flex items-center border-b bg-muted/20 overflow-x-auto shrink-0`,children:[y.map(e=>{let t=r.some(t=>(t.path.startsWith(`/`)?t.path:`${n}/${t.path}`)===e.path);return(0,V.jsxs)(`button`,{className:f(`flex items-center gap-1.5 px-3 py-1.5 text-xs border-r shrink-0 transition-colors`,e.path===w?`bg-background text-foreground`:`text-muted-foreground hover:bg-muted/50`),onClick:()=>T(e.path),title:K(e.path),children:[t&&(0,V.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-orange-400 shrink-0`}),(0,V.jsxs)(`span`,{className:f(`truncate max-w-40`,e.dirty&&`italic`),children:[e.dirty&&`* `,e.name]}),(0,V.jsx)(v,{className:`h-3 w-3 shrink-0 opacity-50 hover:opacity-100`,onClick:t=>ie(e.path,t)})]},e.path)}),A?.dirty&&(0,V.jsxs)(`button`,{className:`flex items-center gap-1 px-2 py-1.5 text-xs text-muted-foreground hover:text-foreground ml-auto shrink-0`,onClick:G,disabled:te,children:[te?(0,V.jsx)(M,{className:`h-3 w-3 animate-spin`}):(0,V.jsx)(C,{className:`h-3 w-3`}),(0,V.jsx)(`kbd`,{className:`text-[10px] text-muted-foreground ml-1`,children:navigator.platform.includes(`Mac`)?`⌘S`:`Ctrl+S`})]})]}),(0,V.jsx)(`div`,{className:`flex-1 min-h-0`,children:J})]})]})]})})}function U(e){let t=e.toLowerCase();return t.includes(`opus`)||t.includes(`sonnet`)||t.includes(`haiku`)?2e5:t.includes(`gpt-4o`)||t.includes(`gpt-4`)?128e3:t.includes(`gpt-3.5`)?16385:t.includes(`gemini`)?1e6:2e5}function ie(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.role===`assistant`&&n.usage){let e=U(n.model??`claude`);return{percent:n.usage.inputTokens/e*100,inputTokens:n.usage.inputTokens,maxTokens:e,model:n.model}}}return null}function W(e,t,n,r,i){t&&(n>0||r>0)&&e.set(t,{inputTokens:n,outputTokens:r,models:i})}function G(e){let t=new Map,n=0,r=0,i=[],a=null;for(let o=0;o<e.length;o++){let s=e[o];s.role===`assistant`?(s.usage&&(n+=s.usage.inputTokens,r+=s.usage.outputTokens),s.model&&!i.includes(s.model)&&i.push(s.model),a=s.id):(W(t,a,n,r,i),n=0,r=0,i=[],a=null)}return W(t,a,n,r,i),t}function K(){let{t:e}=ne(),{projectHash:t,sessionId:r}=i(),c=n(),l=a(),[u,d]=(0,z.useState)([]),f=j(e=>e.markSeen);(0,z.useEffect)(()=>{t&&r&&f(t,r)},[t,r,f]);let{streamingContent:m,streamingThinking:_,streamingToolCalls:v,isStreaming:x,error:S,streamId:C,startStream:k,stopStream:M,consumeStream:N}=O(t&&r?`${t}/${r}`:void 0),P=(0,z.useRef)(null),L=(0,z.useRef)(null),[H,U]=(0,z.useState)(!0),W=(0,z.useCallback)(()=>{P.current?.scrollIntoView({behavior:`smooth`})},[]),K=(0,z.useCallback)(()=>{let e=L.current;e&&U(e.scrollHeight-e.scrollTop-e.clientHeight<100)},[]),ae=(0,z.useCallback)(e=>{d(t=>{let n=t[t.length-1];return n&&n.role===e.role&&n.content===e.content?t:[...t,e]}),setTimeout(W,0)},[W]),{data:oe}=o({queryKey:[`chat-sessions`,t],queryFn:()=>s.chat.getSessions(t,{page:1,pageSize:100}),enabled:!!t}),q=oe?.data??[],{data:J,isLoading:Y}=o({queryKey:[`chat-messages`,t,r],queryFn:()=>s.chat.getMessages(t,r),enabled:!!t&&!!r});(0,z.useEffect)(()=>{J&&d(J.messages)},[J]),(0,z.useEffect)(()=>{!Y&&u.length>0&&P.current?.scrollIntoView()},[Y]),(0,z.useEffect)(()=>{m&&H&&W()},[m,W,H]);let{data:X=[]}=o({queryKey:[`modified-files`,t,r],queryFn:()=>s.chat.getModifiedFiles(t,r),enabled:!!t&&!!r}),[se,ce]=(0,z.useState)(!1),[le,ue]=(0,z.useState)(!1),Z=q.find(e=>e.sessionId===r),Q=Z?.source===`ide`,$=Z?.workspacePath,{data:de}=o({queryKey:[`git-branch`,$],queryFn:()=>s.chat.getGitBranches([$]),enabled:!!$,staleTime:3e4}),fe=$?de?.[$]:null,pe=(0,z.useMemo)(()=>ie(u),[u]),me=(0,z.useMemo)(()=>{let e=[],t={user:null,replies:[]};for(let n of u)n.role===`user`?((t.user||t.replies.length>0)&&e.push(t),t={user:n,replies:[]}):t.replies.push(n);return(t.user||t.replies.length>0)&&e.push(t),e},[u]),he=(0,z.useMemo)(()=>G(u),[u]),{isActive:ge}=B(t,r,Q??!1,u.length,ae);return(0,z.useEffect)(()=>{if(!x&&(m||v.length>0)&&t&&r){let e=N();e&&(e.content||e.toolCalls.length>0)&&d(t=>[...t,{id:`stream-${Date.now()}`,role:`assistant`,content:e.content,thinking:e.thinking||void 0,toolCalls:e.toolCalls.map(e=>({id:e.id,name:e.name,input:e.input,output:e.output}))}])}},[x,m,v,t,r,N]),(0,V.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,V.jsxs)(`div`,{className:`border-b px-4 py-2 shrink-0 space-y-1.5`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(g,{variant:`ghost`,size:`sm`,onClick:()=>c(`/chat/${t}`),children:`← Back`}),(0,V.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,V.jsx)(`h1`,{className:`text-sm font-medium truncate`,children:Z?.name??r})}),Z&&(0,V.jsx)(h,{variant:`secondary`,children:Z.mode}),ge&&(0,V.jsxs)(h,{variant:`outline`,className:`gap-1 text-green-500 border-green-500/30`,children:[(0,V.jsx)(R,{className:`h-3 w-3 animate-pulse`}),`Live`]})]}),$&&(0,V.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground truncate`,children:[(0,V.jsx)(te,{className:`h-3 w-3 shrink-0`}),(0,V.jsx)(`span`,{className:`truncate`,title:$,children:Z?.workspaceName??$.split(`/`).pop()}),fe&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,V.jsx)(D,{className:`h-3 w-3 shrink-0`}),(0,V.jsx)(`span`,{className:`truncate font-mono`,title:fe,children:fe})]})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[q.length>1&&(0,V.jsx)(`select`,{className:`text-xs border rounded px-1.5 py-0.5 bg-background max-w-[200px] truncate`,value:r,onChange:e=>c(`/chat/${t}/${e.target.value}`,{replace:!0}),children:q.map(e=>(0,V.jsxs)(`option`,{value:e.sessionId,children:[e.name,` (`,new Date(e.createdAt).toLocaleDateString(),`)`]},e.sessionId))}),(0,V.jsx)(`div`,{className:`flex-1`}),$&&(0,V.jsxs)(g,{variant:`outline`,size:`sm`,onClick:()=>ue(!0),className:`gap-1.5 text-xs`,title:e(`chat.openWorkspaceEditor`),children:[(0,V.jsx)(I,{className:`h-3 w-3`}),`Editor`]}),Q&&Z?.workspacePath&&(0,V.jsxs)(g,{variant:`outline`,size:`sm`,onClick:()=>window.open(`cursor://file/${Z.workspacePath}`,`_blank`),className:`gap-1.5 text-xs text-blue-500 border-blue-500/30 hover:bg-blue-500/10 hover:text-blue-600`,title:e(`chat.openInCursor`),children:[(0,V.jsx)(E,{className:`h-3 w-3`}),`Cursor`]}),(0,V.jsx)(g,{variant:`ghost`,size:`sm`,onClick:async()=>{!t||!r||confirm(e(`chat.deleteConfirm`))&&(await s.chat.deleteSession(t,r),l.invalidateQueries({queryKey:[`chat-sessions`,t]}),c(`/chat/${t}`))},className:`text-muted-foreground hover:text-destructive`,title:e(`common.deleteSession`),children:(0,V.jsx)(w,{className:`h-4 w-4`})})]}),X.length>0&&(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`button`,{onClick:()=>ce(e=>!e),className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[se?(0,V.jsx)(p,{className:`h-3 w-3`}):(0,V.jsx)(T,{className:`h-3 w-3`}),(0,V.jsx)(ee,{className:`h-3 w-3`}),X.length,` modified file`,X.length>1?`s`:``]}),se&&(0,V.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:X.map(e=>(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] bg-muted px-1.5 py-0.5 rounded font-mono truncate max-w-[300px]`,title:`${e.path} (${e.tool} ×${e.count})`,children:[e.path.split(`/`).pop(),e.count>1&&(0,V.jsxs)(`span`,{className:`text-muted-foreground`,children:[`×`,e.count]})]},e.path))})]})]}),(0,V.jsx)(`div`,{className:`relative flex-1 overflow-y-auto min-h-0`,ref:L,onScroll:K,children:(0,V.jsxs)(`div`,{className:`p-3`,children:[Y&&(0,V.jsx)(`div`,{className:`flex flex-col gap-1`,children:(0,V.jsx)(A,{count:5})}),!Y&&u.length===0&&(0,V.jsx)(`div`,{className:`text-center text-muted-foreground py-12`,children:e(`chat.noMessages`)}),!Y&&u.length>0&&me.map((e,t)=>(0,V.jsxs)(`div`,{children:[e.user&&(0,V.jsx)(`div`,{className:`sticky top-0 z-10 py-1`,children:(0,V.jsx)(b,{role:e.user.role,content:e.user.content,compact:!0})}),(0,V.jsx)(`div`,{className:`flex flex-col gap-1 pt-1`,children:e.replies.map(e=>(0,V.jsx)(b,{role:e.role,content:e.content,thinking:e.thinking,toolCalls:e.toolCalls,aggregatedUsage:he.get(e.id)},e.id))})]},e.user?.id??`group-${t}`)),x&&(m||_||v.length>0)&&(0,V.jsx)(b,{role:`assistant`,content:m,thinking:_,toolCalls:v.map(e=>({id:e.id,name:e.name,input:e.input,output:e.pending?void 0:e.output}))}),x&&!m&&!_&&v.length===0&&(0,V.jsx)(`div`,{className:`flex justify-start`,children:(0,V.jsx)(`div`,{className:`bg-muted rounded-lg px-4 py-2 text-sm text-muted-foreground`,children:e(`common.thinking`)})}),S&&(0,V.jsx)(`div`,{className:`text-center text-destructive text-sm`,children:S}),(0,V.jsx)(`div`,{ref:P})]})}),!H&&(0,V.jsx)(`div`,{className:`pointer-events-none flex justify-end px-4 -mt-12 mb-1 relative z-10`,children:(0,V.jsx)(g,{variant:`secondary`,size:`icon`,className:`pointer-events-auto rounded-full shadow-lg h-8 w-8 opacity-80 hover:opacity-100 transition-opacity`,onClick:W,children:(0,V.jsx)(y,{className:`h-4 w-4`})})}),(0,V.jsxs)(`div`,{className:`shrink-0`,children:[Q&&!x&&(0,V.jsx)(`div`,{className:`border-t px-3 py-1.5 text-xs text-muted-foreground bg-muted/50`,children:e(ge?`chat.watchingLive`:`chat.resumeSession`)}),(0,V.jsx)(F,{onSend:async n=>{if(!(!t||!r)){d(e=>[...e,{id:`temp-${Date.now()}`,role:`user`,content:n}]),setTimeout(W,0);try{let{streamId:e}=Q?await s.chat.resumeSession(t,r,n):await s.chat.sendMessage(t,r,n);k(e)}catch(t){d(n=>[...n,{id:`error-${Date.now()}`,role:`assistant`,content:`Error: ${t instanceof Error?t.message:e(`chat.failedToSend`)}`}])}}},onStop:()=>{C&&s.chat.stopStream(C).catch(()=>{}),M()},isStreaming:x,disabled:Y,workspacePath:Z?.workspacePath,contextUsage:pe})]}),$&&(0,V.jsx)(re,{open:le,onOpenChange:ue,workspacePath:$,modifiedFiles:X,projectHash:t,sessionId:r})]})}export{K as Chat};
@@ -1,2 +1,2 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{h as t,t as n}from"./vendor-react-BJ8SIkmN.js";import{K as r,V as i,q as a,t as o}from"./src-DUhGoAQb.js";import"./utils-DHTPP40O.js";import{w as s}from"./index-dc8HGqTp.js";var c=e(t(),1),l=n();function u(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function d({onSend:e,onStop:t,isStreaming:n,disabled:d,workspacePath:f,contextUsage:p}){let{t:m}=s(),[h,g]=(0,c.useState)(``),[_,v]=(0,c.useState)([]),[y,b]=(0,c.useState)([]),[x,S]=(0,c.useState)(!1),[C,w]=(0,c.useState)(0),T=(0,c.useRef)(null),E=(0,c.useRef)(null);(0,c.useEffect)(()=>{a.chat.getCommands(f).then(v).catch(()=>{})},[f]);let D=()=>{let t=h.trim();!t||d||(e(t),g(``),S(!1))},O=(0,c.useCallback)(e=>{g(e.name+` `),S(!1),E.current?.focus()},[]),k=e=>{if(g(e),e.startsWith(`/`)&&!e.includes(`
2
- `)){let t=e.toLowerCase(),n=_.filter(e=>e.enabled&&e.name.toLowerCase().includes(t));b(n.slice(0,12)),w(0),S(n.length>0)}else S(!1)},A=e=>{if(x){if(e.key===`ArrowDown`){e.preventDefault(),w(e=>Math.min(e+1,y.length-1));return}if(e.key===`ArrowUp`){e.preventDefault(),w(e=>Math.max(e-1,0));return}if((e.key===`Tab`||e.key===`Enter`&&!e.shiftKey)&&y[C]){e.preventDefault(),O(y[C]);return}if(e.key===`Escape`){e.preventDefault(),S(!1);return}}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),D())};(0,c.useEffect)(()=>{!x||!T.current||T.current.children[C]?.scrollIntoView({block:`nearest`})},[C,x]);let j;return p&&(j=p.percent>90?`bg-destructive`:p.percent>70?`bg-yellow-500`:`bg-primary`),(0,l.jsxs)(`div`,{className:`border-t bg-background p-4 relative`,children:[x&&(0,l.jsx)(`div`,{ref:T,className:`absolute bottom-full left-4 right-4 mb-1 max-h-64 overflow-y-auto rounded-lg border bg-popover shadow-lg z-50`,children:y.map((e,t)=>(0,l.jsxs)(`button`,{className:r(`flex w-full items-start gap-3 px-3 py-2 text-left text-sm transition-colors hover:bg-accent`,t===C&&`bg-accent`),onMouseDown:t=>{t.preventDefault(),O(e)},onMouseEnter:()=>w(t),children:[(0,l.jsx)(`span`,{className:`font-mono font-medium text-primary shrink-0`,children:e.name}),(0,l.jsx)(`span`,{className:`text-muted-foreground text-xs truncate`,children:e.description})]},e.name))}),(0,l.jsxs)(`div`,{className:`flex gap-2`,children:[(0,l.jsx)(o,{ref:E,value:h,onChange:e=>k(e.target.value),onKeyDown:A,onBlur:()=>{setTimeout(()=>S(!1),150)},placeholder:m(`chatInput.placeholder`),className:`min-h-[44px] max-h-[200px] resize-none`,disabled:n||d,rows:1}),n?(0,l.jsx)(i,{variant:`destructive`,onClick:t,className:`shrink-0`,children:`Stop`}):(0,l.jsx)(i,{onClick:D,disabled:!h.trim()||d,className:`shrink-0`,children:`Send`})]}),p&&(0,l.jsxs)(`div`,{className:`mt-2 flex items-center gap-2 text-[11px] text-muted-foreground`,children:[(0,l.jsx)(`span`,{className:`shrink-0`,children:`Context`}),(0,l.jsx)(`div`,{className:`flex-1 h-1.5 rounded-full bg-muted overflow-hidden`,children:(0,l.jsx)(`div`,{className:r(`h-full rounded-full transition-all`,j),style:{width:`${Math.min(p.percent,100)}%`}})}),(0,l.jsxs)(`span`,{className:`shrink-0 font-mono tabular-nums`,children:[p.percent.toFixed(0),`%`]}),(0,l.jsxs)(`span`,{className:`shrink-0 text-muted-foreground/60`,children:[`(`,u(p.inputTokens),` / `,u(p.maxTokens),`)`]})]})]})}export{d as t};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{h as t,t as n}from"./vendor-react-BJ8SIkmN.js";import{t as r}from"./api-DNWoqIPN.js";import{K as i,V as a,t as o}from"./src-CaF63bXY.js";import"./utils-D1nRmcA6.js";import{T as s}from"./index-DWNLSHpo.js";var c=e(t(),1),l=n();function u(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function d({onSend:e,onStop:t,isStreaming:n,disabled:d,workspacePath:f,contextUsage:p}){let{t:m}=s(),[h,g]=(0,c.useState)(``),[_,v]=(0,c.useState)([]),[y,b]=(0,c.useState)([]),[x,S]=(0,c.useState)(!1),[C,w]=(0,c.useState)(0),T=(0,c.useRef)(null),E=(0,c.useRef)(null);(0,c.useEffect)(()=>{r.chat.getCommands(f).then(v).catch(()=>{})},[f]);let D=()=>{let t=h.trim();!t||d||(e(t),g(``),S(!1))},O=(0,c.useCallback)(e=>{g(e.name+` `),S(!1),E.current?.focus()},[]),k=e=>{if(g(e),e.startsWith(`/`)&&!e.includes(`
2
+ `)){let t=e.toLowerCase(),n=_.filter(e=>e.enabled&&e.name.toLowerCase().includes(t));b(n.slice(0,12)),w(0),S(n.length>0)}else S(!1)},A=e=>{if(x){if(e.key===`ArrowDown`){e.preventDefault(),w(e=>Math.min(e+1,y.length-1));return}if(e.key===`ArrowUp`){e.preventDefault(),w(e=>Math.max(e-1,0));return}if((e.key===`Tab`||e.key===`Enter`&&!e.shiftKey)&&y[C]){e.preventDefault(),O(y[C]);return}if(e.key===`Escape`){e.preventDefault(),S(!1);return}}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),D())};(0,c.useEffect)(()=>{!x||!T.current||T.current.children[C]?.scrollIntoView({block:`nearest`})},[C,x]);let j;return p&&(j=p.percent>90?`bg-destructive`:p.percent>70?`bg-yellow-500`:`bg-primary`),(0,l.jsxs)(`div`,{className:`border-t bg-background p-4 relative`,children:[x&&(0,l.jsx)(`div`,{ref:T,className:`absolute bottom-full left-4 right-4 mb-1 max-h-64 overflow-y-auto rounded-lg border bg-popover shadow-lg z-50`,children:y.map((e,t)=>(0,l.jsxs)(`button`,{className:i(`flex w-full items-start gap-3 px-3 py-2 text-left text-sm transition-colors hover:bg-accent`,t===C&&`bg-accent`),onMouseDown:t=>{t.preventDefault(),O(e)},onMouseEnter:()=>w(t),children:[(0,l.jsx)(`span`,{className:`font-mono font-medium text-primary shrink-0`,children:e.name}),(0,l.jsx)(`span`,{className:`text-muted-foreground text-xs truncate`,children:e.description})]},e.name))}),(0,l.jsxs)(`div`,{className:`flex gap-2`,children:[(0,l.jsx)(o,{ref:E,value:h,onChange:e=>k(e.target.value),onKeyDown:A,onBlur:()=>{setTimeout(()=>S(!1),150)},placeholder:m(`chatInput.placeholder`),className:`min-h-[44px] max-h-[200px] resize-none`,disabled:n||d,rows:1}),n?(0,l.jsx)(a,{variant:`destructive`,onClick:t,className:`shrink-0`,children:`Stop`}):(0,l.jsx)(a,{onClick:D,disabled:!h.trim()||d,className:`shrink-0`,children:`Send`})]}),p&&(0,l.jsxs)(`div`,{className:`mt-2 flex items-center gap-2 text-[11px] text-muted-foreground`,children:[(0,l.jsx)(`span`,{className:`shrink-0`,children:`Context`}),(0,l.jsx)(`div`,{className:`flex-1 h-1.5 rounded-full bg-muted overflow-hidden`,children:(0,l.jsx)(`div`,{className:i(`h-full rounded-full transition-all`,j),style:{width:`${Math.min(p.percent,100)}%`}})}),(0,l.jsxs)(`span`,{className:`shrink-0 font-mono tabular-nums`,children:[p.percent.toFixed(0),`%`]}),(0,l.jsxs)(`span`,{className:`shrink-0 text-muted-foreground/60`,children:[`(`,u(p.inputTokens),` / `,u(p.maxTokens),`)`]})]})]})}export{d as t};