@seqyuan/annodex 0.1.10 → 0.1.12
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/app/api/agent/[id]/events/route.ts +94 -0
- package/app/api/agent/[id]/route.ts +83 -0
- package/app/api/agent/new/route.ts +53 -0
- package/app/api/auth/all-providers/route.ts +21 -0
- package/app/api/auth/api-key/[provider]/route.ts +7 -0
- package/app/api/auth/login/[provider]/route.ts +7 -0
- package/app/api/auth/login/route.ts +22 -0
- package/app/api/auth/logout/[provider]/route.ts +7 -0
- package/app/api/auth/providers/route.ts +15 -0
- package/app/api/auth/status/route.ts +6 -0
- package/app/api/default-cwd/route.ts +22 -0
- package/app/api/files/[...path]/route.ts +621 -0
- package/app/api/harness/route.ts +47 -0
- package/app/api/home/route.ts +6 -0
- package/app/api/internal/runtime/route.ts +26 -0
- package/app/api/models/route.ts +67 -0
- package/app/api/models-config/discover/route.ts +42 -0
- package/app/api/models-config/route.ts +152 -0
- package/app/api/models-config/test/route.ts +154 -0
- package/app/api/projects/browse/route.ts +51 -0
- package/app/api/projects/route.ts +83 -0
- package/app/api/reports/[id]/route.ts +108 -0
- package/app/api/search/route.ts +122 -0
- package/app/api/sessions/[id]/context/route.ts +23 -0
- package/app/api/sessions/[id]/route.ts +124 -0
- package/app/api/sessions/new/route.ts +5 -0
- package/app/api/sessions/route.ts +16 -0
- package/app/api/settings/route.ts +51 -0
- package/app/api/skills/install/route.ts +249 -0
- package/app/api/skills/route.ts +161 -0
- package/app/api/skills/search/route.ts +121 -0
- package/app/api/soul/route.ts +47 -0
- package/app/api/version/route.ts +55 -0
- package/app/globals.css +736 -0
- package/app/layout.tsx +40 -0
- package/app/login/page.tsx +133 -0
- package/app/page.tsx +10 -0
- package/components/AppShell.tsx +1058 -0
- package/components/ChatInput.tsx +1103 -0
- package/components/ChatMinimap.tsx +381 -0
- package/components/ChatWindow.tsx +576 -0
- package/components/CodeMirrorEditor.tsx +137 -0
- package/components/ConversationSearch.tsx +369 -0
- package/components/DataTableViewer.tsx +248 -0
- package/components/FileExplorer.tsx +758 -0
- package/components/FileIcons.tsx +241 -0
- package/components/FileViewer.tsx +1273 -0
- package/components/GlobalFileEditor.tsx +98 -0
- package/components/MarkdownRenderer.tsx +331 -0
- package/components/MermaidDiagram.tsx +80 -0
- package/components/MessageView.tsx +1141 -0
- package/components/ModelsConfig.tsx +1991 -0
- package/components/ProjectContext.tsx +252 -0
- package/components/ProjectFolderPicker.tsx +202 -0
- package/components/ProjectsConfig.tsx +288 -0
- package/components/ProviderIcons.tsx +91 -0
- package/components/ReportPanel.tsx +237 -0
- package/components/ResizeHandle.tsx +105 -0
- package/components/SessionSidebar.tsx +1464 -0
- package/components/SettingsDialog.tsx +287 -0
- package/components/SkillsConfig.tsx +1093 -0
- package/components/SubagentPanel.tsx +191 -0
- package/components/TabBar.tsx +115 -0
- package/components/ToolPanel.tsx +131 -0
- package/components/WidgetRenderer.tsx +505 -0
- package/components/viewers/DocumentToolbar.tsx +78 -0
- package/components/viewers/DocxViewer.tsx +97 -0
- package/components/viewers/PdfViewer.tsx +206 -0
- package/components/viewers/PptxViewer.tsx +240 -0
- package/components/viewers/XlsxViewer.tsx +143 -0
- package/hooks/useAgentSession.ts +710 -0
- package/hooks/useAudio.ts +50 -0
- package/hooks/useDragDrop.ts +52 -0
- package/hooks/useResizable.ts +60 -0
- package/hooks/useTheme.ts +85 -0
- package/lib/agent-client.ts +39 -0
- package/lib/annodex-config.ts +556 -0
- package/lib/auth-token.ts +74 -0
- package/lib/auth.ts +90 -0
- package/lib/brand.ts +5 -0
- package/lib/code-theme.ts +32 -0
- package/lib/codex-compat-proxy.ts +1603 -0
- package/lib/codex-home.ts +6 -0
- package/lib/codex-server.ts +796 -0
- package/lib/codex-session.ts +590 -0
- package/lib/codex-usage.ts +213 -0
- package/lib/file-paths.ts +34 -0
- package/lib/model-discovery.ts +379 -0
- package/lib/normalize.ts +30 -0
- package/lib/npx.ts +87 -0
- package/lib/pi-types.ts +49 -0
- package/lib/projects.ts +269 -0
- package/lib/provider-api.ts +88 -0
- package/lib/report-prompt.ts +61 -0
- package/lib/report-store.ts +597 -0
- package/lib/report-update-parser.ts +66 -0
- package/lib/rpc-manager.ts +668 -0
- package/lib/runtime-state.ts +117 -0
- package/lib/session-reader.ts +903 -0
- package/lib/session-runtime.ts +105 -0
- package/lib/subagent-progress.ts +279 -0
- package/lib/types.ts +241 -0
- package/lib/widget-export.ts +318 -0
- package/lib/widget-guidelines.ts +288 -0
- package/lib/widget-prompt.ts +76 -0
- package/lib/widget-utils.ts +523 -0
- package/package.json +23 -18
- package/postcss.config.mjs +8 -0
- package/proxy.ts +64 -0
- package/scripts/postinstall.cjs +25 -0
- package/tsconfig.json +41 -0
- package/.next/BUILD_ID +0 -1
- package/.next/app-path-routes-manifest.json +0 -39
- package/.next/build-manifest.json +0 -20
- package/.next/diagnostics/build-diagnostics.json +0 -6
- package/.next/diagnostics/framework.json +0 -1
- package/.next/export-marker.json +0 -6
- package/.next/images-manifest.json +0 -68
- package/.next/next-minimal-server.js.nft.json +0 -1
- package/.next/next-server.js.nft.json +0 -1
- package/.next/package.json +0 -1
- package/.next/prerender-manifest.json +0 -109
- package/.next/react-loadable-manifest.json +0 -2320
- package/.next/required-server-files.js +0 -343
- package/.next/required-server-files.json +0 -343
- package/.next/routes-manifest.json +0 -286
- package/.next/server/app/_global-error/page.js +0 -32
- package/.next/server/app/_global-error/page.js.nft.json +0 -1
- package/.next/server/app/_global-error/page_client-reference-manifest.js +0 -1
- package/.next/server/app/_global-error.html +0 -1
- package/.next/server/app/_global-error.meta +0 -16
- package/.next/server/app/_global-error.rsc +0 -14
- package/.next/server/app/_global-error.segments/_full.segment.rsc +0 -14
- package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +0 -5
- package/.next/server/app/_global-error.segments/_global-error.segment.rsc +0 -5
- package/.next/server/app/_global-error.segments/_head.segment.rsc +0 -5
- package/.next/server/app/_global-error.segments/_index.segment.rsc +0 -5
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +0 -1
- package/.next/server/app/_not-found/page.js +0 -2
- package/.next/server/app/_not-found/page.js.nft.json +0 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +0 -1
- package/.next/server/app/_not-found.html +0 -1
- package/.next/server/app/_not-found.meta +0 -16
- package/.next/server/app/_not-found.rsc +0 -18
- package/.next/server/app/_not-found.segments/_full.segment.rsc +0 -18
- package/.next/server/app/_not-found.segments/_head.segment.rsc +0 -6
- package/.next/server/app/_not-found.segments/_index.segment.rsc +0 -5
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +0 -5
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +0 -5
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +0 -4
- package/.next/server/app/api/agent/[id]/events/route.js +0 -3
- package/.next/server/app/api/agent/[id]/events/route.js.nft.json +0 -1
- package/.next/server/app/api/agent/[id]/events/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/agent/[id]/route.js +0 -1
- package/.next/server/app/api/agent/[id]/route.js.nft.json +0 -1
- package/.next/server/app/api/agent/[id]/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/agent/new/route.js +0 -1
- package/.next/server/app/api/agent/new/route.js.nft.json +0 -1
- package/.next/server/app/api/agent/new/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/auth/all-providers/route.js +0 -1
- package/.next/server/app/api/auth/all-providers/route.js.nft.json +0 -1
- package/.next/server/app/api/auth/all-providers/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/auth/api-key/[provider]/route.js +0 -1
- package/.next/server/app/api/auth/api-key/[provider]/route.js.nft.json +0 -1
- package/.next/server/app/api/auth/api-key/[provider]/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/auth/login/[provider]/route.js +0 -1
- package/.next/server/app/api/auth/login/[provider]/route.js.nft.json +0 -1
- package/.next/server/app/api/auth/login/[provider]/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/auth/login/route.js +0 -1
- package/.next/server/app/api/auth/login/route.js.nft.json +0 -1
- package/.next/server/app/api/auth/login/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/auth/logout/[provider]/route.js +0 -1
- package/.next/server/app/api/auth/logout/[provider]/route.js.nft.json +0 -1
- package/.next/server/app/api/auth/logout/[provider]/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/auth/providers/route.js +0 -1
- package/.next/server/app/api/auth/providers/route.js.nft.json +0 -1
- package/.next/server/app/api/auth/providers/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/auth/status/route.js +0 -1
- package/.next/server/app/api/auth/status/route.js.nft.json +0 -1
- package/.next/server/app/api/auth/status/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/default-cwd/route.js +0 -1
- package/.next/server/app/api/default-cwd/route.js.nft.json +0 -1
- package/.next/server/app/api/default-cwd/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/files/[...path]/route.js +0 -4
- package/.next/server/app/api/files/[...path]/route.js.nft.json +0 -1
- package/.next/server/app/api/files/[...path]/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/harness/route.js +0 -1
- package/.next/server/app/api/harness/route.js.nft.json +0 -1
- package/.next/server/app/api/harness/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/home/route.js +0 -1
- package/.next/server/app/api/home/route.js.nft.json +0 -1
- package/.next/server/app/api/home/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/internal/runtime/route.js +0 -1
- package/.next/server/app/api/internal/runtime/route.js.nft.json +0 -1
- package/.next/server/app/api/internal/runtime/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/models/route.js +0 -1
- package/.next/server/app/api/models/route.js.nft.json +0 -1
- package/.next/server/app/api/models/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/models-config/discover/route.js +0 -1
- package/.next/server/app/api/models-config/discover/route.js.nft.json +0 -1
- package/.next/server/app/api/models-config/discover/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/models-config/route.js +0 -1
- package/.next/server/app/api/models-config/route.js.nft.json +0 -1
- package/.next/server/app/api/models-config/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/models-config/test/route.js +0 -1
- package/.next/server/app/api/models-config/test/route.js.nft.json +0 -1
- package/.next/server/app/api/models-config/test/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/projects/browse/route.js +0 -1
- package/.next/server/app/api/projects/browse/route.js.nft.json +0 -1
- package/.next/server/app/api/projects/browse/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/projects/route.js +0 -1
- package/.next/server/app/api/projects/route.js.nft.json +0 -1
- package/.next/server/app/api/projects/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/reports/[id]/route.js +0 -10
- package/.next/server/app/api/reports/[id]/route.js.nft.json +0 -1
- package/.next/server/app/api/reports/[id]/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/search/route.js +0 -1
- package/.next/server/app/api/search/route.js.nft.json +0 -1
- package/.next/server/app/api/search/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/sessions/[id]/context/route.js +0 -1
- package/.next/server/app/api/sessions/[id]/context/route.js.nft.json +0 -1
- package/.next/server/app/api/sessions/[id]/context/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/sessions/[id]/route.js +0 -1
- package/.next/server/app/api/sessions/[id]/route.js.nft.json +0 -1
- package/.next/server/app/api/sessions/[id]/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/sessions/new/route.js +0 -1
- package/.next/server/app/api/sessions/new/route.js.nft.json +0 -1
- package/.next/server/app/api/sessions/new/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/sessions/route.js +0 -1
- package/.next/server/app/api/sessions/route.js.nft.json +0 -1
- package/.next/server/app/api/sessions/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/settings/route.js +0 -1
- package/.next/server/app/api/settings/route.js.nft.json +0 -1
- package/.next/server/app/api/settings/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/skills/install/route.js +0 -5
- package/.next/server/app/api/skills/install/route.js.nft.json +0 -1
- package/.next/server/app/api/skills/install/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/skills/route.js +0 -6
- package/.next/server/app/api/skills/route.js.nft.json +0 -1
- package/.next/server/app/api/skills/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/skills/search/route.js +0 -1
- package/.next/server/app/api/skills/search/route.js.nft.json +0 -1
- package/.next/server/app/api/skills/search/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/soul/route.js +0 -1
- package/.next/server/app/api/soul/route.js.nft.json +0 -1
- package/.next/server/app/api/soul/route_client-reference-manifest.js +0 -1
- package/.next/server/app/api/version/route.js +0 -1
- package/.next/server/app/api/version/route.js.nft.json +0 -1
- package/.next/server/app/api/version/route_client-reference-manifest.js +0 -1
- package/.next/server/app/index.html +0 -1
- package/.next/server/app/index.meta +0 -14
- package/.next/server/app/index.rsc +0 -17
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +0 -6
- package/.next/server/app/index.segments/_full.segment.rsc +0 -17
- package/.next/server/app/index.segments/_head.segment.rsc +0 -6
- package/.next/server/app/index.segments/_index.segment.rsc +0 -5
- package/.next/server/app/index.segments/_tree.segment.rsc +0 -4
- package/.next/server/app/login/page.js +0 -2
- package/.next/server/app/login/page.js.nft.json +0 -1
- package/.next/server/app/login/page_client-reference-manifest.js +0 -1
- package/.next/server/app/login.html +0 -1
- package/.next/server/app/login.meta +0 -15
- package/.next/server/app/login.rsc +0 -22
- package/.next/server/app/login.segments/_full.segment.rsc +0 -22
- package/.next/server/app/login.segments/_head.segment.rsc +0 -6
- package/.next/server/app/login.segments/_index.segment.rsc +0 -5
- package/.next/server/app/login.segments/_tree.segment.rsc +0 -4
- package/.next/server/app/login.segments/login/__PAGE__.segment.rsc +0 -9
- package/.next/server/app/login.segments/login.segment.rsc +0 -5
- package/.next/server/app/page.js +0 -261
- package/.next/server/app/page.js.nft.json +0 -1
- package/.next/server/app/page_client-reference-manifest.js +0 -1
- package/.next/server/app-paths-manifest.json +0 -39
- package/.next/server/chunks/1048.js +0 -1
- package/.next/server/chunks/1367.js +0 -77
- package/.next/server/chunks/1381.js +0 -1
- package/.next/server/chunks/165.js +0 -1
- package/.next/server/chunks/1681.js +0 -215
- package/.next/server/chunks/1688.js +0 -45
- package/.next/server/chunks/1703.js +0 -79
- package/.next/server/chunks/1712.js +0 -43
- package/.next/server/chunks/1813.js +0 -1
- package/.next/server/chunks/2325.js +0 -80
- package/.next/server/chunks/258.js +0 -1
- package/.next/server/chunks/2671.js +0 -287
- package/.next/server/chunks/2778.js +0 -1
- package/.next/server/chunks/2943.js +0 -1
- package/.next/server/chunks/3031.js +0 -226
- package/.next/server/chunks/3181.js +0 -1
- package/.next/server/chunks/3493.js +0 -1
- package/.next/server/chunks/3672.js +0 -1
- package/.next/server/chunks/3701.js +0 -104
- package/.next/server/chunks/4013.js +0 -1
- package/.next/server/chunks/402.js +0 -2
- package/.next/server/chunks/4035.js +0 -80
- package/.next/server/chunks/4248.js +0 -153
- package/.next/server/chunks/4367.js +0 -1
- package/.next/server/chunks/4406.js +0 -141
- package/.next/server/chunks/4741.js +0 -18
- package/.next/server/chunks/4768.js +0 -1
- package/.next/server/chunks/4858.js +0 -148
- package/.next/server/chunks/4980.js +0 -1
- package/.next/server/chunks/5155.js +0 -5
- package/.next/server/chunks/5293.js +0 -166
- package/.next/server/chunks/5399.js +0 -8
- package/.next/server/chunks/5409.js +0 -1
- package/.next/server/chunks/5797.js +0 -93
- package/.next/server/chunks/5851.js +0 -36
- package/.next/server/chunks/6206.js +0 -1
- package/.next/server/chunks/6296.js +0 -1
- package/.next/server/chunks/63.js +0 -45
- package/.next/server/chunks/6346.js +0 -1
- package/.next/server/chunks/6406.js +0 -23
- package/.next/server/chunks/642.js +0 -1
- package/.next/server/chunks/6429.js +0 -50
- package/.next/server/chunks/6729.js +0 -64
- package/.next/server/chunks/6907.js +0 -115
- package/.next/server/chunks/6980.js +0 -1
- package/.next/server/chunks/7073.js +0 -24
- package/.next/server/chunks/7233.js +0 -24
- package/.next/server/chunks/7307.js +0 -1
- package/.next/server/chunks/7362.js +0 -9
- package/.next/server/chunks/7567.js +0 -29
- package/.next/server/chunks/7765.js +0 -1
- package/.next/server/chunks/7890.js +0 -1
- package/.next/server/chunks/8065.js +0 -1
- package/.next/server/chunks/8238.js +0 -34
- package/.next/server/chunks/8276.js +0 -1
- package/.next/server/chunks/8336.js +0 -1
- package/.next/server/chunks/8477.js +0 -3
- package/.next/server/chunks/8490.js +0 -1
- package/.next/server/chunks/8916.js +0 -1
- package/.next/server/chunks/9280.js +0 -252
- package/.next/server/chunks/9315.js +0 -1
- package/.next/server/chunks/9537.js +0 -90
- package/.next/server/chunks/966.js +0 -1
- package/.next/server/chunks/9818.js +0 -21
- package/.next/server/chunks/static/media/pdf.worker.min.c476e1a0.mjs +0 -6
- package/.next/server/functions-config-manifest.json +0 -16
- package/.next/server/interception-route-rewrite-manifest.js +0 -1
- package/.next/server/middleware-build-manifest.js +0 -1
- package/.next/server/middleware-manifest.json +0 -6
- package/.next/server/middleware-react-loadable-manifest.js +0 -1
- package/.next/server/middleware.js +0 -18
- package/.next/server/middleware.js.nft.json +0 -1
- package/.next/server/next-font-manifest.js +0 -1
- package/.next/server/next-font-manifest.json +0 -1
- package/.next/server/pages/404.html +0 -1
- package/.next/server/pages/500.html +0 -1
- package/.next/server/pages-manifest.json +0 -4
- package/.next/server/prefetch-hints.json +0 -1
- package/.next/server/server-reference-manifest.js +0 -1
- package/.next/server/server-reference-manifest.json +0 -1
- package/.next/server/webpack-runtime.js +0 -1
- package/.next/static/6cuMSvcr0FVO-GiK5RJZh/_buildManifest.js +0 -1
- package/.next/static/6cuMSvcr0FVO-GiK5RJZh/_ssgManifest.js +0 -1
- package/.next/static/chunks/0b9a0da7.9075af772487e743.js +0 -62
- package/.next/static/chunks/1413.922d232de90c0c41.js +0 -115
- package/.next/static/chunks/1643.467a526a1f24f54d.js +0 -24
- package/.next/static/chunks/1852.5543122f11aa7fed.js +0 -1
- package/.next/static/chunks/1960.b1e26436d7a5f586.js +0 -1
- package/.next/static/chunks/2170a4aa.4213bb2183c9cdf9.js +0 -1
- package/.next/static/chunks/2274.6cd173f80a1405a2.js +0 -21
- package/.next/static/chunks/2419.347fdfe3c170854d.js +0 -166
- package/.next/static/chunks/2619.9aac8983f30c7c8a.js +0 -1
- package/.next/static/chunks/2623.d20fabd8e18197c6.js +0 -287
- package/.next/static/chunks/2729.f5365061a849d659.js +0 -34
- package/.next/static/chunks/2821.934bcf60fbdc28c6.js +0 -1
- package/.next/static/chunks/2918becc.abff2ece1de37bc1.js +0 -153
- package/.next/static/chunks/2947.114e51cb06d1c01a.js +0 -23
- package/.next/static/chunks/3079.4c511fa1144e3adf.js +0 -79
- package/.next/static/chunks/3274.208ca44844cd7d95.js +0 -148
- package/.next/static/chunks/3308.465a94263d04bfea.js +0 -73
- package/.next/static/chunks/3325.e4bfe1ca657f3b5b.js +0 -80
- package/.next/static/chunks/3506.2a7eaa08b9f55337.js +0 -90
- package/.next/static/chunks/363642f4-043c1475ab9af70e.js +0 -1
- package/.next/static/chunks/3794-123fdf632563f469.js +0 -32
- package/.next/static/chunks/3837.a755ccfe6f9c1c1c.js +0 -5
- package/.next/static/chunks/394.91597771688df6d0.js +0 -1
- package/.next/static/chunks/3997.1009c06025691712.js +0 -1
- package/.next/static/chunks/4453.91a357dc43c21745.js +0 -1
- package/.next/static/chunks/4491.44fdf20580ac72bd.js +0 -24
- package/.next/static/chunks/4829.cf1d50e43e6d9db5.js +0 -1
- package/.next/static/chunks/498.fe1d9da9ecad6c36.js +0 -1
- package/.next/static/chunks/4bd1b696-e356ca5ba0218e27.js +0 -1
- package/.next/static/chunks/5019.b5a1a2b8daf17525.js +0 -1
- package/.next/static/chunks/5034.8f16c3fa3ce75411.js +0 -1
- package/.next/static/chunks/5074.d16651da01ec4e02.js +0 -1
- package/.next/static/chunks/51fb665c.0950e1b79671348d.js +0 -45
- package/.next/static/chunks/532.5956ed631aff722b.js +0 -9
- package/.next/static/chunks/5326.69460442bdcd6cd3.js +0 -1
- package/.next/static/chunks/5403.ff110bf5bf600758.js +0 -64
- package/.next/static/chunks/547.902a733488cfe3f7.js +0 -77
- package/.next/static/chunks/5567.540d7fc108ad6ee5.js +0 -215
- package/.next/static/chunks/5590.ef62922166d308b4.js +0 -1
- package/.next/static/chunks/5690.9d6eb1edb1399995.js +0 -1
- package/.next/static/chunks/5749.25faee4a1e55b854.js +0 -226
- package/.next/static/chunks/58bb9007.1ccb6bba34b4c635.js +0 -80
- package/.next/static/chunks/6121.f3f43f1896ea0cd9.js +0 -1
- package/.next/static/chunks/6600.583c88eef37aa524.js +0 -1
- package/.next/static/chunks/6696.a41aec266e657d54.js +0 -141
- package/.next/static/chunks/6922.42148793782d2fe7.js +0 -1
- package/.next/static/chunks/7006.e191611ffc2b9528.js +0 -43
- package/.next/static/chunks/7343.9fbb58204d8ac681.js +0 -1
- package/.next/static/chunks/73972abe.25a4cffa03b2bcef.js +0 -119
- package/.next/static/chunks/7547.58bda8a2aabba0d4.js +0 -93
- package/.next/static/chunks/7648.4ae2f183b4db0353.js +0 -1
- package/.next/static/chunks/7874.8db6929b94cdf697.js +0 -1
- package/.next/static/chunks/7959.1f20a35df316216a.js +0 -104
- package/.next/static/chunks/83.85d62d7fc9850b75.js +0 -29
- package/.next/static/chunks/8436.cab94b59cca0a8ff.js +0 -1
- package/.next/static/chunks/8451.ff6ff72b57dc52e1.js +0 -1
- package/.next/static/chunks/8489.45f22859734f514f.js +0 -36
- package/.next/static/chunks/8568.f85d8b36fc9a9037.js +0 -1
- package/.next/static/chunks/8771-3e14b6810486df1f.js +0 -1
- package/.next/static/chunks/8863.be51033a67436277.js +0 -1
- package/.next/static/chunks/90542734.dc1a2723e4f6affb.js +0 -1
- package/.next/static/chunks/9500.1488aec06ee78127.js +0 -1
- package/.next/static/chunks/9633.155548b5fca6e580.js +0 -1
- package/.next/static/chunks/9779.673004a62d70e36a.js +0 -1
- package/.next/static/chunks/app/_global-error/page-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/_not-found/page-c72daab99269beff.js +0 -1
- package/.next/static/chunks/app/api/agent/[id]/events/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/agent/[id]/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/agent/new/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/auth/all-providers/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/auth/api-key/[provider]/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/auth/login/[provider]/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/auth/login/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/auth/logout/[provider]/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/auth/providers/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/auth/status/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/default-cwd/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/files/[...path]/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/harness/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/home/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/internal/runtime/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/models/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/models-config/discover/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/models-config/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/models-config/test/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/projects/browse/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/projects/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/reports/[id]/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/search/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/sessions/[id]/context/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/sessions/[id]/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/sessions/new/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/sessions/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/settings/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/skills/install/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/skills/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/skills/search/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/soul/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/api/version/route-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/app/layout-be148b7ae915b22a.js +0 -1
- package/.next/static/chunks/app/login/page-ebf0e6de99062783.js +0 -1
- package/.next/static/chunks/app/page-c45d98ea81c548ca.js +0 -260
- package/.next/static/chunks/d3ac728e.7964f816a1ca64e5.js +0 -1
- package/.next/static/chunks/framework-711ef29bc66f648c.js +0 -1
- package/.next/static/chunks/main-app-45a0f19af99d61b6.js +0 -1
- package/.next/static/chunks/main-f74964b7ae52493e.js +0 -5
- package/.next/static/chunks/next/dist/client/components/builtin/app-error-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/forbidden-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/global-error-9bfa08b9491621f2.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/not-found-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-cc518af6b1ffb191.js +0 -1
- package/.next/static/chunks/polyfills-42372ed130431b0a.js +0 -1
- package/.next/static/chunks/webpack-fcf4a889ecbd753c.js +0 -1
- package/.next/static/css/45029451a1d7255d.css +0 -3
- package/.next/static/media/15605e25b523335c-s.woff2 +0 -0
- package/.next/static/media/1a3dce5cfb5f7760-s.woff2 +0 -0
- package/.next/static/media/1cdd02902f937a18-s.woff2 +0 -0
- package/.next/static/media/4c4b3b30b6bcb2be-s.woff2 +0 -0
- package/.next/static/media/641a7b8a5800ee0e-s.woff2 +0 -0
- package/.next/static/media/7deddc85b7ffd1dc-s.p.woff2 +0 -0
- package/.next/static/media/ec14413c594b3356-s.p.woff2 +0 -0
- package/.next/static/media/pdf.worker.min.29aaf158.mjs +0 -6
- package/.next/trace +0 -74
- package/.next/trace-build +0 -1
- package/.next/types/app/api/agent/[id]/events/route.ts +0 -351
- package/.next/types/app/api/agent/[id]/route.ts +0 -351
- package/.next/types/app/api/agent/new/route.ts +0 -351
- package/.next/types/app/api/auth/all-providers/route.ts +0 -351
- package/.next/types/app/api/auth/api-key/[provider]/route.ts +0 -351
- package/.next/types/app/api/auth/login/[provider]/route.ts +0 -351
- package/.next/types/app/api/auth/login/route.ts +0 -351
- package/.next/types/app/api/auth/logout/[provider]/route.ts +0 -351
- package/.next/types/app/api/auth/providers/route.ts +0 -351
- package/.next/types/app/api/auth/status/route.ts +0 -351
- package/.next/types/app/api/default-cwd/route.ts +0 -351
- package/.next/types/app/api/files/[...path]/route.ts +0 -351
- package/.next/types/app/api/harness/route.ts +0 -351
- package/.next/types/app/api/home/route.ts +0 -351
- package/.next/types/app/api/internal/runtime/route.ts +0 -351
- package/.next/types/app/api/models/route.ts +0 -351
- package/.next/types/app/api/models-config/discover/route.ts +0 -351
- package/.next/types/app/api/models-config/route.ts +0 -351
- package/.next/types/app/api/models-config/test/route.ts +0 -351
- package/.next/types/app/api/projects/browse/route.ts +0 -351
- package/.next/types/app/api/projects/route.ts +0 -351
- package/.next/types/app/api/reports/[id]/route.ts +0 -351
- package/.next/types/app/api/search/route.ts +0 -351
- package/.next/types/app/api/sessions/[id]/context/route.ts +0 -351
- package/.next/types/app/api/sessions/[id]/route.ts +0 -351
- package/.next/types/app/api/sessions/new/route.ts +0 -351
- package/.next/types/app/api/sessions/route.ts +0 -351
- package/.next/types/app/api/settings/route.ts +0 -351
- package/.next/types/app/api/skills/install/route.ts +0 -351
- package/.next/types/app/api/skills/route.ts +0 -351
- package/.next/types/app/api/skills/search/route.ts +0 -351
- package/.next/types/app/api/soul/route.ts +0 -351
- package/.next/types/app/api/version/route.ts +0 -351
- package/.next/types/app/layout.ts +0 -87
- package/.next/types/app/login/page.ts +0 -87
- package/.next/types/app/page.ts +0 -87
- package/.next/types/package.json +0 -1
- package/.next/types/routes.d.ts +0 -106
- package/.next/types/validator.ts +0 -376
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { NextResponse } from "next/server";
|
|
2
|
+
import { listAllSessions, searchCodexSessionEntries } from "@/lib/session-reader";
|
|
3
|
+
import type { SessionEntry, SessionInfo } from "@/lib/types";
|
|
4
|
+
import type { TextContent } from "@/lib/types";
|
|
5
|
+
|
|
6
|
+
interface SearchMatch {
|
|
7
|
+
entryId: string;
|
|
8
|
+
role: "user" | "assistant";
|
|
9
|
+
timestamp: string;
|
|
10
|
+
snippet: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface SearchGroup {
|
|
14
|
+
session: SessionInfo;
|
|
15
|
+
matches: SearchMatch[];
|
|
16
|
+
matchCount: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const MAX_RESULTS = 80;
|
|
20
|
+
const MAX_MATCHES_PER_SESSION = 8;
|
|
21
|
+
|
|
22
|
+
function normalizeText(value: string): string {
|
|
23
|
+
return value.replace(/\s+/g, " ").trim();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function isTextContent(block: unknown): block is TextContent {
|
|
27
|
+
return !!block && typeof block === "object" && (block as { type?: unknown }).type === "text" && typeof (block as { text?: unknown }).text === "string";
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function extractVisibleText(entry: SessionEntry): { role: "user" | "assistant"; text: string } | null {
|
|
31
|
+
if (entry.type !== "message") return null;
|
|
32
|
+
const { message } = entry;
|
|
33
|
+
if (message.role !== "user" && message.role !== "assistant") return null;
|
|
34
|
+
|
|
35
|
+
const content = message.content;
|
|
36
|
+
if (typeof content === "string") {
|
|
37
|
+
return { role: message.role, text: normalizeText(content) };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (!Array.isArray(content)) return null;
|
|
41
|
+
const text = (content as unknown[])
|
|
42
|
+
.filter(isTextContent)
|
|
43
|
+
.map((block: TextContent) => block.text)
|
|
44
|
+
.join(" ");
|
|
45
|
+
return { role: message.role, text: normalizeText(text) };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function buildSnippet(text: string, query: string): string {
|
|
49
|
+
const lowerText = text.toLowerCase();
|
|
50
|
+
const lowerQuery = query.toLowerCase();
|
|
51
|
+
const index = lowerText.indexOf(lowerQuery);
|
|
52
|
+
if (index < 0) return text.slice(0, 180);
|
|
53
|
+
|
|
54
|
+
const start = Math.max(0, index - 70);
|
|
55
|
+
const end = Math.min(text.length, index + query.length + 110);
|
|
56
|
+
const prefix = start > 0 ? "... " : "";
|
|
57
|
+
const suffix = end < text.length ? " ..." : "";
|
|
58
|
+
return `${prefix}${text.slice(start, end)}${suffix}`;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export async function GET(req: Request) {
|
|
62
|
+
try {
|
|
63
|
+
const url = new URL(req.url);
|
|
64
|
+
const query = normalizeText(url.searchParams.get("q") ?? "");
|
|
65
|
+
const scope = url.searchParams.get("scope") === "current" ? "current" : "all";
|
|
66
|
+
const cwd = url.searchParams.get("cwd");
|
|
67
|
+
|
|
68
|
+
if (query.length < 2) {
|
|
69
|
+
return NextResponse.json({ results: [], totalMatches: 0, truncated: false });
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const sessions = (await listAllSessions())
|
|
73
|
+
.filter((session) => scope !== "current" || !cwd || session.cwd === cwd)
|
|
74
|
+
.sort((a, b) => b.modified.localeCompare(a.modified));
|
|
75
|
+
|
|
76
|
+
const results: SearchGroup[] = [];
|
|
77
|
+
let totalMatches = 0;
|
|
78
|
+
let truncated = false;
|
|
79
|
+
|
|
80
|
+
for (const session of sessions) {
|
|
81
|
+
if (totalMatches >= MAX_RESULTS) {
|
|
82
|
+
truncated = true;
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const matches: SearchMatch[] = [];
|
|
87
|
+
let sessionMatchCount = 0;
|
|
88
|
+
|
|
89
|
+
try {
|
|
90
|
+
const entries = await searchCodexSessionEntries(session.id, session.cwd);
|
|
91
|
+
for (const entry of entries) {
|
|
92
|
+
const visible = extractVisibleText(entry);
|
|
93
|
+
if (!visible?.text) continue;
|
|
94
|
+
if (!visible.text.toLowerCase().includes(query.toLowerCase())) continue;
|
|
95
|
+
|
|
96
|
+
sessionMatchCount += 1;
|
|
97
|
+
if (matches.length < MAX_MATCHES_PER_SESSION && totalMatches < MAX_RESULTS) {
|
|
98
|
+
matches.push({
|
|
99
|
+
entryId: entry.id,
|
|
100
|
+
role: visible.role,
|
|
101
|
+
timestamp: entry.timestamp,
|
|
102
|
+
snippet: buildSnippet(visible.text, query),
|
|
103
|
+
});
|
|
104
|
+
totalMatches += 1;
|
|
105
|
+
} else {
|
|
106
|
+
truncated = true;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
} catch {
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (matches.length > 0) {
|
|
114
|
+
results.push({ session, matches, matchCount: sessionMatchCount });
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return NextResponse.json({ results, totalMatches, truncated });
|
|
119
|
+
} catch (error) {
|
|
120
|
+
return NextResponse.json({ error: String(error) }, { status: 500 });
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { NextResponse } from "next/server";
|
|
2
|
+
import { loadCodexSessionContext, resolveSessionPath } from "@/lib/session-reader";
|
|
3
|
+
|
|
4
|
+
export async function GET(
|
|
5
|
+
req: Request,
|
|
6
|
+
{ params }: { params: Promise<{ id: string }> }
|
|
7
|
+
) {
|
|
8
|
+
const { id } = await params;
|
|
9
|
+
const url = new URL(req.url);
|
|
10
|
+
const leafId = url.searchParams.get("leafId") ?? undefined;
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
const cwd = await resolveSessionPath(id);
|
|
14
|
+
if (!cwd) {
|
|
15
|
+
return NextResponse.json({ error: "Session not found" }, { status: 404 });
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const { context } = await loadCodexSessionContext(id, cwd, leafId);
|
|
19
|
+
return NextResponse.json({ context });
|
|
20
|
+
} catch (error) {
|
|
21
|
+
return NextResponse.json({ error: String(error) }, { status: 500 });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { NextResponse } from "next/server";
|
|
2
|
+
import { existsSync } from "fs";
|
|
3
|
+
import {
|
|
4
|
+
resolveSessionPath,
|
|
5
|
+
invalidateSessionPathCache,
|
|
6
|
+
loadCodexSessionContext,
|
|
7
|
+
getSessionInfoById,
|
|
8
|
+
} from "@/lib/session-reader";
|
|
9
|
+
import { getRpcSession } from "@/lib/rpc-manager";
|
|
10
|
+
import { getOrCreateCodexServer, releaseCodexServerConnection } from "@/lib/codex-server";
|
|
11
|
+
import { deleteSessionRuntime } from "@/lib/session-runtime";
|
|
12
|
+
|
|
13
|
+
// GET /api/sessions/[id] — Read session details + context
|
|
14
|
+
export async function GET(
|
|
15
|
+
req: Request,
|
|
16
|
+
{ params }: { params: Promise<{ id: string }> }
|
|
17
|
+
) {
|
|
18
|
+
const { id } = await params;
|
|
19
|
+
try {
|
|
20
|
+
// Look up the session in the registry
|
|
21
|
+
const info = getSessionInfoById(id);
|
|
22
|
+
|
|
23
|
+
if (!info) {
|
|
24
|
+
return NextResponse.json({ error: "Session not found" }, { status: 404 });
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const loaded = await loadCodexSessionContext(id, info.cwd).catch(() => null);
|
|
28
|
+
const context = loaded?.context ?? { messages: [], entryIds: [], thinkingLevel: "off", model: null, subagentRuns: [] };
|
|
29
|
+
const tree = loaded?.tree ?? [];
|
|
30
|
+
const leafId = loaded?.leafId ?? null;
|
|
31
|
+
|
|
32
|
+
// Query agent state if running
|
|
33
|
+
const url = new URL(req.url);
|
|
34
|
+
let agentState: { running: boolean; state?: unknown } | undefined;
|
|
35
|
+
if (url.searchParams.has("includeState")) {
|
|
36
|
+
const rpc = getRpcSession(id);
|
|
37
|
+
if (rpc?.isAlive()) {
|
|
38
|
+
const state = await rpc.send({ type: "get_state" });
|
|
39
|
+
agentState = { running: rpc.isBusy(), state };
|
|
40
|
+
} else {
|
|
41
|
+
agentState = { running: false };
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return NextResponse.json({
|
|
46
|
+
sessionId: id,
|
|
47
|
+
filePath: "",
|
|
48
|
+
info: { ...info, cwdExists: info.cwd ? existsSync(info.cwd) : false },
|
|
49
|
+
tree,
|
|
50
|
+
leafId,
|
|
51
|
+
context,
|
|
52
|
+
...(agentState !== undefined ? { agentState } : {}),
|
|
53
|
+
});
|
|
54
|
+
} catch (error) {
|
|
55
|
+
return NextResponse.json({ error: String(error) }, { status: 500 });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// PATCH /api/sessions/[id] — Rename session
|
|
60
|
+
export async function PATCH(
|
|
61
|
+
req: Request,
|
|
62
|
+
{ params }: { params: Promise<{ id: string }> }
|
|
63
|
+
) {
|
|
64
|
+
const { id } = await params;
|
|
65
|
+
try {
|
|
66
|
+
const { name } = await req.json() as { name?: string };
|
|
67
|
+
if (typeof name !== "string") {
|
|
68
|
+
return NextResponse.json({ error: "name is required" }, { status: 400 });
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Try to rename via codex server
|
|
72
|
+
try {
|
|
73
|
+
const cwd = await resolveSessionPath(id);
|
|
74
|
+
if (cwd) {
|
|
75
|
+
const codexSession = getRpcSession(id);
|
|
76
|
+
if (codexSession) {
|
|
77
|
+
await codexSession.inner.rename(name.trim());
|
|
78
|
+
} else {
|
|
79
|
+
const connection = await getOrCreateCodexServer(cwd);
|
|
80
|
+
try {
|
|
81
|
+
await connection.request("thread/name/set", {
|
|
82
|
+
threadId: id,
|
|
83
|
+
name: name.trim(),
|
|
84
|
+
});
|
|
85
|
+
} finally {
|
|
86
|
+
releaseCodexServerConnection(connection);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
} catch {
|
|
91
|
+
// Fall back to registry-only update
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return NextResponse.json({ ok: true });
|
|
95
|
+
} catch (error) {
|
|
96
|
+
return NextResponse.json({ error: String(error) }, { status: 500 });
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// DELETE /api/sessions/[id]
|
|
101
|
+
export async function DELETE(
|
|
102
|
+
_req: Request,
|
|
103
|
+
{ params }: { params: Promise<{ id: string }> }
|
|
104
|
+
) {
|
|
105
|
+
const { id } = await params;
|
|
106
|
+
try {
|
|
107
|
+
// Destroy running session if any
|
|
108
|
+
getRpcSession(id)?.destroy();
|
|
109
|
+
const cwd = await resolveSessionPath(id);
|
|
110
|
+
if (cwd) {
|
|
111
|
+
const connection = await getOrCreateCodexServer(cwd);
|
|
112
|
+
try {
|
|
113
|
+
await connection.request("thread/archive", { threadId: id }).catch(() => {});
|
|
114
|
+
} finally {
|
|
115
|
+
releaseCodexServerConnection(connection);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
invalidateSessionPathCache(id);
|
|
119
|
+
deleteSessionRuntime(id);
|
|
120
|
+
return NextResponse.json({ ok: true });
|
|
121
|
+
} catch (error) {
|
|
122
|
+
return NextResponse.json({ error: String(error) }, { status: 500 });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { NextResponse } from "next/server";
|
|
2
|
+
import { listAllSessions } from "@/lib/session-reader";
|
|
3
|
+
|
|
4
|
+
export async function GET(req: Request) {
|
|
5
|
+
try {
|
|
6
|
+
const url = new URL(req.url);
|
|
7
|
+
const cwd = url.searchParams.get("cwd");
|
|
8
|
+
const sessions = await listAllSessions({ cwd });
|
|
9
|
+
return NextResponse.json({ sessions });
|
|
10
|
+
} catch (error) {
|
|
11
|
+
return NextResponse.json(
|
|
12
|
+
{ error: String(error) },
|
|
13
|
+
{ status: 500 }
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Settings API — reads/writes ~/.config/annodex/providers.json + generativeUI
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { NextResponse } from "next/server";
|
|
6
|
+
import { readMergedConfig, readProvidersFile as readProviders, writeProvidersFile as writeProviders } from "@/lib/annodex-config";
|
|
7
|
+
|
|
8
|
+
export const dynamic = "force-dynamic";
|
|
9
|
+
|
|
10
|
+
export async function GET() {
|
|
11
|
+
const data = readProviders();
|
|
12
|
+
const merged = readMergedConfig();
|
|
13
|
+
return NextResponse.json({
|
|
14
|
+
settings: {
|
|
15
|
+
generativeUI: data.generativeUI !== false,
|
|
16
|
+
providers: data.providers.map((p) => ({
|
|
17
|
+
id: p.id, name: p.name, baseUrl: p.baseUrl,
|
|
18
|
+
hasKey: !!p.apiKey, models: p.models,
|
|
19
|
+
})),
|
|
20
|
+
defaultProvider: merged.defaultProvider,
|
|
21
|
+
defaultModel: merged.defaultModel,
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export async function PUT(req: Request) {
|
|
27
|
+
try {
|
|
28
|
+
const body = await req.json() as {
|
|
29
|
+
settings?: {
|
|
30
|
+
generativeUI?: boolean;
|
|
31
|
+
defaultProvider?: string;
|
|
32
|
+
defaultModel?: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
const s = body.settings;
|
|
36
|
+
if (!s || typeof s !== "object") {
|
|
37
|
+
return NextResponse.json({ error: "Invalid settings" }, { status: 400 });
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const data = readProviders();
|
|
41
|
+
if (!data.exists) data.providers = [];
|
|
42
|
+
if (typeof s.generativeUI === "boolean") data.generativeUI = s.generativeUI;
|
|
43
|
+
delete data.defaultProvider;
|
|
44
|
+
delete data.defaultModel;
|
|
45
|
+
writeProviders(data);
|
|
46
|
+
|
|
47
|
+
return NextResponse.json({ success: true });
|
|
48
|
+
} catch (error) {
|
|
49
|
+
return NextResponse.json({ error: String(error) }, { status: 500 });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { NextResponse } from "next/server";
|
|
2
|
+
import { runNpx, spawnNpx } from "@/lib/npx";
|
|
3
|
+
|
|
4
|
+
export const dynamic = "force-dynamic";
|
|
5
|
+
export const runtime = "nodejs";
|
|
6
|
+
|
|
7
|
+
const SKILLS_INSTALL_TIMEOUT_MS = 10 * 60 * 1000;
|
|
8
|
+
const ANSI_RE = /\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~]|\][^\x07]*(?:\x07|\x1B\\))/g;
|
|
9
|
+
const MAX_STREAM_OUTPUT_CHARS = 1024 * 1024;
|
|
10
|
+
|
|
11
|
+
type InstallRequest = {
|
|
12
|
+
package?: string;
|
|
13
|
+
scope?: string;
|
|
14
|
+
cwd?: string;
|
|
15
|
+
stream?: boolean;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
type ProgressPattern = {
|
|
19
|
+
key: string;
|
|
20
|
+
stage: string;
|
|
21
|
+
regex: RegExp;
|
|
22
|
+
line: string | ((match: RegExpMatchArray) => string);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const PROGRESS_PATTERNS: ProgressPattern[] = [
|
|
26
|
+
{
|
|
27
|
+
key: "source",
|
|
28
|
+
stage: "Source resolved",
|
|
29
|
+
regex: /Source:\s*([^\n]+)/,
|
|
30
|
+
line: (match) => `Source: ${match[1].trim()}`,
|
|
31
|
+
},
|
|
32
|
+
{ key: "fetch", stage: "Fetching skills", regex: /Fetching skills/, line: "Fetching skills" },
|
|
33
|
+
{ key: "clone", stage: "Cloning repository", regex: /Cloning repository/, line: "Cloning repository" },
|
|
34
|
+
{ key: "cloned", stage: "Repository cloned", regex: /Repository cloned/, line: "Repository cloned" },
|
|
35
|
+
{ key: "discover", stage: "Discovering skills", regex: /Discovering skills/, line: "Discovering skills" },
|
|
36
|
+
{
|
|
37
|
+
key: "found",
|
|
38
|
+
stage: "Skills discovered",
|
|
39
|
+
regex: /(Found\s+\d+\s+skills?)/,
|
|
40
|
+
line: (match) => match[1],
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
key: "selected",
|
|
44
|
+
stage: "Skill selected",
|
|
45
|
+
regex: /(Selected\s+\d+\s+skills?:?\s*[^\n]*)/,
|
|
46
|
+
line: (match) => match[1],
|
|
47
|
+
},
|
|
48
|
+
{ key: "summary", stage: "Preparing install", regex: /Installation Summary/, line: "Preparing install" },
|
|
49
|
+
{ key: "risk", stage: "Checking risk report", regex: /Security Risk Assessments/, line: "Checking risk report" },
|
|
50
|
+
{ key: "complete", stage: "Installation complete", regex: /Installation complete/, line: "Installation complete" },
|
|
51
|
+
{
|
|
52
|
+
key: "installed",
|
|
53
|
+
stage: "Installed",
|
|
54
|
+
regex: /(Installed\s+\d+\s+skills?)/,
|
|
55
|
+
line: (match) => match[1],
|
|
56
|
+
},
|
|
57
|
+
{ key: "done", stage: "Done", regex: /Done!/, line: "Done" },
|
|
58
|
+
{ key: "clone-failed", stage: "Clone failed", regex: /Failed to clone repository/, line: "Failed to clone repository" },
|
|
59
|
+
{ key: "failed", stage: "Installation failed", regex: /Installation failed|Failed to install/, line: "Installation failed" },
|
|
60
|
+
];
|
|
61
|
+
|
|
62
|
+
function cleanOutput(raw: string): string {
|
|
63
|
+
return raw
|
|
64
|
+
.replace(ANSI_RE, "")
|
|
65
|
+
.replace(/\r/g, "\n")
|
|
66
|
+
.split("\n")
|
|
67
|
+
.map((line) => line.replace(/\s+/g, " ").trim())
|
|
68
|
+
.filter(Boolean)
|
|
69
|
+
.filter((line, index, lines) => index === 0 || line !== lines[index - 1])
|
|
70
|
+
.join("\n");
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function tailOutput(output: string): string {
|
|
74
|
+
return output.split("\n").slice(-20).join("\n");
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function progressEvents(raw: string): Array<{ key: string; stage: string; line: string }> {
|
|
78
|
+
const clean = cleanOutput(raw);
|
|
79
|
+
const events: Array<{ key: string; stage: string; line: string }> = [];
|
|
80
|
+
for (const pattern of PROGRESS_PATTERNS) {
|
|
81
|
+
const match = clean.match(pattern.regex);
|
|
82
|
+
if (!match) continue;
|
|
83
|
+
const line = typeof pattern.line === "function" ? pattern.line(match) : pattern.line;
|
|
84
|
+
events.push({ key: pattern.key, stage: pattern.stage, line });
|
|
85
|
+
}
|
|
86
|
+
return events;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function isSuccessfulInstall(output: string): boolean {
|
|
90
|
+
return /Installation complete|Installed \d+ skill/.test(output);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function killProcessTree(child: ReturnType<typeof spawnNpx>) {
|
|
94
|
+
if (child.exitCode !== null || child.signalCode !== null) return;
|
|
95
|
+
try {
|
|
96
|
+
if (process.platform !== "win32" && child.pid) process.kill(-child.pid, "SIGTERM");
|
|
97
|
+
else child.kill("SIGTERM");
|
|
98
|
+
} catch {
|
|
99
|
+
child.kill("SIGTERM");
|
|
100
|
+
}
|
|
101
|
+
setTimeout(() => {
|
|
102
|
+
if (child.exitCode !== null || child.signalCode !== null) return;
|
|
103
|
+
try {
|
|
104
|
+
if (process.platform !== "win32" && child.pid) process.kill(-child.pid, "SIGKILL");
|
|
105
|
+
else child.kill("SIGKILL");
|
|
106
|
+
} catch {
|
|
107
|
+
// Process is already gone.
|
|
108
|
+
}
|
|
109
|
+
}, 5000).unref();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function streamInstall(req: Request, args: string[], cwd: string | undefined): Response {
|
|
113
|
+
const encoder = new TextEncoder();
|
|
114
|
+
let child: ReturnType<typeof spawnNpx> | null = null;
|
|
115
|
+
|
|
116
|
+
const stream = new ReadableStream({
|
|
117
|
+
start(controller) {
|
|
118
|
+
let output = "";
|
|
119
|
+
let settled = false;
|
|
120
|
+
const seenProgress = new Set<string>();
|
|
121
|
+
|
|
122
|
+
const send = (event: unknown) => {
|
|
123
|
+
controller.enqueue(encoder.encode(`${JSON.stringify(event)}\n`));
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const cleanup = () => {
|
|
127
|
+
clearTimeout(timeout);
|
|
128
|
+
req.signal.removeEventListener("abort", abort);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const finish = (event: unknown) => {
|
|
132
|
+
if (settled) return;
|
|
133
|
+
settled = true;
|
|
134
|
+
cleanup();
|
|
135
|
+
try {
|
|
136
|
+
send(event);
|
|
137
|
+
} finally {
|
|
138
|
+
controller.close();
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const fail = (message: string) => {
|
|
143
|
+
const clean = cleanOutput(output);
|
|
144
|
+
finish({ type: "error", error: message, output: clean });
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const abort = () => {
|
|
148
|
+
if (settled) return;
|
|
149
|
+
settled = true;
|
|
150
|
+
cleanup();
|
|
151
|
+
if (child) killProcessTree(child);
|
|
152
|
+
try {
|
|
153
|
+
controller.close();
|
|
154
|
+
} catch {
|
|
155
|
+
// Client already disconnected.
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
const timeout = setTimeout(() => {
|
|
160
|
+
if (child) killProcessTree(child);
|
|
161
|
+
const clean = cleanOutput(output);
|
|
162
|
+
fail(`Skill installation timed out after ${Math.round(SKILLS_INSTALL_TIMEOUT_MS / 60000)} minutes while cloning or installing. Last output:\n${tailOutput(clean)}`);
|
|
163
|
+
}, SKILLS_INSTALL_TIMEOUT_MS);
|
|
164
|
+
|
|
165
|
+
req.signal.addEventListener("abort", abort);
|
|
166
|
+
child = spawnNpx(args, {
|
|
167
|
+
cwd,
|
|
168
|
+
env: { ...process.env, FORCE_COLOR: "0" },
|
|
169
|
+
detached: process.platform !== "win32",
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
send({ type: "progress", stage: "Starting installer", line: "Starting installer" });
|
|
173
|
+
|
|
174
|
+
const handleOutput = (chunk: Buffer) => {
|
|
175
|
+
const raw = chunk.toString("utf8");
|
|
176
|
+
output = (output + raw).slice(-MAX_STREAM_OUTPUT_CHARS);
|
|
177
|
+
for (const event of progressEvents(output)) {
|
|
178
|
+
const key = `${event.key}:${event.line}`;
|
|
179
|
+
if (seenProgress.has(key)) continue;
|
|
180
|
+
seenProgress.add(key);
|
|
181
|
+
send({ type: "progress", stage: event.stage, line: event.line });
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
child.stdout.on("data", handleOutput);
|
|
186
|
+
child.stderr.on("data", handleOutput);
|
|
187
|
+
child.on("error", (err) => {
|
|
188
|
+
fail(err.message);
|
|
189
|
+
});
|
|
190
|
+
child.on("close", (code, signal) => {
|
|
191
|
+
if (settled) return;
|
|
192
|
+
const clean = cleanOutput(output);
|
|
193
|
+
if (isSuccessfulInstall(clean)) {
|
|
194
|
+
finish({ type: "done", success: true, output: clean });
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
const suffix = code !== null ? `exit code ${code}` : `signal ${signal ?? "unknown"}`;
|
|
198
|
+
fail(`${tailOutput(clean) || "Install failed"}\nInstaller exited with ${suffix}.`);
|
|
199
|
+
});
|
|
200
|
+
},
|
|
201
|
+
cancel() {
|
|
202
|
+
if (child) killProcessTree(child);
|
|
203
|
+
},
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
return new Response(stream, {
|
|
207
|
+
headers: {
|
|
208
|
+
"Content-Type": "application/x-ndjson; charset=utf-8",
|
|
209
|
+
"Cache-Control": "no-store, no-transform",
|
|
210
|
+
"X-Accel-Buffering": "no",
|
|
211
|
+
},
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// POST /api/skills/install body: { package: string; scope: "global" | "project"; cwd?: string }
|
|
216
|
+
export async function POST(req: Request) {
|
|
217
|
+
try {
|
|
218
|
+
const { package: pkg, scope, cwd, stream } = await req.json() as InstallRequest;
|
|
219
|
+
if (!pkg?.trim()) return NextResponse.json({ error: "package required" }, { status: 400 });
|
|
220
|
+
|
|
221
|
+
const isGlobal = scope !== "project";
|
|
222
|
+
const args = ["--yes", "skills", "add", pkg.trim(), "-y", "--agent", "codex"];
|
|
223
|
+
if (isGlobal) args.push("-g");
|
|
224
|
+
|
|
225
|
+
console.log(`[skills/install] running: npx ${args.join(" ")}`);
|
|
226
|
+
if (stream) return streamInstall(req, args, !isGlobal && cwd ? cwd : undefined);
|
|
227
|
+
|
|
228
|
+
const { stdout, stderr } = await runNpx(args, {
|
|
229
|
+
timeout: SKILLS_INSTALL_TIMEOUT_MS,
|
|
230
|
+
cwd: !isGlobal && cwd ? cwd : undefined,
|
|
231
|
+
env: { ...process.env, FORCE_COLOR: "0" },
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
const output = cleanOutput(stdout + stderr);
|
|
235
|
+
const success = isSuccessfulInstall(output);
|
|
236
|
+
if (!success) {
|
|
237
|
+
return NextResponse.json({ error: tailOutput(output) || "Install failed", output }, { status: 500 });
|
|
238
|
+
}
|
|
239
|
+
return NextResponse.json({ success: true, output });
|
|
240
|
+
} catch (e: unknown) {
|
|
241
|
+
const err = e as { stdout?: string; stderr?: string; message?: string; signal?: string; killed?: boolean };
|
|
242
|
+
const output = cleanOutput((err.stdout ?? "") + (err.stderr ?? ""));
|
|
243
|
+
const timedOut = err.killed || err.signal === "SIGTERM" || /timed out|timeout/i.test(err.message ?? "");
|
|
244
|
+
const message = timedOut
|
|
245
|
+
? `Skill installation timed out after ${Math.round(SKILLS_INSTALL_TIMEOUT_MS / 60000)} minutes while cloning or installing. Last output:\n${tailOutput(output)}`
|
|
246
|
+
: tailOutput(output) || (err.message ?? String(e));
|
|
247
|
+
return NextResponse.json({ error: message, output }, { status: 500 });
|
|
248
|
+
}
|
|
249
|
+
}
|