pi-webapp 0.1.45 → 0.1.47

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/README.md CHANGED
@@ -6,7 +6,7 @@ Conversations, project files, terminals, and Git—side by side. Use the same wo
6
6
 
7
7
  [简体中文](README.zh-CN.md) · [Get started](#get-started) · [Download desktop](#desktop-downloads) · [Architecture](#architecture-highlights) · [User guide](docs/en/getting-started.md) · [npm](https://www.npmjs.com/package/pi-webapp)
8
8
 
9
- **Desktop test build 12:** [macOS Apple Silicon DMG](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.39-b12/pi-0.1.39-desktop.12-mac-arm64.dmg) · [Intel, Windows & Linux downloads](#desktop-downloads) · [SHA-256 checksums](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.39-b12/SHA256SUMS). These are unsigned/unnotarized test packages. See [safe installation](docs/desktop-testing.md).
9
+ **Desktop test build 14:** [macOS Apple Silicon DMG](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.39-b14/pi-0.1.39-desktop.14-mac-arm64.dmg) · [Intel, Windows & Linux downloads](#desktop-downloads) · [SHA-256 checksums](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.39-b14/SHA256SUMS). These are unsigned/unnotarized test packages. See [safe installation](docs/desktop-testing.md).
10
10
 
11
11
  [![Pi workbench with project sessions, an agent conversation, and a highlighted code preview](assets/readme/workbench.png)](assets/readme/workbench.png)
12
12
 
@@ -105,25 +105,25 @@ Enter **`/web`** inside Pi. The browser stays synchronized with that terminal se
105
105
 
106
106
  ## Desktop downloads
107
107
 
108
- **Latest desktop test release: [pi 0.1.39 · build 12](https://github.com/chengzhiyi/pi-webapp/releases/tag/desktop-v0.1.39-b12).** Download the installer for your operating system and CPU:
108
+ **Latest desktop test release: [pi 0.1.39 · build 14](https://github.com/chengzhiyi/pi-webapp/releases/tag/desktop-v0.1.39-b14).** Download the installer for your operating system and CPU:
109
109
 
110
110
  | Platform | Download |
111
111
  | --- | --- |
112
- | **macOS · Apple Silicon (arm64)** | [Download DMG](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.39-b12/pi-0.1.39-desktop.12-mac-arm64.dmg) |
113
- | **macOS · Intel (x64)** | [Download DMG](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.39-b12/pi-0.1.39-desktop.12-mac-x64.dmg) |
114
- | **Windows · x64** | [Download EXE installer](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.39-b12/pi-0.1.39-desktop.12-win-x64.exe) |
115
- | **Linux · x64** | [Download AppImage](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.39-b12/pi-0.1.39-desktop.12-linux-x86_64.AppImage) |
112
+ | **macOS · Apple Silicon (arm64)** | [Download DMG](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.39-b14/pi-0.1.39-desktop.14-mac-arm64.dmg) |
113
+ | **macOS · Intel (x64)** | [Download DMG](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.39-b14/pi-0.1.39-desktop.14-mac-x64.dmg) |
114
+ | **Windows · x64** | [Download EXE installer](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.39-b14/pi-0.1.39-desktop.14-win-x64.exe) |
115
+ | **Linux · x64** | [Download AppImage](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.39-b14/pi-0.1.39-desktop.14-linux-x86_64.AppImage) |
116
116
 
117
- [All releases](https://github.com/chengzhiyi/pi-webapp/releases) · [SHA256SUMS](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.39-b12/SHA256SUMS) · [Build/runtime metadata](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.39-b12/desktop-release.json)
117
+ [All releases](https://github.com/chengzhiyi/pi-webapp/releases) · [SHA256SUMS](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.39-b14/SHA256SUMS) · [Build/runtime metadata](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.39-b14/desktop-release.json)
118
118
 
119
119
  **Build 12 fixes desktop quit responsiveness.** Quit confirmations focus the main window, closing a loading window no longer opens a blocking error alert, and a failed backend stop offers a desktop-only exit. Existing background services remain available.
120
120
 
121
- **Build 12 supports stable and preview package updates.** Install this shell once, then select **Settings → General → Update preference → Preview (including alpha)** and click **Update and restart**. The preference and selected release survive future launches; preview chooses the newer of npm’s `latest` and `alpha` versions. Finish chats and close terminals before updating. When replacing build 10 for the first time, choose “停止服务并退出” (stop service and quit) in the old app, then launch the new shell; attaching to a still-running old backend does not change its channel capability. Existing npm 0.1.26/0.1.27 services can still be attached without stopping their tasks.
121
+ **Build 14 adds safe transfer from an old shared launcher.** Build 12 already supports preview updates, but attaching it to a build 10 backend preserves the old launcher's capabilities. With build 14 installed, first update the business package on Stable, then use **pi → 安全切换到当前桌面启动器…**. Handoff waits for idle chats, closed terminals and real drawing save confirmation, preserves the local address and recovery copies, and never force-stops the old owner. Then select Preview and update; the selected channel/release persist across restarts. Preview chooses the newer of npm’s `latest` and `alpha`; an older alpha is not offered as an upgrade. Current-window, launcher and business-package versions are shown separately. Existing npm 0.1.26/0.1.27 services remain available for attachment without taking over their tasks.
122
122
 
123
123
  The **pi** desktop app bundles Node and Pi—no separate runtime installation needed. It can reuse a compatible Web service, open the same service in your browser, and let you choose whether background tasks continue after closing the app. Bring your own model credentials, Git/SSH setup, and project toolchains.
124
124
 
125
125
  - **Install:** macOS: drag **pi.app** from the DMG into Applications. Windows: run the EXE installer. Linux: make the AppImage executable and run it; see the release notes for the FUSE alternative.
126
- - **Verify:** compare the installer with `SHA256SUMS` from the same release. Confirm **build 12** in **pi → 关于 pi (About pi)**. Quit the old desktop before replacing it; do not delete `~/.pi`.
126
+ - **Verify:** compare the installer with `SHA256SUMS` from the same release. Confirm **build 14** in **pi → 关于 pi (About pi)**. Quit the old desktop before replacing it; do not delete `~/.pi`.
127
127
  - **Test-release limits:** these are opt-in prereleases, not publisher-signed stable distributions. macOS uses ad-hoc signatures without Apple notarization and may be blocked by Gatekeeper; follow the [macOS test installation guide](docs/desktop-testing.md) and stop if verification fails. Windows/Linux packages are unsigned. Never disable system security globally. Desktop shell updates require manual installation; business-package updates use the app's Settings. Windows ARM and Linux ARM are not included.
128
128
 
129
129
  ## Architecture highlights
package/README.zh-CN.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  [English](README.md) · [快速开始](#快速开始) · [下载桌面端](#桌面端下载) · [项目架构](#技术架构亮点) · [使用指南](docs/zh/getting-started.md) · [npm](https://www.npmjs.com/package/pi-webapp)
8
8
 
9
- **桌面测试版 build 12:** [macOS Apple 芯片 DMG](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.39-b12/pi-0.1.39-desktop.12-mac-arm64.dmg) · [Intel、Windows 与 Linux 下载](#桌面端下载) · [SHA-256 校验文件](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.39-b12/SHA256SUMS)。测试包未签名或未公证,详见[安全安装说明](docs/desktop-testing.md)。
9
+ **桌面测试版 build 14:** [macOS Apple 芯片 DMG](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.39-b14/pi-0.1.39-desktop.14-mac-arm64.dmg) · [Intel、Windows 与 Linux 下载](#桌面端下载) · [SHA-256 校验文件](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.39-b14/SHA256SUMS)。测试包未签名或未公证,详见[安全安装说明](docs/desktop-testing.md)。
10
10
 
11
11
  [![Pi 工作台:左侧项目会话,中间 Agent 对话,右侧代码高亮预览](assets/readme/workbench.png)](assets/readme/workbench.png)
12
12
 
@@ -105,25 +105,25 @@ pi
105
105
 
106
106
  ## 桌面端下载
107
107
 
108
- **最新桌面测试版:[pi 0.1.39 · build 12](https://github.com/chengzhiyi/pi-webapp/releases/tag/desktop-v0.1.39-b12)。** 请按系统与芯片选择安装包:
108
+ **最新桌面测试版:[pi 0.1.39 · build 14](https://github.com/chengzhiyi/pi-webapp/releases/tag/desktop-v0.1.39-b14)。** 请按系统与芯片选择安装包:
109
109
 
110
110
  | 平台 | 下载 |
111
111
  | --- | --- |
112
- | **macOS · Apple 芯片(arm64)** | [下载 DMG](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.39-b12/pi-0.1.39-desktop.12-mac-arm64.dmg) |
113
- | **macOS · Intel(x64)** | [下载 DMG](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.39-b12/pi-0.1.39-desktop.12-mac-x64.dmg) |
114
- | **Windows · x64** | [下载 EXE 安装包](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.39-b12/pi-0.1.39-desktop.12-win-x64.exe) |
115
- | **Linux · x64** | [下载 AppImage](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.39-b12/pi-0.1.39-desktop.12-linux-x86_64.AppImage) |
112
+ | **macOS · Apple 芯片(arm64)** | [下载 DMG](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.39-b14/pi-0.1.39-desktop.14-mac-arm64.dmg) |
113
+ | **macOS · Intel(x64)** | [下载 DMG](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.39-b14/pi-0.1.39-desktop.14-mac-x64.dmg) |
114
+ | **Windows · x64** | [下载 EXE 安装包](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.39-b14/pi-0.1.39-desktop.14-win-x64.exe) |
115
+ | **Linux · x64** | [下载 AppImage](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.39-b14/pi-0.1.39-desktop.14-linux-x86_64.AppImage) |
116
116
 
117
- [全部版本](https://github.com/chengzhiyi/pi-webapp/releases) · [SHA256SUMS 校验文件](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.39-b12/SHA256SUMS) · [构建与运行时信息](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.39-b12/desktop-release.json)
117
+ [全部版本](https://github.com/chengzhiyi/pi-webapp/releases) · [SHA256SUMS 校验文件](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.39-b14/SHA256SUMS) · [构建与运行时信息](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.39-b14/desktop-release.json)
118
118
 
119
119
  **build 12 修复桌面退出无响应。** 退出确认会显示在主窗口前方;加载中关闭不再弹出阻塞警告;后台停止失败时可以选择“仅退出桌面”。已有后台服务和任务可继续运行。
120
120
 
121
- **build 12 支持稳定版与体验版在线更新。** 安装一次此外壳后,在「设置 → 通用设置 → 更新偏好」选择「体验版(包含 alpha)」,再点击「升级并重启」。偏好及所选版本在下次启动后继续有效;通道会选择 npm `latest` 与 `alpha` 中较新的版本。升级前请完成聊天任务并关闭终端。首次从 build 10 更换外壳时,在旧应用退出时选择“停止服务并退出”,再启动新版;只附加连接仍在运行的旧后台不会更新其通道能力。仍可安全连接已有 npm 0.1.26/0.1.27 后台,不停止其任务。
121
+ **build 14 新增旧共享后台的安全启动器交接。** build 12 本身支持体验版,但附加到 build 10 启动的后台后,旧启动器能力仍会保留。安装 build 14 后,先在稳定版通道升级业务包,再使用「pi → 安全切换到当前桌面启动器…」。交接会等待聊天空闲、终端关闭和真实图稿保存确认,保留原本地地址与恢复副本,不会强制停止旧进程;之后再切换体验版并在线升级。通道和所选版本在重启后保持;体验版选择 npm `latest` 与 `alpha` 中较新的版本,不会把旧 alpha 当作升级。界面分别显示当前窗口、后台启动器和业务包版本。已有 npm 0.1.26/0.1.27 后台仍可安全连接,不接管其任务。
122
122
 
123
123
  桌面应用名为 **pi**,自带 Node 和 Pi,无需另装运行时。支持复用兼容的 Web 服务、在浏览器中打开同一服务,以及退出时选择是否保留后台任务。模型凭据、Git/SSH 配置和项目工具链仍需自行准备。
124
124
 
125
125
  - **安装:** macOS 从 DMG 将 **pi.app** 拖入“应用程序”;Windows 运行 EXE;Linux 为 AppImage 添加执行权限后运行,不支持 FUSE 时可参考该版本发布说明中的替代方式。
126
- - **核对:** 对照同一 Release 的 `SHA256SUMS` 校验安装包,在「pi → 关于 pi」确认 **build 12**。替换前先退出旧桌面,不要删除 `~/.pi`。
126
+ - **核对:** 对照同一 Release 的 `SHA256SUMS` 校验安装包,在「pi → 关于 pi」确认 **build 14**。替换前先退出旧桌面,不要删除 `~/.pi`。
127
127
  - **测试版边界:** 当前为自愿参与的预发布测试包,不是具有发布者签名的稳定发行版。macOS 使用 ad-hoc 临时签名、未经过 Apple 公证,可能被 Gatekeeper 拦截;请按 [macOS 测试安装说明](docs/desktop-testing.md)核验,失败就停止。Windows/Linux 安装包未签名。不要全局关闭系统安全保护。桌面外壳更新仍需手动安装,业务包更新在应用设置中进行;暂不包含 Windows ARM 和 Linux ARM。
128
128
 
129
129
  ## 技术架构亮点
package/bin/pi-webapp.mjs CHANGED
@@ -14,11 +14,13 @@ import { observeStopOutcome } from "./launcher-state.mjs";
14
14
  import { compareVersions, parseVersion } from "../desktop/release-version.mjs";
15
15
  import { desktopProtocolVersion, desktopUpdatePath, readDesktopRelease, rollbackDesktopRelease } from "../desktop/managed-release.mjs";
16
16
 
17
+ import { launcherHandoffProtocol, readHandoff, writeHandoff } from "../desktop/launcher-handoff.mjs";
18
+
17
19
  const minimum = [0, 87, 1];
18
20
  const packageVersion = JSON.parse(await readFile(new URL("../package.json", import.meta.url), "utf8")).version;
19
21
  const runtimeKind = process.env.PI_WEBAPP_RUNTIME === "desktop" ? "desktop" : "npm";
20
22
  const desktopPackages = runtimeKind === "desktop" && process.env.PI_WEBAPP_DESKTOP_PACKAGE_UPDATES === "1";
21
- const runtimeInfo = { version: packageVersion, bridgeVersion: 1, runtimeKind, desktopProtocolVersion };
23
+ const runtimeInfo = { version: packageVersion, bridgeVersion: 1, runtimeKind, desktopProtocolVersion, launcherHandoffProtocol, launcherVersion: packageVersion, desktopShell: { version: process.env.PI_WEBAPP_DESKTOP_VERSION ?? "unknown", build: process.env.PI_WEBAPP_DESKTOP_BUILD ?? "unknown" }, desktopReleaseChannels: process.env.PI_WEBAPP_DESKTOP_RELEASE_CHANNELS === "1" };
22
24
  const launcher = fileURLToPath(import.meta.url);
23
25
  const extension = fileURLToPath(new URL("../dist/extension.js", import.meta.url));
24
26
  const agentDir = resolve((process.env.PI_CODING_AGENT_DIR ?? join(homedir(), ".pi", "agent")).replace(/^~(?=$|[\\/])/, homedir()));
@@ -127,7 +129,7 @@ async function serve(pi, args) {
127
129
  const pluginRoots = (process.env.PI_WEBAPP_PLUGIN_DEV_ROOTS ?? "").split(delimiter).filter(Boolean).map((root) => resolve(root));
128
130
  const piPrefix = process.env.PI_WEBAPP_PI_CLI ? [resolve(process.env.PI_WEBAPP_PI_CLI)] : [];
129
131
  const child = spawn(pi, [...piPrefix, "--mode", "rpc", "-e", extension, ...pluginRoots.flatMap((root) => ["-e", root]), ...args], {
130
- cwd: process.cwd(), env: { ...process.env, NODE_OPTIONS: `${process.env.NODE_OPTIONS ?? ""} --import=${JSON.stringify(new URL("./model-network-bootstrap.mjs", import.meta.url).href)}`.trim(), PI_WEBAPP_AUTO_OPEN: "0", PI_WEBAPP_LAUNCHER_NONCE: nonce }, stdio: ["pipe", "pipe", "pipe"],
132
+ cwd: process.cwd(), env: { ...process.env, NODE_OPTIONS: `${process.env.NODE_OPTIONS ?? ""} --import=${JSON.stringify(new URL("./model-network-bootstrap.mjs", import.meta.url).href)}`.trim(), PI_WEBAPP_AUTO_OPEN: "0", PI_WEBAPP_LAUNCHER_NONCE: nonce, PI_WEBAPP_LAUNCHER_HANDOFF_PROTOCOL: "1", PI_WEBAPP_LAUNCHER_VERSION: packageVersion }, stdio: ["pipe", "pipe", "pipe"],
131
133
  });
132
134
  child.stderr?.pipe(process.stderr, { end: false });
133
135
  let ready = false;
@@ -137,6 +139,7 @@ async function serve(pi, args) {
137
139
  let stateWrite = Promise.resolve();
138
140
  let stopping = false;
139
141
  let restartRequest = null;
142
+ let handoffRequest = null;
140
143
  let runningUrl = null;
141
144
  let buffer = "";
142
145
  let killTimer;
@@ -165,6 +168,9 @@ async function serve(pi, args) {
165
168
  let devReloadCommand;
166
169
  const finishShutdown = (reason) => {
167
170
  child.stdin?.end();
171
+ // A handoff is not permission to kill a stalled process. The new desktop
172
+ // must wait for this supervisor and its child to exit naturally.
173
+ if (handoffRequest) return;
168
174
  killTimer = setTimeout(() => {
169
175
  forceStopRequested = true;
170
176
  lifecycle("pi_force_stop", { reason, signal: "SIGTERM" });
@@ -217,6 +223,18 @@ async function serve(pi, args) {
217
223
  if (request === nonce) shutdown("stop_request");
218
224
  } catch { /* No stop request. */ }
219
225
  if (stopping || epoch !== stopEpoch) return;
226
+ if (runtimeKind === "desktop") {
227
+ const handoff = await readHandoff(agentDir).catch(() => null);
228
+ if (handoff?.nonce === nonce && handoff.pid === process.pid && handoff.phase === "requested") {
229
+ // The authenticated HTTP gate already froze admission and received the
230
+ // real plugin checkpoint/worker drain before publishing this request.
231
+ try { await writeHandoff(agentDir, { ...handoff, phase: "draining" }); }
232
+ catch { lifecycle("launcher_handoff_receipt_failed"); return; }
233
+ handoffRequest = handoff;
234
+ stopping = true; stopEpoch++; stopReason = "launcher_handoff";
235
+ lifecycle("launcher_handoff_draining"); finishShutdown(stopReason); return;
236
+ }
237
+ }
220
238
  try {
221
239
  const request = JSON.parse(await readFile(restartPath, "utf8"));
222
240
  const prepared = JSON.parse(await readFile(updatePath, "utf8"));
@@ -332,6 +350,7 @@ async function serve(pi, args) {
332
350
  });
333
351
  });
334
352
  await stateWrite;
353
+ if (handoffRequest) await writeHandoff(agentDir, { ...handoffRequest, phase: failed || child.exitCode !== 0 ? "failed" : "stopped" });
335
354
  clearTimeout(startupTimer);
336
355
  clearTimeout(stopPreflightTimer);
337
356
  clearTimeout(devReloadTimer);
@@ -0,0 +1,45 @@
1
+ import { readFile, rename, writeFile, unlink } from "node:fs/promises";
2
+ import { join } from "node:path";
3
+ import { randomUUID } from "node:crypto";
4
+
5
+ export const launcherHandoffProtocol = 1;
6
+ export const handoffPath = agentDir => join(agentDir, "pi-web", "launcher-handoff.json");
7
+ export function validHandoff(value) {
8
+ return value?.protocol === launcherHandoffProtocol && typeof value.nonce === "string" && value.nonce.length > 0
9
+ && /^[a-f0-9-]{36}$/i.test(value.requestId) && Number.isSafeInteger(value.pid) && value.pid > 0
10
+ && ["requested", "draining", "stopped", "refused", "failed"].includes(value.phase);
11
+ }
12
+ export async function readHandoff(agentDir) {
13
+ try {
14
+ const value = JSON.parse(await readFile(handoffPath(agentDir), "utf8"));
15
+ if (!validHandoff(value)) throw new Error("Invalid launcher handoff journal; original data retained");
16
+ return value;
17
+ } catch (error) { if (error.code === "ENOENT") return null; throw error; }
18
+ }
19
+ async function atomicRecord(target, value) {
20
+ const temporary = `${target}.${randomUUID()}.tmp`;
21
+ try { await writeFile(temporary, JSON.stringify(value), { mode: 0o600 }); await rename(temporary, target); }
22
+ finally { await unlink(temporary).catch(() => {}); }
23
+ }
24
+
25
+ export async function writeHandoff(agentDir, value) {
26
+ if (!validHandoff(value)) throw new Error("Invalid launcher handoff receipt");
27
+ await atomicRecord(handoffPath(agentDir), value);
28
+ }
29
+ export function validHandoffIntent(value) {
30
+ return validHandoff(value) && value.phase === "requested" && typeof value.version === "string"
31
+ && typeof value.url === "string" && value.url.length < 500
32
+ && (value.completed === undefined || value.completed === true)
33
+ && (value.cancelled === undefined || value.cancelled === true) && !(value.completed && value.cancelled);
34
+ }
35
+ export async function readHandoffIntent(agentDir) {
36
+ try {
37
+ const value = JSON.parse(await readFile(join(agentDir, "pi-web", "desktop-handoff.json"), "utf8"));
38
+ if (!validHandoffIntent(value)) throw new Error("Invalid desktop handoff intent; original data retained");
39
+ return value;
40
+ } catch (error) { if (error.code === "ENOENT") return null; throw error; }
41
+ }
42
+ export async function writeHandoffIntent(agentDir, value) {
43
+ if (!validHandoffIntent(value)) throw new Error("Invalid desktop handoff intent");
44
+ await atomicRecord(join(agentDir, "pi-web", "desktop-handoff.json"), value);
45
+ }