@chainingintention/pi-web-cn 1.202608.5 → 1.202608.7

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.
Files changed (74) hide show
  1. package/dist/cli.js +8 -0
  2. package/dist/cli.js.map +1 -1
  3. package/dist/client/assets/{CodeViewer-BUT2Idcq.js → CodeViewer-CWKEeX0r.js} +1 -1
  4. package/dist/client/assets/{TerminalPanel-b8CZY7en.js → TerminalPanel-BmA7Ayzk.js} +1 -1
  5. package/dist/client/assets/{UnifiedDiffViewer-CXY7AXrD.js → UnifiedDiffViewer-2DACwxFY.js} +1 -1
  6. package/dist/client/assets/{index-80SI7dCz.js → index-D6j67Izj.js} +491 -300
  7. package/dist/client/index.html +1 -1
  8. package/dist/config.js +86 -0
  9. package/dist/config.js.map +1 -1
  10. package/dist/pi-web-plugins/relays/relaysPanelElement.js +112 -46
  11. package/dist/server/app.js +4 -1
  12. package/dist/server/app.js.map +1 -1
  13. package/dist/server/audit/managementAuditStore.js +211 -0
  14. package/dist/server/audit/managementAuditStore.js.map +1 -0
  15. package/dist/server/audit/normalToolAuditCli.js +143 -0
  16. package/dist/server/audit/normalToolAuditCli.js.map +1 -0
  17. package/dist/server/audit/normalToolAuditStore.js +264 -0
  18. package/dist/server/audit/normalToolAuditStore.js.map +1 -0
  19. package/dist/server/managementEmbed.js +19 -1
  20. package/dist/server/managementEmbed.js.map +1 -1
  21. package/dist/server/piWebStatus.js +7 -1
  22. package/dist/server/piWebStatus.js.map +1 -1
  23. package/dist/server/requestLogging.js +10 -7
  24. package/dist/server/requestLogging.js.map +1 -1
  25. package/dist/server/sessiond/sessionProxyRoutes.js +13 -7
  26. package/dist/server/sessiond/sessionProxyRoutes.js.map +1 -1
  27. package/dist/server/sessiond/sessionServiceDependencies.js +1 -0
  28. package/dist/server/sessiond/sessionServiceDependencies.js.map +1 -1
  29. package/dist/server/sessiond.js +91 -4
  30. package/dist/server/sessiond.js.map +1 -1
  31. package/dist/server/sessions/extensionDialogWaiters.js +76 -0
  32. package/dist/server/sessions/extensionDialogWaiters.js.map +1 -0
  33. package/dist/server/sessions/managementPermissionSystem.js +8 -8
  34. package/dist/server/sessions/managementPermissionSystem.js.map +1 -1
  35. package/dist/server/sessions/pendingExtensionDialogStore.js +196 -0
  36. package/dist/server/sessions/pendingExtensionDialogStore.js.map +1 -0
  37. package/dist/server/sessions/piSessionService.js +493 -78
  38. package/dist/server/sessions/piSessionService.js.map +1 -1
  39. package/dist/server/sessions/sessionRoutes.js +54 -27
  40. package/dist/server/sessions/sessionRoutes.js.map +1 -1
  41. package/dist/server/sessions/sessionUiEvents.js +9 -2
  42. package/dist/server/sessions/sessionUiEvents.js.map +1 -1
  43. package/dist/server/sessions/spawnSessionTool.js +8 -1
  44. package/dist/server/sessions/spawnSessionTool.js.map +1 -1
  45. package/dist/server/sessions/spawnSubsessionTool.js +7 -1
  46. package/dist/server/sessions/spawnSubsessionTool.js.map +1 -1
  47. package/dist/server/workbench/accessStateRoutes.js +30 -0
  48. package/dist/server/workbench/accessStateRoutes.js.map +1 -0
  49. package/dist/server/workbench/accessStateStore.js +29 -0
  50. package/dist/server/workbench/accessStateStore.js.map +1 -0
  51. package/dist/server/workbench/capabilitySearch.js +62 -0
  52. package/dist/server/workbench/capabilitySearch.js.map +1 -0
  53. package/dist/server/workbench/gatewayIntegration.js +56 -0
  54. package/dist/server/workbench/gatewayIntegration.js.map +1 -0
  55. package/dist/server/workbench/mcpClient.js +148 -0
  56. package/dist/server/workbench/mcpClient.js.map +1 -0
  57. package/dist/server/workbench/skillSync.js +375 -0
  58. package/dist/server/workbench/skillSync.js.map +1 -0
  59. package/dist/server/workbench/types.js +2 -0
  60. package/dist/server/workbench/types.js.map +1 -0
  61. package/dist/server/workbench/workbenchClient.js +136 -0
  62. package/dist/server/workbench/workbenchClient.js.map +1 -0
  63. package/dist/server/workbench/workbenchTools.js +145 -0
  64. package/dist/server/workbench/workbenchTools.js.map +1 -0
  65. package/dist/shared/apiTypes.d.ts +141 -1
  66. package/dist/shared/apiTypes.js +8 -0
  67. package/dist/shared/apiTypes.js.map +1 -1
  68. package/dist/shared/federatedRoutes.js +2 -0
  69. package/dist/shared/federatedRoutes.js.map +1 -1
  70. package/dist/shared/piWebConfigParsing.js +94 -0
  71. package/dist/shared/piWebConfigParsing.js.map +1 -1
  72. package/docs/config.md +86 -1
  73. package/docs/plugins.md +14 -0
  74. package/package.json +7 -3
package/docs/config.md CHANGED
@@ -46,7 +46,8 @@ Process restarts depend on the key:
46
46
 
47
47
  - `host` / `port`: restart the gateway web/API service or process.
48
48
  - `maxUploadBytes`: restart both the web/API process and the session daemon on that machine.
49
- - `agent.command` / `agent.dir` / `spawnSessions` / `subsessions` / `askUser`: restart the session daemon on that machine.
49
+ - `agent.command` / `agent.dir` / `spawnSessions` / `subsessions` / `askUser` / `extensionDialogsTimeoutMs`: restart the session daemon on that machine.
50
+ - `workbenchIntegration`: restart both the web/API process and session daemon; both processes must use the same endpoints and limits.
50
51
  - `pathAccess`: applies on the next request; existing file views may need a browser refresh.
51
52
  - `uploads.defaultFolder`: applies to newly opened Files upload dialogs and new direct drag/drop batches after config/workspace refresh.
52
53
  - `plugins`: reload the browser tab after changing PI WEB plugin enablement.
@@ -73,6 +74,29 @@ Process restarts depend on the key:
73
74
  "spawnSessions": true,
74
75
  "subsessions": false,
75
76
  "askUser": true,
77
+ "extensionDialogsTimeoutMs": 300000,
78
+ "workbenchIntegration": {
79
+ "baseUrl": "http://ai-platform-backend:8787",
80
+ "mcpUrl": "http://mcp:8000/mcp",
81
+ "requestTimeoutMs": 10000,
82
+ "capabilityTimeoutMs": 30000,
83
+ "skillBundleMaxBytes": 10485760,
84
+ "skillFileMaxBytes": 2097152,
85
+ "skillFileCountMax": 200
86
+ },
87
+ "auditLog": {
88
+ "normalMode": {
89
+ "enabled": true,
90
+ "retentionDays": 90,
91
+ "maxRows": 500000
92
+ },
93
+ "managementMode": {
94
+ "enabled": true,
95
+ "baseUrl": "https://elasticsearch.internal:9200",
96
+ "indexPrefix": "pi-web-management-audit",
97
+ "retentionDays": 365
98
+ }
99
+ },
76
100
  "plugins": {
77
101
  "workspace-tasks": { "enabled": true },
78
102
  "updates": { "enabled": true },
@@ -125,6 +149,10 @@ Rows with JSON key `—` are runtime-only environment variables, not config-file
125
149
  | Agent can spawn sessions | `spawnSessions` | `PI_WEB_SPAWN_SESSIONS` | Global/session daemon | Not supported locally | Restart session daemon on that machine |
126
150
  | Tracked subsessions (beta) | `subsessions` | `PI_WEB_SUBSESSIONS` | Global/session daemon | Not supported locally; also requires `spawnSessions` | Restart session daemon on that machine |
127
151
  | Agent can post question forms | `askUser` | `PI_WEB_ASK_USER` | Global/session daemon | Not supported locally | Restart session daemon on that machine |
152
+ | 扩展对话框自动取消超时 | `extensionDialogsTimeoutMs` | — | 全局/会话守护进程 | 不支持项目级配置 | 重启对应机器上的会话守护进程 |
153
+ | Workbench/MCP integration | `workbenchIntegration.*` | `PI_WEB_WORKBENCH_URL`, `PI_WEB_MCP_URL`, `PI_WEB_WORKBENCH_TIMEOUT_MS`, `PI_WEB_MCP_TIMEOUT_MS`, `PI_WEB_SKILL_BUNDLE_MAX_BYTES`, `PI_WEB_SKILL_FILE_MAX_BYTES`, `PI_WEB_SKILL_FILE_COUNT_MAX` | Web/API + session daemon | Not supported locally | Restart web/API and session daemon; both must match |
154
+ | Ordinary tool audit | `auditLog.normalMode.*` | — | Global/session daemon | Not supported locally | Restart session daemon |
155
+ | Management tool audit | `auditLog.managementMode.*` | `PI_WEB_AUDIT_ES_URL`, `PI_WEB_AUDIT_ES_API_KEY`, `PI_WEB_AUDIT_ES_USERNAME`, `PI_WEB_AUDIT_ES_PASSWORD` | Global/session daemon | Not supported locally | Restart session daemon |
128
156
  | Plugin enablement/settings | `plugins.<id>.enabled`, `plugins.<id>.settings` | — | Global | Not core local config; plugins may read their own project files | Reload browser tab |
129
157
  | Keyboard shortcuts | `shortcuts.<actionId>` | — | Global | Not supported locally | Applies after settings save/config refresh |
130
158
  | Project config version | `version` | — | Project | Project-local only; must be `1` when present | Next project-config read |
@@ -144,6 +172,45 @@ Rows with JSON key `—` are runtime-only environment variables, not config-file
144
172
 
145
173
  ## Key details
146
174
 
175
+ ### Ordinary-mode tool audit
176
+
177
+ PI WEB stores metadata-only ordinary-mode tool calls in `$PI_WEB_DATA_DIR/audit/normal-tool-calls.sqlite` while keeping the existing Pino/service logs. Management-embed calls are not written to this database. Each row contains the session and workspace, tool and call identifiers, start/end timestamps, duration, and `started`, `completed`, `failed`, or `interrupted` status. Arguments, results, prompts, model replies, and credentials are never stored.
178
+
179
+ `auditLog.normalMode.enabled` defaults to `true`. `retentionDays` defaults to `90`, and `maxRows` defaults to `500000`. The session daemon prunes at startup and every 24 hours. Database failures are reported through the existing logger and do not stop tool execution.
180
+
181
+ Use the CLI to inspect and maintain the database:
182
+
183
+ ```bash
184
+ pi-web audit list --since 24h
185
+ pi-web audit list --status failed --since 7d
186
+ pi-web audit stats --since 30d
187
+ pi-web audit export --since 30d --format csv --output audit.csv
188
+ pi-web audit prune --before 2026-05-01
189
+ pi-web audit vacuum
190
+ ```
191
+
192
+ The database uses WAL mode so these read operations can run while sessiond is active. A graceful sessiond shutdown and the next startup mark unfinished calls as `interrupted`; changing audit configuration requires restarting sessiond.
193
+
194
+ ### Management-mode Elasticsearch audit
195
+
196
+ Management-embed audit records can be sent to Elasticsearch while the existing Pino/service logs remain enabled. Set `auditLog.managementMode.enabled` to `true` and provide `baseUrl`, or set `PI_WEB_AUDIT_ES_URL`. Authentication is read only from the session daemon environment: `PI_WEB_AUDIT_ES_API_KEY` takes precedence, while basic authentication requires both `PI_WEB_AUDIT_ES_USERNAME` and `PI_WEB_AUDIT_ES_PASSWORD`. Credentials must not be included in `baseUrl`.
197
+
198
+ Records are written to Shanghai-calendar ISO-week indices such as `pi-web-management-audit-2026-w32`. `indexPrefix` defaults to `pi-web-management-audit`; `retentionDays` defaults to `365`. Sessiond installs a strict index template, batches writes through the Elasticsearch Bulk API, and runs retention at startup and daily. The first successful maintenance in each Shanghai calendar month deletes documents whose `@timestamp` is older than the retention cutoff.
199
+
200
+ Each document identifies `user.id`, `user.root_user_id`, the authorized project owning the actual workspace, the Pi session, and, when applicable, the Workbench Agent Session. Tool calls include tool/call identifiers and status. Capability and Skill events add fixed resource versions, authorization revision, run/trace identifiers, status, duration, and retry metadata. Prompts, tool arguments, tool results, model replies, access tokens, API keys, cookies, and capability tickets are excluded.
201
+
202
+ Elasticsearch failures are reported through Pino and do not stop management sessions. Failed batches remain in a bounded in-memory retry queue and are flushed during graceful sessiond shutdown; a process crash can lose records that have not yet reached Elasticsearch. Use Elasticsearch or Kibana index permissions to limit user-level audit access.
203
+
204
+ ### Workbench and MCP integration
205
+
206
+ `workbenchIntegration` enables the controlled management-embed adapter for the network model workbench. These resource, tool, and Skill restrictions apply only to management-embed sessions; normal-mode sessions keep PI WEB's existing behavior. `baseUrl` is the server-reachable workbench backend origin, while `mcpUrl` is the MCP Streamable HTTP endpoint. Both are required; the environment variables override the corresponding JSON URLs.
207
+
208
+ The adapter exchanges the one-time management token for a private Agent Session, loads only the resulting fixed resource snapshot, and exposes `icnoc_search_capabilities` and `icnoc_call_capability` alongside the managed file tools and sandboxed `python` tool. Python runs without network access in an isolated Bubblewrap environment that binds only the managed workspace. Generic MCP, HTTP, web search, shell, and terminal tools remain denied in management mode. Skill bundles are downloaded only from the MCP origin, checked against the authorized fixed version and manifest, and stored under the managed project's `.pi/skills/` directory. Tokens and tickets remain server-side.
209
+
210
+ The session daemon emits metadata-only tool execution audit entries for both normal and management sessions. These entries include the mode, session, workspace, tool name, call id, and execution status; tool arguments and results are deliberately excluded. Workbench capability calls additionally emit their business and MCP trace identifiers.
211
+
212
+ Set the same effective config and environment on the web/API and session daemon services. Changing any integration endpoint or limit requires restarting both services.
213
+
147
214
  ### Managed data directory
148
215
 
149
216
  `PI_WEB_DATA_DIR` sets the root for PI WEB-managed runtime state and defaults to `~/.pi-web`. Unless a more specific path override is configured, PI WEB stores its project and machine registries, locally discovered plugins, default session-daemon socket, and session archives beneath this root.
@@ -278,6 +345,8 @@ A completion notice wakes an idle parent or queues behind in-flight work. Each n
278
345
 
279
346
  `list_subsessions`, `check_subsession`, and `read_subsession` never yield or change control flow. They are for deliberate inspection or recovery, not completion polling. While a child works, agent-facing `check_subsession` and `read_subsession` withhold partial output and direct the parent to continue independent work or yield at the join point. Output becomes available when the child stops. Included output and transcripts follow a labeled marker and come last, after PI WEB guidance.
280
347
 
348
+ `spawn_session` 和 `spawn_subsession` 都接受可选的 `model` 参数,其值必须是精确的 `provider/model-id`,例如 `anthropic/claude-sonnet-4-5`。设置后,新会话会使用该模型,而不是继承发起会话的模型。匹配是严格的:未知值或格式错误的值会被拒绝并返回错误。用户可以在提示词中通过 `#provider/model-id` 引用指定模型(见[提示词补全](#prompt-completions)),代理会将该引用作为此参数传递。新会话还会继承发起会话当前的思考级别,并根据所选模型的能力自动限制该级别。
349
+
281
350
  In **Settings → Session daemon**, these keys are saved on the selected machine. Restart the session daemon on that machine after changing them.
282
351
 
283
352
  #### `askUser` and `ask_user`
@@ -296,6 +365,14 @@ Sending an ordinary chat message while a form is open voids the form: the card c
296
365
 
297
366
  Restart the session daemon after changing `askUser` or after upgrading PI WEB to a version that introduces this tool. For the systemd user service, run `systemctl --user restart pi-web-sessiond`.
298
367
 
368
+ ### 扩展对话框
369
+
370
+ Pi 扩展可以通过 `ctx.ui.confirm()`、`ctx.ui.select()` 和 `ctx.ui.input()` 向用户提问,包括从 `session_start` 钩子以及运行中的 `tool_call` 钩子发起。PI WEB 会在会话记录中以内联方式显示这些对话框,并通过独立的会话守护进程通道返回回答,不经过提示词队列,因此等待回答的 `tool_call` 钩子不会阻塞运行。对话框支持始终启用,没有单独的启用开关。行为细节和扩展开发说明见 [PI WEB 中的 Pi 扩展对话框](https://pi-web.dev/plugins#pi-extension-dialogs)。
371
+
372
+ `extensionDialogsTimeoutMs` 是无人处理对话框时的安全超时:会话守护进程等待回答的最长时间,超时后将以对应类型的取消值结束对话框(确认框为 `false`,选择框和输入框为 `undefined`)。默认值为 `300000`(5 分钟);设为 `0` 时永久等待。扩展自身设置的 `timeout` 仍然生效,最终期限取两者中较早的时间。
373
+
374
+ 该配置项直接在全局配置文件中编辑。修改后需要重启会话守护进程;使用 systemd 用户服务时运行 `systemctl --user restart pi-web-sessiond`。
375
+
299
376
  ### Plugin config
300
377
 
301
378
  The `plugins` key is only for PI WEB browser plugin enablement/settings on the machine whose config you are editing. It does not install, remove, or update Pi packages; use **Settings → Pi packages** or Pi's package manager for package operations. In a federated setup, **Settings → PI WEB plugins** and **Settings → Pi packages** both target the currently selected machine, and each panel labels where changes will be saved or run.
@@ -328,6 +405,14 @@ Shortcut values are keyed by action id. Values are shortcut strings such as `mod
328
405
 
329
406
  Prefer Settings → Keyboard for editing shortcuts interactively.
330
407
 
408
+ ## 提示词补全
409
+
410
+ 聊天输入框会在键入以下三个触发字符时打开补全菜单:
411
+
412
+ - 在草稿开头键入 `/` 可补全会话命令。
413
+ - `@` 用于补全文件路径:`@` 显示已跟踪文件,`@ `(先键入 `@`,再键入空格)或 `!@` 显示所有文件。选中后会把 `@path` 引用插入草稿;路径包含空格时会自动加引号。
414
+ - `#` 用于补全当前会话可用的模型;输入时不区分大小写地筛选,最多显示 12 项。选中后会把 `#provider/model-id` 引用插入草稿,提示代理应使用该模型执行请求,例如作为 `spawn_session` 的 `model` 参数。
415
+
331
416
  ## Optional completion tools
332
417
 
333
418
  File and path `@` completions work without extra tools. If `fzf` is available on the PI WEB server's `PATH`, PI WEB uses it to improve completion filtering/ranking; otherwise it falls back to built-in ranking.
package/docs/plugins.md CHANGED
@@ -29,6 +29,20 @@ Use **Settings → PI WEB plugins** to enable or disable discovered PI WEB brows
29
29
 
30
30
  After installing, removing, or updating a Pi package, type `/reload` in each idle PI WEB session on the target machine to refresh ordinary Pi resources such as extensions, skills, prompt templates, themes, and context/system prompt files. Reload the browser page separately for newly discovered or changed PI WEB browser plugins. A provider-registering Pi extension follows a separate daemon-start policy; see [Pi extension provider baseline](https://pi-web.dev/config#pi-extension-provider-baseline).
31
31
 
32
+ ## PI WEB 中的 Pi 扩展对话框
33
+
34
+ 运行在 PI WEB 会话守护进程中的 Pi 扩展可以通过 `ctx.ui.confirm()`、`ctx.ui.select()` 和 `ctx.ui.input()` 向用户提问。PI WEB 会报告 `ctx.hasUI === true`,并且这三种对话框方法确实可用:调用后会在会话记录中以内联方式显示对话框卡片,返回的 Promise 将以用户的实际回答结束,确认框返回布尔值,选择框返回所选项,输入框返回输入文本。
35
+
36
+ - **可在钩子中使用,不经过提示词队列。** 回答通过独立的会话守护进程通道传递,因此运行中的 `tool_call` 钩子可以安全等待对话框;代理循环会等待钩子,并在收到回答后继续运行。支持在 `tool_call` 钩子中使用对话框进行工具授权确认。
37
+ - **启动阶段的对话框可以回答。** 无论创建新会话还是打开已有会话,`session_start` 钩子发起的对话框都能在会话仍在启动时回答;对话框结束后启动流程继续。
38
+ - **浏览器刷新后可恢复,最先提交的回答生效。** 浏览器刷新后会根据会话状态重新显示打开的对话框。同一会话打开多个标签页时,最先提交的回答会结束对话框,其他标签页随后显示结束状态。
39
+ - **结束状态卡片会保留到用户关闭。** 已回答或已关闭的对话框会在会话记录中保留结果卡片。回答只会传给扩展,因此该卡片是这次交互唯一的可见记录。卡片属于浏览器本地状态:只有见过对话框打开的浏览器会显示它,切换会话或刷新页面后会清除。
40
+ - **超时。** 扩展自身的 `timeout` 仍然生效,守护进程还提供 `extensionDialogsTimeoutMs` 安全超时(默认 5 分钟,设为 `0` 时永久等待;见[扩展对话框](https://pi-web.dev/config#extension-dialogs))。最终期限取两者中较早的时间。没有回答就关闭的对话框会返回对应类型的取消值:确认框为 `false`,选择框和输入框为 `undefined`。
41
+ - **中止和运行时替换。** 中止当前运行时,本轮运行中打开的对话框会立即以取消值结束。替换会话运行时(例如 `/reload` 或销毁会话)也会结束所有仍打开的对话框;新运行时的钩子可以重新打开对话框。扩展传入的 `AbortSignal` 同样有效,中止信号会关闭对话框并返回取消值。
42
+ - **其他 UI 能力仍为空实现。** 除这三种对话框外,PI WEB 尚未实现 `ExtensionUIContext` 的其他方法(组件、状态、编辑器和 `custom`)。即使 `hasUI` 为 `true`,也不能仅凭它判断这些能力可用。
43
+
44
+ 浏览器本地存在一个限制:新会话仍在创建时刷新页面,会丢失浏览器保存的待启动行,因此对话框卡片会消失。守护进程中的对话框仍会在期限到达时结束,会话创建完成后仍会出现在侧边栏中。
45
+
32
46
  ## Trust model
33
47
 
34
48
  Plugins run as JavaScript in the browser app. Treat them as trusted code:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chainingintention/pi-web-cn",
3
- "version": "1.202608.5",
3
+ "version": "1.202608.7",
4
4
  "description": "Remote web UI and browser control plane for persistent Pi Coding Agent sessions.",
5
5
  "license": "MIT",
6
6
  "author": "Federico Jaramillo Martinez",
@@ -79,7 +79,8 @@
79
79
  "marked": "^18.0.6",
80
80
  "node-pty": "^1.1.0",
81
81
  "typebox": "1.3.6",
82
- "ws": "^8.21.0"
82
+ "ws": "^8.21.0",
83
+ "yauzl": "^3.4.0"
83
84
  },
84
85
  "devDependencies": {
85
86
  "@changesets/cli": "^2.31.0",
@@ -89,6 +90,8 @@
89
90
  "@eslint/js": "^10.0.1",
90
91
  "@types/node": "^24.13.3",
91
92
  "@types/ws": "^8.18.1",
93
+ "@types/yauzl": "^2.10.3",
94
+ "@types/yazl": "^2.4.6",
92
95
  "eslint": "^10.6.0",
93
96
  "globals": "^17.7.0",
94
97
  "happy-dom": "^20.11.1",
@@ -97,7 +100,8 @@
97
100
  "typescript": "^6.0.3",
98
101
  "typescript-eslint": "^8.63.0",
99
102
  "vite": "^8.1.4",
100
- "vitest": "^4.1.10"
103
+ "vitest": "^4.1.10",
104
+ "yazl": "^3.3.1"
101
105
  },
102
106
  "publishConfig": {
103
107
  "access": "public"