pi-webapp 0.1.58-alpha.3 → 0.1.58-alpha.5
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 +7 -7
- package/README.zh-CN.md +7 -7
- package/bin/open-web-page.mjs +4 -1
- package/desktop/local-file-grant.mjs +99 -0
- package/dist/extension.js +399 -89
- package/dist/hosted-recovery.js +2 -2
- package/dist/hosted-worker.js +2 -2
- package/docs/desktop-testing.md +45 -3
- package/docs/desktop.md +32 -11
- package/package.json +3 -2
- package/web/dist/.vite/manifest.json +18 -18
- package/web/dist/assets/{MarkdownText-n7a5RNfV.js → MarkdownText-D7IMkMzK.js} +4 -4
- package/web/dist/assets/app-D_Cp6wxG.js +53 -0
- package/web/dist/assets/app.css +1 -1
- package/web/dist/assets/app.js +4 -4
- package/web/dist/assets/{graphql-DByunozr.js → graphql-Hegc6gEC.js} +2 -2
- package/web/dist/assets/{http-NwUdv8k4.js → http-B3Y7GWkq.js} +2 -2
- package/web/dist/assets/{php-C6oEOKuG.js → php-Dxtxm1aG.js} +2 -2
- package/web/dist/assets/{plugin-DeW_DkTT.js → plugin-BR4Btg9-.js} +2 -2
- package/web/dist/assets/{plugin-C3zB3qOG.js → plugin-CS_X1UYA.js} +3 -3
- package/web/dist/assets/{plugin-BmDUJyrG.js → plugin-DipabKKU.js} +2 -2
- package/web/dist/assets/{plugin-CXVq2CZx.js → plugin-FbnSUOJ6.js} +2 -2
- package/web/dist/assets/{rst-DvMdVuu1.js → rst-B9C_PPTW.js} +2 -2
- package/web/dist/assets/{ruby-CZD-cp5q.js → ruby-RlqKt44Q.js} +2 -2
- package/web/dist/assets/{svelte-Csgo12Mn.js → svelte-C4qPvJS9.js} +2 -2
- package/web/dist/assets/{telemetry-client-BXj9P2wd.js → telemetry-client-wNPyfb0N.js} +3 -3
- package/web/dist/assets/{vue-BDDB9Wgd.js → vue-DacXyh89.js} +2 -2
- package/web/dist/assets/app-c9jZdtMM.js +0 -53
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/introduction.md) · [npm](https://www.npmjs.com/package/pi-webapp)
|
|
8
8
|
|
|
9
|
-
**Desktop test build
|
|
9
|
+
**Desktop test build 18:** [macOS Apple Silicon DMG](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.58-b18/pi-0.1.58-desktop.18-mac-arm64.dmg) · [Intel, Windows & Linux downloads](#desktop-downloads) · [SHA-256 checksums](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.58-b18/SHA256SUMS). These are unsigned/unnotarized test packages. See [safe installation](docs/desktop-testing.md).
|
|
10
10
|
|
|
11
11
|
[](assets/readme/workbench.png)
|
|
12
12
|
|
|
@@ -120,16 +120,16 @@ Enter **`/web`** inside Pi. The browser stays synchronized with that terminal se
|
|
|
120
120
|
|
|
121
121
|
## Desktop downloads
|
|
122
122
|
|
|
123
|
-
**Latest desktop test release: [pi 0.1.
|
|
123
|
+
**Latest desktop test release: [pi 0.1.58 · build 18](https://github.com/chengzhiyi/pi-webapp/releases/tag/desktop-v0.1.58-b18).** Download the installer for your operating system and CPU:
|
|
124
124
|
|
|
125
125
|
| Platform | Download |
|
|
126
126
|
| --- | --- |
|
|
127
|
-
| **macOS · Apple Silicon (arm64)** | [Download DMG](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.
|
|
128
|
-
| **macOS · Intel (x64)** | [Download DMG](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.
|
|
129
|
-
| **Windows · x64** | [Download EXE installer](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.
|
|
130
|
-
| **Linux · x64** | [Download AppImage](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.
|
|
127
|
+
| **macOS · Apple Silicon (arm64)** | [Download DMG](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.58-b18/pi-0.1.58-desktop.18-mac-arm64.dmg) |
|
|
128
|
+
| **macOS · Intel (x64)** | [Download DMG](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.58-b18/pi-0.1.58-desktop.18-mac-x64.dmg) |
|
|
129
|
+
| **Windows · x64** | [Download EXE installer](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.58-b18/pi-0.1.58-desktop.18-win-x64.exe) |
|
|
130
|
+
| **Linux · x64** | [Download AppImage](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.58-b18/pi-0.1.58-desktop.18-linux-x86_64.AppImage) |
|
|
131
131
|
|
|
132
|
-
[All releases](https://github.com/chengzhiyi/pi-webapp/releases) · [SHA256SUMS](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.
|
|
132
|
+
[All releases](https://github.com/chengzhiyi/pi-webapp/releases) · [SHA256SUMS](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.58-b18/SHA256SUMS) · [Build/runtime metadata](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.58-b18/desktop-release.json)
|
|
133
133
|
|
|
134
134
|
**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.
|
|
135
135
|
|
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
|
|
9
|
+
**桌面测试版 build 18:** [macOS Apple 芯片 DMG](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.58-b18/pi-0.1.58-desktop.18-mac-arm64.dmg) · [Intel、Windows 与 Linux 下载](#桌面端下载) · [SHA-256 校验文件](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.58-b18/SHA256SUMS)。测试包未签名或未公证,详见[安全安装说明](docs/desktop-testing.md)。
|
|
10
10
|
|
|
11
11
|
[](assets/readme/workbench.png)
|
|
12
12
|
|
|
@@ -120,16 +120,16 @@ pi
|
|
|
120
120
|
|
|
121
121
|
## 桌面端下载
|
|
122
122
|
|
|
123
|
-
**最新桌面测试版:[pi 0.1.
|
|
123
|
+
**最新桌面测试版:[pi 0.1.58 · build 18](https://github.com/chengzhiyi/pi-webapp/releases/tag/desktop-v0.1.58-b18)。** 请按系统与芯片选择安装包:
|
|
124
124
|
|
|
125
125
|
| 平台 | 下载 |
|
|
126
126
|
| --- | --- |
|
|
127
|
-
| **macOS · Apple 芯片(arm64)** | [下载 DMG](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.
|
|
128
|
-
| **macOS · Intel(x64)** | [下载 DMG](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.
|
|
129
|
-
| **Windows · x64** | [下载 EXE 安装包](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.
|
|
130
|
-
| **Linux · x64** | [下载 AppImage](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.
|
|
127
|
+
| **macOS · Apple 芯片(arm64)** | [下载 DMG](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.58-b18/pi-0.1.58-desktop.18-mac-arm64.dmg) |
|
|
128
|
+
| **macOS · Intel(x64)** | [下载 DMG](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.58-b18/pi-0.1.58-desktop.18-mac-x64.dmg) |
|
|
129
|
+
| **Windows · x64** | [下载 EXE 安装包](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.58-b18/pi-0.1.58-desktop.18-win-x64.exe) |
|
|
130
|
+
| **Linux · x64** | [下载 AppImage](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.58-b18/pi-0.1.58-desktop.18-linux-x86_64.AppImage) |
|
|
131
131
|
|
|
132
|
-
[全部版本](https://github.com/chengzhiyi/pi-webapp/releases) · [SHA256SUMS 校验文件](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.
|
|
132
|
+
[全部版本](https://github.com/chengzhiyi/pi-webapp/releases) · [SHA256SUMS 校验文件](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.58-b18/SHA256SUMS) · [构建与运行时信息](https://github.com/chengzhiyi/pi-webapp/releases/download/desktop-v0.1.58-b18/desktop-release.json)
|
|
133
133
|
|
|
134
134
|
**build 12 修复桌面退出无响应。** 退出确认会显示在主窗口前方;加载中关闭不再弹出阻塞警告;后台停止失败时可以选择“仅退出桌面”。已有后台服务和任务可继续运行。
|
|
135
135
|
|
package/bin/open-web-page.mjs
CHANGED
|
@@ -16,6 +16,9 @@ export async function openWebPage(url, platform = process.platform, env = proces
|
|
|
16
16
|
if (platform === "linux" && !env.DISPLAY && !env.WAYLAND_DISPLAY) return false;
|
|
17
17
|
const command = platform === "darwin" ? "open" : platform === "linux" ? "xdg-open" : platform === "win32" ? "explorer.exe" : null;
|
|
18
18
|
if (command === null) return false;
|
|
19
|
-
|
|
19
|
+
// The file grant is optional; it must never prevent opening the web page.
|
|
20
|
+
const launcher = platform === "darwin" || platform === "win32"
|
|
21
|
+
? await import("../desktop/local-file-grant.mjs").catch(() => undefined) : undefined;
|
|
22
|
+
await run(command, [launcher ? await launcher.localFileLaunchUrl(url, platform, env) : url]);
|
|
20
23
|
return true;
|
|
21
24
|
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { createHmac, randomBytes, timingSafeEqual } from "node:crypto";
|
|
2
|
+
import { constants, statSync } from "node:fs";
|
|
3
|
+
import { link, mkdir, open, rm, writeFile } from "node:fs/promises";
|
|
4
|
+
import { get } from "node:http";
|
|
5
|
+
import { homedir } from "node:os";
|
|
6
|
+
import { join, resolve } from "node:path";
|
|
7
|
+
|
|
8
|
+
const keyName = "native-files.key";
|
|
9
|
+
const tokenPattern = /^[A-Za-z0-9_-]{32}$/;
|
|
10
|
+
const grantPattern = /^[A-Za-z0-9_-]{43}$/;
|
|
11
|
+
|
|
12
|
+
/** A native launch must be local and attended; a loopback HTTP peer alone proves neither. */
|
|
13
|
+
export function localFilePlatform(platform = process.platform, env = process.env, consoleUser = () => statSync("/dev/console").uid, uid = process.getuid?.()) {
|
|
14
|
+
if (env.SSH_CONNECTION || env.SSH_CLIENT || env.SSH_TTY || env.PI_WEBAPP_LISTEN_HOST === "0.0.0.0") return;
|
|
15
|
+
if (platform === "win32" && /^(?:Console|RDP-Tcp#\d+)$/i.test(env.SESSIONNAME ?? "")) return platform;
|
|
16
|
+
if (platform === "darwin" && uid) {
|
|
17
|
+
try { if (uid === consoleUser()) return platform; } catch { /* No console session. */ }
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async function readKey(path) {
|
|
22
|
+
const posix = process.platform !== "win32";
|
|
23
|
+
const file = await open(path, constants.O_RDONLY | (posix ? constants.O_NOFOLLOW | constants.O_NONBLOCK : 0));
|
|
24
|
+
try {
|
|
25
|
+
const info = await file.stat();
|
|
26
|
+
if (!info.isFile() || info.size !== 32 || (posix && ((info.mode & 0o077) !== 0 || info.uid !== process.getuid?.()))) return;
|
|
27
|
+
const key = Buffer.alloc(33);
|
|
28
|
+
if ((await file.read(key)).bytesRead === 32) return key.subarray(0, 32);
|
|
29
|
+
} finally { await file.close(); }
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export async function localFileKey(agentDir, create = false) {
|
|
33
|
+
const dir = join(agentDir, "pi-web");
|
|
34
|
+
const path = join(dir, keyName);
|
|
35
|
+
try { return await readKey(path); } catch (error) {
|
|
36
|
+
if (!create || error?.code !== "ENOENT") return;
|
|
37
|
+
}
|
|
38
|
+
// Publish a complete private key atomically so sibling CLI/shell processes
|
|
39
|
+
// and concurrent starts either see the same key or fail closed.
|
|
40
|
+
const temporary = `${path}.${randomBytes(12).toString("hex")}`;
|
|
41
|
+
try {
|
|
42
|
+
await mkdir(dir, { recursive: true, mode: 0o700 });
|
|
43
|
+
await writeFile(temporary, randomBytes(32), { flag: "wx", mode: 0o600 });
|
|
44
|
+
try { await link(temporary, path); } catch (error) { if (error?.code !== "EEXIST") throw error; }
|
|
45
|
+
return await readKey(path);
|
|
46
|
+
} catch { /* Opening workspace files is optional; the web session still works. */ }
|
|
47
|
+
finally { await rm(temporary, { force: true }).catch(() => {}); }
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function makeGrant(key, token) {
|
|
51
|
+
return createHmac("sha256", key).update(`pi-web/native-files/v1\0${token}`).digest("base64url");
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function matchesLocalFileGrant(key, token, input) {
|
|
55
|
+
return !!key && typeof input === "string" && grantPattern.test(input)
|
|
56
|
+
&& timingSafeEqual(Buffer.from(input), Buffer.from(makeGrant(key, token)));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function acceptsGrant(target, token, grant, platform) {
|
|
60
|
+
// A direct, bounded loopback request: never send these headers through a
|
|
61
|
+
// proxy, follow a redirect, or trust a generic success page from an old host.
|
|
62
|
+
return new Promise(resolve => {
|
|
63
|
+
const request = get(new URL("/api/local-file-actions", target), {
|
|
64
|
+
agent: false, signal: AbortSignal.timeout(1500),
|
|
65
|
+
headers: { Authorization: `Bearer ${token}`, "X-Pi-Local-Files": grant },
|
|
66
|
+
}, response => {
|
|
67
|
+
if (response.statusCode !== 200) { response.destroy(); resolve(false); return; }
|
|
68
|
+
let text = "";
|
|
69
|
+
response.setEncoding("utf8");
|
|
70
|
+
response.on("data", chunk => {
|
|
71
|
+
text += chunk;
|
|
72
|
+
if (text.length > 256) { response.destroy(); resolve(false); }
|
|
73
|
+
});
|
|
74
|
+
response.once("end", () => {
|
|
75
|
+
try { resolve(JSON.parse(text)?.platform === platform); } catch { resolve(false); }
|
|
76
|
+
});
|
|
77
|
+
response.once("error", () => resolve(false));
|
|
78
|
+
});
|
|
79
|
+
request.once("error", () => resolve(false));
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Only the URL actually handed to a local GUI gets the grant; status and logs keep the normal URL. */
|
|
84
|
+
export async function localFileLaunchUrl(url, platform = process.platform, env = process.env, agentDir = resolve((env.PI_CODING_AGENT_DIR ?? join(homedir(), ".pi", "agent")).replace(/^~(?=$|[\\/])/, homedir()))) {
|
|
85
|
+
if (!localFilePlatform(platform, env)) return url;
|
|
86
|
+
try {
|
|
87
|
+
const target = new URL(url);
|
|
88
|
+
const token = target.hash.slice(1);
|
|
89
|
+
if (target.protocol !== "http:" || target.hostname !== "127.0.0.1" || !target.port || target.username || target.password || target.pathname !== "/" || target.search || !tokenPattern.test(token)) return url;
|
|
90
|
+
const key = await localFileKey(agentDir);
|
|
91
|
+
if (!key) return url;
|
|
92
|
+
// A new launcher can reconnect to an older runtime. Only use the extended
|
|
93
|
+
// fragment after the running bridge confirms that it accepts this grant.
|
|
94
|
+
const grant = makeGrant(key, token);
|
|
95
|
+
if (!await acceptsGrant(target, token, grant, platform)) return url;
|
|
96
|
+
target.hash = `${token}.${grant}`;
|
|
97
|
+
return target.href;
|
|
98
|
+
} catch { return url; }
|
|
99
|
+
}
|