pi-web-ui 0.107.0 → 0.109.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 +59 -10
- package/dist/server/agent-formatters.js +19 -4
- package/dist/server/agent-service.js +28 -6
- package/dist/server/bg-servers.js +205 -53
- package/dist/server/client-state.js +8 -3
- package/dist/server/dispatch-domain-handlers.js +2 -0
- package/dist/server/dsh/dsh-agent-service.js +11 -2
- 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 +7 -3
- package/dist/server/text-sniff.js +2 -0
- package/dist/server/universal/universal-session.js +4 -1
- package/package.json +2 -1
- package/themes/aetheris.css +6 -3
- package/themes/ayu-light.css +19 -15
- package/themes/catppuccin-latte.css +17 -15
- package/themes/catppuccin.css +5 -2
- package/themes/claude-code-dark.css +2 -0
- package/themes/codex.css +16 -14
- package/themes/cyberpunk.css +4 -1
- package/themes/dark-teal.css +4 -1
- package/themes/dazzle.css +3 -0
- package/themes/everforest-light.css +17 -15
- package/themes/flow-light.css +8 -6
- package/themes/flow.css +12 -10
- package/themes/geist.css +16 -14
- package/themes/gruvbox-light.css +13 -11
- package/themes/kanagawa-lotus.css +16 -14
- package/themes/mist.css +18 -16
- package/themes/nord.css +16 -12
- package/themes/one-dark.css +9 -5
- package/themes/paper.css +9 -7
- package/themes/rose-pine-dawn.css +14 -12
- package/themes/sakura.css +15 -13
- package/themes/solarized-light.css +19 -17
- package/themes/tokyo-night.css +4 -2
- package/themes/vs-code-dark.css +4 -3
- package/themes/wallpaper-flow.css +2 -0
- package/themes/wallpaper-obsidian.css +3 -0
- package/themes/white.css +8 -6
- package/themes/zhujian-dark.css +5 -3
- package/themes/zhujian.css +5 -3
- package/themes/zhupi-dark.css +5 -3
- package/themes/zhupi.css +5 -3
- package/web/dist/assets/{TerminalPanel-BnViyTlx.js → TerminalPanel-BD3a9o-a.js} +1 -1
- package/web/dist/assets/index-AccytlpP.css +1 -0
- package/web/dist/assets/index-B3dar1BK.js +690 -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
|
@@ -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,
|
|
@@ -3542,8 +3547,8 @@ export class DshClientSession {
|
|
|
3542
3547
|
// DSH 引擎无 customTool 注册面(工具来自 shipped preset),read 目录覆盖面不存在。
|
|
3543
3548
|
readDirEnabled: true,
|
|
3544
3549
|
bgAutoCleanupMin: Number(this.settings.bgAutoCleanupMin ?? 0),
|
|
3545
|
-
// DSH 无 pi
|
|
3546
|
-
toolLazyLoading:
|
|
3550
|
+
// DSH 无 pi 工具注册面,不适用延迟加载;保协议完整(该字段恒为 false,设置页不显示这一行)。
|
|
3551
|
+
toolLazyLoading: false,
|
|
3547
3552
|
codemodeMode: "on",
|
|
3548
3553
|
codemodeInlineBudget: 3000,
|
|
3549
3554
|
editSoftEnabled: this.settings.editSoftEnabled,
|
|
@@ -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({
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* 经 ModelAdminHost 与 ClientSession 解耦(同 settings/goal/slash 服务模式)。
|
|
12
12
|
* UI 文案直接中文(服务端 notice 约定)。apiKey/headers 绝不下发浏览器。
|
|
13
13
|
*/
|
|
14
|
-
import { existsSync, mkdirSync, readFileSync, renameSync } from "node:fs";
|
|
14
|
+
import { chmodSync, existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
15
15
|
import { dirname, join } from "node:path";
|
|
16
16
|
import { writeJsonAtomicSync } from "./atomic-file.js";
|
|
17
17
|
import { enrichBatch } from "./model-enrich.js";
|
|
@@ -70,6 +70,17 @@ export function graduateOverlayModels(providers, official) {
|
|
|
70
70
|
function atomicWriteJson(path, data) {
|
|
71
71
|
writeJsonAtomicSync(path, data);
|
|
72
72
|
}
|
|
73
|
+
/** 原子写凭据 JSON 并修权限 0600(port from fork 50e723f,保留上游原子写语义)。
|
|
74
|
+
* chmod 覆盖已存在文件(mode 选项只对新建有效)。Windows 下尽力而为。 */
|
|
75
|
+
function atomicWriteCredentialJson(path, data) {
|
|
76
|
+
writeJsonAtomicSync(path, data);
|
|
77
|
+
try {
|
|
78
|
+
chmodSync(path, CREDENTIAL_FILE_MODE);
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
/* best-effort (win) */
|
|
82
|
+
}
|
|
83
|
+
}
|
|
73
84
|
/** Strip // and /* *\/ comments without touching string literals (URLs contain //). */
|
|
74
85
|
function stripJsonComments(src) {
|
|
75
86
|
let out = "";
|
|
@@ -247,12 +258,40 @@ function parseGoogleModel(m) {
|
|
|
247
258
|
...(numMeta(r.outputTokenLimit) ? { maxTokens: numMeta(r.outputTokenLimit) } : {}),
|
|
248
259
|
};
|
|
249
260
|
}
|
|
261
|
+
/** Credential files hold raw provider API keys — always mode 0600.
|
|
262
|
+
* models.json can hold per-provider apiKey/headers, so it gets the same treatment. */
|
|
263
|
+
export const CREDENTIAL_FILE_MODE = 0o600;
|
|
264
|
+
/** Write a credential file (provider-keys.json / auth.json / models.json) with mode 0600.
|
|
265
|
+
* The `mode` option covers creation; the chmod covers pre-existing files
|
|
266
|
+
* (mode is ignored when the file already exists). Best-effort on Windows. */
|
|
267
|
+
export function writeCredentialFile(path, data) {
|
|
268
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
269
|
+
writeFileSync(path, data, { mode: CREDENTIAL_FILE_MODE });
|
|
270
|
+
try {
|
|
271
|
+
chmodSync(path, CREDENTIAL_FILE_MODE);
|
|
272
|
+
}
|
|
273
|
+
catch {
|
|
274
|
+
/* best-effort (win) */
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
/** Startup repair: chmod existing credential files to 0600 (best-effort). */
|
|
278
|
+
export function ensureCredentialFilePermissions(agentDir) {
|
|
279
|
+
for (const name of ["provider-keys.json", "auth.json", "models.json"]) {
|
|
280
|
+
try {
|
|
281
|
+
chmodSync(join(agentDir, name), CREDENTIAL_FILE_MODE);
|
|
282
|
+
}
|
|
283
|
+
catch {
|
|
284
|
+
/* missing / win — ignore */
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
250
288
|
export class ModelAdminService {
|
|
251
289
|
host;
|
|
252
290
|
oauthFlows;
|
|
253
291
|
activeEnrichAbort = new Map();
|
|
254
292
|
constructor(host) {
|
|
255
293
|
this.host = host;
|
|
294
|
+
ensureCredentialFilePermissions(host.agentDir);
|
|
256
295
|
this.oauthFlows = new ProviderOAuthFlowManager({
|
|
257
296
|
modelRuntime: host.modelRuntime ??
|
|
258
297
|
(() => {
|
|
@@ -379,8 +418,15 @@ export class ModelAdminService {
|
|
|
379
418
|
return out;
|
|
380
419
|
}
|
|
381
420
|
writeProviderKeys(data) {
|
|
382
|
-
|
|
383
|
-
|
|
421
|
+
atomicWriteCredentialJson(this.providerKeysPath(), data);
|
|
422
|
+
// Keep the sibling credential file at 0600 too (e.g. adding an
|
|
423
|
+
// inactive key rewrites provider-keys.json but not auth.json).
|
|
424
|
+
try {
|
|
425
|
+
chmodSync(join(this.host.agentDir, "auth.json"), CREDENTIAL_FILE_MODE);
|
|
426
|
+
}
|
|
427
|
+
catch {
|
|
428
|
+
/* missing / win — ignore */
|
|
429
|
+
}
|
|
384
430
|
}
|
|
385
431
|
/** 解析失败的配置文件改名留存为 <name>.corrupt-<timestamp>。改名失败(占用/
|
|
386
432
|
* 跨盘等)也不抛——留存是尽力而为,绝不能阻塞主流程。 */
|
|
@@ -498,7 +544,6 @@ export class ModelAdminService {
|
|
|
498
544
|
/** Persist the ACTIVE key's apiKey into auth.json + runtime override + refresh. */
|
|
499
545
|
async applyActiveKey(pid, apiKey) {
|
|
500
546
|
const authPath = join(this.host.agentDir, "auth.json");
|
|
501
|
-
mkdirSync(this.host.agentDir, { recursive: true });
|
|
502
547
|
let data = {};
|
|
503
548
|
try {
|
|
504
549
|
data = JSON.parse(readFileSync(authPath, "utf8"));
|
|
@@ -507,7 +552,13 @@ export class ModelAdminService {
|
|
|
507
552
|
// no file yet / unparsable — start fresh
|
|
508
553
|
}
|
|
509
554
|
data[pid] = { type: "api_key", key: apiKey };
|
|
510
|
-
|
|
555
|
+
atomicWriteCredentialJson(authPath, data);
|
|
556
|
+
try {
|
|
557
|
+
chmodSync(this.providerKeysPath(), CREDENTIAL_FILE_MODE);
|
|
558
|
+
}
|
|
559
|
+
catch {
|
|
560
|
+
/* missing / win — ignore */
|
|
561
|
+
}
|
|
511
562
|
const mr = this.host.modelRuntime?.();
|
|
512
563
|
if (mr) {
|
|
513
564
|
await mr.setRuntimeApiKey(pid, apiKey);
|
|
@@ -740,7 +791,7 @@ export class ModelAdminService {
|
|
|
740
791
|
// no file yet — nothing to clean
|
|
741
792
|
}
|
|
742
793
|
delete auth[pid];
|
|
743
|
-
|
|
794
|
+
atomicWriteCredentialJson(authPath, auth);
|
|
744
795
|
const mr = this.host.modelRuntime?.();
|
|
745
796
|
if (mr) {
|
|
746
797
|
await mr.removeRuntimeApiKey(pid);
|
|
@@ -833,7 +884,7 @@ export class ModelAdminService {
|
|
|
833
884
|
return;
|
|
834
885
|
}
|
|
835
886
|
delete data[pid];
|
|
836
|
-
|
|
887
|
+
atomicWriteCredentialJson(authPath, data);
|
|
837
888
|
// Clear every stored key so the provider returns to unconfigured.
|
|
838
889
|
delete keyData[pid];
|
|
839
890
|
this.writeProviderKeys(keyData);
|
|
@@ -1704,7 +1755,7 @@ export class ModelAdminService {
|
|
|
1704
1755
|
if (graduated.length === 0)
|
|
1705
1756
|
return graduated;
|
|
1706
1757
|
try {
|
|
1707
|
-
|
|
1758
|
+
atomicWriteCredentialJson(this.modelsConfigPath(), { providers });
|
|
1708
1759
|
}
|
|
1709
1760
|
catch {
|
|
1710
1761
|
return [];
|
|
@@ -1741,7 +1792,7 @@ export class ModelAdminService {
|
|
|
1741
1792
|
* config list + the picker. Callers emit their own notice. */
|
|
1742
1793
|
async writeModelsConfigAndReload(providers, pid) {
|
|
1743
1794
|
mkdirSync(this.host.agentDir, { recursive: true });
|
|
1744
|
-
|
|
1795
|
+
atomicWriteCredentialJson(this.modelsConfigPath(), { providers });
|
|
1745
1796
|
// Allow a models.json entry to reuse the provider credential already
|
|
1746
1797
|
// stored in auth.json. Seed the shared runtime too, because older pi-ai
|
|
1747
1798
|
// versions did not always fall back to stored credentials for a
|
|
@@ -1898,7 +1949,7 @@ export class ModelAdminService {
|
|
|
1898
1949
|
return;
|
|
1899
1950
|
}
|
|
1900
1951
|
delete providers[providerId];
|
|
1901
|
-
|
|
1952
|
+
atomicWriteCredentialJson(this.modelsConfigPath(), { providers });
|
|
1902
1953
|
await this.host.modelRuntime?.()?.refresh();
|
|
1903
1954
|
this.host.invalidatePiConfig?.();
|
|
1904
1955
|
await this.listModelsConfig();
|
|
@@ -77,6 +77,7 @@ export const PRESET_FIELD_GROUPS = {
|
|
|
77
77
|
"toolsWrap",
|
|
78
78
|
"toolImagesEnabled",
|
|
79
79
|
"keepRecentMessages",
|
|
80
|
+
"reversePagination",
|
|
80
81
|
"showForkedParentSessions",
|
|
81
82
|
"retainFinishedConversations",
|
|
82
83
|
"openRecentSessionOnProjectSwitch",
|
|
@@ -84,6 +85,7 @@ export const PRESET_FIELD_GROUPS = {
|
|
|
84
85
|
"quickPhrases",
|
|
85
86
|
"quickPhrasesEnabled",
|
|
86
87
|
"minimalNewChat",
|
|
88
|
+
"preserveDraftAcrossConversations",
|
|
87
89
|
"devNoCache",
|
|
88
90
|
"autoReload",
|
|
89
91
|
],
|
|
@@ -403,6 +405,12 @@ export const PRESET_FIELD_META = {
|
|
|
403
405
|
hintZh: "消息列表尾部保持完整渲染的消息条数;更早的折叠为摘要行",
|
|
404
406
|
hintEn: "Recent messages rendered in full; older ones collapse to summary rows",
|
|
405
407
|
},
|
|
408
|
+
reversePagination: {
|
|
409
|
+
labelZh: "向上分页加载",
|
|
410
|
+
labelEn: "Load Earlier Messages",
|
|
411
|
+
hintZh: "默认仅挂载最近消息,向上滚动或点击加载更早历史,完全跳过视口占位符获得原生流畅度",
|
|
412
|
+
hintEn: "Only mount recent messages; scroll up or click to load earlier history with zero placeholders",
|
|
413
|
+
},
|
|
406
414
|
showForkedParentSessions: {
|
|
407
415
|
labelZh: "显示已分支的父会话",
|
|
408
416
|
labelEn: "Show Forked Parent Sessions",
|
|
@@ -439,6 +447,12 @@ export const PRESET_FIELD_META = {
|
|
|
439
447
|
hintZh: "新对话隐藏提示词模板并隐藏快捷短语,呈现现代极简风格",
|
|
440
448
|
hintEn: "Hide prompt templates and quick phrases on new chat for a clean modern look",
|
|
441
449
|
},
|
|
450
|
+
preserveDraftAcrossConversations: {
|
|
451
|
+
labelZh: "输入框文字跨对话保留",
|
|
452
|
+
labelEn: "Preserve Composer Text Across Conversations",
|
|
453
|
+
hintZh: "开启:输入文字切换别的会话不清空;关闭:仅保留当前会话文字,切换其他会话时清空或显示该会话已保留文字,切回时恢复当前会话文字",
|
|
454
|
+
hintEn: "Enabled: keep composer text when switching conversations. Disabled: retain text only for the current conversation",
|
|
455
|
+
},
|
|
442
456
|
devNoCache: {
|
|
443
457
|
labelZh: "开发者免缓存模式",
|
|
444
458
|
labelEn: "Developer No-Cache Mode",
|
|
@@ -273,12 +273,14 @@ const PRESET_FIELD_KINDS = {
|
|
|
273
273
|
toolsWrap: "bool",
|
|
274
274
|
toolImagesEnabled: "bool",
|
|
275
275
|
keepRecentMessages: "number",
|
|
276
|
+
reversePagination: "bool",
|
|
276
277
|
showForkedParentSessions: "bool",
|
|
277
278
|
retainFinishedConversations: "bool",
|
|
278
279
|
openRecentSessionOnProjectSwitch: "bool",
|
|
279
280
|
quickPhrases: "list",
|
|
280
281
|
quickPhrasesEnabled: "bool",
|
|
281
282
|
minimalNewChat: "bool",
|
|
283
|
+
preserveDraftAcrossConversations: "bool",
|
|
282
284
|
devNoCache: "bool",
|
|
283
285
|
autoReload: "bool",
|
|
284
286
|
// -- engine ----------------------------------------------------------
|
|
@@ -47,12 +47,11 @@ export async function snapshotListeningPorts() {
|
|
|
47
47
|
return m;
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
|
-
* Snapshot every process's parent pid → Map<pid,
|
|
51
|
-
* PowerShell CIM pass
|
|
52
|
-
*
|
|
53
|
-
* fails — callers should treat that as "cannot verify, stay conservative".
|
|
50
|
+
* Snapshot every process's parent pid & name → Map<pid, ProcessTreeNode>.
|
|
51
|
+
* Windows: one PowerShell CIM pass; POSIX: one `ps -Ao pid=,ppid=,comm=` pass.
|
|
52
|
+
* Returns undefined when query fails — callers should treat as unverified.
|
|
54
53
|
*/
|
|
55
|
-
export async function
|
|
54
|
+
export async function snapshotProcessTree() {
|
|
56
55
|
try {
|
|
57
56
|
const { execFile } = await import("node:child_process");
|
|
58
57
|
const m = new Map();
|
|
@@ -61,23 +60,35 @@ export async function snapshotProcessParents() {
|
|
|
61
60
|
"-NoProfile",
|
|
62
61
|
"-NonInteractive",
|
|
63
62
|
"-Command",
|
|
64
|
-
'Get-CimInstance Win32_Process | ForEach-Object { "$($_.ProcessId):$($_.ParentProcessId)" }',
|
|
63
|
+
'Get-CimInstance Win32_Process | ForEach-Object { "$($_.ProcessId):$($_.ParentProcessId):$($_.Name)" }',
|
|
65
64
|
], { windowsHide: true, timeout: 10000 }, (err, stdout) => (err ? reject(err) : resolve(stdout))));
|
|
66
65
|
for (const line of out.split(/\r?\n/)) {
|
|
67
|
-
const
|
|
68
|
-
if (
|
|
69
|
-
|
|
66
|
+
const trimmed = line.trim();
|
|
67
|
+
if (!trimmed)
|
|
68
|
+
continue;
|
|
69
|
+
const firstColon = trimmed.indexOf(":");
|
|
70
|
+
const secondColon = trimmed.indexOf(":", firstColon + 1);
|
|
71
|
+
if (firstColon === -1)
|
|
72
|
+
continue;
|
|
73
|
+
const pid = Number(trimmed.slice(0, firstColon));
|
|
74
|
+
const ppid = Number(secondColon === -1 ? trimmed.slice(firstColon + 1) : trimmed.slice(firstColon + 1, secondColon));
|
|
75
|
+
const name = secondColon === -1 ? undefined : trimmed.slice(secondColon + 1).trim() || undefined;
|
|
76
|
+
if (Number.isFinite(pid) && Number.isFinite(ppid)) {
|
|
77
|
+
m.set(pid, { ppid, ...(name ? { name } : {}) });
|
|
78
|
+
}
|
|
70
79
|
}
|
|
71
80
|
}
|
|
72
81
|
else {
|
|
73
|
-
const out = await new Promise((resolve, reject) => execFile("ps", ["-Ao", "pid=,ppid="], { timeout: 5000 }, (err, stdout) => err ? reject(err) : resolve(stdout)));
|
|
82
|
+
const out = await new Promise((resolve, reject) => execFile("ps", ["-Ao", "pid=,ppid=,comm="], { timeout: 5000 }, (err, stdout) => err ? reject(err) : resolve(stdout)));
|
|
74
83
|
for (const line of out.split(/\r?\n/)) {
|
|
75
84
|
const p = line.trim().split(/\s+/);
|
|
76
85
|
if (p.length >= 2) {
|
|
77
86
|
const pid = Number(p[0]);
|
|
78
87
|
const ppid = Number(p[1]);
|
|
79
|
-
|
|
80
|
-
|
|
88
|
+
const name = p.slice(2).join(" ").trim() || undefined;
|
|
89
|
+
if (Number.isFinite(pid) && Number.isFinite(ppid)) {
|
|
90
|
+
m.set(pid, { ppid, ...(name ? { name } : {}) });
|
|
91
|
+
}
|
|
81
92
|
}
|
|
82
93
|
}
|
|
83
94
|
}
|
|
@@ -87,6 +98,97 @@ export async function snapshotProcessParents() {
|
|
|
87
98
|
return undefined;
|
|
88
99
|
}
|
|
89
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Snapshot every process's parent pid → Map<pid, ppid>.
|
|
103
|
+
* Retained for backward compatibility; powered by snapshotProcessTree.
|
|
104
|
+
*/
|
|
105
|
+
export async function snapshotProcessParents() {
|
|
106
|
+
const tree = await snapshotProcessTree();
|
|
107
|
+
if (!tree)
|
|
108
|
+
return undefined;
|
|
109
|
+
const m = new Map();
|
|
110
|
+
for (const [pid, node] of tree) {
|
|
111
|
+
m.set(pid, node.ppid);
|
|
112
|
+
}
|
|
113
|
+
return m;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Batch lookup detailed process info (pid, ppid, name, commandLine, createdMs).
|
|
117
|
+
* Windows: single PowerShell CIM pass with filter; POSIX: `ps -o pid=,ppid=,etimes=,comm=,command=`.
|
|
118
|
+
*/
|
|
119
|
+
export async function lookupProcessDetailsBatch(pids) {
|
|
120
|
+
const out = new Map();
|
|
121
|
+
const validPids = [...new Set(pids.filter((p) => Number.isInteger(p) && p > 0))];
|
|
122
|
+
if (validPids.length === 0)
|
|
123
|
+
return out;
|
|
124
|
+
try {
|
|
125
|
+
const { execFile } = await import("node:child_process");
|
|
126
|
+
if (process.platform === "win32") {
|
|
127
|
+
const filter = validPids.map((p) => `ProcessId=${p}`).join(" or ");
|
|
128
|
+
const command = [
|
|
129
|
+
`$filter = '${filter}';`,
|
|
130
|
+
`Get-CimInstance Win32_Process -Filter $filter | ForEach-Object {`,
|
|
131
|
+
` $ts = if ($_.CreationDate) { [DateTimeOffset]::new($_.CreationDate).ToUnixTimeMilliseconds() } else { 0 };`,
|
|
132
|
+
` $cmd = if ($_.CommandLine) { $_.CommandLine -replace "\\r?\\n", " " } else { "" };`,
|
|
133
|
+
` "$($_.ProcessId)\`t$($_.ParentProcessId)\`t$($_.Name)\`t$ts\`t$cmd"`,
|
|
134
|
+
`}`,
|
|
135
|
+
].join(" ");
|
|
136
|
+
const stdout = await new Promise((resolve, reject) => execFile("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", command], { windowsHide: true, timeout: 8000 }, (err, res) => (err ? reject(err) : resolve(res))));
|
|
137
|
+
for (const line of stdout.split(/\r?\n/)) {
|
|
138
|
+
const trimmed = line.trim();
|
|
139
|
+
if (!trimmed)
|
|
140
|
+
continue;
|
|
141
|
+
const parts = trimmed.split("\t");
|
|
142
|
+
if (parts.length >= 3) {
|
|
143
|
+
const pid = Number(parts[0]);
|
|
144
|
+
const ppid = Number(parts[1]);
|
|
145
|
+
const name = parts[2] || undefined;
|
|
146
|
+
const ts = Number(parts[3]);
|
|
147
|
+
const cmd = parts.slice(4).join("\t").trim();
|
|
148
|
+
if (Number.isFinite(pid)) {
|
|
149
|
+
out.set(pid, {
|
|
150
|
+
pid,
|
|
151
|
+
...(Number.isFinite(ppid) ? { ppid } : {}),
|
|
152
|
+
...(name ? { name } : {}),
|
|
153
|
+
...(Number.isFinite(ts) && ts > 0 ? { createdMs: ts } : {}),
|
|
154
|
+
...(cmd ? { commandLine: cmd } : {}),
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return out;
|
|
160
|
+
}
|
|
161
|
+
// POSIX (Linux / macOS)
|
|
162
|
+
const stdout = await new Promise((resolve, reject) => execFile("ps", ["-o", "pid=,ppid=,etimes=,comm=,command=", "-p", validPids.join(",")], { timeout: 5000 }, (err, res) => (err ? reject(err) : resolve(res))));
|
|
163
|
+
const now = Date.now();
|
|
164
|
+
for (const line of stdout.split(/\r?\n/)) {
|
|
165
|
+
const trimmed = line.trim();
|
|
166
|
+
if (!trimmed)
|
|
167
|
+
continue;
|
|
168
|
+
// 格式: pid ppid etimes comm command...
|
|
169
|
+
const match = trimmed.match(/^(\d+)\s+(\d+)\s+(\d+)\s+(\S+)(?:\s+(.*))?$/);
|
|
170
|
+
if (match) {
|
|
171
|
+
const pid = Number(match[1]);
|
|
172
|
+
const ppid = Number(match[2]);
|
|
173
|
+
const etimes = Number(match[3]);
|
|
174
|
+
const name = match[4];
|
|
175
|
+
const commandLine = match[5]?.trim();
|
|
176
|
+
const createdMs = Number.isFinite(etimes) ? now - etimes * 1000 : undefined;
|
|
177
|
+
out.set(pid, {
|
|
178
|
+
pid,
|
|
179
|
+
ppid,
|
|
180
|
+
name,
|
|
181
|
+
...(commandLine ? { commandLine } : {}),
|
|
182
|
+
...(createdMs !== undefined ? { createdMs } : {}),
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
catch {
|
|
188
|
+
// best effort — lookup failure just returns empty map
|
|
189
|
+
}
|
|
190
|
+
return out;
|
|
191
|
+
}
|
|
90
192
|
/** Kill a pid and its whole process tree (cross-platform).
|
|
91
193
|
*
|
|
92
194
|
* The returned promise is only meaningful on Windows, where taskkill is itself
|
|
@@ -307,7 +307,7 @@ export class SettingsService {
|
|
|
307
307
|
toolWatchdogTimeoutMs: this.settings.toolWatchdogTimeoutMs,
|
|
308
308
|
readDirEnabled: this.settings.readDirEnabled !== false,
|
|
309
309
|
bgAutoCleanupMin: normalizeBgCleanupMinutes(this.settings.bgAutoCleanupMin),
|
|
310
|
-
toolLazyLoading: this.settings.toolLazyLoading
|
|
310
|
+
toolLazyLoading: this.settings.toolLazyLoading === true,
|
|
311
311
|
codemodeMode: this.settings.codemodeMode ?? "on",
|
|
312
312
|
codemodeInlineBudget: this.settings.codemodeInlineBudget ?? 3000,
|
|
313
313
|
toolApprovalEnabled: this.settings.toolApprovalEnabled !== false,
|
|
@@ -372,6 +372,7 @@ export class SettingsService {
|
|
|
372
372
|
quickPhrases: [...this.settings.quickPhrases],
|
|
373
373
|
quickPhrasesEnabled: this.settings.quickPhrasesEnabled,
|
|
374
374
|
minimalNewChat: this.settings.minimalNewChat,
|
|
375
|
+
preserveDraftAcrossConversations: this.settings.preserveDraftAcrossConversations ?? false,
|
|
375
376
|
quickPhrasesSeeded: this.host.stateStore.getQuickPhrasesSeeded(),
|
|
376
377
|
mcpServers: mcp.servers,
|
|
377
378
|
mcpGlobalConfigPath: mcp.globalPath,
|
|
@@ -523,11 +524,11 @@ export class SettingsService {
|
|
|
523
524
|
if (partial.bgAutoCleanupMin !== undefined) {
|
|
524
525
|
this.settings.bgAutoCleanupMin = normalizeBgCleanupMinutes(partial.bgAutoCleanupMin);
|
|
525
526
|
}
|
|
526
|
-
//
|
|
527
|
+
// 工具延迟加载开关(默认关,设置页可开):门控每次实时读取,改动经 applyToolGating 重放生效
|
|
527
528
|
// (见 toolGatingChanged)——**只影响新会话与之后的门控重放**,已有对话的已加载
|
|
528
529
|
// 集合不会被反向清空(不想让在跑的对话凭空丢掉工具)。
|
|
529
530
|
if (partial.toolLazyLoading !== undefined) {
|
|
530
|
-
this.settings.toolLazyLoading = partial.toolLazyLoading
|
|
531
|
+
this.settings.toolLazyLoading = partial.toolLazyLoading === true;
|
|
531
532
|
}
|
|
532
533
|
let codemodeChanged = false;
|
|
533
534
|
if (partial.codemodeMode !== undefined && partial.codemodeMode !== this.settings.codemodeMode) {
|
|
@@ -662,6 +663,9 @@ export class SettingsService {
|
|
|
662
663
|
if (partial.minimalNewChat !== undefined) {
|
|
663
664
|
this.settings.minimalNewChat = partial.minimalNewChat;
|
|
664
665
|
}
|
|
666
|
+
if (partial.preserveDraftAcrossConversations !== undefined) {
|
|
667
|
+
this.settings.preserveDraftAcrossConversations = Boolean(partial.preserveDraftAcrossConversations);
|
|
668
|
+
}
|
|
665
669
|
// 统一工具开关 live 生效(ActiveSet 加减;失败静默,下次创建/reload 重放)。
|
|
666
670
|
// 必须在 this.push() 前生效,保证 promptSnapshot 收集到的是最新的活跃工具集与完整提示词!
|
|
667
671
|
if (toolGatingChanged)
|
|
@@ -151,6 +151,8 @@ export function previewKind(name) {
|
|
|
151
151
|
return "image";
|
|
152
152
|
if (PREVIEW_VIDEO_EXTS.has(ext))
|
|
153
153
|
return "video";
|
|
154
|
+
if (PREVIEW_AUDIO_EXTS.has(ext))
|
|
155
|
+
return "audio";
|
|
154
156
|
if (ext === "" || PREVIEW_TEXT_EXTS.has(ext))
|
|
155
157
|
return "text";
|
|
156
158
|
return "none";
|
|
@@ -259,6 +259,7 @@ export class UniversalSession {
|
|
|
259
259
|
isDisposed: () => this.disposed,
|
|
260
260
|
pluginTasks: () => [],
|
|
261
261
|
cleanupMinutes: () => 0,
|
|
262
|
+
workspaceCwd: () => this.cwd,
|
|
262
263
|
});
|
|
263
264
|
// 加载现有会话或创建初始会话
|
|
264
265
|
const existing = this.store.listConversations(this.cwd);
|
|
@@ -1784,7 +1785,8 @@ export class UniversalSession {
|
|
|
1784
1785
|
toolWatchdogTimeoutMs: s?.toolWatchdogTimeoutMs ?? 1200000,
|
|
1785
1786
|
readDirEnabled: true,
|
|
1786
1787
|
bgAutoCleanupMin: s?.bgAutoCleanupMin ?? 0,
|
|
1787
|
-
|
|
1788
|
+
// 同一字段的含义在本引擎不适用(无 pi 工具注册面):恒为 false 占位,保协议完整。
|
|
1789
|
+
toolLazyLoading: false,
|
|
1788
1790
|
codemodeMode: "on",
|
|
1789
1791
|
codemodeInlineBudget: 3000,
|
|
1790
1792
|
editSoftEnabled: false,
|
|
@@ -1845,6 +1847,7 @@ export class UniversalSession {
|
|
|
1845
1847
|
quickPhrases: s?.quickPhrases ?? [],
|
|
1846
1848
|
quickPhrasesEnabled: s?.quickPhrasesEnabled ?? true,
|
|
1847
1849
|
minimalNewChat: s?.minimalNewChat ?? false,
|
|
1850
|
+
preserveDraftAcrossConversations: s?.preserveDraftAcrossConversations ?? false,
|
|
1848
1851
|
quickPhrasesSeeded: this.stateStore?.getQuickPhrasesSeeded() ?? true,
|
|
1849
1852
|
};
|
|
1850
1853
|
this.send({ type: "settings_state", settings });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-web-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.109.0",
|
|
4
4
|
"description": "Just open your browser to get all your work done — browser cockpit for AI coding agents (chat, code, files, terminal, Git in one tab)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -75,6 +75,7 @@
|
|
|
75
75
|
"test:smoke:core": "node tests/run-smoke.mjs --core",
|
|
76
76
|
"check:protocol": "node scripts/check-protocol-sync.mjs",
|
|
77
77
|
"i18n:diff": "node scripts/i18n-diff.mjs",
|
|
78
|
+
"i18n:check": "node scripts/i18n-diff.mjs --check-packs",
|
|
78
79
|
"release:notes": "node scripts/release-notes.mjs",
|
|
79
80
|
"changelog:i18n": "node scripts/release-notes.mjs --unreleased",
|
|
80
81
|
"test:freeze": "node tests/freeze-test.mjs",
|
package/themes/aetheris.css
CHANGED
|
@@ -11,15 +11,17 @@
|
|
|
11
11
|
--border-soft: rgba(255, 255, 255, 0.04);
|
|
12
12
|
--text: #f0f3f8;
|
|
13
13
|
--text-dim: #8e96aa;
|
|
14
|
-
--text-faint: #
|
|
14
|
+
--text-faint: #5a637c;
|
|
15
15
|
--accent: #00f5d4;
|
|
16
|
+
--accent-contrast: #0a0c13;
|
|
16
17
|
--accent-soft: rgba(0, 245, 212, 0.12);
|
|
17
18
|
--green: #10b981;
|
|
18
19
|
--green-soft: rgba(16, 185, 129, 0.12);
|
|
19
20
|
--red: #ff4a6e;
|
|
21
|
+
--on-red: #1a1a1a;
|
|
20
22
|
--red-soft: rgba(255, 74, 110, 0.12);
|
|
21
23
|
--amber: #fbbf24;
|
|
22
|
-
--blue: #
|
|
24
|
+
--blue: #6c6ff2;
|
|
23
25
|
--blue-soft: rgba(99, 102, 241, 0.12);
|
|
24
26
|
|
|
25
27
|
/* 终端 ANSI 调色板 */
|
|
@@ -73,12 +75,13 @@
|
|
|
73
75
|
--notice-warn-border: #fbbf24;
|
|
74
76
|
--notice-info-border: #6366f1;
|
|
75
77
|
--send-blue: #00f5d4;
|
|
78
|
+
--on-send-blue: #1a1a1a;
|
|
76
79
|
--send-blue-hover: #2dd4bf;
|
|
77
80
|
--stop-red: #ff4a6e;
|
|
78
81
|
--stop-red-hover: #e11d48;
|
|
79
82
|
--brand-grad-a: #00f5d4;
|
|
80
83
|
--brand-grad-b: #6366f1;
|
|
81
|
-
--on-amber: #
|
|
84
|
+
--on-amber: #1a1a1a;
|
|
82
85
|
--search-active-fg: #040507;
|
|
83
86
|
--switch-knob: #ffffff;
|
|
84
87
|
--sunken-bg: rgba(0, 0, 0, 0.45);
|