pi-web-ui 0.88.0 → 0.90.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +80 -1
- package/dist/server/agent-service.js +464 -68
- package/dist/server/attachments.js +39 -0
- package/dist/server/auth-cookie.js +23 -0
- package/dist/server/client-state.js +35 -0
- package/dist/server/composer-drafts.js +20 -2
- package/dist/server/conversation-read-tool.js +325 -0
- package/dist/server/dsh/dsh-agent-service.js +46 -11
- package/dist/server/file-archives.js +258 -0
- package/dist/server/file-transfer-routes.js +113 -0
- package/dist/server/files-service.js +123 -1
- package/dist/server/index.js +361 -14
- package/dist/server/marker-service.js +3 -1
- package/dist/server/model-admin.js +285 -36
- package/dist/server/plugins.js +152 -5
- package/dist/server/queue-utils.js +16 -0
- package/dist/server/schedule-agent-tool.js +240 -0
- package/dist/server/scheduler-tasks.js +414 -0
- package/dist/server/settings-service.js +76 -2
- package/dist/server/terminals.js +14 -1
- package/dist/server/tool-manager.js +16 -1
- package/dist/server/update-check.js +253 -19
- package/dist/server/webui-context.js +4 -0
- package/dist/server/ws-unknown-types.js +44 -0
- package/extensions/webui.ts +9 -2
- package/package.json +7 -3
- package/plugin-sdk/index.d.ts +4 -0
- package/plugin-sdk/index.mjs +9 -0
- package/plugins/catalog.json +11 -2
- package/web/dist/assets/TerminalPanel-BDbdLhpT.js +6 -0
- package/web/dist/assets/index-1f_DP8S3.js +380 -0
- package/web/dist/assets/index-DeUwDA-C.css +10 -0
- package/web/dist/index.html +2 -2
- package/web/dist/assets/TerminalPanel-CDH27dNP.js +0 -6
- package/web/dist/assets/index-CQg5A74_.js +0 -375
- package/web/dist/assets/index-DTEcxHWs.css +0 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-web-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.90.0",
|
|
4
4
|
"description": "Web chat interface for the pi coding agent, powered by the pi SDK (@earendil-works/pi-coding-agent) — one-command run, Docker/systemd/launchd deployable",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -88,6 +88,7 @@
|
|
|
88
88
|
"@xterm/addon-fit": "^0.11.0",
|
|
89
89
|
"@xterm/xterm": "^6.0.0",
|
|
90
90
|
"compression": "^1.8.1",
|
|
91
|
+
"electron-updater": "^6.8.9",
|
|
91
92
|
"express": "^4.21.2",
|
|
92
93
|
"highlight.js": "^11.10.0",
|
|
93
94
|
"katex": "^0.16.47",
|
|
@@ -102,8 +103,10 @@
|
|
|
102
103
|
"remark-breaks": "^4.0.0",
|
|
103
104
|
"remark-gfm": "^4.0.0",
|
|
104
105
|
"remark-math": "^6.0.0",
|
|
106
|
+
"tar": "^7.5.22",
|
|
105
107
|
"typebox": "^1.3.14",
|
|
106
|
-
"ws": "^8.18.0"
|
|
108
|
+
"ws": "^8.18.0",
|
|
109
|
+
"yauzl": "^3.4.0"
|
|
107
110
|
},
|
|
108
111
|
"devDependencies": {
|
|
109
112
|
"@types/compression": "^1.8.1",
|
|
@@ -112,12 +115,13 @@
|
|
|
112
115
|
"@types/react": "^18.3.12",
|
|
113
116
|
"@types/react-dom": "^18.3.1",
|
|
114
117
|
"@types/ws": "^8.5.13",
|
|
118
|
+
"@types/yauzl": "^3.4.0",
|
|
115
119
|
"@vitejs/plugin-react": "^4.3.4",
|
|
116
120
|
"concurrently": "^9.1.0",
|
|
117
121
|
"cross-env": "^10.1.0",
|
|
118
|
-
"esbuild": "^0.25.12",
|
|
119
122
|
"electron": "^44.0.0",
|
|
120
123
|
"electron-builder": "^26.0.0",
|
|
124
|
+
"esbuild": "^0.25.12",
|
|
121
125
|
"jsdom": "^26.1.0",
|
|
122
126
|
"mermaid": "^11.17.2",
|
|
123
127
|
"oxlint": "^1.81.0",
|
package/plugin-sdk/index.d.ts
CHANGED
|
@@ -190,6 +190,8 @@ export interface PluginHost {
|
|
|
190
190
|
path: string,
|
|
191
191
|
handler: (req: unknown, res: unknown) => void,
|
|
192
192
|
): () => void;
|
|
193
|
+
/** 注册通用反向代理前缀(子路径去前缀透传到 127.0.0.1:port;要 "http" 能力;返回注销函数)。 */
|
|
194
|
+
registerProxy(prefix: string, target: number | { port: number; host?: string }): () => void;
|
|
193
195
|
ui: PluginHostUi;
|
|
194
196
|
llm: PluginHostLlm;
|
|
195
197
|
storage: {
|
|
@@ -396,6 +398,8 @@ export interface MockHostControls {
|
|
|
396
398
|
commands: Array<PluginCommandDef>;
|
|
397
399
|
/** 已挂载的路由表(活数组,注销即摘除)。 */
|
|
398
400
|
routes: Array<{ method: string; path: string; handler: (req: unknown, res: unknown) => void }>;
|
|
401
|
+
/** 已注册的代理前缀(活数组,注销即摘除)。 */
|
|
402
|
+
proxies: Array<{ prefix: string; target: number | { port: number; host?: string } }>;
|
|
399
403
|
/** 已登记的定时任务(活数组 {spec, fn, opts};schedule() 不设真定时器,注销即摘除)。 */
|
|
400
404
|
schedules: Array<{ spec: string | number; fn: () => void; opts?: PluginHostScheduleOptions }>;
|
|
401
405
|
/** 依次触发全部已登记的定时回调(返回各回调返回值;抛错即 reject)。 */
|
package/plugin-sdk/index.mjs
CHANGED
|
@@ -262,6 +262,7 @@ export function createMockHost(overrides) {
|
|
|
262
262
|
const agentToolStore = [];
|
|
263
263
|
const commandStore = [];
|
|
264
264
|
const routeStore = [];
|
|
265
|
+
const proxyStore = [];
|
|
265
266
|
const scheduleStore = [];
|
|
266
267
|
// 注册类:存定义体 + 返回只摘除本次注册的注销函数(与宿主同语义)。
|
|
267
268
|
const remember = (store, entry) => {
|
|
@@ -365,6 +366,11 @@ export function createMockHost(overrides) {
|
|
|
365
366
|
path: String(path ?? "/"),
|
|
366
367
|
handler,
|
|
367
368
|
}),
|
|
369
|
+
registerProxy: (prefix, target) =>
|
|
370
|
+
remember(proxyStore, {
|
|
371
|
+
prefix: String(prefix ?? "/"),
|
|
372
|
+
target: typeof target === "number" ? { port: target, host: "127.0.0.1" } : target,
|
|
373
|
+
}),
|
|
368
374
|
fs: {
|
|
369
375
|
list: async () => [],
|
|
370
376
|
read: async () => new Uint8Array(0),
|
|
@@ -475,6 +481,9 @@ export function createMockHost(overrides) {
|
|
|
475
481
|
get routes() {
|
|
476
482
|
return routeStore;
|
|
477
483
|
},
|
|
484
|
+
get proxies() {
|
|
485
|
+
return proxyStore;
|
|
486
|
+
},
|
|
478
487
|
get schedules() {
|
|
479
488
|
return scheduleStore;
|
|
480
489
|
},
|
package/plugins/catalog.json
CHANGED
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"id": "vscode-editor",
|
|
22
22
|
"name": "vscode-editor",
|
|
23
23
|
"icon": "📝",
|
|
24
|
-
"description": "类 VSCode 工作台:多根文件树 + CodeMirror 编辑器 + 底部终端 + Remote-SSH + SFTP
|
|
25
|
-
"descriptionEn": "VSCode-like workbench: multi-root file tree, CodeMirror editor, integrated terminal, Remote-SSH and SFTP sync.",
|
|
24
|
+
"description": "类 VSCode 工作台:多根文件树 + CodeMirror 编辑器 + 底部终端 + Remote-SSH + SFTP 同步;向 AI 注册 SFTP/SSH/远端文件工具,可自主传代码。",
|
|
25
|
+
"descriptionEn": "VSCode-like workbench: multi-root file tree, CodeMirror editor, integrated terminal, Remote-SSH and SFTP sync; registers SFTP/SSH/remote-file tools so the AI can deploy code itself.",
|
|
26
26
|
"source": "xing-shuyin/pi-web-ui/plugins/vscode-editor",
|
|
27
27
|
"homepage": "https://github.com/xing-shuyin/pi-web-ui/tree/main/plugins/vscode-editor"
|
|
28
28
|
},
|
|
@@ -71,6 +71,15 @@
|
|
|
71
71
|
"source": "xing-shuyin/pi-web-ui/plugins/voice-input",
|
|
72
72
|
"homepage": "https://github.com/xing-shuyin/pi-web-ui/tree/main/plugins/voice-input"
|
|
73
73
|
},
|
|
74
|
+
{
|
|
75
|
+
"id": "live-preview",
|
|
76
|
+
"name": "live-preview",
|
|
77
|
+
"icon": "🌐",
|
|
78
|
+
"description": "Live Server 式预览:/liveserver 看 HTML(含相对资源与自动刷新),/md 看 Markdown 渲染;真服务只绑回环地址,经宿主通用代理对外只露同源前缀。",
|
|
79
|
+
"descriptionEn": "Live-Server-style preview: HTML under /liveserver (relative assets + auto reload), rendered Markdown under /md. Loopback-only inner server exposed via host proxy prefixes.",
|
|
80
|
+
"source": "xing-shuyin/pi-web-ui/plugins/live-preview",
|
|
81
|
+
"homepage": "https://github.com/xing-shuyin/pi-web-ui/tree/main/plugins/live-preview"
|
|
82
|
+
},
|
|
74
83
|
{
|
|
75
84
|
"id": "image-toolkit",
|
|
76
85
|
"name": "image-toolkit",
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{a as l,j as t}from"./markdown-D3PKeHAZ.js";import{u as z,b as L,T as q,a as p,c as se,F as G,d as re,r as J,e as ae,f as U,g as ie,h as le,i as oe,j as ce,k as me}from"./index-1f_DP8S3.js";import{l as ge}from"./index-1f_DP8S3.js";import{D as de,o as ue}from"./xterm-B96xOxS9.js";import"./react-w24rH0km.js";function fe(n){let o=null;return{clean:n.replace(/\r?\n?\[pi-term-exit:(-?\d+)\]\r?\n?/g,(k,r)=>(o=Number(r),`\r
|
|
2
|
+
`)).replace(/\r?\n?\x1b\[90m\[(?:进程已退出,退出码 |Process exited with code )-?\d+\]\x1b\[0m\r?\n?/g,`\r
|
|
3
|
+
`),exitCode:o}}function pe({conversationId:n,terminalId:o,command:h,cwd:k,title:r,agentBash:N,active:u,running:j,exitCode:w,register:R}){const C=l.useRef(null),y=l.useRef(null),{locale:T}=z(),c=l.useRef(T);c.current=T;const v=h?JSON.stringify(h):"",F=l.useRef(j===!1);l.useEffect(()=>{const m=C.current;if(!m)return;const a=new de({theme:L(),fontFamily:'"SF Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace',fontSize:13,cursorBlink:!0,scrollback:8e3}),b=new ue;a.loadAddon(b),a.open(m),y.current={term:a,fit:b},u&&a.focus();const g=()=>{a.options.theme=L()};window.addEventListener(q,g),a.attachCustomKeyEventHandler(d=>{if(d.type!=="keydown")return!0;const _=d.key?.toLowerCase();if((d.ctrlKey||d.metaKey)&&_==="v")return!1;if(d.ctrlKey&&!d.shiftKey&&!d.altKey&&_==="c"&&a.hasSelection()){const B=a.textarea;return B&&(B.value=a.getSelection(),B.select()),!1}return!0});const $=R(n,o,{write:d=>a.write(fe(d).clean),dispose:()=>a.dispose()}),A=()=>{try{b.fit(),p({type:"terminal_resize",terminalId:o,conversationId:n,cols:a.cols,rows:a.rows})}catch{}},I=requestAnimationFrame(()=>{try{b.fit()}catch{}F.current||(h?p({type:"run_command",terminalId:o,conversationId:n,command:h,cols:a.cols,rows:a.rows}):p({type:"terminal_create",terminalId:o,title:r,locale:c.current,agentBash:N,conversationId:n,cwd:k,cols:a.cols,rows:a.rows}))}),S=a.onData(d=>{p({type:"terminal_input",terminalId:o,conversationId:n,data:d})});let E=null;return typeof ResizeObserver<"u"&&(E=new ResizeObserver(()=>{m.offsetWidth>0&&m.offsetHeight>0&&A()}),E.observe(m)),()=>{cancelAnimationFrame(I),S.dispose(),window.removeEventListener(q,g),E?.disconnect(),$(),a.dispose(),y.current=null}},[n,o,v,R]),l.useEffect(()=>{if(!u)return;const m=requestAnimationFrame(()=>{const a=y.current;if(a){try{a.fit.fit(),p({type:"terminal_resize",terminalId:o,conversationId:n,cols:a.term.cols,rows:a.term.rows})}catch{}a.term.focus()}});return()=>cancelAnimationFrame(m)},[u]);const{t:D}=z(),x=l.useRef(void 0);return l.useEffect(()=>{if(j===x.current||(x.current=j,j!==!1))return;const m=y.current;m&&m.term.write(`\r
|
|
4
|
+
\x1B[90m${D("exitBanner",{code:w??""})}\x1B[0m\r
|
|
5
|
+
`)},[j,o,w]),t.jsx("div",{ref:C,className:`term-xterm ${u?"":"hidden"}`})}const X={name:"",command:"",cwd:"${pwd}"};function Ne({chat:n,terminal:o,uiTerminalToolbar:h,onUiAction:k}){const r=se(),[N,u]=l.useState(null),[j,w]=l.useState(!1),[R,C]=l.useState(!1),[y,T]=l.useState(null),[c,v]=l.useState(X),[F,D]=l.useState(null),x=l.useRef(null),[m,a]=l.useState(!0),[b,g]=l.useState(null),[$,A]=l.useState("");l.useEffect(()=>{n.terminals.length===0?u(null):n.terminals.some(e=>e.id===N)||u(n.terminals[n.terminals.length-1].id)},[n.terminals,N]),l.useEffect(()=>{n.terminalActiveId&&(u(n.terminalActiveId),w(!1))},[n.terminalActiveId]),l.useEffect(()=>()=>{x.current&&clearTimeout(x.current)},[]);const I=n.terminals.filter(e=>!e.agentBash),S=n.terminals.filter(e=>e.agentBash),E=e=>{if(!n.ready)return;const s=me(),i=n.activeConversationId||n.state?.conversationId||"";o.create({...e,id:s,conversationId:i,cols:e.cols??80,rows:e.rows??24,running:!0,exitCode:null}),u(s),w(!1)},d=()=>E({title:r("terminalTitle",{n:I.length+1}),cwd:n.state?.cwd??""}),_=e=>{const s=e.name||e.command,i=n.terminals.find(f=>f.title===s);if(i){o.restart(i.id),u(i.id),p({type:"run_command",terminalId:i.id,conversationId:i.conversationId,command:e,cols:80,rows:24});return}E({title:s,cwd:n.state?.cwd??"",command:e})},B=e=>{const s=n.terminals.find(i=>i.id===e);if(s&&p({type:"terminal_kill",terminalId:e,conversationId:s.conversationId}),o.close(e),N===e){const i=n.terminals.filter(f=>f.id!==e);u(i.length>0?i[i.length-1].id:null)}},M=e=>t.jsxs("div",{className:`term-tab ${e.id===N?"active":""}`,children:[t.jsxs("button",{type:"button",className:"term-tab-main",title:`${e.cwd}${e.command?`
|
|
6
|
+
> ${e.command.command}`:""}`,onClick:()=>{b||(u(e.id),w(!1))},children:[t.jsx("span",{className:`term-tab-dot ${e.running?"run":"exit"}`}),t.jsxs("span",{className:"term-tab-title",children:[b===e.id?t.jsx("input",{autoFocus:!0,className:"term-tab-rename-input",value:$,placeholder:e.title,onClick:s=>s.stopPropagation(),onChange:s=>A(s.target.value),onKeyDown:s=>{if(s.stopPropagation(),s.key==="Enter"&&!s.nativeEvent.isComposing){const i=$.trim();i&&p({type:"rename_terminal",terminalId:e.id,conversationId:e.conversationId,title:i}),g(null)}else s.key==="Escape"&&g(null)},onBlur:()=>g(null)}):e.title,!e.running&&t.jsx("span",{className:"term-tab-exit",children:r("exited",{code:e.exitCode===null?"":` ${e.exitCode}`})})]})]}),t.jsx("button",{type:"button",className:"term-tab-close term-tab-rename",title:r("renameTerminal"),onClick:s=>{s.stopPropagation(),A(e.title),g(e.id)},children:t.jsx(U,{})}),t.jsx("button",{type:"button",className:"term-tab-close",title:r("closeTerminal"),onClick:()=>B(e.id),children:t.jsx(ce,{})})]},e.id),Q=()=>{C(!0),T(null),v(X)},V=e=>{const s=n.commands[e];s&&(C(!1),T(e),v({name:s.name,command:s.command,cwd:s.cwd??""}))},O=()=>{C(!1),T(null)},K=()=>{const e=c.name.trim(),s=c.command.trim();if(!e||!s)return;const i=c.cwd.trim(),f={name:e,command:s,cwd:i||void 0},ee=R?[...n.commands,f]:y!==null?n.commands.map((te,ne)=>ne===y?f:te):n.commands;p({type:"save_commands",commands:ee}),O()},W=e=>{if(F===e){const s=n.commands.filter((i,f)=>f!==e);p({type:"save_commands",commands:s}),D(null),x.current&&clearTimeout(x.current)}else D(e),x.current&&clearTimeout(x.current),x.current=setTimeout(()=>D(null),2500)},Y=R||y!==null,Z=h===void 0?["host:term-cmd-refresh","host:term-cmd-new","host:term-tab-new"].map(e=>({id:e,source:"host"})):h.filter(e=>!e.hidden),P=(e,s)=>{const i=new Set(e);return Z.filter(f=>i.has(f.id)||s&&f.source!=="host")},H={"host:term-cmd-refresh":t.jsx("button",{type:"button",className:"panel-refresh",title:r("rerun"),onClick:()=>p({type:"list_commands"}),children:t.jsx(re,{})}),"host:term-cmd-new":t.jsx("button",{type:"button",className:"panel-new",title:r("newCommand"),onClick:Q,children:t.jsx(G,{})}),"host:term-tab-new":t.jsx("button",{type:"button",className:"panel-new",title:r("newTerminal"),onClick:d,children:t.jsx(G,{})})};return t.jsxs("div",{className:"terminal-view",children:[t.jsxs("aside",{className:`term-side term-commands ${j?"open":""}`,children:[t.jsxs("div",{className:"panel-header",children:[t.jsx("span",{className:"panel-title",children:r("commands")}),t.jsx("div",{className:"panel-header-actions",children:J(P(["host:term-cmd-refresh","host:term-cmd-new"],!1),H,k)})]}),t.jsx("div",{className:"panel-body",children:Y?t.jsxs("div",{className:"cmd-form",children:[t.jsx("label",{htmlFor:"cmd-name",children:r("name")}),t.jsx("input",{id:"cmd-name",className:"cmd-input",value:c.name,placeholder:r("exampleName"),autoFocus:!0,onChange:e=>v({...c,name:e.target.value})}),t.jsx("label",{htmlFor:"cmd-command",children:r("command")}),t.jsx("input",{id:"cmd-command",className:"cmd-input",value:c.command,placeholder:r("exampleCommand"),onChange:e=>v({...c,command:e.target.value}),onKeyDown:e=>{e.key==="Enter"&&!e.nativeEvent.isComposing&&K()}}),t.jsxs("label",{htmlFor:"cmd-cwd",children:[r("directory")," ",t.jsx("span",{className:"cmd-hint",children:r("cwdHint")})]}),t.jsx("input",{id:"cmd-cwd",className:"cmd-input",value:c.cwd,placeholder:"${pwd}",onChange:e=>v({...c,cwd:e.target.value}),onKeyDown:e=>{e.key==="Enter"&&!e.nativeEvent.isComposing&&K()}}),t.jsxs("div",{className:"cmd-form-actions",children:[t.jsx("button",{type:"button",className:"btn",onClick:O,children:r("cancel")}),t.jsx("button",{type:"button",className:"btn primary",disabled:!c.name.trim()||!c.command.trim(),onClick:K,children:r("save")})]})]}):t.jsxs(t.Fragment,{children:[n.commands.length===0&&t.jsx("div",{className:"panel-empty",children:r("noCommands")}),n.commands.map((e,s)=>t.jsxs("div",{className:"cmd-item",children:[t.jsx("button",{type:"button",className:"cmd-run",title:r("clickToRun"),onClick:()=>_(e),children:t.jsx(ae,{})}),t.jsxs("button",{type:"button",className:"cmd-main",title:r("clickToRun"),onClick:()=>_(e),children:[t.jsx("span",{className:"cmd-name",children:e.name}),t.jsx("span",{className:"cmd-command",children:e.command}),e.cwd&&t.jsx("span",{className:"cmd-cwd",children:e.cwd})]}),t.jsx("button",{type:"button",className:"cmd-act",title:r("edit"),onClick:()=>V(s),children:t.jsx(U,{})}),t.jsx("button",{type:"button",className:`cmd-act del ${F===s?"confirm":""}`,title:r("delete"),onClick:()=>W(s),children:F===s?r("confirmQ"):t.jsx(ie,{})})]},s))]})}),t.jsxs("div",{className:"term-tabs-block",children:[t.jsxs("div",{className:"panel-header",children:[t.jsx("span",{className:"panel-title",children:r("terminal")}),J(P(["host:term-tab-new"],!0),H,k)]}),t.jsxs("div",{className:"panel-body",children:[n.terminals.length===0&&t.jsx("div",{className:"panel-empty",children:r("noTerminal")}),I.map(M),S.length>0&&t.jsxs("div",{className:"term-folder",children:[t.jsxs("button",{type:"button",className:`term-folder-header ${m?"open":""}`,title:r("aiBashGroup"),onClick:()=>a(e=>!e),children:[t.jsx("span",{className:"term-folder-caret",children:m?"▾":"▸"}),t.jsx("span",{className:"term-folder-title",children:r("aiBashGroup")}),t.jsx("span",{className:"term-folder-count",children:S.length})]}),m&&t.jsx("div",{className:"term-folder-body",children:S.map(M)})]})]})]})]}),t.jsxs("div",{className:"term-main",children:[j&&t.jsx("div",{className:"drawer-backdrop",onClick:()=>w(!1)}),t.jsx("button",{type:"button",className:"term-side-toggle",title:r("commands"),onClick:()=>w(e=>!e),children:t.jsx(le,{})}),n.terminals.length===0?t.jsxs("div",{className:"term-empty",children:[t.jsx(oe,{className:"term-empty-icon"}),t.jsx("div",{className:"term-empty-title",children:r("builtinTerminal")}),t.jsx("div",{className:"term-empty-sub",children:r("termEmptySub")})]}):n.terminals.map(e=>t.jsx(pe,{conversationId:e.conversationId,terminalId:e.id,command:e.command,cwd:e.cwd,title:e.title,agentBash:e.agentBash,active:e.id===N,running:e.running,exitCode:e.exitCode,register:o.register},`${e.conversationId}:${e.id}`))]})]})}export{Ne as TerminalPanel,ge as renderSlotToolbar};
|