@calmabacus/pi-web 1.2.8 → 1.2.9
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 +13 -11
- package/.next/build-manifest.json +2 -2
- package/.next/required-server-files.js +1 -1
- package/.next/required-server-files.json +1 -1
- package/.next/routes-manifest.json +14 -0
- 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 +4 -4
- package/.next/server/app/_not-found.segments/_full.segment.rsc +4 -4
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +4 -4
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +3 -3
- package/.next/server/app/api/agent/[id]/bash-output/route.js +1 -1
- package/.next/server/app/api/agent/[id]/events/route.js +1 -1
- package/.next/server/app/api/agent/[id]/lease/route.js +1 -1
- package/.next/server/app/api/agent/[id]/route.js +1 -1
- package/.next/server/app/api/agent/new/route.js +1 -1
- package/.next/server/app/api/agent/running/route.js +1 -1
- package/.next/server/app/api/app-update/route.js +1 -1
- package/.next/server/app/api/auth/api-key/[provider]/route.js +1 -1
- package/.next/server/app/api/auth/login/[provider]/route.js +2 -2
- package/.next/server/app/api/auth/logout/[provider]/route.js +1 -1
- package/.next/server/app/api/auth/providers/route.js +1 -1
- package/.next/server/app/api/cwd/browse/route.js +1 -1
- package/.next/server/app/api/cwd/validate/route.js +1 -1
- package/.next/server/app/api/default-cwd/route.js +1 -1
- package/.next/server/app/api/file-index/route.js +1 -1
- package/.next/server/app/api/files/[...path]/route.js +1 -1
- package/.next/server/app/api/git/diff/route.js +2 -2
- package/.next/server/app/api/git/status/route.js +1 -1
- package/.next/server/app/api/home/route.js +1 -1
- package/.next/server/app/api/image-generation/route.js +1 -1
- package/.next/server/app/api/image-generation/settings/connections/route.js +1 -1
- package/.next/server/app/api/image-generation/settings/route.js +1 -1
- package/.next/server/app/api/models/route.js +1 -1
- package/.next/server/app/api/models-config/catalog/route.js +1 -1
- package/.next/server/app/api/models-config/discover/route.js +1 -1
- package/.next/server/app/api/models-config/picker/route.js +1 -1
- package/.next/server/app/api/models-config/route.js +1 -1
- package/.next/server/app/api/models-config/runtime/route.js +1 -1
- package/.next/server/app/api/models-config/test/route.js +1 -1
- package/.next/server/app/api/plugins/check/route.js +1 -1
- package/.next/server/app/api/plugins/route.js +1 -1
- package/.next/server/app/api/project-overrides/route.js +1 -0
- package/.next/server/app/api/project-overrides/route.js.nft.json +1 -0
- package/.next/server/app/api/project-overrides/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/project-trust/route.js +1 -1
- package/.next/server/app/api/projects/route.js +1 -1
- package/.next/server/app/api/push/config/route.js +1 -1
- package/.next/server/app/api/push/subscribe/route.js +1 -1
- package/.next/server/app/api/sessions/[id]/auto-name/route.js +2 -2
- package/.next/server/app/api/sessions/[id]/context/route.js +1 -1
- package/.next/server/app/api/sessions/[id]/entries/[entryId]/thinking/route.js +1 -1
- package/.next/server/app/api/sessions/[id]/entries/[entryId]/tool-result-image/route.js +1 -1
- package/.next/server/app/api/sessions/[id]/export/route.js +2 -2
- package/.next/server/app/api/sessions/[id]/outline/route.js +1 -1
- package/.next/server/app/api/sessions/[id]/route.js +1 -1
- package/.next/server/app/api/sessions/[id]/state/route.js +1 -1
- package/.next/server/app/api/sessions/[id]/subagent-usage/route.js +1 -0
- package/.next/server/app/api/sessions/[id]/subagent-usage/route.js.nft.json +1 -0
- package/.next/server/app/api/sessions/[id]/subagent-usage/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/sessions/route.js +1 -1
- package/.next/server/app/api/sessions/search/route.js +1 -1
- package/.next/server/app/api/skills/check/route.js +1 -1
- package/.next/server/app/api/skills/check/route.js.nft.json +1 -1
- package/.next/server/app/api/skills/install/route.js +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/skills/search/route.js +1 -1
- package/.next/server/app/api/skills/update/route.js +1 -1
- package/.next/server/app/api/skills/update/route.js.nft.json +1 -1
- package/.next/server/app/api/subagents/[id]/route.js +1 -1
- package/.next/server/app/api/subagents/profiles/route.js +1 -1
- package/.next/server/app/api/subagents/settings/route.js +1 -1
- package/.next/server/app/api/terminal/[id]/events/route.js +1 -1
- package/.next/server/app/api/terminal/[id]/route.js +1 -1
- package/.next/server/app/api/terminal/route.js +1 -1
- package/.next/server/app/api/tools/settings/route.js +1 -1
- package/.next/server/app/api/usage/route.js +1 -1
- package/.next/server/app/api/web-auth/route.js +1 -1
- package/.next/server/app/api/worktrees/route.js +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +7 -7
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +7 -7
- package/.next/server/app/index.segments/_full.segment.rsc +7 -7
- package/.next/server/app/index.segments/_tree.segment.rsc +4 -4
- package/.next/server/app/login/page.js +2 -2
- 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 +5 -5
- package/.next/server/app/login.segments/_full.segment.rsc +5 -5
- package/.next/server/app/login.segments/_tree.segment.rsc +3 -3
- package/.next/server/app/login.segments/login/__PAGE__.segment.rsc +5 -5
- package/.next/server/app/manifest.webmanifest/route.js +2 -2
- package/.next/server/app/page.js +23 -22
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +13 -11
- package/.next/server/chunks/2243.js +1 -1
- package/.next/server/chunks/402.js +3 -2
- package/.next/server/chunks/4020.js +1 -0
- package/.next/server/chunks/6429.js +8 -6
- package/.next/server/chunks/7147.js +1 -1
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/middleware.js +4 -4
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/static/6f_3UIpNmHjU9Xn8SsAAi/_buildManifest.js +1 -0
- package/.next/static/chunks/2981-5abf1fdfdb963718.js +1 -0
- package/.next/static/chunks/app/_global-error/page-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/agent/[id]/bash-output/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/agent/[id]/events/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/agent/[id]/lease/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/agent/[id]/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/agent/new/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/agent/running/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/app-update/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/auth/api-key/[provider]/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/auth/login/[provider]/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/auth/logout/[provider]/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/auth/providers/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/cwd/browse/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/cwd/validate/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/default-cwd/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/file-index/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/files/[...path]/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/git/diff/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/git/status/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/home/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/image-generation/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/image-generation/settings/connections/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/image-generation/settings/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/models/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/models-config/catalog/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/models-config/discover/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/models-config/picker/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/models-config/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/models-config/runtime/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/models-config/test/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/plugins/check/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/plugins/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/project-overrides/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/project-trust/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/projects/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/push/config/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/push/subscribe/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/auto-name/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/context/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/entries/[entryId]/thinking/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/entries/[entryId]/tool-result-image/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/export/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/outline/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/state/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/subagent-usage/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/sessions/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/sessions/search/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/skills/check/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/skills/install/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/skills/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/skills/search/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/skills/update/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/subagents/[id]/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/subagents/profiles/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/subagents/settings/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/terminal/[id]/events/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/terminal/[id]/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/terminal/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/tools/settings/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/usage/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/web-auth/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/api/worktrees/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/{layout-abd03353f2b87156.js → layout-2c4104276f105978.js} +1 -1
- package/.next/static/chunks/app/manifest.webmanifest/route-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/app/page-8a658c191630cbd4.js +213 -0
- package/.next/static/chunks/next/dist/client/components/builtin/app-error-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/forbidden-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/not-found-be5d61c3d2d00f10.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-be5d61c3d2d00f10.js +1 -0
- package/.next/static/css/{f6c5c5c31909d266.css → 90f551ecf6f7f552.css} +1 -1
- package/.next/static/css/{1a6a041bd877a737.css → cdd9ca136f3e707d.css} +1 -1
- package/.next/static/css/eae95890104af950.css +1 -0
- package/.next/trace +9 -42
- package/.next/trace-build +1 -1
- package/.next/types/app/api/project-overrides/route.ts +353 -0
- package/.next/types/app/api/sessions/[id]/subagent-usage/route.ts +353 -0
- package/.next/types/routes.d.ts +3 -1
- package/.next/types/validator.ts +18 -0
- package/package.json +1 -1
- package/.next/static/JdASme3vlmmcq3bfLK3dJ/_buildManifest.js +0 -1
- package/.next/static/chunks/2981-3cdf8a2b6a7acda7.js +0 -1
- package/.next/static/chunks/app/_global-error/page-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/agent/[id]/bash-output/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/agent/[id]/events/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/agent/[id]/lease/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/agent/[id]/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/agent/new/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/agent/running/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/app-update/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/auth/api-key/[provider]/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/auth/login/[provider]/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/auth/logout/[provider]/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/auth/providers/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/cwd/browse/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/cwd/validate/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/default-cwd/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/file-index/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/files/[...path]/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/git/diff/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/git/status/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/home/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/image-generation/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/image-generation/settings/connections/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/image-generation/settings/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/models/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/models-config/catalog/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/models-config/discover/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/models-config/picker/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/models-config/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/models-config/runtime/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/models-config/test/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/plugins/check/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/plugins/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/project-trust/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/projects/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/push/config/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/push/subscribe/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/sessions/[id]/auto-name/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/sessions/[id]/context/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/sessions/[id]/entries/[entryId]/thinking/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/sessions/[id]/entries/[entryId]/tool-result-image/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/sessions/[id]/export/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/sessions/[id]/outline/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/sessions/[id]/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/sessions/[id]/state/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/sessions/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/sessions/search/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/skills/check/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/skills/install/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/skills/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/skills/search/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/skills/update/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/subagents/[id]/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/subagents/profiles/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/subagents/settings/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/terminal/[id]/events/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/terminal/[id]/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/terminal/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/tools/settings/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/usage/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/web-auth/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/api/worktrees/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/manifest.webmanifest/route-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/app/page-3c870fe5f7505e28.js +0 -212
- package/.next/static/chunks/next/dist/client/components/builtin/app-error-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/forbidden-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/not-found-65c0cd7526c36b6b.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-65c0cd7526c36b6b.js +0 -1
- package/.next/static/css/b121d2362092b3ab.css +0 -1
- /package/.next/static/{JdASme3vlmmcq3bfLK3dJ → 6f_3UIpNmHjU9Xn8SsAAi}/_ssgManifest.js +0 -0
|
@@ -51,6 +51,6 @@
|
|
|
51
51
|
}
|
|
52
52
|
containsActive.set(node, has);
|
|
53
53
|
}
|
|
54
|
-
}`));return new Response(c,{headers:{"Content-Type":"text/html; charset=utf-8","Content-Disposition":q(p,f),"Cache-Control":"no-cache","Content-Security-Policy":"frame-ancestors 'none'","X-Content-Type-Options":"nosniff","X-Frame-Options":"DENY"}})}finally{(0,g.rmSync)(r,{force:!0})}}catch(a){return l.NextResponse.json({error:String(a)},{status:500})}}d()}catch(a){d(a)}})},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},51455:a=>{"use strict";a.exports=require("node:fs/promises")},55511:a=>{"use strict";a.exports=require("crypto")},
|
|
54
|
+
}`));return new Response(c,{headers:{"Content-Type":"text/html; charset=utf-8","Content-Disposition":q(p,f),"Cache-Control":"no-cache","Content-Security-Policy":"frame-ancestors 'none'","X-Content-Type-Options":"nosniff","X-Frame-Options":"DENY"}})}finally{(0,g.rmSync)(r,{force:!0})}}catch(a){return l.NextResponse.json({error:String(a)},{status:500})}}d()}catch(a){d(a)}})},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},51455:a=>{"use strict";a.exports=require("node:fs/promises")},55511:a=>{"use strict";a.exports=require("crypto")},62533:(a,b,c)=>{"use strict";c.d(b,{Yh:()=>f});let d="[image]",e=/^\s*(`{3,}|~{3,})/;function f(a,b={}){var c;let k,l=function(a,b){if(0===a.length)return[];let c=new Map(a.map(a=>[a.id,a])),d=(b?c.get(b):void 0)??a.at(-1),e=[];for(;d;)e.push(d),d=d.parentId?c.get(d.parentId):void 0;return e.reverse(),e}(a,b.leafId),m=function(a){let b=[],c=null;for(let f of a){if("message"!==f.type)continue;let a=f.message?.role;if("user"===a){let a=i(f.message?.content);c={title:function(a){for(let b of j(a).split("\n")){let a=b.trim();if(!a||a===d||e.test(b)||/^([-*>]|\d+[.)])$/.test(a))continue;let c=a.replace(/^#{1,6}\s+/,"").replace(/^[-*>]\s+/,"").replace(/^\d+[.)]\s+/,"");if(c=c.replace(/[`*_]/g,"").replace(/\s+/g," ").trim())return c.length>44?`${c.slice(0,44)}…`:c}return a.includes(d)?"image":"Untitled"}(a),question:a,answer:""},b.push(c);continue}if("assistant"!==a||!c)continue;let g=i(f.message?.content);g.trim()&&(c.answer=c.answer?`${c.answer}
|
|
55
55
|
|
|
56
|
-
${g}`:g)}return b.filter(a=>a.answer.trim())}(l);if(0===m.length)return{ok:!1,error:"empty"};let n=b.exportedAt??new Date,o=function(a){if("number"!=typeof a||!Number.isFinite(a))return null;let b=Math.round(a);return 1440>=Math.abs(b)?b:null}(b.timezoneOffsetMinutes),p=b.title?.trim()||function(a){let b;for(let c of a)"session_info"===c.type&&"string"==typeof c.name&&c.name.trim()&&(b=c.name.trim());return b}(a)||m[0].title||"session",q=j([(c={title:p,exportedAt:n,timezoneOffsetMinutes:o,model:function(a){for(let b=a.length-1;b>=0;b-=1){let c=a[b];if("message"!==c.type||c.message?.role!=="assistant")continue;let d="string"==typeof c.message.model?c.message.model:"";if(!d)continue;let e="string"==typeof c.message.provider?c.message.provider:"";return e?`${e}/${d}`:d}return""}(l),turns:m.length},k=["---",`title: ${g(c.title)}`,`date: ${function(a,b){let c=h(a,b).toISOString().replace(/\.\d{3}Z$/,"");if(null===b)return`${c}Z`;let d=b<0?"-":"+",e=Math.abs(b),f=String(Math.floor(e/60)).padStart(2,"0"),g=String(e%60).padStart(2,"0");return`${c}${d}${f}:${g}`}(c.exportedAt,c.timezoneOffsetMinutes)}`],c.model&&k.push(`model: ${g(c.model)}`),k.push(`turns: ${c.turns}`,"---"),k.join("\n")),"",`# ${p}`,"",m.map((a,b)=>{var c,d;let f,g;return c=a,d=b+1,f=[`## ${d}. ${c.title}`,""],(g=j(c.question))&&g!==c.title&&f.push(g.split("\n").map(a=>a.trim()?`> ${a}`:">").join("\n"),""),f.push(function(a,b=2){let c,d=j(a).split("\n"),f=7,g=!1;for(let a of d){let b=e.exec(a);if(b){let a=b[1][0];g?a===c&&(g=!1,c=void 0):(g=!0,c=a);continue}if(g)continue;let d=/^(#{1,6})(\s+.*)$/.exec(a);d&&(f=Math.min(f,d[1].length))}if(7===f)return a;let h=Math.min(6,b+1),i=[];for(let a of(g=!1,c=void 0,d)){let b=e.exec(a);if(b){let d=b[1][0];g?d===c&&(g=!1,c=void 0):(g=!0,c=d),i.push(a);continue}if(g){i.push(a);continue}let d=/^(#{1,6})(\s+.*)$/.exec(a);if(!d){i.push(a);continue}let j=Math.min(6,h+d[1].length-f);i.push(`${"#".repeat(j)}${d[2]}`)}return i.join("\n")}(c.answer,2)),f.join("\n")}).join("\n\n")].join("\n"))+"\n",r=h(n,o).toISOString().slice(0,10);return{ok:!0,markdown:q,fileName:`${r}_${function(a,b=60){return a.replace(/[/\\:*?"<>|]/g,"").replace(/\s+/g," ").trim().replace(/ /g,"_").slice(0,b)||"session"}(p)}.md`,title:p,turns:m.length}}function g(a){let b=a.replace(/\s+/g," ").trim();return`'${b.replace(/'/g,"''")}'`}function h(a,b){return null===b?a:new Date(a.getTime()+6e4*b)}function i(a){if("string"==typeof a)return a;if(!Array.isArray(a))return"";let b=[];for(let c of a){if(!c||"object"!=typeof c)continue;let a="type"in c?c.type:void 0;"text"===a&&"text"in c&&"string"==typeof c.text?b.push(c.text):"image"===a&&b.push(d)}return b.join("\n\n")}function j(a){let b,c=a.replace(/\r\n/g,"\n").replace(/\r/g,"\n").split("\n"),d=[],f=!1,g=!1;for(let a of c){let c=e.exec(a);if(c){let e=c[1][0];g?e===b&&(g=!1,b=void 0):(g=!0,b=e),d.push(a),f=!1;continue}if(g){d.push(a);continue}if(!a.trim()){if(f)continue;f=!0,d.push(a);continue}f=!1,d.push(a)}return d.join("\n").trim()}},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},73024:a=>{"use strict";a.exports=require("node:fs")},75430:a=>{"use strict";a.exports=import("@earendil-works/pi-coding-agent")},76760:a=>{"use strict";a.exports=require("node:path")},78335:()=>{},79405:a=>{function b(a){return Promise.resolve().then(()=>{var b=Error("Cannot find module '"+a+"'");throw b.code="MODULE_NOT_FOUND",b})}b.keys=()=>[],b.resolve=b,b.id=79405,a.exports=b},79646:a=>{"use strict";a.exports=require("child_process")},79748:a=>{"use strict";a.exports=require("fs/promises")},80481:a=>{"use strict";a.exports=require("node:readline")},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},96487:()=>{}};var b=require("../../../../../webpack-runtime.js");b.C(a);var c=b.X(0,[4741,1813,426,402],()=>b(b.s=56815));module.exports=c})();
|
|
56
|
+
${g}`:g)}return b.filter(a=>a.answer.trim())}(l);if(0===m.length)return{ok:!1,error:"empty"};let n=b.exportedAt??new Date,o=function(a){if("number"!=typeof a||!Number.isFinite(a))return null;let b=Math.round(a);return 1440>=Math.abs(b)?b:null}(b.timezoneOffsetMinutes),p=b.title?.trim()||function(a){let b;for(let c of a)"session_info"===c.type&&"string"==typeof c.name&&c.name.trim()&&(b=c.name.trim());return b}(a)||m[0].title||"session",q=j([(c={title:p,exportedAt:n,timezoneOffsetMinutes:o,model:function(a){for(let b=a.length-1;b>=0;b-=1){let c=a[b];if("message"!==c.type||c.message?.role!=="assistant")continue;let d="string"==typeof c.message.model?c.message.model:"";if(!d)continue;let e="string"==typeof c.message.provider?c.message.provider:"";return e?`${e}/${d}`:d}return""}(l),turns:m.length},k=["---",`title: ${g(c.title)}`,`date: ${function(a,b){let c=h(a,b).toISOString().replace(/\.\d{3}Z$/,"");if(null===b)return`${c}Z`;let d=b<0?"-":"+",e=Math.abs(b),f=String(Math.floor(e/60)).padStart(2,"0"),g=String(e%60).padStart(2,"0");return`${c}${d}${f}:${g}`}(c.exportedAt,c.timezoneOffsetMinutes)}`],c.model&&k.push(`model: ${g(c.model)}`),k.push(`turns: ${c.turns}`,"---"),k.join("\n")),"",`# ${p}`,"",m.map((a,b)=>{var c,d;let f,g;return c=a,d=b+1,f=[`## ${d}. ${c.title}`,""],(g=j(c.question))&&g!==c.title&&f.push(g.split("\n").map(a=>a.trim()?`> ${a}`:">").join("\n"),""),f.push(function(a,b=2){let c,d=j(a).split("\n"),f=7,g=!1;for(let a of d){let b=e.exec(a);if(b){let a=b[1][0];g?a===c&&(g=!1,c=void 0):(g=!0,c=a);continue}if(g)continue;let d=/^(#{1,6})(\s+.*)$/.exec(a);d&&(f=Math.min(f,d[1].length))}if(7===f)return a;let h=Math.min(6,b+1),i=[];for(let a of(g=!1,c=void 0,d)){let b=e.exec(a);if(b){let d=b[1][0];g?d===c&&(g=!1,c=void 0):(g=!0,c=d),i.push(a);continue}if(g){i.push(a);continue}let d=/^(#{1,6})(\s+.*)$/.exec(a);if(!d){i.push(a);continue}let j=Math.min(6,h+d[1].length-f);i.push(`${"#".repeat(j)}${d[2]}`)}return i.join("\n")}(c.answer,2)),f.join("\n")}).join("\n\n")].join("\n"))+"\n",r=h(n,o).toISOString().slice(0,10);return{ok:!0,markdown:q,fileName:`${r}_${function(a,b=60){return a.replace(/[/\\:*?"<>|]/g,"").replace(/\s+/g," ").trim().replace(/ /g,"_").slice(0,b)||"session"}(p)}.md`,title:p,turns:m.length}}function g(a){let b=a.replace(/\s+/g," ").trim();return`'${b.replace(/'/g,"''")}'`}function h(a,b){return null===b?a:new Date(a.getTime()+6e4*b)}function i(a){if("string"==typeof a)return a;if(!Array.isArray(a))return"";let b=[];for(let c of a){if(!c||"object"!=typeof c)continue;let a="type"in c?c.type:void 0;"text"===a&&"text"in c&&"string"==typeof c.text?b.push(c.text):"image"===a&&b.push(d)}return b.join("\n\n")}function j(a){let b,c=a.replace(/\r\n/g,"\n").replace(/\r/g,"\n").split("\n"),d=[],f=!1,g=!1;for(let a of c){let c=e.exec(a);if(c){let e=c[1][0];g?e===b&&(g=!1,b=void 0):(g=!0,b=e),d.push(a),f=!1;continue}if(g){d.push(a);continue}if(!a.trim()){if(f)continue;f=!0,d.push(a);continue}f=!1,d.push(a)}return d.join("\n").trim()}},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},73024:a=>{"use strict";a.exports=require("node:fs")},75430:a=>{"use strict";a.exports=import("@earendil-works/pi-coding-agent")},76760:a=>{"use strict";a.exports=require("node:path")},78335:()=>{},79405:a=>{function b(a){return Promise.resolve().then(()=>{var b=Error("Cannot find module '"+a+"'");throw b.code="MODULE_NOT_FOUND",b})}b.keys=()=>[],b.resolve=b,b.id=79405,a.exports=b},79646:a=>{"use strict";a.exports=require("child_process")},79748:a=>{"use strict";a.exports=require("fs/promises")},80481:a=>{"use strict";a.exports=require("node:readline")},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},96487:()=>{},99605:(a,b,c)=>{"use strict";c.r(b),c.d(b,{handler:()=>z,patchFetch:()=>y,routeModule:()=>u,serverHooks:()=>x,workAsyncStorage:()=>v,workUnitAsyncStorage:()=>w});var d=c(19225),e=c(84006),f=c(8317),g=c(99373),h=c(34775),i=c(24235),j=c(261),k=c(54365),l=c(90771),m=c(73461),n=c(67798),o=c(92280),p=c(62018),q=c(45696),r=c(47929),s=c(86439),t=c(37527);let u=new d.AppRouteRouteModule({definition:{kind:e.RouteKind.APP_ROUTE,page:"/api/sessions/[id]/export/route",pathname:"/api/sessions/[id]/export",filename:"route",bundlePath:"app/api/sessions/[id]/export/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/zhujunshen/pi-web/app/api/sessions/[id]/export/route.ts",nextConfigOutput:"",userland:()=>c(39421),...{}}),{workAsyncStorage:v,workUnitAsyncStorage:w,serverHooks:x}=u;function y(){return(0,f.patchFetch)({workAsyncStorage:v,workUnitAsyncStorage:w})}async function z(a,b,c){c.requestMeta&&(0,g.setRequestMeta)(a,c.requestMeta),u.isDev&&(0,g.addRequestMeta)(a,"devRequestTimingInternalsEnd",process.hrtime.bigint());let d="/api/sessions/[id]/export/route";"/index"===d&&(d="/");let f=await u.prepare(a,b,{srcPage:d,multiZoneDraftMode:!1});if(!f)return b.statusCode=400,b.end("Bad Request"),null==c.waitUntil||c.waitUntil.call(c,Promise.resolve()),null;let{buildId:v,deploymentId:w,params:x,nextConfig:y,parsedUrl:z,isDraftMode:A,prerenderManifest:B,routerServerContext:C,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,resolvedPathname:F,clientReferenceManifest:G,serverActionsManifest:H}=f,I=(0,j.normalizeAppPath)(d),J=!!(B.dynamicRoutes[I]||B.routes[F]),K=async()=>((null==C?void 0:C.render404)?await C.render404(a,b,z,!1):b.end("This page could not be found"),null);if(J&&!A){let a=!!B.routes[F],b=B.dynamicRoutes[I];if(b&&!1===b.fallback&&!a){if(y.adapterPath)return await K();throw new s.NoFallbackError}}let L=null;!J||u.isDev||A||(L="/index"===(L=F)?"/":L);let M=!0===u.isDev||!J,N=J&&!M;H&&G&&(0,i.setManifestsSingleton)({page:d,clientReferenceManifest:G,serverActionsManifest:H});let O=a.method||"GET",P=(0,h.getTracer)(),Q=P.getActiveScopeSpan(),R=!!(null==C?void 0:C.isWrappedByNextServer),S=!!(0,g.getRequestMeta)(a,"minimalMode"),T=(0,g.getRequestMeta)(a,"incrementalCache")||await u.getIncrementalCache(a,y,B,S);null==T||T.resetRequestCache(),globalThis.__incrementalCache=T;let U={params:x,previewProps:B.preview,renderOpts:{experimental:{authInterrupts:!!y.experimental.authInterrupts,useCacheTimeout:y.experimental.useCacheTimeout},cacheComponents:!!y.cacheComponents,validationLevel:y.experimental.instantInsights.validationLevel,supportsDynamicResponse:M,incrementalCache:T,hmrRefreshHash:(0,g.getRequestMeta)(a,"hmrRefreshHash"),cacheLifeProfiles:y.cacheLife,staticPageGenerationTimeout:y.staticPageGenerationTimeout,waitUntil:c.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:void 0,onInstrumentationRequestError:(b,c,d,e)=>u.onRequestError(a,b,d,e,C)},sharedContext:{buildId:v,deploymentId:w}},V=new k.NodeNextRequest(a),W=new k.NodeNextResponse(b),X=l.NextRequestAdapter.fromNodeNextRequest(V,(0,l.signalFromNodeResponse)(b)),Y=async({previousCacheEntry:e})=>{try{if(!S&&D&&E&&!e)return b.statusCode=404,b.setHeader("x-nextjs-cache","REVALIDATED"),b.end("This page could not be found"),null;let d=await u.handle(X,U);a.fetchMetrics=U.renderOpts.fetchMetrics;let f=U.renderOpts.pendingWaitUntil;f&&c.waitUntil&&(c.waitUntil(f),f=void 0);let g=U.renderOpts.collectedTags;if(!J)return await (0,o.I)(V,W,d,f),null;{let a=await d.blob(),b=(0,p.toNodeOutgoingHttpHeaders)(d.headers);g&&(b[r.NEXT_CACHE_TAGS_HEADER]=g),!b["content-type"]&&a.type&&(b["content-type"]=a.type);let c=void 0!==U.renderOpts.collectedRevalidate&&!(U.renderOpts.collectedRevalidate>=r.INFINITE_CACHE)&&U.renderOpts.collectedRevalidate,e=void 0===U.renderOpts.collectedExpire||U.renderOpts.collectedExpire>=r.INFINITE_CACHE?!1!==c&&c>0?y.expireTime:void 0:U.renderOpts.collectedExpire;return{value:{kind:t.CachedRouteKind.APP_ROUTE,status:d.status,body:Buffer.from(await a.arrayBuffer()),headers:b},cacheControl:{revalidate:c,expire:e}}}}catch(b){throw(null==e?void 0:e.isStale)&&await u.onRequestError(a,b,{routerKind:"App Router",routePath:d,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),b}},Z=async(d,f)=>{try{var g,i;let d=await u.handleResponse({req:a,nextConfig:y,cacheKey:L,routeKind:e.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:B,isRoutePPREnabled:!1,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,responseGenerator:Y,waitUntil:c.waitUntil,isMinimalMode:S});if(!J)return;if((null==d||null==(g=d.value)?void 0:g.kind)!==t.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==d||null==(i=d.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});S||b.setHeader("x-nextjs-cache",D?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),A&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let f=(0,p.fromNodeOutgoingHttpHeaders)(d.value.headers);S&&J||f.delete(r.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||b.getHeader("Cache-Control")||f.get("Cache-Control")||f.set("Cache-Control",(0,q.getCacheControlHeader)(d.cacheControl)),await (0,o.I)(V,W,new Response(d.value.body,{headers:f,status:d.value.status||200}));return}catch(b){if(b instanceof s.NoFallbackError||await u.onRequestError(a,b,{routerKind:"App Router",routePath:I,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),J)throw b;await (0,o.I)(V,W,new Response(null,{status:500}));return}finally{(()=>{if(!d)return;let a=b.statusCode;d.setAttributes({"http.status_code":a,"next.rsc":!1}),a&&a>=500&&(d.setStatus({code:h.SpanStatusCode.ERROR}),d.setAttribute("error.type",a.toString()));let c=P.getRootSpanAttributes();if(!c)return;if(c.get("next.span_type")!==m.BaseServerSpan.handleRequest)return console.warn(`Unexpected root span type '${c.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let e=c.get("next.route")||I,g=`${O} ${e}`;d.setAttributes({"next.route":e,"http.route":e,"next.span_name":g}),d.updateName(g),f&&f!==d&&(f.setAttribute("http.route",e),f.updateName(g))})()}};if(R&&Q)await Z(Q,void 0);else{let b=P.getActiveScopeSpan();await P.withPropagatedContext(a.headers,()=>P.trace(m.BaseServerSpan.handleRequest,{spanName:`${O} ${d}`,kind:h.SpanKind.SERVER,attributes:{"http.method":O,"http.target":a.url}},a=>Z(a,b)),void 0,!R)}}}};var b=require("../../../../../webpack-runtime.js");b.C(a);var c=b.X(0,[4741,1813,426,402],()=>b(b.s=99605));module.exports=c})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var a={};a.id=8390,a.ids=[8390],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},1932:a=>{"use strict";a.exports=require("url")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},4573:a=>{"use strict";a.exports=require("node:buffer")},8128:a=>{"use strict";a.exports=require("next/dist/server/runtime-reacts.external.js")},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},12412:a=>{"use strict";a.exports=require("assert")},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},27910:a=>{"use strict";a.exports=require("stream")},28354:a=>{"use strict";a.exports=require("util")},28802:a=>{"use strict";a.exports=import("@earendil-works/pi-ai")},29021:a=>{"use strict";a.exports=require("fs")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},29862:a=>{"use strict";a.exports=import("@earendil-works/pi-tui")},31421:a=>{"use strict";a.exports=require("node:child_process")},33873:a=>{"use strict";a.exports=require("path")},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},48161:a=>{"use strict";a.exports=require("node:os")},51181:a=>{"use strict";a.exports=require("web-push")},51455:a=>{"use strict";a.exports=require("node:fs/promises")},55511:a=>{"use strict";a.exports=require("crypto")},57975:a=>{"use strict";a.exports=require("node:util")},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},64317:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{GET:()=>j});var e=c(23211),f=c(75430),g=c(40402),h=c(56429),i=a([f,g,h]);async function j(a,{params:b}){let{id:c}=await b,d=new URL(a.url).searchParams.get("leafId")??void 0;try{let a=(0,h.getRpcSession)(c),b=a?.isAlive()?a:void 0,i=b?null:await (0,g.os)(c);if(!b&&!i)return e.NextResponse.json({error:"Session not found"},{status:404});let j=b?.inner.sessionManager??f.SessionManager.open(i),k=(0,g.jH)(j.getEntries(),d??j.getLeafId());return e.NextResponse.json({items:k})}catch(a){return e.NextResponse.json({error:String(a)},{status:500})}}[f,g,h]=i.then?(await i)():i,d()}catch(a){d(a)}})},72322:a=>{"use strict";a.exports=import("@earendil-works/pi-ai/utils/pi-user-agent")},73024:a=>{"use strict";a.exports=require("node:fs")},75430:a=>{"use strict";a.exports=import("@earendil-works/pi-coding-agent")},76760:a=>{"use strict";a.exports=require("node:path")},77598:a=>{"use strict";a.exports=require("node:crypto")},78335:()=>{},79646:a=>{"use strict";a.exports=require("child_process")},79748:a=>{"use strict";a.exports=require("fs/promises")},80481:a=>{"use strict";a.exports=require("node:readline")},81115:a=>{"use strict";a.exports=require("constants")},
|
|
1
|
+
(()=>{var a={};a.id=8390,a.ids=[8390],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},1932:a=>{"use strict";a.exports=require("url")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},4573:a=>{"use strict";a.exports=require("node:buffer")},8128:a=>{"use strict";a.exports=require("next/dist/server/runtime-reacts.external.js")},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},12412:a=>{"use strict";a.exports=require("assert")},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},27910:a=>{"use strict";a.exports=require("stream")},28354:a=>{"use strict";a.exports=require("util")},28802:a=>{"use strict";a.exports=import("@earendil-works/pi-ai")},29021:a=>{"use strict";a.exports=require("fs")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},29862:a=>{"use strict";a.exports=import("@earendil-works/pi-tui")},31421:a=>{"use strict";a.exports=require("node:child_process")},33873:a=>{"use strict";a.exports=require("path")},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},48161:a=>{"use strict";a.exports=require("node:os")},51181:a=>{"use strict";a.exports=require("web-push")},51455:a=>{"use strict";a.exports=require("node:fs/promises")},55511:a=>{"use strict";a.exports=require("crypto")},57975:a=>{"use strict";a.exports=require("node:util")},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},64317:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{GET:()=>j});var e=c(23211),f=c(75430),g=c(40402),h=c(56429),i=a([f,g,h]);async function j(a,{params:b}){let{id:c}=await b,d=new URL(a.url).searchParams.get("leafId")??void 0;try{let a=(0,h.getRpcSession)(c),b=a?.isAlive()?a:void 0,i=b?null:await (0,g.os)(c);if(!b&&!i)return e.NextResponse.json({error:"Session not found"},{status:404});let j=b?.inner.sessionManager??f.SessionManager.open(i),k=(0,g.jH)(j.getEntries(),d??j.getLeafId());return e.NextResponse.json({items:k})}catch(a){return e.NextResponse.json({error:String(a)},{status:500})}}[f,g,h]=i.then?(await i)():i,d()}catch(a){d(a)}})},72322:a=>{"use strict";a.exports=import("@earendil-works/pi-ai/utils/pi-user-agent")},73024:a=>{"use strict";a.exports=require("node:fs")},75430:a=>{"use strict";a.exports=import("@earendil-works/pi-coding-agent")},76760:a=>{"use strict";a.exports=require("node:path")},77598:a=>{"use strict";a.exports=require("node:crypto")},78335:()=>{},79646:a=>{"use strict";a.exports=require("child_process")},79748:a=>{"use strict";a.exports=require("fs/promises")},80481:a=>{"use strict";a.exports=require("node:readline")},81115:a=>{"use strict";a.exports=require("constants")},84411:(a,b,c)=>{"use strict";c.r(b),c.d(b,{handler:()=>z,patchFetch:()=>y,routeModule:()=>u,serverHooks:()=>x,workAsyncStorage:()=>v,workUnitAsyncStorage:()=>w});var d=c(19225),e=c(84006),f=c(8317),g=c(99373),h=c(34775),i=c(24235),j=c(261),k=c(54365),l=c(90771),m=c(73461),n=c(67798),o=c(92280),p=c(62018),q=c(45696),r=c(47929),s=c(86439),t=c(37527);let u=new d.AppRouteRouteModule({definition:{kind:e.RouteKind.APP_ROUTE,page:"/api/sessions/[id]/outline/route",pathname:"/api/sessions/[id]/outline",filename:"route",bundlePath:"app/api/sessions/[id]/outline/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/zhujunshen/pi-web/app/api/sessions/[id]/outline/route.ts",nextConfigOutput:"",userland:()=>c(64317),...{}}),{workAsyncStorage:v,workUnitAsyncStorage:w,serverHooks:x}=u;function y(){return(0,f.patchFetch)({workAsyncStorage:v,workUnitAsyncStorage:w})}async function z(a,b,c){c.requestMeta&&(0,g.setRequestMeta)(a,c.requestMeta),u.isDev&&(0,g.addRequestMeta)(a,"devRequestTimingInternalsEnd",process.hrtime.bigint());let d="/api/sessions/[id]/outline/route";"/index"===d&&(d="/");let f=await u.prepare(a,b,{srcPage:d,multiZoneDraftMode:!1});if(!f)return b.statusCode=400,b.end("Bad Request"),null==c.waitUntil||c.waitUntil.call(c,Promise.resolve()),null;let{buildId:v,deploymentId:w,params:x,nextConfig:y,parsedUrl:z,isDraftMode:A,prerenderManifest:B,routerServerContext:C,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,resolvedPathname:F,clientReferenceManifest:G,serverActionsManifest:H}=f,I=(0,j.normalizeAppPath)(d),J=!!(B.dynamicRoutes[I]||B.routes[F]),K=async()=>((null==C?void 0:C.render404)?await C.render404(a,b,z,!1):b.end("This page could not be found"),null);if(J&&!A){let a=!!B.routes[F],b=B.dynamicRoutes[I];if(b&&!1===b.fallback&&!a){if(y.adapterPath)return await K();throw new s.NoFallbackError}}let L=null;!J||u.isDev||A||(L="/index"===(L=F)?"/":L);let M=!0===u.isDev||!J,N=J&&!M;H&&G&&(0,i.setManifestsSingleton)({page:d,clientReferenceManifest:G,serverActionsManifest:H});let O=a.method||"GET",P=(0,h.getTracer)(),Q=P.getActiveScopeSpan(),R=!!(null==C?void 0:C.isWrappedByNextServer),S=!!(0,g.getRequestMeta)(a,"minimalMode"),T=(0,g.getRequestMeta)(a,"incrementalCache")||await u.getIncrementalCache(a,y,B,S);null==T||T.resetRequestCache(),globalThis.__incrementalCache=T;let U={params:x,previewProps:B.preview,renderOpts:{experimental:{authInterrupts:!!y.experimental.authInterrupts,useCacheTimeout:y.experimental.useCacheTimeout},cacheComponents:!!y.cacheComponents,validationLevel:y.experimental.instantInsights.validationLevel,supportsDynamicResponse:M,incrementalCache:T,hmrRefreshHash:(0,g.getRequestMeta)(a,"hmrRefreshHash"),cacheLifeProfiles:y.cacheLife,staticPageGenerationTimeout:y.staticPageGenerationTimeout,waitUntil:c.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:void 0,onInstrumentationRequestError:(b,c,d,e)=>u.onRequestError(a,b,d,e,C)},sharedContext:{buildId:v,deploymentId:w}},V=new k.NodeNextRequest(a),W=new k.NodeNextResponse(b),X=l.NextRequestAdapter.fromNodeNextRequest(V,(0,l.signalFromNodeResponse)(b)),Y=async({previousCacheEntry:e})=>{try{if(!S&&D&&E&&!e)return b.statusCode=404,b.setHeader("x-nextjs-cache","REVALIDATED"),b.end("This page could not be found"),null;let d=await u.handle(X,U);a.fetchMetrics=U.renderOpts.fetchMetrics;let f=U.renderOpts.pendingWaitUntil;f&&c.waitUntil&&(c.waitUntil(f),f=void 0);let g=U.renderOpts.collectedTags;if(!J)return await (0,o.I)(V,W,d,f),null;{let a=await d.blob(),b=(0,p.toNodeOutgoingHttpHeaders)(d.headers);g&&(b[r.NEXT_CACHE_TAGS_HEADER]=g),!b["content-type"]&&a.type&&(b["content-type"]=a.type);let c=void 0!==U.renderOpts.collectedRevalidate&&!(U.renderOpts.collectedRevalidate>=r.INFINITE_CACHE)&&U.renderOpts.collectedRevalidate,e=void 0===U.renderOpts.collectedExpire||U.renderOpts.collectedExpire>=r.INFINITE_CACHE?!1!==c&&c>0?y.expireTime:void 0:U.renderOpts.collectedExpire;return{value:{kind:t.CachedRouteKind.APP_ROUTE,status:d.status,body:Buffer.from(await a.arrayBuffer()),headers:b},cacheControl:{revalidate:c,expire:e}}}}catch(b){throw(null==e?void 0:e.isStale)&&await u.onRequestError(a,b,{routerKind:"App Router",routePath:d,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),b}},Z=async(d,f)=>{try{var g,i;let d=await u.handleResponse({req:a,nextConfig:y,cacheKey:L,routeKind:e.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:B,isRoutePPREnabled:!1,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,responseGenerator:Y,waitUntil:c.waitUntil,isMinimalMode:S});if(!J)return;if((null==d||null==(g=d.value)?void 0:g.kind)!==t.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==d||null==(i=d.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});S||b.setHeader("x-nextjs-cache",D?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),A&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let f=(0,p.fromNodeOutgoingHttpHeaders)(d.value.headers);S&&J||f.delete(r.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||b.getHeader("Cache-Control")||f.get("Cache-Control")||f.set("Cache-Control",(0,q.getCacheControlHeader)(d.cacheControl)),await (0,o.I)(V,W,new Response(d.value.body,{headers:f,status:d.value.status||200}));return}catch(b){if(b instanceof s.NoFallbackError||await u.onRequestError(a,b,{routerKind:"App Router",routePath:I,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),J)throw b;await (0,o.I)(V,W,new Response(null,{status:500}));return}finally{(()=>{if(!d)return;let a=b.statusCode;d.setAttributes({"http.status_code":a,"next.rsc":!1}),a&&a>=500&&(d.setStatus({code:h.SpanStatusCode.ERROR}),d.setAttribute("error.type",a.toString()));let c=P.getRootSpanAttributes();if(!c)return;if(c.get("next.span_type")!==m.BaseServerSpan.handleRequest)return console.warn(`Unexpected root span type '${c.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let e=c.get("next.route")||I,g=`${O} ${e}`;d.setAttributes({"next.route":e,"http.route":e,"next.span_name":g}),d.updateName(g),f&&f!==d&&(f.setAttribute("http.route",e),f.updateName(g))})()}};if(R&&Q)await Z(Q,void 0);else{let b=P.getActiveScopeSpan();await P.withPropagatedContext(a.headers,()=>P.trace(m.BaseServerSpan.handleRequest,{spanName:`${O} ${d}`,kind:h.SpanKind.SERVER,attributes:{"http.method":O,"http.target":a.url}},a=>Z(a,b)),void 0,!R)}}},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},94735:a=>{"use strict";a.exports=require("events")},96487:()=>{}};var b=require("../../../../../webpack-runtime.js");b.C(a);var c=b.X(0,[4741,1813,426,974,402,6759,2243,6429],()=>b(b.s=84411));module.exports=c})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var a={};a.id=6849,a.ids=[6849],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},1932:a=>{"use strict";a.exports=require("url")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},4573:a=>{"use strict";a.exports=require("node:buffer")},4896:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{a:()=>i});var e=c(75430),f=a([e]);function g(a){return a?"totalTokens"in a&&"number"==typeof a.totalTokens&&a.totalTokens>0?a.totalTokens:(a.input??0)+(a.output??0)+(a.cacheRead??0)+(a.cacheWrite??0):0}async function h(a,b,c){if(!b)return 0;try{let d=c??await (!globalThis.__piStaticModelRuntime&&(globalThis.__piStaticModelRuntime=e.ModelRuntime.create().catch(a=>{throw delete globalThis.__piStaticModelRuntime,a})),globalThis.__piStaticModelRuntime),f=d.getModel(a,b);if(f?.contextWindow&&f.contextWindow>0)return f.contextWindow;let g=d.getModels(),h=g.find(a=>a.id===b&&a.contextWindow>0);if(h?.contextWindow)return h.contextWindow;let i=g.find(a=>(a.id.endsWith(`/${b}`)||b.endsWith(`/${a.id}`))&&a.contextWindow>0);if(i?.contextWindow)return i.contextWindow;let j=b.toLowerCase();if(j.includes("gemini"))return 1048576;if(j.includes("claude-3-7")||j.includes("claude-sonnet-4")||j.includes("claude-opus-4"))return j.includes("opus-4-6")||j.includes("sonnet-4-6")?1e6:2e5;if(j.includes("gpt-4o")||j.includes("o1")||j.includes("o3"))return 128e3;if(j.includes("deepseek"))return 64e3}catch{}return 0}async function i(a,b,c){try{let d;if(Array.isArray(a))if(b){let c=new Map;for(let b of a)"id"in b&&"string"==typeof b.id&&c.set(b.id,b);let e=[],f=b;for(;f;){let a=c.get(f);if(!a)break;e.push(a),f="parentId"in a?a.parentId:void 0}e.reverse(),d=e}else d=a;else d="getBranch"in a&&"function"==typeof a.getBranch?b?a.getBranch(b):a.getBranch():"getEntries"in a&&"function"==typeof a.getEntries?a.getEntries()??[]:[];if(0===d.length)return null;let f=function(a){for(let b=a.length-1;b>=0;b--){let c=a[b];if("model_change"===c.type&&c.modelId)return{provider:c.provider||"",modelId:c.modelId};if("message"===c.type&&"assistant"===c.message.role&&c.message.model)return{provider:c.message.provider||"",modelId:c.message.model}}return null}(d),i=f?await h(f.provider,f.modelId,c):0,j=function(a){for(let b=a.length-1;b>=0;b--)if("compaction"===a[b].type)return a[b];return null}(d);if(j){let a=d.lastIndexOf(j),b=!1;for(let c=d.length-1;c>a;c--){let a=d[c];if("message"===a.type&&"assistant"===a.message.role){let c=a.message.usage;if(c&&g(c)>0){b=!0;break}}}if(!b)return i>0?{tokens:null,contextWindow:i,percent:null}:null}let k=(0,e.getLastAssistantUsage)(d),l=k?g(k):null;if(null===l&&i<=0)return null;let m=null!==l&&i>0?Math.min(100,Math.round(l/i*1e3)/10):null;return{tokens:l,contextWindow:i,percent:m}}catch{return null}}e=(f.then?(await f)():f)[0],d()}catch(a){d(a)}})},6093:(a,b,c)=>{"use strict";c.d(b,{EL:()=>e});let d=a=>String(a).padStart(2,"0"),e=a=>`${a.getFullYear()}-${d(a.getMonth()+1)}-${d(a.getDate())}`},8128:a=>{"use strict";a.exports=require("next/dist/server/runtime-reacts.external.js")},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},12412:a=>{"use strict";a.exports=require("assert")},14858:(a,b,c)=>{"use strict";function d(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}function e(a,b){if("string"!=typeof b||a.length>40)return a;let c=b.replace(/\s+/g," ").trim();if(!c)return a;let d=a?" ":"",e=a+d;if(e.length>=41)return e.slice(0,41);let f=41-e.length;return e+c.slice(0,f)}function f(a){if("message"!==a.type||!d(a.message)||"string"!=typeof a.message.role||"system"===a.message.role)return;let b=a.message.content,c="",f=!1;if("string"==typeof b)c=e(c,b);else if(Array.isArray(b)){for(let a of b)if(d(a)&&("image"===a.type&&(f=!0),"text"===a.type&&(c=e(c,a.text)),c.length>40))break}c.length>40?c=c.slice(0,40)+"…":c||(c=f?"[image]":"assistant"===a.message.role?"[assistant]":"message");let g="user"===a.message.role||"assistant"===a.message.role?a.message.role:void 0;return{...g?{role:g}:{},text:c}}function g(a){let b=new Set,c=new Set(a),d=new Set,e=[...a];for(;e.length>0;){let a=e.pop();if(!d.has(a))for(let f of(d.add(a),(c.has(a)||1!==a.children.length)&&b.add(a),a.children))e.push(f)}let g=(a,b,c)=>({...a,children:[],...b?.length?{compressedEntryIds:b}:{},...c?{branchPreview:c}:{}}),h=a.map(a=>g(a,void 0,f(a.entry))),i=a.map((a,b)=>({source:a,projected:h[b],depth:1})),j=(a,c)=>{let d=[{node:a,compressedEntryIds:[],branchPreview:void 0}],e=new Set;for(;d.length>0;){let{node:a,compressedEntryIds:h,branchPreview:i}=d.pop();if(e.has(a))continue;e.add(a);let j=i??f(a.entry);b.has(a)&&c.children.push(g(a,h,j));for(let c=a.children.length-1;c>=0;c--)d.push({node:a.children[c],compressedEntryIds:b.has(a)?[]:[...h,a.entry.id],branchPreview:b.has(a)?void 0:j})}};for(;i.length>0;){let{source:a,projected:c,depth:d}=i.pop();for(let e of a.children){let a=e;if(d>=200){j(a,c);continue}let h=[],k=f(a.entry);for(;!b.has(a)&&1===a.children.length;)h.push(a.entry.id),a=a.children[0],k??=f(a.entry);if(!b.has(a))continue;let l=g(a,h,k);c.children.push(l),i.push({source:a,projected:l,depth:d+1})}}return h}c.d(b,{y:()=>g})},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},21906:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{CQ:()=>l,GW:()=>n,JS:()=>m});var e=c(55511),f=c(29021),g=c(33873),h=c(45902),i=c(7048),j=c(74313),k=a([i,j]);function l(a){let b=(0,f.readFileSync)(a,"utf8"),c=b.split("\n"),d=c.map(a=>{if(!a.trim())return null;try{return JSON.parse(a)}catch{return null}}),e=d[0];if(e?.type!=="session"||"string"!=typeof e.id)return null;let g=d.slice(1).filter(a=>null!==a);return{path:a,pathKey:(0,h.$)(a),id:e.id,parentPath:"string"==typeof e.parentSession?e.parentSession:void 0,lines:c,entries:g,original:b,isSubagent:!!(0,i.$u)(g,e.id,a)}}function m(a,b,c){let d=[...a.lines],e=JSON.parse(d[0]);if(b?e.parentSession=b:delete e.parentSession,d[0]=JSON.stringify(e),a.isSubagent){if(!b||!c)throw Error("Cannot reparent a subagent without a valid parent session");for(let a=1;a<d.length;a+=1){let e;try{e=JSON.parse(d[a])}catch{continue}"custom"!==e.type||e.customType!==i.tP||"object"!=typeof e.data||null===e.data||Array.isArray(e.data)||(e.data={...e.data,parentSessionId:c,parentSessionPath:b},d[a]=JSON.stringify(e))}}return d.join("\n")}function n(a){try{(0,j.H2)(a)}catch{}let b=[];try{for(let c of a){if(!(0,f.existsSync)(c))continue;let a=(0,g.join)((0,g.dirname)(c),`.${(0,g.basename)(c)}-${(0,e.randomUUID)()}.deleting`);try{(0,f.renameSync)(c,a)}catch(a){if("ENOENT"===a.code)continue;throw a}b.push({original:c,staged:a})}}catch(a){for(let a of b.reverse())try{(0,f.renameSync)(a.staged,a.original)}catch{}throw a}for(let a of b)try{(0,f.unlinkSync)(a.staged)}catch{}}[i,j]=k.then?(await k)():k,d()}catch(a){d(a)}})},27910:a=>{"use strict";a.exports=require("stream")},28354:a=>{"use strict";a.exports=require("util")},28802:a=>{"use strict";a.exports=import("@earendil-works/pi-ai")},29021:a=>{"use strict";a.exports=require("fs")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},29862:a=>{"use strict";a.exports=import("@earendil-works/pi-tui")},31421:a=>{"use strict";a.exports=require("node:child_process")},33873:a=>{"use strict";a.exports=require("path")},33920:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{Zg:()=>k,fi:()=>l});var e=c(29021),f=c(33873),g=c(75430),h=c(8102),i=a([g]);function j(a=(0,g.getAgentDir)()){return(0,f.join)(a,"pi-web","pinned-sessions.json")}function k(a=j()){let b;try{b=(0,e.readFileSync)(a,"utf8")}catch(a){if("ENOENT"===a.code)return[];throw a}let c=JSON.parse(b);return Array.isArray(c)?c.filter(a=>"string"==typeof a):[]}function l(a,b,c=j()){let d=k(c).filter(b=>b!==a);return b&&d.push(a),(0,e.mkdirSync)((0,f.dirname)(c),{recursive:!0}),(0,h.$)(c,JSON.stringify(d)),d}g=(i.then?(await i)():i)[0],d()}catch(a){d(a)}})},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},47207:(a,b,c)=>{"use strict";c.r(b),c.d(b,{handler:()=>z,patchFetch:()=>y,routeModule:()=>u,serverHooks:()=>x,workAsyncStorage:()=>v,workUnitAsyncStorage:()=>w});var d=c(19225),e=c(84006),f=c(8317),g=c(99373),h=c(34775),i=c(24235),j=c(261),k=c(54365),l=c(90771),m=c(73461),n=c(67798),o=c(92280),p=c(62018),q=c(45696),r=c(47929),s=c(86439),t=c(37527);let u=new d.AppRouteRouteModule({definition:{kind:e.RouteKind.APP_ROUTE,page:"/api/sessions/[id]/route",pathname:"/api/sessions/[id]",filename:"route",bundlePath:"app/api/sessions/[id]/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/zhujunshen/pi-web/app/api/sessions/[id]/route.ts",nextConfigOutput:"",userland:()=>c(98192),...{}}),{workAsyncStorage:v,workUnitAsyncStorage:w,serverHooks:x}=u;function y(){return(0,f.patchFetch)({workAsyncStorage:v,workUnitAsyncStorage:w})}async function z(a,b,c){c.requestMeta&&(0,g.setRequestMeta)(a,c.requestMeta),u.isDev&&(0,g.addRequestMeta)(a,"devRequestTimingInternalsEnd",process.hrtime.bigint());let d="/api/sessions/[id]/route";"/index"===d&&(d="/");let f=await u.prepare(a,b,{srcPage:d,multiZoneDraftMode:!1});if(!f)return b.statusCode=400,b.end("Bad Request"),null==c.waitUntil||c.waitUntil.call(c,Promise.resolve()),null;let{buildId:v,deploymentId:w,params:x,nextConfig:y,parsedUrl:z,isDraftMode:A,prerenderManifest:B,routerServerContext:C,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,resolvedPathname:F,clientReferenceManifest:G,serverActionsManifest:H}=f,I=(0,j.normalizeAppPath)(d),J=!!(B.dynamicRoutes[I]||B.routes[F]),K=async()=>((null==C?void 0:C.render404)?await C.render404(a,b,z,!1):b.end("This page could not be found"),null);if(J&&!A){let a=!!B.routes[F],b=B.dynamicRoutes[I];if(b&&!1===b.fallback&&!a){if(y.adapterPath)return await K();throw new s.NoFallbackError}}let L=null;!J||u.isDev||A||(L="/index"===(L=F)?"/":L);let M=!0===u.isDev||!J,N=J&&!M;H&&G&&(0,i.setManifestsSingleton)({page:d,clientReferenceManifest:G,serverActionsManifest:H});let O=a.method||"GET",P=(0,h.getTracer)(),Q=P.getActiveScopeSpan(),R=!!(null==C?void 0:C.isWrappedByNextServer),S=!!(0,g.getRequestMeta)(a,"minimalMode"),T=(0,g.getRequestMeta)(a,"incrementalCache")||await u.getIncrementalCache(a,y,B,S);null==T||T.resetRequestCache(),globalThis.__incrementalCache=T;let U={params:x,previewProps:B.preview,renderOpts:{experimental:{authInterrupts:!!y.experimental.authInterrupts,useCacheTimeout:y.experimental.useCacheTimeout},cacheComponents:!!y.cacheComponents,validationLevel:y.experimental.instantInsights.validationLevel,supportsDynamicResponse:M,incrementalCache:T,hmrRefreshHash:(0,g.getRequestMeta)(a,"hmrRefreshHash"),cacheLifeProfiles:y.cacheLife,staticPageGenerationTimeout:y.staticPageGenerationTimeout,waitUntil:c.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:void 0,onInstrumentationRequestError:(b,c,d,e)=>u.onRequestError(a,b,d,e,C)},sharedContext:{buildId:v,deploymentId:w}},V=new k.NodeNextRequest(a),W=new k.NodeNextResponse(b),X=l.NextRequestAdapter.fromNodeNextRequest(V,(0,l.signalFromNodeResponse)(b)),Y=async({previousCacheEntry:e})=>{try{if(!S&&D&&E&&!e)return b.statusCode=404,b.setHeader("x-nextjs-cache","REVALIDATED"),b.end("This page could not be found"),null;let d=await u.handle(X,U);a.fetchMetrics=U.renderOpts.fetchMetrics;let f=U.renderOpts.pendingWaitUntil;f&&c.waitUntil&&(c.waitUntil(f),f=void 0);let g=U.renderOpts.collectedTags;if(!J)return await (0,o.I)(V,W,d,f),null;{let a=await d.blob(),b=(0,p.toNodeOutgoingHttpHeaders)(d.headers);g&&(b[r.NEXT_CACHE_TAGS_HEADER]=g),!b["content-type"]&&a.type&&(b["content-type"]=a.type);let c=void 0!==U.renderOpts.collectedRevalidate&&!(U.renderOpts.collectedRevalidate>=r.INFINITE_CACHE)&&U.renderOpts.collectedRevalidate,e=void 0===U.renderOpts.collectedExpire||U.renderOpts.collectedExpire>=r.INFINITE_CACHE?!1!==c&&c>0?y.expireTime:void 0:U.renderOpts.collectedExpire;return{value:{kind:t.CachedRouteKind.APP_ROUTE,status:d.status,body:Buffer.from(await a.arrayBuffer()),headers:b},cacheControl:{revalidate:c,expire:e}}}}catch(b){throw(null==e?void 0:e.isStale)&&await u.onRequestError(a,b,{routerKind:"App Router",routePath:d,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),b}},Z=async(d,f)=>{try{var g,i;let d=await u.handleResponse({req:a,nextConfig:y,cacheKey:L,routeKind:e.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:B,isRoutePPREnabled:!1,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,responseGenerator:Y,waitUntil:c.waitUntil,isMinimalMode:S});if(!J)return;if((null==d||null==(g=d.value)?void 0:g.kind)!==t.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==d||null==(i=d.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});S||b.setHeader("x-nextjs-cache",D?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),A&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let f=(0,p.fromNodeOutgoingHttpHeaders)(d.value.headers);S&&J||f.delete(r.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||b.getHeader("Cache-Control")||f.get("Cache-Control")||f.set("Cache-Control",(0,q.getCacheControlHeader)(d.cacheControl)),await (0,o.I)(V,W,new Response(d.value.body,{headers:f,status:d.value.status||200}));return}catch(b){if(b instanceof s.NoFallbackError||await u.onRequestError(a,b,{routerKind:"App Router",routePath:I,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),J)throw b;await (0,o.I)(V,W,new Response(null,{status:500}));return}finally{(()=>{if(!d)return;let a=b.statusCode;d.setAttributes({"http.status_code":a,"next.rsc":!1}),a&&a>=500&&(d.setStatus({code:h.SpanStatusCode.ERROR}),d.setAttribute("error.type",a.toString()));let c=P.getRootSpanAttributes();if(!c)return;if(c.get("next.span_type")!==m.BaseServerSpan.handleRequest)return console.warn(`Unexpected root span type '${c.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let e=c.get("next.route")||I,g=`${O} ${e}`;d.setAttributes({"next.route":e,"http.route":e,"next.span_name":g}),d.updateName(g),f&&f!==d&&(f.setAttribute("http.route",e),f.updateName(g))})()}};if(R&&Q)await Z(Q,void 0);else{let b=P.getActiveScopeSpan();await P.withPropagatedContext(a.headers,()=>P.trace(m.BaseServerSpan.handleRequest,{spanName:`${O} ${d}`,kind:h.SpanKind.SERVER,attributes:{"http.method":O,"http.target":a.url}},a=>Z(a,b)),void 0,!R)}}},48161:a=>{"use strict";a.exports=require("node:os")},51181:a=>{"use strict";a.exports=require("web-push")},51455:a=>{"use strict";a.exports=require("node:fs/promises")},55511:a=>{"use strict";a.exports=require("crypto")},57975:a=>{"use strict";a.exports=require("node:util")},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},72322:a=>{"use strict";a.exports=import("@earendil-works/pi-ai/utils/pi-user-agent")},73024:a=>{"use strict";a.exports=require("node:fs")},74313:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{H2:()=>w,O6:()=>n,o7:()=>v,xh:()=>u});var e=c(29021),f=c(79748),g=c(33873),h=c(75430),i=c(8102),j=c(45902),k=c(6093),l=a([h]);function m(a){let b,c=a.split("\n");try{b=JSON.parse(c[0])}catch{return{cwd:"",rows:[]}}let d="string"==typeof b.cwd?b.cwd:"",e=Date.parse(b.timestamp??"");if(!Number.isFinite(e))return{cwd:d,rows:[]};let f=new Map;for(let a of c){let b;if(!a.includes('"usage"'))continue;try{b=JSON.parse(a)}catch{continue}let c=b.message,d=c?.usage;if(c?.role!=="assistant"||!d)continue;let g="number"==typeof c.timestamp?c.timestamp:Date.parse(b.timestamp??"");if(!Number.isFinite(g)||g<e)continue;let h=new Date(g),i=(0,k.EL)(h),j=h.getHours(),l=String(c.provider??""),m=String(c.model??""),n=`${i}\0${j}\0${l}\0${m}`,o=f.get(n);o||(o={day:i,hour:j,provider:l,model:m,messages:0,input:0,output:0,cacheRead:0,cacheWrite:0,recordedCost:0},f.set(n,o)),o.messages+=1,o.input+=d.input??0,o.output+=d.output??0,o.cacheRead+=d.cacheRead??0,o.cacheWrite+=d.cacheWrite??0,o.recordedCost+=d.cost?.total??0}return{cwd:d,rows:[...f.values()]}}function n(a,b,c){let d=new Map,e=new Map;for(let f of a){let a=c(f.cwd);for(let c of f.rows){let f=`${c.provider}\0${c.model}`;d.has(f)||d.set(f,b(c.provider,c.model));let g=d.get(f),h=c.hour??null,i=c.model.slice(c.model.lastIndexOf("/")+1),j=`${c.day}\0${h}\0${i}\0${a}`,k=e.get(j);k||(k={day:c.day,hour:h,model:i,project:a,messages:0,input:0,output:0,cacheRead:0,cacheWrite:0,cost:0,unpriced:0},e.set(j,k)),k.messages+=c.messages,k.input+=c.input,k.output+=c.output,k.cacheRead+=c.cacheRead,k.cacheWrite+=c.cacheWrite,k.cost+=g?(c.input*g.input+c.output*g.output+c.cacheRead*g.cacheRead+c.cacheWrite*g.cacheWrite)/1e6:c.recordedCost,g||0!==c.recordedCost||(k.unpriced+=c.messages)}}return[...e.values()]}function o(){return(0,g.join)((0,h.getAgentDir)(),"pi-web-usage-cache.json")}function p(){try{let a=JSON.parse((0,e.readFileSync)(o(),"utf8"));if(!a.files)return new Map;if(2===a.version)return new Map(Object.entries(a.files));if(1===a.version)return new Map(Object.entries(a.files).map(([a,{size:b,mtimeMs:c,rows:d}])=>[a,{size:b,mtimeMs:c,rows:d}]))}catch{}return new Map}function q(){return globalThis.__piUsageCache??=p()}function r(a){for(let[b,c]of p())a.has(b)||a.set(b,c);(0,i.$)(o(),JSON.stringify({version:2,files:Object.fromEntries(a)}))}h=(l.then?(await l)():l)[0];let x=(a,b,c)=>void 0!==a&&void 0!==a.cwd&&a.size===b&&a.mtimeMs===c;async function s(){let a=(0,g.join)((0,h.getAgentDir)(),"sessions");try{return(await (0,f.readdir)(a,{recursive:!0})).filter(a=>a.endsWith(".jsonl")).map(b=>(0,g.join)(a,b))}catch{return[]}}async function t(a,b){let c=q(),d=(await Promise.all((await s()).map(async a=>{try{let{size:b,mtimeMs:c}=await (0,f.stat)(a);return{path:a,key:(0,j.$)(a),size:b,mtimeMs:c}}catch{return null}}))).filter(a=>null!==a&&!x(c.get(a.key),a.size,a.mtimeMs));for(let e of(a.total=d.length,b(),d)){try{c.set(e.key,{size:e.size,mtimeMs:e.mtimeMs,...m(await (0,f.readFile)(e.path,"utf8"))})}catch{}a.done+=1}d.length>0&&r(c)}function u(){let a;if(globalThis.__piUsageScanState)return globalThis.__piUsageScanState;let b={done:0,total:0,planned:new Promise(b=>{a=b}),promise:Promise.resolve()};return b.promise=t(b,a).finally(()=>{a(),globalThis.__piUsageScanState=void 0}),globalThis.__piUsageScanState=b}function v(){return[...q().values()].map(a=>({cwd:a.cwd??"",rows:a.rows}))}function w(a){let b=q(),c=!1;for(let d of a){if(!(0,e.existsSync)(d))continue;let a=(0,j.$)(d),{size:f,mtimeMs:g}=(0,e.statSync)(d);x(b.get(a),f,g)||(b.set(a,{size:f,mtimeMs:g,...m((0,e.readFileSync)(d,"utf8"))}),c=!0)}c&&r(b)}d()}catch(a){d(a)}})},75430:a=>{"use strict";a.exports=import("@earendil-works/pi-coding-agent")},76760:a=>{"use strict";a.exports=require("node:path")},77598:a=>{"use strict";a.exports=require("node:crypto")},78335:()=>{},79646:a=>{"use strict";a.exports=require("child_process")},79748:a=>{"use strict";a.exports=require("fs/promises")},80481:a=>{"use strict";a.exports=require("node:readline")},81115:a=>{"use strict";a.exports=require("constants")},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},89691:(a,b,c)=>{"use strict";function d(a){let b,c=0;for(let e of a){var d;if("message"!==(d=e.type)&&"compaction"!==d&&"branch_summary"!==d&&"custom_message"!==d)continue;let a=Date.parse(e.timestamp);if(!Number.isFinite(a))continue;let f="message"===e.type?e.message?.role:void 0;if("user"===f||"bashExecution"===f){b=a;continue}void 0!==b&&a>b&&(c+=a-b),b=a}return c}c.d(b,{c:()=>d})},94735:a=>{"use strict";a.exports=require("events")},96487:()=>{},98192:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{DELETE:()=>x,GET:()=>v,PATCH:()=>w});var e=c(23211),f=c(29021),g=c(33873),h=c(21906),i=c(75430),j=c(40402),k=c(45902),l=c(56429),m=c(14858),n=c(89691),o=c(88914),p=c(4896),q=c(7048),r=c(21560),s=c(8102),t=c(33920),u=a([h,i,j,l,p,q,t]);async function v(a,{params:b}){let{id:c}=await b;try{let b,d="1"===new URL(a.url).searchParams.get("force"),g=function(a,b){let c=(0,l.getRpcSession)(a);if(!c?.isAlive())return;if(!b)return c;let d=c.sessionFile;if(!d||c.isRunning())return c;let e=(0,j.xL)(d);return e.overlongLine?(console.log(`[pi-web] session ${a} tail exceeds the probe window; rebuilding from the file`),(0,l.releaseRpcSessionForExternalWrite)(a)?void 0:c):!e.entryId||c.inner.sessionManager.getEntries().some(a=>a?.id===e.entryId)?c:(console.log(`[pi-web] session ${a} changed on disk; rebuilding from the file`),(0,l.releaseRpcSessionForExternalWrite)(a)?void 0:c)}(c,d),h=g?null:await (0,j.os)(c);if(!g&&!h)return e.NextResponse.json({error:"Session not found"},{status:404});let k=g?.inner.sessionManager??i.SessionManager.open(h),s=g?.sessionFile||k.getSessionFile()||h||"",t=k.getEntries(),u=k.getLeafId(),v=(0,m.y)(k.getTree()),w=new URL(a.url).searchParams,x=w.has("deferThinking"),y=w.has("deferMedia"),z=Number(w.get("tail")),A=Number.isFinite(z)&&z>0?Math.min(z,1e3):200,B=(0,j.Uv)(t,u,{deferThinking:x,deferToolResultImages:y,tail:A,sessionId:c}),C=(0,n.c)(t),D=(0,o.P)(t),E=g?.inner?.getContextUsage?.()??await (0,p.a)(k,u),F=k.getSessionName(),G=t.find(a=>"message"===a.type&&"user"===a.message.role),H=G?.type==="message"?G.message:void 0,I=k.getHeader(),J=I?.timestamp??new Date().toISOString();try{J=(0,f.statSync)(s).mtime.toISOString()}catch{}let K=I?.parentSession?await (0,j.u1)(I.parentSession):void 0,L=I?(0,q.$u)(t,I.id,s):null,M=L?await (0,l.getSubagentRun)(c):null,N=(0,q.ph)(t)?.tools??(0,r.dS)(t),O=I?(await (0,j.zH)([{path:s,id:I.id,cwd:I.cwd??"",name:F,created:I.timestamp,modified:J,messageCount:D.totalMessages,firstMessage:H?(b=H.content,"string"==typeof b?b:(Array.isArray(b)?b.find(a=>"text"===a.type)?.text??"":"")||"(no messages)"):"(no messages)",parentSessionId:K,...L?{relation:{kind:"subagent",parentSessionId:L.parentSessionId,profile:L.profile,description:L.description,status:M?.status??L.status}}:I.parentSession?{relation:{kind:"fork",...K?{originSessionId:K}:{}}}:{},transient:!s||!(0,f.existsSync)(s)}]))[0]:null;return e.NextResponse.json({sessionId:c,filePath:s,info:O,leafId:u,tree:v,context:B,stats:D,...E?{contextUsage:E}:{},totalActiveMs:C,...void 0!==N?{toolNames:N}:{}})}catch(a){return e.NextResponse.json({error:String(a)},{status:500})}}async function w(a,{params:b}){let{id:c}=await b;try{let{name:b,pinned:d}=await a.json();if("string"!=typeof b&&"boolean"!=typeof d)return e.NextResponse.json({error:"name or pinned is required"},{status:400});let f=await (0,j.os)(c);if(!f)return e.NextResponse.json({error:"Session not found"},{status:404});return"boolean"==typeof d&&(0,t.fi)(c,d),"string"==typeof b&&i.SessionManager.open(f).appendSessionInfo(b.trim()),(0,j.mD)(),e.NextResponse.json({ok:!0})}catch(a){return e.NextResponse.json({error:String(a)},{status:500})}}async function x(a,{params:b}){let{id:c}=await b;try{let a,b=await (0,j.os)(c);if(!b||!(0,f.existsSync)(b)){let a=(0,l.getRpcSession)(c);if(!a)return b&&(0,j.BR)(c),e.NextResponse.json({error:"Session not found"},{status:404});let d=a.sessionFile||b;return await a.shutdown(),d&&(0,h.GW)([d]),(0,j.BR)(c),(0,j.mD)(),e.NextResponse.json({ok:!0})}let d=(0,j.eP)(b)?.parentSession;if(d)try{a=(0,j.eP)(d)?.id}catch{a=void 0}let i=(0,k.$)(b),m=(0,g.dirname)(b),n=(0,f.readdirSync)(m).filter(a=>a.endsWith(".jsonl")).map(a=>(0,h.CQ)((0,g.join)(m,a))).filter(a=>null!==a),o=n.find(a=>a.pathKey===i);if(!o||o.id!==c)return e.NextResponse.json({error:"Session changed while preparing deletion"},{status:409});let p=new Map;for(let a of n){if(!a.parentPath)continue;let b=(0,k.$)(a.parentPath);p.set(b,[...p.get(b)??[],a])}let q=p.get(i)??[],r=new Set;if(!d){let a=q.filter(a=>a.isSubagent);for(;a.length>0;){let b=a.shift();r.has(b.pathKey)||(r.add(b.pathKey),a.push(...p.get(b.pathKey)??[]))}}let t=n.filter(a=>r.has(a.pathKey)),u=q.filter(a=>!r.has(a.pathKey));if(u.some(a=>a.isSubagent)&&(!d||!a))return e.NextResponse.json({error:"Cannot reparent subagent session"},{status:409});let v=[o,...t,...u],w=await (0,l.reserveRpcSessionFileMutation)(v.map(a=>a.id));if(!w)return e.NextResponse.json({error:"Session is busy"},{status:409});try{if(v.some(a=>{try{return(0,f.readFileSync)(a.path,"utf8")!==a.original}catch{return!0}}))return e.NextResponse.json({error:"Session changed while preparing deletion"},{status:409});let g=u.map(b=>({record:b,updated:(0,h.JS)(b,d,a)})),i=[];try{for(let{record:a,updated:b}of g)(0,s.$)(a.path,b),i.push(a);(0,h.GW)([b,...t.map(a=>a.path)])}catch(a){for(let a of i.reverse())try{(0,s.$)(a.path,a.original)}catch{}throw a}for(let a of((0,j.BR)(c),t))(0,j.BR)(a.id);return(0,j.mD)(),e.NextResponse.json({ok:!0})}finally{w()}}catch(a){return e.NextResponse.json({error:String(a)},{status:500})}}[h,i,j,l,p,q,t]=u.then?(await u)():u,d()}catch(a){d(a)}})}};var b=require("../../../../webpack-runtime.js");b.C(a);var c=b.X(0,[4741,1813,426,974,402,6759,2243,6429],()=>b(b.s=47207));module.exports=c})();
|
|
1
|
+
(()=>{var a={};a.id=6849,a.ids=[6849],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},1932:a=>{"use strict";a.exports=require("url")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},4573:a=>{"use strict";a.exports=require("node:buffer")},4896:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{a:()=>i});var e=c(75430),f=a([e]);function g(a){return a?"totalTokens"in a&&"number"==typeof a.totalTokens&&a.totalTokens>0?a.totalTokens:(a.input??0)+(a.output??0)+(a.cacheRead??0)+(a.cacheWrite??0):0}async function h(a,b,c){if(!b)return 0;try{let d=c??await (!globalThis.__piStaticModelRuntime&&(globalThis.__piStaticModelRuntime=e.ModelRuntime.create().catch(a=>{throw delete globalThis.__piStaticModelRuntime,a})),globalThis.__piStaticModelRuntime),f=d.getModel(a,b);if(f?.contextWindow&&f.contextWindow>0)return f.contextWindow;let g=d.getModels(),h=g.find(a=>a.id===b&&a.contextWindow>0);if(h?.contextWindow)return h.contextWindow;let i=g.find(a=>(a.id.endsWith(`/${b}`)||b.endsWith(`/${a.id}`))&&a.contextWindow>0);if(i?.contextWindow)return i.contextWindow;let j=b.toLowerCase();if(j.includes("gemini"))return 1048576;if(j.includes("claude-3-7")||j.includes("claude-sonnet-4")||j.includes("claude-opus-4"))return j.includes("opus-4-6")||j.includes("sonnet-4-6")?1e6:2e5;if(j.includes("gpt-4o")||j.includes("o1")||j.includes("o3"))return 128e3;if(j.includes("deepseek"))return 64e3}catch{}return 0}async function i(a,b,c){try{let d;if(Array.isArray(a))if(b){let c=new Map;for(let b of a)"id"in b&&"string"==typeof b.id&&c.set(b.id,b);let e=[],f=b;for(;f;){let a=c.get(f);if(!a)break;e.push(a),f="parentId"in a?a.parentId:void 0}e.reverse(),d=e}else d=a;else d="getBranch"in a&&"function"==typeof a.getBranch?b?a.getBranch(b):a.getBranch():"getEntries"in a&&"function"==typeof a.getEntries?a.getEntries()??[]:[];if(0===d.length)return null;let f=function(a){for(let b=a.length-1;b>=0;b--){let c=a[b];if("model_change"===c.type&&c.modelId)return{provider:c.provider||"",modelId:c.modelId};if("message"===c.type&&"assistant"===c.message.role&&c.message.model)return{provider:c.message.provider||"",modelId:c.message.model}}return null}(d),i=f?await h(f.provider,f.modelId,c):0,j=function(a){for(let b=a.length-1;b>=0;b--)if("compaction"===a[b].type)return a[b];return null}(d);if(j){let a=d.lastIndexOf(j),b=!1;for(let c=d.length-1;c>a;c--){let a=d[c];if("message"===a.type&&"assistant"===a.message.role){let c=a.message.usage;if(c&&g(c)>0){b=!0;break}}}if(!b)return i>0?{tokens:null,contextWindow:i,percent:null}:null}let k=(0,e.getLastAssistantUsage)(d),l=k?g(k):null;if(null===l&&i<=0)return null;let m=null!==l&&i>0?Math.min(100,Math.round(l/i*1e3)/10):null;return{tokens:l,contextWindow:i,percent:m}}catch{return null}}e=(f.then?(await f)():f)[0],d()}catch(a){d(a)}})},6093:(a,b,c)=>{"use strict";c.d(b,{EL:()=>e});let d=a=>String(a).padStart(2,"0"),e=a=>`${a.getFullYear()}-${d(a.getMonth()+1)}-${d(a.getDate())}`},8128:a=>{"use strict";a.exports=require("next/dist/server/runtime-reacts.external.js")},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},12412:a=>{"use strict";a.exports=require("assert")},14858:(a,b,c)=>{"use strict";function d(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}function e(a,b){if("string"!=typeof b||a.length>40)return a;let c=b.replace(/\s+/g," ").trim();if(!c)return a;let d=a?" ":"",e=a+d;if(e.length>=41)return e.slice(0,41);let f=41-e.length;return e+c.slice(0,f)}function f(a){if("message"!==a.type||!d(a.message)||"string"!=typeof a.message.role||"system"===a.message.role)return;let b=a.message.content,c="",f=!1;if("string"==typeof b)c=e(c,b);else if(Array.isArray(b)){for(let a of b)if(d(a)&&("image"===a.type&&(f=!0),"text"===a.type&&(c=e(c,a.text)),c.length>40))break}c.length>40?c=c.slice(0,40)+"…":c||(c=f?"[image]":"assistant"===a.message.role?"[assistant]":"message");let g="user"===a.message.role||"assistant"===a.message.role?a.message.role:void 0;return{...g?{role:g}:{},text:c}}function g(a){let b=new Set,c=new Set(a),d=new Set,e=[...a];for(;e.length>0;){let a=e.pop();if(!d.has(a))for(let f of(d.add(a),(c.has(a)||1!==a.children.length)&&b.add(a),a.children))e.push(f)}let g=(a,b,c)=>({...a,children:[],...b?.length?{compressedEntryIds:b}:{},...c?{branchPreview:c}:{}}),h=a.map(a=>g(a,void 0,f(a.entry))),i=a.map((a,b)=>({source:a,projected:h[b],depth:1})),j=(a,c)=>{let d=[{node:a,compressedEntryIds:[],branchPreview:void 0}],e=new Set;for(;d.length>0;){let{node:a,compressedEntryIds:h,branchPreview:i}=d.pop();if(e.has(a))continue;e.add(a);let j=i??f(a.entry);b.has(a)&&c.children.push(g(a,h,j));for(let c=a.children.length-1;c>=0;c--)d.push({node:a.children[c],compressedEntryIds:b.has(a)?[]:[...h,a.entry.id],branchPreview:b.has(a)?void 0:j})}};for(;i.length>0;){let{source:a,projected:c,depth:d}=i.pop();for(let e of a.children){let a=e;if(d>=200){j(a,c);continue}let h=[],k=f(a.entry);for(;!b.has(a)&&1===a.children.length;)h.push(a.entry.id),a=a.children[0],k??=f(a.entry);if(!b.has(a))continue;let l=g(a,h,k);c.children.push(l),i.push({source:a,projected:l,depth:d+1})}}return h}c.d(b,{y:()=>g})},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},21906:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{CQ:()=>l,GW:()=>n,JS:()=>m});var e=c(55511),f=c(29021),g=c(33873),h=c(45902),i=c(7048),j=c(74313),k=a([i,j]);function l(a){let b=(0,f.readFileSync)(a,"utf8"),c=b.split("\n"),d=c.map(a=>{if(!a.trim())return null;try{return JSON.parse(a)}catch{return null}}),e=d[0];if(e?.type!=="session"||"string"!=typeof e.id)return null;let g=d.slice(1).filter(a=>null!==a);return{path:a,pathKey:(0,h.$)(a),id:e.id,parentPath:"string"==typeof e.parentSession?e.parentSession:void 0,lines:c,entries:g,original:b,isSubagent:!!(0,i.$u)(g,e.id,a)}}function m(a,b,c){let d=[...a.lines],e=JSON.parse(d[0]);if(b?e.parentSession=b:delete e.parentSession,d[0]=JSON.stringify(e),a.isSubagent){if(!b||!c)throw Error("Cannot reparent a subagent without a valid parent session");for(let a=1;a<d.length;a+=1){let e;try{e=JSON.parse(d[a])}catch{continue}"custom"!==e.type||e.customType!==i.tP||"object"!=typeof e.data||null===e.data||Array.isArray(e.data)||(e.data={...e.data,parentSessionId:c,parentSessionPath:b},d[a]=JSON.stringify(e))}}return d.join("\n")}function n(a){try{(0,j.H2)(a)}catch{}let b=[];try{for(let c of a){if(!(0,f.existsSync)(c))continue;let a=(0,g.join)((0,g.dirname)(c),`.${(0,g.basename)(c)}-${(0,e.randomUUID)()}.deleting`);try{(0,f.renameSync)(c,a)}catch(a){if("ENOENT"===a.code)continue;throw a}b.push({original:c,staged:a})}}catch(a){for(let a of b.reverse())try{(0,f.renameSync)(a.staged,a.original)}catch{}throw a}for(let a of b)try{(0,f.unlinkSync)(a.staged)}catch{}}[i,j]=k.then?(await k)():k,d()}catch(a){d(a)}})},27910:a=>{"use strict";a.exports=require("stream")},28354:a=>{"use strict";a.exports=require("util")},28802:a=>{"use strict";a.exports=import("@earendil-works/pi-ai")},29021:a=>{"use strict";a.exports=require("fs")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},29862:a=>{"use strict";a.exports=import("@earendil-works/pi-tui")},31421:a=>{"use strict";a.exports=require("node:child_process")},33873:a=>{"use strict";a.exports=require("path")},33920:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{Zg:()=>k,fi:()=>l});var e=c(29021),f=c(33873),g=c(75430),h=c(8102),i=a([g]);function j(a=(0,g.getAgentDir)()){return(0,f.join)(a,"pi-web","pinned-sessions.json")}function k(a=j()){let b;try{b=(0,e.readFileSync)(a,"utf8")}catch(a){if("ENOENT"===a.code)return[];throw a}let c=JSON.parse(b);return Array.isArray(c)?c.filter(a=>"string"==typeof a):[]}function l(a,b,c=j()){let d=k(c).filter(b=>b!==a);return b&&d.push(a),(0,e.mkdirSync)((0,f.dirname)(c),{recursive:!0}),(0,h.$)(c,JSON.stringify(d)),d}g=(i.then?(await i)():i)[0],d()}catch(a){d(a)}})},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},48161:a=>{"use strict";a.exports=require("node:os")},51181:a=>{"use strict";a.exports=require("web-push")},51455:a=>{"use strict";a.exports=require("node:fs/promises")},55511:a=>{"use strict";a.exports=require("crypto")},57975:a=>{"use strict";a.exports=require("node:util")},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},65645:(a,b,c)=>{"use strict";c.r(b),c.d(b,{handler:()=>z,patchFetch:()=>y,routeModule:()=>u,serverHooks:()=>x,workAsyncStorage:()=>v,workUnitAsyncStorage:()=>w});var d=c(19225),e=c(84006),f=c(8317),g=c(99373),h=c(34775),i=c(24235),j=c(261),k=c(54365),l=c(90771),m=c(73461),n=c(67798),o=c(92280),p=c(62018),q=c(45696),r=c(47929),s=c(86439),t=c(37527);let u=new d.AppRouteRouteModule({definition:{kind:e.RouteKind.APP_ROUTE,page:"/api/sessions/[id]/route",pathname:"/api/sessions/[id]",filename:"route",bundlePath:"app/api/sessions/[id]/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/zhujunshen/pi-web/app/api/sessions/[id]/route.ts",nextConfigOutput:"",userland:()=>c(98192),...{}}),{workAsyncStorage:v,workUnitAsyncStorage:w,serverHooks:x}=u;function y(){return(0,f.patchFetch)({workAsyncStorage:v,workUnitAsyncStorage:w})}async function z(a,b,c){c.requestMeta&&(0,g.setRequestMeta)(a,c.requestMeta),u.isDev&&(0,g.addRequestMeta)(a,"devRequestTimingInternalsEnd",process.hrtime.bigint());let d="/api/sessions/[id]/route";"/index"===d&&(d="/");let f=await u.prepare(a,b,{srcPage:d,multiZoneDraftMode:!1});if(!f)return b.statusCode=400,b.end("Bad Request"),null==c.waitUntil||c.waitUntil.call(c,Promise.resolve()),null;let{buildId:v,deploymentId:w,params:x,nextConfig:y,parsedUrl:z,isDraftMode:A,prerenderManifest:B,routerServerContext:C,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,resolvedPathname:F,clientReferenceManifest:G,serverActionsManifest:H}=f,I=(0,j.normalizeAppPath)(d),J=!!(B.dynamicRoutes[I]||B.routes[F]),K=async()=>((null==C?void 0:C.render404)?await C.render404(a,b,z,!1):b.end("This page could not be found"),null);if(J&&!A){let a=!!B.routes[F],b=B.dynamicRoutes[I];if(b&&!1===b.fallback&&!a){if(y.adapterPath)return await K();throw new s.NoFallbackError}}let L=null;!J||u.isDev||A||(L="/index"===(L=F)?"/":L);let M=!0===u.isDev||!J,N=J&&!M;H&&G&&(0,i.setManifestsSingleton)({page:d,clientReferenceManifest:G,serverActionsManifest:H});let O=a.method||"GET",P=(0,h.getTracer)(),Q=P.getActiveScopeSpan(),R=!!(null==C?void 0:C.isWrappedByNextServer),S=!!(0,g.getRequestMeta)(a,"minimalMode"),T=(0,g.getRequestMeta)(a,"incrementalCache")||await u.getIncrementalCache(a,y,B,S);null==T||T.resetRequestCache(),globalThis.__incrementalCache=T;let U={params:x,previewProps:B.preview,renderOpts:{experimental:{authInterrupts:!!y.experimental.authInterrupts,useCacheTimeout:y.experimental.useCacheTimeout},cacheComponents:!!y.cacheComponents,validationLevel:y.experimental.instantInsights.validationLevel,supportsDynamicResponse:M,incrementalCache:T,hmrRefreshHash:(0,g.getRequestMeta)(a,"hmrRefreshHash"),cacheLifeProfiles:y.cacheLife,staticPageGenerationTimeout:y.staticPageGenerationTimeout,waitUntil:c.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:void 0,onInstrumentationRequestError:(b,c,d,e)=>u.onRequestError(a,b,d,e,C)},sharedContext:{buildId:v,deploymentId:w}},V=new k.NodeNextRequest(a),W=new k.NodeNextResponse(b),X=l.NextRequestAdapter.fromNodeNextRequest(V,(0,l.signalFromNodeResponse)(b)),Y=async({previousCacheEntry:e})=>{try{if(!S&&D&&E&&!e)return b.statusCode=404,b.setHeader("x-nextjs-cache","REVALIDATED"),b.end("This page could not be found"),null;let d=await u.handle(X,U);a.fetchMetrics=U.renderOpts.fetchMetrics;let f=U.renderOpts.pendingWaitUntil;f&&c.waitUntil&&(c.waitUntil(f),f=void 0);let g=U.renderOpts.collectedTags;if(!J)return await (0,o.I)(V,W,d,f),null;{let a=await d.blob(),b=(0,p.toNodeOutgoingHttpHeaders)(d.headers);g&&(b[r.NEXT_CACHE_TAGS_HEADER]=g),!b["content-type"]&&a.type&&(b["content-type"]=a.type);let c=void 0!==U.renderOpts.collectedRevalidate&&!(U.renderOpts.collectedRevalidate>=r.INFINITE_CACHE)&&U.renderOpts.collectedRevalidate,e=void 0===U.renderOpts.collectedExpire||U.renderOpts.collectedExpire>=r.INFINITE_CACHE?!1!==c&&c>0?y.expireTime:void 0:U.renderOpts.collectedExpire;return{value:{kind:t.CachedRouteKind.APP_ROUTE,status:d.status,body:Buffer.from(await a.arrayBuffer()),headers:b},cacheControl:{revalidate:c,expire:e}}}}catch(b){throw(null==e?void 0:e.isStale)&&await u.onRequestError(a,b,{routerKind:"App Router",routePath:d,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),b}},Z=async(d,f)=>{try{var g,i;let d=await u.handleResponse({req:a,nextConfig:y,cacheKey:L,routeKind:e.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:B,isRoutePPREnabled:!1,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,responseGenerator:Y,waitUntil:c.waitUntil,isMinimalMode:S});if(!J)return;if((null==d||null==(g=d.value)?void 0:g.kind)!==t.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==d||null==(i=d.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});S||b.setHeader("x-nextjs-cache",D?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),A&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let f=(0,p.fromNodeOutgoingHttpHeaders)(d.value.headers);S&&J||f.delete(r.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||b.getHeader("Cache-Control")||f.get("Cache-Control")||f.set("Cache-Control",(0,q.getCacheControlHeader)(d.cacheControl)),await (0,o.I)(V,W,new Response(d.value.body,{headers:f,status:d.value.status||200}));return}catch(b){if(b instanceof s.NoFallbackError||await u.onRequestError(a,b,{routerKind:"App Router",routePath:I,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),J)throw b;await (0,o.I)(V,W,new Response(null,{status:500}));return}finally{(()=>{if(!d)return;let a=b.statusCode;d.setAttributes({"http.status_code":a,"next.rsc":!1}),a&&a>=500&&(d.setStatus({code:h.SpanStatusCode.ERROR}),d.setAttribute("error.type",a.toString()));let c=P.getRootSpanAttributes();if(!c)return;if(c.get("next.span_type")!==m.BaseServerSpan.handleRequest)return console.warn(`Unexpected root span type '${c.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let e=c.get("next.route")||I,g=`${O} ${e}`;d.setAttributes({"next.route":e,"http.route":e,"next.span_name":g}),d.updateName(g),f&&f!==d&&(f.setAttribute("http.route",e),f.updateName(g))})()}};if(R&&Q)await Z(Q,void 0);else{let b=P.getActiveScopeSpan();await P.withPropagatedContext(a.headers,()=>P.trace(m.BaseServerSpan.handleRequest,{spanName:`${O} ${d}`,kind:h.SpanKind.SERVER,attributes:{"http.method":O,"http.target":a.url}},a=>Z(a,b)),void 0,!R)}}},72322:a=>{"use strict";a.exports=import("@earendil-works/pi-ai/utils/pi-user-agent")},73024:a=>{"use strict";a.exports=require("node:fs")},74313:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{H2:()=>w,O6:()=>n,o7:()=>v,xh:()=>u});var e=c(29021),f=c(79748),g=c(33873),h=c(75430),i=c(8102),j=c(45902),k=c(6093),l=a([h]);function m(a){let b,c=a.split("\n");try{b=JSON.parse(c[0])}catch{return{cwd:"",rows:[]}}let d="string"==typeof b.cwd?b.cwd:"",e=Date.parse(b.timestamp??"");if(!Number.isFinite(e))return{cwd:d,rows:[]};let f=new Map;for(let a of c){let b;if(!a.includes('"usage"'))continue;try{b=JSON.parse(a)}catch{continue}let c=b.message,d=c?.usage;if(c?.role!=="assistant"||!d)continue;let g="number"==typeof c.timestamp?c.timestamp:Date.parse(b.timestamp??"");if(!Number.isFinite(g)||g<e)continue;let h=new Date(g),i=(0,k.EL)(h),j=h.getHours(),l=String(c.provider??""),m=String(c.model??""),n=`${i}\0${j}\0${l}\0${m}`,o=f.get(n);o||(o={day:i,hour:j,provider:l,model:m,messages:0,input:0,output:0,cacheRead:0,cacheWrite:0,recordedCost:0},f.set(n,o)),o.messages+=1,o.input+=d.input??0,o.output+=d.output??0,o.cacheRead+=d.cacheRead??0,o.cacheWrite+=d.cacheWrite??0,o.recordedCost+=d.cost?.total??0}return{cwd:d,rows:[...f.values()]}}function n(a,b,c){let d=new Map,e=new Map;for(let f of a){let a=c(f.cwd);for(let c of f.rows){let f=`${c.provider}\0${c.model}`;d.has(f)||d.set(f,b(c.provider,c.model));let g=d.get(f),h=c.hour??null,i=c.model.slice(c.model.lastIndexOf("/")+1),j=`${c.day}\0${h}\0${i}\0${a}`,k=e.get(j);k||(k={day:c.day,hour:h,model:i,project:a,messages:0,input:0,output:0,cacheRead:0,cacheWrite:0,cost:0,unpriced:0},e.set(j,k)),k.messages+=c.messages,k.input+=c.input,k.output+=c.output,k.cacheRead+=c.cacheRead,k.cacheWrite+=c.cacheWrite,k.cost+=g?(c.input*g.input+c.output*g.output+c.cacheRead*g.cacheRead+c.cacheWrite*g.cacheWrite)/1e6:c.recordedCost,g||0!==c.recordedCost||(k.unpriced+=c.messages)}}return[...e.values()]}function o(){return(0,g.join)((0,h.getAgentDir)(),"pi-web-usage-cache.json")}function p(){try{let a=JSON.parse((0,e.readFileSync)(o(),"utf8"));if(!a.files)return new Map;if(2===a.version)return new Map(Object.entries(a.files));if(1===a.version)return new Map(Object.entries(a.files).map(([a,{size:b,mtimeMs:c,rows:d}])=>[a,{size:b,mtimeMs:c,rows:d}]))}catch{}return new Map}function q(){return globalThis.__piUsageCache??=p()}function r(a){for(let[b,c]of p())a.has(b)||a.set(b,c);(0,i.$)(o(),JSON.stringify({version:2,files:Object.fromEntries(a)}))}h=(l.then?(await l)():l)[0];let x=(a,b,c)=>void 0!==a&&void 0!==a.cwd&&a.size===b&&a.mtimeMs===c;async function s(){let a=(0,g.join)((0,h.getAgentDir)(),"sessions");try{return(await (0,f.readdir)(a,{recursive:!0})).filter(a=>a.endsWith(".jsonl")).map(b=>(0,g.join)(a,b))}catch{return[]}}async function t(a,b){let c=q(),d=(await Promise.all((await s()).map(async a=>{try{let{size:b,mtimeMs:c}=await (0,f.stat)(a);return{path:a,key:(0,j.$)(a),size:b,mtimeMs:c}}catch{return null}}))).filter(a=>null!==a&&!x(c.get(a.key),a.size,a.mtimeMs));for(let e of(a.total=d.length,b(),d)){try{c.set(e.key,{size:e.size,mtimeMs:e.mtimeMs,...m(await (0,f.readFile)(e.path,"utf8"))})}catch{}a.done+=1}d.length>0&&r(c)}function u(){let a;if(globalThis.__piUsageScanState)return globalThis.__piUsageScanState;let b={done:0,total:0,planned:new Promise(b=>{a=b}),promise:Promise.resolve()};return b.promise=t(b,a).finally(()=>{a(),globalThis.__piUsageScanState=void 0}),globalThis.__piUsageScanState=b}function v(){return[...q().values()].map(a=>({cwd:a.cwd??"",rows:a.rows}))}function w(a){let b=q(),c=!1;for(let d of a){if(!(0,e.existsSync)(d))continue;let a=(0,j.$)(d),{size:f,mtimeMs:g}=(0,e.statSync)(d);x(b.get(a),f,g)||(b.set(a,{size:f,mtimeMs:g,...m((0,e.readFileSync)(d,"utf8"))}),c=!0)}c&&r(b)}d()}catch(a){d(a)}})},75430:a=>{"use strict";a.exports=import("@earendil-works/pi-coding-agent")},76760:a=>{"use strict";a.exports=require("node:path")},77598:a=>{"use strict";a.exports=require("node:crypto")},78335:()=>{},79646:a=>{"use strict";a.exports=require("child_process")},79748:a=>{"use strict";a.exports=require("fs/promises")},80481:a=>{"use strict";a.exports=require("node:readline")},81115:a=>{"use strict";a.exports=require("constants")},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},89691:(a,b,c)=>{"use strict";function d(a){let b,c=0;for(let e of a){var d;if("message"!==(d=e.type)&&"compaction"!==d&&"branch_summary"!==d&&"custom_message"!==d)continue;let a=Date.parse(e.timestamp);if(!Number.isFinite(a))continue;let f="message"===e.type?e.message?.role:void 0;if("user"===f||"bashExecution"===f){b=a;continue}void 0!==b&&a>b&&(c+=a-b),b=a}return c}c.d(b,{c:()=>d})},94735:a=>{"use strict";a.exports=require("events")},96487:()=>{},98192:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{DELETE:()=>x,GET:()=>v,PATCH:()=>w});var e=c(23211),f=c(29021),g=c(33873),h=c(21906),i=c(75430),j=c(40402),k=c(45902),l=c(56429),m=c(14858),n=c(89691),o=c(88914),p=c(4896),q=c(7048),r=c(21560),s=c(8102),t=c(33920),u=a([h,i,j,l,p,q,t]);async function v(a,{params:b}){let{id:c}=await b;try{let b,d="1"===new URL(a.url).searchParams.get("force"),g=function(a,b){let c=(0,l.getRpcSession)(a);if(!c?.isAlive())return;if(!b)return c;let d=c.sessionFile;if(!d||c.isRunning())return c;let e=(0,j.xL)(d);return e.overlongLine?(console.log(`[pi-web] session ${a} tail exceeds the probe window; rebuilding from the file`),(0,l.releaseRpcSessionForExternalWrite)(a)?void 0:c):!e.entryId||c.inner.sessionManager.getEntries().some(a=>a?.id===e.entryId)?c:(console.log(`[pi-web] session ${a} changed on disk; rebuilding from the file`),(0,l.releaseRpcSessionForExternalWrite)(a)?void 0:c)}(c,d),h=g?null:await (0,j.os)(c);if(!g&&!h)return e.NextResponse.json({error:"Session not found"},{status:404});let k=g?.inner.sessionManager??i.SessionManager.open(h),s=g?.sessionFile||k.getSessionFile()||h||"",t=k.getEntries(),u=k.getLeafId(),v=(0,m.y)(k.getTree()),w=new URL(a.url).searchParams,x=w.has("deferThinking"),y=w.has("deferMedia"),z=Number(w.get("tail")),A=Number.isFinite(z)&&z>0?Math.min(z,1e3):200,B=(0,j.Uv)(t,u,{deferThinking:x,deferToolResultImages:y,tail:A,sessionId:c}),C=(0,n.c)(t),D=(0,o.P)(t),E=g?.inner?.getContextUsage?.()??await (0,p.a)(k,u),F=k.getSessionName(),G=t.find(a=>"message"===a.type&&"user"===a.message.role),H=G?.type==="message"?G.message:void 0,I=k.getHeader(),J=I?.timestamp??new Date().toISOString();try{J=(0,f.statSync)(s).mtime.toISOString()}catch{}let K=I?.parentSession?await (0,j.u1)(I.parentSession):void 0,L=I?(0,q.$u)(t,I.id,s):null,M=L?await (0,l.getSubagentRun)(c):null,N=(0,q.ph)(t)?.tools??(0,r.dS)(t),O=I?(await (0,j.zH)([{path:s,id:I.id,cwd:I.cwd??"",name:F,created:I.timestamp,modified:J,messageCount:D.totalMessages,firstMessage:H?(b=H.content,"string"==typeof b?b:(Array.isArray(b)?b.find(a=>"text"===a.type)?.text??"":"")||"(no messages)"):"(no messages)",parentSessionId:K,...L?{relation:{kind:"subagent",parentSessionId:L.parentSessionId,profile:L.profile,description:L.description,status:M?.status??L.status}}:I.parentSession?{relation:{kind:"fork",...K?{originSessionId:K}:{}}}:{},transient:!s||!(0,f.existsSync)(s)}]))[0]:null;return e.NextResponse.json({sessionId:c,filePath:s,info:O,leafId:u,tree:v,context:B,stats:D,...E?{contextUsage:E}:{},totalActiveMs:C,...void 0!==N?{toolNames:N}:{}})}catch(a){return e.NextResponse.json({error:String(a)},{status:500})}}async function w(a,{params:b}){let{id:c}=await b;try{let{name:b,pinned:d}=await a.json();if("string"!=typeof b&&"boolean"!=typeof d)return e.NextResponse.json({error:"name or pinned is required"},{status:400});let f=await (0,j.os)(c);if(!f)return e.NextResponse.json({error:"Session not found"},{status:404});return"boolean"==typeof d&&(0,t.fi)(c,d),"string"==typeof b&&i.SessionManager.open(f).appendSessionInfo(b.trim()),(0,j.mD)(),e.NextResponse.json({ok:!0})}catch(a){return e.NextResponse.json({error:String(a)},{status:500})}}async function x(a,{params:b}){let{id:c}=await b;try{let a,b=await (0,j.os)(c);if(!b||!(0,f.existsSync)(b)){let a=(0,l.getRpcSession)(c);if(!a)return b&&(0,j.BR)(c),e.NextResponse.json({error:"Session not found"},{status:404});let d=a.sessionFile||b;return await a.shutdown(),d&&(0,h.GW)([d]),(0,j.BR)(c),(0,j.mD)(),e.NextResponse.json({ok:!0})}let d=(0,j.eP)(b)?.parentSession;if(d)try{a=(0,j.eP)(d)?.id}catch{a=void 0}let i=(0,k.$)(b),m=(0,g.dirname)(b),n=(0,f.readdirSync)(m).filter(a=>a.endsWith(".jsonl")).map(a=>(0,h.CQ)((0,g.join)(m,a))).filter(a=>null!==a),o=n.find(a=>a.pathKey===i);if(!o||o.id!==c)return e.NextResponse.json({error:"Session changed while preparing deletion"},{status:409});let p=new Map;for(let a of n){if(!a.parentPath)continue;let b=(0,k.$)(a.parentPath);p.set(b,[...p.get(b)??[],a])}let q=p.get(i)??[],r=new Set;if(!d){let a=q.filter(a=>a.isSubagent);for(;a.length>0;){let b=a.shift();r.has(b.pathKey)||(r.add(b.pathKey),a.push(...p.get(b.pathKey)??[]))}}let t=n.filter(a=>r.has(a.pathKey)),u=q.filter(a=>!r.has(a.pathKey));if(u.some(a=>a.isSubagent)&&(!d||!a))return e.NextResponse.json({error:"Cannot reparent subagent session"},{status:409});let v=[o,...t,...u],w=await (0,l.reserveRpcSessionFileMutation)(v.map(a=>a.id));if(!w)return e.NextResponse.json({error:"Session is busy"},{status:409});try{if(v.some(a=>{try{return(0,f.readFileSync)(a.path,"utf8")!==a.original}catch{return!0}}))return e.NextResponse.json({error:"Session changed while preparing deletion"},{status:409});let g=u.map(b=>({record:b,updated:(0,h.JS)(b,d,a)})),i=[];try{for(let{record:a,updated:b}of g)(0,s.$)(a.path,b),i.push(a);(0,h.GW)([b,...t.map(a=>a.path)])}catch(a){for(let a of i.reverse())try{(0,s.$)(a.path,a.original)}catch{}throw a}for(let a of((0,j.BR)(c),t))(0,j.BR)(a.id);return(0,j.mD)(),e.NextResponse.json({ok:!0})}finally{w()}}catch(a){return e.NextResponse.json({error:String(a)},{status:500})}}[h,i,j,l,p,q,t]=u.then?(await u)():u,d()}catch(a){d(a)}})}};var b=require("../../../../webpack-runtime.js");b.C(a);var c=b.X(0,[4741,1813,426,974,402,6759,2243,6429],()=>b(b.s=65645));module.exports=c})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var a={};a.id=3943,a.ids=[3943],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},1932:a=>{"use strict";a.exports=require("url")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},4573:a=>{"use strict";a.exports=require("node:buffer")},8128:a=>{"use strict";a.exports=require("next/dist/server/runtime-reacts.external.js")},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},12412:a=>{"use strict";a.exports=require("assert")},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},27910:a=>{"use strict";a.exports=require("stream")},28354:a=>{"use strict";a.exports=require("util")},28802:a=>{"use strict";a.exports=import("@earendil-works/pi-ai")},29021:a=>{"use strict";a.exports=require("fs")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},29862:a=>{"use strict";a.exports=import("@earendil-works/pi-tui")},31421:a=>{"use strict";a.exports=require("node:child_process")},33873:a=>{"use strict";a.exports=require("path")},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},48161:a=>{"use strict";a.exports=require("node:os")},51181:a=>{"use strict";a.exports=require("web-push")},51455:a=>{"use strict";a.exports=require("node:fs/promises")},55511:a=>{"use strict";a.exports=require("crypto")},57975:a=>{"use strict";a.exports=require("node:util")},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},72322:a=>{"use strict";a.exports=import("@earendil-works/pi-ai/utils/pi-user-agent")},73024:a=>{"use strict";a.exports=require("node:fs")},
|
|
1
|
+
(()=>{var a={};a.id=3943,a.ids=[3943],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},1932:a=>{"use strict";a.exports=require("url")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},4573:a=>{"use strict";a.exports=require("node:buffer")},8128:a=>{"use strict";a.exports=require("next/dist/server/runtime-reacts.external.js")},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},12412:a=>{"use strict";a.exports=require("assert")},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},27910:a=>{"use strict";a.exports=require("stream")},28354:a=>{"use strict";a.exports=require("util")},28802:a=>{"use strict";a.exports=import("@earendil-works/pi-ai")},29021:a=>{"use strict";a.exports=require("fs")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},29862:a=>{"use strict";a.exports=import("@earendil-works/pi-tui")},31421:a=>{"use strict";a.exports=require("node:child_process")},33873:a=>{"use strict";a.exports=require("path")},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},48161:a=>{"use strict";a.exports=require("node:os")},51181:a=>{"use strict";a.exports=require("web-push")},51455:a=>{"use strict";a.exports=require("node:fs/promises")},55511:a=>{"use strict";a.exports=require("crypto")},57975:a=>{"use strict";a.exports=require("node:util")},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},72322:a=>{"use strict";a.exports=import("@earendil-works/pi-ai/utils/pi-user-agent")},73024:a=>{"use strict";a.exports=require("node:fs")},75430:a=>{"use strict";a.exports=import("@earendil-works/pi-coding-agent")},76760:a=>{"use strict";a.exports=require("node:path")},77598:a=>{"use strict";a.exports=require("node:crypto")},78335:()=>{},78957:(a,b,c)=>{"use strict";c.r(b),c.d(b,{handler:()=>z,patchFetch:()=>y,routeModule:()=>u,serverHooks:()=>x,workAsyncStorage:()=>v,workUnitAsyncStorage:()=>w});var d=c(19225),e=c(84006),f=c(8317),g=c(99373),h=c(34775),i=c(24235),j=c(261),k=c(54365),l=c(90771),m=c(73461),n=c(67798),o=c(92280),p=c(62018),q=c(45696),r=c(47929),s=c(86439),t=c(37527);let u=new d.AppRouteRouteModule({definition:{kind:e.RouteKind.APP_ROUTE,page:"/api/sessions/[id]/state/route",pathname:"/api/sessions/[id]/state",filename:"route",bundlePath:"app/api/sessions/[id]/state/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/zhujunshen/pi-web/app/api/sessions/[id]/state/route.ts",nextConfigOutput:"",userland:()=>c(87230),...{}}),{workAsyncStorage:v,workUnitAsyncStorage:w,serverHooks:x}=u;function y(){return(0,f.patchFetch)({workAsyncStorage:v,workUnitAsyncStorage:w})}async function z(a,b,c){c.requestMeta&&(0,g.setRequestMeta)(a,c.requestMeta),u.isDev&&(0,g.addRequestMeta)(a,"devRequestTimingInternalsEnd",process.hrtime.bigint());let d="/api/sessions/[id]/state/route";"/index"===d&&(d="/");let f=await u.prepare(a,b,{srcPage:d,multiZoneDraftMode:!1});if(!f)return b.statusCode=400,b.end("Bad Request"),null==c.waitUntil||c.waitUntil.call(c,Promise.resolve()),null;let{buildId:v,deploymentId:w,params:x,nextConfig:y,parsedUrl:z,isDraftMode:A,prerenderManifest:B,routerServerContext:C,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,resolvedPathname:F,clientReferenceManifest:G,serverActionsManifest:H}=f,I=(0,j.normalizeAppPath)(d),J=!!(B.dynamicRoutes[I]||B.routes[F]),K=async()=>((null==C?void 0:C.render404)?await C.render404(a,b,z,!1):b.end("This page could not be found"),null);if(J&&!A){let a=!!B.routes[F],b=B.dynamicRoutes[I];if(b&&!1===b.fallback&&!a){if(y.adapterPath)return await K();throw new s.NoFallbackError}}let L=null;!J||u.isDev||A||(L="/index"===(L=F)?"/":L);let M=!0===u.isDev||!J,N=J&&!M;H&&G&&(0,i.setManifestsSingleton)({page:d,clientReferenceManifest:G,serverActionsManifest:H});let O=a.method||"GET",P=(0,h.getTracer)(),Q=P.getActiveScopeSpan(),R=!!(null==C?void 0:C.isWrappedByNextServer),S=!!(0,g.getRequestMeta)(a,"minimalMode"),T=(0,g.getRequestMeta)(a,"incrementalCache")||await u.getIncrementalCache(a,y,B,S);null==T||T.resetRequestCache(),globalThis.__incrementalCache=T;let U={params:x,previewProps:B.preview,renderOpts:{experimental:{authInterrupts:!!y.experimental.authInterrupts,useCacheTimeout:y.experimental.useCacheTimeout},cacheComponents:!!y.cacheComponents,validationLevel:y.experimental.instantInsights.validationLevel,supportsDynamicResponse:M,incrementalCache:T,hmrRefreshHash:(0,g.getRequestMeta)(a,"hmrRefreshHash"),cacheLifeProfiles:y.cacheLife,staticPageGenerationTimeout:y.staticPageGenerationTimeout,waitUntil:c.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:void 0,onInstrumentationRequestError:(b,c,d,e)=>u.onRequestError(a,b,d,e,C)},sharedContext:{buildId:v,deploymentId:w}},V=new k.NodeNextRequest(a),W=new k.NodeNextResponse(b),X=l.NextRequestAdapter.fromNodeNextRequest(V,(0,l.signalFromNodeResponse)(b)),Y=async({previousCacheEntry:e})=>{try{if(!S&&D&&E&&!e)return b.statusCode=404,b.setHeader("x-nextjs-cache","REVALIDATED"),b.end("This page could not be found"),null;let d=await u.handle(X,U);a.fetchMetrics=U.renderOpts.fetchMetrics;let f=U.renderOpts.pendingWaitUntil;f&&c.waitUntil&&(c.waitUntil(f),f=void 0);let g=U.renderOpts.collectedTags;if(!J)return await (0,o.I)(V,W,d,f),null;{let a=await d.blob(),b=(0,p.toNodeOutgoingHttpHeaders)(d.headers);g&&(b[r.NEXT_CACHE_TAGS_HEADER]=g),!b["content-type"]&&a.type&&(b["content-type"]=a.type);let c=void 0!==U.renderOpts.collectedRevalidate&&!(U.renderOpts.collectedRevalidate>=r.INFINITE_CACHE)&&U.renderOpts.collectedRevalidate,e=void 0===U.renderOpts.collectedExpire||U.renderOpts.collectedExpire>=r.INFINITE_CACHE?!1!==c&&c>0?y.expireTime:void 0:U.renderOpts.collectedExpire;return{value:{kind:t.CachedRouteKind.APP_ROUTE,status:d.status,body:Buffer.from(await a.arrayBuffer()),headers:b},cacheControl:{revalidate:c,expire:e}}}}catch(b){throw(null==e?void 0:e.isStale)&&await u.onRequestError(a,b,{routerKind:"App Router",routePath:d,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),b}},Z=async(d,f)=>{try{var g,i;let d=await u.handleResponse({req:a,nextConfig:y,cacheKey:L,routeKind:e.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:B,isRoutePPREnabled:!1,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,responseGenerator:Y,waitUntil:c.waitUntil,isMinimalMode:S});if(!J)return;if((null==d||null==(g=d.value)?void 0:g.kind)!==t.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==d||null==(i=d.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});S||b.setHeader("x-nextjs-cache",D?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),A&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let f=(0,p.fromNodeOutgoingHttpHeaders)(d.value.headers);S&&J||f.delete(r.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||b.getHeader("Cache-Control")||f.get("Cache-Control")||f.set("Cache-Control",(0,q.getCacheControlHeader)(d.cacheControl)),await (0,o.I)(V,W,new Response(d.value.body,{headers:f,status:d.value.status||200}));return}catch(b){if(b instanceof s.NoFallbackError||await u.onRequestError(a,b,{routerKind:"App Router",routePath:I,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),J)throw b;await (0,o.I)(V,W,new Response(null,{status:500}));return}finally{(()=>{if(!d)return;let a=b.statusCode;d.setAttributes({"http.status_code":a,"next.rsc":!1}),a&&a>=500&&(d.setStatus({code:h.SpanStatusCode.ERROR}),d.setAttribute("error.type",a.toString()));let c=P.getRootSpanAttributes();if(!c)return;if(c.get("next.span_type")!==m.BaseServerSpan.handleRequest)return console.warn(`Unexpected root span type '${c.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let e=c.get("next.route")||I,g=`${O} ${e}`;d.setAttributes({"next.route":e,"http.route":e,"next.span_name":g}),d.updateName(g),f&&f!==d&&(f.setAttribute("http.route",e),f.updateName(g))})()}};if(R&&Q)await Z(Q,void 0);else{let b=P.getActiveScopeSpan();await P.withPropagatedContext(a.headers,()=>P.trace(m.BaseServerSpan.handleRequest,{spanName:`${O} ${d}`,kind:h.SpanKind.SERVER,attributes:{"http.method":O,"http.target":a.url}},a=>Z(a,b)),void 0,!R)}}},79646:a=>{"use strict";a.exports=require("child_process")},79748:a=>{"use strict";a.exports=require("fs/promises")},80481:a=>{"use strict";a.exports=require("node:readline")},81115:a=>{"use strict";a.exports=require("constants")},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},87230:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{GET:()=>i});var e=c(23211),f=c(56429),g=c(40402),h=a([f,g]);async function i(a,{params:b}){let{id:c}=await b;try{let a=(0,f.getRpcSession)(c);if(a?.isAlive()){let b=await a.send({type:"get_state"});return e.NextResponse.json({running:!0,state:b})}if(!await (0,g.os)(c))return e.NextResponse.json({error:"Session not found"},{status:404});return e.NextResponse.json({running:!1})}catch(a){return e.NextResponse.json({error:String(a)},{status:500})}}[f,g]=h.then?(await h)():h,d()}catch(a){d(a)}})},94735:a=>{"use strict";a.exports=require("events")},96487:()=>{}};var b=require("../../../../../webpack-runtime.js");b.C(a);var c=b.X(0,[4741,1813,426,974,402,6759,2243,6429],()=>b(b.s=78957));module.exports=c})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(()=>{var a={};a.id=6443,a.ids=[6443],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},8128:a=>{"use strict";a.exports=require("next/dist/server/runtime-reacts.external.js")},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},28354:a=>{"use strict";a.exports=require("util")},29021:a=>{"use strict";a.exports=require("fs")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},33873:a=>{"use strict";a.exports=require("path")},44870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},51455:a=>{"use strict";a.exports=require("node:fs/promises")},55511:a=>{"use strict";a.exports=require("crypto")},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},63610:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{GET:()=>h});var e=c(23211),f=c(79979),g=a([f]);async function h(a,{params:b}){let{id:c}=await b;try{return e.NextResponse.json(await (0,f.v)(c))}catch(a){return e.NextResponse.json({error:String(a)},{status:500})}}f=(g.then?(await g)():g)[0],d()}catch(a){d(a)}})},71715:(a,b,c)=>{"use strict";c.r(b),c.d(b,{handler:()=>z,patchFetch:()=>y,routeModule:()=>u,serverHooks:()=>x,workAsyncStorage:()=>v,workUnitAsyncStorage:()=>w});var d=c(19225),e=c(84006),f=c(8317),g=c(99373),h=c(34775),i=c(24235),j=c(261),k=c(54365),l=c(90771),m=c(73461),n=c(67798),o=c(92280),p=c(62018),q=c(45696),r=c(47929),s=c(86439),t=c(37527);let u=new d.AppRouteRouteModule({definition:{kind:e.RouteKind.APP_ROUTE,page:"/api/sessions/[id]/subagent-usage/route",pathname:"/api/sessions/[id]/subagent-usage",filename:"route",bundlePath:"app/api/sessions/[id]/subagent-usage/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/zhujunshen/pi-web/app/api/sessions/[id]/subagent-usage/route.ts",nextConfigOutput:"",userland:()=>c(63610),...{}}),{workAsyncStorage:v,workUnitAsyncStorage:w,serverHooks:x}=u;function y(){return(0,f.patchFetch)({workAsyncStorage:v,workUnitAsyncStorage:w})}async function z(a,b,c){c.requestMeta&&(0,g.setRequestMeta)(a,c.requestMeta),u.isDev&&(0,g.addRequestMeta)(a,"devRequestTimingInternalsEnd",process.hrtime.bigint());let d="/api/sessions/[id]/subagent-usage/route";"/index"===d&&(d="/");let f=await u.prepare(a,b,{srcPage:d,multiZoneDraftMode:!1});if(!f)return b.statusCode=400,b.end("Bad Request"),null==c.waitUntil||c.waitUntil.call(c,Promise.resolve()),null;let{buildId:v,deploymentId:w,params:x,nextConfig:y,parsedUrl:z,isDraftMode:A,prerenderManifest:B,routerServerContext:C,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,resolvedPathname:F,clientReferenceManifest:G,serverActionsManifest:H}=f,I=(0,j.normalizeAppPath)(d),J=!!(B.dynamicRoutes[I]||B.routes[F]),K=async()=>((null==C?void 0:C.render404)?await C.render404(a,b,z,!1):b.end("This page could not be found"),null);if(J&&!A){let a=!!B.routes[F],b=B.dynamicRoutes[I];if(b&&!1===b.fallback&&!a){if(y.adapterPath)return await K();throw new s.NoFallbackError}}let L=null;!J||u.isDev||A||(L="/index"===(L=F)?"/":L);let M=!0===u.isDev||!J,N=J&&!M;H&&G&&(0,i.setManifestsSingleton)({page:d,clientReferenceManifest:G,serverActionsManifest:H});let O=a.method||"GET",P=(0,h.getTracer)(),Q=P.getActiveScopeSpan(),R=!!(null==C?void 0:C.isWrappedByNextServer),S=!!(0,g.getRequestMeta)(a,"minimalMode"),T=(0,g.getRequestMeta)(a,"incrementalCache")||await u.getIncrementalCache(a,y,B,S);null==T||T.resetRequestCache(),globalThis.__incrementalCache=T;let U={params:x,previewProps:B.preview,renderOpts:{experimental:{authInterrupts:!!y.experimental.authInterrupts,useCacheTimeout:y.experimental.useCacheTimeout},cacheComponents:!!y.cacheComponents,validationLevel:y.experimental.instantInsights.validationLevel,supportsDynamicResponse:M,incrementalCache:T,hmrRefreshHash:(0,g.getRequestMeta)(a,"hmrRefreshHash"),cacheLifeProfiles:y.cacheLife,staticPageGenerationTimeout:y.staticPageGenerationTimeout,waitUntil:c.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:void 0,onInstrumentationRequestError:(b,c,d,e)=>u.onRequestError(a,b,d,e,C)},sharedContext:{buildId:v,deploymentId:w}},V=new k.NodeNextRequest(a),W=new k.NodeNextResponse(b),X=l.NextRequestAdapter.fromNodeNextRequest(V,(0,l.signalFromNodeResponse)(b)),Y=async({previousCacheEntry:e})=>{try{if(!S&&D&&E&&!e)return b.statusCode=404,b.setHeader("x-nextjs-cache","REVALIDATED"),b.end("This page could not be found"),null;let d=await u.handle(X,U);a.fetchMetrics=U.renderOpts.fetchMetrics;let f=U.renderOpts.pendingWaitUntil;f&&c.waitUntil&&(c.waitUntil(f),f=void 0);let g=U.renderOpts.collectedTags;if(!J)return await (0,o.I)(V,W,d,f),null;{let a=await d.blob(),b=(0,p.toNodeOutgoingHttpHeaders)(d.headers);g&&(b[r.NEXT_CACHE_TAGS_HEADER]=g),!b["content-type"]&&a.type&&(b["content-type"]=a.type);let c=void 0!==U.renderOpts.collectedRevalidate&&!(U.renderOpts.collectedRevalidate>=r.INFINITE_CACHE)&&U.renderOpts.collectedRevalidate,e=void 0===U.renderOpts.collectedExpire||U.renderOpts.collectedExpire>=r.INFINITE_CACHE?!1!==c&&c>0?y.expireTime:void 0:U.renderOpts.collectedExpire;return{value:{kind:t.CachedRouteKind.APP_ROUTE,status:d.status,body:Buffer.from(await a.arrayBuffer()),headers:b},cacheControl:{revalidate:c,expire:e}}}}catch(b){throw(null==e?void 0:e.isStale)&&await u.onRequestError(a,b,{routerKind:"App Router",routePath:d,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),b}},Z=async(d,f)=>{try{var g,i;let d=await u.handleResponse({req:a,nextConfig:y,cacheKey:L,routeKind:e.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:B,isRoutePPREnabled:!1,isOnDemandRevalidate:D,revalidateOnlyGenerated:E,responseGenerator:Y,waitUntil:c.waitUntil,isMinimalMode:S});if(!J)return;if((null==d||null==(g=d.value)?void 0:g.kind)!==t.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==d||null==(i=d.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});S||b.setHeader("x-nextjs-cache",D?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),A&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let f=(0,p.fromNodeOutgoingHttpHeaders)(d.value.headers);S&&J||f.delete(r.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||b.getHeader("Cache-Control")||f.get("Cache-Control")||f.set("Cache-Control",(0,q.getCacheControlHeader)(d.cacheControl)),await (0,o.I)(V,W,new Response(d.value.body,{headers:f,status:d.value.status||200}));return}catch(b){if(b instanceof s.NoFallbackError||await u.onRequestError(a,b,{routerKind:"App Router",routePath:I,routeType:"route",revalidateReason:(0,n.getRevalidateReason)({isStaticGeneration:N,isOnDemandRevalidate:D})},!1,C),J)throw b;await (0,o.I)(V,W,new Response(null,{status:500}));return}finally{(()=>{if(!d)return;let a=b.statusCode;d.setAttributes({"http.status_code":a,"next.rsc":!1}),a&&a>=500&&(d.setStatus({code:h.SpanStatusCode.ERROR}),d.setAttribute("error.type",a.toString()));let c=P.getRootSpanAttributes();if(!c)return;if(c.get("next.span_type")!==m.BaseServerSpan.handleRequest)return console.warn(`Unexpected root span type '${c.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let e=c.get("next.route")||I,g=`${O} ${e}`;d.setAttributes({"next.route":e,"http.route":e,"next.span_name":g}),d.updateName(g),f&&f!==d&&(f.setAttribute("http.route",e),f.updateName(g))})()}};if(R&&Q)await Z(Q,void 0);else{let b=P.getActiveScopeSpan();await P.withPropagatedContext(a.headers,()=>P.trace(m.BaseServerSpan.handleRequest,{spanName:`${O} ${d}`,kind:h.SpanKind.SERVER,attributes:{"http.method":O,"http.target":a.url}},a=>Z(a,b)),void 0,!R)}}},73024:a=>{"use strict";a.exports=require("node:fs")},75430:a=>{"use strict";a.exports=import("@earendil-works/pi-coding-agent")},76760:a=>{"use strict";a.exports=require("node:path")},78335:()=>{},79646:a=>{"use strict";a.exports=require("child_process")},79748:a=>{"use strict";a.exports=require("fs/promises")},79979:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{v:()=>j});var e=c(79748),f=c(88914),g=c(40402),h=a([g]);async function i(a){let{size:b,mtimeMs:c}=await (0,e.stat)(a),d=globalThis.__piSubagentUsageCache??=new Map,g=d.get(a);if(g&&g.size===b&&g.mtimeMs===c)return g;let h=(await (0,e.readFile)(a,"utf8")).split("\n").flatMap(a=>{try{return[JSON.parse(a)]}catch{return[]}}),i=(0,f.P)(h),j={size:b,mtimeMs:c,tokens:i.tokens.total,cost:i.cost};return d.set(a,j),j}async function j(a){let b=(await (0,g.dQ)()).filter(b=>b.relation?.kind==="subagent"&&b.relation.parentSessionId===a),c=await Promise.all(b.map(a=>a.path?i(a.path).catch(()=>null):null));return{count:b.length,tokens:c.reduce((a,b)=>a+(b?.tokens??0),0),cost:c.reduce((a,b)=>a+(b?.cost??0),0)}}g=(h.then?(await h)():h)[0],d()}catch(a){d(a)}})},80481:a=>{"use strict";a.exports=require("node:readline")},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},88914:(a,b,c)=>{"use strict";function d(a,b){b&&(a.tokens.input+=b.input??0,a.tokens.output+=b.output??0,a.tokens.cacheRead+=b.cacheRead??0,a.tokens.cacheWrite+=b.cacheWrite??0,a.cost+=b.cost?.total??0,a.costs.input+=b.cost?.input??0,a.costs.output+=b.cost?.output??0,a.costs.cacheRead+=b.cost?.cacheRead??0,a.costs.cacheWrite+=b.cost?.cacheWrite??0)}function e(a){var b;let c={userMessages:0,assistantMessages:0,toolCalls:0,toolResults:0,totalMessages:0,tokens:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0},cost:0,costs:{input:0,output:0,cacheRead:0,cacheWrite:0}};for(let e of a){if("usage"===e.type||"compaction"===e.type||"branch_summary"===e.type){d(c,e.usage);continue}"message"===e.type&&(b=e.message,c.totalMessages+=1,"user"===b.role?c.userMessages+=1:"toolResult"===b.role?(c.toolResults+=1,d(c,b.usage)):"assistant"===b.role&&(c.assistantMessages+=1,Array.isArray(b.content)&&(c.toolCalls+=b.content.filter(a=>"toolCall"===a.type).length),d(c,b.usage)))}return c.tokens.total=c.tokens.input+c.tokens.output+c.tokens.cacheRead+c.tokens.cacheWrite,c}c.d(b,{P:()=>e})},96487:()=>{}};var b=require("../../../../../webpack-runtime.js");b.C(a);var c=b.X(0,[4741,1813,426,402],()=>b(b.s=71715));module.exports=c})();
|