pi-web-ui 0.113.0 → 0.114.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 +69 -1
- package/README.md +117 -252
- package/README.zh-CN.md +145 -223
- package/README.zh-TW.md +145 -223
- package/bin/device-hub-cli.mjs +577 -0
- package/bin/pi-device-hub.mjs +9 -0
- package/bin/pi-web-ui.mjs +145 -20
- package/dist/gh-comment-781.md +5 -0
- package/dist/server/agent-service-daemon.js +102 -24
- package/dist/server/agent-service.js +2296 -1121
- package/dist/server/approval-rules.js +29 -3
- package/dist/server/ask-user-question-tool.js +8 -8
- package/dist/server/atomic-file.js +35 -14
- package/dist/server/attachment-store.js +71 -35
- package/dist/server/attachments.js +18 -8
- package/dist/server/canvas/canvas-agent-tool.js +65 -15
- package/dist/server/canvas/canvas-dispatch.js +61 -20
- package/dist/server/canvas/canvas-orchestrator.js +516 -199
- package/dist/server/canvas/canvas-scheduler.js +99 -0
- package/dist/server/canvas/canvas-store.js +107 -54
- package/dist/server/canvas/canvas-validation.js +131 -0
- package/dist/server/canvas/canvas-workspace.js +284 -0
- package/dist/server/client-id-utils.js +8 -0
- package/dist/server/client-state.js +104 -22
- package/dist/server/communicate-tool.js +76 -0
- package/dist/server/compact-context-tool.js +2 -3
- package/dist/server/compaction-instructions.js +75 -0
- package/dist/server/compaction-markers.js +7 -2
- package/dist/server/compaction-state.js +84 -0
- package/dist/server/composer-drafts.js +43 -40
- package/dist/server/context-evidence.js +346 -0
- package/dist/server/control-socket.js +6 -2
- package/dist/server/conversation-communication.js +368 -0
- package/dist/server/conversation-read-tool.js +3 -4
- package/dist/server/conversation-tool-names.js +14 -0
- package/dist/server/conversation-tool.js +57 -0
- package/dist/server/delegate-mode.js +17 -4
- package/dist/server/device-center/bot-catalog.js +88 -0
- package/dist/server/device-center/bot-execution.js +106 -0
- package/dist/server/device-center/bots.js +170 -0
- package/dist/server/device-center/collab-service.js +153 -0
- package/dist/server/device-center/collab-tool.js +184 -0
- package/dist/server/device-center/connector.js +332 -0
- package/dist/server/device-center/desktop-linux.js +372 -0
- package/dist/server/device-center/desktop-native.js +413 -0
- package/dist/server/device-center/desktop-page.js +232 -0
- package/dist/server/device-center/desktop-setup.js +30 -0
- package/dist/server/device-center/desktop.js +387 -0
- package/dist/server/device-center/device-portals.js +241 -0
- package/dist/server/device-center/execution-failure.js +70 -0
- package/dist/server/device-center/executor.js +371 -0
- package/dist/server/device-center/file-sync.js +493 -0
- package/dist/server/device-center/hub-auth.js +69 -0
- package/dist/server/device-center/hub-page.js +68 -0
- package/dist/server/device-center/hub-setup.js +214 -0
- package/dist/server/device-center/hub.js +829 -0
- package/dist/server/device-center/local-page.js +17 -0
- package/dist/server/device-center/local.js +476 -0
- package/dist/server/device-center/main.js +118 -0
- package/dist/server/device-center/native-desktop/macos.js +192 -0
- package/dist/server/device-center/native-desktop/windows.js +118 -0
- package/dist/server/device-center/path-portal.js +120 -0
- package/dist/server/device-center/relay.js +959 -0
- package/dist/server/device-center/runtime.js +253 -0
- package/dist/server/device-center/smoke-preview.js +3 -0
- package/dist/server/device-center/store.js +122 -0
- package/dist/server/device-center/task-error.js +14 -0
- package/dist/server/device-center/transfers.js +293 -0
- package/dist/server/device-center/workspaces.js +45 -0
- package/dist/server/dispatch-domain-handlers.js +83 -27
- package/dist/server/dsh/dsh-agent-service.js +277 -158
- package/dist/server/dsh/dsh-client.js +12 -2
- package/dist/server/durable/durable-agent-service.js +1 -1
- package/dist/server/evidence-tool-hooks.js +49 -0
- package/dist/server/file-save.js +95 -0
- package/dist/server/file-transfer-routes.js +97 -47
- package/dist/server/files-service.js +110 -34
- package/dist/server/goal-review-gate.js +16 -6
- package/dist/server/goal-service.js +54 -30
- package/dist/server/http-proxy.js +120 -0
- package/dist/server/index.js +236 -232
- package/dist/server/load-timing.js +31 -0
- package/dist/server/mcp-bridge.js +219 -94
- package/dist/server/mcp-hot-reload.js +31 -5
- package/dist/server/mcp-manager.js +192 -93
- package/dist/server/mcp-oauth-login.js +169 -0
- package/dist/server/mcp-oauth-ui.js +137 -0
- package/dist/server/mcp-oauth.js +395 -0
- package/dist/server/mcp-project-runtime.js +207 -0
- package/dist/server/message-window.js +74 -21
- package/dist/server/net-guard.js +122 -20
- package/dist/server/payload-limits.js +17 -0
- package/dist/server/pending-question.js +82 -0
- package/dist/server/plan-mode.js +338 -137
- package/dist/server/plugin-assets.js +8 -4
- package/dist/server/plugin-chat-attachments.js +48 -0
- package/dist/server/plugin-facilities.js +67 -220
- package/dist/server/plugin-installer.js +2 -1
- package/dist/server/plugin-removal.js +49 -0
- package/dist/server/plugin-secrets.js +179 -0
- package/dist/server/plugins.js +262 -92
- package/dist/server/preset-fields.js +49 -0
- package/dist/server/preset-plugin-dependencies.js +57 -0
- package/dist/server/preset-share.js +112 -72
- package/dist/server/protocol-version.js +1 -1
- package/dist/server/queue-modes.js +10 -0
- package/dist/server/remote-ssh-service.js +160 -67
- package/dist/server/request-context.js +164 -0
- package/dist/server/sandbox-data.js +655 -0
- package/dist/server/sandbox-engines.js +7 -0
- package/dist/server/sandbox-runtime-gate.js +41 -0
- package/dist/server/sandbox-service.js +139 -698
- package/dist/server/sandbox-tool.js +21 -4
- package/dist/server/scheduler-tasks.js +63 -48
- package/dist/server/serialize.js +48 -19
- package/dist/server/session-branch.js +25 -3
- package/dist/server/session-parser.js +28 -18
- package/dist/server/session-scan.js +130 -0
- package/dist/server/session-search.js +51 -37
- package/dist/server/settings-service.js +267 -111
- package/dist/server/setup-config.js +58 -0
- package/dist/server/skill-maintenance.js +112 -24
- package/dist/server/subagent-helpers.js +4 -1
- package/dist/server/subagent-notify.js +4 -1
- package/dist/server/subagent-security-gate.js +52 -11
- package/dist/server/subagent-task.js +27 -0
- package/dist/server/subagents.js +217 -46
- package/dist/server/tabs.js +9 -1
- package/dist/server/terminals.js +467 -363
- package/dist/server/tool-guards.js +42 -6
- package/dist/server/tool-manager.js +47 -20
- package/dist/server/tool-overrides.js +13 -11
- package/dist/server/tool-prompt-overrides.js +32 -2
- package/dist/server/tool-prompts.js +1 -1
- package/dist/server/turn-timing.js +11 -0
- package/dist/server/universal/session-store.js +48 -6
- package/dist/server/universal/universal-service.js +1 -1
- package/dist/server/universal/universal-session.js +334 -231
- package/dist/server/uploads.js +64 -5
- package/dist/server/webui-context.js +6 -6
- package/dist/server/worktree-service.js +32 -24
- package/dist/server/ws-pending-queue.js +73 -27
- package/dist/test-artifact.md +9 -0
- package/dist/test-preview-modal.md +11 -0
- package/dist/test-report.html +20 -0
- package/docs/device-center.md +142 -0
- package/docs/device-desktop.md +48 -0
- package/package.json +4 -1
- package/plugin-sdk/index.d.ts +45 -9
- package/plugin-sdk/ssh-host-trust.mjs +225 -0
- package/plugins/catalog.json +1 -1
- package/themes/aetheris.css +1 -107
- package/themes/ayu-light.css +5 -29
- package/themes/bases/flow-base.css +0 -6
- package/themes/bases/statusbar-flat-base.css +112 -0
- package/themes/bases/zhujian-base.css +1 -0
- package/themes/bases/zhupi-base.css +1 -0
- package/themes/catppuccin-latte.css +4 -27
- package/themes/catppuccin.css +4 -35
- package/themes/claude-code-dark.css +1 -0
- package/themes/codex.css +4 -28
- package/themes/cyberpunk.css +3 -61
- package/themes/dark-teal.css +0 -1
- package/themes/dazzle.css +3 -73
- package/themes/everforest-light.css +4 -27
- package/themes/geist.css +4 -28
- package/themes/gruvbox-light.css +4 -27
- package/themes/kanagawa-lotus.css +4 -27
- package/themes/md-preview.css +3 -213
- package/themes/mist.css +4 -24
- package/themes/nord.css +4 -35
- package/themes/one-dark.css +4 -37
- package/themes/paper.css +4 -16
- package/themes/rose-pine-dawn.css +4 -28
- package/themes/sakura.css +4 -24
- package/themes/solarized-light.css +4 -27
- package/themes/tokyo-night.css +3 -34
- package/themes/white.css +4 -26
- package/themes/zhujian-dark.css +1 -0
- package/themes/zhupi-dark.css +1 -0
- package/web/dist/.build-assets.json +1 -0
- package/web/dist/assets/BgTasksModal-CS7UNzcw.js +1 -0
- package/web/dist/assets/BgTasksModal-Dk-tp78W.js +1 -0
- package/web/dist/assets/CanvasStudio-BEJZE5BI.js +1579 -0
- package/web/dist/assets/CanvasStudio-CgUNHqos.js +1579 -0
- package/web/dist/assets/DeviceCenter-C8_CbxQ3.js +3 -0
- package/web/dist/assets/DeviceCenter-CVblvhNX.js +3 -0
- package/web/dist/assets/Dropdown-Oug0DDte.js +1 -0
- package/web/dist/assets/FilePreview-CvdX6nr6.js +2 -0
- package/web/dist/assets/FilePreview-kCZhfBAF.js +2 -0
- package/web/dist/assets/GlobalSearchModal-BLH63yYP.js +1 -0
- package/web/dist/assets/GlobalSearchModal-DAkvlvp6.js +1 -0
- package/web/dist/assets/GroupConversation-Cgo4xbpa.js +1 -0
- package/web/dist/assets/GroupConversation-DZ71jEi8.js +1 -0
- package/web/dist/assets/ModelConfigModal-BpWdFdQC.js +2 -0
- package/web/dist/assets/PiSetupModal-mkWPSxMj.js +1 -0
- package/web/dist/assets/ProviderOAuthControls-VK_jqXYS.js +1 -0
- package/web/dist/assets/SCMPanel-BP1TUT-V.js +2 -0
- package/web/dist/assets/SCMPanel-BscPm9kf.js +2 -0
- package/web/dist/assets/SettingsModal-C8UgMjVM.js +20 -0
- package/web/dist/assets/SettingsModal-VynB7jNb.js +20 -0
- package/web/dist/assets/TerminalPanel-D6cPRFei.js +3 -0
- package/web/dist/assets/TerminalPanel-DL20uKgU.js +3 -0
- package/web/dist/assets/TuiOverlayModal-Dst3BmT8.js +1 -0
- package/web/dist/assets/TuiOverlayModal-NCkpNtTp.js +1 -0
- package/web/dist/assets/UniversalPathPicker-CfQFc_c3.js +1 -0
- package/web/dist/assets/UniversalPathPicker-DwxwNcFw.js +1 -0
- package/web/dist/assets/app-globals-CnO6KlEM.js +325 -0
- package/web/dist/assets/desktop-DPyTy4M3.js +1 -0
- package/web/dist/assets/es-DWMIuDU2.js +2 -0
- package/web/dist/assets/index-CPgAH5q7.js +83 -0
- package/web/dist/assets/index-Cje8iugL.js +83 -0
- package/web/dist/assets/index-DnKeiDbj.css +1 -0
- package/web/dist/assets/markdown-BggnuQ4H.js +40 -0
- package/web/dist/assets/markdown-C8LL_u4z.css +1 -0
- package/web/dist/assets/math-1uRJCsA9.js +257 -0
- package/web/dist/assets/math-BorAY7qD.css +1 -0
- package/web/dist/assets/plugin-host-CqA4yW6w.js +1 -0
- package/web/dist/assets/shortcut-stack-hhrDyRBn.js +1 -0
- package/web/dist/assets/theme-BqdAjEjF.js +1 -0
- package/web/dist/assets/uuid-BzDIGCwP.js +1 -0
- package/web/dist/index.html +15 -9
- package/web/dist/sw.js +1 -1
- package/web/dist/assets/TerminalPanel-3wojLfLk.js +0 -3
- package/web/dist/assets/index-A8YXwnpZ.js +0 -2008
- package/web/dist/assets/index-BwL7qBh6.css +0 -1
- package/web/dist/assets/markdown-BJZlfvdP.js +0 -296
- package/web/dist/assets/markdown-DSNUiDzp.css +0 -1
|
@@ -10,22 +10,19 @@
|
|
|
10
10
|
*
|
|
11
11
|
* 从 agent-service.ts 抽出为独立模块。
|
|
12
12
|
*/
|
|
13
|
-
import { readFileSync, statSync } from "node:fs";
|
|
14
13
|
import * as fsPromises from "node:fs/promises";
|
|
15
14
|
import { basename, resolve, sep } from "node:path";
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
import { sessionLines, mapSessionsConcurrent } from "./session-scan.js";
|
|
16
|
+
export { mapSessionsConcurrent } from "./session-scan.js";
|
|
17
|
+
/** Legacy whole-file reader guard, retained for readHistorySession callers only.
|
|
18
|
+
* Streaming search has no file-size cutoff. */
|
|
18
19
|
export const MAX_TRANSCRIPT_SCAN_BYTES = 16 * 1024 * 1024;
|
|
19
|
-
/**
|
|
20
|
-
* (issue #440 拆分后按需加载),封顶保证单条 worst case 内存可控(缓存 256 条
|
|
21
|
-
* × 256K 字符 ≈ 64MB 上界,且只在搜索活动期间存在)。
|
|
22
|
-
* 影响面:超长转录在截断点之后的内容不参与「是否命中」判定;命中后的消息级
|
|
23
|
-
* 定位(collectSessionAnchors)仍扫全文件,不受此上限影响。 */
|
|
20
|
+
/** Legacy parser text-preview budget. Search must use scanSessionForSearch. */
|
|
24
21
|
export const MAX_SEARCH_TEXT_CHARS = 256 * 1024;
|
|
25
22
|
/** 会话元数据快速匹配(列表初筛):仅比对 session.name、会话文件名与第一条消息。
|
|
26
23
|
* 显示名、当前项目内的文件名片段、首条消息。
|
|
27
24
|
* 转录全文匹配不在这里:全文单条可达 MB 级,不再随列表缓存常驻(issue #440),
|
|
28
|
-
* 由
|
|
25
|
+
* 由 searchSessions / scanSessionForSearch 流式判定(仅 user 与 assistant 消息文本)。 */
|
|
29
26
|
export function sessionMatchesMetadata(q, s) {
|
|
30
27
|
if (s.name && s.name.toLowerCase().includes(q))
|
|
31
28
|
return true;
|
|
@@ -53,49 +50,66 @@ export function messageSearchText(m) {
|
|
|
53
50
|
}
|
|
54
51
|
return parts.join("\n");
|
|
55
52
|
}
|
|
56
|
-
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const
|
|
53
|
+
/** One asynchronous pass determines the match and collects anchors. Only user and
|
|
54
|
+
* assistant text participates. A missing timestamp still counts as a text match.
|
|
55
|
+
* Invalid/unreadable records do not prevent searching other sessions. */
|
|
56
|
+
export async function scanSessionForSearch(filePath, query, cap = 10, signal) {
|
|
57
|
+
signal?.throwIfAborted();
|
|
58
|
+
const result = { matched: false, anchors: [] };
|
|
59
|
+
const q = query.trim().toLowerCase();
|
|
62
60
|
if (!q)
|
|
63
|
-
return
|
|
61
|
+
return result;
|
|
62
|
+
const limit = Number.isFinite(cap) ? Math.max(0, Math.floor(cap)) : 10;
|
|
64
63
|
try {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const lines = readFileSync(filePath, "utf8").split("\n");
|
|
68
|
-
for (const line of lines) {
|
|
69
|
-
if (!line.trim())
|
|
70
|
-
continue;
|
|
71
|
-
let e;
|
|
64
|
+
for await (const line of sessionLines(filePath, signal)) {
|
|
65
|
+
let entry;
|
|
72
66
|
try {
|
|
73
|
-
|
|
67
|
+
entry = JSON.parse(line);
|
|
74
68
|
}
|
|
75
69
|
catch {
|
|
76
70
|
continue;
|
|
77
71
|
}
|
|
78
|
-
if (
|
|
79
|
-
continue;
|
|
80
|
-
const m = e.message;
|
|
81
|
-
if (!m)
|
|
82
|
-
continue;
|
|
83
|
-
if (m.role !== "user" && m.role !== "assistant")
|
|
72
|
+
if (entry?.type !== "message")
|
|
84
73
|
continue;
|
|
85
|
-
|
|
74
|
+
const message = entry.message;
|
|
75
|
+
if (message?.role !== "user" && message?.role !== "assistant")
|
|
86
76
|
continue;
|
|
87
|
-
|
|
88
|
-
if (!text || !text.toLowerCase().includes(q))
|
|
77
|
+
if (!messageSearchText(message).toLowerCase().includes(q))
|
|
89
78
|
continue;
|
|
90
|
-
|
|
91
|
-
if (
|
|
79
|
+
result.matched = true;
|
|
80
|
+
if (typeof message.timestamp === "number" &&
|
|
81
|
+
Number.isFinite(message.timestamp) &&
|
|
82
|
+
result.anchors.length < limit) {
|
|
83
|
+
result.anchors.push({ role: message.role, timestamp: message.timestamp });
|
|
84
|
+
}
|
|
85
|
+
if (result.anchors.length >= limit)
|
|
92
86
|
break;
|
|
93
87
|
}
|
|
94
88
|
}
|
|
95
89
|
catch {
|
|
96
|
-
//
|
|
90
|
+
// Cancellation must propagate; only transcript errors are best effort.
|
|
91
|
+
signal?.throwIfAborted();
|
|
92
|
+
// Keep any matches already read from a partially readable transcript.
|
|
97
93
|
}
|
|
98
|
-
|
|
94
|
+
signal?.throwIfAborted();
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
/** Async compatibility entry point. Prefer scanSessionForSearch when also filtering. */
|
|
98
|
+
export async function collectSessionAnchors(filePath, q, cap = 10, signal) {
|
|
99
|
+
return (await scanSessionForSearch(filePath, q, cap, signal)).anchors;
|
|
100
|
+
}
|
|
101
|
+
/** Search every supplied candidate once, preserving order with bounded I/O.
|
|
102
|
+
* Metadata hits still scan text to provide anchors; no 200-session list limit.
|
|
103
|
+
* Empty queries return all candidates without opening their transcripts. */
|
|
104
|
+
export async function searchSessions(sessions, query, options = {}) {
|
|
105
|
+
const q = query.trim().toLowerCase();
|
|
106
|
+
const results = await mapSessionsConcurrent(sessions, async (session) => {
|
|
107
|
+
const scan = q
|
|
108
|
+
? await scanSessionForSearch(session.path, q, options.anchorCap, options.signal)
|
|
109
|
+
: { matched: true, anchors: [] };
|
|
110
|
+
return scan.matched || sessionMatchesMetadata(q, session) ? { session, anchors: scan.anchors } : null;
|
|
111
|
+
}, options.concurrency ?? 4, options.signal);
|
|
112
|
+
return results.filter((result) => result !== null);
|
|
99
113
|
}
|
|
100
114
|
/**
|
|
101
115
|
* pi 的会话存储根目录。设置了 `PI_CODING_AGENT_SESSION_DIR` 时,pi 将 transcript
|