pi-web-ui 0.109.0 → 0.111.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 +31 -0
- package/README.md +21 -1
- package/README.zh-CN.md +21 -1
- package/README.zh-TW.md +201 -677
- package/bin/frp-manager.mjs +85 -7
- package/dist/server/agent-formatters.js +10 -6
- package/dist/server/agent-service-daemon.js +29 -11
- package/dist/server/agent-service.js +160 -54
- package/dist/server/attachments.js +140 -37
- package/dist/server/canvas/canvas-agent-tool.js +587 -0
- package/dist/server/canvas/canvas-cards.js +144 -0
- package/dist/server/canvas/canvas-dispatch.js +155 -0
- package/dist/server/canvas/canvas-orchestrator.js +1027 -0
- package/dist/server/canvas/canvas-store.js +260 -0
- package/dist/server/client-id-utils.js +2 -2
- package/dist/server/client-state.js +24 -0
- package/dist/server/context-budget.js +6 -3
- package/dist/server/dispatch-domain-handlers.js +2 -0
- package/dist/server/dispatch-plugin-handlers.js +1 -0
- package/dist/server/dsh/dsh-agent-service.js +115 -9
- package/dist/server/dsh/dsh-client.js +10 -1
- package/dist/server/dsh/runtime/goal-rpc.mjs +128 -3
- package/dist/server/dsh/runtime/launcher.mjs +59 -5
- package/dist/server/dsh/runtime/runtime-root.mjs +353 -40
- package/dist/server/durable/durable-agent-service.js +3 -0
- package/dist/server/durable/durable-driver.js +1 -1
- package/dist/server/durable/durable-tools.js +4 -1
- package/dist/server/file-transfer-routes.js +8 -2
- package/dist/server/files-service.js +33 -6
- package/dist/server/goal-service.js +12 -3
- package/dist/server/index.js +175 -13
- package/dist/server/locales.js +33 -0
- package/dist/server/marker-service.js +10 -14
- package/dist/server/markers/builtins/action.js +5 -6
- package/dist/server/markers/builtins/notify.js +2 -2
- package/dist/server/markers/builtins/rename.js +2 -2
- package/dist/server/markers/marker.js +45 -4
- package/dist/server/markers/registry.js +36 -1
- package/dist/server/message-window.js +193 -0
- package/dist/server/model-admin.js +0 -4
- package/dist/server/office-parse.js +394 -7
- package/dist/server/plugin-api-catalog.js +6 -0
- package/dist/server/plugin-catalog-sync.js +10 -2
- package/dist/server/plugin-catalog.js +63 -10
- package/dist/server/plugins.js +144 -26
- package/dist/server/preset-fields.js +35 -1
- package/dist/server/preset-share.js +5 -3
- package/dist/server/process-utils.js +58 -24
- package/dist/server/prompt-assembler.js +7 -1
- package/dist/server/prompt-composer.js +66 -36
- package/dist/server/protocol-version.js +1 -1
- package/dist/server/remote-ssh-service.js +16 -4
- package/dist/server/settings-service.js +24 -3
- package/dist/server/slash-commands.js +16 -4
- package/dist/server/text-sniff.js +10 -7
- package/dist/server/themes.js +36 -1
- package/dist/server/tool-manager.js +30 -0
- package/dist/server/univer-service.js +448 -0
- package/dist/server/universal/drivers/claude-code.js +19 -2
- package/dist/server/universal/drivers/dsh-driver.js +1 -1
- package/dist/server/universal/universal-attachments.js +5 -0
- package/dist/server/universal/universal-service.js +5 -0
- package/dist/server/universal/universal-session.js +38 -15
- package/dist/server/update-check.js +90 -5
- package/dist/server/workspace-snapshot.js +33 -2
- package/dist/server/worktree-service.js +1 -1
- package/docs/dsh-engine.md +497 -0
- package/package.json +11 -5
- package/plugin-sdk/index.d.ts +37 -0
- package/plugin-sdk/index.mjs +19 -0
- package/plugins/catalog.json +44 -2
- package/themes/aetheris.css +263 -118
- package/themes/bases/flow-base.css +1363 -0
- package/themes/bases/obsidian-base.css +895 -0
- package/themes/bases/zhujian-base.css +687 -0
- package/themes/bases/zhupi-base.css +659 -0
- package/themes/flow-light.css +2 -925
- package/themes/flow.css +1 -936
- package/themes/md-preview.css +113 -0
- package/themes/wallpaper-flow.css +251 -1029
- package/themes/wallpaper-obsidian.css +1 -673
- package/themes/zhujian-dark.css +1 -605
- package/themes/zhujian.css +1 -654
- package/themes/zhupi-dark.css +1 -576
- package/themes/zhupi.css +1 -626
- package/web/dist/assets/{TerminalPanel-BD3a9o-a.js → TerminalPanel-BiUNySMA.js} +2 -2
- package/web/dist/assets/index-B0ajS__T.js +697 -0
- package/web/dist/assets/index-BHik5WGG.css +1 -0
- package/web/dist/assets/{markdown-DXwnfD9T.js → markdown-BJZlfvdP.js} +24 -24
- package/web/dist/assets/markdown-DSNUiDzp.css +1 -0
- package/web/dist/index.html +4 -4
- package/web/dist/sw.js +1 -1
- package/web/dist/assets/es-DIDZppIF.js +0 -2
- package/web/dist/assets/index-AccytlpP.css +0 -1
- package/web/dist/assets/index-B3dar1BK.js +0 -690
- package/web/dist/assets/markdown-CCeVCbci.css +0 -1
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
* (reloadSession 里还会刷新斜杠命令目录)。
|
|
8
8
|
*/
|
|
9
9
|
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
10
|
+
import { homedir } from "node:os";
|
|
10
11
|
import { basename, dirname, join } from "node:path";
|
|
11
12
|
import { fileURLToPath } from "node:url";
|
|
12
|
-
import { extensionKey, isInternalExtension, normalizeBgCleanupMinutes, normalizeDisabledPluginTools, normalizeRetryMaxAttempts, normalizeKeepRecentMessages, normalizeSkillList, normalizeToolWatchdogTimeoutMs, normalizeUiLayout, settingsPresetToUi, } from "./client-state.js";
|
|
13
|
+
import { extensionKey, isInternalExtension, normalizeBgCleanupMinutes, normalizeDisabledPluginTools, normalizeRetryMaxAttempts, normalizeKeepRecentMessages, normalizeSkillList, normalizeSkillsCatalogBudget, normalizeSkillsCatalogMaxDesc, normalizeToolWatchdogTimeoutMs, normalizeUiLayout, settingsPresetToUi, } from "./client-state.js";
|
|
13
14
|
import { normalizeSoftCapByModel, normalizeSoftCapTokens } from "./soft-cap.js";
|
|
14
15
|
import { findVisionModels, SYSTEM_PROMPT } from "./vision-bridge.js";
|
|
15
16
|
import { COMMITMSG_SYSTEM_PROMPT } from "./scm-commitmsg.js";
|
|
@@ -66,8 +67,8 @@ export class SettingsService {
|
|
|
66
67
|
this.pendingReload = false;
|
|
67
68
|
return v;
|
|
68
69
|
}
|
|
69
|
-
/** 判断某个 skill 名是否仍存在于磁盘任何来源(agent 区 /
|
|
70
|
-
* .agents/skills / npm 包内 skills)。被禁用且文件已删除的名字不应再
|
|
70
|
+
/** 判断某个 skill 名是否仍存在于磁盘任何来源(agent 区 / 用户级或祖先
|
|
71
|
+
* .agents/skills / 项目 .pi / npm 包内 skills)。被禁用且文件已删除的名字不应再
|
|
71
72
|
* 出现在设置面板,也不应留在持久化记录里。 */
|
|
72
73
|
skillStillOnDisk(name) {
|
|
73
74
|
const cwd = this.host.cwd();
|
|
@@ -76,6 +77,9 @@ export class SettingsService {
|
|
|
76
77
|
// ① 用户区 <agentDir>/skills ② 项目 .pi/skills
|
|
77
78
|
if (check(join(agentDir, "skills")))
|
|
78
79
|
return true;
|
|
80
|
+
// SDK 始终扫描用户级 ~/.agents/skills,不依赖 cwd 的祖先链(issue #669)。
|
|
81
|
+
if (check(join(process.env.HOME || homedir(), ".agents", "skills")))
|
|
82
|
+
return true;
|
|
79
83
|
if (check(join(cwd, ".pi", "skills")))
|
|
80
84
|
return true;
|
|
81
85
|
// ③ 祖先链 .agents/skills(SDK collectAncestorAgentsSkillDirs 语义,最多上溯 6 层)
|
|
@@ -323,6 +327,7 @@ export class SettingsService {
|
|
|
323
327
|
toolsWrap: this.settings.toolsWrap,
|
|
324
328
|
toolImagesEnabled: this.settings.toolImagesEnabled ?? true,
|
|
325
329
|
keepRecentMessages: normalizeKeepRecentMessages(this.settings.keepRecentMessages),
|
|
330
|
+
reversePagination: this.settings.reversePagination ?? false,
|
|
326
331
|
showForkedParentSessions: this.settings.showForkedParentSessions ?? false,
|
|
327
332
|
retainFinishedConversations: this.settings.retainFinishedConversations ?? false,
|
|
328
333
|
openRecentSessionOnProjectSwitch: this.settings.openRecentSessionOnProjectSwitch ?? true,
|
|
@@ -339,6 +344,9 @@ export class SettingsService {
|
|
|
339
344
|
disabledPlugins: [...(this.settings.disabledPlugins ?? [])],
|
|
340
345
|
uiLayout: normalizeUiLayout(this.settings.uiLayout),
|
|
341
346
|
skillsFullText: [...normalizeSkillList(this.settings.skillsFullText)],
|
|
347
|
+
skillsCatalogMaxDesc: this.settings.skillsCatalogMaxDesc,
|
|
348
|
+
skillsCatalogShowLocation: this.settings.skillsCatalogShowLocation,
|
|
349
|
+
skillsCatalogBudget: this.settings.skillsCatalogBudget,
|
|
342
350
|
// The composed system prompt actually in effect (read-only view).
|
|
343
351
|
effectiveSystemPrompt: promptSnap.full,
|
|
344
352
|
// 每个来源未覆盖时的默认(自动)内容(「各来源」行预览用)。
|
|
@@ -577,6 +585,10 @@ export class SettingsService {
|
|
|
577
585
|
if (partial.keepRecentMessages !== undefined) {
|
|
578
586
|
this.settings.keepRecentMessages = normalizeKeepRecentMessages(partial.keepRecentMessages);
|
|
579
587
|
}
|
|
588
|
+
// 向上分页加载:前端 MessageList 实时读它(纯渲染策略),无需 reload runtime。
|
|
589
|
+
if (partial.reversePagination !== undefined) {
|
|
590
|
+
this.settings.reversePagination = Boolean(partial.reversePagination);
|
|
591
|
+
}
|
|
580
592
|
if (partial.retainFinishedConversations !== undefined) {
|
|
581
593
|
this.settings.retainFinishedConversations = Boolean(partial.retainFinishedConversations);
|
|
582
594
|
}
|
|
@@ -596,6 +608,15 @@ export class SettingsService {
|
|
|
596
608
|
if (partial.skillsFullText !== undefined) {
|
|
597
609
|
this.settings.skillsFullText = normalizeSkillList(partial.skillsFullText);
|
|
598
610
|
}
|
|
611
|
+
if (partial.skillsCatalogMaxDesc !== undefined) {
|
|
612
|
+
this.settings.skillsCatalogMaxDesc = normalizeSkillsCatalogMaxDesc(partial.skillsCatalogMaxDesc);
|
|
613
|
+
}
|
|
614
|
+
if (partial.skillsCatalogShowLocation !== undefined) {
|
|
615
|
+
this.settings.skillsCatalogShowLocation = Boolean(partial.skillsCatalogShowLocation);
|
|
616
|
+
}
|
|
617
|
+
if (partial.skillsCatalogBudget !== undefined) {
|
|
618
|
+
this.settings.skillsCatalogBudget = normalizeSkillsCatalogBudget(partial.skillsCatalogBudget);
|
|
619
|
+
}
|
|
599
620
|
if (partial.visionBridgeEnabled !== undefined) {
|
|
600
621
|
this.settings.visionBridgeEnabled = partial.visionBridgeEnabled;
|
|
601
622
|
}
|
|
@@ -63,10 +63,10 @@ export function parseSlash(text) {
|
|
|
63
63
|
const trimmed = text.trim();
|
|
64
64
|
if (!trimmed.startsWith("/"))
|
|
65
65
|
return null;
|
|
66
|
-
const m = trimmed.match(/^\/([^\s]
|
|
67
|
-
if (!m
|
|
66
|
+
const m = trimmed.match(/^\/([^\s]*)\s*([\s\S]*)$/);
|
|
67
|
+
if (!m)
|
|
68
68
|
return null;
|
|
69
|
-
return { name: m[1], args: m[2].trim() };
|
|
69
|
+
return { name: m[1] ?? "", args: (m[2] ?? "").trim() };
|
|
70
70
|
}
|
|
71
71
|
export class SlashCommandsService {
|
|
72
72
|
host;
|
|
@@ -418,7 +418,19 @@ export class SlashCommandsService {
|
|
|
418
418
|
}, 300);
|
|
419
419
|
return true;
|
|
420
420
|
}
|
|
421
|
-
case "
|
|
421
|
+
case "":
|
|
422
|
+
case "?":
|
|
423
|
+
case "help": {
|
|
424
|
+
void this.push();
|
|
425
|
+
const cmdList = NATIVE_COMMANDS.map((c) => `/${c.name} : ${c.description}`).join("\n");
|
|
426
|
+
this.host.emit({
|
|
427
|
+
type: "notice",
|
|
428
|
+
level: "info",
|
|
429
|
+
text: `可用斜杠指令:\n${cmdList}`,
|
|
430
|
+
textEn: `Available slash commands:\n${cmdList}`,
|
|
431
|
+
});
|
|
432
|
+
return true;
|
|
433
|
+
}
|
|
422
434
|
case "copy":
|
|
423
435
|
// Client-side UI actions — the client handles them before sending;
|
|
424
436
|
// swallow here so the SDK never sees them as plain prompt text.
|
|
@@ -158,10 +158,9 @@ export function previewKind(name) {
|
|
|
158
158
|
return "none";
|
|
159
159
|
}
|
|
160
160
|
/**
|
|
161
|
-
* 扩展名是否为浏览器可直接播放的音频。与 previewKind
|
|
162
|
-
* image/video/
|
|
163
|
-
*
|
|
164
|
-
* 「能不能 inline 播」的布尔判断。
|
|
161
|
+
* 扩展名是否为浏览器可直接播放的音频。与 previewKind 分开:预览弹窗的媒体分支
|
|
162
|
+
* 只关心 image/video,音频得单独判一次;而 /api/file 的媒体白名单与
|
|
163
|
+
* present_files 的卡片只需要一个「能不能 inline 播」的布尔判断。
|
|
165
164
|
*/
|
|
166
165
|
export function isAudioFile(name) {
|
|
167
166
|
const dot = name.lastIndexOf(".");
|
|
@@ -183,7 +182,7 @@ export function looksLikeText(buf) {
|
|
|
183
182
|
let control = 0;
|
|
184
183
|
for (const ch of text) {
|
|
185
184
|
const c = ch.charCodeAt(0);
|
|
186
|
-
// Keep \t \n \
|
|
185
|
+
// Keep \t \n \f \r; everything else < 0x20 (including \b and \v) is binary-ish.
|
|
187
186
|
if (c < 0x20 && c !== 9 && c !== 10 && c !== 12 && c !== 13)
|
|
188
187
|
control++;
|
|
189
188
|
}
|
|
@@ -195,8 +194,12 @@ export function looksLikeText(buf) {
|
|
|
195
194
|
* previews and inline attachments never show mojibake for GBK/GB2312 files
|
|
196
195
|
* nor for truncated UTF-8 files (issue #392). */
|
|
197
196
|
export function decodeText(buf) {
|
|
198
|
-
|
|
199
|
-
|
|
197
|
+
// `cut < buf.length` keeps the truncated-tail retry from eating the whole
|
|
198
|
+
// buffer: a 1–3 byte buffer of legacy bytes (GBK "中" = D6 D0) would
|
|
199
|
+
// otherwise trim down to an empty slice, decode "successfully" as UTF-8 and
|
|
200
|
+
// return "" — silently blanking every tiny non-UTF-8 preview.
|
|
201
|
+
for (let cut = 0; cut < 4 && cut < buf.length; cut++) {
|
|
202
|
+
const slice = cut === 0 ? buf : buf.subarray(0, buf.length - cut);
|
|
200
203
|
try {
|
|
201
204
|
return new TextDecoder("utf-8", { fatal: true }).decode(slice);
|
|
202
205
|
}
|
package/dist/server/themes.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* - user : <dataDir>/themes/*.css (drop a css file here to add a theme)
|
|
12
12
|
*/
|
|
13
13
|
import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
14
|
-
import { join } from "node:path";
|
|
14
|
+
import { dirname, join, resolve } from "node:path";
|
|
15
15
|
/** Only simple file ids — no path traversal. */
|
|
16
16
|
const ID_RE = /^[A-Za-z0-9_-]+$/;
|
|
17
17
|
/** Display-name marker inside a theme css file (first lines):
|
|
@@ -111,3 +111,38 @@ export function resolveThemeFile(builtinDir, userDir, id) {
|
|
|
111
111
|
}
|
|
112
112
|
return null;
|
|
113
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* 读取主题 CSS,并安全展开其中的 `@import "./..."` 相对导入。
|
|
116
|
+
* - 仅允许相对当前主题文件所在目录的子路径(或同级);
|
|
117
|
+
* - 限制递归深度(默认 3 层)防循环引用;
|
|
118
|
+
* - 仅允许引入 .css 文件;
|
|
119
|
+
* - 确保生产/开发模式下均能无缝组合共享形态基底(如 bases/flow-base.css),免去客户端多次瀑布流请求。
|
|
120
|
+
*
|
|
121
|
+
* 返回的整份样式表会被包进 `@layer theme { ... }`(与 `web/src/styles.css` 的
|
|
122
|
+
* `@layer guard, base, theme;` 声明配套:主题层永远压在 base 之上,主题之间不再靠
|
|
123
|
+
* `!important` 抢权重)。只包**最外层一次**——递归内联的子文件必须原样返回,
|
|
124
|
+
* 否则会形成嵌套层(嵌套层无法与顶层 base/theme 正确比较顺序)。
|
|
125
|
+
* 调用方(`server/index.ts` 的 `/themes/:id.css`)行为不变:仍直接写回响应。
|
|
126
|
+
*/
|
|
127
|
+
export function readThemeCss(filePath, visited = new Set(), depth = 0) {
|
|
128
|
+
const css = inlineThemeImports(filePath, visited, depth);
|
|
129
|
+
if (depth > 0 || !css.trim())
|
|
130
|
+
return css;
|
|
131
|
+
return `@layer theme {\n${css.trimEnd()}\n}\n`;
|
|
132
|
+
}
|
|
133
|
+
/** `readThemeCss` 的内联主体:递归调用自身(不包层,见上文)。 */
|
|
134
|
+
function inlineThemeImports(filePath, visited, depth) {
|
|
135
|
+
if (depth > 3 || visited.has(filePath))
|
|
136
|
+
return "";
|
|
137
|
+
visited.add(filePath);
|
|
138
|
+
if (!existsSync(filePath) || !statSync(filePath).isFile())
|
|
139
|
+
return "";
|
|
140
|
+
const content = readFileSync(filePath, "utf8");
|
|
141
|
+
const dir = dirname(filePath);
|
|
142
|
+
return content.replace(/@import\s+["'](\.[^"']+\.css)["'];?\r?\n?/g, (_match, relPath) => {
|
|
143
|
+
const targetPath = resolve(dir, relPath);
|
|
144
|
+
if (!existsSync(targetPath) || !statSync(targetPath).isFile())
|
|
145
|
+
return "";
|
|
146
|
+
return inlineThemeImports(targetPath, visited, depth + 1) + "\n";
|
|
147
|
+
});
|
|
148
|
+
}
|
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
* 纯模块:零 node 依赖(不 import 任何 server 模块),前端可直接 import
|
|
16
16
|
* (vite 构建不断),单测零开销。
|
|
17
17
|
*/
|
|
18
|
+
/** 画布流水线编辑工具(定义见 canvas/canvas-agent-tool.ts,单 action:list/get/add_node/update_node/delete_node/add_edge/delete_edge/apply_dag)。 */
|
|
19
|
+
export const CANVAS_TOOL_NAME = "canvas";
|
|
18
20
|
/** 持久终端工具(定义见 terminals.ts,工具名在此唯一登记)。 */
|
|
19
21
|
export const TERMINAL_TOOL_NAMES = [
|
|
20
22
|
"terminal_create",
|
|
@@ -285,6 +287,14 @@ export const AGENT_TOOL_CATALOG = [
|
|
|
285
287
|
descKey: "toolsWorktreeDesc",
|
|
286
288
|
offHintKey: "toolsWorktreeOffHint",
|
|
287
289
|
},
|
|
290
|
+
{
|
|
291
|
+
name: CANVAS_TOOL_NAME,
|
|
292
|
+
group: "other",
|
|
293
|
+
defaultOn: true,
|
|
294
|
+
dshVisible: false,
|
|
295
|
+
descKey: "canvasToolEnabledDesc",
|
|
296
|
+
offHintKey: "canvasToolOffHint",
|
|
297
|
+
},
|
|
288
298
|
];
|
|
289
299
|
/** SDK 核心内置工具名(可被门控显式禁用或被预设白名单过滤)。 */
|
|
290
300
|
export const CORE_BUILTIN_TOOL_NAMES = ["bash", "read", "edit", "write", "powershell", "ls", "grep", "find"];
|
|
@@ -428,6 +438,26 @@ export function applyAgentToolsGating(session, disabled, preset, options) {
|
|
|
428
438
|
// load_tools 是延迟加载模式下的脚手架工具:非延迟加载模式下绝不暴露给模型。
|
|
429
439
|
// 默认从候选集中剔除;仅当延迟加载开启且由 options.forceActive 显式指定时才加回。
|
|
430
440
|
names.delete(LOAD_TOOLS_TOOL_NAME);
|
|
441
|
+
// PATCH-B1: MCP 工具尊重 exposure——codemode/deferred/hidden 不进门控基线。
|
|
442
|
+
// 全集基线会把非 direct 的 MCP 工具强制激活(schema 全量注入每轮请求,pi 本体的
|
|
443
|
+
// tool_search 按需加载被绕过,实测 deferred 配置下 241 个工具回归全量)。
|
|
444
|
+
// 现交给 pi 本体机制管理;存在 deferred 工具时保活 tool_search 发现通道
|
|
445
|
+
// (用户在禁用名单显式关掉 tool_search 时尊重其选择)。options.forceActive 可越过。
|
|
446
|
+
const allToolsSnapshot = session.getAllTools?.() ?? [];
|
|
447
|
+
let hasDeferredMcp = false;
|
|
448
|
+
for (const t of allToolsSnapshot) {
|
|
449
|
+
const ns = t?.namespace?.name ?? "";
|
|
450
|
+
if (typeof ns !== "string" || !ns.startsWith("mcp__"))
|
|
451
|
+
continue;
|
|
452
|
+
const exp = t.exposure ?? "codemode";
|
|
453
|
+
if (exp === "direct" || exp === "model-only")
|
|
454
|
+
continue;
|
|
455
|
+
names.delete(t.name);
|
|
456
|
+
if (exp === "deferred")
|
|
457
|
+
hasDeferredMcp = true;
|
|
458
|
+
}
|
|
459
|
+
if (hasDeferredMcp && allNames.includes("tool_search") && !off.has("tool_search"))
|
|
460
|
+
names.add("tool_search");
|
|
431
461
|
const filtered = filterToolsByPreset(names, preset);
|
|
432
462
|
const active = new Set(filtered);
|
|
433
463
|
const baseline = new Set(allNames);
|