@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.
- package/commands/doctor.d.ts +12 -0
- package/commands/doctor.d.ts.map +1 -0
- package/commands/doctor.js +110 -0
- package/commands/doctor.js.map +1 -0
- package/{dist/commands → commands}/gateway/start.d.ts.map +1 -1
- package/{dist/commands → commands}/gateway/start.js +14 -0
- package/commands/gateway/start.js.map +1 -0
- package/{dist/commands → commands}/setup.d.ts.map +1 -1
- package/{dist/commands → commands}/setup.js +19 -0
- package/commands/setup.js.map +1 -0
- package/externals.json +13 -0
- package/lib/doctor.d.ts +28 -0
- package/lib/doctor.d.ts.map +1 -0
- package/lib/doctor.js +227 -0
- package/lib/doctor.js.map +1 -0
- package/{dist/openapi.yml → openapi.yml} +770 -0
- package/package.json +14 -32
- package/prisma/migrations/20260401135027_add_auth_rbac_multitenancy/migration.sql +211 -0
- package/{dist/prisma → prisma}/schema.prisma +101 -0
- package/server.js +81901 -0
- package/server.js.map +1 -0
- package/{dist/web/assets/activity-feed-D_eonDKG.js → web/assets/activity-feed-CNgi7Qb_.js} +1 -1
- package/web/assets/agent-edit-CgbnHiT5.js +98 -0
- package/web/assets/agent-sessions-Bpay1_ZH.js +1 -0
- package/web/assets/agent-use-BaBxQ2fx.js +1 -0
- package/web/assets/agents-Dwbd6TQx.js +1 -0
- package/web/assets/api-DNWoqIPN.js +1 -0
- package/web/assets/arrow-down-upU5tcpi.js +1 -0
- package/web/assets/arrow-left-BiNeYcK0.js +1 -0
- package/web/assets/auth-client-ys1jC854.js +1 -0
- package/web/assets/chat-BP5H9CWl.js +4 -0
- package/{dist/web/assets/chat-input-BepRPV_L.js → web/assets/chat-input-CKAtAtgG.js} +2 -2
- package/{dist/web/assets/chat-message-CbcDeDcb.js → web/assets/chat-message-CW-HnO3f.js} +3 -3
- package/web/assets/chat-new-BQp9Bn7Q.js +1 -0
- package/web/assets/chat-sessions-D3bS5vba.js +1 -0
- package/web/assets/chats-DJolHH4e.js +1 -0
- package/{dist/web/assets/circle-alert-W8QX9LOG.js → web/assets/circle-alert-D040vPU_.js} +1 -1
- package/web/assets/circle-check-CW3adL8A.js +1 -0
- package/{dist/web/assets/circle-x-D_8Tcgt1.js → web/assets/circle-x-34c-1fVL.js} +1 -1
- package/web/assets/code-BFUT4gGT.js +1 -0
- package/{dist/web/assets/code-editor-x9L6nkh4.js → web/assets/code-editor-I6vK5q_W.js} +1 -1
- package/web/assets/commands-DBI4Bb2N.js +8 -0
- package/{dist/web/assets/copy-C87mjn_Y.js → web/assets/copy-DI5qjA1p.js} +1 -1
- package/web/assets/credentials-D8VN8A5M.js +1 -0
- package/{dist/web/assets/crown-BJEsQkh4.js → web/assets/crown-DWB5bSnq.js} +1 -1
- package/web/assets/dashboard-Cc6KWs62.js +1 -0
- package/{dist/web/assets/database-BohjTljV.js → web/assets/database-5jczNGML.js} +1 -1
- package/web/assets/debug-DewdHeoW.js +1 -0
- package/{dist/web/assets/download-B2UOiYAS.js → web/assets/download-CwO6xusv.js} +1 -1
- package/{dist/web/assets/eye-DN-Km5vf.js → web/assets/eye-BQGasWwb.js} +1 -1
- package/{dist/web/assets/file-plus-B8qWemgt.js → web/assets/file-plus-kHgvf9P8.js} +1 -1
- package/web/assets/file-tree-CTe61XCg.js +1 -0
- package/{dist/web/assets/folder-plus-DsmP6Mur.js → web/assets/folder-plus-mZAz-QpJ.js} +1 -1
- package/{dist/web/assets/globe-fwFSeXZn.js → web/assets/globe-C0WHVFW_.js} +1 -1
- package/{dist/web/assets/grip-vertical-Djo-yR-o.js → web/assets/grip-vertical-CdhrWSnV.js} +1 -1
- package/{dist/web/assets/history-CyBBboEp.js → web/assets/history-w7qYglj5.js} +1 -1
- package/web/assets/index-9X_UIor3.css +2 -0
- package/web/assets/index-DWNLSHpo.js +4 -0
- package/web/assets/key-DJEQ_jUi.js +1 -0
- package/{dist/web/assets/layers-ephyCrDm.js → web/assets/layers-KZu6CpGE.js} +1 -1
- package/{dist/web/assets/layout-grid-DCVGg8ZA.js → web/assets/layout-grid-U17jhSjz.js} +1 -1
- package/web/assets/login-DoSA7KtI.js +1 -0
- package/web/assets/mcp-setup-Cyj1YAiY.js +17 -0
- package/web/assets/memory-DWZU2Tfl.js +1 -0
- package/web/assets/new-chat-BRS3DM8Z.js +1 -0
- package/web/assets/play-BzkxV_O-.js +1 -0
- package/{dist/web/assets/refresh-cw-RFYUf5GB.js → web/assets/refresh-cw-D3_GZ86i.js} +1 -1
- package/web/assets/register-BS5OkCgS.js +1 -0
- package/web/assets/rotate-ccw-CkJIdGxi.js +1 -0
- package/{dist/web/assets/save-Dewm93H6.js → web/assets/save-BXEZF80P.js} +1 -1
- package/web/assets/search-BmZSwFnA.js +1 -0
- package/{dist/web/assets/send-FWvygYFQ.js → web/assets/send-CNiXC6KO.js} +1 -1
- package/web/assets/server-C5bKQLDi.js +1 -0
- package/web/assets/settings-CBAhSOZM.js +1 -0
- package/web/assets/shield-CMMTdOiM.js +1 -0
- package/{dist/web/assets/shield-check-Dt7sXtBF.js → web/assets/shield-check-BmphmMlD.js} +1 -1
- package/{dist/web/assets/shuffle-DjvBJ7XV.js → web/assets/shuffle-Dv_-PFl5.js} +1 -1
- package/web/assets/src-CaF63bXY.js +24 -0
- package/web/assets/sse-url-qohTy4Sw.js +1 -0
- package/web/assets/team-edit-BW1bePKn.js +1 -0
- package/web/assets/team-sessions-GspGc7zN.js +1 -0
- package/web/assets/team-use-BVC7nt9K.js +3 -0
- package/web/assets/terminal-CjSFIwMK.js +1 -0
- package/{dist/web/assets/timer-C9X20mTO.js → web/assets/timer-3siC9tpd.js} +1 -1
- package/{dist/web/assets/useMutation-BlOHt3MR.js → web/assets/useMutation-DA8-TvTt.js} +1 -1
- package/{dist/web/assets/utils-DHTPP40O.js → web/assets/utils-D1nRmcA6.js} +1 -1
- package/web/assets/workflow-edit-DkmsARCv.js +4 -0
- package/web/assets/workflow-runs-DcJPL7Bo.js +1 -0
- package/web/assets/workflows-Dnx0dwJn.js +1 -0
- package/{dist/web/assets/wrench-DZBtSPP8.js → web/assets/wrench-u8B_fDwT.js} +1 -1
- package/{dist/web/assets/zap-CbT5plGA.js → web/assets/zap-hOn7wkXe.js} +1 -1
- package/{dist/web → web}/index.html +9 -7
- package/README.md +0 -33
- package/dist/commands/gateway/start.js.map +0 -1
- package/dist/commands/setup.js.map +0 -1
- package/dist/server.js +0 -38234
- package/dist/server.js.map +0 -1
- package/dist/web/assets/agent-edit-CblZItU5.js +0 -98
- package/dist/web/assets/agent-sessions-COpCcffa.js +0 -1
- package/dist/web/assets/agent-use-F4pOt3KJ.js +0 -1
- package/dist/web/assets/agents-Av7w2wHE.js +0 -1
- package/dist/web/assets/arrow-down-XHN5PD1k.js +0 -1
- package/dist/web/assets/arrow-left-wtNmm6Le.js +0 -1
- package/dist/web/assets/chat-CQvfLy7Y.js +0 -4
- package/dist/web/assets/chat-new-BOtDuYij.js +0 -1
- package/dist/web/assets/chat-sessions-CaCaK_PC.js +0 -1
- package/dist/web/assets/chats-64IReeGV.js +0 -1
- package/dist/web/assets/circle-check-DLl9fl65.js +0 -1
- package/dist/web/assets/code-Brz4KHlI.js +0 -1
- package/dist/web/assets/commands-DT9K8bae.js +0 -8
- package/dist/web/assets/credentials-DC-HOVxW.js +0 -1
- package/dist/web/assets/dashboard-OfnNUjFX.js +0 -1
- package/dist/web/assets/debug-Et9rgBM8.js +0 -1
- package/dist/web/assets/file-tree-DkLQ1z0I.js +0 -1
- package/dist/web/assets/index-YgjFlLLv.css +0 -2
- package/dist/web/assets/index-dc8HGqTp.js +0 -2
- package/dist/web/assets/mcp-setup-BfMdYdsI.js +0 -17
- package/dist/web/assets/memory-DAQ474-p.js +0 -1
- package/dist/web/assets/new-chat-DtMw6FMg.js +0 -1
- package/dist/web/assets/play-DXJMtO-K.js +0 -1
- package/dist/web/assets/search-Ww0msJQz.js +0 -1
- package/dist/web/assets/settings-Auyn4Z5T.js +0 -1
- package/dist/web/assets/src-DUhGoAQb.js +0 -24
- package/dist/web/assets/team-edit-DO-RX3lC.js +0 -1
- package/dist/web/assets/team-sessions-DSw8MTtZ.js +0 -1
- package/dist/web/assets/team-use-BfNvsFcO.js +0 -3
- package/dist/web/assets/terminal-CIapYonS.js +0 -1
- package/dist/web/assets/workflow-edit-D0FNyl64.js +0 -4
- package/dist/web/assets/workflow-runs-CPVvaVzN.js +0 -1
- package/dist/web/assets/workflows-C9jurJiE.js +0 -1
- /package/{dist/commands → commands}/gateway/start.d.ts +0 -0
- /package/{dist/commands → commands}/gateway/stop.d.ts +0 -0
- /package/{dist/commands → commands}/gateway/stop.d.ts.map +0 -0
- /package/{dist/commands → commands}/gateway/stop.js +0 -0
- /package/{dist/commands → commands}/gateway/stop.js.map +0 -0
- /package/{dist/commands → commands}/setup.d.ts +0 -0
- /package/{dist/commands → commands}/setup.spec.d.ts +0 -0
- /package/{dist/commands → commands}/setup.spec.d.ts.map +0 -0
- /package/{dist/commands → commands}/setup.spec.js +0 -0
- /package/{dist/commands → commands}/setup.spec.js.map +0 -0
- /package/{dist/commands → commands}/uninstall.d.ts +0 -0
- /package/{dist/commands → commands}/uninstall.d.ts.map +0 -0
- /package/{dist/commands → commands}/uninstall.js +0 -0
- /package/{dist/commands → commands}/uninstall.js.map +0 -0
- /package/{dist/index.d.ts → index.d.ts} +0 -0
- /package/{dist/index.d.ts.map → index.d.ts.map} +0 -0
- /package/{dist/index.js → index.js} +0 -0
- /package/{dist/index.js.map → index.js.map} +0 -0
- /package/{dist/lib → lib}/gateway.d.ts +0 -0
- /package/{dist/lib → lib}/gateway.d.ts.map +0 -0
- /package/{dist/lib → lib}/gateway.js +0 -0
- /package/{dist/lib → lib}/gateway.js.map +0 -0
- /package/{dist/lib → lib}/shell-profile.d.ts +0 -0
- /package/{dist/lib → lib}/shell-profile.d.ts.map +0 -0
- /package/{dist/lib → lib}/shell-profile.js +0 -0
- /package/{dist/lib → lib}/shell-profile.js.map +0 -0
- /package/{dist/migrations → migrations}/0001-add-memory-enabled.js +0 -0
- /package/{dist/migrations → migrations}/lib/helpers.js +0 -0
- /package/{dist/migrations → migrations}/lib/template.js +0 -0
- /package/{dist/prisma → prisma}/migrations/20260318152538_add_trigger_type_and_source_workflow/migration.sql +0 -0
- /package/{dist/prisma → prisma}/migrations/20260318154232_drop_skill_and_emit_from_action/migration.sql +0 -0
- /package/{dist/prisma → prisma}/migrations/20260318160029_action_types_cli_bash_node_http/migration.sql +0 -0
- /package/{dist/prisma → prisma}/migrations/20260401085053_schema_sync/migration.sql +0 -0
- /package/{dist/prisma → prisma}/migrations/migration_lock.toml +0 -0
- /package/{dist/web/assets/api-docs-BQzn4-6U.js → web/assets/api-docs-DgRFxVfh.js} +0 -0
- /package/{dist/web/assets/bi-gM8sIAZV.js → web/assets/bi-Da3wz7XD.js} +0 -0
- /package/{dist/web/assets/cron-COUPKvGu.js → web/assets/cron-3VyztcE9.js} +0 -0
- /package/{dist/web → web}/assets/geist-cyrillic-wght-normal-CHSlOQsW.woff2 +0 -0
- /package/{dist/web → web}/assets/geist-latin-ext-wght-normal-DMtmJ5ZE.woff2 +0 -0
- /package/{dist/web → web}/assets/geist-latin-wght-normal-Dm3htQBi.woff2 +0 -0
- /package/{dist/web → web}/assets/rolldown-runtime-Dw2cE7zH.js +0 -0
- /package/{dist/web → web}/assets/useQuery-DvovkaPT.js +0 -0
- /package/{dist/web/assets/vendor-editor-BORFA-rZ.js → web/assets/vendor-editor-Cx3Ogh9u.js} +0 -0
- /package/{dist/web → web}/assets/vendor-react-BJ8SIkmN.js +0 -0
- /package/{dist/web → web}/assets/vendor-ui-CHpVij2M.css +0 -0
- /package/{dist/web/assets/vendor-ui-Dpw9mBc-.js → web/assets/vendor-ui-DnL9d3od.js} +0 -0
- /package/{dist/web → web}/docs.html +0 -0
- /package/{dist/web → web}/favicon.svg +0 -0
|
@@ -1,98 +0,0 @@
|
|
|
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};
|
|
@@ -1 +0,0 @@
|
|
|
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};
|
|
@@ -1 +0,0 @@
|
|
|
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};
|
|
@@ -1 +0,0 @@
|
|
|
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};
|
|
@@ -1 +0,0 @@
|
|
|
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};
|
|
@@ -1 +0,0 @@
|
|
|
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};
|
|
@@ -1,4 +0,0 @@
|
|
|
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};
|
|
@@ -1 +0,0 @@
|
|
|
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{t as a}from"./useQuery-DvovkaPT.js";import{V as o,b as s,q as c}from"./src-DUhGoAQb.js";import{t as l}from"./chat-message-CbcDeDcb.js";import{g as u,n as d}from"./index-dc8HGqTp.js";import{t as f}from"./chat-input-BepRPV_L.js";var p=e(n(),1),m=i();function h(){let[e]=t(),n=r(),i=e.get(`workspace`)??``,h=i.split(`/`).pop()??i,[g,_]=(0,p.useState)([]),[v]=(0,p.useState)(()=>`new/${Date.now()}`),[y,b]=(0,p.useState)(`cursor`),{data:x}=a({queryKey:[`cli-agents`],queryFn:()=>c.settings.getCliAgents(),staleTime:6e4}),S=(x?.agents??[]).filter(e=>e.installed),{streamingContent:C,isStreaming:w,error:T,streamId:E,startStream:D,stopStream:O,consumeStream:k}=u(v),A=(0,p.useRef)(null),j=async e=>{if(i){_(t=>[...t,{id:`temp-${Date.now()}`,role:`user`,content:e}]);try{let{streamId:t}=await c.chat.startNew(i,e,y||void 0);D(t)}catch(e){_(t=>[...t,{id:`error-${Date.now()}`,role:`assistant`,content:`Error: ${e instanceof Error?e.message:`Failed to start session`}`}])}}},M=()=>{E&&c.chat.stopStream(E).catch(()=>{}),O()};if(!w&&C&&g[g.length-1]?.role!==`assistant`){let e=k();e?.content&&_(t=>[...t,{id:`stream-${Date.now()}`,role:`assistant`,content:e.content}])}return(0,m.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,m.jsxs)(`div`,{className:`flex items-center gap-3 border-b px-4 py-3`,children:[(0,m.jsx)(o,{variant:`ghost`,size:`sm`,onClick:()=>n(`/new`),children:`← Back`}),(0,m.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,m.jsxs)(`h1`,{className:`text-sm font-medium truncate`,children:[`New chat — `,h]}),(0,m.jsx)(`p`,{className:`text-xs text-muted-foreground truncate`,children:i})]}),S.length>0&&(0,m.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,m.jsx)(d(S.find(e=>e.id===y)?.icon??y),{className:`h-4 w-4 text-muted-foreground`}),(0,m.jsx)(`select`,{value:y,onChange:e=>b(e.target.value),className:`h-8 rounded-md border border-input bg-background px-2 text-xs`,children:S.map(e=>(0,m.jsx)(`option`,{value:e.id,children:e.label},e.id))})]})]}),(0,m.jsx)(s,{className:`flex-1`,ref:A,children:(0,m.jsxs)(`div`,{className:`flex flex-col gap-1 p-3`,children:[g.length===0&&(0,m.jsx)(`div`,{className:`text-center text-muted-foreground py-12`,children:`Start a new conversation with the agent`}),g.map(e=>(0,m.jsx)(l,{role:e.role,content:e.content,thinking:e.thinking,toolCalls:e.toolCalls},e.id)),w&&C&&(0,m.jsx)(l,{role:`assistant`,content:C}),w&&!C&&(0,m.jsx)(`div`,{className:`flex justify-start`,children:(0,m.jsx)(`div`,{className:`bg-muted rounded-lg px-4 py-2 text-sm text-muted-foreground`,children:`Thinking...`})}),T&&(0,m.jsx)(`div`,{className:`text-center text-destructive text-sm`,children:T})]})}),(0,m.jsx)(f,{onSend:j,onStop:M,isStreaming:w,disabled:!i,workspacePath:i})]})}export{h as ChatNew};
|
|
@@ -1 +0,0 @@
|
|
|
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{B as s,I as c,L as l,U as u,V as d,q as f,z as p}from"./src-DUhGoAQb.js";import{t as m}from"./terminal-CIapYonS.js";import{F as h,k as g,s as _,v,w as y}from"./index-dc8HGqTp.js";var b=e(t(),1),x=r();function S(){let{t:e}=y(),{projectHash:t}=i(),r=n(),S=a(),[C,w]=(0,b.useState)(1),{data:T,isLoading:E}=o({queryKey:[`chat-sessions`,t,C,12],queryFn:()=>f.chat.getSessions(t,{page:C,pageSize:12}),enabled:!!t}),D=(0,b.useMemo)(()=>T?.data??[],[T?.data]);(0,b.useEffect)(()=>{!E&&D.length===1&&T?.total===1&&r(`/chat/${t}/${D[0].sessionId}`,{replace:!0})},[E,D,T?.total,t,r]);let O=async(n,r)=>{n.stopPropagation(),t&&confirm(e(`chatSessions.deleteConfirm`,{name:r.name}))&&(await f.chat.deleteSession(t,r.sessionId),S.invalidateQueries({queryKey:[`chat-sessions`,t]}))};return E?(0,x.jsx)(_,{}):D.length===0?(0,x.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4`,children:[(0,x.jsx)(`p`,{className:`text-muted-foreground`,children:e(`chatSessions.noSessions`)}),(0,x.jsx)(d,{variant:`outline`,onClick:()=>r(`/chats`),children:`← Back`})]}):(0,x.jsxs)(`div`,{className:`p-6`,children:[(0,x.jsxs)(`div`,{className:`mb-6 flex items-center gap-3`,children:[(0,x.jsx)(d,{variant:`ghost`,size:`sm`,onClick:()=>r(`/chats`),children:`← Back`}),(0,x.jsx)(`h1`,{className:`text-2xl font-bold`,children:e(`chatSessions.title`)}),(0,x.jsx)(u,{variant:`secondary`,children:T?.total??0})]}),(0,x.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:D.map(n=>(0,x.jsxs)(c,{className:`cursor-pointer transition-colors hover:border-primary/50`,onClick:()=>r(`/chat/${t}/${n.sessionId}`),children:[(0,x.jsx)(p,{className:`pb-2`,children:(0,x.jsxs)(s,{className:`text-sm font-medium truncate flex items-center gap-2`,children:[n.source===`cli`?(0,x.jsx)(m,{className:`h-4 w-4 shrink-0 text-muted-foreground`}):(0,x.jsx)(h,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),n.name]})}),(0,x.jsx)(l,{children:(0,x.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,x.jsx)(u,{variant:`secondary`,children:n.mode}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(`span`,{children:new Date(n.createdAt).toLocaleDateString()}),(0,x.jsx)(`button`,{onClick:e=>O(e,n),className:`text-muted-foreground hover:text-destructive transition-colors`,title:e(`common.deleteSession`),children:(0,x.jsx)(g,{className:`h-3.5 w-3.5`})})]})]})})]},n.sessionId))}),T&&(0,x.jsx)(v,{page:T.page,totalPages:T.totalPages,total:T.total,pageSize:T.pageSize,onPageChange:w,className:`mt-6`})]})}export{S as ChatSessions};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{h as t,l as n,t as r}from"./vendor-react-BJ8SIkmN.js";import{t as i}from"./useQuery-DvovkaPT.js";import{B as a,I as o,L as s,U as c,q as l,z as u}from"./src-DUhGoAQb.js";import{o as d,v as f,w as p}from"./index-dc8HGqTp.js";var m=e(t(),1),h=r();function g(){let{t:e}=p(),t=n(),[r,g]=(0,m.useState)(1),{data:_,isLoading:v}=i({queryKey:[`chat-workspaces`,r,12],queryFn:()=>l.chat.getWorkspaces({page:r,pageSize:12})}),y=_?.data??[];return(0,h.jsxs)(`div`,{className:`p-6`,children:[(0,h.jsxs)(`div`,{className:`mb-6`,children:[(0,h.jsx)(`h1`,{className:`text-2xl font-bold`,children:e(`chats.title`)}),(0,h.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:e(`chats.description`)})]}),v&&(0,h.jsx)(d,{count:6}),!v&&y.length===0&&(0,h.jsx)(`div`,{className:`text-muted-foreground text-center py-12`,children:e(`chats.noHistory`)}),!v&&y.length>0&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:y.map(e=>(0,h.jsxs)(o,{className:`cursor-pointer transition-colors hover:border-primary/50`,onClick:()=>t(`/chat/${e.projectHash}`),children:[(0,h.jsx)(u,{className:`pb-2`,children:(0,h.jsx)(a,{className:`text-sm font-medium truncate`,children:e.workspaceName})}),(0,h.jsx)(s,{children:(0,h.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,h.jsx)(`span`,{className:`text-xs text-muted-foreground truncate max-w-[70%]`,title:e.workspacePath,children:e.workspacePath}),(0,h.jsxs)(c,{variant:`secondary`,className:`text-xs`,children:[e.sessionCount,` session`,e.sessionCount>1?`s`:``]})]})})]},e.projectHash))}),_&&(0,h.jsx)(f,{page:_.page,totalPages:_.totalPages,total:_.total,pageSize:_.pageSize,onPageChange:g,className:`mt-6`})]})]})}export{g as Chats};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{F as e}from"./src-DUhGoAQb.js";var t=e(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]);export{t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{F as e}from"./src-DUhGoAQb.js";var t=e(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]);export{t};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{h as t,t as n}from"./vendor-react-BJ8SIkmN.js";import{r,t as i}from"./useQuery-DvovkaPT.js";import{A as ee,B as a,D as o,I as s,K as c,L as l,O as te,T as u,U as d,V as f,a as p,f as m,i as h,j as g,k as ne,n as _,q as v,r as y,w as b,z as x}from"./src-DUhGoAQb.js";import{t as S}from"./arrow-left-wtNmm6Le.js";import{t as C}from"./file-plus-B8qWemgt.js";import{t as w}from"./file-tree-DkLQ1z0I.js";import{t as T}from"./folder-plus-DsmP6Mur.js";import{t as E}from"./save-Dewm93H6.js";import{t as D}from"./terminal-CIapYonS.js";import"./utils-DHTPP40O.js";import{M as O,P as k,R as A,c as j,j as M,k as N,q as P,t as F,w as I}from"./index-dc8HGqTp.js";import{n as L,t as R}from"./code-editor-x9L6nkh4.js";var z=e(t(),1),B=n();function V({rootPath:e,header:t,className:n,minHeight:i=`500px`}){let{t:a}=I(),s=r(),[l,d]=(0,z.useState)([]),[p,m]=(0,z.useState)(null),[h,_]=(0,z.useState)(!1),[y,x]=(0,z.useState)(null),[S,D]=(0,z.useState)(``),[O,k]=(0,z.useState)(``),j=(0,z.useRef)(null),M=l.find(e=>e.path===p)??null,N=(0,z.useRef)(new Set),P=(0,z.useRef)(l);P.current=l;let V=(0,z.useCallback)(async e=>{if(P.current.some(t=>t.path===e)){m(e);return}if(!N.current.has(e)){N.current.add(e);try{let t=await v.fs.readFile(e),n={path:e,name:e.split(`/`).pop()??e,content:t.content,dirty:!1,etag:t.etag};d(t=>t.some(t=>t.path===e)?t:[...t,n]),m(e)}catch{F.error(a(`fileEditor.failedToOpen`))}finally{N.current.delete(e)}}},[a]),H=(0,z.useCallback)((e,t)=>{t?.stopPropagation();let n=l.find(t=>t.path===e);if(!(n?.dirty&&!confirm(a(`fileEditor.unsavedChanges`,{name:n.name})))&&(d(t=>t.filter(t=>t.path!==e)),p===e)){let t=l.filter(t=>t.path!==e);m(t.length>0?t[t.length-1].path:null)}},[l,p,a]),re=(0,z.useCallback)((e,t)=>{d(n=>n.map(n=>n.path===e?{...n,content:t,dirty:!0}:n))},[]),U=(0,z.useCallback)(async()=>{if(!(!M||!M.dirty)){_(!0);try{let e=await v.fs.writeFile(M.path,M.content);d(t=>t.map(t=>t.path===M.path?{...t,dirty:!1,etag:e.etag}:t)),F.success(a(`common.saved`))}catch{F.error(a(`common.failedToSave`))}finally{_(!1)}}},[M,a]),W=(0,z.useCallback)(async(e,t)=>{let n=t===`directory`?`folder`:`file`;if(confirm(a(`fileEditor.deleteConfirm`,{label:n,path:e})))try{await v.fs.deleteFile(e),d(t=>t.filter(t=>!t.path.startsWith(e))),p?.startsWith(e)&&m(null),s.invalidateQueries({queryKey:[`fs-tree`]}),F.success(a(`skills.deleted`,{label:n}))}catch{F.error(a(`skills.failedToDelete`,{label:n}))}},[p,s,a]),G=(0,z.useCallback)(e=>{x(`file`),D(e),k(``),setTimeout(()=>j.current?.focus(),100)},[]),K=(0,z.useCallback)(e=>{x(`folder`),D(e),k(``),setTimeout(()=>j.current?.focus(),100)},[]),q=(0,z.useCallback)(async()=>{if(!O.trim()||!y)return;let e=`${S}/${O.trim()}`;try{if(y===`folder`)await v.fs.mkdir(e);else{await v.fs.writeFile(e,``);let t={path:e,name:O.trim(),content:``,dirty:!1};d(e=>[...e,t]),m(e)}s.invalidateQueries({queryKey:[`fs-tree`]}),x(null)}catch{F.error(a(`fileEditor.failedToCreate`,{type:y}))}},[O,y,S,s,a]),ie=(0,z.useCallback)(async(e,t)=>{let n=e.split(`/`).pop()??e,r=`${t}/${n}`;try{await v.fs.move(e,r),d(t=>t.map(t=>{if(t.path===e)return{...t,path:r,name:n};if(t.path.startsWith(e+`/`)){let n=r+t.path.slice(e.length);return{...t,path:n}}return t})),p===e?m(r):p?.startsWith(e+`/`)&&m(r+p.slice(e.length)),s.invalidateQueries({queryKey:[`fs-tree`]}),F.success(a(`fileEditor.movedTo`,{folder:t.split(`/`).pop()??``}))}catch{F.error(a(`fileEditor.failedToMove`))}},[p,s,a]);return(0,B.jsxs)(`div`,{className:c(`flex border rounded-lg overflow-hidden bg-background`,n),style:{minHeight:i},children:[(0,B.jsxs)(`div`,{className:`w-56 shrink-0 border-r flex flex-col bg-muted/30`,children:[t&&(0,B.jsx)(`div`,{className:`p-2 border-b`,children:t}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1.5 border-b`,children:[(0,B.jsx)(f,{size:`icon`,variant:`ghost`,className:`h-6 w-6`,onClick:()=>G(e),title:a(`common.newFile`),children:(0,B.jsx)(C,{className:`h-3.5 w-3.5`})}),(0,B.jsx)(f,{size:`icon`,variant:`ghost`,className:`h-6 w-6`,onClick:()=>K(e),title:a(`common.newFolder`),children:(0,B.jsx)(T,{className:`h-3.5 w-3.5`})})]}),(0,B.jsx)(`div`,{className:`flex-1 overflow-auto py-1`,children:(0,B.jsx)(w,{rootPath:e,selectedFile:p,onSelectFile:V,onDelete:W,onNewFile:G,onNewFolder:K,onMove:ie})})]}),(0,B.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0`,children:[l.length>0&&(0,B.jsxs)(`div`,{className:`flex items-center border-b bg-muted/20 overflow-x-auto`,children:[l.map(e=>(0,B.jsxs)(`button`,{className:c(`flex items-center gap-1.5 px-3 py-1.5 text-xs border-r shrink-0 transition-colors`,e.path===p?`bg-background text-foreground`:`text-muted-foreground hover:bg-muted/50`),onClick:()=>m(e.path),children:[(0,B.jsxs)(`span`,{className:c(`truncate max-w-32`,e.dirty&&`italic`),children:[e.dirty&&`* `,e.name]}),(0,B.jsx)(g,{className:`h-3 w-3 shrink-0 opacity-50 hover:opacity-100`,onClick:t=>H(e.path,t)})]},e.path)),M?.dirty&&(0,B.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:U,disabled:h,children:[h?(0,B.jsx)(A,{className:`h-3 w-3 animate-spin`}):(0,B.jsx)(E,{className:`h-3 w-3`}),(0,B.jsx)(`span`,{className:`hidden sm:inline`,children:`Save`}),(0,B.jsx)(`kbd`,{className:`hidden sm:inline text-[10px] text-muted-foreground ml-1`,children:navigator.platform.includes(`Mac`)?`⌘S`:`Ctrl+S`})]})]}),(0,B.jsx)(`div`,{className:`flex-1 min-h-0`,children:M?(0,B.jsx)(R,{value:M.content,onChange:e=>re(M.path,e),language:L(M.name),onSave:U,minHeight:`100%`,className:`h-full border-0 rounded-none [&_.cm-editor]:h-full [&_.cm-scroller]:!overflow-auto`}):(0,B.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:`Select a file to edit`})})]}),(0,B.jsx)(u,{open:y!==null,onOpenChange:e=>!e&&x(null),children:(0,B.jsxs)(o,{className:`max-w-sm`,children:[(0,B.jsx)(ne,{children:(0,B.jsx)(ee,{children:y===`folder`?`New Folder`:`New File`})}),(0,B.jsx)(b,{ref:j,value:O,onChange:e=>k(e.target.value),placeholder:y===`folder`?`folder-name`:`filename.md`,onKeyDown:e=>e.key===`Enter`&&q()}),(0,B.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`in `,S]}),(0,B.jsxs)(te,{children:[(0,B.jsx)(f,{variant:`outline`,onClick:()=>x(null),children:`Cancel`}),(0,B.jsx)(f,{onClick:q,disabled:!O.trim(),children:`Create`})]})]})})]})}var H=`.local/skills`,re=`---
|
|
2
|
-
description: Short description of what this skill does
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Skill Name
|
|
6
|
-
|
|
7
|
-
Instructions for the agent when this skill is invoked.
|
|
8
|
-
`;function U(){let{t:e}=I(),t=r(),[n,c]=(0,z.useState)(!1),[g,C]=(0,z.useState)(`command`),[w,T]=(0,z.useState)(``),[E,A]=(0,z.useState)(!1),[L,R]=(0,z.useState)(``),[U,W]=(0,z.useState)(null),[G,K]=(0,z.useState)(new Map),{data:q,isLoading:ie}=i({queryKey:[`commands`,`custom`],queryFn:()=>v.commands.list({page:1,pageSize:100}),staleTime:3e4}),{data:J,isLoading:ae}=i({queryKey:[`commands`,`all`],queryFn:()=>v.chat.getCommands(),staleTime:3e4}),oe=ie||ae,Y=(0,z.useMemo)(()=>q?.data??[],[q?.data]),X=(0,z.useMemo)(()=>{let e=new Map;if(J)for(let t of J)e.set(t.name,t.enabled);for(let t of Y){let n=`/${t.slug}`;e.has(n)||e.set(n,!0)}for(let[t,n]of G)e.set(t,n);return e},[J,Y,G]),Z=(0,z.useMemo)(()=>{if(!J)return[];let e=new Set(Y.map(e=>`/${e.slug}`));return J.filter(t=>!e.has(t.name))},[J,Y]),Q=()=>{t.invalidateQueries({queryKey:[`commands`]})},$=(0,z.useCallback)(e=>{if(!e.sourcePath)return null;if(!e.sourcePath.endsWith(`.md`))return{rootPath:e.sourcePath,label:e.name};let t=e.sourcePath.split(`/`);return t.pop(),{rootPath:t.join(`/`),label:e.name}},[]),se=(0,z.useCallback)(e=>{let t=J?.find(t=>t.name===`/${e.slug}`);if(t?.sourcePath){let e=$(t);if(e){W(e);return}}W({rootPath:`.local/commands`,label:`/${e.slug}`})},[J,$]),ce=(0,z.useCallback)(e=>{let t=$(e);t&&W(t)},[$]),le=()=>{C(`command`),T(``),R(``),c(!0)},ue=()=>{C(`skill`),T(``),R(``),c(!0)},de=async()=>{if(!w.trim()){R(e(`common.nameRequired`));return}if(!/^[a-zA-Z0-9_-]+$/.test(w)){R(e(`commands.invalidName`));return}A(!0);try{if(g===`skill`){let n=`${H}/${w}`;await v.fs.mkdir(`${n}/techniques`),await v.fs.mkdir(`${n}/scripts`),await v.fs.writeFile(`${n}/SKILL.md`,re),t.invalidateQueries({queryKey:[`fs-tree`]}),c(!1),Q(),W({rootPath:n,label:`/${w}`}),F.success(e(`commands.skillCreated`,{name:w}))}else await v.commands.save(w,`# ${w}\n\nInstructions...\n`),c(!1),Q(),W({rootPath:`.local/commands`,label:`/${w}`}),F.success(e(`commands.commandCreated`,{name:w}))}catch(t){R(t instanceof Error?t.message:e(`commands.createError`))}finally{A(!1)}},fe=async e=>{let n=X.get(e)??!0;K(t=>new Map(t).set(e,!n));try{await v.skillPreferences.toggle(e),t.invalidateQueries({queryKey:[`commands`,`all`]}),K(t=>{let n=new Map(t);return n.delete(e),n})}catch{K(t=>new Map(t).set(e,n))}},pe=async t=>{if(confirm(e(`commands.deleteConfirm`,{name:t.slug})))try{await v.commands.delete(t.slug),Q(),U?.label===`/${t.slug}`&&W(null)}catch{}};return U?(0,B.jsxs)(`div`,{className:`flex flex-col h-[calc(100vh-3.5rem)]`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2 border-b bg-muted/20`,children:[(0,B.jsxs)(f,{variant:`ghost`,size:`sm`,onClick:()=>W(null),children:[(0,B.jsx)(S,{className:`h-4 w-4 mr-1`}),`Back`]}),(0,B.jsx)(`span`,{className:`text-sm font-mono`,children:U.label}),(0,B.jsx)(d,{variant:`secondary`,className:`text-[10px]`,children:U.rootPath})]}),(0,B.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,B.jsx)(V,{rootPath:U.rootPath,className:`h-full border-0 rounded-none`,minHeight:`100%`},U.rootPath)})]}):oe?(0,B.jsxs)(`div`,{className:`p-6`,children:[(0,B.jsx)(`div`,{className:`mb-6 flex items-center justify-between`,children:(0,B.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Commands & Skills`})}),(0,B.jsx)(j,{})]}):(0,B.jsxs)(`div`,{className:`p-6`,children:[(0,B.jsxs)(`div`,{className:`mb-6 flex items-center justify-between`,children:[(0,B.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Commands & Skills`}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsxs)(f,{variant:`outline`,onClick:ue,children:[(0,B.jsx)(M,{className:`h-4 w-4 mr-2`}),`New Skill`]}),(0,B.jsxs)(f,{onClick:le,children:[(0,B.jsx)(O,{className:`h-4 w-4 mr-2`}),`New Command`]})]})]}),(0,B.jsxs)(_,{defaultValue:`custom`,children:[(0,B.jsxs)(h,{children:[(0,B.jsx)(p,{value:`custom`,children:e(`commands.customTab`,{count:Y.length})}),(0,B.jsx)(p,{value:`available`,children:e(`commands.availableTab`,{count:Z.length})})]}),(0,B.jsx)(y,{value:`custom`,className:`mt-4`,children:Y.length===0?(0,B.jsxs)(`div`,{className:`text-muted-foreground text-center py-12`,children:[e(`commands.noCustom`),` `,(0,B.jsx)(`button`,{onClick:le,className:`underline`,children:e(`commands.createCommand`)}),` or `,(0,B.jsx)(`button`,{onClick:ue,className:`underline`,children:e(`commands.createSkill`)})]}):(0,B.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:Y.map(e=>(0,B.jsxs)(s,{className:X.get(`/${e.slug}`)??!0?``:`opacity-50`,children:[(0,B.jsx)(x,{className:`pb-2`,children:(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsxs)(a,{className:`text-sm font-medium flex items-center gap-2`,children:[(0,B.jsx)(D,{className:`h-4 w-4 text-muted-foreground`}),`/`,e.slug]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,B.jsx)(m,{checked:X.get(`/${e.slug}`)??!0,onCheckedChange:()=>fe(`/${e.slug}`)}),(0,B.jsx)(f,{size:`icon`,variant:`ghost`,className:`h-7 w-7`,onClick:()=>se(e),children:(0,B.jsx)(k,{className:`h-3.5 w-3.5`})}),(0,B.jsx)(f,{size:`icon`,variant:`ghost`,className:`h-7 w-7 text-destructive`,onClick:()=>pe(e),children:(0,B.jsx)(N,{className:`h-3.5 w-3.5`})})]})]})}),(0,B.jsxs)(l,{children:[e.name!==e.slug&&(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground mb-2`,children:e.name}),(0,B.jsxs)(`pre`,{className:`text-xs text-muted-foreground bg-muted rounded p-2 max-h-32 overflow-auto whitespace-pre-wrap`,children:[e.content.slice(0,300),e.content.length>300?`...`:``]}),(0,B.jsxs)(d,{variant:`secondary`,className:`mt-2 text-[10px]`,children:[`.local/commands/`,e.slug,`.md`]})]})]},e.slug))})}),(0,B.jsx)(y,{value:`available`,className:`mt-4`,children:Z.length===0?(0,B.jsx)(`div`,{className:`text-muted-foreground text-center py-12`,children:e(`commands.noWorkspace`)}):(0,B.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:Z.map(e=>(0,B.jsx)(s,{className:`py-3${X.get(e.name)??!0?``:` opacity-50`}`,children:(0,B.jsx)(l,{className:`pb-0 pt-0 px-4`,children:(0,B.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,B.jsx)(P,{className:`h-4 w-4 text-muted-foreground mt-0.5 shrink-0`}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`p`,{className:`text-sm font-medium truncate`,children:e.name}),e.description&&(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground truncate`,children:e.description}),(0,B.jsx)(d,{variant:`outline`,className:`mt-1 text-[10px]`,children:e.source})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0 mt-0.5`,children:[e.sourcePath&&(0,B.jsx)(f,{size:`icon`,variant:`ghost`,className:`h-7 w-7`,onClick:()=>ce(e),title:`Edit`,children:(0,B.jsx)(k,{className:`h-3.5 w-3.5`})}),(0,B.jsx)(m,{checked:X.get(e.name)??!0,onCheckedChange:()=>fe(e.name)})]})]})})},e.name))})})]}),(0,B.jsx)(u,{open:n,onOpenChange:c,children:(0,B.jsxs)(o,{className:`max-w-sm`,children:[(0,B.jsx)(ne,{children:(0,B.jsx)(ee,{children:g===`skill`?`New Skill`:e(`commands.newCommand`)})}),(0,B.jsxs)(`div`,{className:`space-y-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`label`,{className:`text-sm font-medium`,children:e(`common.name`)}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2 mt-1`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`/`}),(0,B.jsx)(b,{value:w,onChange:e=>T(e.target.value),placeholder:g===`skill`?`my-skill`:`my-command`,onKeyDown:e=>e.key===`Enter`&&de(),autoFocus:!0})]})]}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(g===`skill`?`commands.skillHelp`:`commands.commandHelp`,{slug:w||`...`})}),L&&(0,B.jsx)(`p`,{className:`text-sm text-destructive`,children:L})]}),(0,B.jsxs)(te,{children:[(0,B.jsx)(f,{variant:`outline`,onClick:()=>c(!1),children:e(`common.cancel`)}),(0,B.jsx)(f,{onClick:de,disabled:E||!w.trim(),children:e(E?`common.creating`:`commands.createAndEdit`)})]})]})})]})}export{U as Commands};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{h as t,t as n}from"./vendor-react-BJ8SIkmN.js";import{r,t as i}from"./useQuery-DvovkaPT.js";import{A as a,D as o,F as s,I as c,L as l,O as u,T as d,U as f,V as p,k as m,q as h,w as g}from"./src-DUhGoAQb.js";import{M as _,P as v,k as y,t as b,w as x,z as S}from"./index-dc8HGqTp.js";var C=s(`file-key`,[[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M4 12v6`,key:`bg1pfk`}],[`path`,{d:`M4 14h2`,key:`1sf9f8`}],[`path`,{d:`M9.65 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v4`,key:`d56i0q`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),w=s(`key`,[[`path`,{d:`m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4`,key:`g0fldk`}],[`path`,{d:`m21 2-9.6 9.6`,key:`1j0ho8`}],[`circle`,{cx:`7.5`,cy:`15.5`,r:`5.5`,key:`yqb3hr`}]]),T=s(`shield`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]),E=e(t(),1),D=n(),O={bearer:T,basic:S,"api-key":w,"custom-header":C},k={bearer:`credentials.bearerToken`,basic:`credentials.basicAuth`,"api-key":`credentials.apiKey`,"custom-header":`credentials.customHeaders`},A=`flex h-9 w-full rounded-md border border-input bg-background px-3 py-1 text-sm shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,j={name:``,type:`bearer`,token:``,username:``,password:``,apiKeyName:``,apiKeyValue:``,apiKeyAddTo:`header`,customHeaders:[{key:``,value:``}]};function M(e){switch(e.type){case`bearer`:return{token:e.token};case`basic`:return{username:e.username,password:e.password};case`api-key`:return{key:e.apiKeyName,value:e.apiKeyValue,addTo:e.apiKeyAddTo};case`custom-header`:return{headers:e.customHeaders.filter(e=>e.key.trim())}}}function N(e,t){switch(e){case`bearer`:return{token:t.token??``};case`basic`:return{username:t.username??``,password:t.password??``};case`api-key`:return{apiKeyName:t.key??``,apiKeyValue:t.value??``,apiKeyAddTo:t.addTo??`header`};case`custom-header`:return{customHeaders:Array.isArray(t.headers)&&t.headers.length>0?t.headers:[{key:``,value:``}]}}}function P(){let{t:e,getDateLocale:t}=x(),n=r(),[s,C]=(0,E.useState)(!1),[w,T]=(0,E.useState)(null),[P,F]=(0,E.useState)({...j}),[I,L]=(0,E.useState)(!1),[R,z]=(0,E.useState)(null),{data:B,isLoading:V}=i({queryKey:[`credentials`],queryFn:()=>h.credentials.list({page:1,pageSize:100}),staleTime:3e4}),H=B?.data??[],U=()=>{T(null),F({...j}),C(!0)},W=async t=>{try{let e=await h.credentials.get(t.id),n=JSON.parse(e.data);T(t.id),F({...j,name:t.name,type:t.type,...N(t.type,n)}),C(!0)}catch{b.error(e(`credentials.loadError`))}},G=async()=>{if(!P.name.trim()){b.error(e(`common.nameRequired`));return}L(!0);try{let t=M(P);w?(await h.credentials.update(w,{name:P.name,type:P.type,data:t}),b.success(e(`credentials.updated`))):(await h.credentials.create({name:P.name,type:P.type,data:t}),b.success(e(`credentials.created`))),n.invalidateQueries({queryKey:[`credentials`]}),C(!1)}catch(t){b.error(t instanceof Error?t.message:e(`common.error`))}finally{L(!1)}},K=async t=>{try{await h.credentials.delete(t),n.invalidateQueries({queryKey:[`credentials`]}),b.success(e(`credentials.deleted`)),z(null)}catch(t){b.error(t instanceof Error?t.message:e(`common.error`))}},q=e=>F(t=>({...t,...e})),J;return J=e(I?`common.saving`:w?`common.update`:`common.create`),(0,D.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto space-y-6`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h1`,{className:`text-2xl font-bold`,children:e(`nav.credentials`)}),(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:e(`credentials.description`)})]}),(0,D.jsxs)(p,{onClick:U,children:[(0,D.jsx)(_,{className:`h-4 w-4 mr-1.5`}),e(`common.new`)]})]}),V&&(0,D.jsx)(`div`,{className:`grid gap-3`,children:[1,2,3].map(e=>(0,D.jsx)(c,{className:`animate-pulse`,children:(0,D.jsx)(l,{className:`p-4 h-16`})},e))}),!V&&H.length===0&&(0,D.jsx)(c,{children:(0,D.jsxs)(l,{className:`p-8 text-center text-muted-foreground`,children:[(0,D.jsx)(S,{className:`h-12 w-12 mx-auto mb-3 opacity-30`}),(0,D.jsx)(`p`,{children:e(`credentials.noCredentials`)}),(0,D.jsx)(`p`,{className:`text-xs mt-1`,children:e(`credentials.createHelp`)})]})}),!V&&H.length>0&&(0,D.jsx)(`div`,{className:`grid gap-3`,children:H.map(n=>{let r=O[n.type];return(0,D.jsx)(c,{className:`group`,children:(0,D.jsxs)(l,{className:`p-4 flex items-center gap-3`,children:[(0,D.jsx)(`div`,{className:`h-9 w-9 rounded-md bg-muted flex items-center justify-center shrink-0`,children:(0,D.jsx)(r,{className:`h-4 w-4 text-muted-foreground`})}),(0,D.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`span`,{className:`font-medium text-sm truncate`,children:n.name}),(0,D.jsx)(f,{variant:`secondary`,className:`text-[10px]`,children:e(k[n.type])})]}),(0,D.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`credentials.updatedAt`,{date:new Date(n.updatedAt).toLocaleDateString(t())})})]}),(0,D.jsxs)(`div`,{className:`flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,D.jsx)(p,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0`,onClick:()=>W(n),children:(0,D.jsx)(v,{className:`h-3.5 w-3.5`})}),(0,D.jsx)(p,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0 text-destructive`,onClick:()=>z(n.id),children:(0,D.jsx)(y,{className:`h-3.5 w-3.5`})})]})]})},n.id)})}),(0,D.jsx)(d,{open:s,onOpenChange:C,children:(0,D.jsxs)(o,{className:`sm:max-w-md`,children:[(0,D.jsx)(m,{children:(0,D.jsx)(a,{children:e(w?`credentials.editTitle`:`credentials.newTitle`)})}),(0,D.jsxs)(`div`,{className:`space-y-4`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:e(`common.name`)}),(0,D.jsx)(g,{value:P.name,onChange:e=>q({name:e.target.value}),placeholder:e(`credentials.namePlaceholder`)})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:e(`credentials.type`)}),(0,D.jsxs)(`select`,{value:P.type,onChange:e=>q({type:e.target.value}),className:A,children:[(0,D.jsx)(`option`,{value:`bearer`,children:e(`credentials.bearerToken`)}),(0,D.jsx)(`option`,{value:`basic`,children:e(`credentials.basicAuth`)}),(0,D.jsx)(`option`,{value:`api-key`,children:e(`credentials.apiKey`)}),(0,D.jsx)(`option`,{value:`custom-header`,children:e(`credentials.customHeaders`)})]})]}),P.type===`bearer`&&(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:e(`credentials.token`)}),(0,D.jsx)(g,{type:`password`,value:P.token,onChange:e=>q({token:e.target.value}),placeholder:`sk-...`})]}),P.type===`basic`&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:e(`credentials.username`)}),(0,D.jsx)(g,{value:P.username,onChange:e=>q({username:e.target.value}),placeholder:`username`})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:e(`credentials.password`)}),(0,D.jsx)(g,{type:`password`,value:P.password,onChange:e=>q({password:e.target.value}),placeholder:`password`})]})]}),P.type===`api-key`&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:e(`credentials.parameterName`)}),(0,D.jsx)(g,{value:P.apiKeyName,onChange:e=>q({apiKeyName:e.target.value}),placeholder:`X-API-Key`})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:e(`credentials.value`)}),(0,D.jsx)(g,{type:`password`,value:P.apiKeyValue,onChange:e=>q({apiKeyValue:e.target.value}),placeholder:`your-api-key`})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:e(`credentials.addTo`)}),(0,D.jsxs)(`select`,{value:P.apiKeyAddTo,onChange:e=>q({apiKeyAddTo:e.target.value}),className:A,children:[(0,D.jsx)(`option`,{value:`header`,children:e(`credentials.header`)}),(0,D.jsx)(`option`,{value:`query`,children:e(`credentials.queryParameter`)})]})]})]}),P.type===`custom-header`&&(0,D.jsxs)(`div`,{className:`space-y-2`,children:[(0,D.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:e(`credentials.headers`)}),P.customHeaders.map((t,n)=>(0,D.jsxs)(`div`,{className:`flex gap-2`,children:[(0,D.jsx)(g,{value:t.key,onChange:e=>{let t=[...P.customHeaders];t[n]={...t[n],key:e.target.value},q({customHeaders:t})},placeholder:e(`credentials.headerName`),className:`flex-1`}),(0,D.jsx)(g,{type:`password`,value:t.value,onChange:e=>{let t=[...P.customHeaders];t[n]={...t[n],value:e.target.value},q({customHeaders:t})},placeholder:e(`credentials.value`),className:`flex-1`}),P.customHeaders.length>1&&(0,D.jsx)(p,{variant:`ghost`,size:`sm`,className:`h-9 w-9 p-0 shrink-0`,onClick:()=>{q({customHeaders:P.customHeaders.filter((e,t)=>t!==n)})},children:(0,D.jsx)(y,{className:`h-3.5 w-3.5`})})]},n)),(0,D.jsxs)(p,{variant:`outline`,size:`sm`,onClick:()=>q({customHeaders:[...P.customHeaders,{key:``,value:``}]}),children:[(0,D.jsx)(_,{className:`h-3.5 w-3.5 mr-1`}),e(`credentials.addHeader`)]})]})]}),(0,D.jsxs)(u,{children:[(0,D.jsx)(p,{variant:`outline`,onClick:()=>C(!1),children:e(`common.cancel`)}),(0,D.jsx)(p,{onClick:G,disabled:I,children:J})]})]})}),(0,D.jsx)(d,{open:!!R,onOpenChange:()=>z(null),children:(0,D.jsxs)(o,{className:`sm:max-w-sm`,children:[(0,D.jsx)(m,{children:(0,D.jsx)(a,{children:e(`credentials.deleteTitle`)})}),(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`credentials.deleteWarning`)}),(0,D.jsxs)(u,{children:[(0,D.jsx)(p,{variant:`outline`,onClick:()=>z(null),children:e(`common.cancel`)}),(0,D.jsx)(p,{variant:`destructive`,onClick:()=>R&&K(R),children:e(`common.delete`)})]})]})})]})}export{P as Credentials};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{h as t,r as n,t as r}from"./vendor-react-BJ8SIkmN.js";import{t as i}from"./useQuery-DvovkaPT.js";import{B as a,F as o,I as s,L as c,R as l,U as u,p as d,q as f,z as p}from"./src-DUhGoAQb.js";import{a as m,c as h,d as g,f as _,i as v,l as y,n as b,o as x,r as S,s as C,t as ee,u as w}from"./vendor-ui-Dpw9mBc-.js";import{n as te,t as ne}from"./zap-CbT5plGA.js";import{t as re}from"./circle-check-DLl9fl65.js";import{t as T}from"./circle-x-D_8Tcgt1.js";import{t as ie}from"./timer-C9X20mTO.js";import{D as ae,J as oe,K as se,T as ce,U as le,w as E}from"./index-dc8HGqTp.js";var ue=o(`coins`,[[`path`,{d:`M13.744 17.736a6 6 0 1 1-7.48-7.48`,key:`bq4yh3`}],[`path`,{d:`M15 6h1v4`,key:`11y1tn`}],[`path`,{d:`m6.134 14.768.866-.5 2 3.464`,key:`17snzx`}],[`circle`,{cx:`16`,cy:`8`,r:`6`,key:`14bfc9`}]]),de=o(`cpu`,[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]),fe=o(`dollar-sign`,[[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`22`,key:`7eqyqh`}],[`path`,{d:`M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6`,key:`1b0p4s`}]]),pe=o(`trending-up`,[[`path`,{d:`M16 7h6v6`,key:`box55l`}],[`path`,{d:`m22 7-8.5 8.5-5-5L2 17`,key:`1t1m79`}]]),me=o(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),D=e(t(),1),O=r(),k={completed:`#10b981`,failed:`#ef4444`,running:`#3b82f6`,pending:`#f59e0b`,total:`#6366f1`,input:`#8b5cf6`,output:`#06b6d4`},A=[`#6366f1`,`#10b981`,`#f59e0b`,`#ef4444`,`#8b5cf6`,`#ec4899`],j={"claude-sonnet-4-6":[3,15],"claude-sonnet-4-5":[3,15],"claude-sonnet-4-20250514":[3,15],"claude-opus-4-6":[15,75],"claude-opus-4-5":[15,75],"claude-3-5-sonnet":[3,15],"claude-3-5-haiku":[.8,4],"claude-haiku-4-5":[.8,4]};function M(e){if(j[e])return j[e];let t=e.toLowerCase();return t.includes(`opus`)?[15,75]:t.includes(`haiku`)?[.8,4]:(t.includes(`sonnet`),[3,15])}function N(e){let t=0;for(let n of e){let[e,r]=M(n.model);t+=n.inputTokens/1e6*e+n.outputTokens/1e6*r}return t}function P(e,t){let n=e.find(e=>e.model===t.model);n?(n.inputTokens+=t.inputTokens,n.outputTokens+=t.outputTokens,n.cacheReadTokens+=t.cacheReadTokens,n.cacheWriteTokens+=t.cacheWriteTokens,n.totalTokens+=t.totalTokens):e.push({...t})}function he(e,t,n){let r=[...e??[]];if(t)for(let e of t.models)P(r,e);if(n)for(let e of n.runs)for(let t of e.agents)!t.model||t.totalTokens===0||P(r,t);return r.sort((e,t)=>t.totalTokens-e.totalTokens)}function ge(e,t,n){let r=[...e??[]];if(t){let e=r.find(e=>e.cli===`claude-code`);e?(e.inputTokens+=t.totalInputTokens,e.outputTokens+=t.totalOutputTokens,e.totalTokens+=t.totalTokens,e.runCount+=t.totalSessions):r.push({cli:`claude-code`,inputTokens:t.totalInputTokens,outputTokens:t.totalOutputTokens,totalTokens:t.totalTokens,runCount:t.totalSessions})}return n&&n.totalTokens>0&&r.push({cli:`teams`,inputTokens:n.totalInputTokens,outputTokens:n.totalOutputTokens,totalTokens:n.totalTokens,runCount:n.runs.length}),r.sort((e,t)=>t.totalTokens-e.totalTokens)}function _e(e,t){let n=(e??[]).map(e=>({...e}));if(t)for(let e of t.daily){let t=n.find(t=>t.date===e.date);t?(t.inputTokens+=e.inputTokens,t.outputTokens+=e.outputTokens,t.totalTokens+=e.totalTokens):n.push({date:e.date,inputTokens:e.inputTokens,outputTokens:e.outputTokens,totalTokens:e.totalTokens})}return n.sort((e,t)=>e.date.localeCompare(t.date))}function F(e){return e<.01?`<$0.01`:e<1?`$${e.toFixed(2)}`:e<100?`$${e.toFixed(1)}`:`$${Math.round(e)}`}function I(e){return e===null?`—`:e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m ${e%60}s`:`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`}function L(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function ve(e){return e.toLocaleString()}function R(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function z(e){return new Date(e+`T00:00:00`).toLocaleDateString([],{month:`short`,day:`numeric`})}function B(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}var V={backgroundColor:`hsl(var(--card))`,border:`1px solid hsl(var(--border))`,borderRadius:`8px`,fontSize:`12px`};function H({title:e,value:t,subtitle:n,icon:r,color:i}){return(0,O.jsx)(s,{size:`sm`,children:(0,O.jsxs)(c,{className:`flex items-center gap-3 pt-0`,children:[(0,O.jsx)(`div`,{className:`rounded-lg p-2 ${i}`,children:(0,O.jsx)(r,{className:`h-4 w-4 text-white`})}),(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground truncate`,children:e}),(0,O.jsx)(`p`,{className:`text-xl font-semibold leading-tight`,children:t}),n&&(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n})]})]})})}function ye({data:e}){let{t}=E();return e.length===0?(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground py-4 text-center`,children:t(`dashboard.noWorkflowRuns`)}):(0,O.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>{let n=e.totalRuns>0?Math.round((e.statuses.completed??0)/e.totalRuns*100):0;return(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`p`,{className:`text-sm font-medium truncate`,children:e.name}),(0,O.jsxs)(`div`,{className:`flex gap-1.5 mt-0.5`,children:[e.statuses.completed&&(0,O.jsxs)(u,{variant:`outline`,className:`text-emerald-500 text-[10px] px-1 py-0`,children:[e.statuses.completed,` ok`]}),e.statuses.failed&&(0,O.jsxs)(u,{variant:`outline`,className:`text-red-500 text-[10px] px-1 py-0`,children:[e.statuses.failed,` err`]})]})]}),(0,O.jsxs)(`div`,{className:`text-right shrink-0`,children:[(0,O.jsx)(`p`,{className:`text-sm font-semibold`,children:e.totalRuns}),(0,O.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:t(`dashboard.successPercent`,{value:n})})]})]},e.workflowId)})})}function be({data:e}){let{t}=E();return e.length===0?(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground py-4 text-center`,children:t(`dashboard.noRecentErrors`)}):(0,O.jsx)(`div`,{className:`space-y-2`,children:e.slice(0,5).map(e=>(0,O.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,O.jsx)(T,{className:`h-3.5 w-3.5 text-red-500 mt-0.5 shrink-0`}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`p`,{className:`text-xs font-medium truncate`,children:e.workflow.name}),(0,O.jsx)(`p`,{className:`text-[11px] text-muted-foreground line-clamp-2`,children:e.error??`Unknown error`}),(0,O.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-0.5`,children:B(e.startedAt)})]})]},e.id))})}function xe({data:e}){let{t}=E();if(e.length===0)return(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground py-4 text-center`,children:t(`dashboard.noTokenData`)});let n=e.reduce((e,t)=>e+t.totalTokens,0);return(0,O.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,O.jsx)(_,{width:120,height:120,children:(0,O.jsx)(b,{children:(0,O.jsx)(y,{data:e,dataKey:`totalTokens`,nameKey:`model`,cx:`50%`,cy:`50%`,outerRadius:55,innerRadius:30,strokeWidth:2,stroke:`hsl(var(--card))`,children:e.map((e,t)=>(0,O.jsx)(w,{fill:A[t%A.length]},t))})})}),(0,O.jsx)(`div`,{className:`flex-1 space-y-1.5 min-w-0`,children:e.slice(0,6).map((e,t)=>{let r=n>0?Math.round(e.totalTokens/n*100):0;return(0,O.jsxs)(`div`,{className:`flex items-center justify-between text-xs gap-2`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,O.jsx)(`span`,{className:`h-2 w-2 rounded-full shrink-0`,style:{backgroundColor:A[t%A.length]}}),(0,O.jsx)(`span`,{className:`text-muted-foreground truncate`,children:e.model})]}),(0,O.jsxs)(`span`,{className:`font-medium shrink-0`,children:[L(e.totalTokens),` `,(0,O.jsxs)(`span`,{className:`text-muted-foreground font-normal`,children:[`(`,r,`%)`]})]})]},e.model)})})]})}function U({items:e,color:t}){let{t:n}=E();if(e.length===0)return(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground py-4 text-center`,children:n(`dashboard.noDataAvailable`)});let r=e[0]?.value??1;return(0,O.jsx)(`div`,{className:`space-y-3`,children:e.map(e=>{let n=Math.round(e.value/r*100);return(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,O.jsx)(`p`,{className:`text-xs font-medium truncate flex-1 mr-2`,children:e.label}),(0,O.jsxs)(`p`,{className:`text-xs text-muted-foreground shrink-0`,children:[L(e.value),` `,e.sub&&(0,O.jsxs)(`span`,{className:`text-[10px]`,children:[`(`,e.sub,`)`]})]})]}),(0,O.jsx)(`div`,{className:`h-2 rounded-full bg-muted overflow-hidden`,children:(0,O.jsx)(`div`,{className:`h-full rounded-full transition-all`,style:{width:`${n}%`,backgroundColor:t}})})]},e.label)})})}function W({tabs:e,active:t,onChange:n}){return(0,O.jsx)(`div`,{className:`inline-flex items-center rounded-lg bg-muted p-0.5 text-xs`,children:e.map((e,r)=>(0,O.jsx)(`button`,{onClick:()=>n(r),className:`rounded-md px-2.5 py-1 font-medium transition-colors ${t===r?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`}`,children:e},e))})}function G(){let{t:e}=E(),[t,r]=(0,D.useState)(0),[o,y]=(0,D.useState)(0),{data:b,isLoading:w}=i({queryKey:[`analytics`,`overview`],queryFn:()=>f.analytics.getOverview(),refetchInterval:3e4}),{data:T}=i({queryKey:[`analytics`,`runs-per-hour`],queryFn:()=>f.analytics.getRunsPerHour(),refetchInterval:6e4}),{data:A}=i({queryKey:[`analytics`,`daily-trend`],queryFn:()=>f.analytics.getDailyTrend(),refetchInterval:6e4}),{data:j}=i({queryKey:[`analytics`,`top-workflows`],queryFn:()=>f.analytics.getTopWorkflows(),refetchInterval:6e4}),{data:M}=i({queryKey:[`analytics`,`recent-errors`],queryFn:()=>f.analytics.getRecentErrors(),refetchInterval:3e4}),{data:P}=i({queryKey:[`analytics`,`context-usage`],queryFn:()=>f.analytics.getContextUsage(),staleTime:6e4}),{data:B}=i({queryKey:[`analytics`,`context-daily`],queryFn:()=>f.analytics.getContextDaily(),staleTime:6e4}),{data:G}=i({queryKey:[`analytics`,`tokens-by-model`],queryFn:()=>f.analytics.getTokensByModel(),staleTime:6e4}),{data:K}=i({queryKey:[`analytics`,`tokens-by-cli`],queryFn:()=>f.analytics.getTokensByCli(),staleTime:6e4}),{data:q}=i({queryKey:[`analytics`,`claude-code-usage`],queryFn:()=>f.analytics.getClaudeCodeUsage(),staleTime:6e4}),{data:J}=i({queryKey:[`analytics`,`team-runs-usage`],queryFn:()=>f.analytics.getTeamRunsUsage(),refetchInterval:3e4}),{data:Y}=i({queryKey:[`team-sessions`,`stats`],queryFn:()=>f.teamSessions.stats(7),staleTime:6e4}),X=(0,D.useMemo)(()=>he(G,q,J),[G,q,J]),Z=(0,D.useMemo)(()=>ge(K,q,J),[K,q,J]),Q=(0,D.useMemo)(()=>_e(B,q),[B,q]),Se=(0,D.useMemo)(()=>N(X),[X]),$=(0,D.useMemo)(()=>{let e=X.reduce((e,t)=>e+t.inputTokens,0),t=X.reduce((e,t)=>e+t.outputTokens,0),n=X.reduce((e,t)=>e+t.cacheReadTokens,0),r=X.reduce((e,t)=>e+t.cacheWriteTokens,0);return{outputRatio:e>0?t/e:0,cacheHitRate:e+n>0?n/(e+n):0,totalCacheRead:n,totalCacheWrite:r}},[X]),Ce=(0,D.useMemo)(()=>Y?Y.byAgent.slice(0,8).map(e=>({label:e.agentName,value:e.totalTokens,sub:`${e.sessions} runs`})):[],[Y]),we=(0,D.useMemo)(()=>P?P.workflows.slice(0,8).map(e=>({label:e.name,value:e.totalTokens,sub:`${e.runCount} runs`})):[],[P]),Te=(0,D.useMemo)(()=>q?q.projects.slice(0,8).map(e=>({label:e.name.split(`/`).filter(Boolean).slice(-2).join(`/`),value:e.totalTokens,sub:`${e.sessions} sessions`})):[],[q]),Ee=(0,D.useMemo)(()=>Z.map(e=>({label:e.cli,value:e.totalTokens,sub:`${e.runCount} runs`})),[Z]);return w?(0,O.jsx)(`div`,{className:`h-full overflow-y-auto`,children:(0,O.jsxs)(`div`,{className:`max-w-7xl mx-auto p-6 space-y-6`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(d,{className:`h-8 w-32`}),(0,O.jsx)(d,{className:`h-4 w-64 mt-2`})]}),(0,O.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-3`,children:Array.from({length:4}).map((e,t)=>(0,O.jsx)(s,{size:`sm`,children:(0,O.jsxs)(c,{className:`flex items-center gap-3 pt-0`,children:[(0,O.jsx)(d,{className:`h-8 w-8 rounded-lg`}),(0,O.jsxs)(`div`,{className:`space-y-1.5 flex-1`,children:[(0,O.jsx)(d,{className:`h-3 w-16`}),(0,O.jsx)(d,{className:`h-6 w-12`})]})]})},t))}),(0,O.jsx)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:Array.from({length:2}).map((e,t)=>(0,O.jsxs)(s,{children:[(0,O.jsx)(p,{children:(0,O.jsx)(d,{className:`h-5 w-32`})}),(0,O.jsx)(c,{children:(0,O.jsx)(d,{className:`h-[220px] w-full rounded-md`})})]},t))})]})}):(0,O.jsx)(`div`,{className:`h-full overflow-y-auto`,children:(0,O.jsxs)(`div`,{className:`max-w-7xl mx-auto p-6 space-y-6`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:e(`dashboard.title`)}),(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`dashboard.subtitle`)})]}),(0,O.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-3`,children:[(0,O.jsx)(H,{title:e(`dashboard.runsToday`),value:b?.runsToday??0,subtitle:e(`dashboard.thisWeek`,{count:b?.runsThisWeek??0}),icon:oe,color:`bg-indigo-500`}),(0,O.jsx)(H,{title:e(`dashboard.successRate`),value:b?.successRateToday===null?`—`:`${b?.successRateToday}%`,subtitle:b?.successRateWeek==null?void 0:e(`dashboard.thisWeekPercent`,{value:b.successRateWeek}),icon:re,color:`bg-emerald-500`}),(0,O.jsx)(H,{title:e(`dashboard.avgDuration`),value:I(b?.avgDurationToday??null),subtitle:e(`dashboard.today`),icon:ie,color:`bg-blue-500`}),(0,O.jsx)(H,{title:e(`dashboard.estCost`),value:F(Se),subtitle:e(`dashboard.tokens`,{count:L(X.reduce((e,t)=>e+t.totalTokens,0))}),icon:fe,color:`bg-amber-500`})]}),(0,O.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[(0,O.jsxs)(s,{children:[(0,O.jsxs)(p,{children:[(0,O.jsxs)(a,{className:`flex items-center gap-2`,children:[(0,O.jsx)(le,{className:`h-4 w-4`}),e(`dashboard.runsPerHour`)]}),(0,O.jsx)(l,{children:e(`dashboard.last24h`)})]}),(0,O.jsx)(c,{children:T&&T.length>0?(0,O.jsx)(_,{width:`100%`,height:220,children:(0,O.jsxs)(S,{data:T,margin:{top:4,right:4,bottom:0,left:-20},children:[(0,O.jsx)(h,{strokeDasharray:`3 3`,className:`stroke-border`}),(0,O.jsx)(m,{dataKey:`hour`,tickFormatter:R,tick:{fontSize:10},interval:`preserveStartEnd`,minTickGap:40}),(0,O.jsx)(v,{tick:{fontSize:10},allowDecimals:!1}),(0,O.jsx)(g,{labelFormatter:e=>R(String(e)),contentStyle:V}),(0,O.jsx)(x,{dataKey:`completed`,stackId:`a`,fill:k.completed,radius:[0,0,0,0]}),(0,O.jsx)(x,{dataKey:`failed`,stackId:`a`,fill:k.failed,radius:[2,2,0,0]})]})}):(0,O.jsx)(`div`,{className:`h-[220px] flex items-center justify-center text-sm text-muted-foreground`,children:e(`dashboard.noData24h`)})})]}),(0,O.jsxs)(s,{children:[(0,O.jsxs)(p,{children:[(0,O.jsxs)(a,{className:`flex items-center gap-2`,children:[(0,O.jsx)(ue,{className:`h-4 w-4`}),e(`dashboard.tokenConsumption`)]}),(0,O.jsx)(l,{children:e(`dashboard.dailyTokens14d`)})]}),(0,O.jsx)(c,{children:Q&&Q.some(e=>e.totalTokens>0)?(0,O.jsx)(_,{width:`100%`,height:220,children:(0,O.jsxs)(S,{data:Q,margin:{top:4,right:4,bottom:0,left:-10},children:[(0,O.jsx)(h,{strokeDasharray:`3 3`,className:`stroke-border`}),(0,O.jsx)(m,{dataKey:`date`,tickFormatter:z,tick:{fontSize:10},interval:`preserveStartEnd`,minTickGap:40}),(0,O.jsx)(v,{tick:{fontSize:10},tickFormatter:e=>L(e)}),(0,O.jsx)(g,{labelFormatter:e=>z(String(e)),formatter:(t,n)=>[ve(Number(t)),e(n===`inputTokens`?`dashboard.input`:`dashboard.output`)],contentStyle:V}),(0,O.jsx)(x,{dataKey:`inputTokens`,stackId:`a`,fill:k.input,radius:[0,0,0,0]}),(0,O.jsx)(x,{dataKey:`outputTokens`,stackId:`a`,fill:k.output,radius:[2,2,0,0]})]})}):(0,O.jsx)(`div`,{className:`h-[220px] flex items-center justify-center text-sm text-muted-foreground`,children:e(`dashboard.noTokenData14d`)})})]})]}),(0,O.jsxs)(s,{children:[(0,O.jsxs)(p,{children:[(0,O.jsxs)(a,{className:`flex items-center gap-2`,children:[(0,O.jsx)(pe,{className:`h-4 w-4`}),e(`dashboard.dailyRunsTrend`)]}),(0,O.jsx)(l,{children:e(`dashboard.last14d`)})]}),(0,O.jsx)(c,{children:A&&A.some(e=>e.total>0)?(0,O.jsx)(_,{width:`100%`,height:200,children:(0,O.jsxs)(ee,{data:A,margin:{top:4,right:4,bottom:0,left:-20},children:[(0,O.jsx)(h,{strokeDasharray:`3 3`,className:`stroke-border`}),(0,O.jsx)(m,{dataKey:`date`,tickFormatter:z,tick:{fontSize:10},interval:`preserveStartEnd`,minTickGap:40}),(0,O.jsx)(v,{tick:{fontSize:10},allowDecimals:!1}),(0,O.jsx)(g,{labelFormatter:e=>z(String(e)),contentStyle:V}),(0,O.jsx)(C,{type:`monotone`,dataKey:`total`,stroke:k.total,fill:k.total,fillOpacity:.1,strokeWidth:2}),(0,O.jsx)(C,{type:`monotone`,dataKey:`completed`,stroke:k.completed,fill:k.completed,fillOpacity:.1,strokeWidth:2}),(0,O.jsx)(C,{type:`monotone`,dataKey:`failed`,stroke:k.failed,fill:k.failed,fillOpacity:.05,strokeWidth:2})]})}):(0,O.jsx)(`div`,{className:`h-[200px] flex items-center justify-center text-sm text-muted-foreground`,children:e(`dashboard.noData14d`)})})]}),(0,O.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[(0,O.jsxs)(s,{children:[(0,O.jsxs)(p,{children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,O.jsxs)(a,{className:`flex items-center gap-2`,children:[(0,O.jsx)(de,{className:`h-4 w-4`}),e(`dashboard.tokenBreakdown`)]}),(0,O.jsx)(W,{tabs:[e(`dashboard.model`),e(`dashboard.source`)],active:o,onChange:y})]}),(0,O.jsx)(l,{children:e(o===0?`dashboard.llmUsage7d`:`dashboard.byCli7d`)})]}),(0,O.jsx)(c,{children:o===0?(0,O.jsx)(xe,{data:X}):(0,O.jsx)(U,{items:Ee,color:`#8b5cf6`})})]}),(0,O.jsxs)(s,{children:[(0,O.jsxs)(p,{children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,O.jsxs)(a,{className:`flex items-center gap-2`,children:[(0,O.jsx)(te,{className:`h-4 w-4`}),e(`dashboard.tokenDistribution`)]}),(0,O.jsx)(W,{tabs:[e(`dashboard.workflow`),e(`dashboard.project`)],active:t,onChange:r})]}),(0,O.jsx)(l,{children:e(t===0?`dashboard.perWorkflow7d`:`dashboard.perProject14d`)})]}),(0,O.jsx)(c,{children:t===0?(0,O.jsx)(U,{items:we,color:k.input}):(0,O.jsx)(U,{items:Te,color:`#f97316`})})]})]}),(0,O.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[(0,O.jsxs)(s,{children:[(0,O.jsxs)(p,{children:[(0,O.jsxs)(a,{className:`flex items-center gap-2`,children:[(0,O.jsx)(ne,{className:`h-4 w-4`}),e(`dashboard.efficiency`)]}),(0,O.jsx)(l,{children:e(`dashboard.tokenEfficiency7d`)})]}),(0,O.jsx)(c,{children:(0,O.jsxs)(`div`,{className:`space-y-4`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,O.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`dashboard.outputInputRatio`)}),(0,O.jsxs)(`span`,{className:`text-sm font-semibold`,children:[($.outputRatio*100).toFixed(1),`%`]})]}),(0,O.jsx)(`div`,{className:`h-2 rounded-full bg-muted overflow-hidden`,children:(0,O.jsx)(`div`,{className:`h-full rounded-full bg-cyan-500 transition-all`,style:{width:`${Math.min($.outputRatio*100,100)}%`}})}),(0,O.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-1`,children:e(`dashboard.higherOutput`)})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,O.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`dashboard.cacheHitRate`)}),(0,O.jsxs)(`span`,{className:`text-sm font-semibold`,children:[($.cacheHitRate*100).toFixed(1),`%`]})]}),(0,O.jsx)(`div`,{className:`h-2 rounded-full bg-muted overflow-hidden`,children:(0,O.jsx)(`div`,{className:`h-full rounded-full bg-emerald-500 transition-all`,style:{width:`${$.cacheHitRate*100}%`}})}),(0,O.jsxs)(`p`,{className:`text-[10px] text-muted-foreground mt-1`,children:[L($.totalCacheRead),` read / `,L($.totalCacheWrite),` write`]})]}),Y&&Y.totalSessions>0&&(0,O.jsxs)(`div`,{className:`pt-2 border-t space-y-1.5`,children:[(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground font-medium`,children:e(`dashboard.avgTokensPerTeamRun`)}),(0,O.jsx)(`p`,{className:`text-lg font-semibold`,children:L(Math.round(Y.totalTokens/Y.totalSessions))})]})]})})]}),(0,O.jsxs)(s,{children:[(0,O.jsxs)(p,{children:[(0,O.jsxs)(a,{className:`flex items-center gap-2`,children:[(0,O.jsx)(ae,{className:`h-4 w-4`}),e(`dashboard.teamSessions`)]}),(0,O.jsxs)(l,{children:[e(`dashboard.last7d`),Y&&Y.totalSessions>0&&(0,O.jsxs)(O.Fragment,{children:[` — `,(0,O.jsx)(n,{to:`/team-sessions`,className:`text-primary hover:underline`,children:e(`dashboard.viewAll`)})]})]})]}),(0,O.jsx)(c,{children:Y&&Y.totalSessions>0?(0,O.jsxs)(`div`,{className:`space-y-3`,children:[(0,O.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`dashboard.sessions`)}),(0,O.jsx)(`p`,{className:`text-lg font-semibold`,children:Y.totalSessions})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`dashboard.totalTokens`)}),(0,O.jsx)(`p`,{className:`text-lg font-semibold`,children:L(Y.totalTokens)})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`dashboard.estCostLabel`)}),(0,O.jsx)(`p`,{className:`text-sm font-medium`,children:F(N(Y.byModel.map(e=>({model:e.model,inputTokens:e.inputTokens,outputTokens:e.outputTokens}))))})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`dashboard.teamsActive`)}),(0,O.jsx)(`p`,{className:`text-sm font-medium`,children:Y.byTeam.length})]})]}),Y.byTeam.length>0&&(0,O.jsxs)(`div`,{className:`space-y-1.5 pt-2 border-t`,children:[(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground font-medium`,children:e(`dashboard.topTeams`)}),Y.byTeam.slice(0,3).map(e=>(0,O.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,O.jsx)(`span`,{className:`text-muted-foreground truncate`,children:e.teamName}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,O.jsx)(`span`,{className:`font-medium`,children:L(e.totalTokens)}),(0,O.jsxs)(u,{variant:`outline`,className:`text-emerald-500 text-[10px] px-1 py-0`,children:[e.completed,`ok`]}),e.failed>0&&(0,O.jsxs)(u,{variant:`outline`,className:`text-red-500 text-[10px] px-1 py-0`,children:[e.failed,`err`]})]})]},e.teamId))]})]}):(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground py-4 text-center`,children:e(`dashboard.noTeamSessions`)})})]}),(0,O.jsxs)(s,{children:[(0,O.jsxs)(p,{children:[(0,O.jsxs)(a,{className:`flex items-center gap-2`,children:[(0,O.jsx)(se,{className:`h-4 w-4`}),e(`dashboard.topAgents`)]}),(0,O.jsx)(l,{children:e(`dashboard.byTokenConsumption7d`)})]}),(0,O.jsx)(c,{children:(0,O.jsx)(U,{items:Ce,color:`#6366f1`})})]})]}),(0,O.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,O.jsxs)(s,{children:[(0,O.jsxs)(p,{children:[(0,O.jsxs)(a,{className:`flex items-center gap-2`,children:[(0,O.jsx)(ce,{className:`h-4 w-4`}),e(`dashboard.topWorkflows`)]}),(0,O.jsx)(l,{children:e(`dashboard.mostActiveThisWeek`)})]}),(0,O.jsx)(c,{children:(0,O.jsx)(ye,{data:j??[]})})]}),(0,O.jsxs)(s,{children:[(0,O.jsxs)(p,{children:[(0,O.jsxs)(a,{className:`flex items-center gap-2`,children:[(0,O.jsx)(me,{className:`h-4 w-4`}),e(`dashboard.recentErrors`)]}),(0,O.jsx)(l,{children:e(`dashboard.latestFailures`)})]}),(0,O.jsx)(c,{children:(0,O.jsx)(be,{data:M??[]})})]})]})]})})}export{G as Dashboard};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./vendor-react-BJ8SIkmN.js";import{t}from"./useQuery-DvovkaPT.js";import{B as n,I as r,L as i,U as a,V as o,p as s,q as c,z as l}from"./src-DUhGoAQb.js";import{t as u}from"./eye-DN-Km5vf.js";import{t as d}from"./refresh-cw-RFYUf5GB.js";import{V as f,w as p}from"./index-dc8HGqTp.js";var m=e();function h(){let{t:e}=p(),{data:h,isLoading:g,dataUpdatedAt:_,refetch:v,isFetching:y}=t({queryKey:[`debug`,`watchers`],queryFn:()=>c.debug.getWatchers(),refetchInterval:5e3});return(0,m.jsxs)(`div`,{className:`p-6 max-w-4xl`,children:[(0,m.jsxs)(`div`,{className:`mb-6 flex items-center justify-between`,children:[(0,m.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Debug`}),(0,m.jsxs)(o,{variant:`outline`,size:`sm`,onClick:()=>v(),disabled:y,children:[(0,m.jsx)(d,{className:`h-4 w-4 mr-2 ${y?`animate-spin`:``}`}),`Refresh`]})]}),(0,m.jsxs)(r,{children:[(0,m.jsxs)(l,{className:`pb-3`,children:[(0,m.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,m.jsxs)(n,{className:`text-base flex items-center gap-2`,children:[(0,m.jsx)(u,{className:`h-4 w-4`}),`File System Watchers`]}),h&&(0,m.jsx)(a,{variant:`secondary`,children:e(`debug.activeCount`,{count:h.total})})]}),(0,m.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`debug.watcherDescription`)})]}),(0,m.jsxs)(i,{children:[g&&(0,m.jsx)(`div`,{className:`space-y-2`,children:Array.from({length:4}).map((e,t)=>(0,m.jsx)(s,{className:`h-8 w-full`},t))}),!g&&h&&(h.dirs.length>0?(0,m.jsx)(`div`,{className:`space-y-1`,children:h.dirs.map(e=>(0,m.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md px-3 py-2 text-sm font-mono bg-muted/50 hover:bg-muted transition-colors`,children:[(0,m.jsx)(f,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,m.jsx)(`span`,{className:`truncate`,children:e})]},e))}):(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:e(`debug.noWatchers`)})),_>0&&(0,m.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-3 text-right`,children:e(`debug.updatedAt`,{time:new Date(_).toLocaleTimeString()})})]})]})]})}export{h as Debug};
|
|
@@ -1 +0,0 @@
|
|
|
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"./useQuery-DvovkaPT.js";import{F as i,K as a,q as o}from"./src-DUhGoAQb.js";import{t as s}from"./folder-plus-DsmP6Mur.js";import"./utils-DHTPP40O.js";import{M as c,V as l,W as u,k as d,w as f}from"./index-dc8HGqTp.js";var p=i(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),m=i(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),h=e(t(),1),g=n();function _({rootPath:e,selectedFile:t,onSelectFile:n,onDelete:i,onNewFile:s,onNewFolder:c,onMove:l,className:u}){let{data:d,isLoading:f}=r({queryKey:[`fs-tree`,e],queryFn:()=>o.fs.tree(e,1),staleTime:1e4});return f?(0,g.jsx)(`div`,{className:a(`p-2 space-y-1`,u),children:Array.from({length:5}).map((e,t)=>(0,g.jsx)(`div`,{className:`h-6 bg-muted/50 rounded animate-pulse`},t))}):(0,g.jsx)(`div`,{className:a(`text-sm select-none`,u),children:d?.entries.map(r=>(0,g.jsx)(v,{node:r,rootPath:e,selectedFile:t,onSelectFile:n,onDelete:i,onNewFile:s,onNewFolder:c,onMove:l,depth:0},r.path))})}var v=(0,h.memo)(function e({node:t,rootPath:n,selectedFile:i,onSelectFile:_,onDelete:v,onNewFile:y,onNewFolder:b,onMove:x,depth:S}){let{t:C}=f(),[w,T]=(0,h.useState)(!1),[E,D]=(0,h.useState)(!1),O=t.type===`directory`,k=`${n}/${t.path}`,A=i===k,{data:j}=r({queryKey:[`fs-tree`,n,t.path],queryFn:()=>o.fs.tree(k,1),enabled:O&&w,staleTime:1e4}),M=(0,h.useCallback)(()=>{O?T(e=>!e):_(k)},[O,k,_]),N=(0,h.useCallback)(e=>{e.dataTransfer.setData(`text/x-file-path`,k),e.dataTransfer.setData(`text/x-file-name`,t.name),e.dataTransfer.effectAllowed=`move`},[k,t.name]),P=(0,h.useCallback)(e=>{O&&e.dataTransfer.types.includes(`text/x-file-path`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,D(!0))},[O]),F=(0,h.useCallback)(e=>{e.currentTarget.contains(e.relatedTarget)||D(!1)},[]),I=(0,h.useCallback)(e=>{if(e.preventDefault(),D(!1),!O||!x)return;let t=e.dataTransfer.getData(`text/x-file-path`);!t||t===k||k.startsWith(t+`/`)||t!==`${k}/${e.dataTransfer.getData(`text/x-file-name`)}`&&x(t,k)},[O,k,x]);return(0,g.jsxs)(`div`,{children:[(0,g.jsxs)(`div`,{className:a(`group flex items-center gap-1 py-0.5 px-1 rounded-sm cursor-pointer hover:bg-muted/80 transition-colors`,A&&`bg-accent text-accent-foreground`,E&&`bg-primary/20 ring-1 ring-primary/40`),style:{paddingLeft:`${S*16+4}px`},onClick:M,draggable:!0,onDragStart:N,onDragOver:P,onDragLeave:F,onDrop:I,children:[O?(0,g.jsx)(u,{className:a(`h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform duration-150`,w&&`rotate-90`)}):(0,g.jsx)(`span`,{className:`w-3.5 shrink-0`}),O&&w&&(0,g.jsx)(l,{className:`h-3.5 w-3.5 shrink-0 text-amber-500`}),O&&!w&&(0,g.jsx)(m,{className:`h-3.5 w-3.5 shrink-0 text-amber-500`}),!O&&(0,g.jsx)(p,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,g.jsx)(`span`,{className:`truncate flex-1 text-[13px]`,children:t.name}),(0,g.jsxs)(`span`,{className:`hidden group-hover:flex items-center gap-0.5 shrink-0`,children:[O&&y&&(0,g.jsx)(`button`,{className:`p-0.5 rounded hover:bg-muted-foreground/20`,onClick:e=>{e.stopPropagation(),y(k)},title:C(`common.newFile`),children:(0,g.jsx)(c,{className:`h-3 w-3`})}),O&&b&&(0,g.jsx)(`button`,{className:`p-0.5 rounded hover:bg-muted-foreground/20`,onClick:e=>{e.stopPropagation(),b(k)},title:C(`common.newFolder`),children:(0,g.jsx)(s,{className:`h-3 w-3`})}),v&&(0,g.jsx)(`button`,{className:`p-0.5 rounded hover:bg-destructive/20 text-destructive`,onClick:e=>{e.stopPropagation(),v(k,t.type)},title:C(`common.delete`),children:(0,g.jsx)(d,{className:`h-3 w-3`})})]})]}),O&&w&&j?.entries&&(0,g.jsxs)(`div`,{children:[j.entries.map(t=>(0,g.jsx)(e,{node:t,rootPath:k,selectedFile:i,onSelectFile:_,onDelete:v,onNewFile:y,onNewFolder:b,onMove:x,depth:S+1},t.path)),j.entries.length===0&&(0,g.jsx)(`div`,{className:`text-[11px] text-muted-foreground italic py-1`,style:{paddingLeft:`${(S+1)*16+4}px`},children:`Empty`})]})]})});export{p as n,_ as t};
|