@seqyuan/annodex 0.1.11 → 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/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-a4bfb7d711561cb3.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/lFCcFmLd1ThQXTFUP6olh/_buildManifest.js +0 -1
- package/.next/static/lFCcFmLd1ThQXTFUP6olh/_ssgManifest.js +0 -1
- 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,668 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RPC Manager — Codex app-server backend
|
|
3
|
+
*
|
|
4
|
+
* Replaces the original pi-agent backend. Manages CodexSession instances (backed by codex app-server)
|
|
5
|
+
* and routes commands from the Next.js API layer to the codex app-server.
|
|
6
|
+
*
|
|
7
|
+
* Session lifecycle:
|
|
8
|
+
* 1. POST /api/agent/new → startRpcSession() creates a new codex thread
|
|
9
|
+
* 2. POST /api/agent/[id] → getRpcSession()+send() routes commands
|
|
10
|
+
* 3. GET /api/agent/[id]/events → SSE stream from session.onEvent()
|
|
11
|
+
* 4. Idle timeout (10 min) → destroy()
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { CodexSession, createCodexSession, resumeCodexSession, type AgentEvent, type EventListener } from "./codex-session";
|
|
15
|
+
import {
|
|
16
|
+
getOrCreateCodexServer,
|
|
17
|
+
releaseCodexServerConnection,
|
|
18
|
+
codexServerEnvForModel,
|
|
19
|
+
type CodexServerConnection,
|
|
20
|
+
} from "./codex-server";
|
|
21
|
+
import { findProvider, normalizeRuntimeProviderId, readMergedConfig, resolveModel, type MergedConfig, type ProviderConfig } from "./annodex-config";
|
|
22
|
+
import {
|
|
23
|
+
stripWidgetPromptBlocks,
|
|
24
|
+
withWidgetCapabilityPrompt,
|
|
25
|
+
} from "./widget-prompt";
|
|
26
|
+
import { stripAnalysisReportPrompt, withAnalysisReportPrompt } from "./report-prompt";
|
|
27
|
+
import { readFileSync, existsSync, writeFileSync, mkdirSync } from "fs";
|
|
28
|
+
import { dirname, join } from "path";
|
|
29
|
+
import { homedir } from "os";
|
|
30
|
+
import { findCodexSessionFile, getAgentDir } from "./session-reader";
|
|
31
|
+
import { readSessionRuntime, upsertSessionRuntime } from "./session-runtime";
|
|
32
|
+
import { readCodexUsageFromFile } from "./codex-usage";
|
|
33
|
+
|
|
34
|
+
// ============================================================================
|
|
35
|
+
// Types
|
|
36
|
+
// ============================================================================
|
|
37
|
+
|
|
38
|
+
type BusyOperation = "prompt" | "compact";
|
|
39
|
+
|
|
40
|
+
export interface RuntimeSessionStatus {
|
|
41
|
+
sessionId: string;
|
|
42
|
+
sessionFile: string;
|
|
43
|
+
busy: boolean;
|
|
44
|
+
operations: BusyOperation[];
|
|
45
|
+
isStreaming: boolean;
|
|
46
|
+
isCompacting: boolean;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface RuntimeStatus {
|
|
50
|
+
busy: boolean;
|
|
51
|
+
activeSessions: number;
|
|
52
|
+
busySessions: RuntimeSessionStatus[];
|
|
53
|
+
sessions: RuntimeSessionStatus[];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function errorMessage(error: unknown): string {
|
|
57
|
+
return error instanceof Error ? error.message : String(error);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function isThreadNotFoundError(error: unknown): boolean {
|
|
61
|
+
return /thread not found|not found/i.test(errorMessage(error));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// ============================================================================
|
|
65
|
+
// CodexSessionWrapper — wraps CodexSession with command dispatch and lifecycle
|
|
66
|
+
// ============================================================================
|
|
67
|
+
|
|
68
|
+
export class CodexSessionWrapper {
|
|
69
|
+
private listeners: EventListener[] = [];
|
|
70
|
+
private cleanupEventSub: (() => void) | null = null;
|
|
71
|
+
private idleTimer: ReturnType<typeof setTimeout> | null = null;
|
|
72
|
+
private onDestroyCallback: (() => void) | null = null;
|
|
73
|
+
private busyOperations = new Set<BusyOperation>();
|
|
74
|
+
private _alive = true;
|
|
75
|
+
private _serverConnection: CodexServerConnection;
|
|
76
|
+
private _thinkingLevel = "auto";
|
|
77
|
+
|
|
78
|
+
constructor(
|
|
79
|
+
public inner: CodexSession,
|
|
80
|
+
) {
|
|
81
|
+
this._serverConnection = inner.connection;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
get sessionId(): string {
|
|
85
|
+
return this.inner.sessionId;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
get sessionFile(): string {
|
|
89
|
+
return this.inner.sessionFile;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
get cwd(): string {
|
|
93
|
+
return this.inner.cwd;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
isAlive(): boolean {
|
|
97
|
+
return this._alive && this.inner.isAlive;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
isBusy(): boolean {
|
|
101
|
+
return this.busyOperations.size > 0 || this.inner.isStreaming || this.inner.isCompacting;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
getRuntimeStatus(): RuntimeSessionStatus {
|
|
105
|
+
return {
|
|
106
|
+
sessionId: this.sessionId,
|
|
107
|
+
sessionFile: this.sessionFile,
|
|
108
|
+
busy: this.isBusy(),
|
|
109
|
+
operations: [...this.busyOperations],
|
|
110
|
+
isStreaming: this.inner.isStreaming,
|
|
111
|
+
isCompacting: this.inner.isCompacting,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
start(): void {
|
|
116
|
+
this.cleanupEventSub?.();
|
|
117
|
+
this.cleanupEventSub = this.inner.onEvent((event: AgentEvent) => {
|
|
118
|
+
this.resetIdleTimer();
|
|
119
|
+
for (const l of this.listeners) l(event);
|
|
120
|
+
});
|
|
121
|
+
this.resetIdleTimer();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
private resetIdleTimer(): void {
|
|
125
|
+
if (this.idleTimer) clearTimeout(this.idleTimer);
|
|
126
|
+
this.idleTimer = setTimeout(() => {
|
|
127
|
+
if (this.isBusy()) {
|
|
128
|
+
this.resetIdleTimer();
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
this.destroy();
|
|
132
|
+
}, 10 * 60 * 1000);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
onEvent(listener: EventListener): () => void {
|
|
136
|
+
this.listeners.push(listener);
|
|
137
|
+
return () => {
|
|
138
|
+
const i = this.listeners.indexOf(listener);
|
|
139
|
+
if (i !== -1) this.listeners.splice(i, 1);
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
onDestroy(cb: () => void): void {
|
|
144
|
+
this.onDestroyCallback = cb;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
async send(command: Record<string, unknown>): Promise<unknown> {
|
|
148
|
+
this.resetIdleTimer();
|
|
149
|
+
const type = command.type as string;
|
|
150
|
+
|
|
151
|
+
switch (type) {
|
|
152
|
+
case "prompt": {
|
|
153
|
+
const promptImages = command.images as Array<{ type: "image"; data: string; mimeType: string }> | undefined;
|
|
154
|
+
const message = command.message as string;
|
|
155
|
+
// Fire and forget — events come via onEvent subscription
|
|
156
|
+
this.trackBusy("prompt", this.inner.prompt(message, promptImages?.map((img) => ({
|
|
157
|
+
data: img.data,
|
|
158
|
+
mimeType: img.mimeType,
|
|
159
|
+
})))).catch(() => {});
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
case "abort": {
|
|
164
|
+
await this.inner.abort();
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
case "get_state": {
|
|
169
|
+
const usage = readCodexUsageFromFile(findCodexSessionFile(this.inner.sessionId), this.inner.model?.modelId);
|
|
170
|
+
return {
|
|
171
|
+
sessionId: this.inner.sessionId,
|
|
172
|
+
sessionFile: "",
|
|
173
|
+
isStreaming: this.inner.isStreaming,
|
|
174
|
+
isCompacting: this.inner.isCompacting,
|
|
175
|
+
autoCompactionEnabled: true,
|
|
176
|
+
autoRetryEnabled: true,
|
|
177
|
+
model: this.inner.model ? {
|
|
178
|
+
id: this.inner.model.modelId,
|
|
179
|
+
provider: this.inner.model.provider,
|
|
180
|
+
...(usage.contextUsage?.contextWindow ? { contextWindow: usage.contextUsage.contextWindow } : {}),
|
|
181
|
+
} : undefined,
|
|
182
|
+
messageCount: 0,
|
|
183
|
+
pendingMessageCount: 0,
|
|
184
|
+
contextUsage: usage.contextUsage,
|
|
185
|
+
systemPrompt: this.inner.baseInstructions ?? "",
|
|
186
|
+
thinkingLevel: this._thinkingLevel,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
case "set_model": {
|
|
191
|
+
const { provider, modelId } = command as { provider: string; modelId: string };
|
|
192
|
+
const cfg = readMergedConfig();
|
|
193
|
+
const normalizedProvider = normalizeRuntimeProviderId(cfg, provider);
|
|
194
|
+
const target = resolveModel(cfg, modelId, normalizedProvider ?? provider);
|
|
195
|
+
const targetProvider = target?.provider ?? findProvider(cfg, normalizedProvider ?? provider);
|
|
196
|
+
const targetProviderId = target?.provider.id ?? normalizedProvider ?? provider;
|
|
197
|
+
const targetModelId = target?.modelId ?? modelId;
|
|
198
|
+
|
|
199
|
+
if (targetProvider) {
|
|
200
|
+
const targetConnection = await getOrCreateCodexServer(this.cwd, codexServerEnvForModel(
|
|
201
|
+
targetProvider,
|
|
202
|
+
targetModelId,
|
|
203
|
+
this._thinkingLevel,
|
|
204
|
+
));
|
|
205
|
+
if (targetConnection.serverKey !== this._serverConnection.serverKey) {
|
|
206
|
+
// Cross-provider switch: each codex app-server instance only knows
|
|
207
|
+
// its own threads, so the old thread won't be found on the new
|
|
208
|
+
// server. Create a fresh thread directly.
|
|
209
|
+
const previousConnection = this._serverConnection;
|
|
210
|
+
const previousInner = this.inner;
|
|
211
|
+
const previousSessionId = previousInner.sessionId;
|
|
212
|
+
let nextInner: CodexSession | undefined;
|
|
213
|
+
try {
|
|
214
|
+
nextInner = await resumeCodexSession(targetConnection, this.sessionId, this.cwd);
|
|
215
|
+
} catch {
|
|
216
|
+
// Thread not accessible from new provider instance — expected.
|
|
217
|
+
}
|
|
218
|
+
if (!nextInner) {
|
|
219
|
+
nextInner = await createCodexSession(targetConnection, {
|
|
220
|
+
cwd: this.cwd,
|
|
221
|
+
baseInstructions: previousInner.baseInstructions,
|
|
222
|
+
model: { provider: targetProviderId, modelId: targetModelId },
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
await nextInner.setModel(targetProviderId, targetModelId);
|
|
226
|
+
this.cleanupEventSub?.();
|
|
227
|
+
previousInner.destroy();
|
|
228
|
+
this.inner = nextInner;
|
|
229
|
+
this._serverConnection = targetConnection;
|
|
230
|
+
this.start();
|
|
231
|
+
releaseCodexServerConnection(previousConnection);
|
|
232
|
+
if (nextInner.sessionId !== previousSessionId) {
|
|
233
|
+
const registry = getRegistry();
|
|
234
|
+
aliasSession(previousSessionId, nextInner.sessionId);
|
|
235
|
+
registry.delete(previousSessionId);
|
|
236
|
+
registry.set(nextInner.sessionId, this);
|
|
237
|
+
this.onDestroyCallback = () => {
|
|
238
|
+
registry.delete(nextInner.sessionId);
|
|
239
|
+
clearAliasesFor(nextInner.sessionId);
|
|
240
|
+
};
|
|
241
|
+
upsertSessionRuntime(nextInner.sessionId, {
|
|
242
|
+
cwd: this.cwd,
|
|
243
|
+
provider: targetProviderId,
|
|
244
|
+
modelId: targetModelId,
|
|
245
|
+
thinkingLevel: this._thinkingLevel,
|
|
246
|
+
});
|
|
247
|
+
return { id: targetModelId, provider: targetProviderId, newSessionId: nextInner.sessionId };
|
|
248
|
+
}
|
|
249
|
+
} else {
|
|
250
|
+
releaseCodexServerConnection(targetConnection);
|
|
251
|
+
await this.inner.setModel(targetProviderId, targetModelId);
|
|
252
|
+
}
|
|
253
|
+
} else {
|
|
254
|
+
await this.inner.setModel(targetProviderId, targetModelId);
|
|
255
|
+
}
|
|
256
|
+
upsertSessionRuntime(this.sessionId, {
|
|
257
|
+
cwd: this.cwd,
|
|
258
|
+
provider: this.inner.model?.provider ?? targetProviderId,
|
|
259
|
+
modelId: this.inner.model?.modelId ?? targetModelId,
|
|
260
|
+
});
|
|
261
|
+
return { id: targetModelId, provider: targetProviderId };
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
case "rename": {
|
|
265
|
+
const name = typeof command.name === "string" ? command.name : "";
|
|
266
|
+
await this.inner.rename(name);
|
|
267
|
+
return null;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
case "fork": {
|
|
271
|
+
const result = await this.inner.fork();
|
|
272
|
+
if ("newThreadId" in result) {
|
|
273
|
+
upsertSessionRuntime(result.newThreadId, {
|
|
274
|
+
cwd: this.cwd,
|
|
275
|
+
provider: this.inner.model?.provider,
|
|
276
|
+
modelId: this.inner.model?.modelId,
|
|
277
|
+
thinkingLevel: this._thinkingLevel,
|
|
278
|
+
});
|
|
279
|
+
this.destroy();
|
|
280
|
+
return { cancelled: false, newSessionId: result.newThreadId };
|
|
281
|
+
}
|
|
282
|
+
return { cancelled: true };
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
case "navigate_tree": {
|
|
286
|
+
const targetId = command.targetId as string;
|
|
287
|
+
const result = await this.inner.navigateTree(targetId);
|
|
288
|
+
return { cancelled: result.cancelled };
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
case "compact": {
|
|
292
|
+
await this.trackBusy("compact", this.inner.compact());
|
|
293
|
+
return null;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
case "get_tools": {
|
|
297
|
+
// Codex has built-in tools (bash, edit, web_search, etc.)
|
|
298
|
+
// Return a basic set — codex manages its own tool activation
|
|
299
|
+
return [
|
|
300
|
+
{ name: "read", description: "Read files", active: true },
|
|
301
|
+
{ name: "bash", description: "Run shell commands", active: true },
|
|
302
|
+
{ name: "edit", description: "Edit files", active: true },
|
|
303
|
+
{ name: "write", description: "Create files", active: true },
|
|
304
|
+
{ name: "grep", description: "Search files", active: true },
|
|
305
|
+
{ name: "find", description: "List files", active: true },
|
|
306
|
+
];
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
case "set_tools": {
|
|
310
|
+
// Codex doesn't support dynamic tool activation in the same way
|
|
311
|
+
// This is a no-op for now
|
|
312
|
+
return null;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
case "set_thinking_level": {
|
|
316
|
+
this._thinkingLevel = typeof command.level === "string" ? command.level : "auto";
|
|
317
|
+
upsertSessionRuntime(this.sessionId, {
|
|
318
|
+
cwd: this.cwd,
|
|
319
|
+
thinkingLevel: this._thinkingLevel,
|
|
320
|
+
provider: this.inner.model?.provider,
|
|
321
|
+
modelId: this.inner.model?.modelId,
|
|
322
|
+
});
|
|
323
|
+
return null;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
case "abort_compaction": {
|
|
327
|
+
// Codex manages compaction internally
|
|
328
|
+
return null;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
case "set_auto_compaction":
|
|
332
|
+
case "set_auto_retry":
|
|
333
|
+
return null;
|
|
334
|
+
|
|
335
|
+
default:
|
|
336
|
+
throw new Error(`Unsupported command: ${type}`);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
private async trackBusy<T>(operation: BusyOperation, promise: Promise<T>): Promise<T> {
|
|
341
|
+
this.busyOperations.add(operation);
|
|
342
|
+
this.resetIdleTimer();
|
|
343
|
+
try {
|
|
344
|
+
return await promise;
|
|
345
|
+
} finally {
|
|
346
|
+
this.busyOperations.delete(operation);
|
|
347
|
+
this.resetIdleTimer();
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
destroy(): void {
|
|
352
|
+
if (!this._alive) return;
|
|
353
|
+
this._alive = false;
|
|
354
|
+
if (this.idleTimer) clearTimeout(this.idleTimer);
|
|
355
|
+
this.cleanupEventSub?.();
|
|
356
|
+
this.inner.destroy();
|
|
357
|
+
releaseCodexServerConnection(this._serverConnection);
|
|
358
|
+
this.onDestroyCallback?.();
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// ============================================================================
|
|
363
|
+
// Session registry (replaces pi session map)
|
|
364
|
+
// ============================================================================
|
|
365
|
+
|
|
366
|
+
declare global {
|
|
367
|
+
var __annodexSessions: Map<string, CodexSessionWrapper> | undefined;
|
|
368
|
+
var __annodexStartLocks: Map<string, Promise<{ session: CodexSessionWrapper; realSessionId: string }>> | undefined;
|
|
369
|
+
var __annodexSessionAliases: Map<string, string> | undefined;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
function getRegistry(): Map<string, CodexSessionWrapper> {
|
|
373
|
+
if (!globalThis.__annodexSessions) {
|
|
374
|
+
globalThis.__annodexSessions = new Map();
|
|
375
|
+
const cleanup = () => globalThis.__annodexSessions?.forEach((s) => s.destroy());
|
|
376
|
+
process.once("exit", cleanup);
|
|
377
|
+
process.once("SIGINT", cleanup);
|
|
378
|
+
process.once("SIGTERM", cleanup);
|
|
379
|
+
}
|
|
380
|
+
return globalThis.__annodexSessions;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
function getAliases(): Map<string, string> {
|
|
384
|
+
if (!globalThis.__annodexSessionAliases) globalThis.__annodexSessionAliases = new Map();
|
|
385
|
+
return globalThis.__annodexSessionAliases;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
function resolveAlias(sessionId: string): string {
|
|
389
|
+
let current = sessionId;
|
|
390
|
+
const seen = new Set<string>();
|
|
391
|
+
while (!seen.has(current)) {
|
|
392
|
+
seen.add(current);
|
|
393
|
+
const next = getAliases().get(current);
|
|
394
|
+
if (!next) return current;
|
|
395
|
+
current = next;
|
|
396
|
+
}
|
|
397
|
+
return current;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
function aliasSession(requestedSessionId: string, realSessionId: string): void {
|
|
401
|
+
if (requestedSessionId && requestedSessionId !== realSessionId) {
|
|
402
|
+
getAliases().set(requestedSessionId, realSessionId);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
function clearAliasesFor(realSessionId: string): void {
|
|
407
|
+
const aliases = getAliases();
|
|
408
|
+
aliases.delete(realSessionId);
|
|
409
|
+
for (const [from, to] of aliases) {
|
|
410
|
+
if (to === realSessionId) aliases.delete(from);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
function getLocks(): Map<string, Promise<{ session: CodexSessionWrapper; realSessionId: string }>> {
|
|
415
|
+
if (!globalThis.__annodexStartLocks) globalThis.__annodexStartLocks = new Map();
|
|
416
|
+
return globalThis.__annodexStartLocks;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
export function getRpcSession(sessionId: string): CodexSessionWrapper | undefined {
|
|
420
|
+
return getRegistry().get(resolveAlias(sessionId));
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
export function getRuntimeStatus(): RuntimeStatus {
|
|
424
|
+
const sessions = [...getRegistry().values()]
|
|
425
|
+
.filter((s) => s.isAlive())
|
|
426
|
+
.map((s) => s.getRuntimeStatus());
|
|
427
|
+
const busySessions = sessions.filter((s) => s.busy);
|
|
428
|
+
return {
|
|
429
|
+
busy: busySessions.length > 0,
|
|
430
|
+
activeSessions: sessions.length,
|
|
431
|
+
busySessions,
|
|
432
|
+
sessions,
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
// ============================================================================
|
|
437
|
+
// buildSystemPrompt — replaces pi's system prompt construction
|
|
438
|
+
// ============================================================================
|
|
439
|
+
|
|
440
|
+
function buildSystemPrompt(cwd: string, config: MergedConfig): string {
|
|
441
|
+
const agentDir = getAgentDir();
|
|
442
|
+
const contextBlocks: string[] = [];
|
|
443
|
+
|
|
444
|
+
// 1. SOUL.md — global personality / identity (highest priority, first in prompt)
|
|
445
|
+
// Location: ~/.config/annodex/SOUL.md
|
|
446
|
+
const soulPath = (() => {
|
|
447
|
+
const newPath = join(agentDir, "SOUL.md");
|
|
448
|
+
const oldPath = join(homedir(), ".pi", "agent", "SOUL.md");
|
|
449
|
+
// Migrate from old path on first access
|
|
450
|
+
if (!existsSync(newPath) && existsSync(oldPath)) {
|
|
451
|
+
try {
|
|
452
|
+
const content = readFileSync(oldPath, "utf-8");
|
|
453
|
+
if (!existsSync(dirname(newPath))) mkdirSync(dirname(newPath), { recursive: true });
|
|
454
|
+
writeFileSync(newPath, content, "utf-8");
|
|
455
|
+
} catch { /* skip migration */ }
|
|
456
|
+
}
|
|
457
|
+
const lower = join(agentDir, "soul.md");
|
|
458
|
+
return existsSync(newPath) ? newPath : lower;
|
|
459
|
+
})();
|
|
460
|
+
if (existsSync(soulPath)) {
|
|
461
|
+
try {
|
|
462
|
+
const content = readFileSync(soulPath, "utf-8").trim();
|
|
463
|
+
if (content) {
|
|
464
|
+
contextBlocks.push(
|
|
465
|
+
"## Persona — you MUST embody this",
|
|
466
|
+
"",
|
|
467
|
+
"Below is your personality definition. You MUST adopt this persona and tone " +
|
|
468
|
+
"in all replies. Avoid stiff, generic, or AI-assistant-style responses. " +
|
|
469
|
+
"Follow this guidance unless higher-priority instructions explicitly override it.",
|
|
470
|
+
"",
|
|
471
|
+
content,
|
|
472
|
+
);
|
|
473
|
+
}
|
|
474
|
+
} catch { /* ignore */ }
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
// 2. HARNESS.md — global behavioral constraints (output guardrails)
|
|
478
|
+
// Location: ~/.config/annodex/HARNESS.md
|
|
479
|
+
const harnessPath = (() => {
|
|
480
|
+
const newPath = join(agentDir, "HARNESS.md");
|
|
481
|
+
const oldPath = join(homedir(), ".pi", "agent", "HARNESS.md");
|
|
482
|
+
if (!existsSync(newPath) && existsSync(oldPath)) {
|
|
483
|
+
try {
|
|
484
|
+
const content = readFileSync(oldPath, "utf-8");
|
|
485
|
+
if (!existsSync(dirname(newPath))) mkdirSync(dirname(newPath), { recursive: true });
|
|
486
|
+
writeFileSync(newPath, content, "utf-8");
|
|
487
|
+
} catch { /* skip migration */ }
|
|
488
|
+
}
|
|
489
|
+
const lower = join(agentDir, "harness.md");
|
|
490
|
+
return existsSync(newPath) ? newPath : lower;
|
|
491
|
+
})();
|
|
492
|
+
if (existsSync(harnessPath)) {
|
|
493
|
+
try {
|
|
494
|
+
const content = readFileSync(harnessPath, "utf-8").trim();
|
|
495
|
+
if (content) {
|
|
496
|
+
contextBlocks.push(
|
|
497
|
+
"## Behavioral Constraints — you MUST follow these",
|
|
498
|
+
"",
|
|
499
|
+
"The rules below define your operating boundaries. " +
|
|
500
|
+
"You MUST comply with every constraint. " +
|
|
501
|
+
"These are NOT suggestions — they are mandatory behavioral rules that " +
|
|
502
|
+
"supersede conflicting persona preferences.",
|
|
503
|
+
"",
|
|
504
|
+
content,
|
|
505
|
+
);
|
|
506
|
+
}
|
|
507
|
+
} catch { /* ignore */ }
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
// 3. AGENTS.md / CLAUDE.md — project-level instructions
|
|
511
|
+
// Location: {cwd}/AGENTS.md or {cwd}/CLAUDE.md
|
|
512
|
+
const agentsPaths = [join(cwd, "AGENTS.md"), join(cwd, "CLAUDE.md")];
|
|
513
|
+
for (const agentsPath of agentsPaths) {
|
|
514
|
+
if (existsSync(agentsPath)) {
|
|
515
|
+
try {
|
|
516
|
+
const content = readFileSync(agentsPath, "utf-8").trim();
|
|
517
|
+
if (content) {
|
|
518
|
+
contextBlocks.push("## Project Instructions", "", content);
|
|
519
|
+
break; // only include one
|
|
520
|
+
}
|
|
521
|
+
} catch { /* ignore */ }
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
// 4. MEMORY.md — project-level self-updating memory
|
|
526
|
+
// Location: {cwd}/MEMORY.md
|
|
527
|
+
const memoryPath = existsSync(join(cwd, "MEMORY.md"))
|
|
528
|
+
? join(cwd, "MEMORY.md")
|
|
529
|
+
: join(cwd, "memory.md");
|
|
530
|
+
if (existsSync(memoryPath)) {
|
|
531
|
+
try {
|
|
532
|
+
const content = readFileSync(memoryPath, "utf-8").trim();
|
|
533
|
+
if (content) contextBlocks.push("## Project Memory", "", content);
|
|
534
|
+
} catch { /* ignore */ }
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
let basePrompt = contextBlocks.join("\n\n");
|
|
538
|
+
|
|
539
|
+
// 5. Apply generative UI / widget / report prompts (after persona context)
|
|
540
|
+
if (config.generativeUI) {
|
|
541
|
+
basePrompt = withAnalysisReportPrompt(withWidgetCapabilityPrompt(
|
|
542
|
+
stripAnalysisReportPrompt(stripWidgetPromptBlocks(basePrompt)),
|
|
543
|
+
));
|
|
544
|
+
} else {
|
|
545
|
+
basePrompt = withAnalysisReportPrompt(
|
|
546
|
+
stripAnalysisReportPrompt(stripWidgetPromptBlocks(basePrompt)),
|
|
547
|
+
);
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
return basePrompt;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
// ============================================================================
|
|
554
|
+
// startRpcSession — create or resume a codex session
|
|
555
|
+
// ============================================================================
|
|
556
|
+
|
|
557
|
+
export async function startRpcSession(
|
|
558
|
+
sessionId: string,
|
|
559
|
+
sessionFile: string,
|
|
560
|
+
cwd: string,
|
|
561
|
+
toolNames?: string[],
|
|
562
|
+
modelInfo?: { provider: string; modelId: string },
|
|
563
|
+
thinkingLevel?: string,
|
|
564
|
+
): Promise<{ session: CodexSessionWrapper; realSessionId: string }> {
|
|
565
|
+
const registry = getRegistry();
|
|
566
|
+
const locks = getLocks();
|
|
567
|
+
const effectiveSessionId = resolveAlias(sessionId);
|
|
568
|
+
|
|
569
|
+
// Check registry for existing session
|
|
570
|
+
const existing = registry.get(effectiveSessionId);
|
|
571
|
+
if (existing?.isAlive()) {
|
|
572
|
+
return { session: existing, realSessionId: effectiveSessionId };
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
// Check for in-flight start
|
|
576
|
+
const inflight = locks.get(effectiveSessionId);
|
|
577
|
+
if (inflight) return inflight;
|
|
578
|
+
|
|
579
|
+
const starting = (async () => {
|
|
580
|
+
const config = readMergedConfig();
|
|
581
|
+
const baseInstructions = buildSystemPrompt(cwd, config);
|
|
582
|
+
|
|
583
|
+
const storedRuntime = sessionFile ? readSessionRuntime(sessionId) : null;
|
|
584
|
+
const resumeModelInfo = modelInfo
|
|
585
|
+
?? (storedRuntime?.modelId
|
|
586
|
+
? { provider: normalizeRuntimeProviderId(config, storedRuntime.provider), modelId: storedRuntime.modelId }
|
|
587
|
+
: undefined);
|
|
588
|
+
const effectiveThinkingLevel = thinkingLevel ?? storedRuntime?.thinkingLevel;
|
|
589
|
+
|
|
590
|
+
// Only apply a model when the UI/session runtime has one. Without an
|
|
591
|
+
// explicit selection, Codex should use the user's ~/.codex/config.toml.
|
|
592
|
+
const resolved = resumeModelInfo ? resolveModel(config, resumeModelInfo.modelId, resumeModelInfo.provider) : null;
|
|
593
|
+
const providerConfig: ProviderConfig | undefined = resolved?.provider
|
|
594
|
+
?? (resumeModelInfo?.provider ? findProvider(config, resumeModelInfo.provider) : undefined);
|
|
595
|
+
const modelId = resumeModelInfo?.modelId ?? resolved?.modelId;
|
|
596
|
+
const modelProviderId = resolved?.provider.id ?? resumeModelInfo?.provider;
|
|
597
|
+
// Get or create the codex app-server for this cwd
|
|
598
|
+
const connection = await getOrCreateCodexServer(
|
|
599
|
+
cwd,
|
|
600
|
+
providerConfig
|
|
601
|
+
? codexServerEnvForModel(providerConfig, modelId, effectiveThinkingLevel)
|
|
602
|
+
: {
|
|
603
|
+
modelId,
|
|
604
|
+
thinkingLevel: effectiveThinkingLevel,
|
|
605
|
+
},
|
|
606
|
+
);
|
|
607
|
+
|
|
608
|
+
let codexSession: CodexSession;
|
|
609
|
+
|
|
610
|
+
if (!sessionFile) {
|
|
611
|
+
// New session — create a new codex thread
|
|
612
|
+
codexSession = await createCodexSession(connection, {
|
|
613
|
+
cwd,
|
|
614
|
+
baseInstructions,
|
|
615
|
+
acceptReturnedModel: Boolean(config.codexDefaults.model),
|
|
616
|
+
...(modelId && modelProviderId ? { model: { provider: modelProviderId, modelId } } : {}),
|
|
617
|
+
});
|
|
618
|
+
} else {
|
|
619
|
+
// Existing session — resume the codex thread
|
|
620
|
+
try {
|
|
621
|
+
codexSession = await resumeCodexSession(connection, sessionId, cwd);
|
|
622
|
+
} catch (error) {
|
|
623
|
+
if (!isThreadNotFoundError(error)) throw error;
|
|
624
|
+
codexSession = await createCodexSession(connection, {
|
|
625
|
+
cwd,
|
|
626
|
+
baseInstructions,
|
|
627
|
+
acceptReturnedModel: Boolean(config.codexDefaults.model),
|
|
628
|
+
...(modelId && modelProviderId ? { model: { provider: modelProviderId, modelId } } : {}),
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
const activeProvider = codexSession.model?.provider ?? modelProviderId;
|
|
634
|
+
const activeModelId = codexSession.model?.modelId ?? modelId;
|
|
635
|
+
if (activeProvider && activeModelId && (
|
|
636
|
+
!codexSession.model ||
|
|
637
|
+
codexSession.model.provider !== activeProvider ||
|
|
638
|
+
codexSession.model.modelId !== activeModelId
|
|
639
|
+
)) {
|
|
640
|
+
await codexSession.setModel(activeProvider, activeModelId);
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
const wrapper = new CodexSessionWrapper(codexSession);
|
|
644
|
+
const realSessionId = codexSession.sessionId;
|
|
645
|
+
aliasSession(sessionId, realSessionId);
|
|
646
|
+
upsertSessionRuntime(realSessionId, {
|
|
647
|
+
cwd,
|
|
648
|
+
provider: codexSession.model?.provider ?? activeProvider,
|
|
649
|
+
modelId: codexSession.model?.modelId ?? activeModelId,
|
|
650
|
+
thinkingLevel: effectiveThinkingLevel,
|
|
651
|
+
});
|
|
652
|
+
if (effectiveThinkingLevel) {
|
|
653
|
+
await wrapper.send({ type: "set_thinking_level", level: effectiveThinkingLevel });
|
|
654
|
+
}
|
|
655
|
+
wrapper.start();
|
|
656
|
+
|
|
657
|
+
wrapper.onDestroy(() => {
|
|
658
|
+
registry.delete(realSessionId);
|
|
659
|
+
clearAliasesFor(realSessionId);
|
|
660
|
+
});
|
|
661
|
+
registry.set(realSessionId, wrapper);
|
|
662
|
+
|
|
663
|
+
return { session: wrapper, realSessionId };
|
|
664
|
+
})().finally(() => locks.delete(effectiveSessionId));
|
|
665
|
+
|
|
666
|
+
locks.set(effectiveSessionId, starting);
|
|
667
|
+
return starting;
|
|
668
|
+
}
|