@baique/pi-web-sky 0.1.55 → 0.1.57
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 +8 -4
- package/.next/build-manifest.json +3 -3
- package/.next/prerender-manifest.json +2 -2
- package/.next/react-loadable-manifest.json +2 -2
- package/.next/required-server-files.js +3 -2
- package/.next/required-server-files.json +3 -2
- package/.next/routes-manifest.json +28 -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 -3
- package/.next/server/app/_not-found.segments/_full.segment.rsc +4 -3
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +4 -3
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +3 -2
- package/.next/server/app/api/agent/[id]/bash-output/route.js +2 -2
- package/.next/server/app/api/agent/[id]/events/route.js +2 -2
- package/.next/server/app/api/agent/[id]/events/route.js.nft.json +1 -1
- package/.next/server/app/api/agent/[id]/route.js +1 -1
- package/.next/server/app/api/agent/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/agent/new/route.js +1 -1
- package/.next/server/app/api/agent/new/route.js.nft.json +1 -1
- package/.next/server/app/api/agent/running/route.js +1 -1
- package/.next/server/app/api/agent/running/route.js.nft.json +1 -1
- package/.next/server/app/api/app-update/route.js +1 -1
- package/.next/server/app/api/auth/all-providers/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 +1 -1
- 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/board-assets/[...path]/route.js +2 -2
- package/.next/server/app/api/board-assets/route.js +2 -2
- package/.next/server/app/api/boards/[id]/add-session/route.js +1 -0
- package/.next/server/app/api/boards/[id]/add-session/route.js.nft.json +1 -0
- package/.next/server/app/api/boards/[id]/add-session/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/boards/[id]/reconcile/route.js +1 -1
- package/.next/server/app/api/boards/[id]/route.js +1 -1
- package/.next/server/app/api/boards/reorder/route.js +2 -2
- package/.next/server/app/api/boards/route.js +1 -1
- package/.next/server/app/api/cwd/browse/route.js +1 -1
- package/.next/server/app/api/cwd/validate/route.js +2 -2
- package/.next/server/app/api/default-cwd/route.js +2 -2
- package/.next/server/app/api/file-index/route.js +2 -2
- package/.next/server/app/api/files/[...path]/route.js +3 -3
- package/.next/server/app/api/git/diff/route.js +1 -1
- 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/mcp/route.js +2 -2
- package/.next/server/app/api/models/route.js +2 -2
- 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/route.js +1 -1
- package/.next/server/app/api/models-config/test/route.js +1 -1
- package/.next/server/app/api/plugins/route.js +2 -2
- package/.next/server/app/api/project-trust/route.js +1 -1
- package/.next/server/app/api/project-trust/route.js.nft.json +1 -1
- package/.next/server/app/api/quota/route.js +1 -1
- package/.next/server/app/api/search/route.js +3 -3
- package/.next/server/app/api/sessions/[id]/auto-name/route.js +2 -2
- package/.next/server/app/api/sessions/[id]/auto-name/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/[id]/context/route.js +1 -1
- package/.next/server/app/api/sessions/[id]/context/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/[id]/entries/[entryId]/thinking/route.js +2 -2
- package/.next/server/app/api/sessions/[id]/export/route.js +2 -2
- package/.next/server/app/api/sessions/[id]/minimap/route.js +1 -1
- package/.next/server/app/api/sessions/[id]/minimap/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/[id]/route.js +1 -1
- package/.next/server/app/api/sessions/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/[id]/state/route.js +1 -1
- package/.next/server/app/api/sessions/[id]/state/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/[id]/todos/route.js +1 -1
- package/.next/server/app/api/sessions/[id]/todos/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/route.js +1 -1
- package/.next/server/app/api/sessions/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/summary/route.js +2 -2
- package/.next/server/app/api/skills/check/route.js +1 -1
- package/.next/server/app/api/skills/install/route.js +2 -2
- package/.next/server/app/api/skills/route.js +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/subagents/[id]/route.js +1 -0
- package/.next/server/app/api/subagents/[id]/route.js.nft.json +1 -0
- package/.next/server/app/api/subagents/[id]/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/subagents/profiles/route.js +30 -0
- package/.next/server/app/api/subagents/profiles/route.js.nft.json +1 -0
- package/.next/server/app/api/subagents/profiles/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/subagents/settings/route.js +1 -0
- package/.next/server/app/api/subagents/settings/route.js.nft.json +1 -0
- package/.next/server/app/api/subagents/settings/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/task-card-questions/[id]/answer/route.js +2 -2
- package/.next/server/app/api/task-card-questions/route.js +2 -2
- package/.next/server/app/api/task-cards/[id]/route.js +1 -1
- package/.next/server/app/api/task-cards/route.js +1 -1
- package/.next/server/app/api/task-cards/unbind/route.js +3 -3
- package/.next/server/app/api/task-scheduler/status/route.js +1 -1
- package/.next/server/app/api/task-scheduler/status/route.js.nft.json +1 -1
- package/.next/server/app/api/tasks/[id]/assign-session/route.js +2 -12
- package/.next/server/app/api/tasks/[id]/board/route.js +1 -1
- package/.next/server/app/api/tasks/[id]/route.js +1 -1
- package/.next/server/app/api/tasks/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/tasks/reorder/route.js +2 -12
- package/.next/server/app/api/tasks/route.js +2 -12
- package/.next/server/app/api/terminal/[id]/events/route.js +2 -2
- package/.next/server/app/api/terminal/[id]/route.js +2 -2
- package/.next/server/app/api/terminal/route.js +2 -2
- package/.next/server/app/api/worktrees/route.js +2 -2
- package/.next/server/app/api/yjs-version/route.js +1 -1
- package/.next/server/app/favicon.ico/route.js +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +6 -5
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +6 -5
- package/.next/server/app/index.segments/_full.segment.rsc +6 -5
- package/.next/server/app/index.segments/_tree.segment.rsc +3 -2
- package/.next/server/app/manifest.webmanifest/route.js +2 -2
- package/.next/server/app/page.js +175 -8
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +8 -4
- package/.next/server/chunks/1937.js +14 -13
- package/.next/server/chunks/2524.js +2 -2
- package/.next/server/chunks/3379.js +1 -1
- package/.next/server/chunks/3500.js +1 -1
- package/.next/server/chunks/402.js +28 -7
- package/.next/server/chunks/426.js +14 -0
- package/.next/server/chunks/4367.js +1 -1
- package/.next/server/chunks/4457.js +3 -13
- package/.next/server/chunks/4980.js +1 -1
- package/.next/server/chunks/542.js +23 -4
- package/.next/server/chunks/5794.js +2 -2
- package/.next/server/chunks/5940.js +1 -1
- package/.next/server/chunks/6337.js +1 -1
- package/.next/server/chunks/6429.js +15 -2
- package/.next/server/chunks/6525.js +25 -4
- package/.next/server/chunks/6583.js +12 -11
- package/.next/server/chunks/7048.js +6 -0
- package/.next/server/instrumentation.js +1 -1
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/.next/server/middleware.js +3 -3
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/static/MPBMmQqmDG8zo8tM_bkDy/_buildManifest.js +1 -0
- package/.next/static/chunks/752.bafff304e6b00987.js +1 -0
- package/.next/static/chunks/8088.39866dc5f1d15868.js +1 -0
- package/.next/static/chunks/app/_global-error/page-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/agent/[id]/bash-output/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/agent/[id]/events/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/agent/[id]/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/agent/new/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/agent/running/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/app-update/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/auth/all-providers/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/auth/api-key/[provider]/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/auth/login/[provider]/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/auth/logout/[provider]/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/auth/providers/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/board-assets/[...path]/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/board-assets/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/boards/[id]/add-session/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/boards/[id]/reconcile/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/boards/[id]/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/boards/reorder/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/boards/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/cwd/browse/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/cwd/validate/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/default-cwd/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/file-index/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/files/[...path]/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/git/diff/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/git/status/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/home/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/mcp/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/models/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/models-config/catalog/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/models-config/discover/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/models-config/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/models-config/test/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/plugins/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/project-trust/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/quota/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/search/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/auto-name/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/context/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/entries/[entryId]/thinking/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/export/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/minimap/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/state/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/sessions/[id]/todos/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/sessions/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/sessions/summary/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/skills/check/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/skills/install/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/skills/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/skills/search/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/skills/update/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/subagents/[id]/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/subagents/profiles/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/subagents/settings/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/task-card-questions/[id]/answer/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/task-card-questions/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/task-cards/[id]/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/task-cards/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/task-cards/unbind/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/task-scheduler/status/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/tasks/[id]/assign-session/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/tasks/[id]/board/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/tasks/[id]/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/tasks/reorder/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/tasks/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/terminal/[id]/events/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/terminal/[id]/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/terminal/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/worktrees/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/api/yjs-version/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/layout-fae2b226b3c78448.js +1 -0
- package/.next/static/chunks/app/manifest.webmanifest/route-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/app/page-d5af3bd535589daf.js +256 -0
- package/.next/static/chunks/next/dist/client/components/builtin/app-error-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/forbidden-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/not-found-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-ad6e695deb9de65c.js +1 -0
- package/.next/static/chunks/{webpack-b0effde51c1651b8.js → webpack-1ce35e1249cfd931.js} +1 -1
- package/.next/static/css/bb9361c7f832a89d.css +1 -0
- package/.next/static/css/c7d127e07b1a786c.css +1 -0
- package/.next/trace +8 -7
- package/.next/trace-build +1 -1
- package/.next/types/app/api/boards/[id]/add-session/route.ts +353 -0
- package/.next/types/app/api/subagents/[id]/route.ts +353 -0
- package/.next/types/app/api/subagents/profiles/route.ts +353 -0
- package/.next/types/app/api/subagents/settings/route.ts +353 -0
- package/.next/types/routes.d.ts +5 -1
- package/.next/types/validator.ts +36 -0
- package/lib/api-types.ts +10 -0
- package/lib/board-reconcile.test.mjs +46 -8
- package/lib/board-reconcile.ts +57 -1
- package/lib/board-store.test.mjs +2 -2
- package/lib/chat-lazy-load.test.mjs +0 -62
- package/lib/chat-lazy-load.ts +0 -13
- package/lib/chat-only.ts +23 -0
- package/lib/draft-stash.ts +4 -5
- package/lib/file-types.ts +16 -1
- package/lib/i18n/messages/en.ts +91 -0
- package/lib/i18n/messages/zh-CN.ts +91 -0
- package/lib/id.test.mjs +38 -0
- package/lib/id.ts +17 -0
- package/lib/ime-guard.test.mjs +52 -0
- package/lib/ime-guard.ts +54 -0
- package/lib/message-text.ts +24 -0
- package/lib/models-cache.ts +1 -1
- package/lib/pi-types.ts +19 -1
- package/lib/pin-store.ts +85 -0
- package/lib/powershell-settings.ts +106 -0
- package/lib/quoted-selection.ts +4 -0
- package/lib/rpc-manager.activity.test.mjs +223 -0
- package/lib/rpc-manager.test.mjs +22 -0
- package/lib/rpc-manager.title.test.mjs +152 -0
- package/lib/rpc-manager.ts +301 -28
- package/lib/session-activity.test.mjs +123 -0
- package/lib/session-activity.ts +77 -0
- package/lib/session-delete.test.mjs +45 -41
- package/lib/session-delete.ts +8 -34
- package/lib/session-family.test.mjs +49 -0
- package/lib/session-family.ts +80 -0
- package/lib/session-index-scanner.test.mjs +364 -2
- package/lib/session-index-scanner.ts +199 -55
- package/lib/session-reader.noscan.test.mjs +371 -0
- package/lib/session-reader.project.test.mjs +30 -52
- package/lib/session-reader.test.mjs +2 -65
- package/lib/session-reader.ts +177 -213
- package/lib/session-scanner.test.mjs +151 -38
- package/lib/session-scanner.ts +140 -61
- package/lib/session-search.ts +6 -5
- package/lib/session-time-group.test.mjs +38 -0
- package/lib/session-time-group.ts +55 -0
- package/lib/settings-navigation.ts +124 -0
- package/lib/sqlite-db.test.mjs +26 -0
- package/lib/sqlite-db.ts +10 -1
- package/lib/subagent-extension.test.mjs +424 -0
- package/lib/subagent-extension.ts +309 -0
- package/lib/subagent-input.test.mjs +63 -0
- package/lib/subagent-input.ts +71 -0
- package/lib/subagent-profile-precedence.ts +20 -0
- package/lib/subagent-prompt.test.mjs +64 -0
- package/lib/subagent-prompt.ts +31 -0
- package/lib/subagent-queue.test.mjs +35 -0
- package/lib/subagent-queue.ts +74 -0
- package/lib/subagent-runtime.test.mjs +150 -0
- package/lib/subagent-runtime.ts +629 -0
- package/lib/subagent-session-title.test.mjs +120 -0
- package/lib/subagent-settings.test.mjs +50 -0
- package/lib/subagent-settings.ts +93 -0
- package/lib/subagents.test.mjs +601 -0
- package/lib/subagents.ts +602 -0
- package/lib/task-scheduler.test.mjs +27 -0
- package/lib/task-scheduler.ts +8 -1
- package/lib/task-store.activity.test.mjs +141 -0
- package/lib/task-store.meta-row.test.mjs +25 -5
- package/lib/task-store.partial-row.test.mjs +198 -0
- package/lib/task-store.subtree.test.mjs +172 -0
- package/lib/task-store.test.mjs +46 -20
- package/lib/task-store.ts +344 -68
- package/lib/tool-presets.ts +4 -0
- package/lib/types.ts +19 -0
- package/lib/worktree-isolation.test.mjs +51 -0
- package/next.config.ts +3 -1
- package/package.json +1 -1
- package/.next/static/bsW3fla0-BlBHVMKtAM5I/_buildManifest.js +0 -1
- package/.next/static/chunks/752.0ad92735d5f38143.js +0 -1
- package/.next/static/chunks/8088.53d9cdaf15634d4b.js +0 -1
- package/.next/static/chunks/app/_global-error/page-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/agent/[id]/bash-output/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/agent/[id]/events/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/agent/[id]/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/agent/new/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/agent/running/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/app-update/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/auth/all-providers/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/auth/api-key/[provider]/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/auth/login/[provider]/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/auth/logout/[provider]/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/auth/providers/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/board-assets/[...path]/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/board-assets/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/boards/[id]/reconcile/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/boards/[id]/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/boards/reorder/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/boards/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/cwd/browse/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/cwd/validate/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/default-cwd/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/file-index/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/files/[...path]/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/git/diff/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/git/status/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/home/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/mcp/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/models/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/models-config/catalog/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/models-config/discover/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/models-config/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/models-config/test/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/plugins/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/project-trust/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/quota/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/search/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/sessions/[id]/auto-name/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/sessions/[id]/context/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/sessions/[id]/entries/[entryId]/thinking/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/sessions/[id]/export/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/sessions/[id]/minimap/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/sessions/[id]/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/sessions/[id]/state/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/sessions/[id]/todos/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/sessions/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/sessions/summary/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/skills/check/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/skills/install/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/skills/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/skills/search/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/skills/update/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/task-card-questions/[id]/answer/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/task-card-questions/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/task-cards/[id]/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/task-cards/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/task-cards/unbind/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/task-scheduler/status/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/tasks/[id]/assign-session/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/tasks/[id]/board/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/tasks/[id]/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/tasks/reorder/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/tasks/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/terminal/[id]/events/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/terminal/[id]/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/terminal/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/worktrees/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/api/yjs-version/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/layout-dace09825b2d3857.js +0 -1
- package/.next/static/chunks/app/manifest.webmanifest/route-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/app/page-64b9f4b3567a2f73.js +0 -89
- package/.next/static/chunks/next/dist/client/components/builtin/app-error-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/forbidden-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/not-found-2d5f6296c7e693c6.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-2d5f6296c7e693c6.js +0 -1
- package/.next/static/css/fd25673802257262.css +0 -1
- package/lib/extension-command.test.mjs +0 -63
- package/lib/extension-command.ts +0 -81
- package/lib/subagent-widget.test.mjs +0 -87
- package/lib/subagent-widget.ts +0 -109
- /package/.next/static/{bsW3fla0-BlBHVMKtAM5I → MPBMmQqmDG8zo8tM_bkDy}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// 会话活跃事件 → 数据库写入意图(纯函数,无 IO)
|
|
3
|
+
//
|
|
4
|
+
// 背景:会话列表的「最后一条消息」「最后活跃时间」原先由 30s 扫描器从文件
|
|
5
|
+
// mtime 反推(滞后 ≤30s,且发消息不刷库)。改为事件驱动:一轮循环真正结束
|
|
6
|
+
// 时(agent_settled)把最后一条 assistant 文本与时间戳落库;用户取消走同一条
|
|
7
|
+
// 路径(SDK 会为取消生成 stopReason="aborted" 的 assistant 消息,随后同样
|
|
8
|
+
// 走 turn_end → agent_end → agent_settled)。
|
|
9
|
+
// · agent_start → touch(活跃时间立刻前移,运行中会话浮顶)
|
|
10
|
+
// · message_end(assistant) → 缓存本轮最后一条(不落库;一轮可能多条)
|
|
11
|
+
// · agent_settled → outcome(落 last_reply + modified)
|
|
12
|
+
// 两个边界:
|
|
13
|
+
// · agent_end 一轮里可能多次(重试/compaction/queue 续跑),所以不用它落库;
|
|
14
|
+
// message_end 也不是「循环结束」,单条不落库。
|
|
15
|
+
// · 本轮一条 assistant 文本都没采到(刚发出就被取消、整轮只有工具调用)时,
|
|
16
|
+
// agent_settled 退化为 touch —— **绝不用空文本覆盖已存的 last_reply**。
|
|
17
|
+
// 状态必须**按 wrapper 实例**持有:多个会话并发跑时共享模块级变量会串台。
|
|
18
|
+
// ============================================================================
|
|
19
|
+
|
|
20
|
+
/** 事件里透传的 message(SDK 的 AgentMessage 的最小结构约定)。 */
|
|
21
|
+
export interface AgentLikeMessage {
|
|
22
|
+
role?: string;
|
|
23
|
+
content?: unknown;
|
|
24
|
+
timestamp?: number;
|
|
25
|
+
stopReason?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type SessionActivityEffect =
|
|
29
|
+
| { kind: "touch" }
|
|
30
|
+
| { kind: "outcome"; lastReply: string; at: number };
|
|
31
|
+
|
|
32
|
+
/** assistant 消息的纯文本(text 块拼接;无 text 返回 "")。 */
|
|
33
|
+
export function lastAssistantText(message: AgentLikeMessage): string {
|
|
34
|
+
const content = message.content;
|
|
35
|
+
if (typeof content === "string") return content.trim();
|
|
36
|
+
if (!Array.isArray(content)) return "";
|
|
37
|
+
return content
|
|
38
|
+
.filter((block): block is { type?: string; text?: string } => Boolean(block) && typeof block === "object")
|
|
39
|
+
.filter((block) => block.type === "text" && typeof block.text === "string")
|
|
40
|
+
.map((block) => block.text as string)
|
|
41
|
+
.join("\n")
|
|
42
|
+
.trim();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** 每个 AgentSessionWrapper 持有一个 tracker,内部缓存「本轮最后一条 assistant」。 */
|
|
46
|
+
export function createSessionActivityTracker(): {
|
|
47
|
+
handle(event: { type: string; message?: AgentLikeMessage }): SessionActivityEffect | null;
|
|
48
|
+
} {
|
|
49
|
+
let pending: { lastReply: string; at: number } | null = null;
|
|
50
|
+
return {
|
|
51
|
+
handle(event) {
|
|
52
|
+
if (event.type === "agent_start") return { kind: "touch" };
|
|
53
|
+
if (event.type === "message_end") {
|
|
54
|
+
const message = event.message;
|
|
55
|
+
if (message?.role === "assistant") {
|
|
56
|
+
const text = lastAssistantText(message);
|
|
57
|
+
// 空文本(纯工具轮 / 半截回复)不覆盖已缓存的文本:本轮最后一条有内容的
|
|
58
|
+
// assistant 消息才是「最后一条消息」。
|
|
59
|
+
if (text) {
|
|
60
|
+
pending = {
|
|
61
|
+
lastReply: text,
|
|
62
|
+
at: typeof message.timestamp === "number" ? message.timestamp : Date.now(),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
if (event.type === "agent_settled") {
|
|
69
|
+
const outcome = pending;
|
|
70
|
+
pending = null;
|
|
71
|
+
// 本轮没采到文本 → 只刷活跃时间,让调用方保留库里已有的 last_reply。
|
|
72
|
+
return outcome ? { kind: "outcome", ...outcome } : { kind: "touch" };
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
}
|
|
@@ -1,53 +1,57 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
|
-
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { tmpdir } from "node:os";
|
|
4
|
-
import { join } from "node:path";
|
|
5
2
|
import test from "node:test";
|
|
6
3
|
import { createJiti } from "jiti";
|
|
4
|
+
import { DatabaseSync } from "node:sqlite";
|
|
7
5
|
|
|
8
6
|
const jiti = createJiti(import.meta.url, { interopDefault: true, moduleCache: false });
|
|
9
7
|
const { collectSessionDescendants } = await jiti.import("./session-delete.ts");
|
|
10
|
-
const {
|
|
11
|
-
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return p;
|
|
8
|
+
const { setDbForTesting, getDb } = await jiti.import("./sqlite-db.ts");
|
|
9
|
+
|
|
10
|
+
function freshDb() {
|
|
11
|
+
setDbForTesting(new DatabaseSync(":memory:"));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** 建一行会话索引。collectSessionDescendants 只读 session_meta.parent_id:
|
|
15
|
+
* 盘上有没有文件、文件在哪个目录都不影响(旧实现靠 readdirSync 平铺目录 + 读每个
|
|
16
|
+
* 文件 header 推父链,所以那时必须有文件且必须同目录——见下面「跨目录」用例)。 */
|
|
17
|
+
function seed(id, parentId = null, path = `/nonexistent/${id}.jsonl`) {
|
|
18
|
+
getDb()
|
|
19
|
+
.prepare("INSERT INTO session_meta (session_id, task_id, updated, pinned, path, parent_id) VALUES (?, NULL, 1, 0, ?, ?)")
|
|
20
|
+
.run(id, path, parentId);
|
|
24
21
|
}
|
|
25
22
|
|
|
26
|
-
test("collectSessionDescendants walks the whole fork tree (multi-level)", async () => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const ids = await collectSessionDescendants("root-id");
|
|
37
|
-
assert.deepEqual(ids.sort(), ["root-id", "child1", "child2"].sort());
|
|
38
|
-
assert.ok(!ids.includes("unrelated"));
|
|
39
|
-
} finally {
|
|
40
|
-
rmSync(dir, { recursive: true, force: true });
|
|
41
|
-
}
|
|
23
|
+
test("collectSessionDescendants walks the whole fork tree by DB parent_id (multi-level)", async () => {
|
|
24
|
+
freshDb();
|
|
25
|
+
seed("root-id");
|
|
26
|
+
seed("child1", "root-id");
|
|
27
|
+
seed("child2", "child1"); // 两级分叉:child1 → child2
|
|
28
|
+
seed("unrelated");
|
|
29
|
+
|
|
30
|
+
const ids = await collectSessionDescendants("root-id");
|
|
31
|
+
assert.deepEqual(ids.sort(), ["root-id", "child1", "child2"].sort());
|
|
32
|
+
assert.ok(!ids.includes("unrelated"));
|
|
42
33
|
});
|
|
43
34
|
|
|
44
35
|
test("collectSessionDescendants returns the root alone when there are no forks", async () => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
36
|
+
freshDb();
|
|
37
|
+
seed("root-alone");
|
|
38
|
+
assert.deepEqual(await collectSessionDescendants("root-alone"), ["root-alone"]);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test("collectSessionDescendants 跨目录:子目录里的 fork 也要一起删(旧实现只 readdir 平铺目录会漏)", async () => {
|
|
42
|
+
freshDb();
|
|
43
|
+
// 外部 pi 系工具的布局:`<proj>/<session>/forks/<ts>_<id>.jsonl`。库里 parent_id 已含
|
|
44
|
+
// 全部副本,所以父子的 path 在不同目录、甚至文件早就不在盘上,一样整棵返回。
|
|
45
|
+
seed("root", null, "/proj/2026-01-01T00-00-00Z_root.jsonl");
|
|
46
|
+
seed("fork1", "root", "/proj/2026-01-01T00-00-00Z_root/forks/2026-01-01T00-10-00-000Z_fork1.jsonl");
|
|
47
|
+
seed("fork2", "fork1", "/nonexistent/fork2.jsonl"); // 文件已不在盘上:库里仍要删
|
|
48
|
+
|
|
49
|
+
assert.deepEqual((await collectSessionDescendants("root")).sort(), ["fork1", "fork2", "root"]);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test("collectSessionDescendants 防环:脏 parent_id 环不会死循环", async () => {
|
|
53
|
+
freshDb();
|
|
54
|
+
seed("a", "b");
|
|
55
|
+
seed("b", "a");
|
|
56
|
+
assert.deepEqual((await collectSessionDescendants("a")).sort(), ["a", "b"]);
|
|
53
57
|
});
|
package/lib/session-delete.ts
CHANGED
|
@@ -3,50 +3,24 @@
|
|
|
3
3
|
// 与单个会话删除(app/api/sessions/[id] DELETE)不同:那里删一个节点并把
|
|
4
4
|
// 子树级联重挂到父级;这里整棵树全部删除,不做重挂。
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import { dirname, join } from "path";
|
|
6
|
+
import { unlinkSync } from "fs";
|
|
8
7
|
import {
|
|
9
8
|
invalidateSessionListCache,
|
|
10
9
|
invalidateSessionPathCache,
|
|
11
|
-
readSessionHeader,
|
|
12
10
|
resolveSessionPath,
|
|
13
11
|
} from "./session-reader";
|
|
14
|
-
import { sessionPathKey } from "./session-path";
|
|
15
12
|
import { getRpcSession } from "./rpc-manager";
|
|
16
|
-
import { unassignSession } from "./task-store";
|
|
13
|
+
import { listDescendantIds, unassignSession } from "./task-store";
|
|
17
14
|
import { removeSessionFromBoards } from "./board-store";
|
|
18
15
|
import { removeSessionsFromYjsBoards } from "./board-reconcile";
|
|
19
16
|
|
|
20
|
-
/** 递归收集一个会话的全部 fork 后代 id(含自身)。
|
|
17
|
+
/** 递归收集一个会话的全部 fork 后代 id(含自身)。
|
|
18
|
+
*
|
|
19
|
+
* 父子链以 session_meta.parent_id 为唯一事实源:旧实现 readdirSync 平铺会话目录
|
|
20
|
+
* + 读每个文件 header 推父链,既漏掉子目录里的 fork(`<session>/forks/…`),
|
|
21
|
+
* 也在每次删任务时把整个项目目录读一遍。库里的 parent_id 已含全部副本。 */
|
|
21
22
|
export async function collectSessionDescendants(rootId: string): Promise<string[]> {
|
|
22
|
-
|
|
23
|
-
if (!rootPath) return [rootId];
|
|
24
|
-
const dir = dirname(rootPath);
|
|
25
|
-
const keySet = new Set<string>([sessionPathKey(rootPath)]);
|
|
26
|
-
const ids = [rootId];
|
|
27
|
-
let files: string[];
|
|
28
|
-
try {
|
|
29
|
-
files = readdirSync(dir).filter((f) => f.endsWith(".jsonl"));
|
|
30
|
-
} catch {
|
|
31
|
-
return [rootId];
|
|
32
|
-
}
|
|
33
|
-
// 迭代扫描:parentSession 指向已收集集合的 .jsonl 全部纳入(支持多级分叉)。
|
|
34
|
-
let added = true;
|
|
35
|
-
while (added) {
|
|
36
|
-
added = false;
|
|
37
|
-
for (const file of files) {
|
|
38
|
-
const p = join(dir, file);
|
|
39
|
-
const pk = sessionPathKey(p);
|
|
40
|
-
if (keySet.has(pk)) continue;
|
|
41
|
-
const header = readSessionHeader(p);
|
|
42
|
-
if (header?.parentSession && keySet.has(sessionPathKey(header.parentSession))) {
|
|
43
|
-
keySet.add(pk);
|
|
44
|
-
ids.push(header.id);
|
|
45
|
-
added = true;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return ids;
|
|
23
|
+
return [rootId, ...listDescendantIds(rootId)];
|
|
50
24
|
}
|
|
51
25
|
|
|
52
26
|
/** 删除单个会话文件(含 RPC/路径缓存/列表缓存/任务元数据/画布引用),不重挂子树。 */
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import { createJiti } from "jiti";
|
|
4
|
+
|
|
5
|
+
const { getSessionFamily, listSessionFamilies } = await createJiti(import.meta.url).import("./session-family.ts");
|
|
6
|
+
|
|
7
|
+
function session(id, modified, relation) {
|
|
8
|
+
return {
|
|
9
|
+
path: `/tmp/${id}.jsonl`,
|
|
10
|
+
id,
|
|
11
|
+
cwd: "/tmp",
|
|
12
|
+
created: modified,
|
|
13
|
+
modified,
|
|
14
|
+
messageCount: 1,
|
|
15
|
+
firstMessage: id,
|
|
16
|
+
...(relation ? { relation } : {}),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
test("groups nested subagents under their main session and uses family activity for sorting", () => {
|
|
21
|
+
const main = session("main", "2026-01-01T00:00:00.000Z");
|
|
22
|
+
const child = session("child", "2026-01-04T00:00:00.000Z", {
|
|
23
|
+
kind: "subagent", parentSessionId: "main", profile: "explore", description: "Explore", status: "completed",
|
|
24
|
+
});
|
|
25
|
+
const grandchild = session("grandchild", "2026-01-03T00:00:00.000Z", {
|
|
26
|
+
kind: "subagent", parentSessionId: "child", profile: "review", description: "Review", status: "running",
|
|
27
|
+
});
|
|
28
|
+
const newerRoot = session("newer-root", "2026-01-02T00:00:00.000Z");
|
|
29
|
+
|
|
30
|
+
const families = listSessionFamilies([main, child, grandchild, newerRoot]);
|
|
31
|
+
assert.deepEqual(families.map((family) => family.root.id), ["main", "newer-root"]);
|
|
32
|
+
assert.deepEqual(families[0].subagents.map((item) => item.id), ["child", "grandchild"]);
|
|
33
|
+
assert.equal(getSessionFamily([main, child, grandchild], "grandchild")?.root.id, "main");
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test("does not promote orphaned or cyclic subagent metadata into the main session list", () => {
|
|
37
|
+
const orphan = session("orphan", "2026-01-03T00:00:00.000Z", {
|
|
38
|
+
kind: "subagent", parentSessionId: "missing", profile: "explore", description: "Explore", status: "interrupted",
|
|
39
|
+
});
|
|
40
|
+
const a = session("a", "2026-01-01T00:00:00.000Z", {
|
|
41
|
+
kind: "subagent", parentSessionId: "b", profile: "a", description: "A", status: "interrupted",
|
|
42
|
+
});
|
|
43
|
+
const b = session("b", "2026-01-02T00:00:00.000Z", {
|
|
44
|
+
kind: "subagent", parentSessionId: "a", profile: "b", description: "B", status: "interrupted",
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
assert.deepEqual(listSessionFamilies([orphan, a, b]), []);
|
|
48
|
+
assert.equal(getSessionFamily([orphan, a, b], "orphan"), null);
|
|
49
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { SessionInfo } from "./types";
|
|
2
|
+
|
|
3
|
+
export interface SessionFamily {
|
|
4
|
+
root: SessionInfo;
|
|
5
|
+
subagents: SessionInfo[];
|
|
6
|
+
latestModified: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function resolveFamilyRoots(sessions: readonly SessionInfo[]): Map<string, string | null> {
|
|
10
|
+
const byId = new Map(sessions.map((session) => [session.id, session]));
|
|
11
|
+
const roots = new Map<string, string | null>();
|
|
12
|
+
|
|
13
|
+
for (const session of sessions) {
|
|
14
|
+
if (roots.has(session.id)) continue;
|
|
15
|
+
|
|
16
|
+
const path: string[] = [];
|
|
17
|
+
const visited = new Set<string>();
|
|
18
|
+
let currentId = session.id;
|
|
19
|
+
let rootId: string | null = null;
|
|
20
|
+
|
|
21
|
+
while (true) {
|
|
22
|
+
if (roots.has(currentId)) {
|
|
23
|
+
rootId = roots.get(currentId) ?? null;
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
if (visited.has(currentId)) break;
|
|
27
|
+
|
|
28
|
+
visited.add(currentId);
|
|
29
|
+
path.push(currentId);
|
|
30
|
+
const current = byId.get(currentId);
|
|
31
|
+
if (!current) break;
|
|
32
|
+
if (current.relation?.kind !== "subagent") {
|
|
33
|
+
rootId = current.id;
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
currentId = current.relation.parentSessionId;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
for (const id of path) roots.set(id, rootId);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return roots;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Groups visible main/fork sessions with every persisted subagent descendant. */
|
|
46
|
+
export function listSessionFamilies(sessions: readonly SessionInfo[]): SessionFamily[] {
|
|
47
|
+
const rootsBySessionId = resolveFamilyRoots(sessions);
|
|
48
|
+
const families = new Map<string, SessionFamily>();
|
|
49
|
+
|
|
50
|
+
for (const session of sessions) {
|
|
51
|
+
if (session.relation?.kind === "subagent") continue;
|
|
52
|
+
families.set(session.id, {
|
|
53
|
+
root: session,
|
|
54
|
+
subagents: [],
|
|
55
|
+
latestModified: session.modified,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
for (const session of sessions) {
|
|
60
|
+
if (session.relation?.kind !== "subagent") continue;
|
|
61
|
+
const rootId = rootsBySessionId.get(session.id);
|
|
62
|
+
const family = rootId ? families.get(rootId) : undefined;
|
|
63
|
+
if (!family) continue;
|
|
64
|
+
family.subagents.push(session);
|
|
65
|
+
if (session.modified > family.latestModified) family.latestModified = session.modified;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return [...families.values()].sort((a, b) => b.latestModified.localeCompare(a.latestModified));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function getSessionFamily(
|
|
72
|
+
sessions: readonly SessionInfo[],
|
|
73
|
+
sessionId: string | null | undefined,
|
|
74
|
+
): SessionFamily | null {
|
|
75
|
+
if (!sessionId) return null;
|
|
76
|
+
return listSessionFamilies(sessions).find((family) => (
|
|
77
|
+
family.root.id === sessionId
|
|
78
|
+
|| family.subagents.some((session) => session.id === sessionId)
|
|
79
|
+
)) ?? null;
|
|
80
|
+
}
|