pi-web-ui 0.113.1 → 0.114.1
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 +71 -1
- package/README.md +187 -316
- package/README.zh-CN.md +227 -299
- package/README.zh-TW.md +227 -299
- package/bin/device-hub-cli.mjs +577 -0
- package/bin/frp-manager.mjs +1573 -1573
- package/bin/pi-device-hub.mjs +9 -0
- package/bin/pi-web-ui.mjs +4081 -4041
- package/deploy/nginx-subpath.conf +100 -100
- package/deploy/pi-web-ui.service +36 -36
- package/dist/server/agent-service-daemon.js +102 -24
- package/dist/server/agent-service.js +2419 -1174
- 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 +69 -13
- package/dist/server/canvas/canvas-agent-tool.js +68 -18
- package/dist/server/canvas/canvas-cards.js +1 -1
- package/dist/server/canvas/canvas-dispatch.js +61 -20
- package/dist/server/canvas/canvas-orchestrator.js +519 -202
- package/dist/server/canvas/canvas-scheduled-task.js +45 -0
- 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 +110 -24
- 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/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 +351 -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 +830 -0
- package/dist/server/device-center/local-hub.js +92 -0
- package/dist/server/device-center/local.js +529 -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 +996 -0
- package/dist/server/device-center/runtime.js +253 -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 +84 -27
- package/dist/server/dsh/dsh-agent-service.js +282 -159
- package/dist/server/dsh/dsh-client.js +12 -2
- package/dist/server/dsh/runtime/cordis.yml +1 -1
- package/dist/server/dsh/runtime/custom-prompt.mjs +33 -33
- package/dist/server/dsh/runtime/goal-rpc.mjs +1309 -1309
- package/dist/server/dsh/runtime/launcher.mjs +235 -235
- package/dist/server/dsh/runtime/override.patch.yml +89 -89
- package/dist/server/dsh/runtime/runtime-root.mjs +405 -405
- package/dist/server/durable/durable-agent-service.js +1 -1
- package/dist/server/engine-probe.js +36 -6
- package/dist/server/eval-tool.js +135 -135
- 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 +38 -26
- package/dist/server/global-loader.js +40 -2
- 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 +285 -255
- 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/patch-bash-process.js +125 -0
- package/dist/server/patch-tool.js +9 -9
- package/dist/server/patch-turn-end-boundary.js +3 -3
- package/dist/server/payload-limits.js +17 -0
- package/dist/server/pending-question.js +82 -0
- package/dist/server/persona-chain.js +8 -8
- 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 +288 -94
- package/dist/server/preset-fields.js +56 -0
- package/dist/server/preset-plugin-dependencies.js +57 -0
- package/dist/server/preset-share.js +113 -72
- package/dist/server/prompt-templates.js +106 -0
- package/dist/server/protocol-version.js +1 -1
- package/dist/server/queue-modes.js +10 -0
- package/dist/server/remote-ssh-service.js +199 -106
- package/dist/server/request-context.js +164 -0
- package/dist/server/resolve-global-sdk.js +2 -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/schedule-agent-tool.js +39 -21
- package/dist/server/scheduler-tasks.js +106 -55
- package/dist/server/scm-commitmsg.js +10 -10
- 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 +273 -111
- package/dist/server/setup-config.js +58 -0
- package/dist/server/setup-page.js +620 -620
- 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/text-quote.js +9 -0
- package/dist/server/tool-guards.js +42 -6
- package/dist/server/tool-manager.js +48 -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/drivers/claude-code.js +5 -0
- package/dist/server/universal/drivers/codex.js +336 -0
- package/dist/server/universal/index.js +1 -0
- package/dist/server/universal/session-store.js +48 -6
- package/dist/server/universal/universal-attachments.js +24 -1
- package/dist/server/universal/universal-service.js +1 -1
- package/dist/server/universal/universal-session.js +357 -231
- package/dist/server/uploads.js +64 -5
- package/dist/server/vision-bridge.js +18 -18
- package/dist/server/worktree-service.js +32 -24
- package/dist/server/ws-pending-queue.js +73 -27
- package/docs/device-center.md +148 -0
- package/docs/device-desktop.md +48 -0
- package/docs/dsh-engine.md +493 -493
- package/extensions/webui.ts +335 -335
- package/package.json +5 -2
- package/plugin-sdk/README.md +174 -174
- package/plugin-sdk/client-utils.mjs +279 -279
- package/plugin-sdk/import-check.mjs +210 -210
- package/plugin-sdk/index.d.ts +698 -676
- package/plugin-sdk/index.mjs +696 -696
- package/plugin-sdk/package.json +13 -13
- package/plugin-sdk/ssh-host-trust.mjs +225 -0
- package/plugins/catalog.json +11 -1
- package/themes/aetheris.css +501 -607
- package/themes/ayu-light.css +116 -140
- package/themes/bases/flow-base.css +1357 -1363
- package/themes/bases/obsidian-base.css +895 -895
- package/themes/bases/statusbar-flat-base.css +112 -0
- package/themes/bases/zhujian-base.css +688 -687
- package/themes/bases/zhupi-base.css +660 -659
- package/themes/catppuccin-latte.css +119 -142
- package/themes/catppuccin.css +116 -147
- package/themes/claude-code-dark.css +147 -146
- package/themes/codex.css +114 -138
- package/themes/cyberpunk.css +50 -108
- package/themes/dark-teal.css +264 -265
- package/themes/dazzle.css +38 -108
- package/themes/everforest-light.css +115 -138
- package/themes/flow-light.css +164 -164
- package/themes/flow.css +161 -161
- package/themes/geist.css +114 -138
- package/themes/gruvbox-light.css +115 -138
- package/themes/kanagawa-lotus.css +115 -138
- package/themes/md-preview.css +24 -234
- package/themes/mist.css +166 -186
- package/themes/nord.css +107 -138
- package/themes/one-dark.css +106 -139
- package/themes/paper.css +174 -186
- package/themes/rose-pine-dawn.css +114 -138
- package/themes/sakura.css +166 -186
- package/themes/solarized-light.css +114 -137
- package/themes/tokyo-night.css +115 -146
- package/themes/translucent.css +85 -85
- package/themes/transparent.css +116 -116
- package/themes/vs-code-dark.css +147 -147
- package/themes/wallpaper-flow.css +382 -382
- package/themes/wallpaper-obsidian.css +74 -74
- package/themes/white.css +164 -186
- package/themes/zhujian-dark.css +115 -114
- package/themes/zhujian.css +114 -114
- package/themes/zhupi-dark.css +115 -114
- package/themes/zhupi.css +114 -114
- package/web/dist/.build-assets.json +1 -0
- package/web/dist/assets/BgTasksModal-BcXJ20RO.js +1 -0
- package/web/dist/assets/BgTasksModal-DjQmiKnE.js +1 -0
- package/web/dist/assets/CanvasStudio-PI9pid0Y.js +1579 -0
- package/web/dist/assets/CanvasStudio-nf5-HxLM.js +1579 -0
- package/web/dist/assets/DeviceCenter-CYttJw2a.js +3 -0
- package/web/dist/assets/DeviceCenter-DPe4sz74.js +3 -0
- package/web/dist/assets/DeviceGroups-D2rogxEN.js +1 -0
- package/web/dist/assets/Dropdown-ZLS04O8p.js +1 -0
- package/web/dist/assets/FilePreview-C9Ut4Lq6.js +2 -0
- package/web/dist/assets/FilePreview-CvK3ZzX5.js +2 -0
- package/web/dist/assets/GlobalSearchModal-C5e-OCw2.js +1 -0
- package/web/dist/assets/GlobalSearchModal-H7pFK2UC.js +1 -0
- package/web/dist/assets/GroupConversation-C2wNM0dQ.js +1 -0
- package/web/dist/assets/GroupConversation-ChN3TWQK.js +1 -0
- package/web/dist/assets/ModelConfigModal-DDZccDYt.js +2 -0
- package/web/dist/assets/PiSetupModal-DHbqfx8T.js +1 -0
- package/web/dist/assets/ProviderOAuthControls-C-MK36Dk.js +1 -0
- package/web/dist/assets/SCMPanel-buTGziDB.js +2 -0
- package/web/dist/assets/SCMPanel-kx-SCL2s.js +2 -0
- package/web/dist/assets/SettingsModal-BsUF8jqr.js +20 -0
- package/web/dist/assets/SettingsModal-D357Ky7P.js +20 -0
- package/web/dist/assets/TerminalPanel-BBuM_Sez.js +3 -0
- package/web/dist/assets/TerminalPanel-D6x6xz8Q.js +3 -0
- package/web/dist/assets/TuiOverlayModal-CdbGV3Za.js +1 -0
- package/web/dist/assets/TuiOverlayModal-d6x9u25n.js +1 -0
- package/web/dist/assets/app-globals-DcyO0UPi.js +1 -0
- package/web/dist/assets/desktop-YguLbrX1.js +1 -0
- package/web/dist/assets/es-DWMIuDU2.js +2 -0
- package/web/dist/assets/fi-DaSO0Q-m.js +325 -0
- package/web/dist/assets/index-BPvpea8t.js +85 -0
- package/web/dist/assets/index-D6u8xH0o.js +85 -0
- package/web/dist/assets/index-DDZMv6LO.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-BRBg6zmQ.js +1 -0
- package/web/dist/assets/shortcut-stack-hhrDyRBn.js +1 -0
- package/web/dist/assets/theme-DDl-Oy1b.js +1 -0
- package/web/dist/assets/uuid-BzDIGCwP.js +1 -0
- package/web/dist/index.html +42 -35
- package/web/dist/sw.js +179 -179
- package/web/public/sw.js +179 -179
- package/dist/gh-comment-781.md +0 -5
- package/dist/server/durable/durable-capabilities.js +0 -11
- package/dist/server/markers/builtins/services.js +0 -123
- package/dist/server/markers/builtins/todo.js +0 -189
- package/dist/server/markers-list-tool.js +0 -34
- package/dist/server/orchestrator.js +0 -109
- package/dist/server/system-prompt-soul.js +0 -41
- package/dist/server/univer-service.js +0 -448
- package/dist/server/universal/drivers/dsh-driver.js +0 -379
- package/dist/test-artifact.md +0 -9
- package/dist/test-preview-modal.md +0 -11
- package/dist/test-report.html +0 -20
- package/web/dist/assets/TerminalPanel-Ci55JtJL.js +0 -3
- package/web/dist/assets/index-ByiO9f-N.js +0 -2008
- package/web/dist/assets/index-ycGLh4a4.css +0 -1
- package/web/dist/assets/markdown-BJZlfvdP.js +0 -296
- package/web/dist/assets/markdown-DSNUiDzp.css +0 -1
|
@@ -1,100 +1,100 @@
|
|
|
1
|
-
# pi-web-ui behind nginx at a sub-path: http://<host>:83/pi/
|
|
2
|
-
# Backend app: http://127.0.0.1:8787 (default PI_WEB_PORT env)
|
|
3
|
-
#
|
|
4
|
-
# IMPORTANT: pi-web-ui 0.23+ checks the WebSocket Origin against the request
|
|
5
|
-
# Host (hostname AND port). Every proxied location MUST forward the original
|
|
6
|
-
# Host with $http_host (keeps the port). Using $host (drops the port) or
|
|
7
|
-
# leaving Host unset (defaults to 127.0.0.1:8787) makes the upgrade fail with
|
|
8
|
-
# 403 — the page loads but chat/terminal keep reconnecting.
|
|
9
|
-
#
|
|
10
|
-
# Topology (two listeners on one port: frp + LAN coexist):
|
|
11
|
-
# frp (public) -> <PUBLIC_IP>:<PUBLIC_PORT> -> 127.0.0.1:83 (PROXY protocol v2)
|
|
12
|
-
# LAN users -> http://<LAN_IP>:83/pi/ (plain HTTP listener)
|
|
13
|
-
#
|
|
14
|
-
# frpc sends PROXY v2 to nginx (transport.proxyProtocolVersion = "v2"):
|
|
15
|
-
# * 127.0.0.1:83 proxy_protocol — only the local frp client connects
|
|
16
|
-
# here (it speaks PROXY v2; nginx then sees the real visitor IP).
|
|
17
|
-
# * <LAN_IP>:83 plain HTTP — LAN browsers, no PROXY header needed.
|
|
18
|
-
#
|
|
19
|
-
# Simpler alternative (no real client IPs): drop proxy_protocol entirely and
|
|
20
|
-
# use a single `listen 83;` — then frpc must NOT set proxyProtocolVersion.
|
|
21
|
-
#
|
|
22
|
-
# The frontend uses absolute paths (/ws WebSocket, /assets/*, /favicon.svg,
|
|
23
|
-
# /api/file…) so those get their own proxied locations next to /pi/.
|
|
24
|
-
|
|
25
|
-
# Reuse for Upgrade/Connection headers (WebSocket).
|
|
26
|
-
map $http_upgrade $connection_upgrade {
|
|
27
|
-
default upgrade;
|
|
28
|
-
'' close;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
server {
|
|
32
|
-
listen 127.0.0.1:83 proxy_protocol;
|
|
33
|
-
listen <LAN_IP>:83;
|
|
34
|
-
|
|
35
|
-
server_name _;
|
|
36
|
-
|
|
37
|
-
# Trust PROXY-protocol headers only from the local frp client; plain
|
|
38
|
-
# (LAN) connections keep their real $remote_addr untouched.
|
|
39
|
-
set_real_ip_from 127.0.0.1;
|
|
40
|
-
real_ip_header proxy_protocol;
|
|
41
|
-
|
|
42
|
-
# ---- main entry: strip /pi/ and forward to the app root ----
|
|
43
|
-
location /pi/ {
|
|
44
|
-
proxy_pass http://127.0.0.1:8787/;
|
|
45
|
-
proxy_http_version 1.1;
|
|
46
|
-
# $http_host keeps the port — origin check compares hostname AND port.
|
|
47
|
-
proxy_set_header Host $http_host;
|
|
48
|
-
proxy_set_header X-Real-IP $remote_addr;
|
|
49
|
-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
50
|
-
proxy_set_header X-Forwarded-Proto $scheme;
|
|
51
|
-
proxy_set_header Upgrade $http_upgrade;
|
|
52
|
-
proxy_set_header Connection $connection_upgrade;
|
|
53
|
-
proxy_read_timeout 3600s;
|
|
54
|
-
proxy_send_timeout 3600s;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
# ---- subpath WebSocket (frontend connects to ws://<host>/pi/ws under /pi/ base) ----
|
|
58
|
-
location /pi/ws {
|
|
59
|
-
proxy_pass http://127.0.0.1:8787/ws;
|
|
60
|
-
proxy_http_version 1.1;
|
|
61
|
-
proxy_set_header Host $http_host;
|
|
62
|
-
proxy_set_header Upgrade $http_upgrade;
|
|
63
|
-
proxy_set_header Connection $connection_upgrade;
|
|
64
|
-
proxy_read_timeout 3600s;
|
|
65
|
-
proxy_send_timeout 3600s;
|
|
66
|
-
proxy_set_header X-Real-IP $remote_addr;
|
|
67
|
-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
# ---- root WebSocket fallback (for direct ws://<host>/ws connections) ----
|
|
71
|
-
location /ws {
|
|
72
|
-
proxy_pass http://127.0.0.1:8787;
|
|
73
|
-
proxy_http_version 1.1;
|
|
74
|
-
proxy_set_header Host $http_host;
|
|
75
|
-
proxy_set_header Upgrade $http_upgrade;
|
|
76
|
-
proxy_set_header Connection $connection_upgrade;
|
|
77
|
-
proxy_read_timeout 3600s;
|
|
78
|
-
proxy_send_timeout 3600s;
|
|
79
|
-
proxy_set_header X-Real-IP $remote_addr;
|
|
80
|
-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
# ---- absolute asset paths baked into index.html ----
|
|
84
|
-
location /assets/ {
|
|
85
|
-
proxy_pass http://127.0.0.1:8787;
|
|
86
|
-
}
|
|
87
|
-
location = /favicon.svg {
|
|
88
|
-
proxy_pass http://127.0.0.1:8787;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
# ---- media preview / download / health API ----
|
|
92
|
-
location /api/ {
|
|
93
|
-
proxy_pass http://127.0.0.1:8787;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
# bare root → app entry
|
|
97
|
-
location = / {
|
|
98
|
-
return 302 /pi/;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
1
|
+
# pi-web-ui behind nginx at a sub-path: http://<host>:83/pi/
|
|
2
|
+
# Backend app: http://127.0.0.1:8787 (default PI_WEB_PORT env)
|
|
3
|
+
#
|
|
4
|
+
# IMPORTANT: pi-web-ui 0.23+ checks the WebSocket Origin against the request
|
|
5
|
+
# Host (hostname AND port). Every proxied location MUST forward the original
|
|
6
|
+
# Host with $http_host (keeps the port). Using $host (drops the port) or
|
|
7
|
+
# leaving Host unset (defaults to 127.0.0.1:8787) makes the upgrade fail with
|
|
8
|
+
# 403 — the page loads but chat/terminal keep reconnecting.
|
|
9
|
+
#
|
|
10
|
+
# Topology (two listeners on one port: frp + LAN coexist):
|
|
11
|
+
# frp (public) -> <PUBLIC_IP>:<PUBLIC_PORT> -> 127.0.0.1:83 (PROXY protocol v2)
|
|
12
|
+
# LAN users -> http://<LAN_IP>:83/pi/ (plain HTTP listener)
|
|
13
|
+
#
|
|
14
|
+
# frpc sends PROXY v2 to nginx (transport.proxyProtocolVersion = "v2"):
|
|
15
|
+
# * 127.0.0.1:83 proxy_protocol — only the local frp client connects
|
|
16
|
+
# here (it speaks PROXY v2; nginx then sees the real visitor IP).
|
|
17
|
+
# * <LAN_IP>:83 plain HTTP — LAN browsers, no PROXY header needed.
|
|
18
|
+
#
|
|
19
|
+
# Simpler alternative (no real client IPs): drop proxy_protocol entirely and
|
|
20
|
+
# use a single `listen 83;` — then frpc must NOT set proxyProtocolVersion.
|
|
21
|
+
#
|
|
22
|
+
# The frontend uses absolute paths (/ws WebSocket, /assets/*, /favicon.svg,
|
|
23
|
+
# /api/file…) so those get their own proxied locations next to /pi/.
|
|
24
|
+
|
|
25
|
+
# Reuse for Upgrade/Connection headers (WebSocket).
|
|
26
|
+
map $http_upgrade $connection_upgrade {
|
|
27
|
+
default upgrade;
|
|
28
|
+
'' close;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
server {
|
|
32
|
+
listen 127.0.0.1:83 proxy_protocol;
|
|
33
|
+
listen <LAN_IP>:83;
|
|
34
|
+
|
|
35
|
+
server_name _;
|
|
36
|
+
|
|
37
|
+
# Trust PROXY-protocol headers only from the local frp client; plain
|
|
38
|
+
# (LAN) connections keep their real $remote_addr untouched.
|
|
39
|
+
set_real_ip_from 127.0.0.1;
|
|
40
|
+
real_ip_header proxy_protocol;
|
|
41
|
+
|
|
42
|
+
# ---- main entry: strip /pi/ and forward to the app root ----
|
|
43
|
+
location /pi/ {
|
|
44
|
+
proxy_pass http://127.0.0.1:8787/;
|
|
45
|
+
proxy_http_version 1.1;
|
|
46
|
+
# $http_host keeps the port — origin check compares hostname AND port.
|
|
47
|
+
proxy_set_header Host $http_host;
|
|
48
|
+
proxy_set_header X-Real-IP $remote_addr;
|
|
49
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
50
|
+
proxy_set_header X-Forwarded-Proto $scheme;
|
|
51
|
+
proxy_set_header Upgrade $http_upgrade;
|
|
52
|
+
proxy_set_header Connection $connection_upgrade;
|
|
53
|
+
proxy_read_timeout 3600s;
|
|
54
|
+
proxy_send_timeout 3600s;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
# ---- subpath WebSocket (frontend connects to ws://<host>/pi/ws under /pi/ base) ----
|
|
58
|
+
location /pi/ws {
|
|
59
|
+
proxy_pass http://127.0.0.1:8787/ws;
|
|
60
|
+
proxy_http_version 1.1;
|
|
61
|
+
proxy_set_header Host $http_host;
|
|
62
|
+
proxy_set_header Upgrade $http_upgrade;
|
|
63
|
+
proxy_set_header Connection $connection_upgrade;
|
|
64
|
+
proxy_read_timeout 3600s;
|
|
65
|
+
proxy_send_timeout 3600s;
|
|
66
|
+
proxy_set_header X-Real-IP $remote_addr;
|
|
67
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
# ---- root WebSocket fallback (for direct ws://<host>/ws connections) ----
|
|
71
|
+
location /ws {
|
|
72
|
+
proxy_pass http://127.0.0.1:8787;
|
|
73
|
+
proxy_http_version 1.1;
|
|
74
|
+
proxy_set_header Host $http_host;
|
|
75
|
+
proxy_set_header Upgrade $http_upgrade;
|
|
76
|
+
proxy_set_header Connection $connection_upgrade;
|
|
77
|
+
proxy_read_timeout 3600s;
|
|
78
|
+
proxy_send_timeout 3600s;
|
|
79
|
+
proxy_set_header X-Real-IP $remote_addr;
|
|
80
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
# ---- absolute asset paths baked into index.html ----
|
|
84
|
+
location /assets/ {
|
|
85
|
+
proxy_pass http://127.0.0.1:8787;
|
|
86
|
+
}
|
|
87
|
+
location = /favicon.svg {
|
|
88
|
+
proxy_pass http://127.0.0.1:8787;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
# ---- media preview / download / health API ----
|
|
92
|
+
location /api/ {
|
|
93
|
+
proxy_pass http://127.0.0.1:8787;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
# bare root → app entry
|
|
97
|
+
location = / {
|
|
98
|
+
return 302 /pi/;
|
|
99
|
+
}
|
|
100
|
+
}
|
package/deploy/pi-web-ui.service
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
# pi-web-ui systemd unit — Linux auto-start on boot.
|
|
2
|
-
#
|
|
3
|
-
# Install (adjust User/WorkingDirectory/Environment to taste):
|
|
4
|
-
# sudo npm i -g pi-web-ui
|
|
5
|
-
# sudo cp deploy/pi-web-ui.service /etc/systemd/system/
|
|
6
|
-
# sudo systemctl daemon-reload
|
|
7
|
-
# sudo systemctl enable --now pi-web-ui
|
|
8
|
-
# sudo systemctl status pi-web-ui
|
|
9
|
-
#
|
|
10
|
-
# Logs: journalctl -u pi-web-ui -f
|
|
11
|
-
|
|
12
|
-
[Unit]
|
|
13
|
-
Description=pi-web-ui — web chat for the pi coding agent
|
|
14
|
-
After=network.target
|
|
15
|
-
|
|
16
|
-
[Service]
|
|
17
|
-
Type=simple
|
|
18
|
-
# Run as an unprivileged user (change to your user, e.g. yourname)
|
|
19
|
-
User=YOUR_USER
|
|
20
|
-
# The workspace the agent operates in (read/edit/bash/write)
|
|
21
|
-
WorkingDirectory=/home/YOUR_USER
|
|
22
|
-
Environment=PI_WEB_PORT=8787
|
|
23
|
-
# For privileged ports (1-1023, e.g. 80/443), uncomment both lines:
|
|
24
|
-
#CapabilityBoundingSet=CAP_NET_BIND_SERVICE
|
|
25
|
-
#AmbientCapabilities=CAP_NET_BIND_SERVICE
|
|
26
|
-
# Optional authentication; protect this file if you store a token here.
|
|
27
|
-
#Environment="PI_WEB_TOKEN=replace-with-your-token"
|
|
28
|
-
# Point at your pi config dir if it's not the default ~/.pi/agent
|
|
29
|
-
#Environment=PI_CODING_AGENT_DIR=/home/YOUR_USER/.pi/agent
|
|
30
|
-
ExecStart=/usr/bin/pi-web-ui
|
|
31
|
-
Restart=on-failure
|
|
32
|
-
RestartSec=5
|
|
33
|
-
# npm global bin may live elsewhere (nvm, etc.) — find with: which pi-web-ui
|
|
34
|
-
|
|
35
|
-
[Install]
|
|
36
|
-
WantedBy=multi-user.target
|
|
1
|
+
# pi-web-ui systemd unit — Linux auto-start on boot.
|
|
2
|
+
#
|
|
3
|
+
# Install (adjust User/WorkingDirectory/Environment to taste):
|
|
4
|
+
# sudo npm i -g pi-web-ui
|
|
5
|
+
# sudo cp deploy/pi-web-ui.service /etc/systemd/system/
|
|
6
|
+
# sudo systemctl daemon-reload
|
|
7
|
+
# sudo systemctl enable --now pi-web-ui
|
|
8
|
+
# sudo systemctl status pi-web-ui
|
|
9
|
+
#
|
|
10
|
+
# Logs: journalctl -u pi-web-ui -f
|
|
11
|
+
|
|
12
|
+
[Unit]
|
|
13
|
+
Description=pi-web-ui — web chat for the pi coding agent
|
|
14
|
+
After=network.target
|
|
15
|
+
|
|
16
|
+
[Service]
|
|
17
|
+
Type=simple
|
|
18
|
+
# Run as an unprivileged user (change to your user, e.g. yourname)
|
|
19
|
+
User=YOUR_USER
|
|
20
|
+
# The workspace the agent operates in (read/edit/bash/write)
|
|
21
|
+
WorkingDirectory=/home/YOUR_USER
|
|
22
|
+
Environment=PI_WEB_PORT=8787
|
|
23
|
+
# For privileged ports (1-1023, e.g. 80/443), uncomment both lines:
|
|
24
|
+
#CapabilityBoundingSet=CAP_NET_BIND_SERVICE
|
|
25
|
+
#AmbientCapabilities=CAP_NET_BIND_SERVICE
|
|
26
|
+
# Optional authentication; protect this file if you store a token here.
|
|
27
|
+
#Environment="PI_WEB_TOKEN=replace-with-your-token"
|
|
28
|
+
# Point at your pi config dir if it's not the default ~/.pi/agent
|
|
29
|
+
#Environment=PI_CODING_AGENT_DIR=/home/YOUR_USER/.pi/agent
|
|
30
|
+
ExecStart=/usr/bin/pi-web-ui
|
|
31
|
+
Restart=on-failure
|
|
32
|
+
RestartSec=5
|
|
33
|
+
# npm global bin may live elsewhere (nvm, etc.) — find with: which pi-web-ui
|
|
34
|
+
|
|
35
|
+
[Install]
|
|
36
|
+
WantedBy=multi-user.target
|
|
@@ -18,14 +18,16 @@ import { randomUUID } from "node:crypto";
|
|
|
18
18
|
import { VERSION, getAgentDir } from "@earendil-works/pi-coding-agent";
|
|
19
19
|
import { ClientStateStore } from "./client-state.js";
|
|
20
20
|
import { ClaimStore } from "./claim-store.js";
|
|
21
|
+
import { isBotExecutionRegistered } from "./device-center/bot-execution.js";
|
|
21
22
|
import { toServiceInfo, launchOrigin } from "./launch-origin.js";
|
|
22
|
-
import { isPseudoClientId, checkPluginCwd } from "./client-id-utils.js";
|
|
23
|
+
import { isPseudoClientId, isOrphanAdoptionExcludedClientId, checkPluginCwd } from "./client-id-utils.js";
|
|
23
24
|
import { pickAdoptableOrphan } from "./orphan-manager.js";
|
|
24
25
|
import { findMostRecentSessionFileFast } from "./session-parser.js";
|
|
25
26
|
import { isRemoteWorkspaceUri, resolveWorkspaceSessionDir } from "./remote-ssh-service.js";
|
|
26
27
|
import { getMaxOpenConversations } from "./agent-formatters.js";
|
|
27
28
|
import { collectSubagentDescendantIds } from "./subagents.js";
|
|
28
29
|
import { pickLatestClientSnapshot } from "./plugin-conversation-view.js";
|
|
30
|
+
import { normalizePluginChatAttachments } from "./plugin-chat-attachments.js";
|
|
29
31
|
import { DEFAULT_PI_CAPABILITIES } from "./engine-capabilities.js";
|
|
30
32
|
import { ClientSession, QuiesceRejectedError, OFFLINE_ROW_TTL_MS, } from "./agent-service.js";
|
|
31
33
|
export class AgentService {
|
|
@@ -590,6 +592,7 @@ export class AgentService {
|
|
|
590
592
|
const acct = String(req?.accountId ?? "default").replace(/[^A-Za-z0-9_-]/g, "") || "default";
|
|
591
593
|
const clientId = `plugin:${safe}:${acct}`;
|
|
592
594
|
const text = String(req?.text ?? "");
|
|
595
|
+
const attachments = normalizePluginChatAttachments(req?.attachments);
|
|
593
596
|
if (!text.trim())
|
|
594
597
|
throw new Error("chatFromPlugin: text 为空");
|
|
595
598
|
if (this.quiesced)
|
|
@@ -602,20 +605,41 @@ export class AgentService {
|
|
|
602
605
|
// miss/已回收时不抛错,回落无头伪客户端(浏览器关着时微信照常可用)。
|
|
603
606
|
const target = String(req?.conversationId ?? "").trim();
|
|
604
607
|
if (target) {
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
608
|
+
// Conversation ids are local to a client. Prefer this channel's own
|
|
609
|
+
// client; otherwise require an unambiguous target instead of guessing.
|
|
610
|
+
const own = this.clients.get(clientId);
|
|
611
|
+
const ownConv = own?.getConversation(target);
|
|
612
|
+
const hits = [];
|
|
613
|
+
if (own && ownConv)
|
|
614
|
+
hits.push({ owner: own, conv: ownConv, ownerId: clientId });
|
|
615
|
+
else {
|
|
616
|
+
for (const [ownerId, owner] of this.clients) {
|
|
617
|
+
const conv = owner.getConversation(target);
|
|
618
|
+
if (conv)
|
|
619
|
+
hits.push({ owner, conv, ownerId });
|
|
617
620
|
}
|
|
618
|
-
|
|
621
|
+
}
|
|
622
|
+
if (hits.length > 1)
|
|
623
|
+
throw new Error("chatFromPlugin: ambiguous conversation id; rebind the channel");
|
|
624
|
+
if (hits.length === 1) {
|
|
625
|
+
const { owner, conv, ownerId } = hits[0];
|
|
626
|
+
if (req.cwd && resolve(req.cwd) !== resolve(conv.cwd))
|
|
627
|
+
throw new Error("chatFromPlugin: bound conversation cwd differs; start a new channel conversation");
|
|
628
|
+
if (req.model || req.thinkingLevel) {
|
|
629
|
+
// Apply overrides only when the captured conversation is active;
|
|
630
|
+
// these APIs address the owner's active conversation.
|
|
631
|
+
if (owner.readConversationForPlugins()?.conversationId !== conv.id)
|
|
632
|
+
throw new Error("chatFromPlugin: cannot change settings of an inactive bound conversation");
|
|
633
|
+
if (req.model)
|
|
634
|
+
await owner.switchModelOrThrow(req.model);
|
|
635
|
+
if (req.thinkingLevel)
|
|
636
|
+
owner.setThinking(req.thinkingLevel);
|
|
637
|
+
}
|
|
638
|
+
owner.markPluginRun(runId, conv);
|
|
639
|
+
void owner
|
|
640
|
+
.prompt(text, attachments, false, conv)
|
|
641
|
+
.catch((err) => console.error("[plugin chat] prompt failed", err));
|
|
642
|
+
return { conversationId: conv.id, clientId: ownerId, runId };
|
|
619
643
|
}
|
|
620
644
|
}
|
|
621
645
|
// 2. 工作空间:不传回落伪客户端当前目录;传了必须存在且非系统目录。
|
|
@@ -662,9 +686,18 @@ export class AgentService {
|
|
|
662
686
|
/* 打标尽力而为 */
|
|
663
687
|
}
|
|
664
688
|
const conversationId = stampedId || (cs.readConversationForPlugins()?.conversationId ?? "");
|
|
665
|
-
|
|
689
|
+
const conv = cs.getConversation(conversationId);
|
|
690
|
+
void cs.prompt(text, attachments, false, conv).catch((err) => console.error("[plugin chat] prompt failed", err));
|
|
666
691
|
return { conversationId, clientId, runId };
|
|
667
692
|
}
|
|
693
|
+
/** Abort by the stable plugin run token, including after conversation takeover. */
|
|
694
|
+
async abortPluginRun(runId) {
|
|
695
|
+
for (const owner of this.clients.values()) {
|
|
696
|
+
if (owner.findPluginRun(runId))
|
|
697
|
+
return owner.abortPluginRun(runId);
|
|
698
|
+
}
|
|
699
|
+
return { ok: false, error: "Plugin run is no longer active" };
|
|
700
|
+
}
|
|
668
701
|
/** 内置定时任务的无头执行(issue #184,server/scheduler-tasks.ts 的 executor)。
|
|
669
702
|
* 每个任务独立伪客户端 `scheduler:<taskId>`(专属会话连续、无浏览器也能跑);
|
|
670
703
|
* cwd 按任务配置 pin 住(不存在即失败,不默默跑错目录);可选模型/思考强度
|
|
@@ -807,7 +840,7 @@ export class AgentService {
|
|
|
807
840
|
for (const [id, cs] of this.clients) {
|
|
808
841
|
if (id === excludeClientId)
|
|
809
842
|
continue;
|
|
810
|
-
const pseudo =
|
|
843
|
+
const pseudo = isOrphanAdoptionExcludedClientId(id);
|
|
811
844
|
let live = false;
|
|
812
845
|
let streaming = 0;
|
|
813
846
|
let adoptable = false;
|
|
@@ -1078,6 +1111,31 @@ export class AgentService {
|
|
|
1078
1111
|
target.refreshExternalRunning();
|
|
1079
1112
|
}
|
|
1080
1113
|
}
|
|
1114
|
+
/** Locate the live request again after takeover; conversation IDs may have changed. */
|
|
1115
|
+
async navigateQuestion(targetId, id) {
|
|
1116
|
+
const target = this.clients.get(targetId);
|
|
1117
|
+
if (!target)
|
|
1118
|
+
return;
|
|
1119
|
+
for (const [ownerId, source] of this.clients) {
|
|
1120
|
+
if (AgentService.isPseudoClientId(ownerId))
|
|
1121
|
+
continue;
|
|
1122
|
+
const request = source.getQuestionNavigation(id);
|
|
1123
|
+
if (!request || resolve(request.cwd) !== resolve(target.cwd))
|
|
1124
|
+
continue;
|
|
1125
|
+
if (source !== target)
|
|
1126
|
+
await this.takeOverConversation(targetId, ownerId, request.rootConversationId);
|
|
1127
|
+
const moved = target.getQuestionNavigation(id);
|
|
1128
|
+
if (moved)
|
|
1129
|
+
await target.switchConversation(moved.conversationId);
|
|
1130
|
+
return;
|
|
1131
|
+
}
|
|
1132
|
+
target.sendNotice({
|
|
1133
|
+
type: "notice",
|
|
1134
|
+
level: "warning",
|
|
1135
|
+
text: "问卷已结束,无法定位来源",
|
|
1136
|
+
textEn: "The question has ended; its source is no longer available.",
|
|
1137
|
+
});
|
|
1138
|
+
}
|
|
1081
1139
|
/** Get or create the session for a client, racing attach calls safely. */
|
|
1082
1140
|
async attach(clientId, send) {
|
|
1083
1141
|
let cs = this.clients.get(clientId);
|
|
@@ -1094,9 +1152,9 @@ export class AgentService {
|
|
|
1094
1152
|
// 流式增量经尾部 attachSink 直接推给新 socket)。
|
|
1095
1153
|
// 有其他在线标签时不认领(issue #10 隔离优先);quiesce 排空期也放行
|
|
1096
1154
|
// (这是重连既有工作,不是新工作)。本段无 await,并发 attach 原子。
|
|
1097
|
-
//
|
|
1098
|
-
//
|
|
1099
|
-
const orphan =
|
|
1155
|
+
// 伪客户端(含 device-task- 私有 Bot capability)绝不认领;
|
|
1156
|
+
// 候选端同样排除伪客户端,禁止浏览器接管 Bot 或新任务复用旧 capability。
|
|
1157
|
+
const orphan = isOrphanAdoptionExcludedClientId(clientId) ? null : this.findAdoptableOrphan(clientId);
|
|
1100
1158
|
if (orphan) {
|
|
1101
1159
|
this.clients.delete(orphan.oldId);
|
|
1102
1160
|
// 残骸被本页认领:它的离线行状态随 id 作废(行归到新 id 名下)。
|
|
@@ -1148,9 +1206,9 @@ export class AgentService {
|
|
|
1148
1206
|
// 也无需事后拆 runtime)。之前只拦 running:空闲持有照样恢复出双
|
|
1149
1207
|
// writer,两边轮流发送分叉历史。其他客户端不存在时不扫目录。
|
|
1150
1208
|
let createOpts;
|
|
1151
|
-
const
|
|
1152
|
-
if (
|
|
1153
|
-
//
|
|
1209
|
+
const requiresBlankSession = isOrphanAdoptionExcludedClientId(clientId);
|
|
1210
|
+
if (requiresBlankSession) {
|
|
1211
|
+
// 伪客户端(插件、调度、Canvas、Bot):禁止自动恢复工作区历史或旧任务,强制空白
|
|
1154
1212
|
createOpts = { blank: true };
|
|
1155
1213
|
}
|
|
1156
1214
|
else if (this.clients.size > 0) {
|
|
@@ -1198,6 +1256,11 @@ export class AgentService {
|
|
|
1198
1256
|
detachedSinks.delete(send);
|
|
1199
1257
|
if (detachedSinks.size === 0)
|
|
1200
1258
|
this.pendingDetaches.delete(clientId);
|
|
1259
|
+
if (clientId.startsWith("device-task-") && !isBotExecutionRegistered(clientId) && cs.sinkCount() === 0) {
|
|
1260
|
+
this.clients.delete(clientId);
|
|
1261
|
+
await cs.dispose();
|
|
1262
|
+
return cs;
|
|
1263
|
+
}
|
|
1201
1264
|
}
|
|
1202
1265
|
else {
|
|
1203
1266
|
cs.attachSink(send);
|
|
@@ -1230,6 +1293,18 @@ export class AgentService {
|
|
|
1230
1293
|
for (const cs of this.clients.values())
|
|
1231
1294
|
cs.refreshPluginTools();
|
|
1232
1295
|
}
|
|
1296
|
+
mcpProjectCwds() {
|
|
1297
|
+
return [...new Set([...this.clients.values()].flatMap((cs) => cs.mcpProjectCwds()))];
|
|
1298
|
+
}
|
|
1299
|
+
/** Runtime initialization/reload also updates management UI, including clients without conversations. */
|
|
1300
|
+
refreshMcpProject(cwd) {
|
|
1301
|
+
for (const cs of this.clients.values()) {
|
|
1302
|
+
if (resolve(cs.cwd) !== resolve(cwd))
|
|
1303
|
+
continue;
|
|
1304
|
+
cs.broadcastMcpServers();
|
|
1305
|
+
cs.pushSettings();
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1233
1308
|
/** Browser UI locale report (hello.locale / set_locale): persist per client
|
|
1234
1309
|
* and refresh lang-aware prompts (streaming-safe via ClientSession). */
|
|
1235
1310
|
async setLocale(clientId, locale) {
|
|
@@ -1270,8 +1345,11 @@ export class AgentService {
|
|
|
1270
1345
|
if (cs) {
|
|
1271
1346
|
cs.detachSink(send);
|
|
1272
1347
|
if (cs.sinkCount() === 0) {
|
|
1273
|
-
if (clientId.startsWith("canvas:") ||
|
|
1274
|
-
|
|
1348
|
+
if (clientId.startsWith("canvas:") ||
|
|
1349
|
+
clientId.startsWith("canvas-") ||
|
|
1350
|
+
(clientId.startsWith("device-task-") && !isBotExecutionRegistered(clientId))) {
|
|
1351
|
+
// Bot registration is released only after the executor confirms stop.
|
|
1352
|
+
// Keep uncertain/disconnected executions owned until that confirmation.
|
|
1275
1353
|
this.clients.delete(clientId);
|
|
1276
1354
|
void cs.dispose().catch(() => { });
|
|
1277
1355
|
return;
|