@openork/cli 0.1.0

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 (122) hide show
  1. package/bin/dev.js +3 -0
  2. package/bin/run.js +3 -0
  3. package/dist/commands/gateway/start.d.ts +14 -0
  4. package/dist/commands/gateway/start.d.ts.map +1 -0
  5. package/dist/commands/gateway/start.js +120 -0
  6. package/dist/commands/gateway/start.js.map +1 -0
  7. package/dist/commands/gateway/stop.d.ts +7 -0
  8. package/dist/commands/gateway/stop.d.ts.map +1 -0
  9. package/dist/commands/gateway/stop.js +33 -0
  10. package/dist/commands/gateway/stop.js.map +1 -0
  11. package/dist/commands/setup.d.ts +7 -0
  12. package/dist/commands/setup.d.ts.map +1 -0
  13. package/dist/commands/setup.js +86 -0
  14. package/dist/commands/setup.js.map +1 -0
  15. package/dist/commands/setup.spec.d.ts +2 -0
  16. package/dist/commands/setup.spec.d.ts.map +1 -0
  17. package/dist/commands/setup.spec.js +88 -0
  18. package/dist/commands/setup.spec.js.map +1 -0
  19. package/dist/commands/uninstall.d.ts +10 -0
  20. package/dist/commands/uninstall.d.ts.map +1 -0
  21. package/dist/commands/uninstall.js +71 -0
  22. package/dist/commands/uninstall.js.map +1 -0
  23. package/dist/index.d.ts +2 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +2 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/lib/gateway.d.ts +19 -0
  28. package/dist/lib/gateway.d.ts.map +1 -0
  29. package/dist/lib/gateway.js +52 -0
  30. package/dist/lib/gateway.js.map +1 -0
  31. package/dist/lib/shell-profile.d.ts +10 -0
  32. package/dist/lib/shell-profile.d.ts.map +1 -0
  33. package/dist/lib/shell-profile.js +56 -0
  34. package/dist/lib/shell-profile.js.map +1 -0
  35. package/dist/migrations/0001-add-memory-enabled.js +42 -0
  36. package/dist/migrations/lib/helpers.js +78 -0
  37. package/dist/migrations/lib/template.js +8 -0
  38. package/dist/openapi.yml +5648 -0
  39. package/dist/prisma/migrations/20260318152538_add_trigger_type_and_source_workflow/migration.sql +79 -0
  40. package/dist/prisma/migrations/20260318154232_drop_skill_and_emit_from_action/migration.sql +25 -0
  41. package/dist/prisma/migrations/20260318160029_action_types_cli_bash_node_http/migration.sql +29 -0
  42. package/dist/prisma/migrations/migration_lock.toml +3 -0
  43. package/dist/prisma/schema.prisma +236 -0
  44. package/dist/server.js +182527 -0
  45. package/dist/server.js.map +1 -0
  46. package/dist/web/assets/activity-feed-D_eonDKG.js +1 -0
  47. package/dist/web/assets/agent-edit-CblZItU5.js +98 -0
  48. package/dist/web/assets/agent-sessions-COpCcffa.js +1 -0
  49. package/dist/web/assets/agent-use-F4pOt3KJ.js +1 -0
  50. package/dist/web/assets/agents-Av7w2wHE.js +1 -0
  51. package/dist/web/assets/api-docs-BQzn4-6U.js +1 -0
  52. package/dist/web/assets/arrow-down-XHN5PD1k.js +1 -0
  53. package/dist/web/assets/arrow-left-wtNmm6Le.js +1 -0
  54. package/dist/web/assets/bi-gM8sIAZV.js +1 -0
  55. package/dist/web/assets/chat-CQvfLy7Y.js +4 -0
  56. package/dist/web/assets/chat-input-BepRPV_L.js +2 -0
  57. package/dist/web/assets/chat-message-CbcDeDcb.js +37 -0
  58. package/dist/web/assets/chat-new-BOtDuYij.js +1 -0
  59. package/dist/web/assets/chat-sessions-CaCaK_PC.js +1 -0
  60. package/dist/web/assets/chats-64IReeGV.js +1 -0
  61. package/dist/web/assets/circle-alert-W8QX9LOG.js +1 -0
  62. package/dist/web/assets/circle-check-DLl9fl65.js +1 -0
  63. package/dist/web/assets/circle-x-D_8Tcgt1.js +1 -0
  64. package/dist/web/assets/code-Brz4KHlI.js +1 -0
  65. package/dist/web/assets/code-editor-x9L6nkh4.js +1 -0
  66. package/dist/web/assets/commands-DT9K8bae.js +8 -0
  67. package/dist/web/assets/copy-C87mjn_Y.js +1 -0
  68. package/dist/web/assets/credentials-DC-HOVxW.js +1 -0
  69. package/dist/web/assets/cron-COUPKvGu.js +1 -0
  70. package/dist/web/assets/crown-BJEsQkh4.js +1 -0
  71. package/dist/web/assets/dashboard-OfnNUjFX.js +1 -0
  72. package/dist/web/assets/database-BohjTljV.js +1 -0
  73. package/dist/web/assets/debug-Et9rgBM8.js +1 -0
  74. package/dist/web/assets/download-B2UOiYAS.js +1 -0
  75. package/dist/web/assets/eye-DN-Km5vf.js +1 -0
  76. package/dist/web/assets/file-plus-B8qWemgt.js +1 -0
  77. package/dist/web/assets/file-tree-DkLQ1z0I.js +1 -0
  78. package/dist/web/assets/folder-plus-DsmP6Mur.js +1 -0
  79. package/dist/web/assets/geist-cyrillic-wght-normal-CHSlOQsW.woff2 +0 -0
  80. package/dist/web/assets/geist-latin-ext-wght-normal-DMtmJ5ZE.woff2 +0 -0
  81. package/dist/web/assets/geist-latin-wght-normal-Dm3htQBi.woff2 +0 -0
  82. package/dist/web/assets/globe-fwFSeXZn.js +1 -0
  83. package/dist/web/assets/grip-vertical-Djo-yR-o.js +1 -0
  84. package/dist/web/assets/history-CyBBboEp.js +1 -0
  85. package/dist/web/assets/index-YgjFlLLv.css +2 -0
  86. package/dist/web/assets/index-dc8HGqTp.js +2 -0
  87. package/dist/web/assets/layers-ephyCrDm.js +1 -0
  88. package/dist/web/assets/layout-grid-DCVGg8ZA.js +1 -0
  89. package/dist/web/assets/mcp-setup-BfMdYdsI.js +17 -0
  90. package/dist/web/assets/memory-DAQ474-p.js +1 -0
  91. package/dist/web/assets/new-chat-DtMw6FMg.js +1 -0
  92. package/dist/web/assets/play-DXJMtO-K.js +1 -0
  93. package/dist/web/assets/refresh-cw-RFYUf5GB.js +1 -0
  94. package/dist/web/assets/rolldown-runtime-Dw2cE7zH.js +1 -0
  95. package/dist/web/assets/save-Dewm93H6.js +1 -0
  96. package/dist/web/assets/search-Ww0msJQz.js +1 -0
  97. package/dist/web/assets/send-FWvygYFQ.js +1 -0
  98. package/dist/web/assets/settings-Auyn4Z5T.js +1 -0
  99. package/dist/web/assets/shield-check-Dt7sXtBF.js +1 -0
  100. package/dist/web/assets/shuffle-DjvBJ7XV.js +1 -0
  101. package/dist/web/assets/src-DUhGoAQb.js +24 -0
  102. package/dist/web/assets/team-edit-DO-RX3lC.js +1 -0
  103. package/dist/web/assets/team-sessions-DSw8MTtZ.js +1 -0
  104. package/dist/web/assets/team-use-BfNvsFcO.js +3 -0
  105. package/dist/web/assets/terminal-CIapYonS.js +1 -0
  106. package/dist/web/assets/timer-C9X20mTO.js +1 -0
  107. package/dist/web/assets/useMutation-BlOHt3MR.js +1 -0
  108. package/dist/web/assets/useQuery-DvovkaPT.js +1 -0
  109. package/dist/web/assets/utils-DHTPP40O.js +1 -0
  110. package/dist/web/assets/vendor-editor-BORFA-rZ.js +39 -0
  111. package/dist/web/assets/vendor-react-BJ8SIkmN.js +11 -0
  112. package/dist/web/assets/vendor-ui-CHpVij2M.css +1 -0
  113. package/dist/web/assets/vendor-ui-Dpw9mBc-.js +39 -0
  114. package/dist/web/assets/workflow-edit-D0FNyl64.js +4 -0
  115. package/dist/web/assets/workflow-runs-CPVvaVzN.js +1 -0
  116. package/dist/web/assets/workflows-C9jurJiE.js +1 -0
  117. package/dist/web/assets/wrench-DZBtSPP8.js +1 -0
  118. package/dist/web/assets/zap-CbT5plGA.js +1 -0
  119. package/dist/web/docs.html +242 -0
  120. package/dist/web/favicon.svg +13 -0
  121. package/dist/web/index.html +23 -0
  122. package/package.json +65 -0
@@ -0,0 +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};
@@ -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 ee,t as a}from"./useQuery-DvovkaPT.js";import{t as o}from"./useMutation-BlOHt3MR.js";import{F as s,K as c,P as l,U as u,V as d,_ as f,f as p,g as te,h as ne,j as re,m,q as h,v as g,w as _,y as ie}from"./src-DUhGoAQb.js";import{t as ae}from"./arrow-left-wtNmm6Le.js";import{t as v}from"./circle-alert-W8QX9LOG.js";import{t as y}from"./database-BohjTljV.js";import{t as oe}from"./download-B2UOiYAS.js";import{t as se}from"./eye-DN-Km5vf.js";import{n as b,t as x}from"./shield-check-Dt7sXtBF.js";import{t as ce}from"./folder-plus-DsmP6Mur.js";import{t as le}from"./globe-fwFSeXZn.js";import{t as ue}from"./save-Dewm93H6.js";import{t as de}from"./terminal-CIapYonS.js";import{t as S}from"./timer-C9X20mTO.js";import"./utils-DHTPP40O.js";import{G as C,P as fe,R as w,V as pe,a as me,j as he,k as ge,n as _e,q as T,t as E,w as ve}from"./index-dc8HGqTp.js";import{t as ye}from"./code-editor-x9L6nkh4.js";var D=s(`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:C,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:T,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 h.fs.pickFolder();if(!i.path)return;if(t.some(e=>e.path===i.path)){E.info(r(`agentEdit.folderAlreadyAdded`));return}n(e===`cursor`?[{path:i.path,permission:`write`}]:e=>[...e,{path:i.path,permission:`read`}])}catch{E.error(r(`agentEdit.couldNotOpenFolder`))}}async function Se(e,t){if(e)try{let n=await h.agents.exportSoul(e);await navigator.clipboard.writeText(n),E.success(t(`agentEdit.exportedToClipboard`))}catch{E.error(t(`agentEdit.failedToExport`))}}function Ce(e,t){let{setInitialized:n,setName:r,setDescription:i,setAvatar:ee,setSlug:a,setRuntime:o,setCli:s,setModel:c,setAdditionalFolders:l,setTemperature:u,setTagsStr:d,setMemoryEnabled:f,setSoul:p,setIdentity:te,setRules:ne,setUser:re,setHeartbeat:m,setMemory:h,setKnowledge:g}=t;n(!0),r(e.name),i(e.description),ee(e.avatar),a(e.slug??``),o(e.runtime??`cli`),s(e.cli??`claude-code`),c(e.model),l(e.additionalFolders??[]),u(e.temperature),d(e.tags.join(`, `)),f(e.memoryEnabled??!0),p(e.soul),te(e.identity??``),ne(e.rules??``),re(e.user??``),m(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 h.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:c(`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)(w,{className:`h-3.5 w-3.5 animate-spin text-muted-foreground`}),t===`available`&&(0,k.jsx)(l,{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=ee(),{t:s}=ve(),l=!e||e===`new`,[v,y]=(0,O.useState)(``),[b,x]=(0,O.useState)(``),[S,C]=(0,O.useState)(`🤖`),[w,T]=(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,l?void 0:e,je,Ae)},[l,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)(l),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}=a({queryKey:[`cli-agents`],queryFn:()=>h.settings.getCliAgents(),staleTime:6e4}),X=(Ke?.agents??[]).filter(e=>e.installed),{data:qe,isLoading:Je}=a({queryKey:[`agents`,e],queryFn:()=>h.agents.get(e),enabled:!l});qe&&!Ue&&Ce(qe,{setInitialized:We,setName:y,setDescription:x,setAvatar:C,setSlug:Oe,setRuntime:L,setCli:z,setModel:V,setAdditionalFolders:U,setTemperature:T,setTagsStr:j,setMemoryEnabled:F,setSoul:G,setIdentity:q,setRules:Pe,setUser:Ie,setHeartbeat:Re,setMemory:ze,setKnowledge:Ve});let Ye=o({mutationFn:e=>h.agents.create(e),onSuccess:e=>{r.invalidateQueries({queryKey:[`agents`]}),E.success(s(`agentEdit.agentCreated`)),t(`/agents/${e.id}`)},onError:e=>E.error(e.message)}),Xe=o({mutationFn:t=>h.agents.update(e,t),onSuccess:()=>{r.invalidateQueries({queryKey:[`agents`]}),E.success(s(`agentEdit.agentSaved`))},onError:e=>E.error(e.message)}),Ze=o({mutationFn:()=>h.agents.delete(e),onSuccess:()=>{r.invalidateQueries({queryKey:[`agents`]}),E.success(s(`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};(l?Ye:Xe).mutate(t)},$e=()=>Se(e,s),et=()=>xe(R,H,U,s),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(!l&&Je)return(0,k.jsx)(me,{});let at=l?`New Agent`:v||`Untitled Agent`,ot=l?`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)(d,{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:[!l&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(d,{variant:`ghost`,size:`sm`,onClick:$e,children:[(0,k.jsx)(oe,{className:`h-4 w-4 mr-1`}),` Export`]}),(0,k.jsxs)(d,{variant:`ghost`,size:`sm`,onClick:()=>Ze.mutate(),className:`text-destructive hover:text-destructive`,children:[(0,k.jsx)(ge,{className:`h-4 w-4 mr-1`}),` Delete`]})]}),(0,k.jsxs)(d,{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:s(`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:s(`agentEdit.descriptionPlaceholder`)})]}),(0,k.jsx)(m,{}),(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:c(`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:c(`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=_e(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:c(`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:s(`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)(f,{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:s(`agentEdit.temperature`,{value:w})}),(0,k.jsx)(`input`,{type:`range`,min:0,max:1,step:.1,value:w,onChange:e=>T(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:s(`agentEdit.precise`)}),(0,k.jsx)(`span`,{children:s(`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:s(`agentEdit.memoryEnabled`)}),(0,k.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:s(`agentEdit.memoryEnabledHelp`)})]}),(0,k.jsx)(p,{checked:P,onCheckedChange:F})]}),(0,k.jsx)(m,{}),(0,k.jsx)(Ee,{slug:De,slugStatus:ke,isNew:l,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)(pe,{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)(d,{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)(fe,{className:`h-3 w-3 text-amber-400`})}),(0,k.jsx)(u,{variant:`outline`,className:c(`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)(d,{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)(d,{variant:`outline`,size:`sm`,className:`text-xs gap-1.5`,onClick:et,children:[(0,k.jsx)(ce,{className:`h-3.5 w-3.5`}),s($?`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:s(`agentEdit.tags`)}),(0,k.jsx)(_,{value:D,onChange:e=>j(e.target.value),placeholder:s(`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)(u,{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:c(`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)(d,{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`&&!l&&!!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{U as o,V as s,q as c}from"./src-DUhGoAQb.js";import{t as l}from"./arrow-left-wtNmm6Le.js";import{n as u,t as d}from"./zap-CbT5plGA.js";import{t as f}from"./layers-ephyCrDm.js";import{t as p}from"./play-DXJMtO-K.js";import{t as m}from"./terminal-CIapYonS.js";import{A as h,H as g,K as _,U as v,W as y,t as b}from"./index-dc8HGqTp.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)(s,{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)(o,{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([c.agentSessions.list({limit:20,offset:(R-1)*20}),c.agentSessions.stats(14),c.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?c.agentSessions.get(t).then(F).catch(()=>F(null)):Promise.resolve().then(()=>F(null))},[t]);let B=async e=>{await c.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)(_,{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)(o,{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)(s,{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)(s,{size:`sm`,variant:`outline`,onClick:()=>B(t.streamId),children:[(0,S.jsx)(h,{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)(o,{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)(v,{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)(s,{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)(y,{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)(s,{size:`sm`,variant:`outline`,disabled:R<=1,onClick:()=>z(e=>e-1),children:`Previous`}),(0,S.jsx)(s,{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{K as o,U as s,V as c,q as l,t as ee}from"./src-DUhGoAQb.js";import{S as u,_ as d,h as f,p,v as m}from"./vendor-ui-Dpw9mBc-.js";import{t as h}from"./arrow-down-XHN5PD1k.js";import{t as g}from"./arrow-left-wtNmm6Le.js";import{t as _}from"./chat-message-CbcDeDcb.js";import{n as v,t as y}from"./shield-check-Dt7sXtBF.js";import{t as b}from"./history-CyBBboEp.js";import{n as te,r as ne,t as x}from"./send-FWvygYFQ.js";import{t as S}from"./timer-C9X20mTO.js";import"./utils-DHTPP40O.js";import{A as C,G as w,K as T,R as E,_ as D,g as re,n as O,q as k,r as A,t as j,w as M}from"./index-dc8HGqTp.js";var N=e(t(),1),P=r();function F({cli:e,className:t}){return(0,N.createElement)(O(e),{className:t})}var I={agentDisplay:(0,N.memo)(function({data:e}){let{t}=M(),n=e.agent;return(0,P.jsxs)(`div`,{className:o(`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,P.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-4`,children:[(0,P.jsx)(`span`,{className:`text-3xl`,children:n.avatar}),(0,P.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,P.jsx)(`div`,{className:`text-base font-semibold truncate`,children:n.name}),(0,P.jsxs)(`div`,{className:`text-xs text-muted-foreground flex items-center gap-1.5`,children:[n.runtime===`cli`&&n.cli&&(0,P.jsx)(F,{cli:n.cli,className:`h-3 w-3`}),n.runtime===`cli`?A(n.cli??void 0):`API`,(0,P.jsx)(`span`,{className:`text-muted-foreground/40`,children:`·`}),(0,P.jsx)(`span`,{children:n.model})]})]}),e.status===`running`&&(0,P.jsx)(`div`,{className:`h-2.5 w-2.5 rounded-full bg-emerald-500 animate-pulse`}),e.status===`done`&&(0,P.jsx)(s,{variant:`secondary`,className:`text-[10px] bg-emerald-500/15 text-emerald-500`,children:t(`common.done`)}),e.status===`error`&&(0,P.jsx)(s,{variant:`secondary`,className:`text-[10px] bg-red-500/15 text-red-500`,children:t(`common.error`)})]}),n.description&&(0,P.jsx)(`div`,{className:`px-4 pb-3 border-t border-border/30 pt-2`,children:(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground line-clamp-2`,children:n.description})}),(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-1 px-4 pb-3`,children:[n.soul&&(0,P.jsxs)(s,{variant:`secondary`,className:`text-[10px]`,children:[(0,P.jsx)(w,{className:`h-2.5 w-2.5 mr-0.5`}),`SOUL`]}),n.identity&&(0,P.jsxs)(s,{variant:`secondary`,className:`text-[10px]`,children:[(0,P.jsx)(v,{className:`h-2.5 w-2.5 mr-0.5`}),`Identity`]}),n.rules&&(0,P.jsxs)(s,{variant:`secondary`,className:`text-[10px]`,children:[(0,P.jsx)(y,{className:`h-2.5 w-2.5 mr-0.5`}),`Rules`]}),n.heartbeat&&(0,P.jsxs)(s,{variant:`secondary`,className:`text-[10px]`,children:[(0,P.jsx)(S,{className:`h-2.5 w-2.5 mr-0.5`}),`Heartbeat`]}),n.knowledge&&(0,P.jsxs)(s,{variant:`secondary`,className:`text-[10px]`,children:[(0,P.jsx)(k,{className:`h-2.5 w-2.5 mr-0.5`}),`Knowledge`]})]}),(0,P.jsx)(d,{type:`source`,position:u.Right,className:`!bg-transparent !border-0 !w-0 !h-0`})]})})};function L(){let{id:e,sessionId:t}=i(),r=n(),{t:u}=M(),{data:d,isLoading:v}=a({queryKey:[`agents`,e],queryFn:()=>l.agents.get(e),enabled:!!e}),[y,S]=(0,N.useState)([]),[w,O]=(0,N.useState)(``),[k,A]=(0,N.useState)(`idle`),[F,L]=(0,N.useState)(),R=(0,N.useRef)(null),z=(0,N.useRef)(null),B=(0,N.useRef)(null),[V,H]=(0,N.useState)(!0),[U,W]=(0,N.useState)(`side`),{streamingContent:G,streamingThinking:K,streamingToolCalls:q,isStreaming:J,error:Y,stopStream:X,consumeStream:Z}=re(F),Q=(0,N.useCallback)(()=>{R.current?.scrollIntoView({behavior:`smooth`})},[]),ie=(0,N.useCallback)(()=>{let e=z.current;e&&H(e.scrollHeight-e.scrollTop-e.clientHeight<100)},[]);(0,N.useEffect)(()=>{(G||q.length>0)&&V&&Q()},[G,q,Q,V]),(0,N.useEffect)(()=>{y.length>0&&y[y.length-1].role===`user`&&setTimeout(Q,0)},[y.length,Q]);let ae=(0,N.useMemo)(()=>{let e=[],t={user:null,replies:[]};for(let n of y)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},[y]);(0,N.useEffect)(()=>{J&&k!==`running`&&A(`running`)},[J,k]),(0,N.useEffect)(()=>{if(!J&&(G||q.length>0)&&(k===`running`||k===`done`)){let e=Z();e&&(e.content||e.toolCalls.length>0)&&(S(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,k,Z]),(0,N.useEffect)(()=>{if(Y&&k===`running`){if(G||q.length>0)return;A(`error`),S(e=>[...e,{id:crypto.randomUUID(),role:`system`,content:`Error: ${Y}`,timestamp:new Date}])}},[Y,k,G,q]);let $=(0,N.useCallback)(async()=>{let e=w.trim();if(!e||!d||J)return;let t={id:crypto.randomUUID(),role:`user`,content:e,timestamp:new Date};S(e=>[...e,t]),O(``),A(`running`);try{let t=d.additionalFolders?.map(e=>e.path),n=await l.chat.startNew(d.dir,e,d.cli??void 0,t?.length?t:void 0,d.model||void 0),r=`agent-use/${d.id}/${n.streamId}`;L(r),D(n.streamId,r),l.agentSessions.track({agentId:d.id,agentName:d.name,streamId:n.streamId,prompt:e,cli:d.cli??void 0,model:d.model||void 0}).catch(()=>{})}catch(e){A(`error`),j.error(u(`agentUse.failedToStart`)),S(t=>[...t,{id:crypto.randomUUID(),role:`system`,content:`Failed to start session: ${e}`,timestamp:new Date}])}},[w,d,J,u]),oe=(0,N.useCallback)(()=>{X(),A(`idle`)},[X]),se=(0,N.useCallback)(e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),$())},[$]);(0,N.useEffect)(()=>{!t||!d||l.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)}),S(t),A(`done`)}).catch(()=>{})},[t,d?.id]),(0,N.useEffect)(()=>{!d||F||t||l.agentSessions.listActive(d.id).then(({data:e})=>{let t=e.find(e=>e.status===`running`);if(t){let e=`agent-use/${d.id}/${t.streamId}`;L(e),D(t.streamId,e),A(`running`),S([{id:crypto.randomUUID(),role:`user`,content:t.prompt,timestamp:new Date(t.startedAt)}]),j.info(`Reconnected to active session`)}}).catch(()=>{})},[d?.id]);let ce=d?[{id:`agent-node`,type:`agentDisplay`,position:{x:100,y:100},data:{agent:d,status:k},draggable:!0,selectable:!1}]:[];return v?(0,P.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,P.jsx)(E,{className:`h-8 w-8 animate-spin text-muted-foreground`})}):d?(0,P.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2 border-b bg-background/95 backdrop-blur shrink-0`,children:[(0,P.jsx)(c,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>r(`/agents`),children:(0,P.jsx)(g,{className:`h-4 w-4`})}),(0,P.jsx)(`span`,{className:`text-xl`,children:d.avatar}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h1`,{className:`text-sm font-semibold`,children:d.name}),(0,P.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:u(`agentUse.interactiveSession`)})]}),(0,P.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[k===`running`&&(0,P.jsx)(s,{className:`bg-emerald-500/15 text-emerald-500 border-emerald-500/30 animate-pulse`,children:u(`common.running`)}),(0,P.jsxs)(c,{variant:`ghost`,size:`sm`,className:`h-7 text-xs gap-1`,onClick:()=>r(`/agent-sessions?agentId=${d.id}`),children:[(0,P.jsx)(b,{className:`h-3.5 w-3.5`}),` History`]}),(0,P.jsxs)(`div`,{className:`flex items-center border rounded-lg p-0.5 bg-muted/50`,children:[(0,P.jsx)(c,{variant:U===`side`?`secondary`:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>W(`side`),title:u(`common.sideBySide`),children:(0,P.jsx)(ne,{className:`h-3.5 w-3.5`})}),(0,P.jsx)(c,{variant:U===`stack`?`secondary`:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>W(`stack`),title:u(`common.stacked`),children:(0,P.jsx)(te,{className:`h-3.5 w-3.5`})})]})]})]}),(0,P.jsxs)(`div`,{className:o(`flex-1 min-h-0`,U===`side`?`flex`:`flex flex-col`),children:[(0,P.jsx)(`div`,{className:o(`bg-muted/30`,U===`side`?`w-[45%] border-r`:`h-[280px] border-b shrink-0`),children:(0,P.jsxs)(m,{nodes:ce,edges:[],nodeTypes:I,fitView:!0,fitViewOptions:{padding:.5},proOptions:{hideAttribution:!0},panOnScroll:!0,zoomOnScroll:!0,minZoom:.5,maxZoom:1.5,children:[(0,P.jsx)(p,{gap:20,size:1}),(0,P.jsx)(f,{showInteractive:!1})]})}),(0,P.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0 min-h-0`,children:[(0,P.jsx)(`div`,{className:`relative flex-1 overflow-y-auto min-h-0`,ref:z,onScroll:ie,children:(0,P.jsxs)(`div`,{className:`p-3`,children:[y.length===0&&!G&&!J&&(0,P.jsxs)(`div`,{className:`text-center py-16 text-muted-foreground`,children:[(0,P.jsx)(T,{className:`h-12 w-12 mx-auto mb-3 opacity-30`}),(0,P.jsx)(`p`,{className:`font-medium`,children:u(`agentUse.startConversation`)}),(0,P.jsx)(`p`,{className:`text-sm mt-1`,children:u(`agentUse.sendMessageTo`,{name:d.name})})]}),ae.map((e,t)=>(0,P.jsxs)(`div`,{children:[e.user&&(0,P.jsx)(`div`,{className:`sticky top-0 z-10 py-1`,children:(0,P.jsx)(_,{role:e.user.role,content:e.user.content,compact:!0})}),(0,P.jsx)(`div`,{className:`flex flex-col gap-1 pt-1`,children:e.replies.map(e=>(0,P.jsx)(_,{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,P.jsx)(_,{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,P.jsx)(`div`,{className:`flex justify-start`,children:(0,P.jsx)(`div`,{className:`bg-muted rounded-lg px-4 py-2 text-sm text-muted-foreground`,children:u(`common.thinking`)})}),Y&&k===`error`&&(0,P.jsx)(`div`,{className:`text-center text-destructive text-sm`,children:Y}),(0,P.jsx)(`div`,{ref:R})]})}),!V&&(0,P.jsx)(`div`,{className:`pointer-events-none flex justify-end px-4 -mt-12 mb-1 relative z-10`,children:(0,P.jsx)(c,{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,P.jsx)(h,{className:`h-4 w-4`})})}),(0,P.jsx)(`div`,{className:`border-t p-4 shrink-0`,children:(0,P.jsxs)(`div`,{className:`flex gap-2 max-w-2xl mx-auto`,children:[(0,P.jsx)(ee,{ref:B,value:w,onChange:e=>O(e.target.value),onKeyDown:se,placeholder:`Message ${d.name}...`,className:`min-h-[44px] max-h-[200px] resize-none`,rows:1,disabled:J}),J?(0,P.jsx)(c,{variant:`destructive`,size:`icon`,className:`h-[44px] w-[44px] shrink-0`,onClick:oe,children:(0,P.jsx)(C,{className:`h-4 w-4`})}):(0,P.jsx)(c,{size:`icon`,className:`h-[44px] w-[44px] shrink-0`,onClick:$,disabled:!w.trim(),children:(0,P.jsx)(x,{className:`h-4 w-4`})})]})})]})]})]}):(0,P.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4`,children:[(0,P.jsx)(`p`,{className:`text-muted-foreground`,children:u(`agentUse.agentNotFound`)}),(0,P.jsxs)(c,{variant:`outline`,onClick:()=>r(`/agents`),children:[(0,P.jsx)(g,{className:`h-4 w-4 mr-1`}),` `,u(`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-BlOHt3MR.js";import{B as c,I as l,L as u,R as d,U as f,V as p,a as m,i as h,n as g,q as _,r as v,w as y,z as b}from"./src-DUhGoAQb.js";import{n as x,r as S,t as C}from"./shuffle-DjvBJ7XV.js";import{t as w}from"./download-B2UOiYAS.js";import{n as T,t as E}from"./shield-check-Dt7sXtBF.js";import{t as D}from"./globe-fwFSeXZn.js";import{t as O}from"./history-CyBBboEp.js";import{t as k}from"./play-DXJMtO-K.js";import{t as A}from"./search-Ww0msJQz.js";import{t as j}from"./timer-C9X20mTO.js";import{D as M,G as N,I as P,K as F,M as I,i as L,k as R,n as z,p as B,q as V,r as H,t as U,w as W}from"./index-dc8HGqTp.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:P,label:`Debate`,description:`Agents discuss and reach consensus`}};function Y({cli:e,className:t}){return(0,G.createElement)(z(e),{className:t})}function X({agent:e,onEdit:t,onDelete:n,onExport:r,onUse:i}){let{t:a}=W(),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`}),H(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)(l,{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)(c,{className:`text-base`,children:e.name}),(0,K.jsxs)(d,{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)(p,{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)(p,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:e=>{e.stopPropagation(),n()},title:a(`common.delete`),children:(0,K.jsx)(R,{className:`h-3.5 w-3.5 text-destructive`})})]})]})}),(0,K.jsxs)(u,{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)(f,{variant:`secondary`,className:`text-xs`,children:[(0,K.jsx)(N,{className:`h-2.5 w-2.5 mr-1`}),`SOUL`]}),e.identity&&(0,K.jsxs)(f,{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)(f,{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)(f,{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)(f,{variant:`secondary`,className:`text-xs`,children:[(0,K.jsx)(V,{className:`h-2.5 w-2.5 mr-1`}),`Knowledge`]}),e.tags.map(e=>(0,K.jsx)(f,{variant:`outline`,className:`text-xs`,children:e},e))]}),(0,K.jsx)(`div`,{className:`mt-auto pt-3 flex justify-end`,children:(0,K.jsxs)(p,{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}=W(),o=J[e.strategy],s=o.icon;return(0,K.jsxs)(l,{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)(M,{className:`h-4 w-4 text-primary`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(c,{className:`text-base`,children:e.name}),(0,K.jsxs)(d,{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)(p,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:e=>{e.stopPropagation(),r()},title:a(`common.delete`),children:(0,K.jsx)(R,{className:`h-3.5 w-3.5 text-destructive`})})})]})}),(0,K.jsxs)(u,{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)(f,{variant:`outline`,className:`text-xs`,children:e},e))}),(0,K.jsx)(`div`,{className:`mt-auto pt-3 flex justify-end`,children:(0,K.jsxs)(p,{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}=W(),[c,l]=t(),u=c.get(`tab`)===`teams`?`teams`:`agents`,d=e=>l(e===`agents`?{}:{tab:e},{replace:!0}),[b,x]=(0,G.useState)(``),S=o({queryKey:[`agents`],queryFn:()=>_.agents.list({page:1,pageSize:100})}),C=o({queryKey:[`teams`],queryFn:()=>_.teams.list({page:1,pageSize:100})}),w=s({mutationFn:e=>_.agents.delete(e),onSuccess:()=>{n.invalidateQueries({queryKey:[`agents`]}),U.success(i(`agentEdit.agentDeleted`))}}),T=s({mutationFn:e=>_.teams.delete(e),onSuccess:()=>{n.invalidateQueries({queryKey:[`teams`]}),U.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())),N=(0,G.useCallback)(async e=>{try{let t=await _.agents.exportSoul(e.id);await navigator.clipboard.writeText(t),U.success(i(`agents.soulMdCopied`))}catch{U.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)(g,{value:u,onValueChange:d,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,K.jsxs)(h,{children:[(0,K.jsxs)(m,{value:`agents`,className:`gap-1.5`,children:[(0,K.jsx)(F,{className:`h-4 w-4`}),` Agents`,E.length>0&&(0,K.jsx)(f,{variant:`secondary`,className:`ml-1 text-xs h-5 px-1.5`,children:E.length})]}),(0,K.jsxs)(m,{value:`teams`,className:`gap-1.5`,children:[(0,K.jsx)(M,{className:`h-4 w-4`}),` Teams`,D.length>0&&(0,K.jsx)(f,{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`})]}),u===`agents`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(p,{variant:`outline`,onClick:()=>e(`/agent-sessions`),children:[(0,K.jsx)(O,{className:`h-4 w-4 mr-1`}),` History`]}),(0,K.jsxs)(p,{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)(p,{variant:`outline`,onClick:()=>e(`/team-sessions`),children:[(0,K.jsx)(O,{className:`h-4 w-4 mr-1`}),` History`]}),(0,K.jsxs)(p,{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)(L,{count:6}),!S.isLoading&&k.length===0&&(0,K.jsxs)(`div`,{className:`text-center py-16 text-muted-foreground`,children:[(0,K.jsx)(F,{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)(p,{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:()=>N(t),onUse:()=>e(`/agents/${t.id}/use`)},t.id))})]}),(0,K.jsxs)(v,{value:`teams`,className:`mt-4`,children:[C.isLoading&&(0,K.jsx)(B,{count:4}),!C.isLoading&&j.length===0&&(0,K.jsxs)(`div`,{className:`text-center py-16 text-muted-foreground`,children:[(0,K.jsx)(M,{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)(p,{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
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{h as t,t as n}from"./vendor-react-BJ8SIkmN.js";var r=e(t(),1),i=n();function a(){let e=(0,r.useRef)(null),t=(0,r.useCallback)(()=>{let t=e.current;t?.contentWindow&&t.contentWindow.location.reload()},[]);return(0,r.useEffect)(()=>{let e=document.documentElement,n=new MutationObserver(e=>{for(let n of e)if(n.attributeName===`class`){t();break}});return n.observe(e,{attributes:!0,attributeFilter:[`class`]}),()=>n.disconnect()},[t]),(0,i.jsx)(`iframe`,{ref:e,src:`/docs.html`,className:`h-full w-full border-0`,title:`API Documentation`})}export{a as ApiDocs};
@@ -0,0 +1 @@
1
+ import{F as e}from"./src-DUhGoAQb.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-DUhGoAQb.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{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{h as t}from"./vendor-react-BJ8SIkmN.js";var n=e(t(),1),r={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},i=n.createContext&&n.createContext(r),a=[`attr`,`size`,`title`];function o(e,t){if(e==null)return{};var n,r,i=s(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function s(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},c.apply(null,arguments)}function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function u(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?l(Object(n),!0).forEach(function(t){d(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function d(e,t,n){return(t=f(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function f(e){var t=p(e,`string`);return typeof t==`symbol`?t:t+``}function p(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function m(e){return e&&e.map((e,t)=>n.createElement(e.tag,u({key:t},e.attr),m(e.child)))}function h(e){return t=>n.createElement(g,c({attr:u({},e.attr)},t),m(e.child))}function g(e){var t=t=>{var{attr:r,size:i,title:s}=e,l=o(e,a),d=i||t.size||`1em`,f;return t.className&&(f=t.className),e.className&&(f=(f?f+` `:``)+e.className),n.createElement(`svg`,c({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,r,l,{className:f,style:u(u({color:e.color||t.color},t.style),e.style),height:d,width:d,xmlns:`http://www.w3.org/2000/svg`}),s&&n.createElement(`title`,null,s),e.children)};return i===void 0?t(r):n.createElement(i.Consumer,null,e=>t(e))}function _(e){return h({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M8.64445 2.55279C8.39746 2.05881 7.79679 1.85859 7.30281 2.10558C6.80883 2.35257 6.60861 2.95324 6.8556 3.44722L9.68128 9.09859L5.06655 5.92596C4.61145 5.61308 3.98887 5.72837 3.67598 6.18348C3.3631 6.63858 3.47839 7.26116 3.9335 7.57405L9.40503 11.3357L3.05258 11.0014C2.50106 10.9724 2.03043 11.3959 2.00141 11.9474C1.97238 12.499 2.39594 12.9696 2.94747 12.9986L8.74187 13.3036L4.44532 16.168C3.9858 16.4743 3.86162 17.0952 4.16797 17.5547C4.47433 18.0142 5.0952 18.1384 5.55473 17.8321L9.19687 15.404L6.68629 18.9188C6.36528 19.3682 6.46937 19.9927 6.91879 20.3137C7.3682 20.6347 7.99275 20.5307 8.31376 20.0812L11.3471 15.8345L10.5136 20.8356C10.4228 21.3804 10.7909 21.8956 11.3356 21.9864C11.8804 22.0772 12.3956 21.7092 12.4864 21.1644L13.2883 16.3532L15.6588 20.0408C15.9575 20.5053 16.5762 20.6398 17.0408 20.3412C17.5054 20.0425 17.6399 19.4238 17.3412 18.9592L15.5553 16.1812L18.3217 18.7348C18.7276 19.1094 19.3602 19.0841 19.7348 18.6783C20.1094 18.2725 20.0841 17.6398 19.6783 17.2652L16.6427 14.4631L20.876 14.9923C21.424 15.0608 21.9238 14.6721 21.9923 14.124C22.0608 13.576 21.6721 13.0762 21.1241 13.0077L16.9342 12.484L21.2291 11.4734C21.7667 11.3469 22.0999 10.8086 21.9734 10.271C21.8469 9.73336 21.3086 9.40009 20.771 9.52659L15.1819 10.8417L19.2863 5.61783C19.6276 5.18356 19.5521 4.5549 19.1178 4.21369C18.6836 3.87247 18.0549 3.94791 17.7137 4.38218L13.8574 9.29015L14.738 3.65438C14.8233 3.10872 14.4501 2.59725 13.9044 2.51199C13.3587 2.42673 12.8473 2.79996 12.762 3.34563L11.876 9.01594L8.64445 2.55279Z`},child:[]}]})(e)}function v(e){return h({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{d:`m21.406 6.086-9-4a1.001 1.001 0 0 0-.813 0l-9 4c-.02.009-.034.024-.054.035-.028.014-.058.023-.084.04-.022.015-.039.034-.06.05a.87.87 0 0 0-.19.194c-.02.028-.041.053-.059.081a1.119 1.119 0 0 0-.076.165c-.009.027-.023.052-.031.079A1.013 1.013 0 0 0 2 7v10c0 .396.232.753.594.914l9 4c.13.058.268.086.406.086a.997.997 0 0 0 .402-.096l.004.01 9-4A.999.999 0 0 0 22 17V7a.999.999 0 0 0-.594-.914zM12 4.095 18.538 7 12 9.905l-1.308-.581L5.463 7 12 4.095zm1 15.366V11.65l7-3.111v7.812l-7 3.11z`},child:[]}]})(e)}export{_ as n,v as t};
@@ -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{A as s,D as c,F as l,K as u,N as d,T as f,U as p,V as m,f as h,j as g,q as _}from"./src-DUhGoAQb.js";import{t as ee}from"./arrow-down-XHN5PD1k.js";import{n as te,t as v}from"./chat-message-CbcDeDcb.js";import{n as y,t as b}from"./file-tree-DkLQ1z0I.js";import{t as x}from"./save-Dewm93H6.js";import"./utils-DHTPP40O.js";import{B as S,C,H as w,R as T,V as E,W as D,g as O,k,l as A,t as j,w as ne}from"./index-dc8HGqTp.js";import{n as re,t as M}from"./code-editor-x9L6nkh4.js";import{t as N}from"./chat-input-BepRPV_L.js";var P=l(`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`}]]),F=l(`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`}]]),I=l(`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`}]]),L=e(t(),1);function R(e,t,n,r,i){let a=(0,L.useRef)(i);(0,L.useEffect)(()=>{a.current=i});let o=(0,L.useRef)(r);(0,L.useEffect)(()=>{o.current=r},[r]);let[s,c]=(0,L.useState)(!1),l=(0,L.useRef)(null),u=n&&e&&t?`${e}/${t}`:null;return(0,L.useEffect)(()=>{if(!u){l.current&&=(l.current.close(),null);return}let[e,t]=u.split(`/`),n=`/api/chat/${e}/${t}/watch?knownCount=${o.current}`,r=new EventSource(n);return l.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);c(t)}catch{}}),r.onerror=()=>{c(!1)},()=>{r.close(),l.current=null,c(!1)}},[u]),{isActive:s}}var z=r();function B({ops:e}){return e.length===0?(0,z.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:`No change operations found in transcript`}):(0,z.jsx)(`div`,{className:`h-full overflow-auto font-mono text-[13px] leading-5 bg-[#1e1e2e] p-0`,children:e.map((e,t)=>(0,z.jsxs)(`div`,{className:`border-b border-white/5`,children:[(0,z.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,z.jsx)(`span`,{className:`uppercase`,children:e.tool}),(0,z.jsxs)(`span`,{className:`text-blue-400/50`,children:[`#`,t+1]})]}),e.tool===`Write`||e.tool===`write_to_file`?(0,z.jsx)(`div`,{children:(e.content??``).split(`
2
+ `).map((e,t)=>(0,z.jsxs)(`div`,{className:`flex`,children:[(0,z.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,z.jsxs)(`span`,{className:`flex-1 px-3 whitespace-pre bg-green-500/10 text-green-300`,children:[(0,z.jsx)(`span`,{className:`select-none text-green-400/50 mr-2`,children:`+`}),e||`\xA0`]})]},t))}):(0,z.jsxs)(`div`,{children:[(e.oldString??``).split(`
3
+ `).map((e,t)=>(0,z.jsxs)(`div`,{className:`flex`,children:[(0,z.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,z.jsxs)(`span`,{className:`flex-1 px-3 whitespace-pre bg-red-500/10 text-red-300`,children:[(0,z.jsx)(`span`,{className:`select-none text-red-400/50 mr-2`,children:`-`}),e||`\xA0`]})]},`r-${t}`)),(e.newString??``).split(`
4
+ `).map((e,t)=>(0,z.jsxs)(`div`,{className:`flex`,children:[(0,z.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,z.jsxs)(`span`,{className:`flex-1 px-3 whitespace-pre bg-green-500/10 text-green-300`,children:[(0,z.jsx)(`span`,{className:`select-none text-green-400/50 mr-2`,children:`+`}),e||`\xA0`]})]},`a-${t}`))]})]},t))})}function V({open:e,onOpenChange:t,workspacePath:n,modifiedFiles:r,projectHash:i,sessionId:a}){let{t:l}=ne(),d=r.length>0,[p,ee]=(0,L.useState)(d),[v,S]=(0,L.useState)([]),[C,w]=(0,L.useState)(null),[E,D]=(0,L.useState)(!1),[O,k]=(0,L.useState)(`diff`),A=v.find(e=>e.path===C)??null,N=(0,L.useRef)(new Set),P=(0,L.useRef)(v);P.current=v;let I=C?r.find(e=>(e.path.startsWith(`/`)?e.path:`${n}/${e.path}`)===C):null,R=!!I,{data:V,isLoading:H}=o({queryKey:[`file-changes`,i,a,I?.path],queryFn:()=>_.chat.getFileChanges(i,a,I.path),enabled:!!I&&O===`diff`,staleTime:6e4}),U=(0,L.useCallback)(async e=>{if(P.current.some(t=>t.path===e)){w(e);return}if(!N.current.has(e)){N.current.add(e);try{let t=await _.fs.readFile(e),n=e.split(`/`).pop()??e;S(r=>r.some(t=>t.path===e)?r:[...r,{path:e,name:n,content:t.content,dirty:!1,etag:t.etag}]),w(e)}catch{j.error(l(`fileEditor.failedToOpen`))}finally{N.current.delete(e)}}},[l]),W=(0,L.useCallback)((e,t)=>{t?.stopPropagation();let n=v.find(t=>t.path===e);if(!(n?.dirty&&!confirm(l(`fileEditor.unsavedChanges`,{name:n.name})))&&(S(t=>t.filter(t=>t.path!==e)),C===e)){let t=v.filter(t=>t.path!==e);w(t.length>0?t[t.length-1].path:null)}},[v,C,l]),ie=(0,L.useCallback)((e,t)=>{S(n=>n.map(n=>n.path===e?{...n,content:t,dirty:!0}:n))},[]),G=(0,L.useCallback)(async()=>{if(!(!A||!A.dirty)){D(!0);try{let e=await _.fs.writeFile(A.path,A.content);S(t=>t.map(t=>t.path===A.path?{...t,dirty:!1,etag:e.etag}:t)),j.success(l(`common.saved`))}catch{j.error(l(`common.failedToSave`))}finally{D(!1)}}},[A,l]),ae=e=>e.startsWith(n+`/`)?e.slice(n.length+1):e,oe=O===`diff`&&R&&V&&V.length>0,se=H&&O===`diff`&&R,K=O===`diff`&&R&&V&&V.length===0,q;return A?oe?q=(0,z.jsx)(B,{ops:V}):se?q=(0,z.jsxs)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm gap-2`,children:[(0,z.jsx)(T,{className:`h-4 w-4 animate-spin`}),`Loading changes...`]}):K?q=(0,z.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:`No change operations found in transcript`}):A&&(q=(0,z.jsx)(M,{value:A.content,onChange:e=>ie(A.path,e),language:re(A.name),onSave:G,minHeight:`100%`,className:`h-full border-0 rounded-none [&_.cm-editor]:h-full [&_.cm-scroller]:!overflow-auto`})):q=(0,z.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,z.jsx)(f,{open:e,onOpenChange:t,children:(0,z.jsxs)(c,{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,z.jsx)(s,{className:`sr-only`,children:`Workspace Editor`}),(0,z.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2.5 border-b shrink-0`,children:[(0,z.jsx)(te,{className:`h-4 w-4 text-muted-foreground`}),(0,z.jsx)(`h2`,{className:`text-sm font-medium truncate flex-1`,children:n.split(`/`).pop()}),R&&(0,z.jsxs)(`div`,{className:`flex items-center gap-1 border rounded-md overflow-hidden text-xs`,children:[(0,z.jsxs)(`button`,{className:u(`px-2 py-1 transition-colors`,O===`diff`?`bg-primary text-primary-foreground`:`hover:bg-muted`),onClick:()=>k(`diff`),children:[(0,z.jsx)(F,{className:`h-3 w-3 inline mr-1`}),`Changes`]}),(0,z.jsx)(`button`,{className:u(`px-2 py-1 transition-colors`,O===`edit`?`bg-primary text-primary-foreground`:`hover:bg-muted`),onClick:()=>k(`edit`),children:`Edit`})]}),d&&(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,z.jsx)(`span`,{children:`Modified only`}),(0,z.jsx)(h,{checked:p,onCheckedChange:ee,size:`sm`})]}),(0,z.jsx)(m,{variant:`ghost`,size:`icon-sm`,onClick:()=>t(!1),children:(0,z.jsx)(g,{className:`h-4 w-4`})})]}),(0,z.jsxs)(`div`,{className:`flex flex-1 min-h-0`,children:[(0,z.jsx)(`div`,{className:`w-60 shrink-0 border-r flex flex-col bg-muted/30 overflow-hidden`,children:p&&d?(0,z.jsxs)(`div`,{className:`flex-1 overflow-auto py-1`,children:[(0,z.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,z.jsxs)(`button`,{className:u(`w-full flex items-center gap-2 px-3 py-1.5 text-left text-[13px] hover:bg-muted/80 transition-colors`,C===t&&`bg-accent text-accent-foreground`),onClick:()=>U(t),title:`${e.path} (${e.tool} ×${e.count})`,children:[(0,z.jsx)(y,{className:`h-3.5 w-3.5 shrink-0 text-orange-400`}),(0,z.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,z.jsx)(`span`,{className:`truncate font-mono text-[12px]`,children:r}),(0,z.jsx)(`span`,{className:`truncate text-[11px] text-muted-foreground`,children:e.path.includes(`/`)?e.path.split(`/`).slice(0,-1).join(`/`):``})]}),e.count>1&&(0,z.jsxs)(`span`,{className:`text-[10px] text-muted-foreground shrink-0`,children:[`×`,e.count]})]},e.path)})]}):(0,z.jsx)(`div`,{className:`flex-1 overflow-auto py-1`,children:(0,z.jsx)(b,{rootPath:n,selectedFile:C,onSelectFile:U})})}),(0,z.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0`,children:[v.length>0&&(0,z.jsxs)(`div`,{className:`flex items-center border-b bg-muted/20 overflow-x-auto shrink-0`,children:[v.map(e=>{let t=r.some(t=>(t.path.startsWith(`/`)?t.path:`${n}/${t.path}`)===e.path);return(0,z.jsxs)(`button`,{className:u(`flex items-center gap-1.5 px-3 py-1.5 text-xs border-r shrink-0 transition-colors`,e.path===C?`bg-background text-foreground`:`text-muted-foreground hover:bg-muted/50`),onClick:()=>w(e.path),title:ae(e.path),children:[t&&(0,z.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-orange-400 shrink-0`}),(0,z.jsxs)(`span`,{className:u(`truncate max-w-40`,e.dirty&&`italic`),children:[e.dirty&&`* `,e.name]}),(0,z.jsx)(g,{className:`h-3 w-3 shrink-0 opacity-50 hover:opacity-100`,onClick:t=>W(e.path,t)})]},e.path)}),A?.dirty&&(0,z.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:E,children:[E?(0,z.jsx)(T,{className:`h-3 w-3 animate-spin`}):(0,z.jsx)(x,{className:`h-3 w-3`}),(0,z.jsx)(`kbd`,{className:`text-[10px] text-muted-foreground ml-1`,children:navigator.platform.includes(`Mac`)?`⌘S`:`Ctrl+S`})]})]}),(0,z.jsx)(`div`,{className:`flex-1 min-h-0`,children:q})]})]})]})})}function H(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 U(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.role===`assistant`&&n.usage){let e=H(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 ie(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 G(){let{t:e}=ne(),{projectHash:t,sessionId:r}=i(),s=n(),c=a(),[l,u]=(0,L.useState)([]),f=C(e=>e.markSeen);(0,L.useEffect)(()=>{t&&r&&f(t,r)},[t,r,f]);let{streamingContent:h,streamingThinking:g,streamingToolCalls:y,isStreaming:b,error:x,streamId:T,startStream:j,stopStream:re,consumeStream:M}=O(t&&r?`${t}/${r}`:void 0),F=(0,L.useRef)(null),B=(0,L.useRef)(null),[H,W]=(0,L.useState)(!0),G=(0,L.useCallback)(()=>{F.current?.scrollIntoView({behavior:`smooth`})},[]),ae=(0,L.useCallback)(()=>{let e=B.current;e&&W(e.scrollHeight-e.scrollTop-e.clientHeight<100)},[]),oe=(0,L.useCallback)(e=>{u(t=>{let n=t[t.length-1];return n&&n.role===e.role&&n.content===e.content?t:[...t,e]}),setTimeout(G,0)},[G]),{data:se}=o({queryKey:[`chat-sessions`,t],queryFn:()=>_.chat.getSessions(t,{page:1,pageSize:100}),enabled:!!t}),K=se?.data??[],{data:q,isLoading:J}=o({queryKey:[`chat-messages`,t,r],queryFn:()=>_.chat.getMessages(t,r),enabled:!!t&&!!r});(0,L.useEffect)(()=>{q&&u(q.messages)},[q]),(0,L.useEffect)(()=>{!J&&l.length>0&&F.current?.scrollIntoView()},[J]),(0,L.useEffect)(()=>{h&&H&&G()},[h,G,H]);let{data:Y=[]}=o({queryKey:[`modified-files`,t,r],queryFn:()=>_.chat.getModifiedFiles(t,r),enabled:!!t&&!!r}),[ce,le]=(0,L.useState)(!1),[ue,de]=(0,L.useState)(!1),X=K.find(e=>e.sessionId===r),Z=X?.source===`ide`,Q=X?.workspacePath,{data:fe}=o({queryKey:[`git-branch`,Q],queryFn:()=>_.chat.getGitBranches([Q]),enabled:!!Q,staleTime:3e4}),$=Q?fe?.[Q]:null,pe=(0,L.useMemo)(()=>U(l),[l]),me=(0,L.useMemo)(()=>{let e=[],t={user:null,replies:[]};for(let n of l)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},[l]),he=(0,L.useMemo)(()=>ie(l),[l]),{isActive:ge}=R(t,r,Z??!1,l.length,oe);return(0,L.useEffect)(()=>{if(!b&&(h||y.length>0)&&t&&r){let e=M();e&&(e.content||e.toolCalls.length>0)&&u(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}))}])}},[b,h,y,t,r,M]),(0,z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,z.jsxs)(`div`,{className:`border-b px-4 py-2 shrink-0 space-y-1.5`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(m,{variant:`ghost`,size:`sm`,onClick:()=>s(`/chat/${t}`),children:`← Back`}),(0,z.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,z.jsx)(`h1`,{className:`text-sm font-medium truncate`,children:X?.name??r})}),X&&(0,z.jsx)(p,{variant:`secondary`,children:X.mode}),ge&&(0,z.jsxs)(p,{variant:`outline`,className:`gap-1 text-green-500 border-green-500/30`,children:[(0,z.jsx)(I,{className:`h-3 w-3 animate-pulse`}),`Live`]})]}),Q&&(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground truncate`,children:[(0,z.jsx)(E,{className:`h-3 w-3 shrink-0`}),(0,z.jsx)(`span`,{className:`truncate`,title:Q,children:X?.workspaceName??Q.split(`/`).pop()}),$&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,z.jsx)(S,{className:`h-3 w-3 shrink-0`}),(0,z.jsx)(`span`,{className:`truncate font-mono`,title:$,children:$})]})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[K.length>1&&(0,z.jsx)(`select`,{className:`text-xs border rounded px-1.5 py-0.5 bg-background max-w-[200px] truncate`,value:r,onChange:e=>s(`/chat/${t}/${e.target.value}`,{replace:!0}),children:K.map(e=>(0,z.jsxs)(`option`,{value:e.sessionId,children:[e.name,` (`,new Date(e.createdAt).toLocaleDateString(),`)`]},e.sessionId))}),(0,z.jsx)(`div`,{className:`flex-1`}),Q&&(0,z.jsxs)(m,{variant:`outline`,size:`sm`,onClick:()=>de(!0),className:`gap-1.5 text-xs`,title:e(`chat.openWorkspaceEditor`),children:[(0,z.jsx)(P,{className:`h-3 w-3`}),`Editor`]}),Z&&X?.workspacePath&&(0,z.jsxs)(m,{variant:`outline`,size:`sm`,onClick:()=>window.open(`cursor://file/${X.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,z.jsx)(w,{className:`h-3 w-3`}),`Cursor`]}),(0,z.jsx)(m,{variant:`ghost`,size:`sm`,onClick:async()=>{!t||!r||confirm(e(`chat.deleteConfirm`))&&(await _.chat.deleteSession(t,r),c.invalidateQueries({queryKey:[`chat-sessions`,t]}),s(`/chat/${t}`))},className:`text-muted-foreground hover:text-destructive`,title:e(`common.deleteSession`),children:(0,z.jsx)(k,{className:`h-4 w-4`})})]}),Y.length>0&&(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`button`,{onClick:()=>le(e=>!e),className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[ce?(0,z.jsx)(d,{className:`h-3 w-3`}):(0,z.jsx)(D,{className:`h-3 w-3`}),(0,z.jsx)(te,{className:`h-3 w-3`}),Y.length,` modified file`,Y.length>1?`s`:``]}),ce&&(0,z.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:Y.map(e=>(0,z.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,z.jsxs)(`span`,{className:`text-muted-foreground`,children:[`×`,e.count]})]},e.path))})]})]}),(0,z.jsx)(`div`,{className:`relative flex-1 overflow-y-auto min-h-0`,ref:B,onScroll:ae,children:(0,z.jsxs)(`div`,{className:`p-3`,children:[J&&(0,z.jsx)(`div`,{className:`flex flex-col gap-1`,children:(0,z.jsx)(A,{count:5})}),!J&&l.length===0&&(0,z.jsx)(`div`,{className:`text-center text-muted-foreground py-12`,children:e(`chat.noMessages`)}),!J&&l.length>0&&me.map((e,t)=>(0,z.jsxs)(`div`,{children:[e.user&&(0,z.jsx)(`div`,{className:`sticky top-0 z-10 py-1`,children:(0,z.jsx)(v,{role:e.user.role,content:e.user.content,compact:!0})}),(0,z.jsx)(`div`,{className:`flex flex-col gap-1 pt-1`,children:e.replies.map(e=>(0,z.jsx)(v,{role:e.role,content:e.content,thinking:e.thinking,toolCalls:e.toolCalls,aggregatedUsage:he.get(e.id)},e.id))})]},e.user?.id??`group-${t}`)),b&&(h||g||y.length>0)&&(0,z.jsx)(v,{role:`assistant`,content:h,thinking:g,toolCalls:y.map(e=>({id:e.id,name:e.name,input:e.input,output:e.pending?void 0:e.output}))}),b&&!h&&!g&&y.length===0&&(0,z.jsx)(`div`,{className:`flex justify-start`,children:(0,z.jsx)(`div`,{className:`bg-muted rounded-lg px-4 py-2 text-sm text-muted-foreground`,children:e(`common.thinking`)})}),x&&(0,z.jsx)(`div`,{className:`text-center text-destructive text-sm`,children:x}),(0,z.jsx)(`div`,{ref:F})]})}),!H&&(0,z.jsx)(`div`,{className:`pointer-events-none flex justify-end px-4 -mt-12 mb-1 relative z-10`,children:(0,z.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:G,children:(0,z.jsx)(ee,{className:`h-4 w-4`})})}),(0,z.jsxs)(`div`,{className:`shrink-0`,children:[Z&&!b&&(0,z.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,z.jsx)(N,{onSend:async n=>{if(!(!t||!r)){u(e=>[...e,{id:`temp-${Date.now()}`,role:`user`,content:n}]),setTimeout(G,0);try{let{streamId:e}=Z?await _.chat.resumeSession(t,r,n):await _.chat.sendMessage(t,r,n);j(e)}catch(t){u(n=>[...n,{id:`error-${Date.now()}`,role:`assistant`,content:`Error: ${t instanceof Error?t.message:e(`chat.failedToSend`)}`}])}}},onStop:()=>{T&&_.chat.stopStream(T).catch(()=>{}),re()},isStreaming:b,disabled:J,workspacePath:X?.workspacePath,contextUsage:pe})]}),Q&&(0,z.jsx)(V,{open:ue,onOpenChange:de,workspacePath:Q,modifiedFiles:Y,projectHash:t,sessionId:r})]})}export{G as Chat};
@@ -0,0 +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};