@rexvane/piweb 0.3.24 → 0.3.26
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/.next/BUILD_ID +1 -1
- package/.next/app-path-routes-manifest.json +11 -11
- package/.next/build-manifest.json +3 -3
- package/.next/prerender-manifest.json +5 -5
- package/.next/react-loadable-manifest.json +13 -20
- package/.next/required-server-files.js +2 -1
- package/.next/required-server-files.json +2 -1
- package/.next/routes-manifest.json +6 -8
- package/.next/server/app/_global-error/page.js +2 -2
- package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page.js +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +2 -2
- package/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/api/agent/[id]/events/route.js +2 -2
- package/.next/server/app/api/agent/[id]/events/route.js.nft.json +1 -1
- package/.next/server/app/api/agent/[id]/route.js +1 -1
- package/.next/server/app/api/agent/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/agent/[id]/tree/route.js +1 -1
- package/.next/server/app/api/agent/[id]/tree/route.js.nft.json +1 -1
- package/.next/server/app/api/agent/new/route.js +1 -1
- package/.next/server/app/api/agent/new/route.js.nft.json +1 -1
- package/.next/server/app/api/agent/resources/route.js +1 -0
- package/.next/server/app/api/agent/resources/route.js.nft.json +1 -0
- package/.next/server/app/api/agent/resources/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/config/route.js +1 -1
- package/.next/server/app/api/config/route.js.nft.json +1 -1
- package/.next/server/app/api/files/route.js +1 -1
- package/.next/server/app/api/files/route.js.nft.json +1 -1
- package/.next/server/app/api/fs/route.js +1 -1
- package/.next/server/app/api/fs/route.js.nft.json +1 -1
- package/.next/server/app/api/git/route.js +4 -4
- package/.next/server/app/api/git/route.js.nft.json +1 -1
- package/.next/server/app/api/github/route.js +4 -4
- package/.next/server/app/api/github/route.js.nft.json +1 -1
- package/.next/server/app/api/growth/route.js +1 -1
- package/.next/server/app/api/growth/route.js.nft.json +1 -1
- package/.next/server/app/api/health/route.js +1 -1
- package/.next/server/app/api/models/defaults/route.js +1 -1
- package/.next/server/app/api/models/defaults/route.js.nft.json +1 -1
- package/.next/server/app/api/models/route.js +1 -1
- package/.next/server/app/api/models/route.js.nft.json +1 -1
- package/.next/server/app/api/pi-settings/route.js +1 -1
- package/.next/server/app/api/pi-settings/route.js.nft.json +1 -1
- package/.next/server/app/api/plugins/route.js +1 -1
- package/.next/server/app/api/plugins/route.js.nft.json +1 -1
- package/.next/server/app/api/prompts/route.js +1 -1
- package/.next/server/app/api/prompts/route.js.nft.json +1 -1
- package/.next/server/app/api/remote/route.js +4 -3
- package/.next/server/app/api/security/route.js +1 -1
- package/.next/server/app/api/security/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/[id]/export/route.js +1 -1
- package/.next/server/app/api/sessions/[id]/export/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/[id]/route.js +1 -1
- package/.next/server/app/api/sessions/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/import/route.js +2 -2
- package/.next/server/app/api/sessions/import/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/route.js +1 -1
- package/.next/server/app/api/sessions/route.js.nft.json +1 -1
- package/.next/server/app/api/skills/route.js +2 -2
- package/.next/server/app/api/skills/route.js.nft.json +1 -1
- package/.next/server/app/api/update/route.js +2 -2
- package/.next/server/app/api/update/route.js.nft.json +1 -1
- package/.next/server/app/api/version/route.js +1 -1
- package/.next/server/app/api/version/route.js.nft.json +1 -1
- package/.next/server/app/api/web-auth/route.js +2 -2
- package/.next/server/app/api/workspaces/route.js +1 -1
- package/.next/server/app/api/workspaces/route.js.nft.json +1 -1
- package/.next/server/app/icon.svg/route.js +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +6 -7
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +6 -7
- package/.next/server/app/index.segments/_full.segment.rsc +6 -7
- package/.next/server/app/index.segments/_tree.segment.rsc +2 -3
- package/.next/server/app/login/page.js +1 -1
- package/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/.next/server/app/login.html +1 -1
- package/.next/server/app/login.rsc +3 -3
- package/.next/server/app/login.segments/_full.segment.rsc +3 -3
- package/.next/server/app/login.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/login.segments/login/__PAGE__.segment.rsc +3 -3
- package/.next/server/app/page.js +1 -1
- package/.next/server/app/page.js.nft.json +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +11 -11
- package/.next/server/chunks/3924.js +3 -3
- package/.next/server/chunks/538.js +1 -1
- package/.next/server/chunks/620.js +1 -0
- package/.next/server/chunks/6229.js +1 -1
- package/.next/server/chunks/7496.js +1 -1
- package/.next/server/chunks/7662.js +2 -2
- package/.next/server/chunks/8686.js +1 -1
- package/.next/server/functions-config-manifest.json +1 -2
- package/.next/server/instrumentation.js.nft.json +1 -1
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/preview-props.json +3 -3
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/QJCtqgDKzGS2BdKABd9ch/_buildManifest.js +1 -0
- package/.next/static/chunks/2577.86c8538fbf05a8b2.js +1 -0
- package/.next/static/chunks/2716.fa561519675a3ff1.js +1 -0
- package/.next/static/chunks/2906.8a0e09bb47605cf1.js +1 -0
- package/.next/static/chunks/4673.ea36e55005c0f82f.js +1 -0
- package/.next/static/chunks/4686-4dc565817a160351.js +1 -0
- package/.next/static/chunks/4778.0d2c5d75b791d352.js +1 -0
- package/.next/static/chunks/{618.949981da99be7182.js → 618.9a22656b863f242b.js} +2 -2
- package/.next/static/chunks/app/_global-error/page-f2d93969c0bcf406.js +1 -0
- package/.next/static/chunks/app/api/agent/[id]/events/route-f2d93969c0bcf406.js +1 -0
- package/.next/static/chunks/app/api/agent/[id]/route-f2d93969c0bcf406.js +1 -0
- package/.next/static/chunks/app/api/agent/[id]/tree/route-f2d93969c0bcf406.js +1 -0
- package/.next/static/chunks/app/api/agent/new/route-f2d93969c0bcf406.js +1 -0
- package/.next/static/chunks/app/api/agent/resources/route-f2d93969c0bcf406.js +1 -0
- package/.next/static/chunks/app/api/config/route-f2d93969c0bcf406.js +1 -0
- package/.next/static/chunks/app/api/files/route-f2d93969c0bcf406.js +1 -0
- package/.next/static/chunks/app/api/fs/route-f2d93969c0bcf406.js +1 -0
- package/.next/static/chunks/app/api/git/route-f2d93969c0bcf406.js +1 -0
- package/.next/static/chunks/app/api/github/route-f2d93969c0bcf406.js +1 -0
- package/.next/static/chunks/app/api/growth/route-f2d93969c0bcf406.js +1 -0
- package/.next/static/chunks/app/api/health/route-f2d93969c0bcf406.js +1 -0
- package/.next/static/chunks/app/api/models/defaults/route-f2d93969c0bcf406.js +1 -0
- package/.next/static/chunks/app/api/models/route-f2d93969c0bcf406.js +1 -0
- package/.next/static/chunks/app/api/pi-settings/route-f2d93969c0bcf406.js +1 -0
- package/.next/static/chunks/app/api/plugins/route-f2d93969c0bcf406.js +1 -0
- package/.next/static/chunks/app/api/prompts/route-f2d93969c0bcf406.js +1 -0
- package/.next/static/chunks/app/api/remote/route-f2d93969c0bcf406.js +1 -0
- package/.next/static/chunks/app/api/security/route-f2d93969c0bcf406.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/export/route-f2d93969c0bcf406.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/route-f2d93969c0bcf406.js +1 -0
- package/.next/static/chunks/app/api/sessions/import/route-f2d93969c0bcf406.js +1 -0
- package/.next/static/chunks/app/api/sessions/route-f2d93969c0bcf406.js +1 -0
- package/.next/static/chunks/app/api/skills/route-f2d93969c0bcf406.js +1 -0
- package/.next/static/chunks/app/api/update/route-f2d93969c0bcf406.js +1 -0
- package/.next/static/chunks/app/api/version/route-f2d93969c0bcf406.js +1 -0
- package/.next/static/chunks/app/api/web-auth/route-f2d93969c0bcf406.js +1 -0
- package/.next/static/chunks/app/api/workspaces/route-f2d93969c0bcf406.js +1 -0
- package/.next/static/chunks/app/page-71f2d3b3ed864b3d.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/app-error-f2d93969c0bcf406.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/forbidden-f2d93969c0bcf406.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/not-found-f2d93969c0bcf406.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-f2d93969c0bcf406.js +1 -0
- package/.next/static/chunks/webpack-ffc09b5fcc8aaa6d.js +1 -0
- package/.next/static/css/014eb1f21414e615.css +1 -0
- package/.next/static/css/56b129a13637fcfd.css +1 -0
- package/.next/static/css/7e3caf797e4cb19a.css +1 -0
- package/.next/types/app/api/agent/{[id]/side-chat → resources}/route.ts +3 -3
- package/.next/types/routes.d.ts +2 -2
- package/.next/types/validator.ts +9 -9
- package/README.md +1 -1
- package/next.config.ts +1 -1
- package/package.json +9 -9
- package/scripts/apply-global.mjs +87 -0
- package/scripts/launcher.mjs +21 -0
- package/scripts/testing/prepare-sdk-tools.mjs +19 -0
- package/src/app/api/agent/new/route.ts +2 -1
- package/src/app/api/agent/resources/route.ts +18 -0
- package/src/app/api/models/route.ts +22 -1
- package/src/app/api/plugins/route.ts +3 -2
- package/src/app/api/prompts/route.ts +3 -2
- package/src/app/api/remote/route.ts +22 -4
- package/src/app/api/sessions/[id]/export/route.ts +3 -1
- package/src/app/api/skills/route.ts +3 -2
- package/src/app/globals.css +1002 -1765
- package/src/components/AppShell.tsx +128 -93
- package/src/components/ChatInput.tsx +177 -98
- package/src/components/ChatWindow.tsx +189 -56
- package/src/components/ContextMeter.tsx +33 -9
- package/src/components/CustomSelect.module.css +142 -0
- package/src/components/CustomSelect.tsx +157 -0
- package/src/components/DrawerPanel.tsx +1 -1
- package/src/components/ExtensionUI.tsx +9 -3
- package/src/components/FileViewer.tsx +24 -21
- package/src/components/GitPanel.tsx +35 -13
- package/src/components/GrowthTree.tsx +6 -2
- package/src/components/ImageViewer.tsx +72 -0
- package/src/components/MarkdownBlock.tsx +67 -96
- package/src/components/ModelSelector.tsx +36 -39
- package/src/components/PiMark.tsx +76 -41
- package/src/components/PreviewImage.tsx +33 -0
- package/src/components/ProjectPanel.tsx +8 -5
- package/src/components/PromptPanel.tsx +85 -20
- package/src/components/ProviderSetupModal.module.css +12 -11
- package/src/components/ProviderSetupModal.tsx +107 -36
- package/src/components/RemoteSection.tsx +53 -2
- package/src/components/SessionImportSection.tsx +30 -15
- package/src/components/SessionSidebar.tsx +72 -62
- package/src/components/SettingsPanel.tsx +49 -151
- package/src/components/TrajectoryAnalyzer.module.css +26 -11
- package/src/components/TrajectoryView.tsx +11 -3
- package/src/components/chat/markdown-actions.tsx +23 -0
- package/src/components/composer/ComposerFiles.tsx +224 -0
- package/src/components/composer/ComposerImages.tsx +59 -127
- package/src/hooks/usePiWeb.ts +47 -2
- package/src/i18n.tsx +62 -80
- package/src/lib/agent-manager.ts +365 -33
- package/src/lib/chat/file-path.ts +54 -0
- package/src/lib/chat/skill-expansion.ts +51 -0
- package/src/lib/extension-ui.ts +25 -1
- package/src/lib/font.ts +37 -39
- package/src/lib/git-service.ts +4 -2
- package/src/lib/growth-turns.ts +3 -1
- package/src/lib/model-draft.ts +69 -2
- package/src/lib/models-service.ts +53 -3
- package/src/lib/pi.ts +2 -2
- package/src/lib/remote/assets.json +1 -1
- package/src/lib/remote/supervisor.ts +48 -5
- package/src/lib/security-service.ts +2 -1
- package/src/lib/session-reader.ts +25 -13
- package/src/lib/session-retention.ts +11 -8
- package/src/lib/skills-service.ts +2 -1
- package/src/lib/slash-command-token.ts +14 -0
- package/src/lib/trajectory.ts +111 -15
- package/src/lib/types.ts +28 -3
- package/src/lib/update-service.ts +29 -9
- package/src/lib/workspace-store.ts +36 -1
- package/.next/server/app/api/agent/[id]/side-chat/route.js +0 -5
- package/.next/server/app/api/agent/[id]/side-chat/route.js.nft.json +0 -1
- package/.next/server/app/api/agent/[id]/side-chat/route_client-reference-manifest.js +0 -1
- package/.next/server/chunks/3421.js +0 -1
- package/.next/static/chunks/2716.44fdf1b21454b961.js +0 -1
- package/.next/static/chunks/4673.e261707dce391be7.js +0 -1
- package/.next/static/chunks/4686-0cd87513f9ea3538.js +0 -1
- package/.next/static/chunks/4778.eddd3a5813f85824.js +0 -1
- package/.next/static/chunks/7411.5f79671208209b13.js +0 -1
- package/.next/static/chunks/8552.25c39ef4c995eba0.js +0 -1
- package/.next/static/chunks/app/_global-error/page-cbaaee0d7aacb85a.js +0 -1
- package/.next/static/chunks/app/api/agent/[id]/events/route-cbaaee0d7aacb85a.js +0 -1
- package/.next/static/chunks/app/api/agent/[id]/route-cbaaee0d7aacb85a.js +0 -1
- package/.next/static/chunks/app/api/agent/[id]/side-chat/route-cbaaee0d7aacb85a.js +0 -1
- package/.next/static/chunks/app/api/agent/[id]/tree/route-cbaaee0d7aacb85a.js +0 -1
- package/.next/static/chunks/app/api/agent/new/route-cbaaee0d7aacb85a.js +0 -1
- package/.next/static/chunks/app/api/config/route-cbaaee0d7aacb85a.js +0 -1
- package/.next/static/chunks/app/api/files/route-cbaaee0d7aacb85a.js +0 -1
- package/.next/static/chunks/app/api/fs/route-cbaaee0d7aacb85a.js +0 -1
- package/.next/static/chunks/app/api/git/route-cbaaee0d7aacb85a.js +0 -1
- package/.next/static/chunks/app/api/github/route-cbaaee0d7aacb85a.js +0 -1
- package/.next/static/chunks/app/api/growth/route-cbaaee0d7aacb85a.js +0 -1
- package/.next/static/chunks/app/api/health/route-cbaaee0d7aacb85a.js +0 -1
- package/.next/static/chunks/app/api/models/defaults/route-cbaaee0d7aacb85a.js +0 -1
- package/.next/static/chunks/app/api/models/route-cbaaee0d7aacb85a.js +0 -1
- package/.next/static/chunks/app/api/pi-settings/route-cbaaee0d7aacb85a.js +0 -1
- package/.next/static/chunks/app/api/plugins/route-cbaaee0d7aacb85a.js +0 -1
- package/.next/static/chunks/app/api/prompts/route-cbaaee0d7aacb85a.js +0 -1
- package/.next/static/chunks/app/api/remote/route-cbaaee0d7aacb85a.js +0 -1
- package/.next/static/chunks/app/api/security/route-cbaaee0d7aacb85a.js +0 -1
- package/.next/static/chunks/app/api/sessions/[id]/export/route-cbaaee0d7aacb85a.js +0 -1
- package/.next/static/chunks/app/api/sessions/[id]/route-cbaaee0d7aacb85a.js +0 -1
- package/.next/static/chunks/app/api/sessions/import/route-cbaaee0d7aacb85a.js +0 -1
- package/.next/static/chunks/app/api/sessions/route-cbaaee0d7aacb85a.js +0 -1
- package/.next/static/chunks/app/api/skills/route-cbaaee0d7aacb85a.js +0 -1
- package/.next/static/chunks/app/api/update/route-cbaaee0d7aacb85a.js +0 -1
- package/.next/static/chunks/app/api/version/route-cbaaee0d7aacb85a.js +0 -1
- package/.next/static/chunks/app/api/web-auth/route-cbaaee0d7aacb85a.js +0 -1
- package/.next/static/chunks/app/api/workspaces/route-cbaaee0d7aacb85a.js +0 -1
- package/.next/static/chunks/app/page-dc3cb41d91c7432e.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/app-error-cbaaee0d7aacb85a.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/forbidden-cbaaee0d7aacb85a.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/not-found-cbaaee0d7aacb85a.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-cbaaee0d7aacb85a.js +0 -1
- package/.next/static/chunks/webpack-2ac3d76b81895f5b.js +0 -1
- package/.next/static/css/08815507594e8b8d.css +0 -1
- package/.next/static/css/9fc559c2c4ad1d0f.css +0 -1
- package/.next/static/css/c6e2227c36ec2fd6.css +0 -1
- package/.next/static/css/f15a853af8b5127f.css +0 -1
- package/.next/static/lvKCJmjFj8LuqSojRVLRF/_buildManifest.js +0 -1
- package/src/app/api/agent/[id]/side-chat/route.ts +0 -77
- package/src/components/side-chat/SideChatPanel.module.css +0 -131
- package/src/components/side-chat/SideChatPanel.tsx +0 -189
- package/src/components/side-chat/icons.tsx +0 -8
- package/src/components/side-chat/request-history.ts +0 -29
- package/src/components/side-chat/store.ts +0 -248
- package/src/lib/chat/stream-settings.ts +0 -192
- package/src/lib/side-chat/context.ts +0 -123
- package/src/lib/side-chat/service.ts +0 -191
- package/src/lib/side-chat/types.ts +0 -61
- /package/.next/static/{lvKCJmjFj8LuqSojRVLRF → QJCtqgDKzGS2BdKABd9ch}/_ssgManifest.js +0 -0
|
@@ -99,6 +99,7 @@ export async function POST(req: Request) {
|
|
|
99
99
|
text?: string;
|
|
100
100
|
force?: boolean;
|
|
101
101
|
allowPrivate?: boolean;
|
|
102
|
+
headers?: unknown;
|
|
102
103
|
};
|
|
103
104
|
if (body.action === "setKey") {
|
|
104
105
|
if (!body.providerId || !body.apiKey) return NextResponse.json({ success: false, error: "missing fields" }, { status: 400 });
|
|
@@ -120,7 +121,27 @@ export async function POST(req: Request) {
|
|
|
120
121
|
}
|
|
121
122
|
if (body.action === "discoverModels") {
|
|
122
123
|
if (!body.baseUrl) return NextResponse.json({ success: false, error: "missing baseUrl" }, { status: 400 });
|
|
123
|
-
|
|
124
|
+
// 自定义请求头来自表单:只接受「名字与值都是字符串」的键值对,条数与长度都要设上限,
|
|
125
|
+
// 否则一个超大对象会原样发给上游。名字按 HTTP 令牌字符集收窄,避免注入换行等非法字符。
|
|
126
|
+
let headers: Record<string, string> | undefined;
|
|
127
|
+
if (body.headers !== undefined) {
|
|
128
|
+
if (!body.headers || typeof body.headers !== "object" || Array.isArray(body.headers)) {
|
|
129
|
+
return NextResponse.json({ success: false, error: "invalid headers" }, { status: 400 });
|
|
130
|
+
}
|
|
131
|
+
const entries = Object.entries(body.headers as Record<string, unknown>);
|
|
132
|
+
if (entries.length > 32) return NextResponse.json({ success: false, error: "too many headers" }, { status: 400 });
|
|
133
|
+
headers = {};
|
|
134
|
+
for (const [name, value] of entries) {
|
|
135
|
+
if (!/^[A-Za-z0-9!#$%&'*+.^_`|~-]{1,64}$/.test(name)) {
|
|
136
|
+
return NextResponse.json({ success: false, error: `invalid header name: ${name}` }, { status: 400 });
|
|
137
|
+
}
|
|
138
|
+
if (typeof value !== "string" || value.length > 4096 || /[\r\n]/.test(value)) {
|
|
139
|
+
return NextResponse.json({ success: false, error: `invalid header value: ${name}` }, { status: 400 });
|
|
140
|
+
}
|
|
141
|
+
if (value) headers[name] = value;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
const models = await discoverModels({ baseUrl: body.baseUrl, api: body.api, apiKey: body.apiKey, providerId: body.providerId, allowPrivate: body.allowPrivate === true, headers });
|
|
124
145
|
return NextResponse.json({ success: true, data: { models } });
|
|
125
146
|
}
|
|
126
147
|
if (body.action === "providerUsage") {
|
|
@@ -10,12 +10,13 @@ import {
|
|
|
10
10
|
updatePackages,
|
|
11
11
|
} from "@/lib/plugins-service";
|
|
12
12
|
import { BoundaryError, resolveWorkspacePath } from "@/lib/path-security";
|
|
13
|
+
import { APP_ROOT } from "@/lib/app-root";
|
|
13
14
|
|
|
14
15
|
export const dynamic = "force-dynamic";
|
|
15
16
|
|
|
16
17
|
export async function GET(req: Request) {
|
|
17
18
|
try {
|
|
18
|
-
const cwd = await resolveWorkspacePath(new URL(req.url).searchParams.get("cwd") ||
|
|
19
|
+
const cwd = await resolveWorkspacePath(new URL(req.url).searchParams.get("cwd") || APP_ROOT);
|
|
19
20
|
const [packages, extensions] = await Promise.all([listPackages(cwd), listLoadedExtensions(cwd)]);
|
|
20
21
|
return NextResponse.json({ success: true, data: { packages, extensions } });
|
|
21
22
|
} catch (err: any) {
|
|
@@ -35,7 +36,7 @@ export async function POST(req: Request) {
|
|
|
35
36
|
local?: boolean;
|
|
36
37
|
cwd?: string;
|
|
37
38
|
};
|
|
38
|
-
const cwd = await resolveWorkspacePath(body.cwd ||
|
|
39
|
+
const cwd = await resolveWorkspacePath(body.cwd || APP_ROOT);
|
|
39
40
|
if (body.source && body.source.length > 4096) {
|
|
40
41
|
return NextResponse.json({ success: false, error: "package source is too long" }, { status: 400 });
|
|
41
42
|
}
|
|
@@ -2,6 +2,7 @@ import { NextResponse } from "next/server";
|
|
|
2
2
|
import { listPromptSources, readPromptSource } from "@/lib/prompt-sources";
|
|
3
3
|
import { getManaged } from "@/lib/agent-manager";
|
|
4
4
|
import { BoundaryError, resolveSessionPath, resolveWorkspacePath } from "@/lib/path-security";
|
|
5
|
+
import { APP_ROOT } from "@/lib/app-root";
|
|
5
6
|
|
|
6
7
|
export const dynamic = "force-dynamic";
|
|
7
8
|
|
|
@@ -27,7 +28,7 @@ async function hotSession(cwd: string, sessionId: string | null) {
|
|
|
27
28
|
export async function GET(req: Request) {
|
|
28
29
|
try {
|
|
29
30
|
const url = new URL(req.url);
|
|
30
|
-
const cwd = await resolveWorkspacePath(url.searchParams.get("cwd") ||
|
|
31
|
+
const cwd = await resolveWorkspacePath(url.searchParams.get("cwd") || APP_ROOT);
|
|
31
32
|
const sessionId = url.searchParams.get("session");
|
|
32
33
|
const data = await listPromptSources({ cwd, session: await hotSession(cwd, sessionId) });
|
|
33
34
|
return NextResponse.json({ success: true, data });
|
|
@@ -42,7 +43,7 @@ export async function POST(req: Request) {
|
|
|
42
43
|
const body = (await req.json()) as { action?: string; filePath?: string; cwd?: string };
|
|
43
44
|
if (body.action !== "read") return NextResponse.json({ success: false, error: "unknown action" }, { status: 400 });
|
|
44
45
|
if (!body.filePath) return NextResponse.json({ success: false, error: "missing filePath" }, { status: 400 });
|
|
45
|
-
const cwd = await resolveWorkspacePath(body.cwd ||
|
|
46
|
+
const cwd = await resolveWorkspacePath(body.cwd || APP_ROOT);
|
|
46
47
|
return NextResponse.json({ success: true, data: { content: await readPromptSource(body.filePath, cwd) } });
|
|
47
48
|
} catch (err) {
|
|
48
49
|
const message = err instanceof Error ? err.message : "request failed";
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 「远程连接」内置插件的控制接口。
|
|
3
3
|
*
|
|
4
|
-
* GET
|
|
5
|
-
* POST { action: "start" | "stop" | "start-lan" | "stop-lan" }
|
|
4
|
+
* GET 当前状态(插件开关 + 局域网入口 + 公网入口 + 拼登录链接用的启动令牌)
|
|
5
|
+
* POST { action: "start" | "stop" | "start-lan" | "stop-lan" | "set-plugin" }
|
|
6
6
|
* DELETE 全停
|
|
7
7
|
*
|
|
8
8
|
* 「谁能调这个接口」由 proxy.ts 把关;但「现在能不能开入口」必须在这里再看一次:
|
|
9
9
|
* 认证没开时 proxy 一律放行,这时开出去的局域网 / 公网入口就是一个免密 shell。
|
|
10
10
|
*/
|
|
11
11
|
import { NextResponse } from "next/server";
|
|
12
|
-
import { remoteBlocked, remoteStatus, startLan, startPublic, stopAll, stopPublic } from "@/lib/remote/supervisor";
|
|
12
|
+
import { remoteBlocked, remoteLanEnabled, remoteStatus, setRemotePluginEnabled, startLan, startPublic, stopAll, stopLan, stopPublic } from "@/lib/remote/supervisor";
|
|
13
13
|
import { authEnabled } from "@/lib/web-auth";
|
|
14
14
|
|
|
15
15
|
export const dynamic = "force-dynamic";
|
|
@@ -63,9 +63,27 @@ export async function POST(request: Request) {
|
|
|
63
63
|
case "start-lan":
|
|
64
64
|
await startLan();
|
|
65
65
|
return respond();
|
|
66
|
+
// 只停局域网入口。原先这里调的是 stopAll(),会连公网隧道一起杀掉——
|
|
67
|
+
// 与动作名不符,也让「只关局域网」变得做不到。
|
|
66
68
|
case "stop-lan":
|
|
67
|
-
await
|
|
69
|
+
await stopLan();
|
|
68
70
|
return respond();
|
|
71
|
+
case "set-plugin": {
|
|
72
|
+
// 内置插件总开关。关掉后:不再注入手机排版、公网入口也必须停(它依赖插件);
|
|
73
|
+
// 局域网入口**保留**,退化成纯转发,自建反代指向同一个端口照旧可用。
|
|
74
|
+
const enabled = (body as { enabled?: unknown }).enabled;
|
|
75
|
+
if (typeof enabled !== "boolean") return bad("enabled must be a boolean");
|
|
76
|
+
const before = remoteStatus();
|
|
77
|
+
setRemotePluginEnabled(enabled);
|
|
78
|
+
if (!enabled) await stopPublic();
|
|
79
|
+
// 注入资源是在建监听时就烧进去的,所以必须重建监听,开关才真正生效;
|
|
80
|
+
// 重建只在「原监听需要换模式」时做,避免白断一次连接。
|
|
81
|
+
if (before.lan.running && before.lan.styled !== enabled) await stopLan();
|
|
82
|
+
// 起监听与启动时(instrumentation-node)同一道闸:认证没开 / 开发模式 / PIWEB_REMOTE_LAN=0 时
|
|
83
|
+
// 只存开关,不开局域网入口——否则拨一下开关就绕过 start-lan 的检查开出一个免密入口。
|
|
84
|
+
if (remoteBlocked() === null && remoteLanEnabled()) await startLan();
|
|
85
|
+
return respond();
|
|
86
|
+
}
|
|
69
87
|
default:
|
|
70
88
|
return bad("unknown action");
|
|
71
89
|
}
|
|
@@ -18,7 +18,9 @@ export async function GET(req: Request, { params }: { params: Promise<{ id: stri
|
|
|
18
18
|
const { id } = await params;
|
|
19
19
|
const format = new URL(req.url).searchParams.get("format") === "html" ? "html" : "jsonl";
|
|
20
20
|
try {
|
|
21
|
-
|
|
21
|
+
// 与 /api/agent/[id] 同一种解析(allowPending 返回原写法而不是 realpath):会话表按路径字符串做键,
|
|
22
|
+
// ~/.pi 经过 junction / 符号链接时两种写法不同,导出 HTML 就会给同一个文件再起一个 agent
|
|
23
|
+
const m = getManaged(await resolveSessionPath(id, { allowPending: true }));
|
|
22
24
|
const { filename, content, contentType } = await exportSession(m, format);
|
|
23
25
|
return new Response(content, {
|
|
24
26
|
headers: {
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { NextResponse } from "next/server";
|
|
2
2
|
import { deleteSkill, listSkills, readSkillFile, setSkillDisabled } from "@/lib/skills-service";
|
|
3
3
|
import { BoundaryError, resolveWorkspacePath } from "@/lib/path-security";
|
|
4
|
+
import { APP_ROOT } from "@/lib/app-root";
|
|
4
5
|
|
|
5
6
|
export const dynamic = "force-dynamic";
|
|
6
7
|
|
|
7
8
|
export async function GET(req: Request) {
|
|
8
9
|
try {
|
|
9
10
|
const rawCwd = new URL(req.url).searchParams.get("cwd");
|
|
10
|
-
const cwd = await resolveWorkspacePath(rawCwd ||
|
|
11
|
+
const cwd = await resolveWorkspacePath(rawCwd || APP_ROOT);
|
|
11
12
|
const skills = await listSkills(cwd);
|
|
12
13
|
return NextResponse.json({ success: true, data: { skills } });
|
|
13
14
|
} catch (err: any) {
|
|
@@ -18,7 +19,7 @@ export async function GET(req: Request) {
|
|
|
18
19
|
export async function POST(req: Request) {
|
|
19
20
|
try {
|
|
20
21
|
const body = (await req.json()) as { action: "toggle" | "read" | "delete"; filePath?: string; disabled?: boolean; cwd?: string };
|
|
21
|
-
const cwd = await resolveWorkspacePath(body.cwd ||
|
|
22
|
+
const cwd = await resolveWorkspacePath(body.cwd || APP_ROOT);
|
|
22
23
|
if (body.action === "toggle") {
|
|
23
24
|
if (!body.filePath || typeof body.disabled !== "boolean")
|
|
24
25
|
return NextResponse.json({ success: false, error: "missing fields" }, { status: 400 });
|