@markus-global/cli 0.11.3 → 0.12.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backend.d.ts.map +1 -1
- package/dist/backend.js +5 -1
- package/dist/backend.js.map +1 -1
- package/dist/commands/approval-card.d.ts +53 -0
- package/dist/commands/approval-card.d.ts.map +1 -0
- package/dist/commands/approval-card.js +43 -0
- package/dist/commands/approval-card.js.map +1 -0
- package/dist/commands/auth.d.ts.map +1 -1
- package/dist/commands/auth.js +11 -5
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +7 -5
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/model.d.ts.map +1 -1
- package/dist/commands/model.js +6 -4
- package/dist/commands/model.js.map +1 -1
- package/dist/commands/outbound.d.ts +76 -0
- package/dist/commands/outbound.d.ts.map +1 -0
- package/dist/commands/outbound.js +80 -0
- package/dist/commands/outbound.js.map +1 -0
- package/dist/commands/start.d.ts +124 -2
- package/dist/commands/start.d.ts.map +1 -1
- package/dist/commands/start.js +718 -82
- package/dist/commands/start.js.map +1 -1
- package/dist/index.js +5 -20
- package/dist/index.js.map +1 -1
- package/dist/markus.mjs +112615 -103125
- package/dist/web-ui/assets/AsyncState-BebkDWbq.js +1 -0
- package/dist/web-ui/assets/{CommentInput-DN3Cichs.js → CommentInput-BRZWIC3U.js} +1 -1
- package/dist/web-ui/assets/{ContentRenderer-CjHOyYgJ.js → ContentRenderer-PGP8H_Zz.js} +2 -2
- package/dist/web-ui/assets/DeliverableShareModal-CcigVYGz.js +1 -0
- package/dist/web-ui/assets/Deliverables-CQwXaCA4.js +3 -0
- package/dist/web-ui/assets/{Notifications-CCsdBfdg.js → Notifications-BvHJCIRG.js} +1 -1
- package/dist/web-ui/assets/Search-BA-aXh7i.js +1 -0
- package/dist/web-ui/assets/SendToChat-CAfyKhpq.js +1 -0
- package/dist/web-ui/assets/Settings-icFp6tNI.js +8 -0
- package/dist/web-ui/assets/{Store-BWi97VP9.js → Store-DKwOcmMu.js} +1 -1
- package/dist/web-ui/assets/Switch-C7lFnHA7.js +1 -0
- package/dist/web-ui/assets/Team-DyqXLZ-X.js +84 -0
- package/dist/web-ui/assets/Work-BXGrda4S.js +12 -0
- package/dist/web-ui/assets/{arc-Cg0-C295.js → arc-Dnk6N-Zc.js} +1 -1
- package/dist/web-ui/assets/{architectureDiagram-3BPJPVTR-BctEHNLp.js → architectureDiagram-3BPJPVTR-CV8JIXXD.js} +1 -1
- package/dist/web-ui/assets/{blockDiagram-GPEHLZMM-hxr2ZwOV.js → blockDiagram-GPEHLZMM-D9pKmrXH.js} +1 -1
- package/dist/web-ui/assets/{c4Diagram-AAUBKEIU-CfIRo1GE.js → c4Diagram-AAUBKEIU-Q26HvIpY.js} +1 -1
- package/dist/web-ui/assets/channel-BZs6ereM.js +1 -0
- package/dist/web-ui/assets/{chunk-2J33WTMH-T0bENsqX.js → chunk-2J33WTMH-BSjFVwnx.js} +1 -1
- package/dist/web-ui/assets/{chunk-4BX2VUAB-ChLLkyYx.js → chunk-4BX2VUAB-BZXv4MQp.js} +1 -1
- package/dist/web-ui/assets/{chunk-55IACEB6-BD3ENYp9.js → chunk-55IACEB6-CeKd3oeJ.js} +1 -1
- package/dist/web-ui/assets/{chunk-727SXJPM-BAes4atE.js → chunk-727SXJPM-DP1tSQo5.js} +1 -1
- package/dist/web-ui/assets/{chunk-AQP2D5EJ-FymM7gfT.js → chunk-AQP2D5EJ-DqEncn7j.js} +1 -1
- package/dist/web-ui/assets/{chunk-FMBD7UC4-N5sRT0m9.js → chunk-FMBD7UC4-tuDUJ9Xx.js} +1 -1
- package/dist/web-ui/assets/{chunk-ND2GUHAM-BSjS3JyS.js → chunk-ND2GUHAM-DoC8aLWB.js} +1 -1
- package/dist/web-ui/assets/{chunk-QZHKN3VN-Dkwitdbr.js → chunk-QZHKN3VN-74zpvcgs.js} +1 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-C9JIxJeJ.js +1 -0
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-C9JIxJeJ.js +1 -0
- package/dist/web-ui/assets/{cose-bilkent-S5V4N54A-BLuYATCK.js → cose-bilkent-S5V4N54A-DjYUalC1.js} +1 -1
- package/dist/web-ui/assets/{dagre-BM42HDAG-DGLiqiH2.js → dagre-BM42HDAG-oSewacE8.js} +1 -1
- package/dist/web-ui/assets/{diagram-2AECGRRQ-Cq_GnNKs.js → diagram-2AECGRRQ-C1fiWe46.js} +1 -1
- package/dist/web-ui/assets/{diagram-5GNKFQAL-CHNz-2dA.js → diagram-5GNKFQAL-9G_q6hCa.js} +1 -1
- package/dist/web-ui/assets/{diagram-KO2AKTUF-D8eKa7jh.js → diagram-KO2AKTUF-CSm-lJp-.js} +1 -1
- package/dist/web-ui/assets/{diagram-LMA3HP47-RkDgQcLr.js → diagram-LMA3HP47-BTAORcHx.js} +1 -1
- package/dist/web-ui/assets/{diagram-OG6HWLK6-LqxQrIwa.js → diagram-OG6HWLK6-DbcCkDfo.js} +1 -1
- package/dist/web-ui/assets/{docx-preview-Be-Qo_ag.js → docx-preview-DjqdA44x.js} +1 -1
- package/dist/web-ui/assets/{erDiagram-TEJ5UH35-BX0zZgYQ.js → erDiagram-TEJ5UH35-DFa-B8-u.js} +1 -1
- package/dist/web-ui/assets/{flowDiagram-I6XJVG4X-DKnfIFA4.js → flowDiagram-I6XJVG4X-WCTnaK9M.js} +1 -1
- package/dist/web-ui/assets/{ganttDiagram-6RSMTGT7-DjBURmY-.js → ganttDiagram-6RSMTGT7-DbW1CoJJ.js} +1 -1
- package/dist/web-ui/assets/{gitGraphDiagram-PVQCEYII-BvSi7SvS.js → gitGraphDiagram-PVQCEYII-1faDfO29.js} +1 -1
- package/dist/web-ui/assets/index-B8h1PPzP.js +883 -0
- package/dist/web-ui/assets/index-DD3NMntN.css +1 -0
- package/dist/web-ui/assets/{infoDiagram-5YYISTIA-CwtIgim2.js → infoDiagram-5YYISTIA-DfXKP4tQ.js} +1 -1
- package/dist/web-ui/assets/{ishikawaDiagram-YF4QCWOH-CWhXJfSa.js → ishikawaDiagram-YF4QCWOH-D6FOsFQ5.js} +1 -1
- package/dist/web-ui/assets/{journeyDiagram-JHISSGLW-DN9rorlL.js → journeyDiagram-JHISSGLW-DXpxntIF.js} +1 -1
- package/dist/web-ui/assets/{kanban-definition-UN3LZRKU-Burf5FE8.js → kanban-definition-UN3LZRKU-Dt7FBCF3.js} +1 -1
- package/dist/web-ui/assets/{mermaid.core-Dx4rzlyC.js → mermaid.core-sTcSUoRD.js} +5 -5
- package/dist/web-ui/assets/{mindmap-definition-RKZ34NQL-DqZ21Siw.js → mindmap-definition-RKZ34NQL-CvOU23ga.js} +1 -1
- package/dist/web-ui/assets/{pieDiagram-4H26LBE5-C_4ksu-T.js → pieDiagram-4H26LBE5-DUedtXVj.js} +1 -1
- package/dist/web-ui/assets/{quadrantDiagram-W4KKPZXB-Dl6Rjg1X.js → quadrantDiagram-W4KKPZXB-CqpHHRca.js} +1 -1
- package/dist/web-ui/assets/{requirementDiagram-4Y6WPE33-CzmWi02d.js → requirementDiagram-4Y6WPE33-CKZYvVDJ.js} +1 -1
- package/dist/web-ui/assets/{sankeyDiagram-5OEKKPKP-D8K7e8we.js → sankeyDiagram-5OEKKPKP-gZ0nzDfs.js} +1 -1
- package/dist/web-ui/assets/{sequenceDiagram-3UESZ5HK-1z9rqtVx.js → sequenceDiagram-3UESZ5HK-DN3XdBkW.js} +1 -1
- package/dist/web-ui/assets/{stateDiagram-AJRCARHV-nneYkkHa.js → stateDiagram-AJRCARHV-BvtafGxO.js} +1 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-B2nWDV5R.js +1 -0
- package/dist/web-ui/assets/{timeline-definition-PNZ67QCA-D6GmLlRi.js → timeline-definition-PNZ67QCA-BrR919lp.js} +1 -1
- package/dist/web-ui/assets/{vennDiagram-CIIHVFJN-TVefhiCa.js → vennDiagram-CIIHVFJN-B7CTm4yM.js} +1 -1
- package/dist/web-ui/assets/{wardley-L42UT6IY-BgUuAeiM.js → wardley-L42UT6IY-CyqFngx_.js} +1 -1
- package/dist/web-ui/assets/{wardleyDiagram-YWT4CUSO-CyJ_l94o.js → wardleyDiagram-YWT4CUSO-BCqEPBJ5.js} +1 -1
- package/dist/web-ui/assets/{xychartDiagram-2RQKCTM6-kajbbx7a.js → xychartDiagram-2RQKCTM6-BmT6Cmz-.js} +1 -1
- package/dist/web-ui/index.html +2 -2
- package/docs/README.md +1 -0
- package/docs/architecture/architecture.md +1 -1
- package/docs/architecture/configuration-model.md +156 -0
- package/docs/architecture/messaging-gateway.md +1043 -0
- package/docs/architecture/notification-delivery.md +273 -0
- package/docs/design/remote-access-contract.md +445 -0
- package/docs/guides/development.md +1 -1
- package/docs/guides/guide.md +4 -2
- package/docs/guides/remote-access.md +147 -214
- package/docs/handoff/approval-tri-state-handoff.md +69 -0
- package/docs/handoff/remote-access-handoff.md +160 -0
- package/docs/records/agent-platform-friction-2026-10.md +102 -2
- package/package.json +1 -1
- package/dist/web-ui/assets/DeliverableShareModal-CBSvxB-X.js +0 -1
- package/dist/web-ui/assets/Deliverables-BaAF4-w0.js +0 -3
- package/dist/web-ui/assets/Search-BiBdevAU.js +0 -1
- package/dist/web-ui/assets/Settings-CawBnWuy.js +0 -8
- package/dist/web-ui/assets/Team-CfUDkdc3.js +0 -84
- package/dist/web-ui/assets/Work-DrIXOW-P.js +0 -12
- package/dist/web-ui/assets/channel-DAQ2Rbxq.js +0 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-BZyCVtJb.js +0 -1
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-BZyCVtJb.js +0 -1
- package/dist/web-ui/assets/index-D8vskks7.js +0 -882
- package/dist/web-ui/assets/index-DEN_qReg.css +0 -1
- package/dist/web-ui/assets/modelCapabilities-DDtCBZ6o.js +0 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-C-hpzcms.js +0 -1
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# 远程访问重构 · 交付说明与手动验证(T10 收口)
|
|
2
|
+
|
|
3
|
+
> 作者:CTO · 2026-10-14 · 状态:**交老板手动合入前的交付说明**
|
|
4
|
+
> 需求:`req_656422cc529a09e31cd04990` · 设计:`remote-access-design.md`(v2) · 契约:`docs/design/remote-access-contract.md`(冻结 v1.0.0)
|
|
5
|
+
> 一句话:**用户自带隧道(Cloudflare / Tailscale)+ Hub 只做入口域名 / 端点注册表 / 登录鉴权门**,数据通路不再经过我们的服务器。
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 1. 这次交付了什么
|
|
10
|
+
|
|
11
|
+
| 片 | 内容 | 分支 / 提交 |
|
|
12
|
+
|---|---|---|
|
|
13
|
+
| T1 | 冻结契约(枚举 / 错误码 / 签名串 / SSRF 表 / 探针阈值) | `feat/remote-access-tunnel` 基线 |
|
|
14
|
+
| T2 | Hub 端点注册表 schema + 迁移 | → `42b4385` |
|
|
15
|
+
| T6 / T7 | TunnelManager(cloudflared / tailscale provider)、RegistryClient + verify-server | 同上 |
|
|
16
|
+
| T8 | 本地 CLI / api-server 接线 + `RemoteStatusV2` | `ae16de96` |
|
|
17
|
+
| T9 | Web-UI 开通向导 + 就绪面板 + i18n(zh/en/es) + 文档 | `3af312d9` |
|
|
18
|
+
| T3 | Hub 端点 API + 归属校验(challenge-response + SSRF 防护 + secret 发放) | `feat/remote-endpoints` `a6d6241` |
|
|
19
|
+
| T5 | 入口域名 302 + 登录鉴权门 + legacy 灰度回落 | `feat/remote-endpoints` `88e6a61` |
|
|
20
|
+
| **T10** | **路径 B(一键交 Agent 代跑)+ 端到端集成收口**(本片) | `feat/remote-access-t10` |
|
|
21
|
+
|
|
22
|
+
**本片(T10)新增**
|
|
23
|
+
1. **路径 B**:向导「交给 Agent」→ 生成结构化任务契约(`goal / commands[{shell,run,purpose,sensitive,idempotent}] / successCriteria / rollback`)→ 用户**自选**接收 Agent → 派发 → 进度回报 → 完成后前端自动切「就绪」。复用平台既有 Agent + shell + task 能力,**不新增专用执行通道**。
|
|
24
|
+
2. **跨仓集成收口**:修掉 T8↔T9 的路由契约接缝(前端声明 `/tunnel/{restart,rotate,stop,register}` + `/detect`,T8 只实现了 `/restart`、`/rotate`)。
|
|
25
|
+
3. **T3⇄T5 语义漂移归零**:`health='unknown'` 曾出现 T3 判 `pending`、T5 判 503 `down` 的分歧 → 收敛为**单一事实源** `entry-status.ts#entryStatusOf()`,两个消费方共用,并配跨组件一致性测试(含变异检验)。
|
|
26
|
+
4. **本地端到端 harness**:真 Hub + 真 `cloudflared` 隧道 + 真归属探针(走公网往返)+ 真入口门 302 → **19/19 断言绿**。
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## 2. 给老板的分步手动验证脚本
|
|
31
|
+
|
|
32
|
+
> 目标:在你自己的机器上亲手跑通「点一下 → 手机打开自己的 Markus,数据不经我们」。
|
|
33
|
+
|
|
34
|
+
### 2.1 一键端到端(推荐先跑这个)
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
cd <markus 仓库>/worktrees/markus-ra-t10 # 或合入后的主仓
|
|
38
|
+
bash scripts/e2e/remote-access-e2e.sh
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
它会自动:起一个"我的 Markus"替身 App → 起**真 cloudflared 快速隧道**指向它 → 起**真 Hub**(临时库)→ 注册用户/端点 → 让 Hub **经公网**探针校验归属 → 校验入口门四种分支。
|
|
42
|
+
期望输出结尾:`═══ RESULT: 19 passed, 0 failed ═══`
|
|
43
|
+
|
|
44
|
+
它逐条验证的关键行为:
|
|
45
|
+
- ✅ 公网隧道直达本机(**数据通路不经我们**)
|
|
46
|
+
- ✅ 未登录访问入口 → 302 到登录页,且**响应体与响应头都不含隧道地址**(S1)
|
|
47
|
+
- ✅ 公开状态端点 `/api/remote/entry/:username` 只回 `{status}`,**不含隧道地址**(S1)
|
|
48
|
+
- ✅ 登录用户访问自己入口 → **302,`Location` 逐字等于 `publicUrl`**(见 §3 已知行为)
|
|
49
|
+
- ✅ **他人**访问你的入口 → 403,且不泄露隧道地址
|
|
50
|
+
|
|
51
|
+
### 2.2 手动分步(想自己掐每一步时)
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# ① 起本机 App 替身(真机可换成 `markus start` 后的本地端口)
|
|
55
|
+
node scripts/e2e/tunnel-target-stub.mjs &
|
|
56
|
+
# ② 起隧道,记下打印的 https://xxx.trycloudflare.com
|
|
57
|
+
cloudflared tunnel --url http://127.0.0.1:18056
|
|
58
|
+
# ③ 起 Hub(临时库,避免污染)
|
|
59
|
+
cd <markus-hub 仓库> && DATABASE_PATH=/tmp/hub-e2e.db JWT_SECRET=e2e npx tsx src/server/index.ts
|
|
60
|
+
# ④ 注册用户(拿会话 cookie)
|
|
61
|
+
curl -i -X POST localhost:3003/api/auth/register -H 'content-type: application/json' \
|
|
62
|
+
-d '{"username":"you","email":"you@example.com","password":"<pw>"}'
|
|
63
|
+
# ⑤ 注册端点 → 记下 verifyToken / verifyPath,让替身 App 在该路径回 {"token":"<verifyToken>"}
|
|
64
|
+
curl -X POST localhost:3003/api/remote/endpoints -H "Cookie: hub_token=<t>" \
|
|
65
|
+
-H 'content-type: application/json' -d '{"kind":"cloudflare_quick","publicUrl":"<隧道URL>"}'
|
|
66
|
+
# ⑥ 触发归属校验(Hub 会经公网探针回访)
|
|
67
|
+
curl -X POST localhost:3003/api/remote/endpoints/<id>/verify -H "Cookie: hub_token=<t>"
|
|
68
|
+
# ⑦ 入口门(本地用 ?_remote_user= 模拟 Vercel 边缘把 Host 改写成的形态)
|
|
69
|
+
curl -i 'localhost:3003/api?_remote_user=you' # 期望 302 → /auth/login
|
|
70
|
+
curl -i -H "Cookie: hub_token=<t>" 'localhost:3003/api?_remote_user=you' # 期望 302 → 隧道URL
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
> 本地是用 `?_remote_user=` **模拟**边缘改写;生产由 Vercel `middleware.ts` 把 `Host: {user}.remote.markus.global` 改写成该查询参数。这是 §4 风险 ④ 的来源。
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## 3. 已知行为(措辞与实现严格一致)
|
|
78
|
+
|
|
79
|
+
1. **入口门 302 的 `Location` 逐字等于该端点的 `publicUrl`,不拼接任何深链 path/query。**
|
|
80
|
+
即:你请求 `https://{user}.remote.markus.global/some/deep/path?a=1`,`Location` 仍然是 `https://xxx.trycloudflare.com`(根),**深链由隧道侧自行处理**。这是当前实现,不是"将来会做路径拼接"。
|
|
81
|
+
2. `health='unknown'`(尚未探针过的瞬态)在**所有**展示口径下都读作"尚未就绪"(`pending`),**绝不**读作"通道离线"。
|
|
82
|
+
3. 入口门对 **非 GET/HEAD** 与非法用户名**不做处理**(交还后续路由)。
|
|
83
|
+
4. 未校验(pending)的端点走 **200「尚未开启」**页,不是 302。
|
|
84
|
+
5. 未鉴权一律不返回隧道地址:**响应体与响应头都没有 `publicUrl` / target**。
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## 4. 待部署验证项(**未在本地端到端环境验证**)
|
|
89
|
+
|
|
90
|
+
### 4.1 跨子域 cookie(`Domain=.markus.global`)
|
|
91
|
+
|
|
92
|
+
入口子域 `{user}.remote.markus.global` 要能读到主站登录态,`hub_token` 必须带 `Domain=.markus.global`(T5 已改)。**本地 localhost 下 Domain 属性会被浏览器省略,因此本地无法证伪,必须在真实域名上复验。**
|
|
93
|
+
|
|
94
|
+
最小验证步骤:
|
|
95
|
+
```bash
|
|
96
|
+
# ① 直测 Set-Cookie 三属性(放到真实域名上跑)
|
|
97
|
+
curl -i -X POST https://www.markus.global/api/auth/login \
|
|
98
|
+
-H 'content-type: application/json' -d '{"username":"you","password":"<pw>"}' \
|
|
99
|
+
| grep -i '^set-cookie'
|
|
100
|
+
# 期望看到:hub_token=…; Path=/; Domain=.markus.global; HttpOnly; Secure; SameSite=Lax(或 Strict)
|
|
101
|
+
# 注意:不要用 __Host- 前缀 —— 它与 Domain 互斥(契约已冻结该取舍)
|
|
102
|
+
```
|
|
103
|
+
```
|
|
104
|
+
# ② 浏览器跨子域登录态可达
|
|
105
|
+
# 在 www.markus.global 登录后,直接访问 https://{user}.remote.markus.global
|
|
106
|
+
# 期望:不再跳登录页,而是 302 到隧道地址(说明入口子域读到了主站 cookie)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### 4.2 其余部署复验
|
|
110
|
+
|
|
111
|
+
| 项 | 为什么本地测不了 | 怎么验 |
|
|
112
|
+
|---|---|---|
|
|
113
|
+
| 真实 `{user}.remote.markus.global` 边缘改写 | 本地用 `?_remote_user=` 模拟 | 部署后直接访问入口域名,看是否 302/403/200 分支正确 |
|
|
114
|
+
| Cloudflare **命名**隧道(自有域名) | 需自有域名 + CF 账号 | 向导选「命名隧道」,跑通后确认 URL 稳定不轮换 |
|
|
115
|
+
| Tailscale Funnel / Serve | 需 tailnet | 分别验「公网可达」与「仅 tailnet 内」两种形态 |
|
|
116
|
+
| 轮换(rotate)后入口跟随 | 需真实 tunnel 生命周期 | 轮换 URL 后重访入口,`Location` 应指向新地址 |
|
|
117
|
+
| legacy 旧中继灰度回落 | 需真有旧 `hub_instances` 用户 | 老用户未开通新隧道时,入口应回落到旧壳而非报错 |
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## 5. 残余风险清单(**必须保留,不得在文档中消失**)
|
|
122
|
+
|
|
123
|
+
1. **第三方隧道可达性 / 快速隧道不稳。** Cloudflare Quick Tunnel 是随机的 `*.trycloudflare.com`,**重连后 URL 会变**。我们靠「隧道地址自动同步 + 轮换」兜底,但同步窗口内入口可能短暂指向失效地址。用户长期使用应引导到**命名隧道**(自有域名,一等公民)。
|
|
124
|
+
2. **公开 entry 状态端点仍暴露侧信道。** `GET /api/remote/entry/:username` 返回 `{status}`,会泄露「该用户名是否存在 + 其隧道 up/down」。当前缓解仅靠 **IP 限流(60/min)+ 常量底延迟(默认 250ms,可 env 调)**,属**尽力而为**、**非密码学恒定时间**。**这是已知且被接受的取舍**——如实记录于此,不因为"看起来是安全问题"就从文档里删掉。
|
|
125
|
+
3. **跨子域 cookie(`Domain=.markus.global`)。** 见 §4.1:真机未验;且 `__Host-` 前缀与跨子域不可兼得(已选跨子域)。若未来要 `__Host-`,必须改为在入口子域单独发一份 cookie。
|
|
126
|
+
4. **本地端到端环境与生产存在差异。** 本地用 `?_remote_user=` 模拟边缘改写,生产走真实 DNS + Vercel middleware;本地 temp DB,生产是远程 Turso(**libsql 事务语义不同**——本地嵌入式与远程 hrana 行为不一致,已在别处踩过坑)。**绿在本地 ≠ 绿在生产。**
|
|
127
|
+
5. **边界说明:入口门是「第一道」,隧道侧登录才是「根本」。** 302 一跳后,隧道地址进入浏览器地址栏,地址本身即凭据(持有者可直连)。因此生产必须叠加 **Cloudflare Access / Tailscale ACL** 作为第二道防线。入口门解决的是"从我们域名进不来",**不等于**"隧道绝对安全"。
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## 6. 未做项(P2 / P3,如实列出)
|
|
132
|
+
|
|
133
|
+
- **P2**:团队共享访问(多成员访问同一入口,契约中的 O1)——本期只做「一人一入口」。
|
|
134
|
+
- **P2**:入口门 302 **深链透传**(现在 `Location` 只到根,深链 path/query 丢失,依赖隧道侧自行处理)。
|
|
135
|
+
- **P2**:旧 WebRTC 中继代码的**物理删除**(现仅灰度不回落到新路径,代码仍在)。
|
|
136
|
+
- **P3**:nonce 防重放的**共享存储**(现为进程内窗口,容量 10000 / 窗口 2×300s)——Hub 多实例部署前必须替换,代码注释已标注。
|
|
137
|
+
- **P3**:`pricing.test.ts` 的 `SQLITE_BUSY`(迁移期多进程争用默认 DB)——**既有缺陷**,已在基线复现,与本需求无关,建议另立修复单。
|
|
138
|
+
- **P3**:路径 B 的**真机端到端**(真 cloudflared + 真 Agent 跑完安装)——本期以「集成级 E2E(真 HTTP 处理器 + 真 Agent 注册表)」+「隧道/Hub 半程真 cloudflared E2E」覆盖,**Agent 真正执行安装那一步未在真机跑通**。
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## 7. 合入前状态
|
|
143
|
+
|
|
144
|
+
- 两个仓均为**本地分支,未 push、未动 main**(遵循本重构硬约束)。
|
|
145
|
+
- markus:`feat/remote-access-t10`;markus-hub:`feat/remote-endpoints`。
|
|
146
|
+
- 逐片保留独立可回滚提交(T2 → T8 → T9 → T3 → T5 → T10)。
|
|
147
|
+
- 验证结论见 §8。
|
|
148
|
+
|
|
149
|
+
## 8. 本片验证证据(摘要)
|
|
150
|
+
|
|
151
|
+
| 验证 | 结果 |
|
|
152
|
+
|---|---|
|
|
153
|
+
| 跨仓本地端到端 harness(真 cloudflared + 真 Hub + 真 302) | **19/19 断言绿** |
|
|
154
|
+
| Hub 目标测试(ssrf 44 + 端点 API 29 + 入口门 16 + 一致性 6) | **95/95 绿** |
|
|
155
|
+
| Hub `tsc --noEmit` 首方错误 | **0**(vendored 23 条为既有) |
|
|
156
|
+
| Hub 全量单测 | 1069/1070(唯一失败 `billing-gaps` cu_reset_at,**已在 merge-base 复现 = 既有**) |
|
|
157
|
+
| markus 全量单测 | 6969/6984(失败仅 1 条既有 `commands-start-integration` 端口冲突 + 若干负载型 timing flake,均在 pristine HEAD 复现) |
|
|
158
|
+
| markus `tsc -b` + web-ui typecheck | **exit 0** |
|
|
159
|
+
| 架构守卫 | ✓ 通过(31 命中全在白名单,契约不变量 11/11) |
|
|
160
|
+
| 牙齿检验 | 把 `entryStatusOf` 的 unknown 分支改成 `down` → 一致性测试**精确变红**;复原即绿 |
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
# Agent Platform Friction — field notes from a working agent (2026-10)
|
|
2
2
|
|
|
3
|
-
> **Status:
|
|
4
|
-
>
|
|
3
|
+
> **Status: audited 2026-10-08.** Before acting on this record it was re-read against `main` (the
|
|
4
|
+
> v0.11.3 era). Two items were already resolved and the record did not say so: the *core* of F1/F2
|
|
5
|
+
> had shipped with H6 (`f7cdbd7d`), and T5 (`docs/api/` ignore) was already fixed. The remaining
|
|
6
|
+
> gaps were actioned in the PR that closes [#366](https://github.com/markus-global/markus/issues/366).
|
|
7
|
+
> Per-item verdicts are in the audit below; the original bodies are kept verbatim as the dated
|
|
8
|
+
> evidence they are, each now carrying a **Resolution** line.
|
|
9
|
+
>
|
|
10
|
+
> **Live-verified 2026-10-09** on a rebuilt desktop bundle (`probe/friction-live-1009`, cherry-pick of
|
|
11
|
+
> the fix commit): the new delegation fields appear in the real `spawn_subagent` envelope, and F1/F3
|
|
12
|
+
> behave exactly as designed (a budget-stopped child returned `budgetHit: 'own'` plus an `[INCOMPLETE …]`
|
|
13
|
+
> note that reminds the parent to verify before trusting the child's output).
|
|
5
14
|
|
|
6
15
|
Written by an agent that runs on Markus and used its own delegation, background-exec and test
|
|
7
16
|
tooling for a multi-hour real task. Every item below is something that cost real time and that a
|
|
@@ -12,6 +21,22 @@ This is a *dated record* (see `docs/records/`). It is not a specification.
|
|
|
12
21
|
|
|
13
22
|
---
|
|
14
23
|
|
|
24
|
+
## 0. Audit (2026-10-08) — already fixed vs. still owed
|
|
25
|
+
|
|
26
|
+
| Item | Verdict on `main` before this pass | Resolution |
|
|
27
|
+
|------|------------------------------------|------------|
|
|
28
|
+
| **F1** | **Partly fixed by H6** (`f7cdbd7d`): `iteration_budget` is now an independent per-child budget, and the fan-out pool is a breaker only. Still missing: the breaker was undocumented, and a stopped child reported only a boolean. | Breaker documented in the `spawn_subagents` description; `budgetHit` added. |
|
|
29
|
+
| **F2** | **Partly fixed by H6**: `output` is never empty and carries an `[INCOMPLETE …]` note. Still missing: no structured record of *what* was written. | `filesTouched` added and echoed in the note as a best-effort **reminder to verify** — not an exhaustive audit. Counting every write path (shell, scripts, builds) is intentionally out of scope (owner decision, 2026-10-09). |
|
|
30
|
+
| **F3** | **Open.** | `toolCalls { total, writes }` added; a zero-write early stop now says so. |
|
|
31
|
+
| **F4** | **Partly fixed by H6** (`status` / `iterations` / `aggregateCeilingReached`). | Extended with the fields above; the schema now crosses the `spawn_subagent` / `spawn_subagents` boundary. |
|
|
32
|
+
| **T1** | Still true. | Documented in `CONTRIBUTING.md` → *Development Gotchas*. |
|
|
33
|
+
| **T2** | Still true (pnpm builtin). | Documented. |
|
|
34
|
+
| **T3** | Still true (pnpm semantics). | Documented. |
|
|
35
|
+
| **T4** | Still true. | Documented (points at `scripts/sync-dir.mjs`). |
|
|
36
|
+
| **T5** | **Already fixed** before this audit. | No change; record corrected. |
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
15
40
|
## 1. Platform issues (Markus itself)
|
|
16
41
|
|
|
17
42
|
### F1 — `spawn_subagents` iteration budgets are shared, not per-child, and the sharing is invisible
|
|
@@ -32,6 +57,11 @@ boundary with "use `iteration_budget` for per-child limits". Whatever is chosen,
|
|
|
32
57
|
ceiling must be documented in the tool description, and the response should state which budget was
|
|
33
58
|
hit (`own` vs `aggregate`) — today it only reports `aggregateCeilingReached` on some children.
|
|
34
59
|
|
|
60
|
+
**Resolution (2026-10-08).** H6 had already made the budget genuinely per-child and turned the
|
|
61
|
+
shared pool into a breaker. This pass documented the breaker in the tool description and added
|
|
62
|
+
`budgetHit: 'own' | 'aggregate' | 'max_iterations' | null`, so a parent learns *which* budget
|
|
63
|
+
stopped a child and not merely that one did.
|
|
64
|
+
|
|
35
65
|
### F2 — A budget-exhausted child leaves silent partial writes
|
|
36
66
|
|
|
37
67
|
**Observed.** A child stopped at its budget returned exactly
|
|
@@ -48,6 +78,12 @@ children cannot know about each other.
|
|
|
48
78
|
the default behaviour for a child that ends `budget_exhausted` *without* a completion report either
|
|
49
79
|
(a) revert its writes, or (b) explicitly mark them as unverified in the parent's context.
|
|
50
80
|
|
|
81
|
+
**Resolution (2026-10-08).** Added `filesTouched: string[]` — the distinct paths a child actually
|
|
82
|
+
changed via `file_write` / `file_edit` / `apply_patch` (errored calls and `apply_patch` dry runs are
|
|
83
|
+
excluded) — and echoed it inside the `[INCOMPLETE …]` note. Option (b) was chosen over (a): the
|
|
84
|
+
writes are *marked*, not silently reverted, because reverting a child's work behind its parent's
|
|
85
|
+
back is exactly the "platform decides your content" failure this record keeps warning about.
|
|
86
|
+
|
|
51
87
|
### F3 — No signal that a task is too large for one child
|
|
52
88
|
|
|
53
89
|
**Observed.** Two attempts to audit a ~900-line document each burned the full budget (30 then 35
|
|
@@ -60,12 +96,23 @@ There is no feedback that says "this child spent 90 % of its budget on reads".
|
|
|
60
96
|
**Suggested change.** Return an iteration breakdown (reads vs writes) in the result, and surface a
|
|
61
97
|
hint when a child exhausts its budget without a single write.
|
|
62
98
|
|
|
99
|
+
**Resolution (2026-10-08, rescoped 2026-10-09).** Added `toolCalls: { total, writes }`. We
|
|
100
|
+
deliberately did not split calls into "reads" vs "writes" (a `shell_execute` can write without being
|
|
101
|
+
a write tool). We also do **not** claim that an early stop wrote nothing: enumerating every write
|
|
102
|
+
path (shell redirection, scripts, builds) is impossible, so the note is a *reminder to verify*, not
|
|
103
|
+
a negative assertion (owner decision, 2026-10-09 — see the F2 audit row).
|
|
104
|
+
|
|
63
105
|
### F4 — Delegation results have no schema
|
|
64
106
|
|
|
65
107
|
The free-text `result` is fine for a summary, but the parent needs machine-checkable fields
|
|
66
108
|
(what changed, what was verified, what was left). Right now the only reliable audit path is to
|
|
67
109
|
ignore the report and diff the workspace — which works, but means the report is decoration.
|
|
68
110
|
|
|
111
|
+
**Resolution (2026-10-08).** H6 had already structured `status` / `iterations` /
|
|
112
|
+
`aggregateCeilingReached`; this pass adds `budgetHit`, `filesTouched` and `toolCalls` to both
|
|
113
|
+
`spawn_subagent` and `spawn_subagents`. The report is no longer decoration — a parent can branch on
|
|
114
|
+
the fields without touching the workspace.
|
|
115
|
+
|
|
69
116
|
---
|
|
70
117
|
|
|
71
118
|
## 2. Repo tooling papercuts (not platform bugs, but they cost the same time)
|
|
@@ -88,6 +135,11 @@ ignore the report and diff the workspace — which works, but means the report i
|
|
|
88
135
|
typedoc generator that no longer exists anywhere in the repo, so the directory that holds the
|
|
89
136
|
API reference was silently ignoring any new file added to it.
|
|
90
137
|
|
|
138
|
+
**Resolution (2026-10-08).** T1–T4 are workflow papercuts rather than defects in our code, so they
|
|
139
|
+
are now documented in `CONTRIBUTING.md` → *Development Gotchas* instead of being "fixed" with a
|
|
140
|
+
wrapper. T5 was already fixed: `.gitignore` now states that `docs/api/` is deliberately tracked and
|
|
141
|
+
only `docs/api-test/` is ignored.
|
|
142
|
+
|
|
91
143
|
---
|
|
92
144
|
|
|
93
145
|
## 3. What I would fix first
|
|
@@ -96,3 +148,51 @@ ignore the report and diff the workspace — which works, but means the report i
|
|
|
96
148
|
2. **F2**, because it is the difference between "safe to fan out" and "must diff after every
|
|
97
149
|
dispatch".
|
|
98
150
|
3. Then the repo tooling items — they are cheap and each one has already burned time twice.
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## 4. New friction found while fixing these (2026-10-08)
|
|
155
|
+
|
|
156
|
+
Four more items surfaced during the audit-and-fix pass. They are recorded here, not fixed in it.
|
|
157
|
+
|
|
158
|
+
### F5 — A dated record can silently drift from the code, and its own banner hides it
|
|
159
|
+
|
|
160
|
+
`docs/records/` files are written as field notes, but nothing forces them to be re-checked against
|
|
161
|
+
`HEAD`. This file's banner still read *"Nothing here has been actioned yet"* while H6 had already
|
|
162
|
+
fixed the core of F1/F2 — so the record and the code disagreed and neither side said so. **Observed
|
|
163
|
+
cost:** the first chunk of this task went into re-deriving what was actually left. **Suggested
|
|
164
|
+
change:** give every `docs/records/*` file an explicit `Audited: <sha> / <date>` line plus per-item
|
|
165
|
+
verdicts, and treat "re-audit this record against HEAD" as step 0 of any task that picks it up.
|
|
166
|
+
(§0 of this document is what that looks like.)
|
|
167
|
+
|
|
168
|
+
### F6 — The tool-loop detector fires on identical result *envelopes*, not identical actions
|
|
169
|
+
|
|
170
|
+
Applying a batch of `file_edit` calls that each replaced a *different* hunk tripped
|
|
171
|
+
`Loop detected: "file_edit" returned identical results 6 times`. The calls were not a loop — they
|
|
172
|
+
were a normal refactor — but every successful edit returns the same envelope
|
|
173
|
+
(`{"status":"success","path":…,"replacements":1}`), and the detector compares envelopes. **Why it is
|
|
174
|
+
a problem:** the warning is a false positive by construction for *any* repetitive-but-distinct
|
|
175
|
+
operation (a multi-hunk refactor, a fan-out of same-shaped writes), and false positives are exactly
|
|
176
|
+
how a detector trains its reader to ignore it. The only workaround is to spread a normal edit batch
|
|
177
|
+
over several turns — i.e. the tooling makes correct behaviour slower. **Suggested change:** key the
|
|
178
|
+
detector on the call *arguments* (or a hash of them), or exempt calls whose result reports a
|
|
179
|
+
distinct side effect (`replacements`, `bytesWritten`), instead of on the result body. This item was
|
|
180
|
+
itself produced by the detector firing repeatedly during this very pass.
|
|
181
|
+
|
|
182
|
+
### T6 — A `git worktree` does not inherit `node_modules`, and reusing the primary checkout's is wrong
|
|
183
|
+
|
|
184
|
+
The clean way to develop a PR without disturbing the primary checkout is `git worktree add`. A fresh
|
|
185
|
+
worktree has **no** `node_modules`, and symlinking the primary checkout's is actively incorrect:
|
|
186
|
+
pnpm's workspace symlinks (`node_modules/@markus/shared → ../../packages/shared`) resolve back to the
|
|
187
|
+
*primary* checkout, so tests would run against the wrong sources. The correct move is a fresh
|
|
188
|
+
`pnpm install --prefer-offline --frozen-lockfile` **inside** the worktree — fast (6.3 s here) because
|
|
189
|
+
pnpm hardlinks from its global store. Documented in `CONTRIBUTING.md`.
|
|
190
|
+
|
|
191
|
+
### T7 — `CONTRIBUTING.md` recommended a test command that cannot work
|
|
192
|
+
|
|
193
|
+
The command table advised `pnpm test --filter @markus/<pkg>`, but no package other than the repo root
|
|
194
|
+
has a `test` script (`pnpm --filter @markus/core test` just looks for a `test` script that isn't
|
|
195
|
+
there). The working form is the root Vitest plus a positional path filter —
|
|
196
|
+
`pnpm test -- packages/core`. **Resolution:** already applied (the table and *Development Gotchas*),
|
|
197
|
+
and recorded here so the pattern is not reintroduced.
|
|
198
|
+
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{u as de,r as u,h as R,o as ue,t as fe,l as N,j as r}from"./index-D8vskks7.js";const G=50*1024*1024,q=new Set(["markdown","html"]);function be(e){return e||"markdown"}function he(e){return q.has(be(e))}class S extends Error{constructor(t){super(t),this.name="DeliverableShareError"}}class Q extends S{constructor(){super("需要登录 Markus Hub 账号后才能分享产出物。"),this.name="NotLoggedIntoHubError"}}class pe extends S{bytes;limit;constructor(t,a){super(`产出物文件大小 ${t} 字节超过上限 ${a} 字节(50MB),请压缩或拒绝分享。`),this.name="DeliverableTooLargeError",this.bytes=t,this.limit=a}}class me extends S{status;constructor(t,a){super(`Hub 请求失败 (HTTP ${t}): ${a}`),this.name="HubApiError",this.status=t}}function ge(e){const t=e.replace(/\s+/g,"");if(!t)return 0;let a=0;return t.endsWith("==")?a=2:t.endsWith("=")&&(a=1),Math.floor(t.length*3/4)-a}function $(e,t){const a=e&&typeof e=="object"?e:{},l=a.share??a.deliverable??{},s=m=>a[m]??l[m],i=s("id")??s("shareId")??"",c=s("slug"),o=c!=null?String(c):void 0,d=s("url")??s("shareUrl");let b=null;d!=null?b=String(d):o&&t&&(b=`${t.replace(/\/+$/,"")}/deliverable/${encodeURIComponent(o)}`);const f=s("reason")??s("rejectNote"),p=s("localDeliverableId")??s("localId");return{id:String(i),slug:o,visibility:s("visibility")??"public",status:s("status")??"pending_review",url:b,reason:f!=null?String(f):null,localId:p!=null?String(p):null}}class xe{basePath;fetchImpl;hubOrigin;constructor(t){this.getHubToken=t.getHubToken,this.hubOrigin=t.hubUrl,this.basePath=(t.proxyBasePath??"/api/hub").replace(/\/+$/,""),this.fetchImpl=t.fetch??(globalThis.fetch?globalThis.fetch.bind(globalThis):(()=>{throw new Error("fetch unavailable")}))}getHubToken;isHubLoggedIn(){return!!this.getHubToken()}assertHubLoggedIn(){if(!this.getHubToken())throw new Q}async doFetch(t,a){const l=this.getHubToken(),s={"Content-Type":"application/json",...a.headers};l&&(s.Authorization=`Bearer ${l}`);const i=await this.fetchImpl(`${this.basePath}${t}`,{...a,headers:s,credentials:"include"});let c=null;try{c=await i.json()}catch{c=null}if(!i.ok){const o=c&&typeof c=="object"&&"error"in c?String(c.error):i.statusText||`HTTP ${i.status}`;throw new me(i.status,o)}return{status:i.status,data:c}}async publish(t){this.assertHubLoggedIn();const a=t.fileSizeBytes??(t.fileBase64?ge(t.fileBase64):0);if(a>G)throw new pe(a,G);const l={localDeliverableId:t.localId,visibility:t.visibility,title:t.title,summary:t.summary,tags:t.tags,filename:t.filename,format:t.format,producerAgent:{id:t.producerAgent.id,name:t.producerAgent.name,source:t.producerAgent.source}};t.content&&(l.content=t.content),t.fileBase64&&(l.fileBase64=t.fileBase64);const{data:s}=await this.doFetch("/deliverables/publish",{method:"POST",body:JSON.stringify(l)});return $(s,this.hubOrigin)}async pollStatus(t){this.assertHubLoggedIn();const{data:a}=await this.doFetch(`/deliverables/status?localId=${encodeURIComponent(t)}`,{method:"GET"});return $(a,this.hubOrigin)}async listMine(){this.assertHubLoggedIn();const{data:t}=await this.doFetch("/deliverables/mine",{method:"GET"}),a=t&&typeof t=="object"?t:{};return(Array.isArray(a.shares)?a.shares:[]).map(s=>$(s,this.hubOrigin))}async revoke(t){this.assertHubLoggedIn();const{data:a}=await this.doFetch("/deliverables/revoke",{method:"POST",body:JSON.stringify({localId:t})});return{...$(a,this.hubOrigin),status:"revoked",url:null}}}function ye(e,t){return new xe({getHubToken:e,hubUrl:t,proxyBasePath:"/api/hub"})}const ve=/\.(png|jpe?g|gif|webp|svg|bmp|avif|ico)$/i,ke=/\.(mp4|webm|mp3|wav|ogg|m4a|mov|avi|mkv|flac)$/i;function X(e){return ve.test(e)?"image":ke.test(e)?"media":"other"}function we(e){return e.replace(/^file:\/\//i,"").replace(/^file:/i,"")}function J(e){const t=e.match(/!?\[[^\]]*\]\(([^)]+)\)/);if(t)return t[1].trim().split(/\s+(?="|')/)[0].trim()||null;const a=e.match(/(?:src|href|poster)\s*=\s*["']([^"']+)["']/i);return a?a[1]:null}function Z(e){return!e||/^(https?:|data:|mailto:|tel:|#)/i.test(e)||e.startsWith("//")?!1:(e.startsWith("/api/files/"),!0)}function Y(e,t){if(!e)return null;const a=e.trim(),l=a.match(/^\/api\/files\/(?:image|stream|preview)\?path=([^&]+)/i);if(l)try{return decodeURIComponent(l[1])||null}catch{return l[1]||null}return/^file:\/\//i.test(a)?we(a).replace(/\\/g,"/"):/^[a-zA-Z]:[\\/]/.test(a)?a.replace(/\\/g,"/"):a.startsWith("/")?a:t&&(a.startsWith("./")||a.startsWith("../")||!a.includes("://"))?`${t.replace(/\\/g,"/").replace(/\/+$/,"")}/${a.replace(/^\.\//,"").replace(/\\/g,"/")}`:null}function je(e,t){const a=[],l=new Set,s=/!?\[[^\]]*\]\(([^)\s]+(?:\s+["'][^"']*["'])?)\)/g;for(const c of e.matchAll(s)){const o=c[0],d=J(o);if(!d||!Z(d))continue;const b=Y(d,t);!b||l.has(o)||(l.add(o),a.push({raw:o,localPath:b,kind:X(b.split("?")[0])}))}const i=/<[a-zA-Z][^>]*(?:src|href|poster)\s*=\s*["'][^"']+["'][^>]*>/gi;for(const c of e.matchAll(i)){const o=c[0],d=J(o);if(!d||!Z(d))continue;const b=Y(d,t);!b||l.has(o)||(l.add(o),a.push({raw:o,localPath:b,kind:X(b.split("?")[0])}))}return{refs:a,baseDir:t??""}}function Ne(e,t){let a=e;for(const[l,s]of t){const i=Se(l,s);a=a.split(l).join(i)}return a}function Se(e,t){const a=e.match(/^(!?\[[^\]]*\])\([^)]*\)$/);if(a)return`${a[1]}(${t})`;const l=e.match(/(src|href|poster)(\s*=\s*)(["'])[^"']*\3/i);return l?e.replace(/(src|href|poster)(\s*=\s*)(["'])[^"']*\3/i,`${l[1]}${l[2]}${l[3]}${t}${l[3]}`):t}function He(e,t){return/^https?:\/\//i.test(e)?e:`${t.replace(/\/+$/,"")}${e.startsWith("/")?"":"/"}${e}`}function Ve(e,t,a){const l=new Map,s=new Map(e.map(i=>[i.localPath,i]));for(const i of t){if(!i.key)continue;const c=s.get(i.key);!c||!i.url||l.set(c.raw,He(i.url,a))}return l}async function Ie(e){try{const t=N.files.streamUrl(e),a=await fetch(t).then(d=>d.ok?d.blob():null);if(!a)return null;const l=await a.arrayBuffer(),s=new Uint8Array(l);let i="";const c=32768;for(let d=0;d<s.length;d+=c)i+=String.fromCharCode.apply(null,Array.from(s.subarray(d,d+c)));const o=e.split("/").pop()||"media";return{base64:btoa(i),filename:o}}catch{return null}}async function Te(e,t){const a=new Map;if(e.length===0)return a;const l=[];for(const c of e){const o=await Ie(c.localPath);o&&l.push({key:c.localPath,filename:o.filename,base64:o.base64})}if(l.length===0)return a;const{files:s,errors:i}=await R.uploadMediaBatch(l);return i.length>0&&console.warn("[deliverable-share] media upload errors:",i),Ve(e,s,t)}async function Ce(e,t,a){if(!e||t==="directory"||e.startsWith("http://")||e.startsWith("https://"))return{};try{const l=await N.files.preview(e);if((l.type==="text"||l.type==="markdown"||l.type==="html"||l.type==="json"||l.type==="csv")&&typeof l.content=="string"){if(!(l.type==="markdown"||l.type==="html"))return{content:l.content};const i=e.replace(/[/\\]/g,"/").split("/").slice(0,-1).join("/"),{refs:c}=je(l.content,i);if(c.length===0)return{content:l.content};const o=await Te(c,a);return o.size===0?{content:l.content}:{content:Ne(l.content,o),uploadedMedia:o.size}}if(l.type==="image"||l.type==="audio"||l.type==="video"||l.type==="binary"){const s=l.streamUrl||(l.path?N.files.streamUrl(l.path):N.files.streamUrl(e)),c=await(await fetch(s).then(f=>f.blob())).arrayBuffer(),o=new Uint8Array(c);let d="";const b=32768;for(let f=0;f<o.length;f+=b)d+=String.fromCharCode.apply(null,Array.from(o.subarray(f,f+b)));return{fileBase64:btoa(d)}}return{}}catch{return{}}}function Ee({item:e,onClose:t,onShared:a,service:l}){const{t:s}=de(["deliverables","common"]),i=u.useMemo(()=>l??ye(ue,R.getUrl()),[l]),[c,o]=u.useState(()=>i?i.isHubLoggedIn():null),[d,b]=u.useState(!1),[f,p]=u.useState(()=>{const n=e.shareStatus;return n==="published"?"published":n==="pending_review"?"pending_review":n==="rejected"?"rejected":"form"}),[m,M]=u.useState("public"),[H,ee]=u.useState(e.title||""),[E,te]=u.useState(e.summary||""),[x,L]=u.useState(Array.isArray(e.tags)?[...e.tags]:[]),[k,P]=u.useState(""),[A,re]=u.useState(null),[V,U]=u.useState(!1),[I,g]=u.useState(null),F=u.useRef(a);F.current=a;const y=u.useCallback(n=>{re(n);const h=n.status;p(h==="published"?"published":h==="rejected"?"rejected":h==="revoked"?"revoked":h==="pending_review"?"pending_review":"form"),F.current?.(n)},[]);u.useEffect(()=>{o(i.isHubLoggedIn())},[i]);const se=u.useCallback(async()=>{b(!0),g(null);try{await fe({force:!0}),o(i.isHubLoggedIn())}catch{o(i.isHubLoggedIn())}finally{b(!1)}},[i]),B=u.useCallback(()=>{const n=k.trim().replace(/^#/,"");n&&!x.includes(n)&&L(h=>[...h,n]),P("")},[k,x]),ae=u.useCallback(n=>{L(h=>h.filter(v=>v!==n))},[]),le=u.useCallback(n=>{n.key==="Enter"||n.key===","?(n.preventDefault(),B()):n.key==="Backspace"&&!k&&x.length&&L(h=>h.slice(0,-1))},[B,k,x.length]),D=u.useCallback(()=>{const n=A?.url??e.shareUrl;n&&navigator.clipboard?.writeText(n).then(()=>{U(!0),setTimeout(()=>U(!1),1500)}).catch(()=>{})},[A,e.shareUrl]),ne=u.useCallback(async()=>{if(!he(e.format)){g(`分享仅支持 ${[...q].join(" / ")} 格式`);return}g(null),p("busy");try{const n=e.reference.replace(/[/\\]/g,"/").split("/").pop()||"deliverable",h=R.getUrl(),{content:v,fileBase64:ie,uploadedMedia:z}=await Ce(e.reference,e.type,h);z&&console.info(`[deliverable-share] uploaded ${z} local media reference(s) to Hub`);const w=e.agentId??"";let O=w;if(w)try{const{agents:oe}=await N.agents.list(),K=oe.find(ce=>ce.id===w);K&&(O=K.name||w)}catch{}const j=await i.publish({localId:e.id,title:H.trim()||e.title,summary:E.trim(),tags:x,visibility:m,filename:n,format:e.format||"markdown",content:v,fileBase64:ie,producerAgent:{id:w,name:O,source:"local"}});y(j),j.status==="rejected"?g(typeof j.reason=="string"&&j.reason?j.reason:"分享被拒绝"):t()}catch(n){if(p("form"),n instanceof Q){o(!1);return}g(n instanceof S||n instanceof Error?n.message:String(n))}},[i,e,H,E,x,m,y]),_=u.useCallback(async()=>{g(null);try{const n=await i.revoke(e.id);y({...n,status:"revoked",url:null})}catch(n){g(n instanceof S?n.message:String(n))}},[i,e.id,y]),W=u.useCallback(()=>{p("form"),g(null)},[]);u.useEffect(()=>{if(f!=="pending_review")return;let n=!1;const h=setInterval(async()=>{try{const v=await i.pollStatus(e.id);if(n)return;v.status!=="pending_review"&&y(v)}catch{}},8e3);return()=>{n=!0,clearInterval(h)}},[f,i,e.id,y]),u.useEffect(()=>{const n=h=>{h.key==="Escape"&&t()};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[t]);const T=m==="link",C=A?.url??e.shareUrl;return r.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:t,children:[r.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm"}),r.jsxs("div",{className:"relative bg-surface-primary rounded-2xl shadow-2xl border border-border-default w-full max-w-md max-h-[85vh] overflow-y-auto",onClick:n=>n.stopPropagation(),children:[r.jsxs("div",{className:"sticky top-0 bg-surface-primary/95 backdrop-blur-sm border-b border-border-default px-5 py-4 flex items-center justify-between rounded-t-2xl z-10",children:[r.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:s("deliverables:share.title",{defaultValue:"分享到 Markus Hub"})}),r.jsx("button",{onClick:t,className:"p-1.5 rounded-lg hover:bg-surface-overlay transition-colors text-fg-tertiary hover:text-fg-primary",children:r.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),r.jsx("div",{className:"px-5 py-4 space-y-4",children:c===!1?r.jsxs("div",{className:"space-y-4 py-2",children:[r.jsxs("div",{className:"flex items-start gap-3 rounded-xl bg-amber-500/10 border border-amber-500/25 p-3",children:[r.jsx("span",{className:"text-lg",children:"🔑"}),r.jsx("p",{className:"text-sm text-fg-secondary",children:s("deliverables:share.needHubLogin",{defaultValue:"需登录 Markus Hub 账号后才能分享产出物。"})})]}),r.jsx("button",{onClick:()=>{se()},disabled:d,className:"w-full px-3 py-2 text-sm font-medium rounded-lg bg-brand-600 text-white hover:bg-brand-500 transition-colors disabled:opacity-60",children:d?s("deliverables:share.loggingIn",{defaultValue:"正在打开登录…"}):s("deliverables:share.loginHub",{defaultValue:"登录 Markus Hub 账号"})}),r.jsx("p",{className:"text-[11px] text-fg-tertiary",children:s("deliverables:share.loginHint",{defaultValue:"解锁后将支持一键公开/链接分享产出物。"})})]}):r.jsx(r.Fragment,{children:f==="published"?r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"px-2 py-0.5 text-[11px] rounded-full bg-green-500/15 text-green-500 font-medium",children:s("deliverables:share.published",{defaultValue:"已发布"})}),r.jsx("span",{className:"text-[11px] text-fg-tertiary",children:m==="link"?s("deliverables:share.linkVisibility",{defaultValue:"有链接可见"}):s("deliverables:share.publicVisibility",{defaultValue:"公开"})})]}),C?r.jsxs("div",{className:"flex items-center gap-2 bg-surface-elevated rounded-lg px-3 py-2",children:[r.jsx("span",{className:"text-xs text-fg-secondary font-mono break-all flex-1 select-all",children:C}),r.jsx("button",{onClick:D,className:`px-2 py-1 text-[10px] rounded transition-colors shrink-0 ${V?"bg-green-500/20 text-green-500":"bg-brand-600/20 text-brand-500 hover:bg-brand-600/30"}`,children:V?s("common:copied",{defaultValue:"已复制"}):s("common:copy",{defaultValue:"复制链接"})})]}):r.jsx("p",{className:"text-xs text-fg-tertiary",children:s("deliverables:share.urlPending",{defaultValue:"链接生成中,稍后刷新查看…"})}),r.jsx("button",{onClick:()=>{_()},className:"w-full px-3 py-2 text-xs font-medium rounded-lg text-red-500 border border-red-500/30 hover:bg-red-500/10 transition-colors",children:s("deliverables:share.revoke",{defaultValue:"取消分享"})})]}):f==="pending_review"?r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-amber-500 animate-pulse"}),r.jsx("span",{className:"px-2 py-0.5 text-[11px] rounded-full bg-amber-500/15 text-amber-500 font-medium",children:s("deliverables:share.pendingReview",{defaultValue:"审核中"})}),r.jsx("span",{className:"text-[11px] text-fg-tertiary",children:m==="link"?s("deliverables:share.linkVisibility",{defaultValue:"有链接可见"}):s("deliverables:share.publicVisibility",{defaultValue:"公开"})})]}),r.jsx("p",{className:"text-sm text-fg-secondary",children:s("deliverables:share.pendingHint",{defaultValue:"你的产出物已公开,其他人现在就能通过链接访问。管理员审核通过后,内容将进入搜索引擎收录。"})}),C?r.jsxs("div",{className:"flex items-center gap-2 bg-surface-elevated rounded-lg px-3 py-2",children:[r.jsx("span",{className:"text-xs text-fg-secondary font-mono break-all flex-1 select-all",children:C}),r.jsx("button",{onClick:D,className:`px-2 py-1 text-[10px] rounded transition-colors shrink-0 ${V?"bg-green-500/20 text-green-500":"bg-brand-600/20 text-brand-500 hover:bg-brand-600/30"}`,children:V?s("common:copied",{defaultValue:"已复制"}):s("common:copy",{defaultValue:"复制链接"})})]}):null,r.jsx("button",{onClick:()=>{_()},className:"w-full px-3 py-2 text-xs font-medium rounded-lg text-red-500 border border-red-500/30 hover:bg-red-500/10 transition-colors",children:s("deliverables:share.revoke",{defaultValue:"取消分享"})})]}):f==="rejected"?r.jsxs("div",{className:"space-y-3",children:[r.jsx("div",{className:"flex items-center gap-2",children:r.jsx("span",{className:"px-2 py-0.5 text-[11px] rounded-full bg-red-500/15 text-red-500 font-medium",children:s("deliverables:share.rejected",{defaultValue:"已拒绝"})})}),I&&r.jsx("div",{className:"rounded-lg bg-red-500/10 border border-red-500/25 px-3 py-2 text-xs text-red-500",children:I}),r.jsx("button",{onClick:W,className:"w-full px-3 py-2 text-sm font-medium rounded-lg bg-brand-600 text-white hover:bg-brand-500 transition-colors",children:s("deliverables:share.resubmit",{defaultValue:"重新提交"})})]}):f==="revoked"?r.jsxs("div",{className:"space-y-3",children:[r.jsx("p",{className:"text-sm text-fg-secondary",children:s("deliverables:share.revoked",{defaultValue:"已取消分享,该产出物不再公开可访问。"})}),r.jsx("button",{onClick:W,className:"w-full px-3 py-2 text-sm font-medium rounded-lg bg-brand-600 text-white hover:bg-brand-500 transition-colors",children:s("deliverables:share.shareAgain",{defaultValue:"重新分享"})})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:s("deliverables:share.visibility",{defaultValue:"可见性"})}),r.jsxs("label",{className:`flex items-start gap-3 rounded-xl border p-3 cursor-pointer transition-colors ${T?"border-border-default hover:bg-surface-elevated":"border-brand-500/50 bg-brand-500/5"}`,children:[r.jsx("input",{type:"radio",name:"visibility",checked:!T,onChange:()=>M("public"),className:"mt-0.5 accent-brand-500"}),r.jsxs("span",{className:"space-y-0.5",children:[r.jsx("span",{className:"block text-sm font-medium text-fg-primary",children:s("deliverables:share.public",{defaultValue:"公开(所有人可见 + 搜索引擎)"})}),r.jsx("span",{className:"block text-[11px] text-fg-tertiary",children:s("deliverables:share.publicHint",{defaultValue:"公开产出物需经 Hub 审核后发布,发布后所有人可见并参与搜索"})})]})]}),r.jsxs("label",{className:`flex items-start gap-3 rounded-xl border p-3 cursor-pointer transition-colors ${T?"border-brand-500/50 bg-brand-500/5":"border-border-default hover:bg-surface-elevated"}`,children:[r.jsx("input",{type:"radio",name:"visibility",checked:T,onChange:()=>M("link"),className:"mt-0.5 accent-brand-500"}),r.jsxs("span",{className:"space-y-0.5",children:[r.jsx("span",{className:"block text-sm font-medium text-fg-primary",children:s("deliverables:share.link",{defaultValue:"有链接可见"})}),r.jsx("span",{className:"block text-[11px] text-fg-tertiary",children:s("deliverables:share.linkHint",{defaultValue:"仅获得链接的人可查看,不参与搜索引擎;同样需经 Hub 审核"})})]})]})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:s("deliverables:share.titleField",{defaultValue:"标题"})}),r.jsx("input",{value:H,onChange:n=>ee(n.target.value),placeholder:s("deliverables:share.titlePlaceholder",{defaultValue:"清晰、可检索的标题"}),className:"w-full px-3 py-2 text-sm rounded-lg bg-surface-elevated border border-border-default focus:border-brand-500/60 outline-none"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:s("deliverables:share.summary",{defaultValue:"摘要"})}),r.jsx("textarea",{value:E,onChange:n=>te(n.target.value),rows:3,placeholder:s("deliverables:share.summaryPlaceholder",{defaultValue:"简要描述该产出物…"}),className:"w-full px-3 py-2 text-sm rounded-lg bg-surface-elevated border border-border-default focus:border-brand-500/60 outline-none resize-y"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:s("deliverables:share.tags",{defaultValue:"标签"})}),r.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1.5",children:x.map(n=>r.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-[11px] bg-surface-elevated rounded-md text-fg-secondary",children:[n,r.jsx("button",{onClick:()=>ae(n),className:"text-fg-tertiary hover:text-red-500","aria-label":"remove",children:r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},n))}),r.jsx("input",{value:k,onChange:n=>P(n.target.value),onKeyDown:le,onBlur:B,placeholder:s("deliverables:share.tagsPlaceholder",{defaultValue:"输入标签后回车添加"}),className:"w-full px-3 py-2 text-sm rounded-lg bg-surface-elevated border border-border-default focus:border-brand-500/60 outline-none"})]}),I&&r.jsx("div",{className:"rounded-lg bg-red-500/10 border border-red-500/25 px-3 py-2 text-xs text-red-500",children:I}),r.jsxs("button",{type:"button",onClick:()=>{ne()},disabled:f==="busy"||!H.trim(),className:"w-full px-3 py-2.5 text-sm font-medium rounded-lg bg-brand-600 text-white hover:bg-brand-500 transition-colors disabled:opacity-60 flex items-center justify-center gap-2",children:[f==="busy"&&r.jsxs("svg",{className:"animate-spin",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",opacity:"0.25"}),r.jsx("path",{d:"M22 12a10 10 0 0 0-10-10",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]}),f==="busy"?s("deliverables:share.sharing",{defaultValue:"分享中…"}):s("deliverables:share.shareToHub",{defaultValue:"分享到 Hub"})]})]})})})]})]})}export{Ee as D,he as a,ye as c};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{u as Je,j as e,r as a,a as Es,b as Ps,m as Ts,d as Bs,c as As,l as m,w as Nt,o as ls,p as Ms,P as B,n as se,M as $s,q as St,D as Ds,O as Vs,h as Fs,i as is,s as Hs}from"./index-D8vskks7.js";import{resolveFormat as Ws,ContentRenderer as _s}from"./ContentRenderer-CjHOyYgJ.js";import{c as Us,a as Os,D as Ks}from"./DeliverableShareModal-CBSvxB-X.js";function $(d){return Array.isArray(d)?d.map(o=>String(o).trim()).filter(Boolean):typeof d=="string"&&d?d.split(",").map(o=>o.trim()).filter(Boolean):[]}function zs(d){return d.files&&typeof d.files=="object"&&!Array.isArray(d.files)?d.files:null}function re({label:d,value:o}){return o?e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:d}),e.jsx("div",{className:"text-xs text-fg-secondary mt-0.5",children:o})]}):null}function he({label:d,value:o,color:c}){if(!o)return null;const s={purple:"bg-brand-500/15 text-brand-500",cyan:"bg-blue-500/15 text-blue-600",indigo:"bg-brand-500/15 text-brand-500",gray:"bg-gray-500/15 text-fg-secondary",emerald:"bg-green-500/15 text-green-600"};return e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:d}),e.jsx("div",{className:`mt-0.5 px-2 py-0.5 rounded-full text-[10px] font-medium ${s[c]??s.gray} capitalize inline-block`,children:o})]})}function Ct({files:d}){const{t:o}=Je(["builder","common"]),[c,s]=a.useState(Object.keys(d)[0]??""),u=Object.keys(d);return u.length===0?null:e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:o("builder:artifact.files",{count:u.length})}),e.jsxs("div",{className:"mt-1 bg-surface-elevated/50 rounded-lg border border-border-default/30 overflow-hidden",children:[e.jsx("div",{className:"flex gap-0.5 px-1.5 py-1 border-b border-border-default/30 overflow-x-auto",children:u.map(v=>e.jsx("button",{onClick:()=>s(v),className:`px-2 py-0.5 text-[10px] rounded whitespace-nowrap transition-colors ${c===v?"bg-brand-600/30 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:v},v))}),c&&d[c]!=null&&e.jsx("pre",{className:"p-2 text-[10px] text-fg-secondary max-h-[120px] overflow-auto whitespace-pre-wrap font-mono",children:d[c]})]})]})}function Gs({artifact:d,mode:o}){const{t:c}=Je(["builder","common"]),s=zs(d),u=d.agent,v=d.team,S=d.dependencies,N=d.displayName??d.name;if(o==="agent"){const j=u?.roleName,E=u?.agentRole,w=u?.llmProvider,L=u?.llmModel,g=$(S?.env),R=$(S?.skills);return e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsx(re,{label:c("builder:artifact.name"),value:N}),e.jsx(re,{label:c("builder:artifact.description"),value:d.description}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[j&&e.jsx(he,{label:c("builder:artifact.baseTemplate"),value:j,color:"indigo"}),e.jsx(he,{label:c("builder:artifact.agentRole"),value:E,color:E==="manager"?"purple":"cyan"})]}),$(d.tags).length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:$(d.tags).map(k=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:k},k))}),(w||L)&&e.jsxs("div",{className:"flex gap-2",children:[w&&e.jsx(he,{label:c("builder:artifact.llmProvider"),value:w,color:"gray"}),L&&e.jsx(he,{label:c("builder:artifact.llmModel"),value:L,color:"gray"})]}),g.length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:c("builder:artifact.requiredEnv")}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:g.map(k=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-amber-500/10 text-amber-600 rounded font-mono",children:k},k))})]}),R.length>0&&e.jsx(re,{label:c("builder:artifact.skills"),value:R.join(", ")}),s&&e.jsx(Ct,{files:s})]})}if(o==="team"){const E=v?.members??[];return e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsx(re,{label:c("builder:artifact.name"),value:N}),e.jsx(re,{label:c("builder:artifact.description"),value:d.description}),e.jsx("div",{className:"flex flex-wrap gap-2",children:e.jsx(he,{label:c("builder:artifact.category"),value:d.category,color:"indigo"})}),$(d.tags).length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:$(d.tags).map(w=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:w},w))}),s&&e.jsx(Ct,{files:s}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:c("builder:artifact.members",{count:E.length})}),e.jsx("div",{className:"mt-1.5 space-y-1.5",children:E.map((w,L)=>e.jsxs("div",{className:"bg-surface-elevated/30 rounded-lg px-2 py-1.5 border border-border-default/20",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`w-5 h-5 rounded flex items-center justify-center text-[10px] font-bold ${w.role==="manager"?"bg-brand-500/20 text-brand-500":"bg-blue-500/20 text-blue-600"}`,children:w.role==="manager"?"★":L+1}),e.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:w.name}),typeof w.roleName=="string"&&w.roleName&&e.jsx("span",{className:"text-[10px] text-brand-500/70 font-mono",children:w.roleName}),e.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["x",String(w.count??1)]})]}),$(w.skills).length>0&&e.jsx("div",{className:"mt-1 ml-7 flex flex-wrap gap-1",children:$(w.skills).map(g=>e.jsx("span",{className:"px-1 py-0.5 text-[9px] bg-green-500/10 text-green-600 rounded font-mono",children:g},g))})]},L))})]})]})}return e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsx(re,{label:c("builder:artifact.name"),value:N}),e.jsx(re,{label:c("builder:artifact.description"),value:d.description}),e.jsx("div",{className:"flex gap-2",children:e.jsx(he,{label:c("builder:artifact.category"),value:d.category,color:"indigo"})}),s&&e.jsx(Ct,{files:s}),$(d.tags).length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:$(d.tags).map(j=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:j},j))})]})}const me={file:{icon:"📄",color:"bg-green-500/10 text-green-600"},directory:{icon:"📁",color:"bg-blue-500/10 text-blue-600"}},qs=["file","directory"];function Qe(d){return/^https?:\/\//i.test(d)}function I(d){return d?.shareStatus??null}function Ys(d,o){const c=Date.now(),s=new Date(d).getTime(),u=c-s,v=Math.floor(u/6e4);if(v<1)return o("time.justNow");if(v<60)return o("time.minutesAgo",{count:v});const S=Math.floor(v/60);if(S<24)return o("time.hoursAgo",{count:S});const N=Math.floor(S/24);if(N===1)return o("time.yesterday");if(N<30)return o("time.daysAgo",{count:N});const j=Math.floor(N/30);return j<12?o("time.monthsAgo",{count:j}):o("time.yearsAgo",{count:Math.floor(j/12)})}const z={agent:{icon:"✦",color:"bg-brand-500/10 text-brand-500"},team:{icon:"◈",color:"bg-blue-500/10 text-blue-600"},skill:{icon:"⬡",color:"bg-amber-500/10 text-amber-600"}};function er({authUser:d,previewMode:o,previewData:c}={}){const{t:s}=Je(["deliverables","common"]),u=Es(),v=Ps(B.DELIVERABLES),S=Ts({side:"left",defaultWidth:384,minWidth:280,maxWidth:600,storageKey:"markus_deliverables_list"}),[N,j]=a.useState(!1),E=a.useRef(N);E.current=N,a.useEffect(()=>{if(!u)return;const t=()=>{E.current&&j(!1)};return window.addEventListener("popstate",t),()=>window.removeEventListener("popstate",t)},[u]);const w=100,L=5e3,[g,R]=a.useState(c?.items??[]),[k,D]=a.useState(c?.items?.length??0),[p,ne]=a.useState(!1),[Xe,It]=a.useState(c?.projects??[]),[Lt,Rt]=a.useState(c?.agents??[]),[Et,cs]=a.useState([]),[G,Pt]=a.useState(!c),[Te,Be]=a.useState(""),[ge,Ae]=a.useState(""),[V,be]=a.useState(""),[F,ye]=a.useState(""),[H,W]=a.useState(""),[ae,Me]=a.useState(""),[ds,Ze]=a.useState(!1),[A,Tt]=a.useState("date"),[n,P]=a.useState(()=>c?.initialSelectedId&&c.items?c.items.find(t=>t.id===c.initialSelectedId)??c.items[0]??null:c?.items?.[0]??null),[et,Bt]=a.useState(null),[At,Mt]=a.useState(""),[q,us]=a.useState(!0),[tt,ve]=a.useState(()=>{const t=new Date,r=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`;return new Set([r])}),[st,xs]=a.useState(!1),[rt,$t]=a.useState(!1),fs=a.useMemo(()=>[{id:"date"},{id:"project"},{id:"team"},{id:"agent"}],[]),hs=a.useCallback(t=>{Tt(t)},[]),Dt=Bs(fs,A,hs),Y=a.useRef(null),[$e,le]=a.useState(null),[De,Vt]=a.useState("markdown"),[je,nt]=a.useState(null),[we,at]=a.useState(null),[ie,lt]=a.useState(null),[Q,ke]=a.useState(null),[it,oe]=a.useState(!1),[Ft,J]=a.useState(!1),[Ne,Ht]=a.useState(!1),[Wt,Ve]=a.useState(null),[ot,Fe]=a.useState(null),[ct,He]=a.useState(null),[ms,dt]=a.useState(!1),[ut,ps]=a.useState(""),[_t,gs]=a.useState(new Set),Ut=ie&&n?.type==="file",We=Ut||!!Q&&n?.type==="directory",[_,X]=a.useState(!1),M=As(),ce=M?.keyboardPane??"content",[Se,de]=a.useState(null),[ue,Z]=a.useState(!1),[Ce,xt]=a.useState(""),[U,ee]=a.useState(!1),[ft,Ot]=a.useState(!1),[ht,te]=a.useState(null),mt=a.useRef(null),Kt=a.useCallback(t=>{t&&(t.style.height="auto",t.style.height=t.scrollHeight+"px")},[]),zt=a.useRef(void 0);a.useEffect(()=>{Kt(mt.current)},[Ce,ue,Kt]);const T=(t,r)=>{Bt({type:t,text:r}),setTimeout(()=>Bt(null),3e3)},_e=async t=>{await Hs(t)?(Ht(!0),setTimeout(()=>Ht(!1),1500)):T("error",s("detail.copyFailed"))},Ue=a.useMemo(()=>new Map(Lt.map(t=>[t.id,t])),[Lt]),pt=a.useMemo(()=>new Map(Xe.map(t=>[t.id,t])),[Xe]),Gt=a.useMemo(()=>new Map(Et.map(t=>[t.id,t])),[Et]),Ie=a.useCallback(t=>{if(!t||t==="default")return null;const r=pt.get(t)?.name;return!r||r==="default"?null:r},[pt]);a.useEffect(()=>{o||(m.projects.list().then(t=>It(t.projects)).catch(()=>{}),m.agents.list().then(t=>Rt(t.agents??[])).catch(()=>{}),m.teams.list().then(t=>cs(t.teams??[])).catch(()=>{}),m.system.storage().then(t=>ps(t.dataDir+"/shared")).catch(()=>{}),m.deliverables.checkHealth().then(t=>gs(new Set(t.missingFiles))).catch(()=>{}))},[o]),a.useEffect(()=>(zt.current=setTimeout(()=>Ae(Te),300),()=>clearTimeout(zt.current)),[Te]);const xe=a.useMemo(()=>({q:ge||void 0,projectId:ae||void 0,type:V||void 0,artifactType:F||void 0,source:H||void 0}),[ge,V,F,ae,H]),fe=A==="date"?w:L,gt=a.useCallback((t,r)=>r?{...r,hubShareId:r.hubShareId!=null?r.hubShareId:t.hubShareId??null,shareStatus:r.shareStatus!=null?r.shareStatus:t.shareStatus??null,shareUrl:r.shareUrl!=null?r.shareUrl:t.shareUrl??null,shareVisibility:r.shareVisibility!=null?r.shareVisibility:t.shareVisibility??null,shareReason:r.shareReason!=null?r.shareReason:t.shareReason}:t,[]),Oe=a.useCallback(async()=>{try{const{results:t,total:r}=await m.deliverables.search({...xe,offset:0,limit:fe});R(i=>i.map(l=>{const f=t.find(x=>x.id===l.id);return f?gt(l,f):l})),D(r),P(i=>{if(!i)return null;const l=t.find(f=>f.id===i.id);return l?gt(i,l):i})}catch{}},[xe,fe,gt]),O=a.useCallback(async()=>{Pt(!0),Y.current?.scrollTo({top:0,behavior:"instant"});try{const{results:t,total:r}=await m.deliverables.search({...xe,offset:0,limit:fe});R(t),D(r),P(i=>i&&t.some(l=>l.id===i.id)?i:null)}catch{R([]),D(0),P(null)}Pt(!1)},[xe,fe]),Ke=a.useCallback(async()=>{if(!(p||g.length>=k)){ne(!0);try{const{results:t,total:r}=await m.deliverables.search({...xe,offset:g.length,limit:fe});R(i=>[...i,...t]),D(r)}catch{}ne(!1)}},[xe,fe,g.length,k,p]);a.useEffect(()=>{o||O()},[O,o]),a.useEffect(()=>{!o||!c||(R(c.items??[]),D(c.items?.length??0),It(c.projects??[]),Rt(c.agents??[]),c.initialSelectedId&&P(c.items?.find(t=>t.id===c.initialSelectedId)??c.items?.[0]??null))},[o,c]);const bt=a.useRef(n);bt.current=n,a.useEffect(()=>{if(o||!v)return;const t=Nt.on("deliverable:created",()=>O()),r=Nt.on("deliverable:updated",l=>{Oe();const f=l.payload?.deliverableId;f&&bt.current?.id===f&&m.deliverables.get(f).then(x=>{x.deliverable&&(P(h=>({...h??x.deliverable,...x.deliverable,hubShareId:h?.hubShareId??x.deliverable.hubShareId??null,shareStatus:h?.shareStatus??x.deliverable.shareStatus??null,shareUrl:h?.shareUrl??x.deliverable.shareUrl??null,shareVisibility:h?.shareVisibility??x.deliverable.shareVisibility??null,shareReason:h?.shareReason??x.deliverable.shareReason??null})),Qt(x.deliverable))}).catch(()=>{})}),i=Nt.on("deliverable:removed",()=>O());return()=>{t(),r(),i()}},[Oe,v,o]);const qt=a.useMemo(()=>Us(ls,Fs.getUrl()),[]);a.useEffect(()=>{if(o||!v||!ls())return;let t=!1;const r=async()=>{try{const l=await qt.listMine();if(t)return;const f=new Map,x=new Map;for(const b of l)b.id&&f.set(b.id,b),b.localId&&x.set(b.localId,b);const h=new Map;R(b=>b.map(y=>{const C=y.hubShareId&&f.get(y.hubShareId)||x.get(y.id);if(!C)return y;const Pe={hubShareId:y.hubShareId??C.id??null,shareStatus:C.status??null,shareUrl:C.url??null,shareVisibility:y.shareVisibility??C.visibility??null,...C.reason!=null?{shareReason:C.reason}:{}};return h.set(y.id,Pe),{...y,...Pe}})),P(b=>{if(!b)return b;const y=h.get(b.id);return y?{...b,...y}:b});for(const[b,y]of h)m.deliverables.update(b,y).catch(C=>{console.warn("[deliverables] Hub 分享状态本地持久化失败:",C)})}catch{}};r();const i=setInterval(r,3e4);return()=>{t=!0,clearInterval(i)}},[qt,v,o]);const ze=a.useRef(null),yt=a.useRef(g);yt.current=g;const Le=a.useCallback(t=>{const r=l=>{P(l),u&&(j(!0),history.pushState({mobileDetail:B.DELIVERABLES},"",window.location.hash))},i=yt.current.find(l=>l.id===t);if(i){r(i);return}m.deliverables.get(t).then(l=>{l.deliverable&&r(l.deliverable)}).catch(()=>{})},[u]);a.useEffect(()=>{if(o)return;const t=window.location.hash.slice(1).split("/"),r=Ms(t[0])===B.DELIVERABLES?t[1]:void 0,i=localStorage.getItem("markus_nav_projectId"),l=localStorage.getItem("markus_nav_source");i&&(localStorage.removeItem("markus_nav_projectId"),Me(i)),(l==="knowledge"||l==="agent")&&(localStorage.removeItem("markus_nav_source"),W(l));const f=localStorage.getItem("markus_nav_openDeliverable")||r;f&&(localStorage.removeItem("markus_nav_openDeliverable"),yt.current.length>0?Le(f):ze.current=f);const x=h=>{const y=h.detail?.params;y?.projectId&&Me(y.projectId),(y?.source==="knowledge"||y?.source==="agent")&&W(y.source),y?.openDeliverable&&(localStorage.removeItem("markus_nav_openDeliverable"),Le(y.openDeliverable))};return window.addEventListener("markus:navigate",x),()=>window.removeEventListener("markus:navigate",x)},[Le,o]),a.useEffect(()=>{const t=ze.current;!t||g.length===0||(ze.current=null,Le(t))},[g,Le]);const Yt=a.useCallback(()=>{const t=Y.current;!t||G||p||g.length>=k||t.scrollHeight<=t.clientHeight+100&&Ke()},[G,p,g.length,k,Ke]);a.useEffect(()=>{const t=Y.current;if(!t)return;const r=()=>{t.scrollTop+t.clientHeight>=t.scrollHeight-100&&Ke()};return t.addEventListener("scroll",r,{passive:!0}),()=>t.removeEventListener("scroll",r)},[Ke]),a.useEffect(()=>{Yt()},[Yt,q,tt]);const K=a.useMemo(()=>{const t=new Map;for(const i of g){let l,f;if(A==="project"){const x=Ie(i.projectId);l=x?i.projectId??"_none":"_none",f=x??s("noProject")}else if(A==="team"){const h=(i.agentId?Ue.get(i.agentId):void 0)?.teamId??"_none";l=h,f=h!=="_none"?Gt.get(h)?.name??h:s("noTeam")}else if(A==="agent")l=i.agentId??"_none",f=i.agentId?Ue.get(i.agentId)?.name??i.agentId:s("common:unknown");else{const x=new Date(i.updatedAt);l=`${x.getFullYear()}-${String(x.getMonth()+1).padStart(2,"0")}-${String(x.getDate()).padStart(2,"0")}`,f=l}t.has(l)||t.set(l,{label:f,items:[]}),t.get(l).items.push(i)}const r=[...t.entries()];return A==="date"?r.sort((i,l)=>l[0].localeCompare(i[0])):r.sort((i,l)=>i[1].label.localeCompare(l[1].label)),r},[g,A,pt,Ue,Gt,s]);a.useEffect(()=>{if(A==="date"&&q){const t=new Date,r=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`;ve(new Set([r]))}else ve(new Set)},[A]);const bs=async t=>{Mt("remove");try{await m.deliverables.remove(t.id),T("success",s("removed")),P(null),O()}catch(r){T("error",s("common:error",{message:String(r)}))}Mt("")},ys=a.useCallback(t=>{const r=bt.current,i=r?.id;if(!i)return;const l={hubShareId:t.id??null,shareStatus:t.status??null,shareUrl:t.url??null,shareVisibility:t.visibility??null,...t.reason!=null||t.status==="rejected"?{shareReason:t.reason??r?.shareReason??null}:{}},f={...l,shareStatus:l.shareStatus??r?.shareStatus??null};P(x=>x&&x.id===i?{...x,...f}:x),R(x=>x.map(h=>h.id===i?{...h,...f}:h)),(async()=>{try{await m.deliverables.update(i,l)}catch(x){console.warn("[deliverables] 分享状态本地回写失败,将由 Hub 轮询补偿:",x)}Oe()})()},[Oe]),vs=()=>{se.navigate(B.BUILDER)},Re=a.useCallback(async(t,r,i)=>{if(t.type==="directory"&&Array.isArray(t.entries))ke({path:t.path,name:t.name,entries:t.entries});else if(t.type==="image"&&t.mimeType){const l=t.streamUrl||(t.path?m.files.streamUrl(t.path):m.files.streamUrl(r));nt({src:l,name:t.name})}else if(t.type==="audio"||t.type==="video"){const l=t.streamUrl||(t.path?m.files.streamUrl(t.path):m.files.streamUrl(r));at({kind:t.type,src:l,name:t.name})}else if(t.type==="office"){const l=t.streamUrl||(t.path?m.files.streamUrl(t.path):m.files.streamUrl(r));lt({format:t.format||String(t.extension||"").replace(/^\./,"")||"pdf",streamUrl:l,name:t.name,size:t.size,reference:t.path||r})}else t.type==="binary"?J(!0):typeof t.content=="string"?(le(t.content),Vt(Ws({format:i,reference:r,content:t.content}))):J(!0)},[]),vt=a.useCallback(async t=>{oe(!0),le(null),nt(null),at(null),lt(null),J(!1),ke(null),Ve(null),Fe(null);try{const r=await m.files.preview(t);r.type==="directory"&&Array.isArray(r.entries)?ke({path:r.path,name:r.name,entries:r.entries}):await Re(r,t)}catch{J(!0)}oe(!1)},[Re]),js=a.useCallback(async(t,r)=>{oe(!0),Ve(r??null),Fe(t),ke(null);try{const i=await m.files.preview(t);await Re(i,t)}catch{le(null),J(!0)}oe(!1)},[Re]),Qt=async t=>{if(t.reference&&!Qe(t.reference)){if(t.type==="directory"){vt(t.reference);return}oe(!0);try{const r=await m.files.preview(t.reference);await Re(r,t.reference,t.format)}catch{le(null),t.type==="file"&&J(!0)}oe(!1)}};a.useEffect(()=>{o||(le(null),Vt("markdown"),nt(null),at(null),lt(null),ke(null),J(!1),Ve(null),Fe(null),n&&Qt(n))},[n?.id,o]);const Jt=a.useCallback(t=>q!==tt.has(t),[q,tt]),Xt=K.length>0&&K.every(([t])=>Jt(t)),ws=a.useCallback(t=>{ve(r=>{const i=new Set(r);return i.has(t)?i.delete(t):i.add(t),i})},[]),Zt=a.useCallback(t=>{ve(r=>{if(r.has(t)===q)return r;const i=new Set(r);return q?i.add(t):i.delete(t),i})},[q]),ks=a.useCallback(()=>{us(t=>!t),ve(new Set)},[]),Ge=!!(V||F||H||ae||ge),es=a.useCallback(()=>{be(""),ye(""),W(""),Me(""),Be(""),Ae("")},[]),Ee=a.useMemo(()=>K.flatMap(([,t])=>t.items),[K]);a.useEffect(()=>{o||u||G||n||ze.current||Ee.length!==0&&P(Ee[0])},[o,u,G,n,Ee]);const jt=a.useRef(null);a.useEffect(()=>{if(!n){jt.current=null;return}if(jt.current===n.id)return;const t=K.find(([,r])=>r.items.some(i=>i.id===n.id));t&&(jt.current=n.id,Zt(t[0]))},[n?.id,K,Zt]);const ts=a.useRef(null),ss=a.useRef(null),qe=a.useRef(!1),rs=a.useRef(ce);a.useEffect(()=>{if(o||u||!v)return;const t=rs.current;rs.current=ce,!(ce!=="l1"||t==="l1")&&_&&(qe.current=!0,X(!1))},[ce,o,u,v,_]),a.useEffect(()=>{if(o||u||!v)return;const t=r=>{if(r.metaKey||r.ctrlKey){if(r.target instanceof HTMLInputElement||r.target instanceof HTMLTextAreaElement){r.key==="Escape"&&(r.target.blur(),r.preventDefault());return}if(is(r.target))return;if(r.key==="f"){r.preventDefault(),ts.current?.focus();return}if(r.key.toLowerCase()==="b"){r.preventDefault(),X(C=>{const Pe=!C;return Pe&&(qe.current=!0,M?.setKeyboardPane("l1"),requestAnimationFrame(()=>ss.current?.focus())),Pe});return}if(r.key.toLowerCase()==="l"){r.preventDefault(),kt();return}return r.altKey,void 0}if(M?.keyboardPane==="l0")return;if(r.target instanceof HTMLInputElement||r.target instanceof HTMLTextAreaElement){r.key==="Escape"&&(r.target.blur(),r.preventDefault());return}if(is(r.target)||r.metaKey||r.ctrlKey||r.altKey)return;const l=r.key.length===1?r.key.toLowerCase():r.key;if(l==="h"||l==="ArrowLeft"){r.preventDefault(),_&&X(!1),M?.setL0FocusPageId(B.DELIVERABLES),M?.setLeftCollapsed(!1),M?.setKeyboardPane("l0");return}if(l==="l"||l==="ArrowRight"){r.preventDefault(),_&&X(!1),M?.keyboardPane!=="l1"&&M?.setKeyboardPane("l1");return}const f=l==="j"||l==="ArrowDown"?1:l==="k"||l==="ArrowUp"?-1:0;if(!f)return;r.preventDefault(),M?.setKeyboardPane("l1"),_&&(qe.current=!0,X(!1));const x=Ee;if(x.length===0)return;const h=n?x.findIndex(C=>C.id===n.id):-1,b=h<0?f>0?-1:0:h,y=Math.max(0,Math.min(x.length-1,b+f));ns(x[y]),requestAnimationFrame(()=>{document.querySelector(`[data-deliverable-id="${x[y].id}"]`)?.scrollIntoView({block:"nearest"})})};return document.addEventListener("keydown",t,!0),()=>document.removeEventListener("keydown",t,!0)},[Ee,n,o,u,v,M,_]);const Ye=a.useRef(null),Ns=a.useCallback(t=>{if(!u)return;const r=Y.current;!r||r.scrollTop>0||(Ye.current={y:t.touches[0].clientY,scrollTop:r.scrollTop})},[u]),Ss=a.useCallback(t=>{if(!u||!Ye.current||rt)return;const r=t.changedTouches[0].clientY-Ye.current.y;Ye.current=null,r>80&&Y.current&&Y.current.scrollTop<=0&&($t(!0),O().finally(()=>$t(!1)))},[u,rt,O]),ns=t=>{const r=()=>{P(t),dt(!1),Z(!1),ee(!1),u&&(j(!0),history.pushState({mobileDetail:B.DELIVERABLES},"",window.location.hash))};U?te({action:r}):r()},Cs=()=>{if(!U){const t=$e??n?.summary??"";xt(t)}Z(!0)},Is=()=>{U?te({action:()=>{Z(!1),ee(!1)}}):Z(!1)},as=async()=>{if(!(!n?.reference||ft)){Ot(!0);try{await m.files.write(n.reference,Ce),le(Ce),ee(!1),Z(!1),T("success",s("detail.saved"))}catch(t){T("error",s("detail.saveFailed")+": "+String(t))}Ot(!1)}},Ls=()=>{Z(!1),ee(!1),te(null)};a.useEffect(()=>{if(!U)return;const t=r=>{r.preventDefault()};return window.addEventListener("beforeunload",t),()=>window.removeEventListener("beforeunload",t)},[U]),a.useEffect(()=>{if(!U)return;const t=r=>{r.preventDefault(),r.stopImmediatePropagation(),te({action:()=>{Z(!1),ee(!1);const{page:i,params:l}=r.detail||{};i&&se.navigate(i,l)}})};return window.addEventListener("markus:navigate",t),()=>window.removeEventListener("markus:navigate",t)},[U]);const wt=a.useRef(null),kt=a.useCallback((t,r)=>{const i=n?.agentId??"",l=n?.id??"",f={};l&&(f.openDeliverable=l);const x=[];if(l){const h=n?.title?.trim()||l,b=h.length>40?`${h.slice(0,24)}…${h.slice(-12)}`:h;x.push({label:`📄 ${b}`,content:["[deliverable]",`ID: ${l}`,`Title: ${n?.title??""}`,n?.reference?`Reference: ${n.reference}`:"",n?.taskId?`Task: ${n.taskId}`:"",n?.projectId?`Project: ${n.projectId}`:""].filter(Boolean).join(`
|
|
2
|
-
`)})}if(t?.trim()){const h=t.trim().length>40?`${t.trim().slice(0,24)}…${t.trim().slice(-12)}`:t.trim();if(r){const b=n?.reference??"";x.push({label:`🌐 ${h}`,content:["[html-selection]",`Text: "${t.trim()}"`,`CSS Selector: ${r.cssSelector}`,`XPath: ${r.xpath}`,b?`File: ${b}`:""].filter(Boolean).join(`
|
|
3
|
-
`)})}else x.push({label:`📝 ${h}`,content:t.trim()})}x.length>0&&(f.chatChips=JSON.stringify(x)),i&&(f.agentId=i),de(null),window.getSelection()?.removeAllRanges(),se.navigate(B.TEAM,f)},[n]),Rs=a.useCallback(t=>{if(!t.text.trim())return;const i=wt.current?.querySelector("iframe")?.getBoundingClientRect(),l=(i?.left??0)+t.rect.x+t.rect.width/2,f=(i?.top??0)+t.rect.y;de({x:l,y:f,text:t.text,htmlMeta:{xpath:t.xpath,cssSelector:t.cssSelector}})},[]);return a.useEffect(()=>{const t=wt.current;if(!t)return;const r=()=>{requestAnimationFrame(()=>{const l=window.getSelection(),f=l?.toString().trim();if(!f||!l?.rangeCount){de(null);return}const x=l.getRangeAt(0);if(!t.contains(x.commonAncestorContainer)){de(null);return}const h=x.getBoundingClientRect();de({x:h.left+h.width/2,y:h.top,text:f})})},i=l=>{const f=document.getElementById("selection-toolbar");f&&f.contains(l.target)||de(null)};return t.addEventListener("mouseup",r),document.addEventListener("mousedown",i),()=>{t.removeEventListener("mouseup",r),document.removeEventListener("mousedown",i)}},[]),e.jsxs("div",{className:"flex-1 overflow-hidden flex",children:[e.jsxs("div",{ref:ss,tabIndex:-1,"data-keyboard-pane":"l1",className:`${u?"flex-1 min-w-0":"shrink-0"} flex flex-col bg-surface-secondary rounded-xl m-1 mr-0 outline-none ${!u&&ce==="l1"?"ring-1 ring-inset ring-brand-500/30":""}`,style:u?N?{display:"none"}:void 0:_?{display:"none"}:{width:S.width},children:[e.jsxs("div",{"data-electron-drag":!0,className:"p-4 space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between gap-2",children:e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[u&&e.jsx($s,{}),!u&&e.jsx("button",{onClick:()=>X(!0),className:"w-8 h-8 flex items-center justify-center rounded-lg transition-colors shrink-0 bg-brand-500/15 text-brand-500 hover:bg-brand-500/25",title:s("sidebar.collapse"),children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),e.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]})}),e.jsxs("h2",{className:"text-sm font-semibold text-fg-secondary truncate",children:[s("title"),k>0&&e.jsxs("span",{className:"ml-1.5 text-fg-tertiary font-normal",children:["(",k,")"]})]})]})}),e.jsxs("div",{className:"relative",children:[e.jsxs("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-fg-muted pointer-events-none",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),e.jsx("input",{ref:ts,value:Te,onChange:t=>Be(t.target.value),placeholder:s("searchPlaceholder"),className:"w-full bg-surface-elevated border border-border-default rounded-lg pl-8 pr-8 py-2 text-sm text-fg-primary focus:border-brand-500 focus:outline-none transition-colors"}),Te&&e.jsx("button",{onClick:()=>{Be(""),Ae("")},className:"absolute right-2.5 top-1/2 -translate-y-1/2 w-4 h-4 flex items-center justify-center rounded-full bg-surface-overlay text-fg-tertiary hover:text-fg-secondary transition-colors",children:e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),ut&&!u&&e.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1.5 bg-surface-elevated rounded-lg text-[10px] text-fg-tertiary",children:[e.jsx("span",{className:"truncate font-mono",children:ut}),e.jsx("button",{onClick:()=>{m.system.openPath(ut)},className:"shrink-0 underline hover:text-fg-secondary transition-colors",children:s("common:open")})]}),u&&e.jsxs("button",{onClick:()=>xs(t=>!t),className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs transition-colors ${st||Ge?"bg-brand-500/15 text-brand-500":"bg-surface-elevated text-fg-secondary"}`,children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),e.jsx("line",{x1:"8",y1:"12",x2:"20",y2:"12"}),e.jsx("line",{x1:"12",y1:"18",x2:"20",y2:"18"})]}),s("filters.filtersLabel"),Ge&&e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-brand-500"}),e.jsx("svg",{className:`w-3 h-3 ml-auto transition-transform ${st?"rotate-180":""}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),e.jsxs("div",{className:u&&!st?"hidden":"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-1 overflow-x-auto scrollbar-hide filter-pills-fade",children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:s("filters.source")}),e.jsx(pe,{label:s("filters.allSources"),value:"",current:H,onClick:()=>W("")}),e.jsx(pe,{label:s("filters.sourceAgent"),value:"agent",current:H,onClick:t=>W(t||"")}),e.jsx(pe,{label:s("filters.sourceKnowledge"),value:"knowledge",current:H,onClick:t=>W(t||"")}),e.jsxs("button",{type:"button",onClick:()=>Ze(!0),className:"ml-auto shrink-0 flex items-center gap-1 px-2 py-1 rounded text-[10px] text-fg-tertiary hover:text-brand-500 hover:bg-surface-elevated transition-colors",title:s("filters.bindKnowledgeBase"),children:[e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[e.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),e.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),s("filters.bindKnowledgeBase")]})]}),e.jsxs("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide filter-pills-fade",children:[e.jsx(pe,{label:s("filters.allTypes"),value:"",current:V||F||"",onClick:()=>{be(""),ye("")}}),qs.map(t=>e.jsx(pe,{label:`${me[t]?.icon??""} ${t}`,value:t,current:V,onClick:r=>{be(r),ye("")}},t)),["agent","team","skill"].map(t=>e.jsx(pe,{label:`${z[t].icon} ${s(`artifactTypes.${t}`)}`,value:t,current:F,onClick:r=>{ye(r),be("")}},t))]}),e.jsxs("div",{className:"flex gap-1.5 items-center",children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary",children:s("filters.group")}),["date","project","team","agent"].map(t=>e.jsx("button",{onClick:()=>{Tt(t)},className:`px-2 py-1 rounded text-xs transition-colors ${A===t?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:bg-surface-overlay"}`,children:s(`groupBy.${t}`)},t)),K.length>1&&e.jsx("button",{onClick:ks,className:"ml-auto px-1.5 py-1 rounded text-[10px] text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated transition-colors",title:s(Xt?"expandAllTooltip":"collapseAllTooltip"),children:s(Xt?"expandAll":"collapseAll")})]})]}),Ge&&e.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[ge&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-brand-500/10 text-brand-500 text-[10px]",children:["“",ge,"”",e.jsx("button",{onClick:()=>{Be(""),Ae("")},className:"hover:text-brand-400",children:e.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),V&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-brand-500/10 text-brand-500 text-[10px]",children:[me[V]?.icon," ",V,e.jsx("button",{onClick:()=>be(""),className:"hover:text-brand-400",children:e.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),F&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-brand-500/10 text-brand-500 text-[10px]",children:[z[F]?.icon," ",s(`artifactTypes.${F}`),e.jsx("button",{onClick:()=>ye(""),className:"hover:text-brand-400",children:e.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),H&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-brand-500/10 text-brand-500 text-[10px]",children:[s(H==="knowledge"?"filters.sourceKnowledge":"filters.sourceAgent"),e.jsx("button",{onClick:()=>W(""),className:"hover:text-brand-400",children:e.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),ae&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-brand-500/10 text-brand-500 text-[10px]",children:[Ie(ae)??ae,e.jsx("button",{onClick:()=>Me(""),className:"hover:text-brand-400",children:e.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),e.jsx("button",{onClick:es,className:"text-[10px] text-fg-tertiary hover:text-brand-500 ml-auto transition-colors",children:s("filters.clearAll")})]})]}),et&&e.jsx("div",{className:`mx-4 mt-2 px-3 py-1.5 text-xs rounded-lg ${et.type==="success"?"bg-green-500/15 text-green-600":"bg-red-500/15 text-red-500"}`,children:et.text}),e.jsxs("div",{ref:Y,className:"flex-1 overflow-y-auto p-2 space-y-1 transition-opacity duration-150",style:{opacity:G?.5:1},onTouchStart:u?t=>{Dt.onTouchStart(t),Ns(t)}:void 0,onTouchEnd:u?t=>{Dt.onTouchEnd(t),Ss(t)}:void 0,children:[rt&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-2 text-brand-500",children:[e.jsx(os,{})," ",e.jsx("span",{className:"text-[10px]",children:s("filters.refreshing")})]}),G?e.jsx("div",{className:"p-4 space-y-3",children:[1,2,3].map(t=>e.jsxs("div",{className:"animate-pulse space-y-2",children:[e.jsx("div",{className:"h-4 bg-surface-elevated rounded w-3/4"}),e.jsx("div",{className:"h-3 bg-surface-elevated rounded w-1/2"})]},t))}):g.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-6 text-center",children:[e.jsx("svg",{className:"w-12 h-12 text-fg-muted mb-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),Ge?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-fg-secondary",children:s("empty.noResults")}),e.jsx("p",{className:"text-xs text-fg-tertiary mt-1 mb-3",children:s("empty.noResultsHint")}),e.jsx("button",{onClick:es,className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:s("filters.clearAll")})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-fg-secondary",children:s("empty.title")}),e.jsx("p",{className:"text-xs text-fg-tertiary mt-1 mb-3",children:s("empty.subtitle")}),e.jsx("button",{onClick:()=>se.navigate(B.WORK),className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:s("empty.goToWork")})]})]}):K.map(([t,r])=>{const i=Jt(t);return e.jsxs("div",{className:"mb-1",children:[e.jsxs("button",{onClick:()=>ws(t),className:"w-full flex items-center gap-1.5 px-2 py-2 rounded-md hover:bg-surface-elevated/50 transition-colors group/header border-b border-border-subtle/50",children:[e.jsx("svg",{className:`w-3 h-3 text-fg-tertiary transition-transform duration-200 shrink-0 ${i?"":"rotate-90"}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),e.jsx("span",{className:"text-[11px] font-semibold text-fg-tertiary uppercase tracking-wider truncate",children:r.label}),e.jsxs("span",{className:"text-[10px] text-fg-muted bg-surface-elevated px-1.5 py-0.5 rounded-full shrink-0",children:[r.items.length,g.length<k?"+":""]})]}),e.jsx("div",{className:`overflow-hidden transition-all duration-200 ${i?"max-h-0 opacity-0":"max-h-[5000px] opacity-100"}`,children:r.items.map(l=>e.jsx("button",{"data-deliverable-id":l.id,onClick:()=>ns(l),className:`w-full text-left px-3 py-2 rounded-lg transition-all duration-150 ${n?.id===l.id?ce==="l1"?"bg-brand-500/25 ring-1 ring-inset ring-brand-500/40 border-l-2 border-l-brand-500 border-y border-r border-y-brand-500/20 border-r-brand-500/20":"bg-brand-600/15 border-l-2 border-l-brand-500 border-y border-r border-y-brand-500/20 border-r-brand-500/20":"hover:bg-surface-elevated/60 border-l-2 border-l-transparent border-y border-r border-transparent"}`,children:e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[l.artifactType&&z[l.artifactType]?e.jsx("span",{className:`text-[10px] px-1 py-0.5 rounded font-medium shrink-0 ${z[l.artifactType].color}`,children:z[l.artifactType].icon}):e.jsx("span",{className:`text-[10px] px-1 py-0.5 rounded font-medium uppercase shrink-0 ${me[l.type]?.color??"bg-surface-overlay text-fg-secondary"}`,children:me[l.type]?.icon??l.type.charAt(0)}),e.jsx("span",{className:"text-sm font-medium text-fg-primary truncate flex-1",children:l.title}),I(l)==="published"&&e.jsxs("svg",{className:"shrink-0 text-green-500",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-label":s("share.published",{defaultValue:"已发布到 Hub"}),children:[e.jsx("title",{children:s("share.published",{defaultValue:"已发布到 Hub"})}),e.jsx("circle",{cx:"18",cy:"5",r:"3"}),e.jsx("circle",{cx:"6",cy:"12",r:"3"}),e.jsx("circle",{cx:"18",cy:"19",r:"3"}),e.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),e.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]}),I(l)==="pending_review"&&e.jsxs("svg",{className:"shrink-0 text-amber-500 animate-pulse",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-label":s("share.pendingReview",{defaultValue:"Hub 审核中"}),children:[e.jsx("title",{children:s("share.pendingReview",{defaultValue:"Hub 审核中"})}),e.jsx("circle",{cx:"18",cy:"5",r:"3"}),e.jsx("circle",{cx:"6",cy:"12",r:"3"}),e.jsx("circle",{cx:"18",cy:"19",r:"3"}),e.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),e.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]}),I(l)==="rejected"&&e.jsxs("svg",{className:"shrink-0 text-red-500",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-label":s("share.rejected",{defaultValue:"Hub 已拒绝"}),children:[e.jsx("title",{children:s("share.rejected",{defaultValue:"Hub 已拒绝"})}),e.jsx("circle",{cx:"18",cy:"5",r:"3"}),e.jsx("circle",{cx:"6",cy:"12",r:"3"}),e.jsx("circle",{cx:"18",cy:"19",r:"3"}),e.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),e.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]}),_t.has(l.id)&&e.jsx("span",{className:"shrink-0 text-amber-500",title:s("detail.fileMissing"),children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]})}),e.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:Ys(l.updatedAt,s)})]})},l.id))})]},t)}),p&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-fg-tertiary",children:[e.jsx(os,{})," ",e.jsx("span",{className:"text-[10px]",children:s("common:loadingMore")})]}),!G&&g.length>0&&e.jsx("div",{className:"text-center text-[10px] text-fg-tertiary py-2",children:g.length<k?s("count.partial",{loaded:g.length,total:k}):s("count.total",{total:k})})]})]}),!u&&e.jsx("div",{className:"w-2 shrink-0 cursor-col-resize group relative flex items-center justify-center hover:bg-brand-500/5 transition-colors",onMouseDown:S.onResizeStart,children:e.jsxs("div",{className:"flex flex-col gap-1 items-center opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx("div",{className:"w-1 h-1 rounded-full bg-fg-muted"}),e.jsx("div",{className:"w-1 h-1 rounded-full bg-fg-muted"}),e.jsx("div",{className:"w-1 h-1 rounded-full bg-fg-muted"})]})}),(!u||N)&&e.jsxs("div",{"data-no-drag":!0,className:"flex-1 overflow-hidden min-w-0 flex relative self-stretch",children:[e.jsxs("div",{ref:wt,className:"flex-1 overflow-y-auto min-w-0 h-full",children:[_&&!u&&e.jsxs("div",{className:"sticky top-0 z-10 bg-surface-primary/80 backdrop-blur-sm px-4 py-2 flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{qe.current=!0,X(!1)},className:"w-8 h-8 flex items-center justify-center rounded-lg transition-colors shrink-0 text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated",title:s("sidebar.expand"),children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),e.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]})}),e.jsx("span",{className:"text-sm font-medium text-fg-secondary truncate",children:n?.title??s("detail.details")})]}),u&&e.jsxs("div",{className:"sticky top-0 z-10 bg-surface-secondary px-4 py-2.5 flex items-center gap-2",children:[e.jsx("button",{onClick:()=>history.back(),className:"text-fg-secondary hover:text-fg-primary transition-colors p-1 -ml-1",children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"15 18 9 12 15 6"})})}),e.jsx("span",{className:"text-sm font-medium truncate",children:n?.title??s("detail.details")})]}),n?e.jsxs("div",{className:`p-6 space-y-4 ${We?"flex flex-col min-h-0 h-full":""}`,children:[!o&&_t.has(n.id)&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-amber-500/10 border border-amber-500/20 rounded-lg text-amber-600 text-xs",children:[e.jsxs("svg",{className:"w-4 h-4 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),e.jsx("span",{children:s("detail.fileMissing")})]}),e.jsxs("div",{className:`space-y-3 ${We?"shrink-0":""}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("h2",{className:"text-xl font-semibold text-fg-primary",children:n.title}),!o&&e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[Os(n?.format)&&e.jsxs("button",{onClick:()=>dt(!0),title:s("share.title",{defaultValue:"分享到 Markus Hub"}),"aria-label":s("share.title",{defaultValue:"分享到 Markus Hub"}),className:`relative p-1.5 rounded-lg transition-colors ${I(n)==="published"?"text-green-500 hover:text-green-400 hover:bg-green-500/10":I(n)==="pending_review"?"text-amber-500 hover:text-amber-400 hover:bg-amber-500/10":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"18",cy:"5",r:"3"}),e.jsx("circle",{cx:"6",cy:"12",r:"3"}),e.jsx("circle",{cx:"18",cy:"19",r:"3"}),e.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),e.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]}),I(n)==="published"||I(n)==="pending_review"||I(n)==="rejected"?e.jsx("span",{className:`absolute top-0.5 right-0.5 w-2 h-2 rounded-full border border-surface-primary ${I(n)==="published"?"bg-green-500":I(n)==="pending_review"?"bg-amber-500 animate-pulse":"bg-red-500"}`,"aria-hidden":!0}):null]}),e.jsx("button",{onClick:()=>He(n),disabled:!!At,className:"p-1.5 rounded-lg text-fg-tertiary hover:text-red-500 hover:bg-red-500/10 transition-colors disabled:opacity-50 shrink-0",title:s("common:remove"),children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"3 6 5 6 21 6"}),e.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{className:`px-2 py-0.5 rounded text-xs font-medium uppercase ${me[n.type]?.color??"bg-surface-overlay text-fg-secondary"}`,children:[me[n.type]?.icon??""," ",n.type]}),n.artifactType&&z[n.artifactType]&&e.jsxs("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${z[n.artifactType].color}`,children:[z[n.artifactType].icon," ",s("detail.builderWithType",{type:s(`artifactTypes.${n.artifactType}`)})]}),n.tags.length>0&&n.tags.map(t=>e.jsx("span",{className:"px-2 py-0.5 text-xs bg-surface-elevated text-fg-secondary rounded",children:t},t)),I(n)==="published"&&e.jsxs("a",{href:n.shareUrl??void 0,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium bg-green-500/15 text-green-600 hover:bg-green-500/25 hover:underline",title:n.shareUrl??void 0,children:[e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"18",cy:"5",r:"3"}),e.jsx("circle",{cx:"6",cy:"12",r:"3"}),e.jsx("circle",{cx:"18",cy:"19",r:"3"}),e.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),e.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]}),s("share.published",{defaultValue:"已发布"})]}),I(n)==="pending_review"&&e.jsxs("a",{href:n.shareUrl??void 0,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium bg-amber-500/15 text-amber-500 hover:bg-amber-500/25 hover:underline",title:`${n.shareUrl??void 0} · ${s("share.pendingReview",{defaultValue:"审核中"})}`,children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-500 animate-pulse"}),s("share.pendingReview",{defaultValue:"审核中"})]}),I(n)==="rejected"&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium bg-red-500/15 text-red-500",title:n.shareReason??void 0,children:[s("share.rejected",{defaultValue:"已拒绝"}),n.shareReason?e.jsxs("span",{className:"text-red-400/90 font-normal",children:["— ",n.shareReason]}):null]})]}),(n.taskId||n.agentId||Ie(n.projectId))&&e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.taskId&&e.jsx("button",{onClick:()=>se.navigate(B.WORK,{openTask:n.taskId}),className:"text-xs text-brand-500 hover:underline bg-brand-500/10 px-2 py-0.5 rounded",children:s("links.task",{id:`${n.taskId.slice(0,12)}...`})}),n.agentId&&e.jsx("button",{onClick:()=>se.navigate(B.TEAM,{selectAgent:n.agentId}),className:"text-xs text-blue-600 hover:underline bg-blue-500/10 px-2 py-0.5 rounded",children:s("links.agent",{name:Ue.get(n.agentId)?.name??n.agentId.slice(0,12)})}),Ie(n.projectId)&&e.jsx("button",{onClick:()=>se.navigate(B.WORK,{projectId:n.projectId}),className:"text-xs text-blue-600 hover:underline bg-blue-500/10 px-2 py-0.5 rounded",children:s("links.project",{name:Ie(n.projectId)})})]}),(n.diffStats||n.testResults)&&e.jsxs("div",{className:"flex gap-3 flex-wrap",children:[n.diffStats&&e.jsxs("div",{className:"bg-surface-elevated rounded-lg px-3 py-2 text-xs flex items-center gap-2",children:[e.jsxs("span",{className:"text-fg-tertiary font-medium",children:[s("diffStats.title"),":"]}),e.jsx("span",{className:"text-fg-secondary",children:s("diffStats.files",{count:n.diffStats.filesChanged})}),e.jsxs("span",{className:"text-green-600",children:["+",n.diffStats.additions]}),e.jsxs("span",{className:"text-red-500",children:["-",n.diffStats.deletions]})]}),n.testResults&&e.jsxs("div",{className:"bg-surface-elevated rounded-lg px-3 py-2 text-xs flex items-center gap-2",children:[e.jsxs("span",{className:"text-fg-tertiary font-medium",children:[s("testResults.title"),":"]}),e.jsx("span",{className:"text-green-600",children:s("testResults.passed",{count:n.testResults.passed})}),e.jsx("span",{className:"text-red-500",children:s("testResults.failed",{count:n.testResults.failed})}),e.jsx("span",{className:"text-fg-secondary",children:s("testResults.skipped",{count:n.testResults.skipped})})]})]}),e.jsxs("div",{className:"flex items-center gap-4 text-[10px] text-fg-tertiary flex-wrap",children:[e.jsxs("span",{children:[s("metadata.created")," ",new Date(n.createdAt).toLocaleString()]}),e.jsxs("span",{children:[s("metadata.updated")," ",new Date(n.updatedAt).toLocaleString()]}),e.jsx("span",{className:"text-fg-muted select-all",children:n.id.slice(0,12)})]}),n.reference&&!Qe(n.reference)&&n.type==="file"&&e.jsxs("div",{className:"flex items-center gap-2 bg-surface-elevated rounded-lg px-3 py-2",children:[e.jsx("button",{onClick:()=>{m.files.reveal(n.reference).catch(()=>T("error",s("detail.failedToOpenBrowser")))},className:"text-xs font-mono text-brand-500 hover:text-brand-500 hover:underline truncate flex-1 text-left cursor-pointer",title:s("detail.openInFileBrowser"),children:n.reference}),e.jsx("button",{onClick:()=>{m.files.reveal(n.reference).catch(()=>T("error",s("detail.failedToOpenBrowser")))},className:"px-2 py-1 text-[10px] rounded bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors shrink-0",title:s("detail.revealInFinder"),children:s("common:open")}),e.jsx("button",{onClick:()=>_e(n.reference),className:`px-2 py-1 text-[10px] rounded transition-colors shrink-0 ${Ne?"bg-green-500/20 text-green-600":"bg-surface-overlay/50 text-fg-secondary hover:bg-surface-overlay"}`,title:s("detail.copyPath"),children:s(Ne?"common:copied":"common:copy")})]}),n.reference&&!Qe(n.reference)&&n.type!=="file"&&n.type!=="directory"&&e.jsx("span",{className:"text-xs text-fg-tertiary font-mono break-all",children:n.reference})]}),n.artifactType&&n.artifactData?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:e.jsx(Gs,{artifact:n.artifactData,mode:n.artifactType})}),n.reference&&e.jsxs("div",{className:"px-3 py-2 bg-surface-elevated rounded-lg",children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider block mb-1",children:s("detail.artifactDirectory")}),e.jsx("span",{className:"text-xs text-fg-secondary font-mono break-all",children:n.reference})]}),e.jsx("div",{className:"flex gap-2",children:e.jsx("button",{onClick:vs,className:"flex-1 px-4 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-sm font-medium rounded-lg transition-colors",children:s("detail.openInBuilder")})}),n.summary&&e.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:e.jsx(St,{content:n.summary,className:"text-fg-secondary text-sm"})})]}):n.reference&&Qe(n.reference)?e.jsxs("div",{className:"space-y-4",children:[n.summary&&e.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:e.jsx(St,{content:n.summary,className:"text-fg-secondary text-sm"})}),e.jsxs("div",{className:"flex flex-col items-center justify-center py-10",children:[e.jsxs("svg",{className:"w-10 h-10 text-fg-muted mb-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),e.jsx("p",{className:"text-xs text-fg-tertiary font-mono mb-4 px-4 text-center break-all select-all",children:n.reference}),e.jsx("button",{onClick:()=>window.open(n.reference,"_blank","noopener,noreferrer"),className:"px-6 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-sm font-medium rounded-lg transition-colors",children:s("detail.openUrl")})]})]}):e.jsxs("div",{className:`bg-surface-elevated rounded-xl overflow-hidden ${We?"flex flex-col h-full":""}`,children:[($e||n.summary)&&!it&&!je&&!Q&&!Ft&&n.reference&&n.type==="file"&&(De==="markdown"||De==="text"||De==="html")&&e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border-subtle bg-surface-secondary/50",children:[e.jsx("button",{onClick:Is,className:`px-3 py-1 rounded text-xs font-medium transition-colors ${ue?"text-fg-tertiary hover:text-fg-secondary":"bg-brand-600/20 text-brand-500"}`,children:s("detail.preview")}),e.jsx("button",{onClick:Cs,className:`px-3 py-1 rounded text-xs font-medium transition-colors ${ue?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:s("detail.edit")}),e.jsx("div",{className:"flex-1"}),ue&&e.jsx("button",{onClick:as,disabled:!U||ft,className:"px-3 py-1 rounded text-xs font-medium bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:s(ft?"detail.saving":"detail.save")})]}),e.jsxs("div",{className:We?"flex-1 min-h-0 p-5 flex flex-col":"p-5",children:[Wt&&ot&&!Q&&!it&&e.jsxs("div",{className:"flex items-center gap-2 mb-3 px-3 py-2 border border-border-subtle bg-surface-secondary/50 rounded-lg shrink-0",children:[e.jsxs("button",{className:"inline-flex items-center gap-1 text-xs text-fg-secondary hover:text-brand-500 transition-colors cursor-pointer",onClick:()=>{const t=Wt;Ve(null),Fe(null),vt(t)},children:[e.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M17 10a.75.75 0 01-.75.75H5.612l4.158 3.96a.75.75 0 11-1.04 1.08l-5.5-5.25a.75.75 0 010-1.08l5.5-5.25a.75.75 0 111.04 1.08L5.612 9.25H16.25A.75.75 0 0117 10z",clipRule:"evenodd"})}),"返回上级目录"]}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{className:"shrink-0 text-xs text-fg-secondary hover:text-fg-primary hover:underline cursor-pointer",onClick:()=>_e(ot),children:Ne?s("common:copied"):s("common:copyPath",{defaultValue:"复制路径"})}),e.jsx("button",{className:"shrink-0 text-xs text-fg-secondary hover:text-fg-primary hover:underline cursor-pointer",onClick:()=>{m.files.reveal(ot).catch(()=>T("error",s("detail.failedToOpenBrowser")))},children:s("detail.openInFileBrowser",{defaultValue:"在文件浏览器中显示"})})]}),it?e.jsxs("div",{className:"animate-pulse space-y-4",children:[e.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-full"}),e.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-5/6"}),e.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-4/6"}),e.jsx("div",{className:"h-32 bg-surface-overlay/40 rounded-lg w-full mt-2"}),e.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-3/4"}),e.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-2/3"})]}):Q?e.jsx("div",{className:n.type==="directory"?"flex-1 min-h-0":"h-[50vh] min-h-[300px]",children:e.jsx(Ds,{path:Q.path,entries:Q.entries,onNavigate:t=>{vt(t)},onOpenFile:t=>{js(t,Q?.path)},onReveal:t=>{m.files.reveal(t).catch(()=>T("error",s("detail.failedToOpenBrowser")))},onCopyPath:t=>_e(t)})}):je?e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx("img",{src:je.src,alt:je.name,className:"max-w-full max-h-[60vh] rounded-lg object-contain"}),e.jsx("span",{className:"text-xs text-fg-tertiary",children:je.name})]}):ie?e.jsx("div",{className:Ut?"flex-1 min-h-0":"h-[55vh]",children:e.jsx(Vs,{data:ie,reference:ie.reference,onFallback:ie.reference?()=>{m.files.reveal(ie.reference).catch(()=>{})}:void 0})}):we?e.jsxs("div",{className:"flex flex-col gap-3 py-4",children:[we.kind==="audio"?e.jsx("audio",{controls:!0,preload:"metadata",src:we.src,className:"w-full"}):e.jsx("video",{controls:!0,preload:"metadata",src:we.src,className:"w-full max-h-[60vh] rounded-lg bg-black"}),e.jsx("span",{className:"text-xs text-fg-tertiary",children:we.name})]}):$e?ue?e.jsx("div",{className:"animate-fadeIn",children:e.jsx("textarea",{ref:mt,value:Ce,onChange:t=>{xt(t.target.value),ee(!0)},className:"w-full min-h-[120px] p-3 text-sm font-mono bg-surface-primary border border-border-subtle rounded-lg text-fg-secondary focus:outline-none focus:ring-1 focus:ring-brand-500/50 overflow-hidden",style:{resize:"none"},spellCheck:!1})},"edit"):e.jsx("div",{className:"animate-fadeIn",children:e.jsx(_s,{content:$e,format:De,className:"text-fg-secondary text-sm",onHtmlSelection:Rs,basePath:n?.reference?n.reference.replace(/[/\\][^/\\]+$/,""):void 0})},"preview"):Ft?e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-fg-secondary",children:s("detail.cannotPreview",{type:n.type})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{m.files.reveal(n.reference).catch(()=>T("error",s("detail.failedToOpen")))},className:"text-xs bg-surface-elevated px-3 py-2 rounded text-brand-500 hover:text-brand-500 hover:underline flex-1 truncate text-left cursor-pointer font-mono",title:s("detail.openInFileBrowser"),children:n.reference}),e.jsx("button",{onClick:()=>{m.files.reveal(n.reference).catch(()=>T("error",s("detail.failedToOpen")))},className:"px-3 py-2 text-xs rounded-lg bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors shrink-0",children:s("common:open")}),e.jsx("button",{onClick:()=>_e(n.reference),className:`px-3 py-2 text-xs rounded-lg transition-colors shrink-0 ${Ne?"bg-green-500/20 text-green-600":"bg-surface-overlay/50 text-fg-secondary hover:bg-surface-overlay"}`,children:s(Ne?"common:copied":"common:copy")})]})]}):n.summary?ue?e.jsx("textarea",{ref:mt,value:Ce,onChange:t=>{xt(t.target.value),ee(!0)},className:"w-full min-h-[120px] p-3 text-sm font-mono bg-surface-primary border border-border-subtle rounded-lg text-fg-secondary focus:outline-none focus:ring-1 focus:ring-brand-500/50 overflow-hidden",style:{resize:"none"},spellCheck:!1}):e.jsx(St,{content:n.summary,className:"text-fg-secondary text-sm"}):e.jsx("p",{className:"text-sm text-fg-tertiary italic",children:s("detail.noContent")})]})]})]}):e.jsx("div",{className:"flex-1 flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center text-fg-tertiary space-y-3 max-w-xs",children:[e.jsx("div",{className:"w-16 h-16 mx-auto rounded-2xl bg-surface-elevated/60 flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-fg-muted",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})})}),e.jsx("p",{className:"text-sm text-fg-secondary",children:s("detail.selectToView")}),!u&&e.jsx("p",{className:"text-[10px] text-fg-muted",children:s("detail.keyboardHint")})]})})]}),n?.agentId&&!u&&e.jsx("button",{type:"button",onClick:()=>kt(),className:"absolute bottom-6 right-6 z-20 w-12 h-12 rounded-full bg-brand-600 hover:bg-brand-500 text-white shadow-lg shadow-black/20 flex items-center justify-center transition-transform hover:scale-105 animate-fab-in",title:s("chat.openChat",{defaultValue:"Open in Team Chat"}),children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})})]}),Se&&e.jsx("div",{id:"selection-toolbar",className:"fixed z-50 -translate-x-1/2 -translate-y-full bg-surface-elevated border border-border-default rounded-lg shadow-xl overflow-hidden",style:{left:Se.x,top:Se.y-8},children:e.jsxs("button",{onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),kt(Se.text,Se.htmlMeta)},className:"px-3 py-1.5 text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-1.5 whitespace-nowrap",children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),s("contextMenu.addToConversation")]})}),ms&&n&&e.jsx(Ks,{item:n,onClose:()=>dt(!1),onShared:ys}),ds&&e.jsx(Qs,{projects:Xe,onClose:()=>Ze(!1),onBound:()=>{Ze(!1),W("knowledge"),O()}}),ct&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:()=>He(null),children:e.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 max-w-sm mx-4 shadow-2xl",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/15 flex items-center justify-center shrink-0",children:e.jsxs("svg",{className:"w-5 h-5 text-red-500",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"3 6 5 6 21 6"}),e.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-fg-primary",children:s("detail.confirmRemoveTitle")}),e.jsx("div",{className:"text-xs text-fg-secondary mt-0.5",children:s("detail.confirmRemoveMessage",{name:ct.title})})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:()=>He(null),className:"px-4 py-1.5 text-xs text-fg-secondary hover:text-fg-primary border border-border-default hover:border-gray-600 rounded-lg transition-colors",children:s("common:cancel")}),e.jsx("button",{onClick:()=>{const t=ct;He(null),bs(t)},disabled:!!At,className:"px-4 py-1.5 text-xs bg-red-600 hover:bg-red-500 text-white rounded-lg transition-colors disabled:opacity-50",children:s("common:remove")})]})]})}),ht&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:()=>te(null),children:e.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 max-w-sm mx-4 shadow-2xl",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-amber-500/15 flex items-center justify-center shrink-0",children:e.jsx("svg",{className:"w-5 h-5 text-amber-500",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-fg-primary",children:s("detail.unsavedTitle")}),e.jsx("div",{className:"text-xs text-fg-secondary mt-0.5",children:s("detail.unsavedMessage")})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:()=>te(null),className:"px-4 py-1.5 text-xs text-fg-secondary hover:text-fg-primary border border-border-default hover:border-gray-600 rounded-lg transition-colors",children:s("common:cancel")}),e.jsx("button",{onClick:()=>{Ls(),ht.action()},className:"px-4 py-1.5 text-xs text-fg-secondary hover:text-fg-primary border border-border-default hover:border-gray-600 rounded-lg transition-colors",children:s("detail.discard")}),e.jsx("button",{onClick:async()=>{await as(),ht.action(),te(null)},className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors",children:s("detail.saveAndLeave")})]})]})})]})}function Qs({projects:d,onClose:o,onBound:c}){const{t:s}=Je("deliverables"),[u,v]=a.useState(""),[S,N]=a.useState(""),[j,E]=a.useState(!1),[w,L]=a.useState(""),g=d.find(p=>p.id===u),R=typeof window<"u"&&!!window.markusDesktop?.selectDirectory,k=async()=>{try{const p=await window.markusDesktop?.selectDirectory?.(s("bindBrowseTitle",{defaultValue:"Select knowledge base directory"}));p&&N(p)}catch(p){L(String(p))}},D=async()=>{if(!(!u||!S.trim()||j)){E(!0),L("");try{const p=S.trim(),ne=[...new Set([...g?.knowledgeBasePaths??[],p])];await m.projects.update(u,{knowledgeBasePaths:ne}),await m.projects.syncKnowledge(u),c()}catch(p){L(String(p))}finally{E(!1)}}};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:()=>{j||o()},children:e.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 max-w-md w-full mx-4 shadow-2xl",onClick:p=>p.stopPropagation(),children:[e.jsx("div",{className:"text-sm font-medium text-fg-primary mb-1",children:s("bindKnowledgeBase")}),e.jsx("p",{className:"text-xs text-fg-secondary mb-4",children:s("bindKnowledgeBaseHint")}),e.jsx("label",{className:"block text-[10px] text-fg-tertiary mb-1",children:s("bindProject")}),e.jsxs("select",{value:u,onChange:p=>v(p.target.value),className:"w-full mb-3 px-2.5 py-2 text-xs bg-surface-primary border border-border-default rounded-lg text-fg-primary",children:[e.jsx("option",{value:"",children:s("bindProjectSelect")}),d.map(p=>e.jsx("option",{value:p.id,children:p.name},p.id))]}),e.jsx("label",{className:"block text-[10px] text-fg-tertiary mb-1",children:s("bindPath")}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx("input",{value:S,onChange:p=>N(p.target.value),onKeyDown:p=>{p.key==="Enter"&&D()},placeholder:s("bindPathPlaceholder"),className:"flex-1 min-w-0 px-2.5 py-2 text-xs bg-surface-primary border border-border-default rounded-lg text-fg-primary placeholder:text-fg-tertiary font-mono"}),R&&e.jsx("button",{type:"button",onClick:()=>{k()},disabled:j,title:s("bindBrowse",{defaultValue:"Browse…"}),className:"shrink-0 px-3 py-2 text-xs bg-surface-overlay text-fg-secondary hover:text-fg-primary rounded-lg disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:s("bindBrowse",{defaultValue:"Browse…"})})]}),g&&(g.knowledgeBasePaths??[]).length>0&&e.jsxs("div",{className:"mb-3 space-y-1",children:[e.jsx("div",{className:"text-[10px] text-fg-tertiary",children:s("bindCurrentPaths")}),(g.knowledgeBasePaths??[]).map((p,ne)=>e.jsxs("div",{className:"text-[11px] text-fg-secondary font-mono truncate",title:p,children:["• ",p]},`${p}-${ne}`))]}),w&&e.jsx("div",{className:"mb-3 px-2.5 py-1.5 text-[11px] rounded-md bg-red-500/15 text-red-500",children:w}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx("button",{onClick:o,disabled:j,className:"px-3 py-1.5 text-xs text-fg-tertiary hover:text-fg-secondary rounded-lg transition-colors",children:s("common:cancel",{defaultValue:"Cancel"})}),e.jsx("button",{onClick:()=>{D()},disabled:j||!u||!S.trim(),className:"px-3 py-1.5 text-xs bg-brand-600 text-white rounded-lg hover:bg-brand-500 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:j?s("bindSaving",{defaultValue:"Saving…"}):s("bindSave",{defaultValue:"Bind directory"})})]})]})})}function pe({label:d,value:o,current:c,onClick:s}){return e.jsx("button",{onClick:()=>s(c===o?"":o),className:`px-2 py-1 rounded text-xs whitespace-nowrap shrink-0 transition-colors ${c===o?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:bg-surface-overlay"}`,children:d})}function os(){return e.jsxs("svg",{className:"animate-spin h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}export{er as DeliverablesPage};
|