vibepulse 0.2.2 → 0.3.1-beta
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 +1 -0
- package/.next/build-manifest.json +2 -2
- package/.next/cache/.previewinfo +1 -1
- package/.next/cache/.rscinfo +1 -1
- package/.next/cache/.tsbuildinfo +1 -1
- package/.next/cache/config.json +3 -3
- package/.next/fallback-build-manifest.json +2 -2
- package/.next/prerender-manifest.json +3 -3
- package/.next/routes-manifest.json +8 -0
- package/.next/server/app/_global-error/page.js +1 -1
- package/.next/server/app/_global-error/page.js.nft.json +1 -1
- package/.next/server/app/_global-error.html +2 -2
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_index.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.js.nft.json +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +2 -2
- package/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/api/node/events/route.js +2 -2
- package/.next/server/app/api/node/events/route.js.nft.json +1 -1
- package/.next/server/app/api/node/sessions/[id]/delete/route.js +2 -2
- package/.next/server/app/api/node/sessions/[id]/delete/route.js.nft.json +1 -1
- package/.next/server/app/api/node/sessions/[id]/open-editor/route.js +2 -2
- package/.next/server/app/api/node/sessions/[id]/open-editor/route.js.nft.json +1 -1
- package/.next/server/app/api/node/sessions/route.js +6 -4
- package/.next/server/app/api/node/sessions/route.js.nft.json +1 -1
- package/.next/server/app/api/nodes/route.js +2 -2
- package/.next/server/app/api/nodes/route.js.nft.json +1 -1
- package/.next/server/app/api/opencode-config/route.js +2 -2
- package/.next/server/app/api/opencode-config/route.js.nft.json +1 -1
- package/.next/server/app/api/opencode-config/status/route.js +2 -2
- package/.next/server/app/api/opencode-config/status/route.js.nft.json +1 -1
- package/.next/server/app/api/opencode-events/route.js +3 -3
- package/.next/server/app/api/opencode-events/route.js.nft.json +1 -1
- package/.next/server/app/api/profiles/[id]/apply/route.js +2 -2
- package/.next/server/app/api/profiles/[id]/apply/route.js.nft.json +1 -1
- package/.next/server/app/api/profiles/[id]/export/route.js +2 -2
- package/.next/server/app/api/profiles/[id]/export/route.js.nft.json +1 -1
- package/.next/server/app/api/profiles/[id]/route.js +2 -2
- package/.next/server/app/api/profiles/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/profiles/import/route.js +2 -2
- package/.next/server/app/api/profiles/import/route.js.nft.json +1 -1
- package/.next/server/app/api/profiles/route.js +2 -2
- package/.next/server/app/api/profiles/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/[id]/archive/route.js +3 -2
- package/.next/server/app/api/sessions/[id]/archive/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/[id]/delete/route.js +4 -3
- package/.next/server/app/api/sessions/[id]/delete/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/[id]/open-editor/route.js +2 -2
- package/.next/server/app/api/sessions/[id]/open-editor/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/[id]/restore/route/app-paths-manifest.json +3 -0
- package/.next/server/app/api/sessions/[id]/restore/route/build-manifest.json +11 -0
- package/.next/server/app/api/sessions/[id]/restore/route/server-reference-manifest.json +4 -0
- package/.next/server/app/api/sessions/[id]/restore/route.js +8 -0
- package/.next/server/app/api/sessions/[id]/restore/route.js.map +5 -0
- package/.next/server/app/api/sessions/[id]/restore/route.js.nft.json +1 -0
- package/.next/server/app/api/sessions/[id]/restore/route_client-reference-manifest.js +2 -0
- package/.next/server/app/api/sessions/[id]/route.js +2 -2
- package/.next/server/app/api/sessions/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/sessions/route.js +5 -3
- package/.next/server/app/api/sessions/route.js.nft.json +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +3 -3
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/index.segments/_full.segment.rsc +3 -3
- package/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/server/app/index.segments/_index.segment.rsc +2 -2
- package/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +1 -0
- package/.next/server/chunks/[root-of-the-server]__005eb0c5._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__005eb0c5._.js.map +1 -0
- package/.next/server/chunks/[root-of-the-server]__09e90d57._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__09e90d57._.js.map +1 -0
- package/.next/server/chunks/[root-of-the-server]__18dd0ce9._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__18dd0ce9._.js.map +1 -0
- package/.next/server/chunks/[root-of-the-server]__19468536._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__19468536._.js.map +1 -0
- package/.next/server/chunks/[root-of-the-server]__1b87ec42._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__1b87ec42._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__2b912935._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__2b912935._.js.map +1 -0
- package/.next/server/chunks/[root-of-the-server]__303d3bac._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__303d3bac._.js.map +1 -0
- package/.next/server/chunks/[root-of-the-server]__3fac2b91._.js +5 -0
- package/.next/server/chunks/[root-of-the-server]__3fac2b91._.js.map +1 -0
- package/.next/server/chunks/[root-of-the-server]__43440b8d._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__43440b8d._.js.map +1 -0
- package/.next/server/chunks/[root-of-the-server]__438f8bbe._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__438f8bbe._.js.map +1 -0
- package/.next/server/chunks/[root-of-the-server]__4a0bfb55._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__4a0bfb55._.js.map +1 -0
- package/.next/server/chunks/[root-of-the-server]__534c3949._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__534c3949._.js.map +1 -0
- package/.next/server/chunks/[root-of-the-server]__59160266._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__59160266._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__6f812da0._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__6f812da0._.js.map +1 -0
- package/.next/server/chunks/[root-of-the-server]__71aac504._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__71aac504._.js.map +1 -0
- package/.next/server/chunks/[root-of-the-server]__907a8bf2._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__907a8bf2._.js.map +1 -0
- package/.next/server/chunks/[root-of-the-server]__92089220._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__92089220._.js.map +1 -0
- package/.next/server/chunks/[root-of-the-server]__9b7bc2d0._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__9b7bc2d0._.js.map +1 -0
- package/.next/server/chunks/[root-of-the-server]__b2640944._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__b2640944._.js.map +1 -0
- package/.next/server/chunks/[root-of-the-server]__c2267cf1._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__c2267cf1._.js.map +1 -0
- package/.next/server/chunks/[root-of-the-server]__d7f7e6dd._.js +3 -0
- package/.next/server/chunks/{[root-of-the-server]__6924c09d._.js.map → [root-of-the-server]__d7f7e6dd._.js.map} +1 -1
- package/.next/server/chunks/[root-of-the-server]__d8e61048._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__d8e61048._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__f6d0d488._.js +3 -0
- package/.next/server/chunks/{[root-of-the-server]__192ed2f4._.js.map → [root-of-the-server]__f6d0d488._.js.map} +1 -1
- package/.next/server/chunks/[root-of-the-server]__fa559e1e._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__fa559e1e._.js.map +1 -0
- package/.next/server/chunks/_next-internal_server_app_api_sessions_[id]_restore_route_actions_af7d6b6c.js +3 -0
- package/.next/server/chunks/_next-internal_server_app_api_sessions_[id]_restore_route_actions_af7d6b6c.js.map +1 -0
- package/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_7e181e75.js +1 -1
- package/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_7e181e75.js.map +1 -1
- package/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_aca45402.js +1 -1
- package/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_aca45402.js.map +1 -1
- package/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_b054aff3.js +1 -1
- package/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_b054aff3.js.map +1 -1
- package/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_fa835ac3.js +2 -2
- package/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_fa835ac3.js.map +1 -1
- package/.next/server/chunks/src_lib_opencodeConfig_ts_8e209941._.js +3 -0
- package/.next/server/chunks/src_lib_opencodeConfig_ts_8e209941._.js.map +1 -0
- package/.next/server/chunks/src_lib_session-providers_claudeCode_ts_0f9590ed._.js +3 -0
- package/.next/server/chunks/src_lib_session-providers_claudeCode_ts_0f9590ed._.js.map +1 -0
- package/.next/server/chunks/ssr/{[root-of-the-server]__631e12d0._.js → [root-of-the-server]__c91a8380._.js} +2 -2
- package/.next/server/chunks/ssr/{[root-of-the-server]__631e12d0._.js.map → [root-of-the-server]__c91a8380._.js.map} +1 -1
- package/.next/server/chunks/ssr/src_app_page_tsx_a7111f3e._.js +3 -3
- package/.next/server/chunks/ssr/src_app_page_tsx_a7111f3e._.js.map +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +2 -2
- package/.next/server/server-reference-manifest.js +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/BUILD_ID +1 -1
- package/.next/standalone/.next/app-path-routes-manifest.json +1 -0
- package/.next/standalone/.next/build-manifest.json +2 -2
- package/.next/standalone/.next/prerender-manifest.json +3 -3
- package/.next/standalone/.next/routes-manifest.json +8 -0
- package/.next/standalone/.next/server/app/_global-error/page.js +1 -1
- package/.next/standalone/.next/server/app/_global-error/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/_global-error.html +2 -2
- package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found/page.js +1 -1
- package/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_not-found.html +1 -1
- package/.next/standalone/.next/server/app/_not-found.rsc +2 -2
- package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/api/node/events/route.js +2 -2
- package/.next/standalone/.next/server/app/api/node/events/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/node/sessions/[id]/delete/route.js +2 -2
- package/.next/standalone/.next/server/app/api/node/sessions/[id]/delete/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/node/sessions/[id]/open-editor/route.js +2 -2
- package/.next/standalone/.next/server/app/api/node/sessions/[id]/open-editor/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/node/sessions/route.js +6 -4
- package/.next/standalone/.next/server/app/api/node/sessions/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/nodes/route.js +2 -2
- package/.next/standalone/.next/server/app/api/nodes/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/opencode-config/route.js +2 -2
- package/.next/standalone/.next/server/app/api/opencode-config/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/opencode-config/status/route.js +2 -2
- package/.next/standalone/.next/server/app/api/opencode-config/status/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/opencode-events/route.js +3 -3
- package/.next/standalone/.next/server/app/api/opencode-events/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/profiles/[id]/apply/route.js +2 -2
- package/.next/standalone/.next/server/app/api/profiles/[id]/apply/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/profiles/[id]/export/route.js +2 -2
- package/.next/standalone/.next/server/app/api/profiles/[id]/export/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/profiles/[id]/route.js +2 -2
- package/.next/standalone/.next/server/app/api/profiles/[id]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/profiles/import/route.js +2 -2
- package/.next/standalone/.next/server/app/api/profiles/import/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/profiles/route.js +2 -2
- package/.next/standalone/.next/server/app/api/profiles/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/sessions/[id]/archive/route.js +3 -2
- package/.next/standalone/.next/server/app/api/sessions/[id]/archive/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/sessions/[id]/delete/route.js +4 -3
- package/.next/standalone/.next/server/app/api/sessions/[id]/delete/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/sessions/[id]/open-editor/route.js +2 -2
- package/.next/standalone/.next/server/app/api/sessions/[id]/open-editor/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/sessions/[id]/restore/route/app-paths-manifest.json +3 -0
- package/.next/standalone/.next/server/app/api/sessions/[id]/restore/route/build-manifest.json +11 -0
- package/.next/standalone/.next/server/app/api/sessions/[id]/restore/route/server-reference-manifest.json +4 -0
- package/.next/standalone/.next/server/app/api/sessions/[id]/restore/route.js +8 -0
- package/.next/standalone/.next/server/app/api/sessions/[id]/restore/route.js.map +5 -0
- package/.next/standalone/.next/server/app/api/sessions/[id]/restore/route.js.nft.json +1 -0
- package/.next/standalone/.next/server/app/api/sessions/[id]/restore/route_client-reference-manifest.js +2 -0
- package/.next/standalone/.next/server/app/api/sessions/[id]/route.js +2 -2
- package/.next/standalone/.next/server/app/api/sessions/[id]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/sessions/route.js +5 -3
- package/.next/standalone/.next/server/app/api/sessions/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/index.html +1 -1
- package/.next/standalone/.next/server/app/index.rsc +3 -3
- package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/index.segments/_index.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app-paths-manifest.json +1 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__005eb0c5._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__09e90d57._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__18dd0ce9._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__19468536._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__1b87ec42._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__2b912935._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__303d3bac._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__3fac2b91._.js +5 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__43440b8d._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__438f8bbe._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__4a0bfb55._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__534c3949._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__59160266._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__6f812da0._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__71aac504._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__907a8bf2._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__92089220._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__9b7bc2d0._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__b2640944._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__c2267cf1._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__d7f7e6dd._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__d8e61048._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__f6d0d488._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__fa559e1e._.js +3 -0
- package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_sessions_[id]_restore_route_actions_af7d6b6c.js +3 -0
- package/.next/standalone/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_7e181e75.js +1 -1
- package/.next/standalone/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_aca45402.js +1 -1
- package/.next/standalone/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_b054aff3.js +1 -1
- package/.next/standalone/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_fa835ac3.js +2 -2
- package/.next/standalone/.next/server/chunks/src_lib_opencodeConfig_ts_8e209941._.js +3 -0
- package/.next/standalone/.next/server/chunks/src_lib_session-providers_claudeCode_ts_0f9590ed._.js +3 -0
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__631e12d0._.js → [root-of-the-server]__c91a8380._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/src_app_page_tsx_a7111f3e._.js +3 -3
- package/.next/standalone/.next/server/pages/404.html +1 -1
- package/.next/standalone/.next/server/pages/500.html +2 -2
- package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/static/chunks/9e790b67c80f853c.js +13 -0
- package/.next/standalone/.next/static/chunks/c3dc8cd80979c971.css +3 -0
- package/.next/standalone/AGENTS.md +4 -0
- package/.next/standalone/README.md +54 -5
- package/.next/standalone/check-hsql.mjs +1 -1
- package/.next/standalone/docs/session-status-detection.md +36 -0
- package/.next/standalone/docs/superpowers/specs/2026-04-09-claude-capability-alignment-design.md +39 -0
- package/.next/standalone/eslint.config.mjs +1 -0
- package/.next/standalone/package-lock.json +74 -13
- package/.next/standalone/package.json +2 -2
- package/.next/standalone/src/app/api/node/events/route.ts +3 -3
- package/.next/standalone/src/app/api/node/sessions/[id]/archive/route.test.ts +60 -1
- package/.next/standalone/src/app/api/node/sessions/[id]/archive/route.ts +77 -22
- package/.next/standalone/src/app/api/node/sessions/[id]/delete/route.ts +6 -5
- package/.next/standalone/src/app/api/node/sessions/[id]/open-editor/route.ts +6 -5
- package/.next/standalone/src/app/api/node/sessions/route.test.ts +282 -0
- package/.next/standalone/src/app/api/node/sessions/route.ts +156 -30
- package/.next/standalone/src/app/api/opencode-config/route.test.ts +613 -0
- package/.next/standalone/src/app/api/opencode-config/route.ts +336 -185
- package/.next/standalone/src/app/api/opencode-events/route.test.ts +77 -1
- package/.next/standalone/src/app/api/opencode-events/route.ts +3 -3
- package/.next/standalone/src/app/api/opencode-models/route.test.ts +19 -0
- package/.next/standalone/src/app/api/opencode-models/route.ts +4 -1
- package/.next/standalone/src/app/api/profiles/[id]/apply/route.test.ts +227 -0
- package/.next/standalone/src/app/api/profiles/[id]/apply/route.ts +13 -9
- package/.next/standalone/src/app/api/sessions/[id]/archive/route.test.ts +126 -0
- package/.next/standalone/src/app/api/sessions/[id]/archive/route.ts +47 -12
- package/.next/standalone/src/app/api/sessions/[id]/delete/route.test.ts +140 -0
- package/.next/standalone/src/app/api/sessions/[id]/delete/route.ts +51 -16
- package/.next/standalone/src/app/api/sessions/[id]/open-editor/route.test.ts +74 -0
- package/.next/standalone/src/app/api/sessions/[id]/open-editor/route.ts +22 -2
- package/.next/standalone/src/app/api/sessions/[id]/restore/route.test.ts +186 -0
- package/.next/standalone/src/app/api/sessions/[id]/restore/route.ts +184 -0
- package/.next/standalone/src/app/api/sessions/[id]/route.ts +3 -3
- package/.next/standalone/src/app/api/sessions/route.test.ts +1955 -100
- package/.next/standalone/src/app/api/sessions/route.ts +361 -986
- package/.next/standalone/src/components/KanbanBoard.test.tsx +307 -1
- package/.next/standalone/src/components/KanbanBoard.tsx +106 -19
- package/.next/standalone/src/components/ProjectCard.test.tsx +420 -6
- package/.next/standalone/src/components/ProjectCard.tsx +238 -86
- package/.next/standalone/src/components/SessionCard.test.tsx +259 -8
- package/.next/standalone/src/components/SessionCard.tsx +182 -76
- package/.next/standalone/src/components/opencode-config/AgentConfigForm.test.tsx +141 -1
- package/.next/standalone/src/components/opencode-config/AgentConfigForm.tsx +99 -7
- package/.next/standalone/src/components/opencode-config/GeneralSettingsForm.test.tsx +11 -0
- package/.next/standalone/src/components/opencode-config/GeneralSettingsForm.tsx +41 -2
- package/.next/standalone/src/components/opencode-config/categories/CategoriesManager.tsx +3 -1
- package/.next/standalone/src/components/opencode-config/categories/CategoryConfigForm.test.tsx +106 -8
- package/.next/standalone/src/components/opencode-config/categories/CategoryConfigForm.tsx +82 -5
- package/.next/standalone/src/hooks/useHostSources.test.ts +0 -41
- package/.next/standalone/src/hooks/useOpencodeSync.test.ts +321 -1
- package/.next/standalone/src/hooks/useOpencodeSync.ts +16 -12
- package/.next/standalone/src/lib/claudeSessionOverrides.test.ts +75 -0
- package/.next/standalone/src/lib/claudeSessionOverrides.ts +169 -0
- package/.next/standalone/src/lib/fixtures/opencode-config/oh-my-openagent.v4.jsonc +70 -0
- package/.next/standalone/src/lib/fixtures/opencode-config/oh-my-openagent.v4.secret-like.jsonc +21 -0
- package/.next/standalone/src/lib/fixtures/opencode-config/oh-my-opencode.v3.jsonc +17 -0
- package/.next/standalone/src/lib/opencodeConfig.test.ts +430 -3
- package/.next/standalone/src/lib/opencodeConfig.ts +157 -4
- package/.next/standalone/src/lib/opencodeDiscovery.test.ts +241 -0
- package/.next/standalone/src/lib/opencodeDiscovery.ts +164 -9
- package/.next/standalone/src/lib/profiles/share.test.ts +92 -0
- package/.next/standalone/src/lib/profiles/share.ts +1 -0
- package/.next/standalone/src/lib/profiles/storage.test.ts +77 -1
- package/.next/standalone/src/lib/profiles/storage.ts +10 -9
- package/.next/standalone/src/lib/session-providers/claudeCode.test.ts +2288 -0
- package/.next/standalone/src/lib/session-providers/claudeCode.ts +1083 -0
- package/.next/standalone/src/lib/session-providers/localAggregator.test.ts +322 -0
- package/.next/standalone/src/lib/session-providers/localAggregator.ts +302 -0
- package/.next/standalone/src/lib/session-providers/opencodeProvider.test.ts +170 -0
- package/.next/standalone/src/lib/session-providers/opencodeProvider.ts +721 -0
- package/.next/standalone/src/lib/session-providers/opencodeSdkCompat.ts +92 -0
- package/.next/standalone/src/lib/session-providers/providerIds.test.ts +337 -0
- package/.next/standalone/src/lib/session-providers/providerIds.ts +176 -0
- package/.next/standalone/src/lib/session-providers/types.ts +131 -0
- package/.next/standalone/src/lib/transform.test.ts +253 -0
- package/.next/standalone/src/lib/transform.ts +96 -37
- package/.next/standalone/src/types/index.ts +23 -17
- package/.next/standalone/src/types/opencodeConfig.ts +55 -0
- package/.next/static/chunks/9e790b67c80f853c.js +13 -0
- package/.next/static/chunks/c3dc8cd80979c971.css +3 -0
- package/.next/trace +1 -1
- package/.next/trace-build +1 -1
- package/.next/types/routes.d.ts +2 -1
- package/.next/types/validator.ts +9 -0
- package/README.md +54 -5
- package/package.json +2 -2
- package/.next/server/chunks/[root-of-the-server]__1211da38._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__1211da38._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__192ed2f4._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__2b526e7a._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__2b526e7a._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__2f981540._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__2f981540._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__3745b314._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__3745b314._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__56690af0._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__56690af0._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__56f5f249._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__56f5f249._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__59175de4._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__59175de4._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__64fffc02._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__64fffc02._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__6924c09d._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__6c428a24._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__6c428a24._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__73a00b88._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__73a00b88._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__7e757f50._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__7e757f50._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__89c5eeab._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__89c5eeab._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__8da6c5a8._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__8da6c5a8._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__b796d06c._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__b796d06c._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__c2ce5c0f._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__c2ce5c0f._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__db285678._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__db285678._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__e00a9200._.js +0 -5
- package/.next/server/chunks/[root-of-the-server]__e00a9200._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__e5df5e5f._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__e5df5e5f._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__edbc8d9e._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__edbc8d9e._.js.map +0 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__1211da38._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__192ed2f4._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__2b526e7a._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__2f981540._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__3745b314._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__56690af0._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__56f5f249._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__59175de4._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__64fffc02._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__6924c09d._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__6c428a24._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__73a00b88._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__7e757f50._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__89c5eeab._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__8da6c5a8._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__b796d06c._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__c2ce5c0f._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__db285678._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__e00a9200._.js +0 -5
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__e5df5e5f._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__edbc8d9e._.js +0 -3
- package/.next/standalone/.next/static/chunks/65d5354ba0add961.js +0 -13
- package/.next/standalone/.next/static/chunks/f42202943f6742e5.css +0 -3
- package/.next/static/chunks/65d5354ba0add961.js +0 -13
- package/.next/static/chunks/f42202943f6742e5.css +0 -3
- /package/.next/standalone/.next/static/{5kq9DtuBFVxu4jsgmL5Q- → 0WaQ6UjiNBgvh531pJVh0}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{5kq9DtuBFVxu4jsgmL5Q- → 0WaQ6UjiNBgvh531pJVh0}/_clientMiddlewareManifest.json +0 -0
- /package/.next/standalone/.next/static/{5kq9DtuBFVxu4jsgmL5Q- → 0WaQ6UjiNBgvh531pJVh0}/_ssgManifest.js +0 -0
- /package/.next/static/{5kq9DtuBFVxu4jsgmL5Q- → 0WaQ6UjiNBgvh531pJVh0}/_buildManifest.js +0 -0
- /package/.next/static/{5kq9DtuBFVxu4jsgmL5Q- → 0WaQ6UjiNBgvh531pJVh0}/_clientMiddlewareManifest.json +0 -0
- /package/.next/static/{5kq9DtuBFVxu4jsgmL5Q- → 0WaQ6UjiNBgvh531pJVh0}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,1083 @@
|
|
|
1
|
+
import { constants, type Dirent, type Stats } from 'fs';
|
|
2
|
+
import { access, open, readdir, realpath, stat, type FileHandle } from 'fs/promises';
|
|
3
|
+
import { homedir } from 'os';
|
|
4
|
+
import { basename, join } from 'path';
|
|
5
|
+
import { listClaudeSessionOverrides } from '@/lib/claudeSessionOverrides';
|
|
6
|
+
import type { ChildEntry, LocalSessionProvider, ProviderTopology, SessionsRouteResult } from './types';
|
|
7
|
+
import { namespaceClaudeRawId, READONLY_PROVIDER_CONTEXT } from './providerIds';
|
|
8
|
+
|
|
9
|
+
const DEFAULT_SMALL_FILE_LIMIT_BYTES = 128 * 1024;
|
|
10
|
+
const DEFAULT_JSONL_HEAD_LIMIT_BYTES = 64 * 1024;
|
|
11
|
+
const DEFAULT_JSONL_HEAD_RETRY_LIMIT_BYTES = 256 * 1024;
|
|
12
|
+
const DEFAULT_SESSION_TITLE_MAX_CHARS = 72;
|
|
13
|
+
const DEFAULT_BUSY_ACTIVITY_WINDOW_MS = 10 * 1000;
|
|
14
|
+
const DEFAULT_WAITING_FOR_USER_WINDOW_MS = 10 * 60 * 1000;
|
|
15
|
+
const CLAUDE_PROJECTS_DIR = 'projects';
|
|
16
|
+
const CLAUDE_SESSIONS_DIR = 'sessions';
|
|
17
|
+
const PROJECT_INDEX_FILE = 'sessions-index.json';
|
|
18
|
+
const CLAUDE_TITLE_WRAPPER_TAGS = ['command-message', 'local-command-caveat'] as const;
|
|
19
|
+
const CLAUDE_TITLE_NOISE_PATTERNS = [
|
|
20
|
+
/^\s*<ide_[a-z0-9_-]+(?=[\s>/]|$)/i,
|
|
21
|
+
/^the\s+user\s+opened\s+(?:\.\.\/|\.\/|~\/|\/|[a-zA-Z]:[\\/])/i,
|
|
22
|
+
] as const;
|
|
23
|
+
|
|
24
|
+
function stripKnownClaudeTitleWrappers(title: string): string {
|
|
25
|
+
let normalized = title;
|
|
26
|
+
|
|
27
|
+
for (const tagName of CLAUDE_TITLE_WRAPPER_TAGS) {
|
|
28
|
+
const openTagFragment = new RegExp(`<${tagName}(?=[\\s>/]|$)\\s*/?>?`, 'ig');
|
|
29
|
+
const closeTagFragment = new RegExp(`</${tagName}(?=[\\s>]|$)\\s*>?`, 'ig');
|
|
30
|
+
|
|
31
|
+
normalized = normalized.replace(openTagFragment, ' ').replace(closeTagFragment, ' ');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return normalized.trim();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function normalizeSessionTitle(title: string): string {
|
|
38
|
+
const compact = stripKnownClaudeTitleWrappers(title).replace(/\s+/g, ' ').trim();
|
|
39
|
+
if (compact.length <= DEFAULT_SESSION_TITLE_MAX_CHARS) {
|
|
40
|
+
return compact;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return `${compact.slice(0, DEFAULT_SESSION_TITLE_MAX_CHARS - 3)}...`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function toClaudeTitleCandidate(rawText: string): string | null {
|
|
47
|
+
const normalizedTitle = normalizeSessionTitle(rawText);
|
|
48
|
+
if (!normalizedTitle) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (isNoisyClaudeSessionTitle(rawText, normalizedTitle)) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return normalizedTitle;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function isNoisyClaudeSessionTitle(rawTitle: string, normalizedTitle: string): boolean {
|
|
60
|
+
if (!normalizedTitle) {
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return CLAUDE_TITLE_NOISE_PATTERNS.some((pattern) => pattern.test(rawTitle) || pattern.test(normalizedTitle));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function composeClaudeCodeSessionFallbackTitle(sessionId: string): string {
|
|
68
|
+
const trimmedId = sessionId.trim();
|
|
69
|
+
if (!trimmedId) {
|
|
70
|
+
return 'Session';
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return trimmedId.slice(0, 8);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export type ClaudeCodeDiscoveredSession = {
|
|
77
|
+
sessionId: string;
|
|
78
|
+
title?: string;
|
|
79
|
+
cwd: string;
|
|
80
|
+
projectPath: string;
|
|
81
|
+
projectName: string;
|
|
82
|
+
artifactPath: string;
|
|
83
|
+
gitBranch: string | null;
|
|
84
|
+
createdAt: number;
|
|
85
|
+
updatedAt: number;
|
|
86
|
+
startedAt?: number;
|
|
87
|
+
pid?: number;
|
|
88
|
+
isRunning: boolean;
|
|
89
|
+
archivedAt?: number;
|
|
90
|
+
waitingForUser: boolean;
|
|
91
|
+
parentSessionId?: string;
|
|
92
|
+
topology?: ProviderTopology;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export type ClaudeCodeNormalizedSession = {
|
|
96
|
+
id: string;
|
|
97
|
+
slug: string;
|
|
98
|
+
title: string;
|
|
99
|
+
directory: string;
|
|
100
|
+
projectName: string;
|
|
101
|
+
branch?: string;
|
|
102
|
+
parentID?: string;
|
|
103
|
+
messageCount?: number;
|
|
104
|
+
hasTranscript?: boolean;
|
|
105
|
+
time: {
|
|
106
|
+
created: number;
|
|
107
|
+
updated: number;
|
|
108
|
+
archived?: number;
|
|
109
|
+
};
|
|
110
|
+
provider: 'claude-code';
|
|
111
|
+
readOnly: true;
|
|
112
|
+
capabilities: typeof READONLY_PROVIDER_CONTEXT.capabilities;
|
|
113
|
+
realTimeStatus: 'idle' | 'busy';
|
|
114
|
+
waitingForUser: boolean;
|
|
115
|
+
children: ChildEntry[];
|
|
116
|
+
rawSessionId: string;
|
|
117
|
+
providerRawId: string;
|
|
118
|
+
topology: ProviderTopology;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export type ClaudeCodeDiscoveryOptions = {
|
|
122
|
+
repoPath?: string;
|
|
123
|
+
homeDir?: string;
|
|
124
|
+
claudeDir?: string;
|
|
125
|
+
jsonlHeadLimitBytes?: number;
|
|
126
|
+
smallFileLimitBytes?: number;
|
|
127
|
+
isPidAlive?: (pid: number) => boolean | Promise<boolean>;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
function normalizeClaudeCodeSessionId(rawSessionId: string): string {
|
|
131
|
+
return namespaceClaudeRawId(rawSessionId);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function normalizeClaudeTopology(topology?: ProviderTopology): ProviderTopology {
|
|
135
|
+
if (topology?.childSessions === 'authoritative') {
|
|
136
|
+
return topology;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return READONLY_PROVIDER_CONTEXT.topology;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function toClaudeChildEntry(
|
|
143
|
+
session: ClaudeCodeNormalizedSession,
|
|
144
|
+
parentId: string
|
|
145
|
+
): ChildEntry {
|
|
146
|
+
return {
|
|
147
|
+
id: session.id,
|
|
148
|
+
slug: session.slug,
|
|
149
|
+
title: session.title,
|
|
150
|
+
directory: session.directory,
|
|
151
|
+
parentID: parentId,
|
|
152
|
+
time: session.time,
|
|
153
|
+
realTimeStatus: session.realTimeStatus,
|
|
154
|
+
waitingForUser: session.waitingForUser,
|
|
155
|
+
readOnly: session.readOnly,
|
|
156
|
+
capabilities: session.capabilities,
|
|
157
|
+
rawSessionId: session.rawSessionId,
|
|
158
|
+
provider: session.provider,
|
|
159
|
+
providerRawId: session.providerRawId,
|
|
160
|
+
topology: session.topology,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export function normalizeClaudeCodeSession(
|
|
165
|
+
session: ClaudeCodeDiscoveredSession
|
|
166
|
+
): ClaudeCodeNormalizedSession {
|
|
167
|
+
const normalizedId = normalizeClaudeCodeSessionId(session.sessionId);
|
|
168
|
+
const normalizedTitle = typeof session.title === 'string' ? normalizeSessionTitle(session.title) : '';
|
|
169
|
+
const topology = normalizeClaudeTopology(session.topology);
|
|
170
|
+
|
|
171
|
+
return {
|
|
172
|
+
id: normalizedId,
|
|
173
|
+
slug: session.sessionId,
|
|
174
|
+
title: normalizedTitle || composeClaudeCodeSessionFallbackTitle(session.sessionId),
|
|
175
|
+
directory: session.cwd,
|
|
176
|
+
projectName: session.projectName,
|
|
177
|
+
...(session.gitBranch ? { branch: session.gitBranch } : {}),
|
|
178
|
+
time: {
|
|
179
|
+
created: session.createdAt,
|
|
180
|
+
updated: session.updatedAt,
|
|
181
|
+
...(typeof session.archivedAt === 'number' ? { archived: session.archivedAt } : {}),
|
|
182
|
+
},
|
|
183
|
+
rawSessionId: session.sessionId,
|
|
184
|
+
providerRawId: session.sessionId,
|
|
185
|
+
provider: 'claude-code',
|
|
186
|
+
readOnly: true,
|
|
187
|
+
capabilities: READONLY_PROVIDER_CONTEXT.capabilities,
|
|
188
|
+
topology,
|
|
189
|
+
realTimeStatus: session.waitingForUser ? 'idle' : session.isRunning ? 'busy' : 'idle',
|
|
190
|
+
waitingForUser: session.waitingForUser,
|
|
191
|
+
children: [],
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export function normalizeClaudeCodeSessions(
|
|
196
|
+
sessions: ClaudeCodeDiscoveredSession[]
|
|
197
|
+
): ClaudeCodeNormalizedSession[] {
|
|
198
|
+
const normalizedSessions = sessions.map(normalizeClaudeCodeSession);
|
|
199
|
+
const sessionById = new Map(normalizedSessions.map((session) => [session.id, session]));
|
|
200
|
+
const parentByChildId = new Map<string, string>();
|
|
201
|
+
const childrenByParentId = new Map<string, ChildEntry[]>();
|
|
202
|
+
const nestedChildIds = new Set<string>();
|
|
203
|
+
|
|
204
|
+
const resolveRootParentId = (childId: string): string | undefined => {
|
|
205
|
+
const visited = new Set<string>([childId]);
|
|
206
|
+
let currentParentId = parentByChildId.get(childId);
|
|
207
|
+
|
|
208
|
+
while (currentParentId) {
|
|
209
|
+
if (visited.has(currentParentId)) {
|
|
210
|
+
return undefined;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
visited.add(currentParentId);
|
|
214
|
+
const nextParentId = parentByChildId.get(currentParentId);
|
|
215
|
+
if (!nextParentId) {
|
|
216
|
+
return currentParentId;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
currentParentId = nextParentId;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return undefined;
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
for (const session of sessions) {
|
|
226
|
+
if (session.topology?.childSessions !== 'authoritative' || !session.parentSessionId) {
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const normalizedChildId = normalizeClaudeCodeSessionId(session.sessionId);
|
|
231
|
+
const normalizedParentId = normalizeClaudeCodeSessionId(session.parentSessionId);
|
|
232
|
+
const normalizedChild = sessionById.get(normalizedChildId);
|
|
233
|
+
const normalizedParent = sessionById.get(normalizedParentId);
|
|
234
|
+
|
|
235
|
+
if (
|
|
236
|
+
!normalizedChild
|
|
237
|
+
|| !normalizedParent
|
|
238
|
+
|| normalizedChildId === normalizedParentId
|
|
239
|
+
|| normalizedParent.topology.childSessions !== 'authoritative'
|
|
240
|
+
) {
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
parentByChildId.set(normalizedChildId, normalizedParentId);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
for (const [normalizedChildId] of parentByChildId) {
|
|
248
|
+
const normalizedChild = sessionById.get(normalizedChildId);
|
|
249
|
+
if (!normalizedChild) {
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const normalizedRootParentId = resolveRootParentId(normalizedChildId);
|
|
254
|
+
if (!normalizedRootParentId || normalizedRootParentId === normalizedChildId) {
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
const normalizedRootParent = sessionById.get(normalizedRootParentId);
|
|
259
|
+
if (!normalizedRootParent || normalizedRootParent.topology.childSessions !== 'authoritative') {
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
const rootChildren = childrenByParentId.get(normalizedRootParentId) ?? [];
|
|
264
|
+
rootChildren.push(toClaudeChildEntry(normalizedChild, normalizedRootParentId));
|
|
265
|
+
childrenByParentId.set(normalizedRootParentId, rootChildren);
|
|
266
|
+
nestedChildIds.add(normalizedChildId);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
return normalizedSessions
|
|
270
|
+
.filter((session) => !nestedChildIds.has(session.id))
|
|
271
|
+
.map((session) => ({
|
|
272
|
+
...session,
|
|
273
|
+
children: childrenByParentId.get(session.id) ?? [],
|
|
274
|
+
}));
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export const claudeCodeLocalSessionProvider: LocalSessionProvider = {
|
|
278
|
+
id: 'claude-code',
|
|
279
|
+
async getSessionsResult(): Promise<SessionsRouteResult> {
|
|
280
|
+
try {
|
|
281
|
+
const sessions = normalizeClaudeCodeSessions(await discoverClaudeCodeSessions({ repoPath: process.cwd() }));
|
|
282
|
+
return {
|
|
283
|
+
payload: {
|
|
284
|
+
sessions,
|
|
285
|
+
processHints: [],
|
|
286
|
+
},
|
|
287
|
+
sourceMeta: {
|
|
288
|
+
online: sessions.length > 0,
|
|
289
|
+
},
|
|
290
|
+
};
|
|
291
|
+
} catch {
|
|
292
|
+
return {
|
|
293
|
+
payload: {
|
|
294
|
+
sessions: [],
|
|
295
|
+
processHints: [],
|
|
296
|
+
},
|
|
297
|
+
sourceMeta: {
|
|
298
|
+
online: false,
|
|
299
|
+
degraded: true,
|
|
300
|
+
reason: 'Claude Code discovery failed',
|
|
301
|
+
},
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
type ProjectIndexMetadata = {
|
|
308
|
+
originalPath?: string;
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
type SessionIndexMetadata = {
|
|
312
|
+
pid?: number;
|
|
313
|
+
sessionId?: string;
|
|
314
|
+
cwd?: string;
|
|
315
|
+
startedAt?: number;
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
type JsonlSessionHead = {
|
|
319
|
+
cwd?: string;
|
|
320
|
+
sessionId?: string;
|
|
321
|
+
title?: string;
|
|
322
|
+
gitBranch?: string;
|
|
323
|
+
timestampMs?: number;
|
|
324
|
+
explicitParentSessionId?: string;
|
|
325
|
+
agentId?: string;
|
|
326
|
+
isSidechain?: boolean;
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
type CandidateSessionMetadata = {
|
|
330
|
+
sessionId: string;
|
|
331
|
+
cwd?: string;
|
|
332
|
+
startedAt?: number;
|
|
333
|
+
runningPid?: number;
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
function candidateMetadataScore(candidate: CandidateSessionMetadata): number {
|
|
337
|
+
let score = 0;
|
|
338
|
+
if (typeof candidate.runningPid === 'number') {
|
|
339
|
+
score += 2;
|
|
340
|
+
}
|
|
341
|
+
if (typeof candidate.startedAt === 'number') {
|
|
342
|
+
score += 1;
|
|
343
|
+
}
|
|
344
|
+
return score;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
function mergeCandidateSessionMetadata(
|
|
348
|
+
existing: CandidateSessionMetadata,
|
|
349
|
+
incoming: CandidateSessionMetadata
|
|
350
|
+
): CandidateSessionMetadata {
|
|
351
|
+
const existingScore = candidateMetadataScore(existing);
|
|
352
|
+
const incomingScore = candidateMetadataScore(incoming);
|
|
353
|
+
|
|
354
|
+
if (incomingScore > existingScore) {
|
|
355
|
+
return incoming;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
if (incomingScore < existingScore) {
|
|
359
|
+
return existing;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
const existingStartedAt = existing.startedAt ?? -Infinity;
|
|
363
|
+
const incomingStartedAt = incoming.startedAt ?? -Infinity;
|
|
364
|
+
|
|
365
|
+
if (incomingStartedAt > existingStartedAt) {
|
|
366
|
+
return incoming;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
return existing;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
function getClaudeDir({ claudeDir, homeDir }: ClaudeCodeDiscoveryOptions): string {
|
|
373
|
+
if (claudeDir) {
|
|
374
|
+
return claudeDir;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
return join(homeDir ?? homedir(), '.claude');
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
export function sanitizeClaudeProjectPath(repoPath: string): string {
|
|
381
|
+
return repoPath.replace(/[^a-zA-Z0-9]/g, '-');
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
function toFiniteTimestamp(value: unknown): number | undefined {
|
|
385
|
+
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
386
|
+
return value;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
if (typeof value === 'string') {
|
|
390
|
+
const parsed = Date.parse(value);
|
|
391
|
+
if (Number.isFinite(parsed)) {
|
|
392
|
+
return parsed;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
return undefined;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
async function safeAccess(filePath: string): Promise<boolean> {
|
|
400
|
+
try {
|
|
401
|
+
await access(filePath, constants.F_OK);
|
|
402
|
+
return true;
|
|
403
|
+
} catch {
|
|
404
|
+
return false;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
async function safeRealpath(filePath: string): Promise<string | null> {
|
|
409
|
+
try {
|
|
410
|
+
return await realpath(filePath);
|
|
411
|
+
} catch {
|
|
412
|
+
return null;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
async function readFileHead(filePath: string, byteLimit: number): Promise<string | null> {
|
|
417
|
+
let handle: FileHandle | undefined;
|
|
418
|
+
|
|
419
|
+
try {
|
|
420
|
+
handle = await open(filePath, 'r');
|
|
421
|
+
const buffer = Buffer.alloc(byteLimit);
|
|
422
|
+
const { bytesRead } = await handle.read(buffer, 0, byteLimit, 0);
|
|
423
|
+
return buffer.subarray(0, bytesRead).toString('utf8');
|
|
424
|
+
} catch {
|
|
425
|
+
return null;
|
|
426
|
+
} finally {
|
|
427
|
+
await handle?.close().catch(() => undefined);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
async function readSmallJsonFile<T>(filePath: string, byteLimit: number): Promise<T | null> {
|
|
432
|
+
try {
|
|
433
|
+
const fileStat = await stat(filePath);
|
|
434
|
+
if (!fileStat.isFile() || fileStat.size > byteLimit) {
|
|
435
|
+
return null;
|
|
436
|
+
}
|
|
437
|
+
} catch {
|
|
438
|
+
return null;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
const text = await readFileHead(filePath, byteLimit);
|
|
442
|
+
if (!text) {
|
|
443
|
+
return null;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
try {
|
|
447
|
+
return JSON.parse(text) as T;
|
|
448
|
+
} catch {
|
|
449
|
+
return null;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
async function readProjectIndexRealpath(projectDir: string, byteLimit: number): Promise<string | null> {
|
|
454
|
+
const indexPath = join(projectDir, PROJECT_INDEX_FILE);
|
|
455
|
+
const index = await readSmallJsonFile<ProjectIndexMetadata>(indexPath, byteLimit);
|
|
456
|
+
|
|
457
|
+
if (!index?.originalPath || typeof index.originalPath !== 'string') {
|
|
458
|
+
return null;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
const originalRealpath = await safeRealpath(index.originalPath);
|
|
462
|
+
if (!originalRealpath) {
|
|
463
|
+
return null;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
return originalRealpath;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
async function readJsonlSessionHead(filePath: string, byteLimit: number): Promise<JsonlSessionHead | null> {
|
|
470
|
+
const text = await readFileHead(filePath, byteLimit);
|
|
471
|
+
if (text === null) {
|
|
472
|
+
return null;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
const metadata: JsonlSessionHead = {};
|
|
476
|
+
|
|
477
|
+
for (const rawLine of text.split('\n')) {
|
|
478
|
+
const line = rawLine.trim();
|
|
479
|
+
if (!line) {
|
|
480
|
+
continue;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
try {
|
|
484
|
+
const parsed = JSON.parse(line) as Record<string, unknown>;
|
|
485
|
+
|
|
486
|
+
if (typeof parsed.cwd === 'string' && !metadata.cwd) {
|
|
487
|
+
metadata.cwd = parsed.cwd;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
if (typeof parsed.sessionId === 'string' && !metadata.sessionId) {
|
|
491
|
+
metadata.sessionId = parsed.sessionId;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
if (typeof parsed.agentId === 'string' && !metadata.agentId) {
|
|
495
|
+
const normalizedAgentId = parsed.agentId.trim();
|
|
496
|
+
if (normalizedAgentId) {
|
|
497
|
+
metadata.agentId = normalizedAgentId;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
if (typeof parsed.isSidechain === 'boolean' && metadata.isSidechain === undefined) {
|
|
502
|
+
metadata.isSidechain = parsed.isSidechain;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
if (typeof parsed.gitBranch === 'string' && !metadata.gitBranch) {
|
|
506
|
+
metadata.gitBranch = parsed.gitBranch;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
if (!metadata.title) {
|
|
510
|
+
const titleCandidate = extractTitleFromSessionEvent(parsed);
|
|
511
|
+
if (titleCandidate) {
|
|
512
|
+
metadata.title = titleCandidate;
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
if (!metadata.explicitParentSessionId) {
|
|
517
|
+
const parentSessionId = extractExplicitParentSessionId(parsed);
|
|
518
|
+
if (parentSessionId) {
|
|
519
|
+
metadata.explicitParentSessionId = parentSessionId;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
const timestampMs = toFiniteTimestamp(parsed.timestamp);
|
|
524
|
+
if (timestampMs !== undefined && metadata.timestampMs === undefined) {
|
|
525
|
+
metadata.timestampMs = timestampMs;
|
|
526
|
+
}
|
|
527
|
+
} catch {
|
|
528
|
+
continue;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
if (
|
|
532
|
+
metadata.cwd
|
|
533
|
+
&& metadata.sessionId
|
|
534
|
+
&& metadata.gitBranch
|
|
535
|
+
&& metadata.timestampMs !== undefined
|
|
536
|
+
&& metadata.title
|
|
537
|
+
&& metadata.explicitParentSessionId
|
|
538
|
+
) {
|
|
539
|
+
break;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
return metadata;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
function isAgentSessionArtifactId(value: string): boolean {
|
|
547
|
+
return value.startsWith('agent-') && value.length > 'agent-'.length;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
function extractSidechainParentSessionId(
|
|
551
|
+
artifactSessionId: string,
|
|
552
|
+
metadata: JsonlSessionHead
|
|
553
|
+
): string | null {
|
|
554
|
+
if (!isAgentSessionArtifactId(artifactSessionId)) {
|
|
555
|
+
return null;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
const artifactAgentId = artifactSessionId.slice('agent-'.length);
|
|
559
|
+
const metadataAgentId = typeof metadata.agentId === 'string' ? metadata.agentId.trim() : '';
|
|
560
|
+
if (metadataAgentId && metadataAgentId !== artifactAgentId) {
|
|
561
|
+
return null;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
if (metadata.isSidechain !== true && !metadataAgentId) {
|
|
565
|
+
return null;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
const candidateParentSessionId = typeof metadata.sessionId === 'string' ? metadata.sessionId.trim() : '';
|
|
569
|
+
if (!candidateParentSessionId || candidateParentSessionId === artifactSessionId) {
|
|
570
|
+
return null;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
return candidateParentSessionId;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
function toScopedSidechainSessionId(parentSessionId: string, artifactSessionId: string): string {
|
|
577
|
+
return `${parentSessionId}__${artifactSessionId}`;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
async function collectProjectArtifactPaths(projectDir: string): Promise<string[]> {
|
|
581
|
+
let projectArtifacts: Dirent[];
|
|
582
|
+
try {
|
|
583
|
+
projectArtifacts = await readdir(projectDir, { withFileTypes: true });
|
|
584
|
+
} catch {
|
|
585
|
+
return [];
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
const artifactPaths: string[] = [];
|
|
589
|
+
|
|
590
|
+
for (const entry of projectArtifacts) {
|
|
591
|
+
const entryPath = join(projectDir, entry.name);
|
|
592
|
+
|
|
593
|
+
if (entry.isFile() && entry.name.endsWith('.jsonl')) {
|
|
594
|
+
artifactPaths.push(entryPath);
|
|
595
|
+
continue;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
if (!entry.isDirectory()) {
|
|
599
|
+
continue;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
const subagentsDir = join(entryPath, 'subagents');
|
|
603
|
+
|
|
604
|
+
let subagentArtifacts: Dirent[];
|
|
605
|
+
try {
|
|
606
|
+
subagentArtifacts = await readdir(subagentsDir, { withFileTypes: true });
|
|
607
|
+
} catch {
|
|
608
|
+
continue;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
for (const subagentArtifact of subagentArtifacts) {
|
|
612
|
+
if (!subagentArtifact.isFile() || !subagentArtifact.name.endsWith('.jsonl')) {
|
|
613
|
+
continue;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
artifactPaths.push(join(subagentsDir, subagentArtifact.name));
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
return artifactPaths;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
async function readFileTail(filePath: string, byteLimit: number): Promise<string | null> {
|
|
624
|
+
let handle: FileHandle | undefined;
|
|
625
|
+
|
|
626
|
+
try {
|
|
627
|
+
const fileStat = await stat(filePath);
|
|
628
|
+
if (!fileStat.isFile()) {
|
|
629
|
+
return null;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
handle = await open(filePath, 'r');
|
|
633
|
+
const bytesToRead = Math.min(byteLimit, fileStat.size);
|
|
634
|
+
const start = Math.max(0, fileStat.size - bytesToRead);
|
|
635
|
+
const buffer = Buffer.alloc(bytesToRead);
|
|
636
|
+
const { bytesRead } = await handle.read(buffer, 0, bytesToRead, start);
|
|
637
|
+
return buffer.subarray(0, bytesRead).toString('utf8');
|
|
638
|
+
} catch {
|
|
639
|
+
return null;
|
|
640
|
+
} finally {
|
|
641
|
+
await handle?.close().catch(() => undefined);
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
async function readJsonlSessionHeadWithTitleRetry(filePath: string, byteLimit: number): Promise<JsonlSessionHead | null> {
|
|
646
|
+
const headReadLimits = Array.from(
|
|
647
|
+
new Set([
|
|
648
|
+
Math.max(1, byteLimit),
|
|
649
|
+
Math.max(byteLimit * 4, DEFAULT_JSONL_HEAD_RETRY_LIMIT_BYTES),
|
|
650
|
+
])
|
|
651
|
+
);
|
|
652
|
+
|
|
653
|
+
let headMetadata: JsonlSessionHead | null = null;
|
|
654
|
+
for (const headReadLimit of headReadLimits) {
|
|
655
|
+
const scanned = await readJsonlSessionHead(filePath, headReadLimit);
|
|
656
|
+
if (!scanned) {
|
|
657
|
+
continue;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
headMetadata = scanned;
|
|
661
|
+
if (headMetadata.title) {
|
|
662
|
+
break;
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
return headMetadata;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
function extractTextMessage(content: unknown): string | null {
|
|
670
|
+
if (typeof content === 'string') {
|
|
671
|
+
const compact = content.trim();
|
|
672
|
+
return compact || null;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
if (!Array.isArray(content)) return null;
|
|
676
|
+
const texts = content
|
|
677
|
+
.map((part) => (part && typeof part === 'object' && typeof (part as Record<string, unknown>).text === 'string'
|
|
678
|
+
? (part as Record<string, unknown>).text as string
|
|
679
|
+
: null))
|
|
680
|
+
.filter((value): value is string => !!value)
|
|
681
|
+
.join('\n')
|
|
682
|
+
.trim();
|
|
683
|
+
return texts || null;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
function extractTitleFromSessionEvent(entry: Record<string, unknown>): string | null {
|
|
687
|
+
const outerType = entry.type;
|
|
688
|
+
const message = entry.message;
|
|
689
|
+
const role = message && typeof message === 'object' ? (message as Record<string, unknown>).role : undefined;
|
|
690
|
+
const isUserEvent = outerType === 'user' || role === 'user';
|
|
691
|
+
if (!isUserEvent) {
|
|
692
|
+
return null;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
const content = message && typeof message === 'object'
|
|
696
|
+
? (message as Record<string, unknown>).content
|
|
697
|
+
: entry.content;
|
|
698
|
+
|
|
699
|
+
if (typeof content === 'string') {
|
|
700
|
+
return toClaudeTitleCandidate(content);
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
if (Array.isArray(content)) {
|
|
704
|
+
for (const part of content) {
|
|
705
|
+
if (!part || typeof part !== 'object') {
|
|
706
|
+
continue;
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
const typedPart = part as Record<string, unknown>;
|
|
710
|
+
if (typeof typedPart.type === 'string' && typedPart.type !== 'text') {
|
|
711
|
+
continue;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
const text = typeof typedPart.text === 'string'
|
|
715
|
+
? typedPart.text
|
|
716
|
+
: typeof typedPart.content === 'string'
|
|
717
|
+
? typedPart.content
|
|
718
|
+
: null;
|
|
719
|
+
if (!text) {
|
|
720
|
+
continue;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
const titleCandidate = toClaudeTitleCandidate(text);
|
|
724
|
+
if (titleCandidate) {
|
|
725
|
+
return titleCandidate;
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
return null;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
return null;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
function extractExplicitParentSessionId(entry: Record<string, unknown>): string | null {
|
|
736
|
+
const candidate = entry.parentSessionId ?? entry.parent_session_id ?? entry.parentSessionID;
|
|
737
|
+
if (typeof candidate !== 'string') {
|
|
738
|
+
return null;
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
const normalizedCandidate = candidate.trim();
|
|
742
|
+
return normalizedCandidate || null;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
function hasToolUseContent(content: unknown): boolean {
|
|
746
|
+
return Array.isArray(content) && content.some((part) => part && typeof part === 'object' && (part as Record<string, unknown>).type === 'tool_use');
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
function textLooksLikeUserQuestion(text: string): boolean {
|
|
750
|
+
const trimmed = text.trim();
|
|
751
|
+
return trimmed.endsWith('?') || trimmed.endsWith('?');
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
type WaitingDetectionResult = {
|
|
755
|
+
waitingForUser: boolean;
|
|
756
|
+
trailingParseErrors: boolean;
|
|
757
|
+
};
|
|
758
|
+
|
|
759
|
+
async function detectWaitingForUserFromTranscript(
|
|
760
|
+
filePath: string,
|
|
761
|
+
updatedAt: number
|
|
762
|
+
): Promise<WaitingDetectionResult> {
|
|
763
|
+
const now = Date.now();
|
|
764
|
+
if (now - updatedAt > DEFAULT_WAITING_FOR_USER_WINDOW_MS) {
|
|
765
|
+
return {
|
|
766
|
+
waitingForUser: false,
|
|
767
|
+
trailingParseErrors: false,
|
|
768
|
+
};
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
const tail = await readFileTail(filePath, DEFAULT_JSONL_HEAD_LIMIT_BYTES);
|
|
772
|
+
if (!tail) {
|
|
773
|
+
return {
|
|
774
|
+
waitingForUser: false,
|
|
775
|
+
trailingParseErrors: false,
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
const lines = tail.split('\n').map((line) => line.trim()).filter(Boolean);
|
|
780
|
+
let trailingParseErrors = false;
|
|
781
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
782
|
+
try {
|
|
783
|
+
const parsed = JSON.parse(lines[i]) as Record<string, unknown>;
|
|
784
|
+
const outerType = parsed.type;
|
|
785
|
+
const message = parsed.message;
|
|
786
|
+
const role = message && typeof message === 'object' ? (message as Record<string, unknown>).role : undefined;
|
|
787
|
+
|
|
788
|
+
if (outerType === 'user' || role === 'user') {
|
|
789
|
+
return {
|
|
790
|
+
waitingForUser: false,
|
|
791
|
+
trailingParseErrors,
|
|
792
|
+
};
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
if (outerType === 'assistant' && message && typeof message === 'object') {
|
|
796
|
+
const msg = message as Record<string, unknown>;
|
|
797
|
+
const stopReason = msg.stop_reason;
|
|
798
|
+
const text = extractTextMessage(msg.content);
|
|
799
|
+
const toolUsePending = stopReason === 'tool_use' || hasToolUseContent(msg.content);
|
|
800
|
+
if (toolUsePending) {
|
|
801
|
+
return {
|
|
802
|
+
waitingForUser: true,
|
|
803
|
+
trailingParseErrors,
|
|
804
|
+
};
|
|
805
|
+
}
|
|
806
|
+
if (stopReason === 'end_turn' && typeof text === 'string' && textLooksLikeUserQuestion(text)) {
|
|
807
|
+
return {
|
|
808
|
+
waitingForUser: true,
|
|
809
|
+
trailingParseErrors,
|
|
810
|
+
};
|
|
811
|
+
}
|
|
812
|
+
return {
|
|
813
|
+
waitingForUser: false,
|
|
814
|
+
trailingParseErrors,
|
|
815
|
+
};
|
|
816
|
+
}
|
|
817
|
+
} catch {
|
|
818
|
+
trailingParseErrors = true;
|
|
819
|
+
continue;
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
return {
|
|
824
|
+
waitingForUser: false,
|
|
825
|
+
trailingParseErrors,
|
|
826
|
+
};
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
async function defaultIsPidAlive(pid: number): Promise<boolean> {
|
|
830
|
+
try {
|
|
831
|
+
process.kill(pid, 0);
|
|
832
|
+
return true;
|
|
833
|
+
} catch {
|
|
834
|
+
return false;
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
async function readCandidateSessionMetadata(
|
|
839
|
+
claudeDir: string,
|
|
840
|
+
byteLimit: number,
|
|
841
|
+
isPidAlive: (pid: number) => boolean | Promise<boolean>
|
|
842
|
+
): Promise<Map<string, CandidateSessionMetadata>> {
|
|
843
|
+
const sessionsDir = join(claudeDir, CLAUDE_SESSIONS_DIR);
|
|
844
|
+
|
|
845
|
+
let entries: Dirent[];
|
|
846
|
+
try {
|
|
847
|
+
entries = (await readdir(sessionsDir, { withFileTypes: true })).sort((a, b) => a.name.localeCompare(b.name));
|
|
848
|
+
} catch {
|
|
849
|
+
return new Map();
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
const metadataBySessionId = new Map<string, CandidateSessionMetadata>();
|
|
853
|
+
|
|
854
|
+
for (const entry of entries) {
|
|
855
|
+
if (!entry.isFile() || !entry.name.endsWith('.json')) {
|
|
856
|
+
continue;
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
const metadata = await readSmallJsonFile<SessionIndexMetadata>(join(sessionsDir, entry.name), byteLimit);
|
|
860
|
+
if (!metadata?.sessionId || typeof metadata.sessionId !== 'string') {
|
|
861
|
+
continue;
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
if (typeof metadata.cwd !== 'string') {
|
|
865
|
+
continue;
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
const metadataRepoRealpath = await safeRealpath(metadata.cwd);
|
|
869
|
+
if (!metadataRepoRealpath) {
|
|
870
|
+
continue;
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
const candidate: CandidateSessionMetadata = {
|
|
874
|
+
sessionId: metadata.sessionId,
|
|
875
|
+
cwd: metadataRepoRealpath,
|
|
876
|
+
startedAt: typeof metadata.startedAt === 'number' && Number.isFinite(metadata.startedAt)
|
|
877
|
+
? metadata.startedAt
|
|
878
|
+
: undefined,
|
|
879
|
+
};
|
|
880
|
+
|
|
881
|
+
if (typeof metadata.pid === 'number' && Number.isInteger(metadata.pid) && metadata.pid > 0) {
|
|
882
|
+
let alive = false;
|
|
883
|
+
try {
|
|
884
|
+
alive = await isPidAlive(metadata.pid);
|
|
885
|
+
} catch {
|
|
886
|
+
alive = false;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
if (alive && candidate.startedAt !== undefined) {
|
|
890
|
+
candidate.runningPid = metadata.pid;
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
const existing = metadataBySessionId.get(metadata.sessionId);
|
|
895
|
+
if (!existing) {
|
|
896
|
+
metadataBySessionId.set(metadata.sessionId, candidate);
|
|
897
|
+
continue;
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
metadataBySessionId.set(metadata.sessionId, mergeCandidateSessionMetadata(existing, candidate));
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
return metadataBySessionId;
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
export async function discoverClaudeCodeSessions(
|
|
907
|
+
options: ClaudeCodeDiscoveryOptions = {}
|
|
908
|
+
): Promise<ClaudeCodeDiscoveredSession[]> {
|
|
909
|
+
const claudeDir = getClaudeDir(options);
|
|
910
|
+
const projectsDir = join(claudeDir, CLAUDE_PROJECTS_DIR);
|
|
911
|
+
if (!(await safeAccess(projectsDir))) {
|
|
912
|
+
return [];
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
const smallFileLimitBytes = options.smallFileLimitBytes ?? DEFAULT_SMALL_FILE_LIMIT_BYTES;
|
|
916
|
+
const jsonlHeadLimitBytes = options.jsonlHeadLimitBytes ?? DEFAULT_JSONL_HEAD_LIMIT_BYTES;
|
|
917
|
+
const candidateMetadata = await readCandidateSessionMetadata(
|
|
918
|
+
claudeDir,
|
|
919
|
+
smallFileLimitBytes,
|
|
920
|
+
options.isPidAlive ?? defaultIsPidAlive
|
|
921
|
+
);
|
|
922
|
+
|
|
923
|
+
let projectDirs: Dirent[];
|
|
924
|
+
try {
|
|
925
|
+
projectDirs = await readdir(projectsDir, { withFileTypes: true });
|
|
926
|
+
} catch {
|
|
927
|
+
return [];
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
const discoveredSessions = new Map<string, ClaudeCodeDiscoveredSession>();
|
|
931
|
+
const explicitParentSessionIds = new Map<string, string>();
|
|
932
|
+
const overrideMap = new Map((await listClaudeSessionOverrides()).map((entry) => [entry.sessionId, entry]));
|
|
933
|
+
const now = Date.now();
|
|
934
|
+
|
|
935
|
+
for (const projectEntry of projectDirs) {
|
|
936
|
+
if (!projectEntry.isDirectory()) {
|
|
937
|
+
continue;
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
const projectDir = join(projectsDir, projectEntry.name);
|
|
941
|
+
const projectIndexRealpath = await readProjectIndexRealpath(projectDir, smallFileLimitBytes);
|
|
942
|
+
|
|
943
|
+
const projectArtifactPaths = await collectProjectArtifactPaths(projectDir);
|
|
944
|
+
|
|
945
|
+
for (const artifactPath of projectArtifactPaths) {
|
|
946
|
+
const artifactName = basename(artifactPath);
|
|
947
|
+
const artifactSessionId = artifactName.slice(0, -'.jsonl'.length);
|
|
948
|
+
if (!artifactSessionId) {
|
|
949
|
+
continue;
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
const metadata = candidateMetadata.get(artifactSessionId);
|
|
953
|
+
let artifactStat: Stats;
|
|
954
|
+
try {
|
|
955
|
+
artifactStat = await stat(artifactPath);
|
|
956
|
+
if (!artifactStat.isFile()) {
|
|
957
|
+
continue;
|
|
958
|
+
}
|
|
959
|
+
} catch {
|
|
960
|
+
continue;
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
const headMetadata = await readJsonlSessionHeadWithTitleRetry(artifactPath, jsonlHeadLimitBytes);
|
|
964
|
+
if (headMetadata === null) {
|
|
965
|
+
continue;
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
let scopedCwd: string | null = projectIndexRealpath;
|
|
969
|
+
if (typeof headMetadata.cwd === 'string') {
|
|
970
|
+
const artifactRepoRealpath = await safeRealpath(headMetadata.cwd);
|
|
971
|
+
if (!artifactRepoRealpath) {
|
|
972
|
+
continue;
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
if (projectIndexRealpath && artifactRepoRealpath !== projectIndexRealpath) {
|
|
976
|
+
continue;
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
scopedCwd = artifactRepoRealpath;
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
if (!scopedCwd) {
|
|
983
|
+
continue;
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
const sidechainParentSessionId = extractSidechainParentSessionId(artifactSessionId, headMetadata);
|
|
987
|
+
const isSidechainArtifact = typeof sidechainParentSessionId === 'string';
|
|
988
|
+
const resolvedSessionId = headMetadata.sessionId ?? artifactSessionId;
|
|
989
|
+
if (!isSidechainArtifact && resolvedSessionId !== artifactSessionId) {
|
|
990
|
+
continue;
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
const discoveredTitle = headMetadata.title;
|
|
994
|
+
|
|
995
|
+
const sessionId = sidechainParentSessionId
|
|
996
|
+
? toScopedSidechainSessionId(sidechainParentSessionId, artifactSessionId)
|
|
997
|
+
: artifactSessionId;
|
|
998
|
+
|
|
999
|
+
const directOverride = overrideMap.get(sessionId);
|
|
1000
|
+
const parentDeletedOverride = sidechainParentSessionId
|
|
1001
|
+
? overrideMap.get(sidechainParentSessionId)
|
|
1002
|
+
: undefined;
|
|
1003
|
+
const deletedOverride = typeof directOverride?.deletedAt === 'number'
|
|
1004
|
+
? directOverride
|
|
1005
|
+
: parentDeletedOverride;
|
|
1006
|
+
if (typeof deletedOverride?.deletedAt === 'number') {
|
|
1007
|
+
continue;
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
const scopedMetadata = metadata?.cwd === scopedCwd ? metadata : undefined;
|
|
1011
|
+
const updatedAt = Math.max(artifactStat.mtimeMs, headMetadata.timestampMs ?? 0);
|
|
1012
|
+
const artifactAgeMs = now - updatedAt;
|
|
1013
|
+
const hasVeryRecentArtifactActivity = artifactAgeMs <= DEFAULT_BUSY_ACTIVITY_WINDOW_MS;
|
|
1014
|
+
const waitingSuppressedByRestore = typeof directOverride?.restoredAt === 'number' && directOverride.restoredAt >= updatedAt;
|
|
1015
|
+
const waitingDetection = waitingSuppressedByRestore
|
|
1016
|
+
? { waitingForUser: false, trailingParseErrors: false }
|
|
1017
|
+
: await detectWaitingForUserFromTranscript(artifactPath, updatedAt);
|
|
1018
|
+
const hasRunningEvidence = typeof scopedMetadata?.runningPid === 'number' || isSidechainArtifact;
|
|
1019
|
+
const waitingStaleDuringActiveWrite =
|
|
1020
|
+
waitingDetection.waitingForUser
|
|
1021
|
+
&& waitingDetection.trailingParseErrors
|
|
1022
|
+
&& hasVeryRecentArtifactActivity
|
|
1023
|
+
&& hasRunningEvidence;
|
|
1024
|
+
const waitingForUser = hasRunningEvidence
|
|
1025
|
+
? (waitingStaleDuringActiveWrite ? false : waitingDetection.waitingForUser)
|
|
1026
|
+
: false;
|
|
1027
|
+
const isRunning =
|
|
1028
|
+
!waitingForUser
|
|
1029
|
+
&& hasVeryRecentArtifactActivity
|
|
1030
|
+
&& hasRunningEvidence;
|
|
1031
|
+
const createdAt = scopedMetadata?.runningPid !== undefined
|
|
1032
|
+
? scopedMetadata.startedAt ?? headMetadata.timestampMs ?? artifactStat.birthtimeMs ?? artifactStat.mtimeMs
|
|
1033
|
+
: headMetadata.timestampMs ?? artifactStat.birthtimeMs ?? artifactStat.mtimeMs;
|
|
1034
|
+
|
|
1035
|
+
discoveredSessions.set(sessionId, {
|
|
1036
|
+
sessionId,
|
|
1037
|
+
...(discoveredTitle ? { title: discoveredTitle } : {}),
|
|
1038
|
+
cwd: scopedCwd,
|
|
1039
|
+
projectPath: scopedCwd,
|
|
1040
|
+
projectName: basename(scopedCwd),
|
|
1041
|
+
artifactPath,
|
|
1042
|
+
gitBranch: headMetadata.gitBranch ?? null,
|
|
1043
|
+
createdAt,
|
|
1044
|
+
updatedAt,
|
|
1045
|
+
startedAt: scopedMetadata?.runningPid !== undefined ? scopedMetadata.startedAt : undefined,
|
|
1046
|
+
pid: scopedMetadata?.runningPid,
|
|
1047
|
+
isRunning,
|
|
1048
|
+
waitingForUser,
|
|
1049
|
+
...(typeof directOverride?.archivedAt === 'number' ? { archivedAt: directOverride.archivedAt } : {}),
|
|
1050
|
+
});
|
|
1051
|
+
|
|
1052
|
+
if (headMetadata.explicitParentSessionId) {
|
|
1053
|
+
explicitParentSessionIds.set(sessionId, headMetadata.explicitParentSessionId);
|
|
1054
|
+
} else if (sidechainParentSessionId) {
|
|
1055
|
+
explicitParentSessionIds.set(sessionId, sidechainParentSessionId);
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
if (discoveredSessions.size === 0) {
|
|
1061
|
+
return [];
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
for (const [sessionId, parentSessionId] of explicitParentSessionIds) {
|
|
1065
|
+
const childSession = discoveredSessions.get(sessionId);
|
|
1066
|
+
const parentSession = discoveredSessions.get(parentSessionId);
|
|
1067
|
+
if (!childSession || !parentSession || sessionId === parentSessionId) {
|
|
1068
|
+
continue;
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
discoveredSessions.set(sessionId, {
|
|
1072
|
+
...childSession,
|
|
1073
|
+
parentSessionId,
|
|
1074
|
+
topology: { childSessions: 'authoritative' },
|
|
1075
|
+
});
|
|
1076
|
+
discoveredSessions.set(parentSessionId, {
|
|
1077
|
+
...parentSession,
|
|
1078
|
+
topology: { childSessions: 'authoritative' },
|
|
1079
|
+
});
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
return Array.from(discoveredSessions.values()).sort((a, b) => b.updatedAt - a.updatedAt);
|
|
1083
|
+
}
|