pi-web-ui 0.107.0 → 0.108.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/CHANGELOG.md +36 -10
- package/dist/server/agent-formatters.js +19 -4
- package/dist/server/agent-service.js +1 -0
- package/dist/server/bg-servers.js +205 -53
- package/dist/server/client-state.js +4 -0
- package/dist/server/dispatch-domain-handlers.js +2 -0
- package/dist/server/dsh/dsh-agent-service.js +9 -0
- package/dist/server/files-service.js +15 -1
- package/dist/server/model-admin.js +61 -10
- package/dist/server/preset-fields.js +14 -0
- package/dist/server/preset-share.js +2 -0
- package/dist/server/process-utils.js +114 -12
- package/dist/server/protocol-version.js +1 -1
- package/dist/server/settings-service.js +4 -0
- package/dist/server/text-sniff.js +2 -0
- package/dist/server/universal/universal-session.js +2 -0
- package/package.json +2 -1
- package/web/dist/assets/{TerminalPanel-BnViyTlx.js → TerminalPanel-CslRhcS7.js} +1 -1
- package/web/dist/assets/index-C_2Fl6f6.js +690 -0
- package/web/dist/assets/index-D0BtO5dn.css +1 -0
- package/web/dist/index.html +2 -2
- package/web/dist/sw.js +1 -1
- package/web/dist/assets/index-cCRCYMwT.css +0 -1
- package/web/dist/assets/index-fH5vhkAE.js +0 -690
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,37 @@
|
|
|
8
8
|
每个版本的内容按"实际合入该版本发布的提交"归档(以 `package.json` 的 version 变更提交为准),
|
|
9
9
|
而不是按提交日期聚类——连续快速发布的 patch 版本以此为准最准确。
|
|
10
10
|
|
|
11
|
+
## [0.108.0] — 2026-10-18
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- **集中式「插件设置」面板 (Plugin Settings Center)**:
|
|
16
|
+
- 顶栏插件菜单新增「插件设置」入口,一屏集中管理所有插件的启用状态与参数配置,不必再逐个进设置页翻找;
|
|
17
|
+
- 支持「全部 / 可配置 / 已启用 / 已停用」筛选与插件名称、ID、描述关键词搜索,卡片直观标注「可配置 / 界面 / 后台 / N 个工具」徽标;
|
|
18
|
+
- 支持批量展开/折叠配置、单卡快速配置,并可一键跳转插件市场做高级管理。
|
|
19
|
+
- **插件菜单分组**:插件菜单按「功能界面」与「扩展组件」分栏展示,界面插件与工具型扩展一目了然。
|
|
20
|
+
- **向上分页加载 (Reverse Pagination)**:设置 › 界面 › 新增开关。开启后默认只挂载最近消息,向上滚动或点击「加载前 N 条 / 全部展开」按需取更早历史,完全不使用视口占位符,超长会话滚动更接近原生流畅度。
|
|
21
|
+
- **输入框文字跨对话保留**:设置 › 界面 › 新增开关。开启后输入的文字在切换会话时不再清空,可跨对话延续;关闭时各会话草稿严格独立,切回原会话照常恢复。
|
|
22
|
+
- **`browser-use` 插件升级 0.9.0:常驻 Chrome 自动化 + 智能搜索**:
|
|
23
|
+
- 新增 `browser_search` 搜索工具:专用工作标签页隔离、无图极速渲染(CDP 阻断图片/字体/媒体)、搜阅一体(搜索结果与首条正文一次返回)、时效过滤(24 小时 / 周 / 月 / 年)、官网与权威源认证置顶、域名多样性、真实落地页还原与反爬降级链重试;
|
|
24
|
+
- 新增插件设置项:无头模式(默认静默后台运行)、默认搜索引擎、极速搜索、搜索标签页隔离、闲置自动关闭时长;
|
|
25
|
+
- `read_page` 纯净阅读增强(表格转 Markdown、代码语法高亮);后台任务面板统一精确管理,支持一键停止。
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
|
|
29
|
+
- **后台服务误报治理**:新增「创建时序 + 进程链完整性 + 桌面安装路径」三重判定,WPS、腾讯 ima 等随桌面软件启动的常驻进程不再被误判为 AI 拉起,后台服务面板更贴近真实任务(#651)。
|
|
30
|
+
- 消息编辑区的「取消 / 从这条重问」改用标准按钮样式,与其余操作区视觉统一。
|
|
31
|
+
|
|
32
|
+
### Fixed
|
|
33
|
+
|
|
34
|
+
- 会话切换结转草稿时,仅在目标会话没有自己的草稿时才写入,避免覆盖该会话已保留的输入内容。
|
|
35
|
+
|
|
36
|
+
<!-- auto-i18n:start -->
|
|
37
|
+
### i18n
|
|
38
|
+
|
|
39
|
+
- 前端新增 key(30):`preserveDraftAcrossConversations`、`preserveDraftAcrossConversationsDesc`、`reversePagination`、`reversePaginationDesc`、`earlierMessagesInfo`、`loadEarlier`、`loadAllEarlier`、`pluginMenuSettings`、`pluginGroupViews`、`pluginGroupExtensions`、`pluginManagerTitle`、`pluginManagerDesc`、`pluginFilterAll`、`pluginFilterConfigurable`、`pluginFilterEnabled`、`pluginFilterDisabled`、`pluginSearchPlaceholder`、`pluginQuickSettings`、`pluginToggleEnable`、`pluginToggleDisable`、`pluginExpandAll`、`pluginCollapseAll`、`pluginGoMarket`、`pluginCountSummary`、`pluginBadgeConfig`、`pluginBadgeView`、`pluginBadgeBg`、`pluginBadgeTools`、`pluginOpenView`、`pluginEmptyFilter`
|
|
40
|
+
<!-- auto-i18n:end -->
|
|
41
|
+
|
|
11
42
|
## [0.107.0] — 2026-10-18
|
|
12
43
|
|
|
13
44
|
### Added
|
|
@@ -834,15 +865,7 @@
|
|
|
834
865
|
|
|
835
866
|
### Fixed
|
|
836
867
|
|
|
837
|
-
-
|
|
838
|
-
- **排队消息按索引删除**(#200)—— `removeQueued` 按索引删,文本只做回退匹配,重复文本不再连带误删。
|
|
839
|
-
- **更新面板:过时行按钮优先 + git 扩展名填充**(#202)。
|
|
840
|
-
- **↑ 翻历史可靠进入 prompt 历史**;**提交后按时间戳水位丢弃过期草稿**;**switchSession 限定 sessions 根目录**;**折叠控制展开时保持在左侧**。
|
|
841
|
-
- **在资源管理器中显示 / 默认打开不再压住 GUI 窗口**;**git 扩展更新命令加 `git:` 前缀,更新面板隐藏 SHA 并修复横向滚动**。
|
|
842
|
-
- **Windows ConPTY 关停死锁改走外部看门狗**(#215);**心跳定时器 unref,不再阻塞进程退出**。
|
|
843
|
-
- **无挂载 widget 时跳过刷新**(perf);**未知消息类型节流打日志**;**WS maxPayload 对齐 100MB 上限**。
|
|
844
|
-
- **安全**:TLS 下 `pi_web_token` cookie 加 `Secure` 标记;`shell.openExternal` 前做 URL scheme 白名单校验。
|
|
845
|
-
- **设置重载失败打日志**,不再静默吞错。
|
|
868
|
+
- **git 源扩展更新命令补 `git:` 前缀**(P1 TODO 14)—— 更新面板为 git 源扩展生成的命令由 `pi update <host>/<path>` 改为 `pi update git:<host>/<path>`(裸路径会被 pi core 拒绝并提示 `Did you mean git:...?`);已带 `git:` 前缀的输入不会重复加前缀。
|
|
846
869
|
|
|
847
870
|
<!-- auto-i18n:start -->
|
|
848
871
|
|
|
@@ -851,6 +874,7 @@
|
|
|
851
874
|
- 前端新增 key(27):`brandLogo`、`brandName`、`manageProjects`、`projectPickerTitle`、`newProject`、`projectName`、`createAndOpenProject`、`invalidProjectName`、`openProject`、`fileCompress`、`fileExtract`、`fileCompressDownload`、`fileUploadFolder`、`fileChooseFolder`、`fileExtractDestination`、`fileConflictPolicy`、`fileConflictSkip`、`fileConflictOverwrite`、`fileConflictError`、`fileArchiveLimits`、`fileFolderUploadHint`、`fileTransferBusy`、`fileTransferFailed`、`conversationReadEnabledDesc`、`conversationReadOffHint`、`scheduleTaskEnabledDesc`、`scheduleTaskOffHint`
|
|
852
875
|
- 服务端新增 key(9):`sched.not.wired`、`sched.task.bad.schedule`、`sched.task.interval.too.short`、`sched.task.empty.prompt`、`sched.task.no.cwd`、`sched.list.empty`、`sched.cancel.empty.id`、`sched.cancel.not.found`、`sched.cancel.ok`
|
|
853
876
|
|
|
877
|
+
- 前端新增 key(26):`fileCompress`、`fileExtract`、`fileCompressDownload`、`fileUploadFolder`、`fileChooseFolder`、`fileExtractDestination`、`fileConflictPolicy`、`fileConflictSkip`、`fileConflictOverwrite`、`fileConflictError`、`fileArchiveLimits`、`fileFolderUploadHint`、`fileTransferBusy`、`fileTransferFailed`、`tmuxNewWindow`、`tmuxTakeControl`、`tmuxTakeControlShort`、`tmuxRelease`、`tmuxReleaseShort`、`tmuxReadonly`、`tmuxAdopted`、`tmuxDetach`、`tmuxDetachShort`、`tmuxAdoptGroup`、`tmuxAdopt`、`tmuxNoAdoptable`
|
|
854
878
|
<!-- auto-i18n:end -->
|
|
855
879
|
|
|
856
880
|
## [0.89.0] — 2026-09-17
|
|
@@ -1831,7 +1855,8 @@ when?, children?}`,也收 `topbar` / `settings` 这类简写别名);宿主
|
|
|
1831
1855
|
- 0.35.1(2026-08-27):编辑重问保留附件(#18)+ 全窗口拖放(#19)。
|
|
1832
1856
|
- 0.29.0(2026-08-23):全局搜索弹窗(Ctrl+K)+ 消息列表惰性窗口化。
|
|
1833
1857
|
|
|
1834
|
-
[Unreleased]: https://github.com/xing-shuyin/pi-web-ui/compare/v0.
|
|
1858
|
+
[Unreleased]: https://github.com/xing-shuyin/pi-web-ui/compare/v0.108.0...main
|
|
1859
|
+
[0.108.0]: https://github.com/xing-shuyin/pi-web-ui/releases/tag/v0.108.0
|
|
1835
1860
|
[0.103.3]: https://github.com/xing-shuyin/pi-web-ui/releases/tag/v0.103.3
|
|
1836
1861
|
[0.103.2]: https://github.com/xing-shuyin/pi-web-ui/releases/tag/v0.103.2
|
|
1837
1862
|
[0.103.1]: https://github.com/xing-shuyin/pi-web-ui/releases/tag/v0.103.1
|
|
@@ -1853,6 +1878,7 @@ when?, children?}`,也收 `topbar` / `settings` 这类简写别名);宿主
|
|
|
1853
1878
|
[0.90.1]: https://github.com/xing-shuyin/pi-web-ui/releases/tag/v0.90.1
|
|
1854
1879
|
[0.90.0]: https://github.com/xing-shuyin/pi-web-ui/releases/tag/v0.90.0
|
|
1855
1880
|
[0.89.0]: https://github.com/xing-shuyin/pi-web-ui/releases/tag/v0.89.0
|
|
1881
|
+
[Unreleased]: https://github.com/xing-shuyin/pi-web-ui/compare/v0.88.0...main
|
|
1856
1882
|
[0.88.0]: https://github.com/xing-shuyin/pi-web-ui/releases/tag/v0.88.0
|
|
1857
1883
|
[0.87.2]: https://github.com/xing-shuyin/pi-web-ui/releases/tag/v0.87.2
|
|
1858
1884
|
[0.87.1]: https://github.com/xing-shuyin/pi-web-ui/releases/tag/v0.87.1
|
|
@@ -148,13 +148,28 @@ export function contentFingerprint(m) {
|
|
|
148
148
|
if (first?.type === "image") {
|
|
149
149
|
return `img:${(first.data ?? "").length}`;
|
|
150
150
|
}
|
|
151
|
-
|
|
151
|
+
if (first?.type === "toolCall") {
|
|
152
|
+
if (typeof first?.id === "string" && first.id.length > 0)
|
|
153
|
+
return `tc:${first.id}`;
|
|
154
|
+
return `tc:${first?.name ?? ""}`;
|
|
155
|
+
}
|
|
156
|
+
// Ported from fork fix(cache): type-aware contentFingerprint (949a8bd):
|
|
157
|
+
// thinking-first blocks hash their thinking text (they carry no .text —
|
|
158
|
+
// else all collide as txt:45h:0). Per-type prefix keeps old txt: keys stable.
|
|
159
|
+
const tag = first?.type === "thinking" ? "thk" : "txt";
|
|
160
|
+
const s = tag === "thk"
|
|
161
|
+
? typeof first?.thinking === "string"
|
|
162
|
+
? first.thinking
|
|
163
|
+
: ""
|
|
164
|
+
: typeof first?.text === "string"
|
|
165
|
+
? first.text
|
|
166
|
+
: "";
|
|
152
167
|
// djb2 — fast enough to run per snapshot, distinct enough for asides.
|
|
153
168
|
let h = 5381;
|
|
154
|
-
for (let i = 0; i <
|
|
155
|
-
h = ((h << 5) + h +
|
|
169
|
+
for (let i = 0; i < s.length && i < 512; i++) {
|
|
170
|
+
h = ((h << 5) + h + s.charCodeAt(i)) >>> 0;
|
|
156
171
|
}
|
|
157
|
-
return
|
|
172
|
+
return `${tag}:${h.toString(36)}:${s.length}`;
|
|
158
173
|
}
|
|
159
174
|
export function extractPartialText(partial) {
|
|
160
175
|
const content = partial?.content;
|
|
@@ -290,6 +290,7 @@ export class ClientSession {
|
|
|
290
290
|
pluginTasks: () => this.pluginBgTasksProvider?.() ?? [],
|
|
291
291
|
// 「自动清理遗留实例」阈值(分钟;0 = 关):每轮定时器实时读设置。
|
|
292
292
|
cleanupMinutes: () => this.settingsSvc.current.bgAutoCleanupMin ?? 0,
|
|
293
|
+
workspaceCwd: () => this.convs.get(this.activeId)?.cwd ?? this.cwd,
|
|
293
294
|
});
|
|
294
295
|
/** index.ts 注入(经 AgentService 拷贝到每个新会话):把 SDK 工具执行事件转发给
|
|
295
296
|
* 插件(PluginManager.emitToolEvent)。未设置时不做任何事。 */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { killPidTree,
|
|
1
|
+
import { killPidTree, lookupProcessDetailsBatch, snapshotListeningPorts, snapshotProcessTree, } from "./process-utils.js";
|
|
2
2
|
const BG_REFRESH_INTERVAL_MS = 30_000;
|
|
3
3
|
/** bash 结束后等这么久再拍「后」快照——给后台服务绑定端口的时间。 */
|
|
4
4
|
const BG_BIND_WAIT_MS = 1500;
|
|
@@ -20,11 +20,20 @@ export function staleLeftovers(entries, opts) {
|
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
22
|
* 基本不可能由 AI 启动的常驻桌面软件进程名(小写)。命中即跳过,避免面板被
|
|
23
|
-
* 微信/QQ 等本地软件的动态监听端口污染。注意 Chrome 不进黑名单:AI 会用
|
|
23
|
+
* 微信/QQ/WPS/ima 等本地软件的动态监听端口污染。注意 Chrome 不进黑名单:AI 会用
|
|
24
24
|
* Playwright 拉浏览器做模拟,它靠下方父链回溯判定(Playwright 起的 chrome
|
|
25
25
|
* 能回溯到服务器进程,自己开的 chrome 父链是 explorer,分得开)。
|
|
26
26
|
*/
|
|
27
27
|
export const NON_AGENT_PROCESS_NAMES = new Set([
|
|
28
|
+
// 办公与知识库(Issue #651:WPS、腾讯 ima.copilot 等)
|
|
29
|
+
"wps.exe",
|
|
30
|
+
"wpscenter.exe",
|
|
31
|
+
"ksoqing.exe",
|
|
32
|
+
"ksolaunch.exe",
|
|
33
|
+
"wpscloudsvr.exe",
|
|
34
|
+
"ima.copilot.exe",
|
|
35
|
+
"ima.exe",
|
|
36
|
+
// 即时通讯与社交
|
|
28
37
|
"wechat.exe",
|
|
29
38
|
"weixin.exe",
|
|
30
39
|
"wechatappex.exe",
|
|
@@ -32,6 +41,7 @@ export const NON_AGENT_PROCESS_NAMES = new Set([
|
|
|
32
41
|
"tim.exe",
|
|
33
42
|
"telegram.exe",
|
|
34
43
|
"dingtalk.exe",
|
|
44
|
+
// 系统外壳与基础设施
|
|
35
45
|
"explorer.exe",
|
|
36
46
|
"searchhost.exe",
|
|
37
47
|
"searchapp.exe",
|
|
@@ -40,43 +50,176 @@ export const NON_AGENT_PROCESS_NAMES = new Set([
|
|
|
40
50
|
"dwm.exe",
|
|
41
51
|
"csrss.exe",
|
|
42
52
|
"conhost.exe",
|
|
53
|
+
"sihost.exe",
|
|
54
|
+
"taskhostw.exe",
|
|
55
|
+
"services.exe",
|
|
56
|
+
"shellexperiencehost.exe",
|
|
57
|
+
"startmenuexperiencehost.exe",
|
|
58
|
+
]);
|
|
59
|
+
/**
|
|
60
|
+
* 桌面外壳与系统服务进程名(小写)。
|
|
61
|
+
* 祖先回溯时如果撞上这些进程,说明该进程是由桌面 GUI、开始菜单或系统服务启动的,
|
|
62
|
+
* 绝不可能由当前 CLI / Node.js 进程在后台拉起。
|
|
63
|
+
*/
|
|
64
|
+
export const SHELL_OR_SYSTEM_PROCESS_NAMES = new Set([
|
|
65
|
+
"explorer.exe",
|
|
66
|
+
"winlogon.exe",
|
|
67
|
+
"services.exe",
|
|
68
|
+
"dwm.exe",
|
|
69
|
+
"taskhostw.exe",
|
|
70
|
+
"sihost.exe",
|
|
71
|
+
"svchost.exe",
|
|
72
|
+
"shellexperiencehost.exe",
|
|
73
|
+
"startmenuexperiencehost.exe",
|
|
74
|
+
"system",
|
|
75
|
+
]);
|
|
76
|
+
/**
|
|
77
|
+
* 典型的 AI / 开发者开发服务运行时进程名(小写)。
|
|
78
|
+
* 在发生中途断链(父进程已退出)时作为启发式白名单校验依据。
|
|
79
|
+
*/
|
|
80
|
+
export const DEV_RUNTIME_PROCESS_NAMES = new Set([
|
|
81
|
+
"node.exe",
|
|
82
|
+
"node",
|
|
83
|
+
"python.exe",
|
|
84
|
+
"python",
|
|
85
|
+
"python3.exe",
|
|
86
|
+
"python3",
|
|
87
|
+
"deno.exe",
|
|
88
|
+
"deno",
|
|
89
|
+
"bun.exe",
|
|
90
|
+
"bun",
|
|
91
|
+
"ruby.exe",
|
|
92
|
+
"ruby",
|
|
93
|
+
"go.exe",
|
|
94
|
+
"go",
|
|
95
|
+
"java.exe",
|
|
96
|
+
"java",
|
|
97
|
+
"dotnet.exe",
|
|
98
|
+
"dotnet",
|
|
99
|
+
"php.exe",
|
|
100
|
+
"php",
|
|
101
|
+
"cargo.exe",
|
|
102
|
+
"cargo",
|
|
103
|
+
"uvicorn.exe",
|
|
104
|
+
"uvicorn",
|
|
105
|
+
"gunicorn",
|
|
106
|
+
"vite.exe",
|
|
107
|
+
"vite",
|
|
108
|
+
"flask.exe",
|
|
109
|
+
"flask",
|
|
43
110
|
]);
|
|
44
111
|
/**
|
|
45
112
|
* 判定 bash 后新出现的监听端口进程是否该记入后台任务列表(即「AI 启动的」)。
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* -
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
113
|
+
*
|
|
114
|
+
* 判定规则(三重防护):
|
|
115
|
+
* 1. 【时序防线(CreationDate)】如果进程启动时间早于 bash 启动时刻(留 2s 容差),
|
|
116
|
+
* 说明该进程在 bash 执行前就已存在,100% 为外部已有应用(如提前开着的 WPS、ima、游戏),跳过;
|
|
117
|
+
* 2. 【进程名与黑名单】命中 NON_AGENT_PROCESS_NAMES(如 wps.exe、ima.copilot.exe、wechat.exe),跳过;
|
|
118
|
+
* 3. 【祖先链追溯】
|
|
119
|
+
* - 撞上服务器进程(serverPid)→ 记录(铁证);
|
|
120
|
+
* - 撞上桌面 Shell 或系统服务(explorer.exe / services.exe 等)→ 跳过;
|
|
121
|
+
* - 撞上本次 diff 出的其他新 pid(如 concurrently 等中间层)→ 记录并继续向上回溯;
|
|
122
|
+
* - 完整回溯到系统根(0/1)未命中 serverPid → 跳过;
|
|
123
|
+
* 4. 【断链安全底线】中途断链(父进程已退出,常见于 nohup 或 Windows launcher):
|
|
124
|
+
* - 具备明确开发特征(DEV_RUNTIME_PROCESS_NAMES 或命令行/路径包含工作区)才予收录;
|
|
125
|
+
* - 未知可执行文件或桌面安装目录应用(如 Program Files)坚决跳过,杜绝误杀用户正常程序。
|
|
57
126
|
*/
|
|
58
|
-
export function shouldTrackBackgroundServer(pid, parents, newPids, serverPid, name) {
|
|
59
|
-
|
|
127
|
+
export function shouldTrackBackgroundServer(pid, parents, newPids, serverPid, name, opts) {
|
|
128
|
+
const lowerName = name?.toLowerCase();
|
|
129
|
+
// 1. 命中黑名单 → 跳过
|
|
130
|
+
if (lowerName && NON_AGENT_PROCESS_NAMES.has(lowerName))
|
|
60
131
|
return false;
|
|
61
|
-
|
|
62
|
-
|
|
132
|
+
// 2. 时序防护:早于 bash 开始时刻创建的进程绝不可能是本次命令拉起的新任务。
|
|
133
|
+
if (typeof opts?.startedBeforeMs === "number" &&
|
|
134
|
+
opts.startedBeforeMs > 0 &&
|
|
135
|
+
typeof opts.createdMs === "number" &&
|
|
136
|
+
opts.createdMs > 0) {
|
|
137
|
+
// 允许 2000ms 的时钟抖动/快照耗时容差
|
|
138
|
+
if (opts.createdMs < opts.startedBeforeMs - 2000) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
// 3. 命令行路径防范:如果可执行路径明显指向普通桌面安装目录(如 Program Files / AppData Local Programs)
|
|
143
|
+
// 且不是开发工具链运行时,跳过
|
|
144
|
+
if (opts?.commandLine) {
|
|
145
|
+
const lowerCmd = opts.commandLine.toLowerCase();
|
|
146
|
+
const isDevRuntime = lowerName ? DEV_RUNTIME_PROCESS_NAMES.has(lowerName) : false;
|
|
147
|
+
if (!isDevRuntime) {
|
|
148
|
+
const isDesktopPath = lowerCmd.includes("\\program files") ||
|
|
149
|
+
lowerCmd.includes("/program files") ||
|
|
150
|
+
lowerCmd.includes("\\appdata\\local\\programs\\") ||
|
|
151
|
+
lowerCmd.includes("/appdata/local/programs/");
|
|
152
|
+
if (isDesktopPath) {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
// 4. 进程树查不到时:降级为保守记录(保持现有纯单测行为)
|
|
158
|
+
if (!parents) {
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
// 5. 向上回溯父链
|
|
63
162
|
const seen = new Set();
|
|
64
163
|
let cur = pid;
|
|
164
|
+
let brokenAt;
|
|
65
165
|
while (cur !== undefined && !seen.has(cur)) {
|
|
66
166
|
seen.add(cur);
|
|
67
167
|
if (cur === serverPid)
|
|
68
168
|
return true;
|
|
69
169
|
if (cur !== pid && newPids.has(cur))
|
|
70
170
|
return true;
|
|
71
|
-
const
|
|
171
|
+
const parentEntry = parents.get(cur);
|
|
172
|
+
let next;
|
|
173
|
+
let parentName;
|
|
174
|
+
if (typeof parentEntry === "object" && parentEntry !== null) {
|
|
175
|
+
next = parentEntry.ppid;
|
|
176
|
+
parentName = parentEntry.name;
|
|
177
|
+
}
|
|
178
|
+
else if (typeof parentEntry === "number") {
|
|
179
|
+
next = parentEntry;
|
|
180
|
+
}
|
|
181
|
+
// 检查当前祖先节点是否命中桌面外壳或系统服务
|
|
182
|
+
if (parentName) {
|
|
183
|
+
const lowerParent = parentName.toLowerCase();
|
|
184
|
+
if (SHELL_OR_SYSTEM_PROCESS_NAMES.has(lowerParent) || NON_AGENT_PROCESS_NAMES.has(lowerParent)) {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
72
188
|
if (next === undefined) {
|
|
73
|
-
// 到达系统根(0
|
|
74
|
-
|
|
189
|
+
// 到达系统根(0 或 1)→ 完整链,非 AI 启动
|
|
190
|
+
if (cur <= 1)
|
|
191
|
+
return false;
|
|
192
|
+
// 中途断链:父进程已退出
|
|
193
|
+
brokenAt = cur;
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
if (next === cur) {
|
|
197
|
+
// 自引用根,视为完整链终点
|
|
198
|
+
return false;
|
|
75
199
|
}
|
|
76
|
-
if (next === cur)
|
|
77
|
-
return false; // 自引用根,同样视为完整链终点
|
|
78
200
|
cur = next;
|
|
79
201
|
}
|
|
202
|
+
// 6. 断链处理(brokenAt !== undefined)
|
|
203
|
+
if (brokenAt !== undefined) {
|
|
204
|
+
// 如果未传 opts 且未传 name(保持现有纯断链单测的向后兼容)
|
|
205
|
+
if (!opts && !name) {
|
|
206
|
+
return true;
|
|
207
|
+
}
|
|
208
|
+
// 具备明确开发运行时特征(node, python 等)才予收录
|
|
209
|
+
if (lowerName && DEV_RUNTIME_PROCESS_NAMES.has(lowerName)) {
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
212
|
+
// 命令行包含当前工作区路径时收录
|
|
213
|
+
if (opts?.workspaceCwd && opts.commandLine) {
|
|
214
|
+
const normalizedCwd = opts.workspaceCwd.toLowerCase().replace(/\\/g, "/");
|
|
215
|
+
const normalizedCmd = opts.commandLine.toLowerCase().replace(/\\/g, "/");
|
|
216
|
+
if (normalizedCmd.includes(normalizedCwd)) {
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
// 默认断链不再盲目信任,防止误杀外部软件
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
80
223
|
return false;
|
|
81
224
|
}
|
|
82
225
|
export class BgServerTracker {
|
|
@@ -90,6 +233,7 @@ export class BgServerTracker {
|
|
|
90
233
|
* 读到 null 直接漏记,延迟解析的旧快照还会污染下一轮)。
|
|
91
234
|
*/
|
|
92
235
|
listenBefore = null;
|
|
236
|
+
listenBeforeTime = 0;
|
|
93
237
|
refreshTimer = null;
|
|
94
238
|
constructor(opts) {
|
|
95
239
|
this.opts = opts;
|
|
@@ -113,9 +257,12 @@ export class BgServerTracker {
|
|
|
113
257
|
this.refreshTimer = null;
|
|
114
258
|
}
|
|
115
259
|
}
|
|
116
|
-
/** tool_execution_start(bash)
|
|
260
|
+
/** tool_execution_start(bash):先记下「前」快照(快照在途时保留最早的一份与启动时间)。 */
|
|
117
261
|
snapshotBefore() {
|
|
118
|
-
this.listenBefore
|
|
262
|
+
if (!this.listenBefore) {
|
|
263
|
+
this.listenBeforeTime = Date.now();
|
|
264
|
+
this.listenBefore = snapshotListeningPorts();
|
|
265
|
+
}
|
|
119
266
|
}
|
|
120
267
|
/** After a bash tool run, wait briefly for background servers to bind,
|
|
121
268
|
* then diff the listening-port snapshot against the pre-run one and
|
|
@@ -124,7 +271,9 @@ export class BgServerTracker {
|
|
|
124
271
|
// 读后清槽:await in-flight 快照(消除 fire-and-forget 的时序竞态),
|
|
125
272
|
// 并发 bash 共用这份最早的基线,各自结束都能对得上。
|
|
126
273
|
const beforePromise = this.listenBefore;
|
|
274
|
+
const beforeTime = this.listenBeforeTime;
|
|
127
275
|
this.listenBefore = null;
|
|
276
|
+
this.listenBeforeTime = 0;
|
|
128
277
|
if (!beforePromise)
|
|
129
278
|
return;
|
|
130
279
|
const before = await beforePromise;
|
|
@@ -138,30 +287,19 @@ export class BgServerTracker {
|
|
|
138
287
|
}
|
|
139
288
|
if (fresh.length === 0)
|
|
140
289
|
return;
|
|
141
|
-
//
|
|
142
|
-
const keep = await this.filterAgentSpawned(fresh);
|
|
290
|
+
// 剔除桌面软件误报(微信/WPS/ima 等)后,剩下的才是 AI 启动的后台服务。
|
|
291
|
+
const keep = await this.filterAgentSpawned(fresh, beforeTime);
|
|
143
292
|
let added = false;
|
|
144
|
-
for (const { port, pid } of keep) {
|
|
293
|
+
for (const { port, pid, name, command } of keep) {
|
|
145
294
|
if (this.servers.has(port))
|
|
146
295
|
continue;
|
|
147
|
-
this.servers.set(port, {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
const cur = this.servers.get(port);
|
|
153
|
-
if (cur && cur.pid === pid && name) {
|
|
154
|
-
cur.name = name;
|
|
155
|
-
this.push();
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
void lookupProcessCommandLine(pid).then((command) => {
|
|
159
|
-
const cur = this.servers.get(port);
|
|
160
|
-
if (cur && cur.pid === pid && command) {
|
|
161
|
-
cur.command = command;
|
|
162
|
-
this.push();
|
|
163
|
-
}
|
|
296
|
+
this.servers.set(port, {
|
|
297
|
+
pid,
|
|
298
|
+
since: Date.now(),
|
|
299
|
+
...(name ? { name } : {}),
|
|
300
|
+
...(command ? { command } : {}),
|
|
164
301
|
});
|
|
302
|
+
added = true;
|
|
165
303
|
this.opts.emit({
|
|
166
304
|
type: "notice",
|
|
167
305
|
level: "info",
|
|
@@ -172,16 +310,30 @@ export class BgServerTracker {
|
|
|
172
310
|
if (added)
|
|
173
311
|
this.push();
|
|
174
312
|
}
|
|
175
|
-
/**
|
|
176
|
-
async filterAgentSpawned(fresh) {
|
|
177
|
-
const
|
|
178
|
-
const
|
|
179
|
-
const newPids = new Set(
|
|
313
|
+
/** 并行拉进程树与各进程详情,用时序防线 + 黑名单 + 父链回溯剔除桌面软件误报。 */
|
|
314
|
+
async filterAgentSpawned(fresh, beforeTime) {
|
|
315
|
+
const pids = [...new Set(fresh.map((f) => f.pid))];
|
|
316
|
+
const [tree, detailsMap] = await Promise.all([snapshotProcessTree(), lookupProcessDetailsBatch(pids)]);
|
|
317
|
+
const newPids = new Set(pids);
|
|
318
|
+
const cwd = this.opts.workspaceCwd?.();
|
|
180
319
|
const out = [];
|
|
181
|
-
for (
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
320
|
+
for (const { port, pid } of fresh) {
|
|
321
|
+
const details = detailsMap.get(pid);
|
|
322
|
+
const name = details?.name;
|
|
323
|
+
const command = details?.commandLine;
|
|
324
|
+
const should = shouldTrackBackgroundServer(pid, tree, newPids, process.pid, name, {
|
|
325
|
+
commandLine: command,
|
|
326
|
+
createdMs: details?.createdMs,
|
|
327
|
+
startedBeforeMs: beforeTime > 0 ? beforeTime : undefined,
|
|
328
|
+
workspaceCwd: cwd,
|
|
329
|
+
});
|
|
330
|
+
if (should) {
|
|
331
|
+
out.push({
|
|
332
|
+
port,
|
|
333
|
+
pid,
|
|
334
|
+
...(name ? { name } : {}),
|
|
335
|
+
...(command ? { command } : {}),
|
|
336
|
+
});
|
|
185
337
|
}
|
|
186
338
|
}
|
|
187
339
|
return out;
|
|
@@ -846,6 +846,7 @@ export class ClientStateStore {
|
|
|
846
846
|
toolsWrap: stored?.toolsWrap ?? true,
|
|
847
847
|
toolImagesEnabled: stored?.toolImagesEnabled ?? true,
|
|
848
848
|
keepRecentMessages: normalizeKeepRecentMessages(stored?.keepRecentMessages),
|
|
849
|
+
reversePagination: stored?.reversePagination ?? false,
|
|
849
850
|
showForkedParentSessions: stored?.showForkedParentSessions ?? false,
|
|
850
851
|
retainFinishedConversations: stored?.retainFinishedConversations ?? false,
|
|
851
852
|
openRecentSessionOnProjectSwitch: stored?.openRecentSessionOnProjectSwitch ?? true,
|
|
@@ -865,6 +866,7 @@ export class ClientStateStore {
|
|
|
865
866
|
quickPhrases: stored?.quickPhrases ?? [],
|
|
866
867
|
quickPhrasesEnabled: stored?.quickPhrasesEnabled ?? true,
|
|
867
868
|
minimalNewChat: stored?.minimalNewChat ?? false,
|
|
869
|
+
preserveDraftAcrossConversations: stored?.preserveDraftAcrossConversations ?? false,
|
|
868
870
|
reviewPrompt: stored?.reviewPrompt ?? "",
|
|
869
871
|
reviewDisabledSkills: stored?.reviewDisabledSkills ?? [],
|
|
870
872
|
disabledPlugins: stored?.disabledPlugins ?? [],
|
|
@@ -913,6 +915,7 @@ export class ClientStateStore {
|
|
|
913
915
|
toolsWrap: settings.toolsWrap ?? cur.toolsWrap ?? true,
|
|
914
916
|
toolImagesEnabled: settings.toolImagesEnabled ?? cur.toolImagesEnabled ?? true,
|
|
915
917
|
keepRecentMessages: normalizeKeepRecentMessages(settings.keepRecentMessages ?? cur.keepRecentMessages ?? DEFAULT_KEEP_RECENT_MESSAGES),
|
|
918
|
+
reversePagination: settings.reversePagination ?? cur.reversePagination ?? false,
|
|
916
919
|
showForkedParentSessions: settings.showForkedParentSessions ?? cur.showForkedParentSessions ?? false,
|
|
917
920
|
retainFinishedConversations: settings.retainFinishedConversations ?? cur.retainFinishedConversations ?? false,
|
|
918
921
|
openRecentSessionOnProjectSwitch: settings.openRecentSessionOnProjectSwitch ?? cur.openRecentSessionOnProjectSwitch ?? true,
|
|
@@ -941,6 +944,7 @@ export class ClientStateStore {
|
|
|
941
944
|
quickPhrases: settings.quickPhrases ?? cur.quickPhrases ?? [],
|
|
942
945
|
quickPhrasesEnabled: settings.quickPhrasesEnabled ?? cur.quickPhrasesEnabled ?? true,
|
|
943
946
|
minimalNewChat: settings.minimalNewChat ?? cur.minimalNewChat ?? false,
|
|
947
|
+
preserveDraftAcrossConversations: settings.preserveDraftAcrossConversations ?? cur.preserveDraftAcrossConversations ?? false,
|
|
944
948
|
defaultAgentPreset: settings.defaultAgentPreset ?? cur.defaultAgentPreset ?? "standard",
|
|
945
949
|
defaultPermissionPreset: settings.defaultPermissionPreset ?? cur.defaultPermissionPreset ?? "workspace-write-never",
|
|
946
950
|
};
|
|
@@ -615,6 +615,8 @@ export function handleSettingsMessage(msg, cs) {
|
|
|
615
615
|
quickPhrases: msg.quickPhrases,
|
|
616
616
|
quickPhrasesEnabled: msg.quickPhrasesEnabled,
|
|
617
617
|
minimalNewChat: msg.minimalNewChat,
|
|
618
|
+
preserveDraftAcrossConversations: msg
|
|
619
|
+
.preserveDraftAcrossConversations,
|
|
618
620
|
quickPhrasesSeeded: msg.quickPhrasesSeeded,
|
|
619
621
|
uiLayout: msg.uiLayout,
|
|
620
622
|
});
|
|
@@ -48,6 +48,7 @@ import { checkAll as checkAllUpdates, collectTargets, resolveNpmRegistry } from
|
|
|
48
48
|
import { collectInstalledEngineTargets } from "../engine-probe.js";
|
|
49
49
|
import { previewKind } from "../text-sniff.js";
|
|
50
50
|
import { removeQueuedByIndexOrText } from "../queue-utils.js";
|
|
51
|
+
import { ensureCredentialFilePermissions } from "../model-admin.js";
|
|
51
52
|
import { launchOrigin, toServiceInfo } from "../launch-origin.js";
|
|
52
53
|
import { DshRuntime, loadDeepSeekKey } from "./dsh-client.js";
|
|
53
54
|
import { resolveProviderCredential, listCustomModelsFromConfig, isModelProtocolSupportedByEngine, } from "../model-resolver.js";
|
|
@@ -159,6 +160,7 @@ const DEFAULT_SETTINGS = {
|
|
|
159
160
|
quickPhrases: [],
|
|
160
161
|
quickPhrasesEnabled: true,
|
|
161
162
|
minimalNewChat: false,
|
|
163
|
+
preserveDraftAcrossConversations: false,
|
|
162
164
|
promptTemplate: "",
|
|
163
165
|
promptOverrides: {},
|
|
164
166
|
};
|
|
@@ -257,6 +259,7 @@ export class DshClientSession {
|
|
|
257
259
|
this.roots = stateStore.getWorkspaceRoots(clientId, cwd);
|
|
258
260
|
this.dataDir = dataDir;
|
|
259
261
|
this.agentDir = agentDir;
|
|
262
|
+
ensureCredentialFilePermissions(this.agentDir);
|
|
260
263
|
this.sessionRoot = dshSessionRoot(dataDir);
|
|
261
264
|
this.sandboxes = new SandboxManager(dataDir);
|
|
262
265
|
try {
|
|
@@ -284,6 +287,7 @@ export class DshClientSession {
|
|
|
284
287
|
isDisposed: () => this.disposed,
|
|
285
288
|
pluginTasks: () => this.pluginBgTasksProvider?.() ?? [],
|
|
286
289
|
cleanupMinutes: () => Number(this.settings.bgAutoCleanupMin ?? 0),
|
|
290
|
+
workspaceCwd: () => this.cwd,
|
|
287
291
|
});
|
|
288
292
|
this.markerSvc = new MarkerService({
|
|
289
293
|
clientId,
|
|
@@ -352,6 +356,7 @@ export class DshClientSession {
|
|
|
352
356
|
quickPhrases: savedSettings.quickPhrases ?? [],
|
|
353
357
|
quickPhrasesEnabled: savedSettings.quickPhrasesEnabled ?? true,
|
|
354
358
|
minimalNewChat: savedSettings.minimalNewChat ?? false,
|
|
359
|
+
preserveDraftAcrossConversations: savedSettings.preserveDraftAcrossConversations ?? false,
|
|
355
360
|
promptTemplate: savedSettings.promptTemplate ?? "",
|
|
356
361
|
promptOverrides: savedSettings.promptOverrides ?? {},
|
|
357
362
|
defaultAgentPreset: savedSettings.defaultAgentPreset ?? PRESET_DEFAULT_ID,
|
|
@@ -3608,6 +3613,7 @@ export class DshClientSession {
|
|
|
3608
3613
|
quickPhrases: [...this.settings.quickPhrases],
|
|
3609
3614
|
quickPhrasesEnabled: this.settings.quickPhrasesEnabled,
|
|
3610
3615
|
minimalNewChat: this.settings.minimalNewChat,
|
|
3616
|
+
preserveDraftAcrossConversations: this.settings.preserveDraftAcrossConversations ?? false,
|
|
3611
3617
|
quickPhrasesSeeded: this.stateStore.getQuickPhrasesSeeded(),
|
|
3612
3618
|
};
|
|
3613
3619
|
this.emit({ type: "settings_state", settings });
|
|
@@ -3680,6 +3686,8 @@ export class DshClientSession {
|
|
|
3680
3686
|
this.settings.quickPhrasesEnabled = partial.quickPhrasesEnabled;
|
|
3681
3687
|
if (partial.minimalNewChat !== undefined)
|
|
3682
3688
|
this.settings.minimalNewChat = partial.minimalNewChat;
|
|
3689
|
+
if (partial.preserveDraftAcrossConversations !== undefined)
|
|
3690
|
+
this.settings.preserveDraftAcrossConversations = partial.preserveDraftAcrossConversations;
|
|
3683
3691
|
const prevMarkerGuidance = this.markerSvc.buildGuidance();
|
|
3684
3692
|
this.markerSvc.setAll({
|
|
3685
3693
|
markersEnabled: partial.markersEnabled,
|
|
@@ -3719,6 +3727,7 @@ export class DshClientSession {
|
|
|
3719
3727
|
quickPhrases: this.settings.quickPhrases,
|
|
3720
3728
|
quickPhrasesEnabled: this.settings.quickPhrasesEnabled,
|
|
3721
3729
|
minimalNewChat: this.settings.minimalNewChat,
|
|
3730
|
+
preserveDraftAcrossConversations: this.settings.preserveDraftAcrossConversations,
|
|
3722
3731
|
defaultAgentPreset: this.settings.defaultAgentPreset,
|
|
3723
3732
|
promptTemplate: this.settings.promptTemplate ?? "",
|
|
3724
3733
|
promptOverrides: this.settings.promptOverrides ?? {},
|
|
@@ -832,7 +832,7 @@ export class FilesService {
|
|
|
832
832
|
const kind = previewKind(name);
|
|
833
833
|
// Media previews stream over the /api/file HTTP endpoint, so only
|
|
834
834
|
// metadata is sent here — the raw bytes never touch the socket.
|
|
835
|
-
if (kind === "image" || kind === "video") {
|
|
835
|
+
if (kind === "image" || kind === "video" || kind === "audio") {
|
|
836
836
|
this.host.emit({
|
|
837
837
|
type: "file_content",
|
|
838
838
|
path: rel,
|
|
@@ -1827,6 +1827,20 @@ export class FilesService {
|
|
|
1827
1827
|
catch { }
|
|
1828
1828
|
}
|
|
1829
1829
|
const kind = previewKind(name);
|
|
1830
|
+
if (kind === "image" || kind === "video" || kind === "audio") {
|
|
1831
|
+
this.host.emit({
|
|
1832
|
+
type: "file_content",
|
|
1833
|
+
path: t.rel,
|
|
1834
|
+
name,
|
|
1835
|
+
text: "",
|
|
1836
|
+
truncated: false,
|
|
1837
|
+
binary: true,
|
|
1838
|
+
kind,
|
|
1839
|
+
lines: 0,
|
|
1840
|
+
size: st.size,
|
|
1841
|
+
});
|
|
1842
|
+
return;
|
|
1843
|
+
}
|
|
1830
1844
|
const { data, size } = await sshSvc.sftpReadFile(rawCwd, t.abs, MAX_PREVIEW_BYTES);
|
|
1831
1845
|
if (looksLikeText(data)) {
|
|
1832
1846
|
this.host.emit({
|