pi-web-ui 0.106.0 → 0.107.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 +41 -1
- package/README.zh-TW.md +2 -2
- package/dist/server/agent-service.js +32 -16
- package/dist/server/client-state.js +2 -2
- package/dist/server/dsh/dsh-agent-service.js +15 -10
- package/dist/server/durable/durable-agent-service.js +153 -0
- package/dist/server/durable/durable-capabilities.js +11 -0
- package/dist/server/durable/durable-driver.js +481 -0
- package/dist/server/durable/durable-loader.js +38 -0
- package/dist/server/durable/durable-models.js +283 -0
- package/dist/server/durable/durable-storage.js +42 -0
- package/dist/server/durable/durable-tools.js +45 -0
- package/dist/server/durable/index.js +8 -0
- package/dist/server/engine-capabilities.js +20 -1
- package/dist/server/engine-probe.js +156 -8
- package/dist/server/global-loader.js +335 -0
- package/dist/server/index.js +127 -17
- package/dist/server/managed.js +2 -0
- package/dist/server/marker-service.js +5 -19
- package/dist/server/markers/index.js +1 -3
- package/dist/server/model-resolver.js +91 -3
- package/dist/server/plugins.js +18 -1
- package/dist/server/sdk-origin.js +2 -2
- package/dist/server/serialize.js +1 -1
- package/dist/server/tool-manager.js +3 -19
- package/dist/server/universal/driver-base.js +4 -0
- package/dist/server/universal/drivers/claude-code.js +3 -2
- package/dist/server/universal/universal-service.js +19 -2
- package/dist/server/universal/universal-session.js +61 -7
- package/dist/server/update-check.js +20 -8
- package/package.json +1 -1
- package/plugins/catalog.json +13 -2
- package/themes/dark-teal.css +0 -1
- package/themes/flow-light.css +1085 -0
- package/themes/flow.css +1094 -0
- package/themes/wallpaper-flow.css +1158 -0
- package/themes/wallpaper-obsidian.css +50 -0
- package/themes/zhujian-dark.css +0 -7
- package/themes/zhujian.css +0 -7
- package/themes/zhupi-dark.css +0 -7
- package/themes/zhupi.css +0 -7
- package/web/dist/assets/{TerminalPanel-CfxKLDW9.js → TerminalPanel-BnViyTlx.js} +2 -2
- package/web/dist/assets/index-cCRCYMwT.css +1 -0
- package/web/dist/assets/index-fH5vhkAE.js +690 -0
- package/web/dist/index.html +2 -2
- package/web/dist/sw.js +1 -1
- package/web/dist/assets/index-BtcP6BDk.css +0 -1
- package/web/dist/assets/index-XVtCzcHR.js +0 -690
package/CHANGELOG.md
CHANGED
|
@@ -8,7 +8,47 @@
|
|
|
8
8
|
每个版本的内容按"实际合入该版本发布的提交"归档(以 `package.json` 的 version 变更提交为准),
|
|
9
9
|
而不是按提交日期聚类——连续快速发布的 patch 版本以此为准最准确。
|
|
10
10
|
|
|
11
|
-
## [
|
|
11
|
+
## [0.107.0] — 2026-10-18
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- **设置面板全新结构化重构 (Settings Redesign)**:
|
|
16
|
+
- 设置页全新引入四大核心业务分组:「核心配置 (Core)」、「AI 与工具 (Tools)」、「界面与外观 (UI)」、「高级与扩展 (Advanced)」;
|
|
17
|
+
- 新增全局实时即搜即显搜索框,支持中英文关键词双向匹配高亮;
|
|
18
|
+
- 新增上下文安全区 (Context Safe Zone) 与供应商 Prompt Cache 缓存就绪状态指示器,带来沉浸式修改自动保存体验。
|
|
19
|
+
- **通用多源 TTS 语音合成插件 (`plugins/tts`)**:
|
|
20
|
+
- 深度聚合字节豆包大模型语音(阳光阿辰、磁性俊宇、清爽男大、阳光甜妹等)与 DeepSeek 官方音色(Echo、Tide、Mira、Stella);
|
|
21
|
+
- 内置配套 Chrome / Edge 伴侣扩展,支持在网页端一键无感同步双平台凭据;
|
|
22
|
+
- 原生接入系统设置中的语音引擎切换(浏览器内置 / 豆包语音 / DeepSeek 语音),并提供 `tts_speak` 智能体音频生成工具。
|
|
23
|
+
- **流式语音伴读 (Streaming TTS)**:
|
|
24
|
+
- 新增智能分句流式伴读机制,模型流式吐字的同时自动分句并行预取语音,首句 200~300ms 极速发声,告别大段长文本的漫长等待。
|
|
25
|
+
- **浅色流体主题 (Flow Light)**:
|
|
26
|
+
- 新增极简现代的「浅色流体」专属主题(`flow-light`),搭配细腻高光微透材质与清晰层次,日间编码更轻快舒适。
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
|
|
30
|
+
- **官方插件体验升级**:
|
|
31
|
+
- 动态壁纸插件(`wallpaper-engine` 0.3.59)优化了渲染性能负载与抽屉展开交互;
|
|
32
|
+
- 语音与拍照输入插件(`voice-input` 0.4.2)强化了听写识别流程与状态同步稳定性。
|
|
33
|
+
- **引擎探测与模型管理增强**:
|
|
34
|
+
- 改进多引擎(DSH、Claude 等)后台更新检测与版本同步;模型选择器支持在工作区范围与全量配置模型间自如切换。
|
|
35
|
+
|
|
36
|
+
### Fixed
|
|
37
|
+
|
|
38
|
+
- **标记系统精简与单测稳定性**:
|
|
39
|
+
- 清理废弃的内置 Todo 标记与孤立工具定义,精简智能体系统提示词上下文预算;
|
|
40
|
+
- 优化高并发测试环境下的引擎探测超时保护。
|
|
41
|
+
|
|
42
|
+
<!-- auto-i18n:start -->
|
|
43
|
+
### i18n
|
|
44
|
+
|
|
45
|
+
- 前端新增 key(23):`showAllModels`、`showEnabledModels`、`showAllModelsTitle`、`showEnabledModelsTitle`、`searchAllModelsHint`、`notInScopeBadge`、`settingsEngineDurableTitle`、`settingsEngineDurableDesc`、`engineTagDurable`、`engineUpdating`、`ttsStreamReplies`、`ttsStreamRepliesDesc`、`ttsEngine`、`ttsEngineBuiltin`、`settingsSearchPlaceholder`、`settingsSearchEmpty`、`settingsGroupCore`、`settingsGroupTools`、`settingsGroupUi`、`settingsGroupAdvanced`、`settingsAutoSavedTip`、`settingsContextSafeZone`、`settingsCacheReady`
|
|
46
|
+
- 前端删除 key(4):`updateEngineTabTitle`、`markerGroupTodo`、`todoListEnabledDesc`、`todoListOffHint`
|
|
47
|
+
- 前端中文变更(2):`ttsEnableDesc`、`settingsMarkersDesc`
|
|
48
|
+
- 前端英文变更(2):`ttsEnableDesc`、`settingsMarkersDesc`
|
|
49
|
+
- 服务端文案变更(1):`markers.service.guidance.frame`
|
|
50
|
+
- 服务端删除 key(18):`markers.service.describe.empty`、`markers.todo.guidance`、`markers.todo.new.requires.subject`、`markers.todo.new.created`、`markers.todo.set.invalid.id`、`markers.todo.set.invalid.status`、`markers.todo.set.task.missing`、`markers.todo.set.completed.no.pending`、`markers.todo.set.completed.no.inprogress`、`markers.todo.set.updated`、`markers.todo.remove.invalid.id`、`markers.todo.remove.task.missing`、`markers.todo.remove.deleted`、`markers.todo.dep.invalid.id`、`markers.todo.dep.task.missing`、`markers.todo.dep.invalid.dependencies`、`markers.todo.dep.blocks.updated`、`markers.todo.unknown.operation`
|
|
51
|
+
<!-- auto-i18n:end -->
|
|
12
52
|
|
|
13
53
|
## [0.106.0] — 2026-10-16
|
|
14
54
|
|
package/README.zh-TW.md
CHANGED
|
@@ -113,8 +113,8 @@ QQ 群組 1126050727
|
|
|
113
113
|
|
|
114
114
|
**代理工具與行內標記**
|
|
115
115
|
|
|
116
|
-
- **工具開關** —— 設定 →「工具」把所有可選工具逐個列出:統一的 `subagent` 工具(預設開)、以及另外
|
|
117
|
-
- **行內標記** —— 狀態改變不需要工具往返,AI
|
|
116
|
+
- **工具開關** —— 設定 →「工具」把所有可選工具逐個列出:統一的 `subagent` 工具(預設開)、以及另外 14 個工具 —— `edit_soft`、`browser_page`、`eval` 與 `lsp` 預設關,`delegate_task` / `ask_user_question` / `conversation_read` / `present_files` / `skill` / `schedule` / `claim_files` / `plan_update` / `patch` / `compact_context` 預設開。開關即時生效、不重新啟動,工具只是被停用仍保留註冊以便隨時開回;核心工具 `bash` 與 SDK 內建的 `read` / `write` / `edit` 走設定頁「核心工具」獨立區域管理。
|
|
117
|
+
- **行內標記** —— 狀態改變不需要工具往返,AI 直接把標記寫進回覆:不打斷的提醒用 `[[notify:<級別>:<內容>]]`,改對話標題用 `[[conv:rename:<標題>]]`,建議操作用 `[[action:suggest:<文字>]]`。氣泡定稿即執行,標記寫錯會以瀏覽器提示回顯。設定 →「工具」另有總開關與逐標記開關(這兩項全域共享)。
|
|
118
118
|
- **`edit_soft`** —— 更寬鬆的 `edit`(預設關):縮排/空白導致內建工具失敗時用它,先精確子串、再按去空白逐行核心比對,`newText` 原樣寫入並保留檔案換行符/BOM,結果帶 diff 與 unified patch。
|
|
119
119
|
- **`delegate_task`** —— 強制六段派單(TASK / EXPECTED OUTCOME / REQUIRED TOOLS / MUST DO / MUST NOT DO / CONTEXT)並在伺服器端校驗:範本不可用、任務少於 20 字或任一段為空都會被打回,並把可用範本清單回給模型。卡片按六段結構化展示,跑完後可一鍵跳到對應子代理對話。
|
|
120
120
|
- **`ask_user_question`** —— pi 引擎本身沒有問卷工具,這是 pi-web-ui 加的:模型可以問結構化問題(單選/多選 + 富文字選項預覽 + 自由文字),以對話方塊彈出;回答作為工具結果回給模型,取消則以工具錯誤返回,等你回答的時間不受工具看門狗限制,未答的問卷重新整理/重連後會恢復。
|
|
@@ -25,7 +25,7 @@ import { homedir } from "node:os";
|
|
|
25
25
|
import { basename, delimiter, dirname, join, resolve, sep } from "node:path";
|
|
26
26
|
import { fileURLToPath } from "node:url";
|
|
27
27
|
import { writeAtomicSync } from "./atomic-file.js";
|
|
28
|
-
import { createAgentSessionFromServices, createAgentSessionRuntime, createAgentSessionServices, createBashToolDefinition, createCodemodeExtension, createEditToolDefinition, createFindToolDefinition, createGrepToolDefinition, createLocalBashOperations, createLsToolDefinition, createToolSearchExtension, createWriteToolDefinition, getAgentDir, SessionManager, VERSION, estimateTokens, } from "@earendil-works/pi-coding-agent";
|
|
28
|
+
import { createAgentSessionFromServices, createAgentSessionRuntime, createAgentSessionServices, createBashToolDefinition, createCodemodeExtension, createEditToolDefinition, createFindToolDefinition, createGrepToolDefinition, createLocalBashOperations, createLsToolDefinition, createToolSearchExtension, createWriteToolDefinition, resolveModelScopeWithDiagnostics, getAgentDir, SessionManager, VERSION, estimateTokens, } from "@earendil-works/pi-coding-agent";
|
|
29
29
|
import { Type } from "typebox";
|
|
30
30
|
import { BG_CLEANUP_FALLBACK_MIN, BgServerTracker } from "./bg-servers.js";
|
|
31
31
|
import { checkAll as checkAllUpdates, collectTargets, compareVersions as compareSemver, detectPiSdkSplit, resolveNpmRegistry, sortUpdateItems, } from "./update-check.js";
|
|
@@ -74,7 +74,7 @@ import { goalReviewDenial, shouldDeferPromptForReview } from "./goal-review-gate
|
|
|
74
74
|
import { readPlanModeFromSession, readPlanFromSession } from "./permission-preset.js";
|
|
75
75
|
import { readDelegateModeFromSession } from "./permission-preset.js";
|
|
76
76
|
import { applyHeadTail, makePersistentTerminalTools, makeTerminalBashTool, stripAnsi, TERMINAL_TOOLS_GUIDANCE, } from "./terminals.js";
|
|
77
|
-
import { applyAgentToolsGating, ASK_USER_QUESTION_TOOL_NAME, BROWSER_PAGE_TOOL_NAME, effectiveDisabledAgentTools, filterToolsByPreset, isAgentToolEnabled, isTerminalGuidanceOn, LAZY_CORE_TOOL_NAMES, lazyLoadingDisabledTools, LOAD_TOOLS_TOOL_NAME, localizedName,
|
|
77
|
+
import { applyAgentToolsGating, ASK_USER_QUESTION_TOOL_NAME, BROWSER_PAGE_TOOL_NAME, effectiveDisabledAgentTools, filterToolsByPreset, isAgentToolEnabled, isTerminalGuidanceOn, LAZY_CORE_TOOL_NAMES, lazyLoadingDisabledTools, LOAD_TOOLS_TOOL_NAME, localizedName, PI_AGENT_PRESETS, PI_PERMISSION_OPTIONS, PLAN_UPDATE_TOOL_NAME, PRESENT_FILES_TOOL_NAME, presetAllowsPluginTools, presetHasQuestionnaire, presetShowsSkillCatalog, } from "./tool-manager.js";
|
|
78
78
|
import { makeLoadToolsTool } from "./load-tools-tool.js";
|
|
79
79
|
import { formatCompactSignature } from "./tool-signature.js";
|
|
80
80
|
import { WebUIContext } from "./webui-context.js";
|
|
@@ -209,13 +209,12 @@ import { withPlanModeGate, withGoalReviewGate, withDelegationGate, makeLateToolG
|
|
|
209
209
|
export { withPlanModeGate, withGoalReviewGate, withDelegationGate, makeLateToolGuard, withToolGuard, isInsideWorkspaceRoots, wrapWriteToolWithPermission, EDIT_DESCRIPTION, EDIT_GUIDELINES, wrapEditToolWithPermission, wrapEditSoftToolWithPermission, wrapBashToolWithPermission, };
|
|
210
210
|
import { normalizeSolPlanToPlanSteps, makePlanUpdateTool } from "./plan-update-tool.js";
|
|
211
211
|
export { normalizeSolPlanToPlanSteps, makePlanUpdateTool };
|
|
212
|
-
import { makeMarkersListTool } from "./markers-list-tool.js";
|
|
213
212
|
import { makeAskUserQuestionTool, shouldPopQuestion } from "./ask-user-question-tool.js";
|
|
214
213
|
import { normalizePageCallTimeoutMs, collectBrowserPageArgs, formatPageCallResult, formatBrowserPageError, makeBrowserPageTool, extractShotImage, } from "./browser-page-tool.js";
|
|
215
214
|
export { makeAskUserQuestionTool, shouldPopQuestion, normalizePageCallTimeoutMs, collectBrowserPageArgs, formatPageCallResult, formatBrowserPageError, makeBrowserPageTool, extractShotImage, };
|
|
216
215
|
import { RUN_TASK_CAP, RUN_ARGS_CAP, RUN_RESULT_CAP, getMaxOpenConversations, getMaxSubagents, SUBAGENT_PROMPT_SNAPSHOT_CAP, DEFAULT_CONV_TITLE, truncRun, previewToolResult, atomicWriteFileSync, conversationTitle, pluginToolToDefinition, contentFingerprint, extractPartialText, extractAssistantTextFromContent, firstSentence, modelKeyOf, contextWindowOf, } from "./agent-formatters.js";
|
|
217
216
|
export { workspacePath };
|
|
218
|
-
import { MAX_TRANSCRIPT_SCAN_BYTES,
|
|
217
|
+
import { MAX_TRANSCRIPT_SCAN_BYTES, sessionMatchesMetadata, collectSessionAnchors, piSessionsRoot, isInsideSessionsDir, } from "./session-search.js";
|
|
219
218
|
export { piSessionsRoot, isInsideSessionsDir };
|
|
220
219
|
import { discoverRecentProjectsFromDisk, filterForkedParentSessions, findMostRecentSessionFileFast, parseSessionInfoFast, } from "./session-parser.js";
|
|
221
220
|
import { pickAdoptableOrphan, sameCwd } from "./orphan-manager.js";
|
|
@@ -1645,7 +1644,7 @@ export class ClientSession {
|
|
|
1645
1644
|
sandboxes;
|
|
1646
1645
|
/** 当前工作区关联的 Git 工作树元数据(用于顶栏横幅与 AI 工具同步)。 */
|
|
1647
1646
|
worktreeInfo = null;
|
|
1648
|
-
/** 内置标记服务(
|
|
1647
|
+
/** 内置标记服务(action/notify/conv 等,可全局/分组开关)。 */
|
|
1649
1648
|
markerSvc;
|
|
1650
1649
|
// -----------------------------------------------------------------------
|
|
1651
1650
|
// 用户提问桥(标准 pi 引擎的 ask_user_question customTool):与 DSH 引擎的
|
|
@@ -1712,7 +1711,7 @@ export class ClientSession {
|
|
|
1712
1711
|
// issue #91:标记引导/错误按客户端 UI 语言出中英(英文默认)。
|
|
1713
1712
|
lang: () => this.getLang(),
|
|
1714
1713
|
});
|
|
1715
|
-
// 标记 widget 动态渲染「当前活动会话」的
|
|
1714
|
+
// 标记 widget 动态渲染「当前活动会话」的 overlay:切换会话时只要刷新
|
|
1716
1715
|
// webUi(见 switchConversation/setCwd/newChat)就会显示对应会话的标记,
|
|
1717
1716
|
// 且与扩展 widget 合并下发、不会互相覆盖。
|
|
1718
1717
|
this.webUi.setDynamicWidget("markers", () => this.markerSvc.overlayLines(this.activeId));
|
|
@@ -2459,8 +2458,6 @@ export class ClientSession {
|
|
|
2459
2458
|
...(ownerId
|
|
2460
2459
|
? [makeDelegateTaskTool(withSubagentOwner(this.subagentHost, ownerId))]
|
|
2461
2460
|
: [makeDelegateTaskTool(this.subagentHost)]),
|
|
2462
|
-
// 内置标记只读查询工具(todo/svc 状态查询,写操作走内联标记)。
|
|
2463
|
-
makeMarkersListTool(() => this.activeId, this.markerSvc),
|
|
2464
2461
|
// 结构化任务计划更新(Plan Mode / Step State Machine)。
|
|
2465
2462
|
makePlanUpdateTool(this.planManager, () => {
|
|
2466
2463
|
const id = ownerId ?? this.activeId;
|
|
@@ -3675,7 +3672,7 @@ export class ClientSession {
|
|
|
3675
3672
|
this.scheduleSessionsRefresh();
|
|
3676
3673
|
this.refreshConversationTitle(conv);
|
|
3677
3674
|
// 内联标记不在此兜底扫最后一条 assistant:每条气泡结束已走 message_end
|
|
3678
|
-
//
|
|
3675
|
+
// 即时解析(含中间文本块);这里再扫会把最后一条标记重复执行。
|
|
3679
3676
|
// Manual interrupt (Stop button / abort): the last assistant message
|
|
3680
3677
|
// carries stopReason "aborted". A half-finished run should NOT be
|
|
3681
3678
|
// reviewed (it would fail and inject a revision, only to be stopped
|
|
@@ -11505,10 +11502,12 @@ export class ClientSession {
|
|
|
11505
11502
|
.slice(0, 50)
|
|
11506
11503
|
.map((s) => {
|
|
11507
11504
|
const isPinned = this.stateStore?.isSessionPinned(this.cwd, s.path);
|
|
11505
|
+
const displayName = s.name?.trim() || (s.firstMessage ? s.firstMessage.trim().replace(/\s+/g, " ") : undefined);
|
|
11508
11506
|
const base = {
|
|
11509
11507
|
path: s.path,
|
|
11510
11508
|
...(s.id ? { sessionId: s.id } : {}),
|
|
11511
11509
|
name: s.name,
|
|
11510
|
+
displayName,
|
|
11512
11511
|
firstMessage: s.firstMessage,
|
|
11513
11512
|
messageCount: s.messageCount,
|
|
11514
11513
|
modified: s.modified.getTime(),
|
|
@@ -12159,13 +12158,30 @@ export class ClientSession {
|
|
|
12159
12158
|
// list must never fail because the catalog sync did
|
|
12160
12159
|
});
|
|
12161
12160
|
const available = await mr.getAvailable();
|
|
12162
|
-
|
|
12163
|
-
|
|
12164
|
-
|
|
12165
|
-
|
|
12166
|
-
|
|
12167
|
-
|
|
12168
|
-
|
|
12161
|
+
// 遵循 ~/.pi/agent/settings.json 中的 enabledModels 白名单限定(issue #646)
|
|
12162
|
+
let enabledSet = null;
|
|
12163
|
+
try {
|
|
12164
|
+
const sm = this.session?.settingsManager ?? this.runtime?.services?.settingsManager;
|
|
12165
|
+
const patterns = sm?.getEnabledModels?.();
|
|
12166
|
+
if (Array.isArray(patterns) && patterns.length > 0 && typeof resolveModelScopeWithDiagnostics === "function") {
|
|
12167
|
+
const { scopedModels } = await resolveModelScopeWithDiagnostics(patterns, mr);
|
|
12168
|
+
enabledSet = new Set(scopedModels.map((s) => `${s.model.provider}/${s.model.id}`));
|
|
12169
|
+
}
|
|
12170
|
+
}
|
|
12171
|
+
catch {
|
|
12172
|
+
// 作用域解析异常时静默回退全量(enabledSet 保持 null)
|
|
12173
|
+
}
|
|
12174
|
+
const models = available.map((m) => {
|
|
12175
|
+
const fullId = `${m.provider}/${m.id}`;
|
|
12176
|
+
return {
|
|
12177
|
+
id: fullId,
|
|
12178
|
+
name: this.cleanModelDisplayName(m.name),
|
|
12179
|
+
provider: m.provider,
|
|
12180
|
+
reasoning: m.reasoning,
|
|
12181
|
+
vision: m.input?.includes("image") ?? false,
|
|
12182
|
+
...(enabledSet ? { enabled: enabledSet.has(fullId) } : {}),
|
|
12183
|
+
};
|
|
12184
|
+
});
|
|
12169
12185
|
this.emit({ type: "models", models });
|
|
12170
12186
|
}
|
|
12171
12187
|
catch (err) {
|
|
@@ -1351,7 +1351,7 @@ export class ClientStateStore {
|
|
|
1351
1351
|
/** 读取某客户端(标签页)上次使用的引擎(未设置返回 undefined)。 */
|
|
1352
1352
|
getClientEngine(clientId) {
|
|
1353
1353
|
const eng = this.load()[clientId]?.engine;
|
|
1354
|
-
return eng === "dsh" || eng === "pi" || eng === "claude" ? eng : undefined;
|
|
1354
|
+
return eng === "dsh" || eng === "pi" || eng === "claude" || eng === "durable" ? eng : undefined;
|
|
1355
1355
|
}
|
|
1356
1356
|
/** 保存某客户端(标签页)当前使用的引擎。 */
|
|
1357
1357
|
saveClientEngine(clientId, engine) {
|
|
@@ -1364,7 +1364,7 @@ export class ClientStateStore {
|
|
|
1364
1364
|
/** 读取全局默认引擎(存在 __settings__ 下,新标签页及服务重启后默认跟随)。 */
|
|
1365
1365
|
getDefaultEngine() {
|
|
1366
1366
|
const eng = this.load()[ClientStateStore.GLOBAL_SETTINGS_KEY]?.defaultEngine;
|
|
1367
|
-
return eng === "dsh" || eng === "pi" || eng === "claude" ? eng : undefined;
|
|
1367
|
+
return eng === "dsh" || eng === "pi" || eng === "claude" || eng === "durable" ? eng : undefined;
|
|
1368
1368
|
}
|
|
1369
1369
|
/** 保存全局默认引擎。 */
|
|
1370
1370
|
saveDefaultEngine(engine) {
|
|
@@ -50,7 +50,7 @@ import { previewKind } from "../text-sniff.js";
|
|
|
50
50
|
import { removeQueuedByIndexOrText } from "../queue-utils.js";
|
|
51
51
|
import { launchOrigin, toServiceInfo } from "../launch-origin.js";
|
|
52
52
|
import { DshRuntime, loadDeepSeekKey } from "./dsh-client.js";
|
|
53
|
-
import { resolveProviderCredential, listCustomModelsFromConfig } from "../model-resolver.js";
|
|
53
|
+
import { resolveProviderCredential, listCustomModelsFromConfig, isModelProtocolSupportedByEngine, } from "../model-resolver.js";
|
|
54
54
|
import { loadDshMarketData } from "./dsh-market-service.js";
|
|
55
55
|
import { formatTextQuote, readTextQuote, messageTextWithQuotes } from "../text-quote.js";
|
|
56
56
|
import { MarkerService } from "../marker-service.js";
|
|
@@ -3159,13 +3159,18 @@ export class DshClientSession {
|
|
|
3159
3159
|
// 审查会话不进搜索。
|
|
3160
3160
|
if (sessionId.startsWith("review-"))
|
|
3161
3161
|
continue;
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3162
|
+
const firstMsg = firstUserText(events, this.getLang());
|
|
3163
|
+
if (all.includes(q) || sessionId.toLowerCase().includes(q) || firstMsg.toLowerCase().includes(q)) {
|
|
3164
|
+
const storedTitle = this.stateStore?.getSessionTitle(this.cwd, file) ?? this.stateStore?.getSessionTitle(this.cwd, sessionId);
|
|
3165
|
+
const explicitTitle = storedTitle ??
|
|
3166
|
+
sessionLogTitle(events) ??
|
|
3167
|
+
[...this.convs.values()].find((c) => c.sessionId === sessionId && !DshClientSession.isDefaultTitle(c.title))?.title;
|
|
3168
|
+
const displayName = this.resolveSessionDisplayName(sessionId, explicitTitle, firstMsg);
|
|
3165
3169
|
results.push({
|
|
3166
3170
|
path: file,
|
|
3167
|
-
name: sessionId,
|
|
3168
|
-
|
|
3171
|
+
name: explicitTitle ?? sessionId,
|
|
3172
|
+
displayName,
|
|
3173
|
+
firstMessage: firstMsg,
|
|
3169
3174
|
messageCount: events.filter((e) => (e.type === "user/message" && !isDshInternalUserMessage(e.data)) ||
|
|
3170
3175
|
e.type === "assistant/message" ||
|
|
3171
3176
|
e.type === "tool/result").length,
|
|
@@ -3308,9 +3313,9 @@ export class DshClientSession {
|
|
|
3308
3313
|
vision,
|
|
3309
3314
|
});
|
|
3310
3315
|
}
|
|
3311
|
-
// 3. 用户在 models.json
|
|
3316
|
+
// 3. 用户在 models.json 中配置的第三方自定义端点模型(针对性过滤 DSH 不支持的协议,如 anthropic-messages)
|
|
3312
3317
|
try {
|
|
3313
|
-
const custom = listCustomModelsFromConfig(this.agentDir);
|
|
3318
|
+
const custom = listCustomModelsFromConfig(this.agentDir, (entry) => isModelProtocolSupportedByEngine("dsh", entry));
|
|
3314
3319
|
for (const c of custom) {
|
|
3315
3320
|
const canonicalId = `${c.providerId}/${c.modelId}`;
|
|
3316
3321
|
if (seen.has(canonicalId))
|
|
@@ -3364,7 +3369,7 @@ export class DshClientSession {
|
|
|
3364
3369
|
}
|
|
3365
3370
|
else {
|
|
3366
3371
|
try {
|
|
3367
|
-
const customList = listCustomModelsFromConfig(this.agentDir);
|
|
3372
|
+
const customList = listCustomModelsFromConfig(this.agentDir, (entry) => isModelProtocolSupportedByEngine("dsh", entry));
|
|
3368
3373
|
const hit = customList.find((c) => `${c.providerId}/${c.modelId}` === normId || c.modelId === normId || c.modelId === bareModelId);
|
|
3369
3374
|
if (hit) {
|
|
3370
3375
|
meta = {
|
|
@@ -4822,7 +4827,7 @@ export class DshClientSession {
|
|
|
4822
4827
|
return true;
|
|
4823
4828
|
}
|
|
4824
4829
|
try {
|
|
4825
|
-
const custom = listCustomModelsFromConfig(this.agentDir);
|
|
4830
|
+
const custom = listCustomModelsFromConfig(this.agentDir, (entry) => isModelProtocolSupportedByEngine("dsh", entry));
|
|
4826
4831
|
if (custom.length > 0) {
|
|
4827
4832
|
for (const c of custom) {
|
|
4828
4833
|
if (resolveProviderCredential(this.agentDir, c.providerId).apiKey)
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* durable-agent-service.ts — Pi Durable 独立智能体引擎顶层服务(实现 EngineService)。
|
|
3
|
+
*
|
|
4
|
+
* 职责:
|
|
5
|
+
* 1. 管理 Pi Durable 驱动及会话调度;
|
|
6
|
+
* 2. 借助通用宿主底座(UniversalSession)提供完整 160+ 个 Web UI 交互契约;
|
|
7
|
+
* 3. 负责安静停机(quiesce)、状态汇总(serviceStatus)与生命周期销毁。
|
|
8
|
+
*/
|
|
9
|
+
import { existsSync } from "node:fs";
|
|
10
|
+
import { UniversalSessionStore } from "../universal/session-store.js";
|
|
11
|
+
import { UniversalSession } from "../universal/universal-session.js";
|
|
12
|
+
import { DurableAgentDriver } from "./durable-driver.js";
|
|
13
|
+
import { getAppVersion } from "../pkg-info.js";
|
|
14
|
+
export class DurableAgentService {
|
|
15
|
+
cwd;
|
|
16
|
+
dataDir;
|
|
17
|
+
store;
|
|
18
|
+
stateStore;
|
|
19
|
+
sessions = new Map();
|
|
20
|
+
agentDir;
|
|
21
|
+
quiesced = false;
|
|
22
|
+
quiescedSince;
|
|
23
|
+
socketCount = 0;
|
|
24
|
+
pluginCommandsProvider;
|
|
25
|
+
onQuit;
|
|
26
|
+
constructor(opts) {
|
|
27
|
+
this.cwd = opts.cwd;
|
|
28
|
+
this.dataDir = opts.dataDir;
|
|
29
|
+
this.agentDir = opts.agentDir;
|
|
30
|
+
this.store = new UniversalSessionStore(opts.dataDir);
|
|
31
|
+
this.stateStore = opts.stateStore;
|
|
32
|
+
}
|
|
33
|
+
async attach(clientId, send) {
|
|
34
|
+
let session = this.sessions.get(clientId);
|
|
35
|
+
if (!session) {
|
|
36
|
+
let effectiveCwd = this.cwd;
|
|
37
|
+
const saved = this.stateStore?.get(clientId);
|
|
38
|
+
if (saved?.lastCwd && saved.lastCwd !== this.cwd) {
|
|
39
|
+
try {
|
|
40
|
+
if (existsSync(saved.lastCwd)) {
|
|
41
|
+
effectiveCwd = saved.lastCwd;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
/* fallback */
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (typeof this.stateStore?.remember === "function") {
|
|
49
|
+
this.stateStore.remember(clientId, effectiveCwd);
|
|
50
|
+
}
|
|
51
|
+
const driver = new DurableAgentDriver(effectiveCwd, { dataDir: this.dataDir, agentDir: this.agentDir });
|
|
52
|
+
session = new UniversalSession({
|
|
53
|
+
clientId,
|
|
54
|
+
cwd: effectiveCwd,
|
|
55
|
+
dataDir: this.dataDir,
|
|
56
|
+
agentDir: this.agentDir,
|
|
57
|
+
send,
|
|
58
|
+
store: this.store,
|
|
59
|
+
stateStore: this.stateStore,
|
|
60
|
+
driver,
|
|
61
|
+
driverFactory: (cwd) => new DurableAgentDriver(cwd, { dataDir: this.dataDir, agentDir: this.agentDir }),
|
|
62
|
+
engine: "durable",
|
|
63
|
+
pluginCommandsProvider: () => this.pluginCommandsProvider?.() ?? [],
|
|
64
|
+
onQuit: () => this.onQuit?.() ?? false,
|
|
65
|
+
});
|
|
66
|
+
this.sessions.set(clientId, session);
|
|
67
|
+
session.attachSink(send);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
session.attachSink(send);
|
|
71
|
+
}
|
|
72
|
+
return session;
|
|
73
|
+
}
|
|
74
|
+
detach(clientId, send) {
|
|
75
|
+
const session = this.sessions.get(clientId);
|
|
76
|
+
if (session) {
|
|
77
|
+
session.detachSink(send);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
get(clientId) {
|
|
81
|
+
return this.sessions.get(clientId);
|
|
82
|
+
}
|
|
83
|
+
async disposeAll() {
|
|
84
|
+
for (const session of this.sessions.values()) {
|
|
85
|
+
session.dispose();
|
|
86
|
+
}
|
|
87
|
+
this.sessions.clear();
|
|
88
|
+
}
|
|
89
|
+
recordInterruptedRuns() {
|
|
90
|
+
// Durable 引擎自带事务级检查点,无需手动序列化内存临时态
|
|
91
|
+
}
|
|
92
|
+
noteSocketOpen() {
|
|
93
|
+
this.socketCount++;
|
|
94
|
+
}
|
|
95
|
+
noteSocketClose() {
|
|
96
|
+
this.socketCount = Math.max(0, this.socketCount - 1);
|
|
97
|
+
}
|
|
98
|
+
isQuiesced() {
|
|
99
|
+
return this.quiesced;
|
|
100
|
+
}
|
|
101
|
+
quiesce() {
|
|
102
|
+
this.quiesced = true;
|
|
103
|
+
this.quiescedSince = Date.now();
|
|
104
|
+
}
|
|
105
|
+
unquiesce() {
|
|
106
|
+
this.quiesced = false;
|
|
107
|
+
this.quiescedSince = undefined;
|
|
108
|
+
}
|
|
109
|
+
quiesceInfo() {
|
|
110
|
+
return { quiesced: this.quiesced, quiescedSince: this.quiescedSince };
|
|
111
|
+
}
|
|
112
|
+
serviceStatus() {
|
|
113
|
+
return {
|
|
114
|
+
pid: process.pid,
|
|
115
|
+
version: getAppVersion(),
|
|
116
|
+
cwd: this.cwd,
|
|
117
|
+
quiesced: this.quiesced,
|
|
118
|
+
quiescedSince: this.quiescedSince,
|
|
119
|
+
connectedClients: this.socketCount,
|
|
120
|
+
activeConversations: this.activeConversations(),
|
|
121
|
+
pendingMessages: this.pendingMessages(),
|
|
122
|
+
service: null,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
activeConversations() {
|
|
126
|
+
let count = 0;
|
|
127
|
+
for (const session of this.sessions.values()) {
|
|
128
|
+
if (session.isStreaming)
|
|
129
|
+
count++;
|
|
130
|
+
}
|
|
131
|
+
return count;
|
|
132
|
+
}
|
|
133
|
+
pendingMessages() {
|
|
134
|
+
return 0;
|
|
135
|
+
}
|
|
136
|
+
applyPluginAgentTools() {
|
|
137
|
+
// 插件工具热重载通知
|
|
138
|
+
}
|
|
139
|
+
applyPluginCommandCatalog() {
|
|
140
|
+
// 斜杠命令热重载通知
|
|
141
|
+
}
|
|
142
|
+
refreshBackgroundServers() {
|
|
143
|
+
for (const session of this.sessions.values()) {
|
|
144
|
+
session.listBgServers();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
async setLocale(clientId, locale) {
|
|
148
|
+
const session = this.sessions.get(clientId);
|
|
149
|
+
if (session) {
|
|
150
|
+
await session.setLocale(locale);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* durable-capabilities.ts — Pi Durable 引擎的能力事实源。
|
|
3
|
+
*/
|
|
4
|
+
import { DEFAULT_DURABLE_CAPABILITIES } from "../engine-capabilities.js";
|
|
5
|
+
export { DEFAULT_DURABLE_CAPABILITIES };
|
|
6
|
+
export function resolveDurableCapabilities(caps) {
|
|
7
|
+
return {
|
|
8
|
+
...DEFAULT_DURABLE_CAPABILITIES,
|
|
9
|
+
...caps,
|
|
10
|
+
};
|
|
11
|
+
}
|