pi-web-ui 0.25.0 → 0.26.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.
|
@@ -18,7 +18,7 @@ import { createAgentSessionFromServices, createAgentSessionRuntime, createAgentS
|
|
|
18
18
|
import { Type } from "typebox";
|
|
19
19
|
import { serializeMessage, serializeStreamingMessage, } from "./serialize.js";
|
|
20
20
|
import { loadCommands, saveCommandsFile, TerminalManager, } from "./terminals.js";
|
|
21
|
-
import { buildVisionBridgePrompt, findVisionModels, transcribeImages, } from "./vision-bridge.js";
|
|
21
|
+
import { buildVisionBridgePrompt, findVisionModels, SYSTEM_PROMPT, transcribeImages, } from "./vision-bridge.js";
|
|
22
22
|
const SNAPSHOT_INTERVAL_MS = 60;
|
|
23
23
|
const WIDGET_REFRESH_MS = 2000;
|
|
24
24
|
const WIDGET_WIDTH = 80;
|
|
@@ -1114,6 +1114,30 @@ export class ClientSession {
|
|
|
1114
1114
|
* a question doesn't re-burn tokens on re-transcribing identical screenshots.
|
|
1115
1115
|
*/
|
|
1116
1116
|
visionBridgeCache = new Map();
|
|
1117
|
+
/** Most recent built-in (default) system prompt observed by the
|
|
1118
|
+
* resource-loader override — surfaced via settings_state so the
|
|
1119
|
+
* replace-mode editor can show the prompt it would otherwise replace.
|
|
1120
|
+
* Only non-empty when the user has a system-prompt file. */
|
|
1121
|
+
lastBaseSystemPrompt = "";
|
|
1122
|
+
/** The system prompt the replace-mode editor should show as its seed:
|
|
1123
|
+
* the user's system-prompt file content if one exists, otherwise the
|
|
1124
|
+
* SDK's built-in default actually in effect (agent.state.systemPrompt,
|
|
1125
|
+
* which the loader rebuilds at session init). If the user HAS a custom
|
|
1126
|
+
* prompt the seed is only cosmetic — an unmodified seed is saved as
|
|
1127
|
+
* empty and the server falls back to the true base. */
|
|
1128
|
+
effectiveDefaultSystemPrompt() {
|
|
1129
|
+
if (this.lastBaseSystemPrompt)
|
|
1130
|
+
return this.lastBaseSystemPrompt;
|
|
1131
|
+
try {
|
|
1132
|
+
const sp = this.session.agent.state.systemPrompt;
|
|
1133
|
+
if (typeof sp === "string" && sp)
|
|
1134
|
+
return sp;
|
|
1135
|
+
}
|
|
1136
|
+
catch {
|
|
1137
|
+
// Session not ready yet.
|
|
1138
|
+
}
|
|
1139
|
+
return "";
|
|
1140
|
+
}
|
|
1117
1141
|
/** Web-facing extension UI context (widgets, notifications). */
|
|
1118
1142
|
webUi = new WebUIContext((msg) => this.emit(msg));
|
|
1119
1143
|
widgetsTimer = null;
|
|
@@ -1203,10 +1227,17 @@ export class ClientSession {
|
|
|
1203
1227
|
// 新对话(新 runtime)也会自动带上当前设置。
|
|
1204
1228
|
resourceLoaderOptions: {
|
|
1205
1229
|
// 系统提示词:replace 模式整体替换;append 模式追加到提示词末尾。
|
|
1206
|
-
systemPromptOverride: (base) =>
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1230
|
+
systemPromptOverride: (base) => {
|
|
1231
|
+
// Remember the built-in default so the settings panel can show
|
|
1232
|
+
// it when the user edits in replace mode.
|
|
1233
|
+
if (typeof base === "string" && base) {
|
|
1234
|
+
this.lastBaseSystemPrompt = base;
|
|
1235
|
+
}
|
|
1236
|
+
return this.settings.promptMode === "replace" &&
|
|
1237
|
+
this.settings.customSystemPrompt.trim()
|
|
1238
|
+
? this.settings.customSystemPrompt
|
|
1239
|
+
: base;
|
|
1240
|
+
},
|
|
1210
1241
|
appendSystemPromptOverride: (base) => {
|
|
1211
1242
|
const out = [...base];
|
|
1212
1243
|
const custom = this.settings.customSystemPrompt.trim();
|
|
@@ -2539,6 +2570,11 @@ export class ClientSession {
|
|
|
2539
2570
|
visionBridgeModel: this.settings.visionBridgeModel,
|
|
2540
2571
|
visionBridgePromptMode: this.settings.visionBridgePromptMode,
|
|
2541
2572
|
visionBridgePrompt: this.settings.visionBridgePrompt,
|
|
2573
|
+
// The built-in prompts, so the replace-mode editors can prefill the
|
|
2574
|
+
// text they would otherwise replace (empty until the resource-loader
|
|
2575
|
+
// has run once for the system prompt).
|
|
2576
|
+
defaultSystemPrompt: this.effectiveDefaultSystemPrompt(),
|
|
2577
|
+
visionBridgeDefaultPrompt: SYSTEM_PROMPT,
|
|
2542
2578
|
visionModels: this.collectVisionModels(),
|
|
2543
2579
|
disabledSkills: [...this.settings.disabledSkills],
|
|
2544
2580
|
disabledExtensions: [...this.settings.disabledExtensions],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-web-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"description": "Web chat interface for the pi coding agent, powered by the pi SDK (@earendil-works/pi-coding-agent) — one-command run, Docker/systemd/launchd deployable",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|