@kafca/agentdock 0.1.44 → 0.1.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/README.md +76 -11
  2. package/bin/agentdock.mjs +5 -5
  3. package/dist/renderer/assets/{Badge-Qk9qHovH.js → Badge-BIesaDYG.js} +1 -1
  4. package/dist/renderer/assets/Chat-CpataoDh.js +2 -0
  5. package/dist/renderer/assets/{ChatMarkdown-BKdW8OON.js → ChatMarkdown-_Mdmltgv.js} +1 -1
  6. package/dist/renderer/assets/Config-Pe5-zKZk.js +21 -0
  7. package/dist/renderer/assets/CronList-BnaOSPT8.js +1 -0
  8. package/dist/renderer/assets/Dashboard-D05l8GKE.js +26 -0
  9. package/dist/renderer/assets/{EmptyState-kD9yAwtw.js → EmptyState-BDBavDll.js} +1 -1
  10. package/dist/renderer/assets/{KnowledgeDetail-BAMCLrjz.js → KnowledgeDetail-DvR798l_.js} +2 -2
  11. package/dist/renderer/assets/KnowledgeHome-r2ZuvU8-.js +11 -0
  12. package/dist/renderer/assets/Logs-BaljtmAV.js +1 -0
  13. package/dist/renderer/assets/{Modal-DwY4lecS.js → Modal-CXhD_OWR.js} +1 -1
  14. package/dist/renderer/assets/MonitorList-D7tyipbx.js +1 -0
  15. package/dist/renderer/assets/{Page-CnB9ePsb.js → Page-KUuFYgjg.js} +1 -1
  16. package/dist/renderer/assets/ProjectDetail-Ddq94-yu.js +11 -0
  17. package/dist/renderer/assets/ProjectList-CbdHd5Ev.js +1 -0
  18. package/dist/renderer/assets/{Select-zfoksLGB.js → Select-Djc8BXMC.js} +1 -1
  19. package/dist/renderer/assets/SessionChat-DOy0iKQR.js +1 -0
  20. package/dist/renderer/assets/SessionList-DHgl1s1D.js +1 -0
  21. package/dist/renderer/assets/ThreadChat-I7dYibDc.js +23 -0
  22. package/dist/renderer/assets/Workspace-DTocqY-F.js +19 -0
  23. package/dist/renderer/assets/{arrow-left-CNEAuElg.js → arrow-left-CXyya3hP.js} +1 -1
  24. package/dist/renderer/assets/{book-open-BNJMhNI-.js → book-open-9n4Kxc7E.js} +1 -1
  25. package/dist/renderer/assets/bot-C9HBk5XH.js +6 -0
  26. package/dist/renderer/assets/{check-BnclClRU.js → check-CutSg9a5.js} +1 -1
  27. package/dist/renderer/assets/{chevron-down-Bh53e0O-.js → chevron-down-DrydR4i3.js} +1 -1
  28. package/dist/renderer/assets/{circle-ClZTWCWO.js → circle-BEjtahw6.js} +1 -1
  29. package/dist/renderer/assets/desktop-DATgk_ka.js +1 -0
  30. package/dist/renderer/assets/{desktop-C6q6wBae.js → desktop-JQkhNOF4.js} +5 -5
  31. package/dist/renderer/assets/en-CmAr_0e6.js +1 -0
  32. package/dist/renderer/assets/es-Cs9x52ca.js +1 -0
  33. package/dist/renderer/assets/{funnel-_5hsz0xI.js → funnel-BhqZpS4f.js} +1 -1
  34. package/dist/renderer/assets/{heart-u4Q1aOqj.js → heart-Dp8Vs-7_.js} +1 -1
  35. package/dist/renderer/assets/{index-BNFx4uYv.js → index-BKpv0P0s.js} +2 -2
  36. package/dist/renderer/assets/index-CO4fGqmv.css +11 -0
  37. package/dist/renderer/assets/{index-B36eowj-.js → index-cI3pWBnN.js} +36 -36
  38. package/dist/renderer/assets/ja-DtvtBRTW.js +1 -0
  39. package/dist/renderer/assets/{pencil-DLh9QNmT.js → pencil-ywcJzeOo.js} +1 -1
  40. package/dist/renderer/assets/{play-BDTk9Scm.js → play-AtN492Cx.js} +1 -1
  41. package/dist/renderer/assets/{plus-BSc8POsz.js → plus-BEj14BBV.js} +1 -1
  42. package/dist/renderer/assets/projects-Clar8lgb.js +1 -0
  43. package/dist/renderer/assets/save-D6ov4CNv.js +11 -0
  44. package/dist/renderer/assets/{search-CniPk7Ey.js → search-C3bvw7AR.js} +1 -1
  45. package/dist/renderer/assets/{server-GsXyQAZm.js → server-C1Uyedyx.js} +1 -1
  46. package/dist/renderer/assets/{session-utils-BDxzgTBC.js → session-utils-DpRwJ6Nh.js} +1 -1
  47. package/dist/renderer/assets/{sessions-CLcKA1Tt.js → sessions-BWmAppwK.js} +1 -1
  48. package/dist/renderer/assets/{shield-check-4i0E3hmf.js → shield-check-CVx1mEs2.js} +1 -1
  49. package/dist/renderer/assets/{trash-2-DhtOCsO5.js → trash-2-o-heXOgs.js} +1 -1
  50. package/dist/renderer/assets/user-dPOzUqIc.js +6 -0
  51. package/dist/renderer/assets/{wifi-off-BHPzPY_B.js → wifi-off-Fz5c3_x_.js} +1 -1
  52. package/dist/renderer/assets/zh-CcJ9vBZj.js +1 -0
  53. package/dist/renderer/assets/zh-TW-elI72AC1.js +1 -0
  54. package/dist/renderer/index.html +2 -2
  55. package/dist-electron/electron/main.js +26 -1
  56. package/dist-electron/packages/core-sdk/src/index.js +28 -0
  57. package/dist-electron/services/local-ai-core/src/acp/local-core-acp-backend.js +111 -62
  58. package/dist-electron/services/local-ai-core/src/acp/local-core-acp-session-coordinator.js +80 -7
  59. package/dist-electron/services/local-ai-core/src/acp/local-core-acp-transport.js +78 -5
  60. package/dist-electron/services/local-ai-core/src/acp/store/external-store.js +98 -0
  61. package/dist-electron/services/local-ai-core/src/acp/store/local-core-acp-store.js +33 -0
  62. package/dist-electron/services/local-ai-core/src/acp/store/model-provider-store.js +88 -0
  63. package/dist-electron/services/local-ai-core/src/acp/store/schema.js +43 -0
  64. package/dist-electron/services/local-ai-core/src/agents/pi/launch.js +2 -119
  65. package/dist-electron/services/local-ai-core/src/agents/pi/provider-materializer.js +148 -0
  66. package/dist-electron/services/local-ai-core/src/channel/lark/inbound.js +55 -1
  67. package/dist-electron/services/local-ai-core/src/channel/lark/local-core-lark-gateway.js +65 -10
  68. package/dist-electron/services/local-ai-core/src/channel/shared/session-command-runtime.js +4 -2
  69. package/dist-electron/services/local-ai-core/src/channel/weixin/local-core-weixin-gateway.js +139 -29
  70. package/dist-electron/services/local-ai-core/src/execution/agent-execution-backend.js +56 -0
  71. package/dist-electron/services/local-ai-core/src/kernel/bootstrap.js +18 -57
  72. package/dist-electron/services/local-ai-core/src/kernel/local-core-errors.js +255 -0
  73. package/dist-electron/services/local-ai-core/src/plugins/builtin/catalog.js +78 -0
  74. package/dist-electron/services/local-ai-core/src/router/workspace-route-config.js +3 -1
  75. package/dist-electron/services/local-ai-core/src/router/workspace-router.js +64 -9
  76. package/dist-electron/services/local-ai-core/src/runtime/agent-runtime-detector.js +5 -2
  77. package/dist-electron/services/local-ai-core/src/runtime/config-migration.js +152 -0
  78. package/dist-electron/services/local-ai-core/src/runtime/deployment-diagnostics.js +175 -0
  79. package/dist-electron/services/local-ai-core/src/runtime/local-core-controller.js +330 -3
  80. package/dist-electron/services/local-ai-core/src/runtime/local-core-runtime-state.js +11 -2
  81. package/dist-electron/services/local-ai-core/src/runtime/provider-config-migration.js +32 -0
  82. package/dist-electron/services/local-ai-core/src/runtime/runtime-detection-service.js +76 -8
  83. package/dist-electron/services/local-ai-core/src/runtime/server-routes.js +62 -0
  84. package/dist-electron/services/local-ai-core/src/runtime/server.js +708 -4
  85. package/dist-electron/services/local-ai-core/src/runtime/standalone.js +13 -3
  86. package/dist-electron/services/local-ai-core/src/sandbox/opensandbox-client.js +113 -0
  87. package/dist-electron/services/local-ai-core/src/sandbox/sandbox-config.js +273 -0
  88. package/dist-electron/services/local-ai-core/src/sandbox/sandbox-manager.js +215 -0
  89. package/dist-electron/services/local-ai-core/src/sandbox/sandbox-stdio-proxy.js +188 -0
  90. package/dist-electron/services/local-ai-core/src/thread/slash-command-registry.js +3 -0
  91. package/dist-electron/services/local-ai-core/src/thread/thread-command-service.js +32 -0
  92. package/dist-electron/services/local-ai-core/src/thread/thread-slash-command-dispatcher.js +71 -0
  93. package/dist-electron/shared/desktop.js +85 -1
  94. package/dist-electron/tests/contracts/architecture-docs.test.js +83 -0
  95. package/dist-electron/tests/electron/plugin-kernel.test.js +225 -18
  96. package/dist-electron/tests/electron/runtime-detection-service.test.js +57 -5
  97. package/dist-electron/tests/electron/sandbox-config.test.js +541 -0
  98. package/dist-electron/tests/electron/workspace-task-store.test.js +257 -0
  99. package/dist-electron/tests/integration/lark-gateway.test.js +139 -0
  100. package/dist-electron/tests/integration/local-core-refactor.test.js +183 -20
  101. package/dist-electron/tests/integration/local-core-routes.test.js +34 -0
  102. package/package.json +2 -3
  103. package/dist/renderer/assets/Chat-BK-fm0Xr.js +0 -2
  104. package/dist/renderer/assets/Config-B93CQGvY.js +0 -16
  105. package/dist/renderer/assets/CronList-Z3TvSRKP.js +0 -1
  106. package/dist/renderer/assets/Dashboard-Ch3QkWwf.js +0 -26
  107. package/dist/renderer/assets/KnowledgeHome-ChvjOfrc.js +0 -11
  108. package/dist/renderer/assets/Logs-Cv0nth3j.js +0 -1
  109. package/dist/renderer/assets/MonitorList-JEvMoWUm.js +0 -1
  110. package/dist/renderer/assets/ProjectDetail-DJa3sMmU.js +0 -11
  111. package/dist/renderer/assets/ProjectList-D6CXumR_.js +0 -1
  112. package/dist/renderer/assets/SessionChat-DUTh4WoM.js +0 -1
  113. package/dist/renderer/assets/SessionList-D9o-lUst.js +0 -1
  114. package/dist/renderer/assets/ThreadChat-BYXlT-Kc.js +0 -23
  115. package/dist/renderer/assets/Workspace-BrhSwRQ-.js +0 -14
  116. package/dist/renderer/assets/desktop-C5vBT0yM.js +0 -1
  117. package/dist/renderer/assets/en-D2SkCrhG.js +0 -1
  118. package/dist/renderer/assets/es-C8UBPhxM.js +0 -1
  119. package/dist/renderer/assets/index-CaQZSRbg.css +0 -11
  120. package/dist/renderer/assets/ja-ChF4vbBL.js +0 -1
  121. package/dist/renderer/assets/plug-BG0JHW6B.js +0 -6
  122. package/dist/renderer/assets/projects-DwfZwxDW.js +0 -1
  123. package/dist/renderer/assets/save-D5AO_G6a.js +0 -6
  124. package/dist/renderer/assets/user-BtC_pVXV.js +0 -11
  125. package/dist/renderer/assets/zh-DIcdHycM.js +0 -1
  126. package/dist/renderer/assets/zh-TW-BtRwreY_.js +0 -1
package/README.md CHANGED
@@ -13,7 +13,7 @@ React 19 · Electron 35 · Vite · TypeScript · Tailwind CSS · Zustand · i18n
13
13
 
14
14
  ## 系统架构
15
15
 
16
- AgentDock 由 Electron 桌面壳、React 渲染进程和 Local AI Core 组成。Electron 负责应用生命周期、窗口与本地进程编排;React 渲染进程通过 API 客户端与本地 core 通信,承载桌面、Web、线程、项目、知识库和系统配置界面;Local AI Core 提供 runtime、ACP 会话、channel 网关、定时任务、知识库和插件能力。跨进程契约集中在 `shared/``packages/contracts/`,插件 SDK 与内置插件分别位于 `packages/plugin-sdk/` 和 `services/local-ai-core/src/plugins/`。
16
+ AgentDock 由 Electron 桌面壳、React/Web 渲染入口、Local AI Core、OpenSandbox 云端运行层和外部 Agent API 组成。Electron 只负责桌面生命周期、窗口和本地 core 启动;React/Web 通过 API client 访问 Local AI Core;Local AI Core 统一管理 workspacethread、run、ACP 流式事件、channel 网关、定时任务、知识库、sandbox 启动与外部系统映射。云端 sandbox 模式通过 OpenSandbox 创建隔离容器,容器内 agent runtime 通过 HTTP NDJSON ACP bridge Local AI Core 通信。外部系统可通过 `/api/local/v1/external/*` 创建或复用项目、发起 agent run,并通过 per-run SSE 订阅过程。
17
17
 
18
18
  ```mermaid
19
19
  ---
@@ -26,44 +26,65 @@ config:
26
26
  textColor: "#0f172a"
27
27
  ---
28
28
  flowchart LR
29
- Web["Web 入口<br/>apps/shell-web"]
29
+ Web["AgentDock Web<br/>apps/shell-web"]
30
+ External["外部系统 / Agent API Client"]
30
31
 
31
32
  subgraph Desktop["AgentDock Desktop"]
32
33
  direction LR
33
- Electron["Electron Shell<br/>窗口 / 应用生命周期"]
34
- Renderer["React Renderer<br/>页面 / 状态 / API Client"]
34
+ Electron["Electron Shell<br/>窗口 / 本地 Core 启动"]
35
+ Renderer["React Renderer<br/>桌面 UI / API Client"]
35
36
  end
36
37
 
37
38
  subgraph Core["Local AI Core"]
38
39
  direction TB
39
- CoreApi["HTTP API / SSE<br/>127.0.0.1:9831"]
40
+ CoreApi["HTTP API / SSE<br/>/api/local/v1"]
41
+ ExternalApi["External Agent API<br/>/external/* · /openai/chat/completions"]
40
42
  Kernel["Kernel & Plugin Registry"]
41
- Runtime["Workspace Router / ACP / Scheduler / Knowledge"]
43
+ Router["Workspace Router<br/>workspace · thread · run"]
44
+ Acp["ACP Runtime<br/>stdio 或 HTTP NDJSON bridge"]
45
+ Scheduler["Scheduler / Automation"]
46
+ Knowledge["Knowledge Runtime"]
47
+ Channels["Lark / 微信 Channel Gateway"]
42
48
  end
43
49
 
44
- subgraph Integrations["外部通道与 Agent"]
50
+ subgraph Sandbox["Cloud Sandbox Mode"]
45
51
  direction TB
46
- Channels["Lark / 微信 Channel"]
47
- Agents["Codex / Claude Code / Hermes / Pi / opencode"]
52
+ OpenSandbox["OpenSandbox Server"]
53
+ Container["Sandbox Container<br/>agent runtime + HTTP NDJSON ACP bridge"]
54
+ State["workspace mount / agent state mount"]
48
55
  end
49
56
 
57
+ Agents["本地 Agent Runtime<br/>Codex / Claude Code / Hermes / Pi / opencode"]
50
58
  Contracts["共享契约<br/>shared/ · packages/contracts/"]
59
+ CoreSdk["Core SDK<br/>packages/core-sdk/"]
51
60
  PluginSdk["Plugin SDK<br/>packages/plugin-sdk/"]
52
61
 
53
62
  Web --> CoreApi
63
+ External --> ExternalApi
54
64
  Electron --> Renderer --> CoreApi
55
65
  Electron -.启动 / 管理.-> CoreApi
56
- CoreApi --> Kernel --> Runtime
66
+ CoreApi --> ExternalApi
67
+ CoreApi --> Kernel --> Router
68
+ Router --> Acp
69
+ Router --> Scheduler
70
+ Router --> Knowledge
57
71
  Kernel --> Channels
58
- Kernel --> Agents
72
+ Acp --> Agents
73
+ Acp --> OpenSandbox --> Container
74
+ Container --> State
75
+ Container -.HTTP NDJSON ACP.-> Acp
76
+ Scheduler --> Channels
59
77
 
60
78
  Contracts -.-> Renderer
61
79
  Contracts -.-> CoreApi
80
+ CoreSdk -.-> Renderer
62
81
  PluginSdk -.-> Kernel
63
82
  ```
64
83
 
65
84
  后台关键模块说明:
66
85
 
86
+ - [架构总览](docs/architecture/overview.md)
87
+ - [云端 Sandbox 与外部 Agent API](docs/architecture/cloud-sandbox-and-external-api.md)
67
88
  - [Local AI Core Kernel 与插件装配](docs/architecture/local-core-kernel.md)
68
89
  - [Workspace Router 路由层](docs/architecture/workspace-router.md)
69
90
  - [ACP 会话运行时](docs/architecture/acp-protocol.md)
@@ -73,9 +94,35 @@ flowchart LR
73
94
 
74
95
  ## New
75
96
 
97
+ ### 2026-05-16
98
+
99
+ - 优化桌面与 Web 聊天界面视觉层级:统一会话列表、消息气泡、工具结果卡片和输入区样式,降低装饰噪音,提升长对话可读性。
100
+ - 统一工作区、概览、知识库、自动化、系统诊断、项目与会话列表页面的轻量面板、列表行、状态摘要和操作按钮样式。
101
+
102
+ ### 2026-05-15
103
+
104
+ - 删除旧的 sandbox WebSocket proxy 兼容路径,云端 sandbox ACP 通信统一走 HTTP NDJSON bridge。
105
+ - 云端模式默认按 thread 复用 sandbox/ACP session,并增加 idle TTL 与阶段耗时日志,降低连续对话的首 token 延迟。
106
+ - 新增外部系统 API,可按 `user_id` 创建/复用项目、发起 agent run,并通过 per-run SSE 订阅回答过程;compose 模式下外部 workspace 默认持久化到 `AGENTDOCK_EXTERNAL_WORKSPACE_ROOT`。
107
+ - 新增 OpenAI Chat Completions 兼容入口 `/api/local/v1/openai/chat/completions`,通过 `metadata.user_id/project_id/thread_id` 映射外部身份,统一在 sandbox + yolo 模式下运行,并以 OpenAI chunk + `agentdock` 扩展字段流式返回思考、规划和工具进度。
108
+
109
+ ### 2026-05-14
110
+
111
+ - Docker Compose 支持一键启动 AgentDock Web、Local AI Core 和 OpenSandbox,Core 容器默认通过 compose 内网访问 OpenSandbox。
112
+ - 工作区“云端模式”改为选择 Deployment Profile,项目只保存 Sandbox Provider / Runtime Image 引用、state scope 和资源覆盖项。
113
+ - Sandbox 模式下工作区路径作为 OpenSandbox host mount 使用,Core 启动代理不再要求该路径在 Core 容器内可见。
114
+ - 新增部署诊断接口与 `pnpm e2e:compose`,用于检查 Web/Core/OpenSandbox/Docker socket/工作区挂载和 sandbox 镜像注册。
115
+ - Docker Compose 云端模式支持通过 `AGENTDOCK_SANDBOX_STATE_HOST_ROOT` 将 agent state 持久化到 OpenSandbox 可挂载的宿主机路径。
116
+ - Sandbox 镜像改为通用 HTTP NDJSON ACP bridge:容器 HTTP 接口只转发标准 ACP JSON-RPC,和具体 agent runtime 解耦。
117
+ - 云端模式新增 execution 元数据、user/project/thread/run state scope、配置迁移和 Pi provider 规范化,便于多用户云端部署与运行排障。
118
+ - Provider 从工作区配置中独立为共享模块,工作区现在选择 provider,并支持旧项目内嵌 provider 自动迁移。
119
+
76
120
  ### 2026-05-12
77
121
 
122
+ - 新增 OpenSandbox 沙箱运行基础:提供 `docker-compose.yaml` 手动启动 OpenSandbox server,项目可开启 sandbox 模式后通过一次性容器运行 agent ACP server,并为 Pi sandbox 预留按用户/项目/Agent 持久化的 runtime state 挂载。
78
123
  - 发布 AgentDock 0.1.44。
124
+ - 本地线程与 Lark/微信通道支持 `/help` 查看命令清单,支持 `/stop` 停止当前正在运行的任务。
125
+ - Local AI Core 新增结构化错误模型,ACP runtime 与微信通道会把启动失败、会话过期等问题回写为可诊断状态,并提供 diagnostics 错误摘要与 doctor 自检接口。
79
126
  - 拆分超大测试文件,按 Local Core 路由、ACP 进度、Lark/Weixin channel gateway 等边界组织集成测试。
80
127
 
81
128
  ### 2026-05-11
@@ -155,6 +202,22 @@ pnpm dev # 启动开发环境(Vite + Electron)
155
202
  pnpm start:core # 启动已构建的 Local AI Core
156
203
  ```
157
204
 
205
+ ## Docker Compose
206
+
207
+ ```bash
208
+ docker compose up --build
209
+ ```
210
+
211
+ 默认会启动 AgentDock Web、Local AI Core 和 OpenSandbox:
212
+
213
+ | 服务 | 地址 |
214
+ |---|---|
215
+ | AgentDock Web | `http://127.0.0.1:14173` |
216
+ | Local AI Core | `http://127.0.0.1:9831/api/local/v1` |
217
+ | OpenSandbox | `http://127.0.0.1:8080` |
218
+
219
+ Compose 模式下 Core 容器通过 `http://opensandbox-server:8080` 访问 OpenSandbox;桌面本地模式仍默认使用 `http://127.0.0.1:8080`。Core 数据默认保存在 Docker volume `agentdock-core-data`。
220
+
158
221
  ## macOS 打开应用
159
222
 
160
223
  如果安装后提示应用无法打开,可先清除隔离属性再启动:
@@ -187,6 +250,8 @@ xattr -cr /Applications/AgentDock.app
187
250
  | `AI_WORKSTATION_SMOKE_SCENARIO` | 冒烟测试场景 |
188
251
  | `AI_WORKSTATION_FORCE_RUNTIME_STATUS_ERROR` | 强制触发运行时状态错误,用于测试 |
189
252
  | `AI_WORKSTATION_DEV_SERVER_URL` | Electron 开发模式连接的前端地址 |
253
+ | `OPEN_SANDBOX_API_KEY` | OpenSandbox API key,compose 默认 `agentdock-local` |
254
+ | `AGENTDOCK_OPENSANDBOX_SERVER_URL` | OpenSandbox server 地址,容器内默认可设为 `http://opensandbox-server:8080` |
190
255
  | `AGENTDOCK_LOG_DIR` | 日志目录,默认 `~/.agentdock/logs` |
191
256
  | `AGENTDOCK_LOG_MAX_BYTES` | 单个日志文件轮动大小,默认 10MB |
192
257
  | `AGENTDOCK_LOG_MAX_FILES` | 单个日志保留的轮动文件数,默认 5 |
package/bin/agentdock.mjs CHANGED
@@ -75,11 +75,11 @@ Examples:
75
75
  `);
76
76
  }
77
77
 
78
- function ensureBuildOutput() {
79
- if (!existsSync(rendererRoot)) {
78
+ function ensureBuildOutput({ requireRenderer = true, requireCore = true } = {}) {
79
+ if (requireRenderer && !existsSync(rendererRoot)) {
80
80
  throw new Error(`Missing renderer build output: ${rendererRoot}`);
81
81
  }
82
- if (!existsSync(coreEntry)) {
82
+ if (requireCore && !existsSync(coreEntry)) {
83
83
  throw new Error(`Missing Local AI Core build output: ${coreEntry}`);
84
84
  }
85
85
  }
@@ -93,7 +93,7 @@ function coreEnv() {
93
93
  }
94
94
 
95
95
  function startCoreProcess({ stdio = 'inherit' } = {}) {
96
- ensureBuildOutput();
96
+ ensureBuildOutput({ requireRenderer: false, requireCore: true });
97
97
  return spawn(process.execPath, [coreEntry], {
98
98
  cwd: process.cwd(),
99
99
  env: coreEnv(),
@@ -268,7 +268,7 @@ function proxyToCore(req, res, coreOrigin) {
268
268
  }
269
269
 
270
270
  function startWebServer({ host, port, coreOrigin }) {
271
- ensureBuildOutput();
271
+ ensureBuildOutput({ requireRenderer: true, requireCore: false });
272
272
  const normalizedCoreOrigin = coreOrigin.replace(/\/+$/, '');
273
273
  const server = http.createServer((req, res) => {
274
274
  const requestUrl = new URL(req.url || '/', `http://${req.headers.host || `${host}:${port}`}`);
@@ -1 +1 @@
1
- import{j as t,g as a}from"./index-B36eowj-.js";const n={default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",success:"border-transparent bg-primary/10 text-primary dark:bg-primary/15 dark:text-primary",warning:"border-transparent bg-amber-100 text-amber-700 dark:bg-amber-500/15 dark:text-amber-200",danger:"border-transparent bg-destructive/10 text-destructive dark:bg-destructive/20 dark:text-red-200",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground",info:"border-transparent bg-blue-100 text-blue-700 dark:bg-blue-500/15 dark:text-blue-200"};function s({children:r,variant:e="default"}){return t.jsx("span",{className:a("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",n[e]),children:r})}export{s as B};
1
+ import{j as t,g as a}from"./index-cI3pWBnN.js";const n={default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",success:"border-transparent bg-primary/10 text-primary dark:bg-primary/15 dark:text-primary",warning:"border-transparent bg-amber-100 text-amber-700 dark:bg-amber-500/15 dark:text-amber-200",danger:"border-transparent bg-destructive/10 text-destructive dark:bg-destructive/20 dark:text-red-200",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground",info:"border-transparent bg-blue-100 text-blue-700 dark:bg-blue-500/15 dark:text-blue-200"};function s({children:r,variant:e="default"}){return t.jsx("span",{className:a("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",n[e]),children:r})}export{s as B};
@@ -0,0 +1,2 @@
1
+ import{u as ze,x as Me,r as n,j as s,C as pe,I as ye,M as U,B as C,g as ee,R as De,T as Ae}from"./index-cI3pWBnN.js";import{M as be}from"./Modal-CXhD_OWR.js";import{E as $}from"./EmptyState-BDBavDll.js";import{C as Le,A as Be}from"./ChatMarkdown-_Mdmltgv.js";import{l as Ke}from"./projects-Clar8lgb.js";import{l as Ue,g as $e,s as qe,a as je,r as Fe,d as Oe}from"./sessions-BWmAppwK.js";import{s as We,a as we,b as w,L as _,t as He}from"./session-utils-DpRwJ6Nh.js";import{S as Ve}from"./search-C3bvw7AR.js";import{P as Ge}from"./pencil-ywcJzeOo.js";import{T as Je}from"./trash-2-o-heXOgs.js";import{B as Qe}from"./bot-C9HBk5XH.js";import{U as Xe}from"./user-dPOzUqIc.js";import"./index-BKpv0P0s.js";import"./check-CutSg9a5.js";const Ye=1500,Ze=9e4;function es(a){return String(a||"").startsWith("web:")}function ss(a){return(a||[]).map((d,y)=>({id:`${d.timestamp||y}-${d.role}-${y}`,role:d.role==="user"?"user":"assistant",content:d.content,timestamp:d.timestamp,kind:d.kind}))}function ts(a){return a.map(d=>`${d.role}:${d.kind||"final"}:${d.timestamp||""}:${d.content}`).join(`
2
+ `)}function as(a){return a.filter(d=>d.role!=="user").length}function rs(a,d){var y;return(y=a.last_message)!=null&&y.content?a.last_message.content.replace(/\n/g," "):d("sessions.noMessages")}function ve(a){return(a instanceof Error?a.message:String(a||"")).trim().toLowerCase().includes("no active session found")}function ns(a,d){return(a instanceof Error?a.message:String(a||"")).trim().toLowerCase()?ve(a)?d("sessions.sessionUnavailable"):a instanceof Error?a.message:d("sessions.sendFailed"):d("sessions.sendFailed")}function js(){const{t:a}=ze(),[d,y]=Me(),[se,ke]=n.useState([]),[te,ae]=n.useState({}),[i,G]=n.useState(d.get("project")||""),[b,R]=n.useState([]),[r,h]=n.useState(null),[I,v]=n.useState([]),[J,re]=n.useState(""),[T,Q]=n.useState(""),[Ne,ne]=n.useState(!0),[Se,ie]=n.useState(!1),[Ce,le]=n.useState(!1),[X,oe]=n.useState(!1),[E,P]=n.useState("idle"),[de,k]=n.useState(""),[z,q]=n.useState(null),[F,Y]=n.useState(""),[M,O]=n.useState(null),[ce,W]=n.useState(null),me=n.useRef(null),x=n.useRef({project:"",sessionId:""}),H=n.useRef(null),V=n.useRef(null),j=d.get("project")||"",D=d.get("session")||"",ue=n.useMemo(()=>new Set(Object.values(te)),[te]),N=n.useMemo(()=>{const e=J.trim().toLowerCase();return e?b.filter(t=>We(t,e)):b},[J,b]),A=!!(r&&(r.live||ue.has(r.id))),Ee=!!(i&&A&&T.trim()&&!X&&E!=="sending"&&E!=="activating"&&E!=="polling"),f=n.useCallback((e,t)=>{const l=new URLSearchParams;e&&l.set("project",e),t&&l.set("session",t),y(l,{replace:!0})},[y]),c=n.useCallback((e="idle")=>{H.current&&(window.clearTimeout(H.current),H.current=null),V.current=null,P(e)},[]),xe=n.useCallback(e=>{R(t=>{const l=t.some(o=>o.id===e.id)?t.map(o=>o.id===e.id?{...o,...e}:o):[...t,e];return we(l)})},[]),fe=n.useCallback(async()=>{ne(!0);try{const{projects:e}=await Ke();ke(e||[])}finally{ne(!1)}},[]),u=n.useCallback(async e=>{if(!e)return R([]),ae({}),[];ie(!0);try{const{sessions:t,active_keys:l}=await Ue(e),o=we((t||[]).filter(m=>!es(m.session_key)));return ae(l||{}),x.current.project===e&&R(o),o}finally{ie(!1)}},[]),S=n.useCallback(async(e,t,l)=>{if(!e||!t)return h(null),v([]),null;l!=null&&l.silent||le(!0);try{const o=await $e(e,t,200);return x.current.project!==e||x.current.sessionId!==t||(xe(o),h({id:o.id,project:e,sessionKey:o.session_key,name:o.name||w(o),live:o.live,isDraft:!1,detail:o}),v(ss(o.history)),k("")),o}catch(o){return x.current.project===e&&x.current.sessionId===t&&k(o instanceof Error?o.message:a("sessions.loadFailed")),null}finally{l!=null&&l.silent||le(!1)}},[xe,a]),Z=n.useCallback(e=>{V.current=e,H.current=window.setTimeout(async()=>{const t=V.current;if(!t)return;if(Date.now()-t.startedAt>=Ze){c("timed_out"),k(a("sessions.pollTimeout")),await u(t.project);return}const l=await S(t.project,t.sessionId,{silent:!0});if(!l||!V.current){c(),await u(t.project);return}if(x.current.project!==t.project||x.current.sessionId!==t.sessionId){c();return}const o=ts(l.history),m=as(l.history)>t.assistantCountBefore,g=m&&o===t.lastSignature?t.stableCount+1:0,K={...t,lastSignature:o,stableCount:g};if(m&&g>=2){c(),await u(t.project);return}P("polling"),Z(K)},Ye)},[S,u,c,a]),he=n.useCallback((e,t,l)=>{c(),P("polling"),Z({project:e,sessionId:t,assistantCountBefore:l,stableCount:0,lastSignature:"",startedAt:Date.now()})},[Z,c]),Pe=n.useCallback(async e=>{if(c(),G(e),re(""),k(""),Q(""),!e){x.current={project:"",sessionId:""},h(null),v([]),R([]),f("");return}x.current={project:e,sessionId:""},h(null),v([]),f(e),await u(e)},[u,c,f]),L=n.useCallback(async e=>{if(e.isDraft||e.live||!e.id)return e;P("activating");try{await qe(e.project,{session_key:e.sessionKey,session_id:e.id}),await u(e.project);const t=await S(e.project,e.id,{silent:!0}),l={...e,live:(t==null?void 0:t.live)??!0,isDraft:!1,detail:t??e.detail,name:(t==null?void 0:t.name)||e.name};return h(l),l}finally{P("idle")}},[S,u]),B=n.useCallback(async(e,t)=>{c(),k(""),x.current={project:e,sessionId:t.id},G(e),f(e,t.id),h({id:t.id,project:e,sessionKey:t.session_key,name:w(t),live:t.live,isDraft:!1,detail:null});const l=await S(e,t.id);l&&!l.live&&await L({id:l.id,project:e,sessionKey:l.session_key,name:l.name||w(l),live:l.live,isDraft:!1,detail:l})},[L,S,c,f]),_e=n.useCallback(async()=>{c(),i&&(await u(i),r!=null&&r.id&&(x.current={project:i,sessionId:r.id},await S(i,r.id)))},[r==null?void 0:r.id,S,u,i,c]),ge=n.useCallback(async()=>{if(!T.trim()||!i)return;if(!A){k(a("sessions.sessionUnavailable"));return}const e=T.trim(),t=`${crypto.randomUUID()}-user`,l={id:t,role:"user",content:e,timestamp:new Date().toISOString()};Q(""),oe(!0),P("sending"),k("");try{const o=r||N[0];if(!o)throw new Error(a("sessions.noAvailableChatTarget"));let m=r&&r.id===o.id?r:{id:o.id,project:i,sessionKey:"session_key"in o?o.session_key:o.sessionKey,name:"session_key"in o?w(o):o.name,live:o.live,isDraft:!1,detail:null};(!r||r.id!==m.id)&&(x.current={project:i,sessionId:m.id},f(i,m.id),h(m)),m=await L(m),v(p=>[...p,l]);try{await je(i,{session_key:m.sessionKey,message:e})}catch(p){if(!ve(p)||!m.id)throw p;m=await L({...m,live:!1}),await je(i,{session_key:m.sessionKey,message:e})}const g=m.id;if(!g)throw new Error(a("sessions.createFailed"));const K=I.filter(p=>p.role!=="user").length;x.current={project:i,sessionId:g},h(p=>p&&{...p,id:g,isDraft:!1}),f(i,g),he(i,g,K),await u(i)}catch(o){c(),v(g=>g.filter(K=>K.id!==t));const m=ns(o,a);k(m)}finally{oe(!1)}},[r,A,L,T,N,I,u,i,he,c,a,f]),Re=n.useCallback(async()=>{if(!(!z||!i||!F.trim())){W("rename");try{await Fe(i,z.id,{name:F.trim()});const t=(await u(i)).find(l=>l.id===z.id);t&&(r==null?void 0:r.id)===t.id&&h(l=>l&&{...l,name:w(t)}),q(null),Y("")}finally{W(null)}}},[r==null?void 0:r.id,u,F,z,i]),Ie=n.useCallback(async()=>{if(!(!M||!i)){W("delete");try{await Oe(i,M.id);const e=await u(i);(r==null?void 0:r.id)===M.id&&(c(),x.current={project:i,sessionId:""},h(null),v([]),f(i)),e.length===0&&v([]),O(null)}finally{W(null)}}},[r==null?void 0:r.id,M,u,i,c,f]);n.useEffect(()=>{fe()},[fe]),n.useEffect(()=>{j&&(i&&i===j||G(j))},[j,i]),n.useEffect(()=>{if(!i){R([]);return}x.current.project=i,u(i)},[u,i]),n.useEffect(()=>{!i||D||r!=null&&r.id||N.length===0||B(i,N[0])},[r==null?void 0:r.id,N,B,D,i]),n.useEffect(()=>{if(!j||!D||i!==j)return;const e=b.find(t=>t.id===D);if(!e){b.length>0&&f(j,b[0].id);return}(r==null?void 0:r.id)!==e.id&&B(j,e)},[r==null?void 0:r.id,B,j,D,i,b,f]),n.useEffect(()=>{var e;(e=me.current)==null||e.scrollIntoView({behavior:"smooth"})},[I]),n.useEffect(()=>()=>c(),[c]);const Te=(r==null?void 0:r.name)||a("sessions.activeChat");return s.jsxs("div",{className:"grid min-h-[calc(100vh-8rem)] grid-cols-1 gap-4 xl:grid-cols-[22rem_minmax(0,1fr)] animate-fade-in",children:[s.jsxs(pe,{className:"flex flex-col gap-4 border-gray-200/80 bg-[#fbfbfd] p-4 shadow-none xl:h-[calc(100vh-8rem)] xl:overflow-hidden dark:border-white/[0.08] dark:bg-[#111214]",children:[s.jsx("div",{className:"flex items-center gap-3",children:s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.2em] text-gray-400",children:a("sessions.selectProject")}),s.jsxs("select",{value:i,onChange:e=>void Pe(e.target.value),className:"mt-2 w-full rounded-[18px] border border-gray-300/90 bg-white px-3 py-2 text-sm text-gray-900 transition-all focus:border-primary/40 focus:outline-none focus:ring-2 focus:ring-primary/10 dark:border-white/[0.1] dark:bg-[rgba(0,0,0,0.45)] dark:text-white",children:[s.jsx("option",{value:"",children:a("sessions.allProjects")}),se.map(e=>s.jsx("option",{value:e.name,children:e.name},e.name))]})]})}),s.jsxs("div",{className:"relative",children:[s.jsx(ye,{value:J,onChange:e=>re(e.target.value),placeholder:a("common.search"),className:"pl-9","aria-label":a("common.search")}),s.jsx(Ve,{size:16,className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"})]}),s.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[s.jsxs("div",{className:"mb-3 flex items-center justify-between text-xs text-gray-500 dark:text-gray-400",children:[s.jsx("span",{children:a("sessions.historyTitle")}),s.jsx("span",{children:N.length})]}),s.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto space-y-2 pr-1",children:Ne?s.jsx("div",{className:"flex h-32 items-center justify-center text-gray-400",children:s.jsx(_,{className:"animate-spin",size:18})}):i?Se&&b.length===0?s.jsx("div",{className:"flex h-32 items-center justify-center text-gray-400",children:s.jsx(_,{className:"animate-spin",size:18})}):b.length===0?s.jsx($,{message:a("sessions.noSessions"),icon:U}):N.length===0?s.jsx($,{message:a("sessions.noSessions"),icon:U}):N.map(e=>{const t=e.id===(r==null?void 0:r.id);return s.jsxs("div",{className:ee("rounded-[18px] border p-3 transition-all",t?"border-primary/25 bg-primary/5":"border-gray-200/80 bg-white hover:border-gray-300 dark:border-white/[0.08] dark:bg-white/[0.03]"),children:[s.jsxs("button",{type:"button",onClick:()=>void B(i,e),className:"w-full text-left","data-testid":"web-chat-session-open",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"truncate text-sm font-medium text-gray-900 dark:text-white",children:w(e)}),e.live||ue.has(e.id)?s.jsx("span",{className:"rounded-full bg-primary/10 px-2 py-0.5 text-[10px] text-primary",children:"live"}):s.jsx("span",{className:"rounded-full bg-gray-100 px-2 py-0.5 text-[10px] text-gray-400 dark:bg-white/[0.06] dark:text-gray-500",children:"history"})]}),s.jsx("p",{className:"mt-1 truncate text-xs text-gray-500 dark:text-gray-400",children:He(e.updated_at||e.created_at,a("sessions.justNow"))})]}),s.jsx("span",{className:"shrink-0 text-[10px] text-gray-400",children:e.history_count})]}),s.jsx("p",{className:"mt-2 line-clamp-2 text-xs text-gray-500 dark:text-gray-400",children:rs(e,a)})]}),s.jsxs("div",{className:"mt-3 flex items-center justify-end gap-1",children:[s.jsx(C,{size:"sm",variant:"ghost",onClick:()=>{q({id:e.id,name:w(e)}),Y(w(e))},"data-testid":"web-chat-session-rename",children:s.jsx(Ge,{size:14})}),s.jsx(C,{size:"sm",variant:"ghost",onClick:()=>O({id:e.id,name:w(e)}),"data-testid":"web-chat-session-delete",children:s.jsx(Je,{size:14})})]})]},e.id)}):s.jsx($,{message:a("sessions.projectRequired"),icon:U})})]})]}),s.jsxs(pe,{className:"flex min-h-[32rem] flex-col border-gray-200/80 bg-white p-0 shadow-none xl:h-[calc(100vh-8rem)] dark:border-white/[0.08] dark:bg-[#0b0d10]",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-gray-200/80 px-5 py-4 dark:border-white/[0.08]",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("h2",{className:"truncate text-lg font-semibold text-gray-900 dark:text-white",children:Te})}),s.jsx("p",{className:"mt-1 truncate text-sm text-gray-500 dark:text-gray-400",children:r?r.project:a("sessions.sendHint")})]}),s.jsxs(C,{size:"sm",variant:"secondary",onClick:()=>void _e(),"data-testid":"web-chat-refresh",children:[s.jsx(De,{size:14})," ",a("common.refresh")]})]}),s.jsx("div",{className:"flex-1 overflow-y-auto px-5 py-5",children:i?Ce?s.jsx("div",{className:"flex h-full items-center justify-center text-gray-400",children:s.jsx(_,{className:"animate-spin",size:22})}):I.length===0?s.jsx("div",{className:"flex h-full items-center justify-center",children:s.jsx($,{message:a(r?"sessions.noMessages":"sessions.sendHint"),icon:U})}):s.jsxs("div",{className:"mx-auto max-w-4xl space-y-5",children:[I.map(e=>{const t=e.role==="user";return s.jsxs("div",{className:ee("flex gap-3",t?"justify-end":"justify-start"),children:[!t&&s.jsx("div",{className:"mt-1 flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-[#f5f5f7] dark:bg-white/[0.06]",children:s.jsx(Qe,{size:16,className:"text-primary"})}),s.jsx("div",{className:ee("max-w-[78%] rounded-[20px] px-5 py-3.5 text-sm",t?"chat-user-glass rounded-br-sm text-slate-950 dark:text-slate-50":"rounded-bl-sm border border-gray-200 bg-[#fbfbfd] text-gray-900 dark:border-white/[0.08] dark:bg-[rgba(255,255,255,0.04)] dark:text-gray-100"),children:s.jsx(Le,{content:e.content,isUser:t})}),t&&s.jsx("div",{className:"mt-1 flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-[#f0f0f0] dark:bg-white/[0.08]",children:s.jsx(Xe,{size:16,className:"text-gray-500 dark:text-gray-300"})})]},e.id)}),s.jsx("div",{ref:me})]}):s.jsx("div",{className:"flex h-full items-center justify-center",children:s.jsx($,{message:a("sessions.emptySelection"),icon:U})})}),s.jsxs("div",{className:"border-t border-gray-200/80 px-5 py-4 dark:border-white/[0.08]",children:[de&&s.jsx("div",{className:"mb-3 rounded-xl border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-600 dark:border-red-900/40 dark:bg-red-950/20 dark:text-red-300",children:de}),E==="polling"&&s.jsxs("div",{className:"mb-3 flex items-center gap-2 text-sm text-gray-500 dark:text-gray-400",children:[s.jsx(_,{size:14,className:"animate-spin"}),s.jsx("span",{children:a("sessions.waitingForReply")})]}),E==="activating"&&s.jsxs("div",{className:"mb-3 flex items-center gap-2 text-sm text-gray-500 dark:text-gray-400",children:[s.jsx(_,{size:14,className:"animate-spin"}),s.jsx("span",{children:a("sessions.preparingChat")})]}),s.jsx("div",{className:"mx-auto max-w-4xl",children:s.jsxs("div",{className:"relative",children:[s.jsx(Ae,{value:T,onChange:e=>Q(e.target.value),onKeyDown:e=>{e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),ge())},rows:3,placeholder:a(i?"sessions.messageInput":"sessions.projectRequired"),disabled:!i||!A||X||E==="polling"||E==="activating",className:"min-h-[104px] rounded-[22px] border-gray-200 bg-[#fbfbfd] px-4 pb-16 pt-3 text-[15px] leading-6 dark:border-white/[0.08] dark:bg-[rgba(255,255,255,0.04)] sm:min-h-[112px] sm:px-5 sm:pt-4","data-testid":"web-chat-input"}),s.jsx(C,{onClick:()=>void ge(),disabled:!Ee,size:"icon","aria-label":a("sessions.send"),className:"absolute bottom-3 right-3 h-11 w-11 rounded-full bg-primary px-0 text-white shadow-none hover:bg-[#0071e3] disabled:bg-slate-300 disabled:text-white disabled:opacity-100 dark:bg-primary dark:text-white dark:hover:bg-[#2997ff] dark:disabled:bg-white/20 dark:disabled:text-white/55 sm:h-12 sm:w-12","data-testid":"web-chat-send",children:X?s.jsx(_,{size:18,className:"animate-spin"}):s.jsx(Be,{size:22,strokeWidth:2.2})})]})}),!A&&r&&s.jsx("div",{className:"mt-3 rounded-xl border border-gray-200 bg-gray-50 px-4 py-3 text-sm text-gray-500 dark:border-white/[0.08] dark:bg-white/[0.03] dark:text-gray-400",children:a("sessions.notLiveHint")})]})]}),s.jsx(be,{open:!!z,onClose:()=>q(null),title:a("sessions.renameTitle"),children:s.jsxs("div",{className:"space-y-4",children:[s.jsx(ye,{value:F,onChange:e=>Y(e.target.value),placeholder:a("sessions.renamePlaceholder"),"data-testid":"web-chat-rename-input"}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(C,{variant:"secondary",onClick:()=>q(null),children:a("common.cancel")}),s.jsx(C,{onClick:()=>void Re(),loading:ce==="rename","data-testid":"web-chat-rename-save",children:a("common.save")})]})]})}),s.jsx(be,{open:!!M,onClose:()=>O(null),title:a("sessions.deleteConfirmTitle"),children:s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:a("sessions.deleteConfirmBody")}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(C,{variant:"secondary",onClick:()=>O(null),children:a("common.cancel")}),s.jsx(C,{variant:"danger",onClick:()=>void Ie(),loading:ce==="delete","data-testid":"web-chat-delete-confirm",children:a("common.delete")})]})]})})]})}export{js as default};
@@ -1,4 +1,4 @@
1
- import{c as qi,H as dr,j as Te,g as Bo,r as Fo}from"./index-B36eowj-.js";import{C as zo}from"./check-BnclClRU.js";/**
1
+ import{c as qi,H as dr,j as Te,g as Bo,r as Fo}from"./index-cI3pWBnN.js";import{C as zo}from"./check-CutSg9a5.js";/**
2
2
  * @license lucide-react v0.487.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -0,0 +1,21 @@
1
+ import{c as m,u as B,r as n,j as e,B as c,R as E,L as $,$ as H,I as q,a0 as T,a1 as V}from"./index-cI3pWBnN.js";import{g as F,q as X,v as R,w as G,x as J}from"./desktop-DATgk_ka.js";import{B as x}from"./Badge-BIesaDYG.js";import{P as O,S as l,a as C}from"./Page-KUuFYgjg.js";import{S as Q}from"./shield-check-CVx1mEs2.js";import{S as W,P as Y}from"./save-D6ov4CNv.js";/**
2
+ * @license lucide-react v0.487.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const Z=[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]],ee=m("file-code",Z);/**
7
+ * @license lucide-react v0.487.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const se=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],te=m("rotate-ccw",se);/**
12
+ * @license lucide-react v0.487.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const ae=[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]],ne=m("scroll-text",ae);/**
17
+ * @license lucide-react v0.487.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const re=[["path",{d:"M11 2v2",key:"1539x4"}],["path",{d:"M5 2v2",key:"1yf1q8"}],["path",{d:"M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1",key:"rb5t3r"}],["path",{d:"M8 15a6 6 0 0 0 12 0v-3",key:"x18d4x"}],["circle",{cx:"20",cy:"10",r:"2",key:"ts1r5v"}]],ie=m("stethoscope",re);function le(a){return a==="api_ready"?"success":a==="error"?"danger":a==="starting"?"warning":"neutral"}function xe(){const{t:a}=B(),[t,h]=n.useState(null),[o,M]=n.useState(null),[p,f]=n.useState([]),[d,I]=n.useState(null),[u,j]=n.useState(""),[D,v]=n.useState(""),[P,y]=n.useState(!0),[w,N]=n.useState(!1),[z,k]=n.useState(!1),[b,i]=n.useState(""),g=n.useCallback(async()=>{y(!0);try{const[s,r,S]=await Promise.allSettled([F(),X(),R()]);s.status==="fulfilled"&&(h(s.value),j(s.value.settings.knowledge.baseUrl||""),v(s.value.settings.knowledge.baseUrl||"")),r.status==="fulfilled"&&M(r.value),S.status==="fulfilled"&&f(S.value)}finally{y(!1)}},[]);n.useEffect(()=>{g()},[g]);const A=async()=>{if(confirm(a("system.restartConfirm")))try{await T(),i(a("common.success")),await g()}catch(s){i(s.message)}},L=async()=>{if(confirm(a("system.reloadConfirm")))try{await V(),i(a("common.success")),await g()}catch(s){i(s.message)}},U=async()=>{N(!0);try{const s=await G({knowledge:{baseUrl:u,authMode:(t==null?void 0:t.settings.knowledge.authMode)||"none",token:(t==null?void 0:t.settings.knowledge.token)||"",headerName:(t==null?void 0:t.settings.knowledge.headerName)||"X-API-Key",defaultCollection:(t==null?void 0:t.settings.knowledge.defaultCollection)||"personal_knowledge"}});h(r=>r&&{...r,settings:s}),v(s.knowledge.baseUrl||""),i(a("common.success"))}catch(s){i(s.message)}finally{N(!1)}},_=async()=>{k(!0);try{const s=await J();I(s),f(await R()),i(`Diagnostics completed with ${s.status} status.`)}catch(s){i(s.message)}finally{k(!1)}},K=u!==D;return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsx(O,{title:a("nav.system"),description:"Runtime health, logs, and plugin diagnostics. Advanced config is available read-only from the diagnostics drawer.",actions:e.jsxs(e.Fragment,{children:[e.jsxs(c,{variant:"secondary",onClick:L,children:[e.jsx(E,{size:16})," ",a("system.reload")]}),e.jsxs(c,{variant:"danger",onClick:A,children:[e.jsx(te,{size:16})," ",a("system.restart")]}),e.jsx($,{to:"/system/logs",children:e.jsxs(c,{variant:"secondary",children:[e.jsx(ne,{size:16})," ",a("system.logs")]})})]})}),b?e.jsx("div",{role:"status",className:"rounded-lg border border-primary/20 bg-primary/10 px-4 py-3 text-sm text-primary",children:b}):null,e.jsxs("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-3",children:[e.jsxs(l,{className:"app-panel",title:"Runtime",description:P?"Loading...":"Local service status.",children:[e.jsx(C,{tone:le(t==null?void 0:t.phase),children:(t==null?void 0:t.phase)||"unknown"}),e.jsx("p",{className:"mt-3 text-sm text-muted-foreground",children:t!=null&&t.pendingRestart?"Restart required to apply saved changes.":"No pending restart."})]}),e.jsx(l,{className:"app-panel",title:"Config",description:"Active config file location.",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ee,{size:18,className:"mt-0.5 text-primary"}),e.jsx("p",{className:"break-all font-mono text-xs leading-5 text-muted-foreground",children:(t==null?void 0:t.settings.configPath)||(t==null?void 0:t.configFile.path)||"-"})]})}),e.jsxs(l,{className:"app-panel",title:"Plugins",description:"Health summary only.",children:[e.jsx("p",{className:"text-2xl font-semibold text-foreground",children:o?`${o.enabledPluginCount}/${o.pluginCount}`:"-"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"enabled plugins"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 xl:grid-cols-2",children:[e.jsx(l,{className:"app-panel",title:"Diagnostics",description:"Structured runtime and channel health checks.",actions:e.jsxs(c,{size:"sm",variant:"secondary",onClick:()=>void _(),loading:z,children:[e.jsx(ie,{size:14})," Run doctor"]}),children:d?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{tone:d.status==="pass"?"success":d.status==="warn"?"warning":"danger",children:d.status}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Checked ",new Date(d.checkedAt).toLocaleString()]})]}),e.jsx("div",{className:"space-y-2",children:d.checks.map(s=>{var r;return e.jsx("div",{className:"app-list-row",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:s.label}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:s.summary}),(r=s.errorInfo)!=null&&r.suggestedAction?e.jsx("p",{className:"mt-1 text-xs leading-5 text-amber-700 dark:text-amber-200",children:s.errorInfo.suggestedAction}):null]}),e.jsx(x,{variant:s.status==="pass"?"success":s.status==="warn"?"warning":"danger",children:s.status})]})},s.id)})})]}):e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-dashed border-border px-4 py-3 text-sm text-muted-foreground",children:[e.jsx(Q,{size:16,className:"mt-0.5 shrink-0"}),e.jsx("p",{children:"Run doctor to validate config, runtime readiness, channel health, and log access."})]})}),e.jsx(l,{className:"app-panel",title:"Recent Errors",description:"Aggregated runtime and channel failures from the current window.",children:p.length===0?e.jsx("div",{className:"py-8 text-sm text-muted-foreground",children:"No aggregated errors in the current diagnostics window."}):e.jsx("div",{className:"space-y-3",children:p.map(s=>e.jsx("div",{className:"app-list-row",children:e.jsx("div",{className:"flex items-start justify-between gap-3",children:e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(H,{size:14,className:"text-amber-500"}),e.jsx("p",{className:"text-sm font-medium text-foreground",children:s.errorInfo.userMessage}),e.jsx(x,{variant:s.errorInfo.severity==="error"?"danger":s.errorInfo.severity==="warning"?"warning":"info",children:s.errorInfo.code})]}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:s.errorInfo.message}),s.errorInfo.suggestedAction?e.jsx("p",{className:"mt-1 text-xs leading-5 text-amber-700 dark:text-amber-200",children:s.errorInfo.suggestedAction}):null,e.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:[s.count," occurrence(s), last seen ",new Date(s.lastSeenAt).toLocaleString()]})]})})},s.key))})})]}),e.jsx(l,{className:"app-panel",title:"Knowledge",description:"System-wide knowledge API connection.",actions:e.jsxs(c,{size:"sm",onClick:()=>void U(),loading:w,disabled:!K&&!w,children:[e.jsx(W,{size:14})," Save"]}),children:e.jsx(q,{label:"Knowledge base URL",value:u,onChange:s=>j(s.target.value),placeholder:"http://127.0.0.1:16007"})}),e.jsx(l,{className:"app-panel",title:a("system.plugins"),description:"Plugin state is read-only in the daily UI. Use backend config for advanced changes.",children:o?o.plugins.length===0?e.jsx("div",{className:"py-8 text-sm text-muted-foreground",children:"No plugins registered."}):e.jsx("div",{className:"divide-y divide-border",children:o.plugins.map(s=>e.jsxs("div",{className:"flex items-start justify-between gap-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Y,{size:15,className:"text-muted-foreground"}),e.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:s.pluginId})]}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:s.health.summary||s.manifest.provides.join(", ")||"No declared capabilities"})]}),e.jsx(x,{variant:s.health.status==="healthy"?"success":s.health.status==="failed"?"danger":"warning",children:s.health.status})]},s.pluginId))}):e.jsx("div",{className:"py-8 text-sm text-muted-foreground",children:"Loading..."})})]})}export{xe as default};
@@ -0,0 +1 @@
1
+ import{J as P,l as R,K as z,N as D,O as W,P as O,u as B,r as n,j as t,s as F,B as c,G as L,C as U,E as k,I as f,T as G}from"./index-cI3pWBnN.js";import{B as u}from"./Badge-BIesaDYG.js";import{M as H}from"./Modal-CXhD_OWR.js";import{S as w}from"./Select-Djc8BXMC.js";import{E as K}from"./EmptyState-BDBavDll.js";import{P as _}from"./Page-KUuFYgjg.js";import{P as $}from"./plus-BEj14BBV.js";import{P as q}from"./play-AtN492Cx.js";import{P as Q}from"./pencil-ywcJzeOo.js";import{T as V}from"./trash-2-o-heXOgs.js";import"./index-BKpv0P0s.js";import"./chevron-down-DrydR4i3.js";import"./check-CutSg9a5.js";const X=a=>P(),Y=a=>D(a),Z=(a,o)=>z(a,o),ee=a=>W(a),te=a=>O(a),ae=()=>R().then(a=>a.workspaces),x={workspaceId:"",executionMode:"same-thread",triggerType:"cron",cronExpr:"0 9 * * *",runAt:"",promptTemplate:"",description:"",chatId:"",platformUserId:"",threadId:"",enabled:!0};function se(a){return a?{workspaceId:a.workspaceId,executionMode:a.executionMode,triggerType:a.triggerType,cronExpr:a.cronExpr||"0 9 * * *",runAt:a.runAt?String(a.runAt).slice(0,16):"",promptTemplate:a.promptTemplate,description:a.description,chatId:a.route.channelId,platformUserId:a.route.participantId||"",threadId:a.route.threadId||"",enabled:a.enabled}:x}function re(a){return{workspaceId:a.workspaceId,platform:"local",route:{type:"local.thread",channelId:a.workspaceId||"local",...a.threadId?{threadId:a.threadId}:{}},executionMode:a.executionMode||"same-thread",triggerType:a.triggerType,...a.triggerType==="cron"?{cronExpr:a.cronExpr,runAt:void 0}:{runAt:new Date(a.runAt).toISOString(),cronExpr:void 0},promptTemplate:a.promptTemplate,description:a.description,enabled:a.enabled}}function ye(){const{t:a}=B(),[o,I]=n.useState([]),[m,j]=n.useState([]),[T,y]=n.useState(!0),[C,d]=n.useState(!1),[E,v]=n.useState(!1),[p,h]=n.useState(null),[s,r]=n.useState(x),S=n.useMemo(()=>m.map(e=>t.jsx("option",{value:e.id,children:e.name},e.id)),[m]),i=n.useCallback(async()=>{y(!0);try{const[e,l]=await Promise.all([X(),ae()]);I(e.jobs||[]),j(l),r(g=>g.workspaceId||l.length===0?g:{...g,workspaceId:l[0].id})}finally{y(!1)}},[]);n.useEffect(()=>{i();const e=F(l=>{(l.type==="scheduler.job.updated"||l.type==="scheduler.run.updated")&&i()});return()=>e()},[i]);const N=()=>{var e;h(null),r({...x,workspaceId:((e=m[0])==null?void 0:e.id)||""}),d(!0)},b=e=>{h(e),r(se(e)),d(!0)},J=async()=>{if(!(!s.workspaceId||!s.promptTemplate.trim())&&!(s.triggerType==="once"&&!s.runAt)){v(!0);try{const e=re(s);p?await Z(p.id,e):await Y(e),d(!1),h(null),r(x),await i()}finally{v(!1)}}},A=async e=>{confirm(a("common.confirmDelete"))&&(await ee(e),await i())},M=async e=>{await te(e),await i()};return T&&o.length===0?t.jsx("div",{className:"flex items-center justify-center h-64 text-gray-400 animate-pulse",children:a("common.loading")}):t.jsxs("div",{className:"space-y-4 animate-fade-in",children:[t.jsx(_,{title:a("cron.title"),description:"Create simple scheduled prompts for a workspace.",actions:t.jsxs(c,{onClick:N,children:[t.jsx($,{size:16})," ",a("cron.add")]})}),o.length===0?t.jsx(K,{message:a("cron.noJobs"),icon:L}):t.jsx("div",{className:"space-y-3",children:o.map(e=>t.jsx(U,{className:"app-panel",children:t.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",children:[t.jsxs("div",{className:"flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1 flex-wrap",children:[t.jsx("span",{className:"font-medium text-gray-900 dark:text-white text-sm",children:e.description||e.id}),t.jsx(u,{variant:e.enabled?"success":"default",children:e.enabled?a("cron.enabled"):"disabled"}),t.jsx(u,{variant:"default",children:e.triggerType}),t.jsx(u,{variant:"default",children:e.platform}),e.lastStatus&&t.jsx(u,{variant:e.lastStatus==="failed"?"danger":"default",children:e.lastStatus})]}),t.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-xs text-gray-500 dark:text-gray-400 mt-2",children:[t.jsxs("span",{children:[t.jsx("strong",{children:"Workspace:"})," ",e.workspaceId]}),t.jsxs("span",{children:[t.jsx("strong",{children:"Execution:"})," ",e.executionMode]}),t.jsxs("span",{children:[t.jsx("strong",{children:"Route:"})," ",e.route.channelId," / ",e.route.participantId]}),t.jsxs("span",{children:[t.jsxs("strong",{children:[e.triggerType==="cron"?a("cron.expression"):"Run at",":"]})," ",e.triggerType==="cron"?e.cronExpr:k(e.runAt||"")]}),e.route.threadId&&t.jsxs("span",{children:[t.jsx("strong",{children:"Thread:"})," ",e.route.threadId]}),e.lastRunAt&&t.jsxs("span",{children:[t.jsxs("strong",{children:[a("cron.lastRun"),":"]})," ",k(e.lastRunAt)]})]}),t.jsx("p",{className:"mt-3 line-clamp-3 rounded-[16px] bg-black/[0.035] px-3 py-2 text-sm leading-6 text-gray-700 dark:bg-white/[0.05] dark:text-gray-300",children:e.promptTemplate}),e.lastError&&t.jsx("p",{className:"text-xs text-red-500 mt-2",children:e.lastError})]}),t.jsxs("div",{className:"flex shrink-0 gap-2 lg:pt-0",children:[t.jsx(c,{size:"sm",variant:"secondary",className:"app-icon-button",onClick:()=>void M(e.id),"aria-label":"Run now",children:t.jsx(q,{size:14})}),t.jsx(c,{size:"sm",variant:"secondary",className:"app-icon-button",onClick:()=>b(e),"aria-label":"Edit job",children:t.jsx(Q,{size:14})}),t.jsx(c,{size:"sm",variant:"danger",className:"app-icon-button",onClick:()=>void A(e.id),"aria-label":"Delete job",children:t.jsx(V,{size:14})})]})]})},e.id))}),t.jsx(H,{open:C,onClose:()=>d(!1),title:p?"Edit scheduler job":a("cron.add"),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs(w,{label:"Workspace",value:s.workspaceId,onChange:e=>r({...s,workspaceId:e.target.value}),children:[t.jsx("option",{value:"",children:"Select workspace"}),S]}),t.jsxs(w,{label:"Schedule type",value:s.triggerType,onChange:e=>r({...s,triggerType:e.target.value}),children:[t.jsx("option",{value:"cron",children:"Repeating"}),t.jsx("option",{value:"once",children:"One time"})]}),s.triggerType==="cron"?t.jsxs("div",{className:"space-y-2",children:[t.jsx(f,{label:a("cron.expression"),value:s.cronExpr,onChange:e=>r({...s,cronExpr:e.target.value}),placeholder:"0 9 * * *"}),t.jsx("div",{className:"flex flex-wrap gap-2",children:[["0 9 * * *","Daily 09:00"],["0 9 * * 1","Weekly Mon"],["*/30 * * * *","Every 30m"]].map(([e,l])=>t.jsx("button",{type:"button",onClick:()=>r({...s,cronExpr:e}),className:`app-segment text-xs ${s.cronExpr===e?"app-segment-active":"app-segment-idle"}`,children:l},e))})]}):t.jsx(f,{label:"Run at",type:"datetime-local",value:s.runAt,onChange:e=>r({...s,runAt:e.target.value})}),t.jsx(f,{label:a("cron.description"),value:s.description,onChange:e=>r({...s,description:e.target.value})}),t.jsx(G,{label:a("cron.prompt"),value:s.promptTemplate,onChange:e=>r({...s,promptTemplate:e.target.value}),rows:4,placeholder:"Summarize today's blockers and post a status update."}),t.jsxs("label",{className:"flex items-center gap-2 text-sm text-gray-700 dark:text-gray-300",children:[t.jsx("input",{type:"checkbox",checked:s.enabled,onChange:e=>r({...s,enabled:e.target.checked})}),a("cron.enabled")]}),t.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[t.jsx(c,{variant:"secondary",onClick:()=>d(!1),children:a("common.cancel")}),t.jsx(c,{onClick:()=>void J(),disabled:E,children:a(p?"common.save":"cron.add")})]})]})})]})}export{ye as default};
@@ -0,0 +1,26 @@
1
+ import{c as b,u as ae,r,a as re,l as ie,b as L,d as ne,e as de,j as e,M as le,W as ce,F as V,C as f,B as oe,R as me,f as xe,L as E,S as ue,g as he}from"./index-cI3pWBnN.js";import{B as d}from"./Badge-BIesaDYG.js";import{E as j}from"./EmptyState-BDBavDll.js";import{P as pe}from"./Page-KUuFYgjg.js";import{l as ge}from"./projects-Clar8lgb.js";import{l as fe,r as je,o as be,a as ve}from"./desktop-DATgk_ka.js";import{S as ke,A as K}from"./server-C1Uyedyx.js";import{B as ye}from"./book-open-9n4Kxc7E.js";import{S as O}from"./shield-check-CVx1mEs2.js";/**
2
+ * @license lucide-react v0.487.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const Ne=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],we=b("activity",Ne);/**
7
+ * @license lucide-react v0.487.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const Re=[["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M17.5 17.5 16 16.3V14",key:"akvzfd"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],Ae=b("calendar-clock",Re);/**
12
+ * @license lucide-react v0.487.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const Se=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Le=b("circle-check",Se);/**
17
+ * @license lucide-react v0.487.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const Me=[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]],U=b("cpu",Me);/**
22
+ * @license lucide-react v0.487.0 - ISC
23
+ *
24
+ * This source code is licensed under the ISC license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */const Ee=[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]],Ce=b("list-checks",Ee);function _e({title:a,description:t,to:l,icon:o,primary:m}){return e.jsxs(E,{to:l,className:["group flex min-h-[112px] flex-col justify-between rounded-[18px] border p-5 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-ring",m?"border-primary/20 bg-primary/5 text-foreground hover:bg-primary/10 dark:bg-primary/10 dark:hover:bg-primary/15":"border-black/[0.08] bg-white text-foreground hover:bg-[#fcfcfd] dark:border-white/[0.07] dark:bg-white/[0.04] dark:hover:bg-white/[0.07]"].join(" "),children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-primary/10 text-primary dark:bg-primary/15",children:e.jsx(o,{size:20})}),e.jsx(K,{size:17,className:"mt-1 text-muted-foreground/45 transition-colors group-hover:text-foreground"})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-foreground",children:a}),e.jsx("p",{className:"mt-2 max-w-sm text-sm leading-5 text-muted-foreground",children:t})]})]})}function N({label:a,value:t,detail:l,tone:o="neutral"}){return e.jsxs("div",{className:"app-surface p-4",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:a}),e.jsx("p",{className:he("mt-2 text-2xl font-semibold",o==="primary"?"text-primary":o==="warning"?"text-amber-600 dark:text-amber-300":"text-foreground"),children:t}),e.jsx("p",{className:"mt-1 truncate text-xs text-muted-foreground",children:l})]})}function ze(a){return a.readiness==="ready"?"success":a.readiness==="failed"?"danger":a.readiness==="degraded"?"warning":a.status==="installed"?"success":a.status==="error"?"danger":"warning"}function De(a){return a.readiness||(a.status==="installed"?"ready":"unknown")}function M({title:a,description:t,tasks:l,empty:o,urgent:m}){return e.jsxs(f,{className:"app-panel overflow-hidden p-0",children:[e.jsx("div",{className:"border-b border-black/[0.08] px-5 py-4 dark:border-white/[0.07]",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-foreground",children:a}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:t})]}),e.jsx(d,{variant:m&&l.length>0?"warning":"secondary",children:l.length})]})}),l.length===0?e.jsx("div",{className:"p-5",children:e.jsx(j,{message:o,icon:Ce})}):e.jsx("div",{className:"divide-y divide-black/[0.08] dark:divide-white/[0.07]",children:l.map(c=>e.jsxs("div",{className:"px-5 py-4 transition-colors hover:bg-black/[0.025] dark:hover:bg-white/[0.035]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:c.title}),e.jsxs("p",{className:"mt-1 truncate text-xs text-muted-foreground",children:[c.workspaceId," · ",c.runtimeId]})]}),e.jsx(d,{variant:c.status==="failed"?"danger":c.status==="completed"?"success":"info",children:c.status})]}),e.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:["Updated ",new Date(c.updatedAt).toLocaleString()]})]},c.taskId))})]})}function Pe({approvals:a}){return e.jsxs(f,{className:"app-panel overflow-hidden p-0",children:[e.jsx("div",{className:"border-b border-black/[0.08] px-5 py-4 dark:border-white/[0.07]",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-foreground",children:"待审批"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"高风险操作会在这里等待确认或拒绝。"})]}),e.jsx(d,{variant:a.length>0?"warning":"secondary",children:a.length})]})}),a.length===0?e.jsx("div",{className:"p-5",children:e.jsx(j,{message:"暂无待审批操作",icon:O})}):e.jsx("div",{className:"divide-y divide-black/[0.08] dark:divide-white/[0.07]",children:a.map(t=>e.jsxs("div",{className:"px-5 py-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:t.title}),e.jsxs("p",{className:"mt-1 truncate text-xs text-muted-foreground",children:[t.workspaceId," · ",t.kind]})]}),e.jsx(d,{variant:t.riskLevel==="high"?"danger":"warning",children:t.riskLevel})]}),e.jsx("p",{className:"mt-2 line-clamp-2 text-xs leading-5 text-muted-foreground",children:t.description})]},t.approvalId))})]})}function Te({events:a}){return e.jsxs(f,{className:"app-panel overflow-hidden p-0",children:[e.jsxs("div",{className:"border-b border-black/[0.08] px-5 py-4 dark:border-white/[0.07]",children:[e.jsx("h2",{className:"text-base font-semibold text-foreground",children:"审计记录"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"最近的任务、审批和权限事件。"})]}),a.length===0?e.jsx("div",{className:"p-5",children:e.jsx(j,{message:"暂无审计记录",icon:O})}):e.jsx("div",{className:"divide-y divide-black/[0.08] dark:divide-white/[0.07]",children:a.map(t=>e.jsxs("div",{className:"px-5 py-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:t.summary}),e.jsxs("p",{className:"mt-1 truncate text-xs text-muted-foreground",children:[t.type," · ",t.actor||"system"]})]}),t.riskLevel?e.jsx(d,{variant:t.riskLevel==="high"?"danger":"secondary",children:t.riskLevel}):null]}),e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:new Date(t.createdAt).toLocaleString()})]},t.auditId))})]})}function Ke(){const{t:a}=ae(),[t,l]=r.useState([]),[o,m]=r.useState([]),[c,C]=r.useState([]),[w,_]=r.useState([]),[Q,z]=r.useState([]),[R,D]=r.useState([]),[G,P]=r.useState([]),[J,T]=r.useState(!0),[X,I]=r.useState(!1),[Y,p]=r.useState(!1),[q,$]=r.useState(""),[B,g]=r.useState(""),{desktopRuntime:x,desktopWorkspace:W,knowledgeModule:F,schedulerModule:H}=re(),A=o.filter(s=>s.installed),v=[{title:"继续聊天",description:"打开本地对话,继续当前项目里的 agent 线程。",to:"/chat",icon:le,primary:!0},{title:"工作区",description:"管理项目、平台、模型和本地运行配置。",to:W?"/workspace":"/projects",icon:W?ce:V}];F&&v.push({title:"知识库",description:"上传文档,维护可被检索的项目资料。",to:"/knowledge",icon:ye}),H&&v.push({title:"定时任务",description:"查看和管理自动执行的计划任务。",to:"/cron",icon:Ae}),(!F||!H)&&v.push({title:"系统设置",description:"查看配置、日志和桌面应用偏好。",to:"/system",icon:ue});const k=r.useCallback(async()=>{var s;T(!0),$(""),g("");try{if(x){const[h,i]=await Promise.all([ie(),fe().then(u=>({status:"fulfilled",runtimes:u}),u=>({status:"rejected",error:u}))]),[S,y,ee]=await Promise.all([L({status:["created","queued","running"],limit:6}),L({status:"waiting_for_user",limit:6}),L({status:["completed","failed","cancelled"],limit:6})]),[se,te]=await Promise.all([ne({status:"pending",limit:6}),de({limit:6})]);C(S.tasks||[]),_(y.tasks||[]),z(ee.tasks||[]),D(se.approvals||[]),P(te.events||[]),l((h.workspaces||[]).map(u=>({name:u.name,agent_type:u.agentType,platforms:u.platforms,sessions_count:u.sessionsCount,heartbeat_enabled:u.heartbeatEnabled}))),i.status==="fulfilled"?m(i.runtimes):(m([]),g(((s=i.error)==null?void 0:s.message)||String(i.error)));return}const n=await ge();l(n.projects||[]),m([]),C([]),_([]),z([]),D([]),P([])}catch(n){$(n.message||String(n))}finally{T(!1)}},[x]),Z=r.useCallback(async()=>{I(!0),p(!0),g("");try{m(await je())}catch(s){g(s.message||String(s))}finally{I(!1),p(!1)}},[]);return r.useEffect(()=>{k();const s=()=>k();window.addEventListener("cc:refresh",s);const n=x?be(()=>{k()}):()=>{},h=x?ve(i=>{if(i.type==="runtime.detect.started"){p(!0);return}if(i.type==="runtime.detect.completed"){p(!1),m(i.runtimes);return}if(i.type==="runtime.detect.failed"){p(!1),g(i.error);return}i.type==="runtime.status.changed"&&m(S=>S.map(y=>y.runtimeId===i.runtime.runtimeId?i.runtime:y))}):()=>{};return()=>{window.removeEventListener("cc:refresh",s),n(),h()}},[x,k]),J&&t.length===0?e.jsx("div",{className:"flex h-64 items-center justify-center text-muted-foreground",children:e.jsx(we,{className:"animate-pulse",size:24})}):e.jsxs("div",{className:"animate-fade-in space-y-8",children:[e.jsx(pe,{title:"概览",description:"继续最近的工作,或进入项目、知识和自动化配置。当前版本 v0.1.46"}),e.jsxs("section",{className:"grid grid-cols-2 gap-3 lg:grid-cols-4",children:[e.jsx(N,{label:"Projects",value:t.length,detail:"configured workspaces",tone:"primary"}),e.jsx(N,{label:"Running",value:c.length,detail:"active agent tasks"}),e.jsx(N,{label:"Waiting",value:w.length+R.length,detail:"needs attention",tone:w.length+R.length>0?"warning":"neutral"}),e.jsx(N,{label:"Runtimes",value:A.length,detail:"installed locally"})]}),q?e.jsx("div",{role:"alert",className:"rounded-lg border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-700 dark:border-amber-400/20 dark:bg-amber-500/10 dark:text-amber-200",children:q}):null,e.jsxs("section",{className:"space-y-3",children:[e.jsx("div",{className:"flex items-end justify-between gap-4",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold tracking-tight text-foreground",children:"快速开始"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"常用入口会保留在最前面。"})]})}),e.jsx("div",{className:"grid grid-cols-1 gap-3 lg:grid-cols-2",children:v.map(s=>e.jsx(_e,{...s},s.to))})]}),x?e.jsxs(f,{className:"app-panel overflow-hidden p-0",children:[e.jsxs("div",{className:"flex flex-col gap-3 border-b border-black/[0.08] px-5 py-4 dark:border-white/[0.07] sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-foreground",children:"本机 Agent Runtime"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"显示本机 runtime 安装检测状态,不执行安装或登录检查。"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(d,{variant:A.length>0?"success":"default",children:[A.length," installed"]}),Y?e.jsx(d,{variant:"info",children:"checking"}):null,e.jsxs(oe,{variant:"outline",size:"sm",loading:X,onClick:Z,title:"刷新 runtime 检测",children:[e.jsx(me,{size:15}),"刷新"]})]})]}),B?e.jsxs("div",{className:"px-5 py-4 text-sm text-amber-700 dark:text-amber-200",children:["检测失败:",B]}):o.length===0?e.jsx("div",{className:"p-5",children:e.jsx(j,{message:"还没有 runtime 检测结果",icon:U})}):e.jsx("div",{className:"grid grid-cols-1 gap-3 p-5 md:grid-cols-2 xl:grid-cols-3",children:o.map(s=>{var n,h;return e.jsxs("div",{className:"app-list-row",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx("div",{className:["flex h-10 w-10 shrink-0 items-center justify-center rounded-xl",s.status==="installed"?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-300":s.status==="error"?"bg-red-500/10 text-red-600 dark:text-red-200":"bg-amber-500/10 text-amber-700 dark:text-amber-200"].join(" "),children:e.jsx(U,{size:19})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-foreground",children:s.displayName}),e.jsx("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:s.agentType})]})]}),s.status==="installed"?e.jsx(Le,{size:18,className:"mt-0.5 shrink-0 text-emerald-500"}):e.jsx(xe,{size:18,className:"mt-0.5 shrink-0 text-amber-500"})]}),e.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-2",children:[e.jsx(d,{variant:s.status==="installed"?"success":s.status==="error"?"danger":"warning",children:s.status}),e.jsx(d,{variant:ze(s),children:De(s)}),e.jsx(d,{children:s.source}),s.version?e.jsxs(d,{variant:"secondary",children:["v",s.version]}):null]}),e.jsx("p",{className:"mt-3 text-sm leading-5 text-muted-foreground",children:s.summary}),s.lastLaunchError?e.jsx("p",{className:"mt-2 text-xs leading-5 text-red-600 dark:text-red-200",children:s.lastLaunchError.userMessage}):s.issues[0]?e.jsx("p",{className:"mt-2 text-xs leading-5 text-amber-700 dark:text-amber-200",children:s.issues[0].message}):null,(n=s.lastLaunchError)!=null&&n.suggestedAction?e.jsx("p",{className:"mt-2 text-xs leading-5 text-muted-foreground",children:s.lastLaunchError.suggestedAction}):null,s.binaryPath||s.command?e.jsx("p",{className:"mt-3 truncate rounded-lg bg-black/[0.045] px-2.5 py-2 font-mono text-xs text-muted-foreground dark:bg-white/[0.06]",children:s.binaryPath||s.command}):null,s.recommendedActions[0]&&!((h=s.lastLaunchError)!=null&&h.suggestedAction)?e.jsx("p",{className:"mt-3 text-xs leading-5 text-muted-foreground",children:s.recommendedActions[0].description}):null,e.jsxs("p",{className:"mt-3 text-xs text-muted-foreground",children:["Last checked ",new Date(s.lastCheckedAt||s.detectedAt).toLocaleString()]})]},s.agentType)})})]}):null,x?e.jsxs("section",{className:"grid grid-cols-1 gap-4 xl:grid-cols-3",children:[e.jsx(M,{title:"运行中任务",description:"正在排队或执行的 agent 工作。",tasks:c,empty:"暂无运行中的任务"}),e.jsx(M,{title:"等待处理",description:"需要用户输入或审批的任务。",tasks:w,empty:"暂无等待处理的任务",urgent:!0}),e.jsx(M,{title:"最近完成",description:"最近结束、失败或取消的任务。",tasks:Q,empty:"暂无最近任务"})]}):null,x?e.jsxs("section",{className:"grid grid-cols-1 gap-4 xl:grid-cols-2",children:[e.jsx(Pe,{approvals:R}),e.jsx(Te,{events:G})]}):null,e.jsxs(f,{className:"app-panel p-0",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 border-b border-black/[0.08] px-5 py-4 dark:border-white/[0.07]",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-foreground",children:a("nav.projects")}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"最近配置和会话概览。"})]}),e.jsx(E,{to:x?"/workspace":"/projects",className:"text-sm font-medium text-primary transition-colors hover:text-primary/80",children:a("common.viewAll")})]}),t.length===0?e.jsx("div",{className:"p-5",children:e.jsx(j,{message:a("projects.noProjects"),icon:V})}):e.jsx("div",{className:"divide-y divide-black/[0.08] dark:divide-white/[0.07]",children:t.slice(0,6).map(s=>{var n;return e.jsxs(E,{to:x?`/workspace?project=${encodeURIComponent(s.name)}`:`/projects/${s.name}`,className:"group flex items-center justify-between gap-3 px-5 py-4 transition-colors duration-200 hover:bg-black/[0.04] dark:hover:bg-white/[0.06]",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary",children:e.jsx(ke,{size:17})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:s.name}),e.jsxs("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:[s.agent_type," · ",((n=s.platforms)==null?void 0:n.join(", "))||"no platform"," · ",s.sessions_count," sessions"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[s.heartbeat_enabled?e.jsx(d,{variant:"success",children:"heartbeat"}):null,e.jsx(K,{size:16,className:"text-muted-foreground/45 transition-colors group-hover:text-foreground"})]})]},s.name)})})]})]})}export{Ke as default};
@@ -1,4 +1,4 @@
1
- import{c as s,j as e}from"./index-B36eowj-.js";/**
1
+ import{c as s,j as e}from"./index-cI3pWBnN.js";/**
2
2
  * @license lucide-react v0.487.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as y,D as R,r as t,aH as C,aT as U,aI as q,aU as P,aV as V,aW as O,aX as Z,j as e,L as _,B as p,S as G,C as x,g as Q,E as F,I as W}from"./index-B36eowj-.js";import{E}from"./EmptyState-kD9yAwtw.js";import{A as X}from"./arrow-left-CNEAuElg.js";import{S as J}from"./search-CniPk7Ey.js";import{T as Y}from"./trash-2-DhtOCsO5.js";/**
1
+ import{c as y,D as R,r as t,aP as C,a$ as q,aQ as H,b0 as U,b1 as O,b2 as Q,b3 as V,j as e,L as _,B as p,S as Z,C as x,g as G,E as F,I as J}from"./index-cI3pWBnN.js";import{E}from"./EmptyState-BDBavDll.js";import{A as W}from"./arrow-left-CXyya3hP.js";import{S as X}from"./search-C3bvw7AR.js";import{T as Y}from"./trash-2-o-heXOgs.js";/**
2
2
  * @license lucide-react v0.487.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -13,4 +13,4 @@ import{c as y,D as R,r as t,aH as C,aT as U,aI as q,aU as P,aV as V,aW as O,aX a
13
13
  *
14
14
  * This source code is licensed under the ISC license.
15
15
  * See the LICENSE file in the root directory of this source tree.
16
- */const re=[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]],I=y("upload",re);function K(a){return a==="success"?"border-violet-200 bg-violet-50 text-violet-700 dark:border-violet-900/30 dark:bg-violet-950/20 dark:text-violet-300":a==="warning"?"border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-900/30 dark:bg-amber-950/20 dark:text-amber-300":"border-red-200 bg-red-50 text-red-700 dark:border-red-900/30 dark:bg-red-950/20 dark:text-red-300"}function oe(){const{knowledgebaseId:a=""}=R(),[f,u]=t.useState(!0),[j,b]=t.useState(!1),[B,k]=t.useState(!1),[m,M]=t.useState(!1),[r,A]=t.useState(null),[N,D]=t.useState([]),[g,T]=t.useState([]),[w,v]=t.useState([]),[n,z]=t.useState(""),[h,c]=t.useState(null),o=t.useCallback(async()=>{if(a){u(!0);try{const[s,d,l,L]=await Promise.all([C(),U(a),q(),P(a).catch(()=>({files:[]}))]);M(!!s.baseUrl),A(d),D(l.folders||[]),T(L.files||[])}catch(s){c({tone:"error",message:s instanceof Error?s.message:String(s)})}finally{u(!1)}}},[a]);t.useEffect(()=>{o()},[o]);const i=t.useMemo(()=>N.find(s=>s.id===(r==null?void 0:r.folderId))||null,[r==null?void 0:r.folderId,N]),$=t.useCallback(async s=>{const d=Array.from(s.target.files||[]);if(!(!a||d.length===0)){b(!0);try{const l=await C();await V(a,{files:d,collection:l.defaultCollection,folder:i==null?void 0:i.path}),c({tone:"success",message:"Files uploaded and indexed."}),await o(),s.target.value=""}catch(l){c({tone:"error",message:l instanceof Error?l.message:String(l)})}finally{b(!1)}}},[i==null?void 0:i.path,a,o]),H=t.useCallback(async s=>{if(!(!a||!window.confirm(`Delete file "${s.fileName}"?`)))try{await O(a,s.fileId),c({tone:"success",message:"File deleted."}),await o()}catch(d){c({tone:"error",message:d instanceof Error?d.message:String(d)})}},[a,o]),S=t.useCallback(async()=>{if(!a||!n.trim()){v([]);return}k(!0);try{const s=await Z(a,{query:n.trim(),limit:8});v(s.results||[])}catch(s){c({tone:"error",message:s instanceof Error?s.message:String(s)})}finally{k(!1)}},[a,n]);return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx(_,{to:"/knowledge",children:e.jsxs(p,{variant:"secondary",children:[e.jsx(X,{size:14})," 返回知识库"]})}),r&&e.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:[e.jsx("span",{className:"text-gray-900 dark:text-white",children:r.name}),i?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mx-2",children:"/"}),e.jsx("span",{children:i.path})]}):null]})]}),h&&e.jsx("div",{className:`rounded-xl border px-4 py-3 text-sm ${K(h.tone)}`,children:h.message}),!m&&!f&&e.jsx("div",{className:`rounded-2xl border px-5 py-4 ${K("warning")}`,children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Knowledge retrieval is not configured."}),e.jsx("p",{className:"mt-1 text-sm opacity-90",children:"Add the ai_vector connection in System settings to upload files and search this knowledge base."})]}),e.jsx(_,{to:"/system",children:e.jsxs(p,{variant:"secondary",children:[e.jsx(G,{size:14})," Open System Settings"]})})]})}),f?e.jsx(x,{children:e.jsx("div",{className:"py-16 text-center text-sm text-gray-400",children:"正在加载知识库详情…"})}):r?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 gap-6 xl:grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)]",children:[e.jsxs(x,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold text-gray-900 dark:text-white",children:r.name}),e.jsx("p",{className:"mt-2 text-sm text-gray-500 dark:text-gray-400",children:r.description||"上传文档后,这个知识库会变成你当前项目的专属 RAG 索引。"})]}),e.jsxs("label",{className:Q("inline-flex cursor-pointer items-center gap-2 rounded-xl px-4 py-2 text-sm font-medium",m?"bg-accent text-white hover:bg-accent-dim":"bg-gray-200 text-gray-500 dark:bg-white/[0.08] dark:text-gray-500"),children:[e.jsx(I,{size:14}),j?"上传中…":"上传文件",e.jsx("input",{type:"file",multiple:!0,className:"hidden",disabled:!m||j,onChange:s=>void $(s)})]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-2xl border border-gray-200/80 px-4 py-4 dark:border-white/[0.08]",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-gray-400",children:"文档数"}),e.jsx("p",{className:"mt-2 text-2xl font-semibold text-gray-900 dark:text-white",children:g.length})]}),e.jsxs("div",{className:"rounded-2xl border border-gray-200/80 px-4 py-4 dark:border-white/[0.08]",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-gray-400",children:"字符统计"}),e.jsx("p",{className:"mt-2 text-2xl font-semibold text-gray-900 dark:text-white",children:g.reduce((s,d)=>s+Number(d.wordCount||0),0)})]}),e.jsxs("div",{className:"rounded-2xl border border-gray-200/80 px-4 py-4 dark:border-white/[0.08]",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-gray-400",children:"最近更新"}),e.jsx("p",{className:"mt-2 text-sm font-medium text-gray-900 dark:text-white",children:F(r.updatedAt)})]})]})]}),e.jsxs(x,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"内容搜索"}),e.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:"在当前知识库内检索已解析内容,快速确认切块与召回效果。"})]}),e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(J,{size:16,className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx(W,{value:n,onChange:s=>z(s.target.value),placeholder:"例如:升级流程、性能测试结论",className:"pl-9",onKeyDown:s=>{s.key==="Enter"&&S()}})]}),e.jsxs(p,{onClick:()=>void S(),disabled:!m||!n.trim(),loading:B,children:[e.jsx(se,{size:14})," 搜索"]})]}),w.length===0?e.jsx("div",{className:"rounded-2xl border border-dashed border-gray-200/80 px-4 py-8 text-center text-sm text-gray-400 dark:border-white/[0.08]",children:n?"还没有搜索结果。":"输入关键词后可以查看召回片段。"}):e.jsx("div",{className:"space-y-3",children:w.map(s=>e.jsxs("div",{className:"rounded-2xl border border-gray-200/80 px-4 py-4 dark:border-white/[0.08]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-gray-900 dark:text-white",children:s.title}),e.jsxs("p",{className:"mt-1 text-xs text-gray-400",children:["chunk #",s.chunkOffset," · score ",s.score.toFixed(4)]})]}),e.jsx("span",{className:"rounded-full bg-gray-100 px-2.5 py-1 text-xs text-gray-500 dark:bg-white/[0.06] dark:text-gray-400",children:s.fileName})]}),e.jsx("p",{className:"mt-3 whitespace-pre-wrap text-sm leading-7 text-gray-600 dark:text-gray-300",children:s.snippet})]},s.id))})]})]}),e.jsxs(x,{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between gap-4",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"文件列表"}),e.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:"当前知识库内已完成解析并入库的文件。"})]})}),g.length===0?e.jsx(E,{message:"还没有文件,上传文档后会出现在这里。",icon:I}):e.jsxs("div",{className:"overflow-hidden rounded-2xl border border-gray-200/80 dark:border-white/[0.08]",children:[e.jsxs("div",{className:"grid grid-cols-[minmax(0,1.8fr)_120px_120px_160px_60px] gap-3 border-b border-gray-200/80 bg-gray-50/80 px-4 py-3 text-xs font-medium uppercase tracking-wide text-gray-500 dark:border-white/[0.08] dark:bg-white/[0.03]",children:[e.jsx("span",{children:"文件"}),e.jsx("span",{children:"类型"}),e.jsx("span",{children:"字符数"}),e.jsx("span",{children:"创建时间"}),e.jsx("span",{})]}),g.map(s=>e.jsxs("div",{className:"grid grid-cols-[minmax(0,1.8fr)_120px_120px_160px_60px] gap-3 border-b border-gray-200/70 px-4 py-3 text-sm last:border-b-0 dark:border-white/[0.06]",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate font-medium text-gray-900 dark:text-white",children:s.fileName}),e.jsx("p",{className:"mt-1 truncate text-xs text-gray-400",children:s.fileId})]}),e.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:s.fileType}),e.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:s.wordCount||0}),e.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:F(s.createTime)}),e.jsx("button",{type:"button",onClick:()=>void H(s),className:"rounded-lg p-2 text-gray-400 hover:bg-red-500/10 hover:text-red-500","aria-label":`Delete ${s.fileName}`,children:e.jsx(Y,{size:15})})]},s.fileId))]})]})]}):e.jsx(x,{children:e.jsx(E,{message:"没有找到这个知识库。",icon:te})})]})}export{oe as default};
16
+ */const re=[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]],K=y("upload",re);function B(a){return a==="success"?"border-violet-200 bg-violet-50 text-violet-700 dark:border-violet-900/30 dark:bg-violet-950/20 dark:text-violet-300":a==="warning"?"border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-900/30 dark:bg-amber-950/20 dark:text-amber-300":"border-red-200 bg-red-50 text-red-700 dark:border-red-900/30 dark:bg-red-950/20 dark:text-red-300"}function oe(){const{knowledgebaseId:a=""}=R(),[f,u]=t.useState(!0),[j,b]=t.useState(!1),[I,k]=t.useState(!1),[m,M]=t.useState(!1),[r,A]=t.useState(null),[N,D]=t.useState([]),[g,$]=t.useState([]),[w,v]=t.useState([]),[n,z]=t.useState(""),[h,c]=t.useState(null),o=t.useCallback(async()=>{if(a){u(!0);try{const[s,d,l,P]=await Promise.all([C(),q(a),H(),U(a).catch(()=>({files:[]}))]);M(!!s.baseUrl),A(d),D(l.folders||[]),$(P.files||[])}catch(s){c({tone:"error",message:s instanceof Error?s.message:String(s)})}finally{u(!1)}}},[a]);t.useEffect(()=>{o()},[o]);const i=t.useMemo(()=>N.find(s=>s.id===(r==null?void 0:r.folderId))||null,[r==null?void 0:r.folderId,N]),T=t.useCallback(async s=>{const d=Array.from(s.target.files||[]);if(!(!a||d.length===0)){b(!0);try{const l=await C();await O(a,{files:d,collection:l.defaultCollection,folder:i==null?void 0:i.path}),c({tone:"success",message:"Files uploaded and indexed."}),await o(),s.target.value=""}catch(l){c({tone:"error",message:l instanceof Error?l.message:String(l)})}finally{b(!1)}}},[i==null?void 0:i.path,a,o]),L=t.useCallback(async s=>{if(!(!a||!window.confirm(`Delete file "${s.fileName}"?`)))try{await Q(a,s.fileId),c({tone:"success",message:"File deleted."}),await o()}catch(d){c({tone:"error",message:d instanceof Error?d.message:String(d)})}},[a,o]),S=t.useCallback(async()=>{if(!a||!n.trim()){v([]);return}k(!0);try{const s=await V(a,{query:n.trim(),limit:8});v(s.results||[])}catch(s){c({tone:"error",message:s instanceof Error?s.message:String(s)})}finally{k(!1)}},[a,n]);return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx(_,{to:"/knowledge",children:e.jsxs(p,{variant:"secondary",children:[e.jsx(W,{size:14})," 返回知识库"]})}),r&&e.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:[e.jsx("span",{className:"text-gray-900 dark:text-white",children:r.name}),i?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mx-2",children:"/"}),e.jsx("span",{children:i.path})]}):null]})]}),h&&e.jsx("div",{className:`rounded-xl border px-4 py-3 text-sm ${B(h.tone)}`,children:h.message}),!m&&!f&&e.jsx("div",{className:`rounded-2xl border px-5 py-4 ${B("warning")}`,children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Knowledge retrieval is not configured."}),e.jsx("p",{className:"mt-1 text-sm opacity-90",children:"Add the ai_vector connection in System settings to upload files and search this knowledge base."})]}),e.jsx(_,{to:"/system",children:e.jsxs(p,{variant:"secondary",children:[e.jsx(Z,{size:14})," Open System Settings"]})})]})}),f?e.jsx(x,{children:e.jsx("div",{className:"py-16 text-center text-sm text-gray-400",children:"正在加载知识库详情…"})}):r?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 gap-6 xl:grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)]",children:[e.jsxs(x,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold text-gray-900 dark:text-white",children:r.name}),e.jsx("p",{className:"mt-2 text-sm text-gray-500 dark:text-gray-400",children:r.description||"上传文档后,这个知识库会变成你当前项目的专属 RAG 索引。"})]}),e.jsxs("label",{className:G("inline-flex cursor-pointer items-center gap-2 rounded-xl px-4 py-2 text-sm font-medium",m?"bg-accent text-white hover:bg-accent-dim":"bg-gray-200 text-gray-500 dark:bg-white/[0.08] dark:text-gray-500"),children:[e.jsx(K,{size:14}),j?"上传中…":"上传文件",e.jsx("input",{type:"file",multiple:!0,className:"hidden",disabled:!m||j,onChange:s=>void T(s)})]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-2xl border border-gray-200/80 px-4 py-4 dark:border-white/[0.08]",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-gray-400",children:"文档数"}),e.jsx("p",{className:"mt-2 text-2xl font-semibold text-gray-900 dark:text-white",children:g.length})]}),e.jsxs("div",{className:"rounded-2xl border border-gray-200/80 px-4 py-4 dark:border-white/[0.08]",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-gray-400",children:"字符统计"}),e.jsx("p",{className:"mt-2 text-2xl font-semibold text-gray-900 dark:text-white",children:g.reduce((s,d)=>s+Number(d.wordCount||0),0)})]}),e.jsxs("div",{className:"rounded-2xl border border-gray-200/80 px-4 py-4 dark:border-white/[0.08]",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-gray-400",children:"最近更新"}),e.jsx("p",{className:"mt-2 text-sm font-medium text-gray-900 dark:text-white",children:F(r.updatedAt)})]})]})]}),e.jsxs(x,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"内容搜索"}),e.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:"在当前知识库内检索已解析内容,快速确认切块与召回效果。"})]}),e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(X,{size:16,className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx(J,{value:n,onChange:s=>z(s.target.value),placeholder:"例如:升级流程、性能测试结论",className:"pl-9",onKeyDown:s=>{s.key==="Enter"&&S()}})]}),e.jsxs(p,{onClick:()=>void S(),disabled:!m||!n.trim(),loading:I,children:[e.jsx(se,{size:14})," 搜索"]})]}),w.length===0?e.jsx("div",{className:"rounded-2xl border border-dashed border-gray-200/80 px-4 py-8 text-center text-sm text-gray-400 dark:border-white/[0.08]",children:n?"还没有搜索结果。":"输入关键词后可以查看召回片段。"}):e.jsx("div",{className:"space-y-3",children:w.map(s=>e.jsxs("div",{className:"rounded-2xl border border-gray-200/80 px-4 py-4 dark:border-white/[0.08]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-gray-900 dark:text-white",children:s.title}),e.jsxs("p",{className:"mt-1 text-xs text-gray-400",children:["chunk #",s.chunkOffset," · score ",s.score.toFixed(4)]})]}),e.jsx("span",{className:"rounded-full bg-gray-100 px-2.5 py-1 text-xs text-gray-500 dark:bg-white/[0.06] dark:text-gray-400",children:s.fileName})]}),e.jsx("p",{className:"mt-3 whitespace-pre-wrap text-sm leading-7 text-gray-600 dark:text-gray-300",children:s.snippet})]},s.id))})]})]}),e.jsxs(x,{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between gap-4",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"文件列表"}),e.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:"当前知识库内已完成解析并入库的文件。"})]})}),g.length===0?e.jsx(E,{message:"还没有文件,上传文档后会出现在这里。",icon:K}):e.jsxs("div",{className:"overflow-hidden rounded-2xl border border-gray-200/80 dark:border-white/[0.08]",children:[e.jsxs("div",{className:"grid grid-cols-[minmax(0,1.8fr)_120px_120px_160px_60px] gap-3 border-b border-gray-200/80 bg-gray-50/80 px-4 py-3 text-xs font-medium uppercase tracking-wide text-gray-500 dark:border-white/[0.08] dark:bg-white/[0.03]",children:[e.jsx("span",{children:"文件"}),e.jsx("span",{children:"类型"}),e.jsx("span",{children:"字符数"}),e.jsx("span",{children:"创建时间"}),e.jsx("span",{})]}),g.map(s=>e.jsxs("div",{className:"grid grid-cols-[minmax(0,1.8fr)_120px_120px_160px_60px] gap-3 border-b border-gray-200/70 px-4 py-3 text-sm last:border-b-0 dark:border-white/[0.06]",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate font-medium text-gray-900 dark:text-white",children:s.fileName}),e.jsx("p",{className:"mt-1 truncate text-xs text-gray-400",children:s.fileId})]}),e.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:s.fileType}),e.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:s.wordCount||0}),e.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:F(s.createTime)}),e.jsx("button",{type:"button",onClick:()=>void L(s),className:"rounded-lg p-2 text-gray-400 hover:bg-red-500/10 hover:text-red-500","aria-label":`Delete ${s.fileName}`,children:e.jsx(Y,{size:15})})]},s.fileId))]})]})]}):e.jsx(x,{children:e.jsx(E,{message:"没有找到这个知识库。",icon:te})})]})}export{oe as default};
@@ -0,0 +1,11 @@
1
+ import{c as _,r as t,aP as ae,aQ as se,y as te,aR as re,aS as ne,aT as ie,aU as le,aV as oe,aW as de,j as e,L as D,B as d,S as ce,C as x,g as I,h as me,I as C,aX as xe,E as ge,T as pe}from"./index-cI3pWBnN.js";import{M as L}from"./Modal-CXhD_OWR.js";import{E as R}from"./EmptyState-BDBavDll.js";import{P}from"./pencil-ywcJzeOo.js";import{T as O}from"./trash-2-o-heXOgs.js";import{S as he}from"./search-C3bvw7AR.js";import{P as ue}from"./plus-BEj14BBV.js";import{B as ye}from"./book-open-9n4Kxc7E.js";import"./index-BKpv0P0s.js";/**
2
+ * @license lucide-react v0.487.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const fe=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["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"}]],je=_("folder-plus",fe);/**
7
+ * @license lucide-react v0.487.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const be=[["path",{d:"M20 17a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3.9a2 2 0 0 1-1.69-.9l-.81-1.2a2 2 0 0 0-1.67-.9H8a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2Z",key:"4u7rpt"}],["path",{d:"M2 8v11a2 2 0 0 0 2 2h14",key:"1eicx1"}]],S=_("folders",be);function T(o){return o==="success"?"border-primary/20 bg-primary/10 text-primary dark:border-primary/25 dark:bg-primary/10 dark:text-blue-200":o==="warning"?"border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-900/30 dark:bg-amber-950/20 dark:text-amber-300":"border-red-200 bg-red-50 text-red-700 dark:border-red-900/30 dark:bg-red-950/20 dark:text-red-300"}function ve(o){switch(o){case"file":return"bg-blue-500";case"spark":return"bg-amber-500";case"screen":return"bg-fuchsia-500";default:return"bg-indigo-500"}}function we(o){return o.split("/").length-1}function Me(){const[o,F]=t.useState(!0),[m,q]=t.useState([]),[j,A]=t.useState([]),[l,b]=t.useState(null),[g,U]=t.useState(""),[H,V]=t.useState(!1),[Q,p]=t.useState(!1),[W,h]=t.useState(!1),[u,B]=t.useState(""),[y,K]=t.useState(""),[v,E]=t.useState(""),[w,r]=t.useState(null),[z,f]=t.useState(null),n=t.useCallback(async()=>{F(!0);try{const[a,s,i]=await Promise.all([ae(),se(),te()]);V(!!a.baseUrl),q(s.folders||[]),A(i.bases||[])}catch(a){r({tone:"error",message:a instanceof Error?a.message:String(a)})}finally{F(!1)}},[]);t.useEffect(()=>{n()},[n]);const N=t.useMemo(()=>{if(!l)return null;const a=m.find(i=>i.id===l);if(!a)return null;const s=new Set([a.id]);return m.forEach(i=>{i.path.startsWith(`${a.path}/`)&&s.add(i.id)}),s},[m,l]),M=t.useMemo(()=>{const a=g.trim().toLowerCase();return j.filter(s=>(N?N.has(s.folderId||""):!0)?a?[s.name,s.description,s.creatorName].join(" ").toLowerCase().includes(a):!0:!1)},[j,N,g]),Z=t.useCallback(async()=>{if(!u.trim()){r({tone:"warning",message:"Folder name is required."});return}f("folder");try{await re({name:u.trim(),parentId:l}),B(""),p(!1),r({tone:"success",message:"Folder created."}),await n()}catch(a){r({tone:"error",message:a instanceof Error?a.message:String(a)})}finally{f(null)}},[u,n,l]),G=t.useCallback(async()=>{if(!y.trim()){r({tone:"warning",message:"Knowledge base name is required."});return}f("base");try{await ne({name:y.trim(),description:v.trim(),folderId:l}),K(""),E(""),h(!1),r({tone:"success",message:"Knowledge base created."}),await n()}catch(a){r({tone:"error",message:a instanceof Error?a.message:String(a)})}finally{f(null)}},[v,y,n,l]),X=t.useCallback(async a=>{var i;const s=(i=window.prompt("Rename folder",a.name))==null?void 0:i.trim();if(!(!s||s===a.name))try{await ie(a.id,{name:s}),r({tone:"success",message:"Folder updated."}),await n()}catch(c){r({tone:"error",message:c instanceof Error?c.message:String(c)})}},[n]),J=t.useCallback(async a=>{if(window.confirm(`Delete folder "${a.name}"?`))try{await le(a.id),l===a.id&&b(null),r({tone:"success",message:"Folder deleted."}),await n()}catch(s){r({tone:"error",message:s instanceof Error?s.message:String(s)})}},[n,l]),Y=t.useCallback(async a=>{var c,$;const s=(c=window.prompt("Knowledge base name",a.name))==null?void 0:c.trim();if(!s)return;const i=(($=window.prompt("Description",a.description))==null?void 0:$.trim())??a.description;try{await oe(a.id,{name:s,description:i}),r({tone:"success",message:"Knowledge base updated."}),await n()}catch(k){r({tone:"error",message:k instanceof Error?k.message:String(k)})}},[n]),ee=t.useCallback(async a=>{if(window.confirm(`Delete knowledge base "${a.name}"?`))try{await de(a.id),r({tone:"success",message:"Knowledge base deleted."}),await n()}catch(s){r({tone:"error",message:s instanceof Error?s.message:String(s)})}},[n]);return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[w&&e.jsx("div",{className:`rounded-xl border px-4 py-3 text-sm ${T(w.tone)}`,children:w.message}),!H&&!o&&e.jsx("div",{className:`rounded-2xl border px-5 py-4 ${T("warning")}`,children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Knowledge search is not configured yet."}),e.jsx("p",{className:"mt-1 text-sm opacity-90",children:"Add the ai_vector base URL in System settings before uploading files or running retrieval."})]}),e.jsx(D,{to:"/system",children:e.jsxs(d,{variant:"secondary",children:[e.jsx(ce,{size:14})," Open System Settings"]})})]})}),e.jsxs("div",{className:"grid grid-cols-1 gap-6 xl:grid-cols-[300px_minmax(0,1fr)]",children:[e.jsxs(x,{className:"app-panel p-0 overflow-hidden",children:[e.jsx("div",{className:"border-b border-gray-200/80 px-5 py-4 dark:border-white/[0.08]",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:"知识库"}),e.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:"创建目录并管理知识库分类。"})]}),e.jsxs(d,{size:"sm",variant:"secondary",onClick:()=>p(!0),children:[e.jsx(je,{size:14})," 文件夹"]})]})}),e.jsx("div",{className:"px-5 py-4",children:e.jsxs("button",{type:"button",onClick:()=>b(null),className:I("flex w-full items-center justify-between rounded-[16px] px-3 py-2.5 text-left text-sm transition-colors",l?"hover:bg-gray-100/80 text-gray-600 dark:text-gray-300 dark:hover:bg-white/[0.06]":"bg-primary/10 text-gray-900 ring-1 ring-primary/25 dark:text-white"),children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(S,{size:16}),"全部知识库"]}),e.jsx("span",{className:"text-xs opacity-70",children:j.length})]})}),e.jsx("div",{className:"max-h-[70vh] overflow-y-auto px-3 pb-4",children:m.length===0?e.jsx(R,{message:"还没有目录,先创建一个文件夹吧。",icon:S}):e.jsx("div",{className:"space-y-1",children:m.map(a=>{const s=a.id===l;return e.jsx("div",{className:I("group rounded-[16px] px-2 py-1",s?"bg-primary/10 ring-1 ring-primary/25":"hover:bg-gray-100/80 dark:hover:bg-white/[0.04]"),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>b(a.id),className:"flex min-w-0 flex-1 items-center gap-2 rounded-lg px-2 py-2 text-left",style:{paddingLeft:`${8+we(a.path)*18}px`},children:[e.jsx(me,{size:14,className:"text-gray-400"}),e.jsx(S,{size:15,className:"text-amber-500"}),e.jsx("span",{className:"truncate text-sm text-gray-800 dark:text-gray-100",children:a.name})]}),e.jsx("button",{type:"button",onClick:()=>void X(a),className:"rounded-md p-1 text-gray-400 transition hover:bg-gray-200/70 hover:text-gray-700 dark:hover:bg-white/[0.08] dark:hover:text-white","aria-label":`Rename ${a.name}`,children:e.jsx(P,{size:14})}),e.jsx("button",{type:"button",onClick:()=>void J(a),className:"rounded-md p-1 text-gray-400 transition hover:bg-red-500/10 hover:text-red-500","aria-label":`Delete ${a.name}`,children:e.jsx(O,{size:14})})]})},a.id)})})})]}),e.jsxs("div",{className:"space-y-5",children:[e.jsx(x,{className:"app-toolbar",children:e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:"知识库列表"}),e.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:"目录筛选、本地搜索,以及知识库卡片概览都在这里。"})]}),e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row",children:[e.jsxs("div",{className:"relative min-w-[260px]",children:[e.jsx(he,{size:16,className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx(C,{value:g,onChange:a=>U(a.target.value),placeholder:"搜索名称、描述或创建者","aria-label":"搜索名称、描述或创建者",className:"pl-9"})]}),e.jsxs(d,{variant:"secondary",onClick:()=>h(!0),children:[e.jsx(ue,{size:14})," 创建知识库"]})]})]})}),o?e.jsx(x,{className:"app-panel",children:e.jsx("div",{className:"py-16 text-center text-sm text-gray-400",children:"正在加载知识库…"})}):M.length===0?e.jsx(x,{className:"app-panel",children:e.jsx(R,{message:g?"没有匹配的知识库。":"还没有知识库,先创建一个开始上传文档。",icon:xe})}):e.jsx("div",{className:"grid grid-cols-1 gap-5 md:grid-cols-2 2xl:grid-cols-3",children:M.map(a=>e.jsxs(x,{className:"group app-panel relative overflow-hidden p-5 hover:border-primary/25",children:[e.jsxs("div",{className:"absolute right-4 top-4 flex gap-1",children:[e.jsx("button",{type:"button",onClick:()=>void Y(a),"aria-label":`编辑 ${a.name}`,className:"rounded-lg p-2 text-gray-400 hover:bg-gray-100/90 hover:text-gray-700 dark:hover:bg-white/[0.08] dark:hover:text-white",children:e.jsx(P,{size:15})}),e.jsx("button",{type:"button",onClick:()=>void ee(a),"aria-label":`删除 ${a.name}`,className:"rounded-lg p-2 text-gray-400 hover:bg-red-500/10 hover:text-red-500",children:e.jsx(O,{size:15})})]}),e.jsxs(D,{to:`/knowledge/${encodeURIComponent(a.id)}`,className:"block space-y-5",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:`mt-1 flex h-11 w-11 items-center justify-center rounded-full text-white ${ve(a.icon)}`,children:e.jsx(ye,{size:22})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"truncate pr-8 text-xl font-semibold text-gray-900 dark:text-white",children:a.name}),e.jsxs("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:["创建者: ",a.creatorName||"系统管理员"]})]})]}),e.jsx("div",{className:"min-h-[60px] text-sm leading-6 text-gray-600 dark:text-gray-300",children:a.description||"这个知识库还没有描述,点击进入后可以上传文件并开始检索。"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 rounded-[16px] bg-black/[0.035] px-3 py-2 text-sm font-medium text-gray-700 dark:bg-white/[0.05] dark:text-gray-200",children:[e.jsxs("span",{children:[a.fileCount," 文档数"]}),e.jsxs("span",{children:[(a.wordCount/1e3).toFixed(a.wordCount>0?1:0),"k 字符"]})]}),e.jsxs("div",{className:"text-xs text-gray-400 dark:text-gray-500",children:["更新于 ",ge(a.updatedAt)]})]})]},a.id))})]})]}),e.jsx(L,{open:Q,onClose:()=>p(!1),title:"创建文件夹",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(C,{label:"文件夹名称",value:u,onChange:a=>B(a.target.value),placeholder:"例如:产品文档"}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(d,{variant:"secondary",onClick:()=>p(!1),children:"取消"}),e.jsx(d,{onClick:()=>void Z(),loading:z==="folder",children:"创建"})]})]})}),e.jsx(L,{open:W,onClose:()=>h(!1),title:"创建知识库",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(C,{label:"名称",value:y,onChange:a=>K(a.target.value),placeholder:"例如:运营文档库"}),e.jsx(pe,{label:"描述",rows:4,value:v,onChange:a=>E(a.target.value),placeholder:"一句话说明这个知识库主要收录什么内容"}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(d,{variant:"secondary",onClick:()=>h(!1),children:"取消"}),e.jsx(d,{onClick:()=>void G(),loading:z==="base",children:"创建"})]})]})})]})}export{Me as default};
@@ -0,0 +1 @@
1
+ import{u as b,r as t,aN as N,j as e,L as S,B as m,I as L,C}from"./index-cI3pWBnN.js";import{B as E}from"./Badge-BIesaDYG.js";import{S as f}from"./Select-Djc8BXMC.js";import{P as k}from"./Page-KUuFYgjg.js";import{A as z}from"./arrow-left-CXyya3hP.js";import{F as B}from"./funnel-BhqZpS4f.js";import{S as I}from"./search-C3bvw7AR.js";import"./index-BKpv0P0s.js";import"./chevron-down-DrydR4i3.js";import"./check-CutSg9a5.js";const A={sys:"text-gray-300",debug:"text-gray-400",info:"text-blue-400",warn:"text-amber-400",error:"text-red-400"},F={sys:"default",debug:"default",info:"info",warn:"warning",error:"danger"};function $(){const{t:o}=b(),[n,g]=t.useState([]),[l,h]=t.useState("sys"),[i,v]=t.useState("100"),[c,j]=t.useState(""),[d,w]=t.useState(!1),[y,u]=t.useState(!0),a=t.useCallback(async()=>{u(!0);try{const s=await N({level:l,limit:i});g(s.entries||[])}finally{u(!1)}},[l,i]);t.useEffect(()=>{a()},[a]),t.useEffect(()=>{if(!d)return;const s=window.setInterval(()=>{a()},3e3);return()=>window.clearInterval(s)},[d,a]);const x=t.useMemo(()=>{const s=c.trim().toLowerCase();return s?n.filter(r=>[r.level,r.time,r.message].join(" ").toLowerCase().includes(s)):n},[n,c]);return e.jsxs("div",{className:"space-y-4 animate-fade-in",children:[e.jsx(k,{title:o("system.logs"),description:"Filtered runtime logs for troubleshooting.",actions:e.jsx(S,{to:"/system",children:e.jsxs(m,{variant:"secondary",size:"sm",children:[e.jsx(z,{size:14})," ",o("nav.system")]})})}),e.jsxs("div",{className:"app-toolbar flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{size:14,className:"text-muted-foreground"}),e.jsxs(f,{value:l,onChange:s=>h(s.target.value),className:"w-auto",children:[e.jsx("option",{value:"sys",children:"Sys"}),e.jsx("option",{value:"debug",children:"Debug"}),e.jsx("option",{value:"info",children:"Info"}),e.jsx("option",{value:"warn",children:"Warn"}),e.jsx("option",{value:"error",children:"Error"})]})]}),e.jsxs(f,{value:i,onChange:s=>v(s.target.value),className:"w-auto",children:[e.jsx("option",{value:"50",children:"50"}),e.jsx("option",{value:"100",children:"100"}),e.jsx("option",{value:"500",children:"500"}),e.jsx("option",{value:"1000",children:"1000"})]}),e.jsx(m,{size:"sm",variant:"secondary",onClick:a,children:o("common.refresh")}),e.jsx(m,{size:"sm",variant:d?"primary":"secondary",onClick:()=>w(s=>!s),children:"Auto"}),e.jsxs("div",{className:"relative min-w-[16rem] flex-1",children:[e.jsx(I,{size:15,className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),e.jsx(L,{value:c,onChange:s=>j(s.target.value),placeholder:"Search logs","aria-label":"Search logs",className:"pl-9"})]})]}),e.jsx(C,{className:"app-panel",children:y?e.jsx("div",{className:"text-muted-foreground animate-pulse text-sm",children:"Loading..."}):x.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:o("common.noData")}):e.jsx("div",{className:"max-h-[65vh] overflow-auto font-mono text-xs [scrollbar-gutter:stable]",children:x.map((s,r)=>{var p;return e.jsxs("div",{className:"grid min-w-[760px] grid-cols-[9rem_5rem_minmax(0,1fr)] items-start gap-3 border-b py-2 last:border-0",children:[e.jsx("span",{className:"text-muted-foreground shrink-0 w-36",children:(p=s.time)==null?void 0:p.slice(0,19)}),e.jsx(E,{variant:F[s.level]||"default",children:s.level}),e.jsx("span",{className:`${A[s.level]||"text-gray-500"} whitespace-pre-wrap break-words`,children:s.message})]},r)})})})]})}export{$ as default};
@@ -1,4 +1,4 @@
1
- import{c as K,r as s,aG as C,j as i,g as P}from"./index-B36eowj-.js";import{u as I,d as X,e as O,g as Y,P as x,f as N,R as Z,h as J,c as Q,a as ee,i as te,F as ne,D as oe,j as re}from"./index-BNFx4uYv.js";/**
1
+ import{c as K,r as s,aO as C,j as i,g as P}from"./index-cI3pWBnN.js";import{u as I,d as X,e as O,g as Y,P as x,f as N,R as Z,h as J,c as Q,a as ee,i as te,F as ne,D as oe,j as re}from"./index-BKpv0P0s.js";/**
2
2
  * @license lucide-react v0.487.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -0,0 +1 @@
1
+ import{Q as q,l as D,U as W,V as B,X as F,Y as $,u as L,r as l,j as s,s as R,B as p,_ as O,C as U,E as V,I as x,T as H}from"./index-cI3pWBnN.js";import{B as h}from"./Badge-BIesaDYG.js";import{M as Q}from"./Modal-CXhD_OWR.js";import{S as y}from"./Select-Djc8BXMC.js";import{E as X}from"./EmptyState-BDBavDll.js";import{P as Y}from"./Page-KUuFYgjg.js";import{P as Z}from"./plus-BEj14BBV.js";import{P as G}from"./play-AtN492Cx.js";import{P as J}from"./pencil-ywcJzeOo.js";import{T as K}from"./trash-2-o-heXOgs.js";import"./index-BKpv0P0s.js";import"./chevron-down-DrydR4i3.js";import"./check-CutSg9a5.js";const ee=t=>q(),te=t=>B(t),se=(t,o)=>W(t,o),ae=t=>F(t),ne=t=>$(t),oe=()=>D().then(t=>t.workspaces),g={workspaceId:"",title:"",sourceType:"stock.quote",symbol:"",condition:"abs_change_percent >= 3",promptTemplate:"",cooldownMinutes:"15",executionMode:"side-thread",enabled:!0};function v(t){const o=t.trim();if(o.includes("&&")||o.includes("||"))return{metric:"expression",operator:"==",value:!0,expression:o};const c=o.match(/^([a-zA-Z0-9_.-]+)\s*(>=|<=|==|!=|>|<)\s*(.+)$/);if(!c)return null;const r=String(c[3]||"").trim(),m=Number(r);return{metric:String(c[1]||"").trim(),operator:c[2],value:Number.isFinite(m)&&r!==""?m:r}}function C(t){return t.condition.expression?t.condition.expression:`${t.condition.metric} ${t.condition.operator} ${t.condition.value}`}function ie(t){return t?{workspaceId:t.workspaceId,title:t.title,sourceType:"stock.quote",symbol:String(t.sourceConfig.symbol||""),condition:C(t),promptTemplate:t.promptTemplate,cooldownMinutes:String(Math.round(t.cooldownMs/6e4)),executionMode:t.executionMode,enabled:t.enabled}:g}function le(t){const o=v(t.condition);if(!o)throw new Error("Invalid condition");return{workspaceId:t.workspaceId,title:t.title,sourceType:t.sourceType,sourceConfig:k[t.sourceType].buildConfig(t),condition:o,promptTemplate:t.promptTemplate,executionMode:t.executionMode,cooldownMs:Math.max(0,Number(t.cooldownMinutes||"0")*6e4),enabled:t.enabled}}const k={"stock.quote":{label:"Stock quote",buildConfig:t=>({symbol:t.symbol.toUpperCase()}),renderSummary:t=>String(t.sourceConfig.symbol||"")}};function ve(){const{t}=L(),[o,c]=l.useState([]),[r,m]=l.useState([]),[T,w]=l.useState(!0),[S,u]=l.useState(!1),[N,M]=l.useState(!1),[j,b]=l.useState(null),[a,n]=l.useState(g),I=l.useMemo(()=>r.map(e=>s.jsx("option",{value:e.id,children:e.name},e.id)),[r]),d=l.useCallback(async()=>{w(!0);try{const[e,i]=await Promise.all([ee(),oe()]);c(e.monitors||[]),m(i),n(f=>f.workspaceId||i.length===0?f:{...f,workspaceId:i[0].id})}finally{w(!1)}},[]);l.useEffect(()=>{d();const e=R(i=>{(i.type==="automation.monitor.updated"||i.type==="automation.monitor.run.updated")&&d()});return()=>e()},[d]);const E=()=>{var e;b(null),n({...g,workspaceId:((e=r[0])==null?void 0:e.id)||""}),u(!0)},P=e=>{b(e),n(ie(e)),u(!0)},A=async()=>{if(!(!a.workspaceId||!a.title.trim()||!a.symbol.trim()||!a.promptTemplate.trim()||!v(a.condition))){M(!0);try{const e=le(a);j?await se(j.id,e):await te(e),u(!1),b(null),n(g),await d()}finally{M(!1)}}},_=async e=>{confirm(t("common.confirmDelete"))&&(await ae(e),await d())},z=async e=>{await ne(e),await d()};return T&&o.length===0?s.jsx("div",{className:"flex h-64 items-center justify-center text-gray-400 animate-pulse",children:t("common.loading")}):s.jsxs("div",{className:"space-y-4 animate-fade-in",children:[s.jsx(Y,{title:t("monitors.title"),description:"Create event monitors that trigger agent analysis and stream results back to channels.",actions:s.jsxs(p,{onClick:E,children:[s.jsx(Z,{size:16})," ",t("monitors.add")]})}),o.length===0?s.jsx(X,{message:t("monitors.noMonitors"),icon:O}):s.jsx("div",{className:"space-y-3",children:o.map(e=>s.jsx(U,{className:"app-panel",children:s.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"mb-1 flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:e.title}),s.jsx(h,{variant:e.enabled?"success":"default",children:e.enabled?t("monitors.enabled"):"disabled"}),s.jsx(h,{variant:"default",children:e.sourceType}),s.jsx(h,{variant:"default",children:e.platform}),e.lastStatus&&s.jsx(h,{variant:e.lastStatus==="failed"?"danger":"default",children:e.lastStatus})]}),s.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-xs text-gray-500 dark:text-gray-400",children:[s.jsxs("span",{children:[s.jsx("strong",{children:"Workspace:"})," ",e.workspaceId]}),s.jsxs("span",{children:[s.jsx("strong",{children:"Subject:"})," ",k["stock.quote"].renderSummary(e)]}),s.jsxs("span",{children:[s.jsx("strong",{children:"Condition:"})," ",C(e)]}),s.jsxs("span",{children:[s.jsx("strong",{children:"Execution:"})," ",e.executionMode]}),s.jsxs("span",{children:[s.jsx("strong",{children:"Cooldown:"})," ",Math.round(e.cooldownMs/6e4),"m"]}),e.lastTriggeredAt&&s.jsxs("span",{children:[s.jsxs("strong",{children:[t("monitors.lastRun"),":"]})," ",V(e.lastTriggeredAt)]})]}),s.jsx("p",{className:"mt-3 line-clamp-3 rounded-[16px] bg-black/[0.035] px-3 py-2 text-sm leading-6 text-gray-700 dark:bg-white/[0.05] dark:text-gray-300",children:e.promptTemplate}),e.lastError&&s.jsx("p",{className:"mt-2 text-xs text-red-500",children:e.lastError})]}),s.jsxs("div",{className:"flex shrink-0 gap-2",children:[s.jsx(p,{variant:"secondary",size:"sm",className:"app-icon-button",onClick:()=>z(e.id),title:t("monitors.run"),"aria-label":t("monitors.run"),children:s.jsx(G,{size:14})}),s.jsx(p,{variant:"secondary",size:"sm",className:"app-icon-button",onClick:()=>P(e),title:t("common.save"),"aria-label":t("common.save"),children:s.jsx(J,{size:14})}),s.jsx(p,{variant:"danger",size:"sm",className:"app-icon-button",onClick:()=>_(e.id),title:t("common.delete"),"aria-label":t("common.delete"),children:s.jsx(K,{size:14})})]})]})},e.id))}),s.jsx(Q,{open:S,title:t(j?"monitors.edit":"monitors.add"),onClose:()=>u(!1),children:s.jsxs("div",{className:"space-y-4",children:[s.jsx(y,{label:"Workspace",value:a.workspaceId,onChange:e=>n({...a,workspaceId:e.target.value}),children:I}),s.jsx(x,{label:t("monitors.monitorTitle"),value:a.title,onChange:e=>n({...a,title:e.target.value})}),s.jsx(y,{label:"Source",value:a.sourceType,onChange:e=>n({...a,sourceType:e.target.value}),children:Object.entries(k).map(([e,i])=>s.jsx("option",{value:e,children:i.label},e))}),a.sourceType==="stock.quote"&&s.jsx(x,{label:"Symbol",value:a.symbol,onChange:e=>n({...a,symbol:e.target.value}),placeholder:"AAPL"}),s.jsx(x,{label:t("monitors.condition"),value:a.condition,onChange:e=>n({...a,condition:e.target.value}),placeholder:"abs_change_percent >= 3"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:[["abs_change_percent >= 3","+/- 3%"],["price >= 500","Price >= 500"],["volume_ratio >= 2","Volume spike"]].map(([e,i])=>s.jsx("button",{type:"button",onClick:()=>n({...a,condition:e}),className:`app-segment text-xs ${a.condition===e?"app-segment-active":"app-segment-idle"}`,children:i},e))}),v(a.condition)?null:s.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-200",children:"Condition should look like metric >= value or a boolean expression."}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsx(x,{label:t("monitors.cooldown"),value:a.cooldownMinutes,onChange:e=>n({...a,cooldownMinutes:e.target.value})}),s.jsxs(y,{label:"Execution",value:a.executionMode,onChange:e=>n({...a,executionMode:e.target.value}),children:[s.jsx("option",{value:"side-thread",children:"side-thread"}),s.jsx("option",{value:"same-thread",children:"same-thread"})]})]}),s.jsx(H,{label:t("monitors.prompt"),rows:6,value:a.promptTemplate,onChange:e=>n({...a,promptTemplate:e.target.value})}),s.jsxs("label",{className:"flex items-center gap-2 text-sm text-gray-700 dark:text-gray-300",children:[s.jsx("input",{type:"checkbox",checked:a.enabled,onChange:e=>n({...a,enabled:e.target.checked})}),t("monitors.enabled")]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(p,{variant:"secondary",onClick:()=>u(!1),children:t("common.cancel")}),s.jsx(p,{onClick:A,disabled:N,children:t("common.save")})]})]})})]})}export{ve as default};
@@ -1 +1 @@
1
- import{j as e,C as m,g as a}from"./index-B36eowj-.js";function u({title:s,description:r,actions:t}){return e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-2xl font-semibold tracking-tight text-foreground",children:s}),r?e.jsx("p",{className:"mt-1 max-w-3xl text-sm leading-6 text-muted-foreground",children:r}):null]}),t?e.jsx("div",{className:"flex shrink-0 flex-wrap gap-2",children:t}):null]})}function o({title:s,description:r,actions:t,children:l,className:d,bodyClassName:n}){return e.jsxs(m,{className:a("p-0",d),children:[(s||r||t)&&e.jsxs("div",{className:"flex flex-col gap-3 border-b px-5 py-4 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[s?e.jsx("h2",{className:"text-sm font-semibold text-foreground",children:s}):null,r?e.jsx("p",{className:"mt-1 text-sm leading-5 text-muted-foreground",children:r}):null]}),t?e.jsx("div",{className:"flex shrink-0 flex-wrap gap-2",children:t}):null]}),e.jsx("div",{className:a("p-5",n),children:l})]})}const x={neutral:"border-border bg-muted text-muted-foreground",success:"border-primary/20 bg-primary/10 text-primary",warning:"border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-400/20 dark:bg-amber-500/10 dark:text-amber-200",danger:"border-destructive/20 bg-destructive/10 text-destructive dark:text-red-200",info:"border-blue-200 bg-blue-50 text-blue-700 dark:border-blue-400/20 dark:bg-blue-500/10 dark:text-blue-200"};function b({children:s,tone:r="neutral"}){return e.jsx("span",{className:a("inline-flex items-center rounded-full border px-2.5 py-1 text-xs font-medium",x[r]),children:s})}export{u as P,o as S,b as a};
1
+ import{j as e,C as m,g as a}from"./index-cI3pWBnN.js";function u({title:s,description:r,actions:t}){return e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-2xl font-semibold tracking-tight text-foreground",children:s}),r?e.jsx("p",{className:"mt-1 max-w-3xl text-sm leading-6 text-muted-foreground",children:r}):null]}),t?e.jsx("div",{className:"flex shrink-0 flex-wrap gap-2",children:t}):null]})}function o({title:s,description:r,actions:t,children:l,className:d,bodyClassName:n}){return e.jsxs(m,{className:a("p-0",d),children:[(s||r||t)&&e.jsxs("div",{className:"flex flex-col gap-3 border-b px-5 py-4 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[s?e.jsx("h2",{className:"text-sm font-semibold text-foreground",children:s}):null,r?e.jsx("p",{className:"mt-1 text-sm leading-5 text-muted-foreground",children:r}):null]}),t?e.jsx("div",{className:"flex shrink-0 flex-wrap gap-2",children:t}):null]}),e.jsx("div",{className:a("p-5",n),children:l})]})}const x={neutral:"border-border bg-muted text-muted-foreground",success:"border-primary/20 bg-primary/10 text-primary",warning:"border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-400/20 dark:bg-amber-500/10 dark:text-amber-200",danger:"border-destructive/20 bg-destructive/10 text-destructive dark:text-red-200",info:"border-blue-200 bg-blue-50 text-blue-700 dark:border-blue-400/20 dark:bg-blue-500/10 dark:text-blue-200"};function b({children:s,tone:r="neutral"}){return e.jsx("span",{className:a("inline-flex items-center rounded-full border px-2.5 py-1 text-xs font-medium",x[r]),children:s})}export{u as P,o as S,b as a};