@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,590 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Codex Session Wrapper
|
|
3
|
+
*
|
|
4
|
+
* Wraps a codex app-server thread as an annodex session.
|
|
5
|
+
* Maps codex thread events to the unified AgentEvent protocol used by the SSE stream.
|
|
6
|
+
*
|
|
7
|
+
* Event mapping:
|
|
8
|
+
* codex app-server notifications → AgentEvent
|
|
9
|
+
* - item/agentMessage/delta → message_update
|
|
10
|
+
* - item/completed → message_end / tool_execution_end
|
|
11
|
+
* - turn/completed → agent_end
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import type { CodexServerConnection, CodexThread, CodexThreadItem, CodexTurn, CodexUserInput } from "./codex-server";
|
|
15
|
+
import { subagentRunsFromCollabItem } from "./subagent-progress";
|
|
16
|
+
|
|
17
|
+
// ============================================================================
|
|
18
|
+
// AgentEvent — the unified event protocol consumed by SSE and ChatWindow
|
|
19
|
+
// ============================================================================
|
|
20
|
+
|
|
21
|
+
export interface AgentEvent {
|
|
22
|
+
type: string;
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// ============================================================================
|
|
27
|
+
// Codex thread raw event types (from app-server notifications)
|
|
28
|
+
// ============================================================================
|
|
29
|
+
|
|
30
|
+
interface CodexNotificationBase {
|
|
31
|
+
threadId: string;
|
|
32
|
+
turnId: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface CodexItemNotification extends CodexNotificationBase {
|
|
36
|
+
item: CodexThreadItem;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface CodexDeltaNotification extends CodexNotificationBase {
|
|
40
|
+
itemId: string;
|
|
41
|
+
delta: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
interface CodexTurnCompletedNotification {
|
|
45
|
+
threadId: string;
|
|
46
|
+
turn: CodexTurn;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
interface CodexThreadStatusNotification {
|
|
50
|
+
threadId: string;
|
|
51
|
+
status?: { type?: string; activeFlags?: string[] };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
type CodexCompactedNotification = CodexNotificationBase;
|
|
55
|
+
|
|
56
|
+
function userInputsFromMessage(message: string, images?: Array<{ data: string; mimeType: string }>): CodexUserInput[] {
|
|
57
|
+
const input: CodexUserInput[] = [];
|
|
58
|
+
if (message.trim()) {
|
|
59
|
+
input.push({ type: "text", text: message, text_elements: [] });
|
|
60
|
+
}
|
|
61
|
+
for (const image of images ?? []) {
|
|
62
|
+
const mime = image.mimeType || "image/png";
|
|
63
|
+
input.push({ type: "image", url: `data:${mime};base64,${image.data}` });
|
|
64
|
+
}
|
|
65
|
+
return input.length > 0 ? input : [{ type: "text", text: "", text_elements: [] }];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function itemText(item: CodexThreadItem): string {
|
|
69
|
+
if (item.type === "agentMessage" && typeof item.text === "string") return item.text;
|
|
70
|
+
if (item.type === "reasoning") return [...(item.summary ?? []), ...(item.content ?? [])].join("\n");
|
|
71
|
+
if (item.type === "plan" && typeof item.text === "string") return item.text;
|
|
72
|
+
return "";
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function itemToolName(item: CodexThreadItem): string {
|
|
76
|
+
if (item.type === "commandExecution") return "bash";
|
|
77
|
+
if (item.type === "fileChange") return "edit";
|
|
78
|
+
if (item.type === "mcpToolCall") return item.tool || item.server || "mcp";
|
|
79
|
+
if (item.type === "dynamicToolCall") return item.tool || "tool";
|
|
80
|
+
if (item.type === "collabAgentToolCall") return "agents";
|
|
81
|
+
return item.type;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function itemToolResult(item: CodexThreadItem): string {
|
|
85
|
+
if (item.type === "commandExecution") {
|
|
86
|
+
const out = item.aggregatedOutput ?? "";
|
|
87
|
+
const exit = item.exitCode !== null && item.exitCode !== undefined ? `Exit code: ${item.exitCode}` : "";
|
|
88
|
+
return out ? (exit ? `${out}\n${exit}` : out) : exit;
|
|
89
|
+
}
|
|
90
|
+
if (item.type === "fileChange") return JSON.stringify(item.changes ?? []);
|
|
91
|
+
if (item.type === "mcpToolCall") {
|
|
92
|
+
if (item.error) return typeof item.error === "string" ? item.error : JSON.stringify(item.error);
|
|
93
|
+
if (item.result) return typeof item.result === "string" ? item.result : JSON.stringify(item.result);
|
|
94
|
+
return "";
|
|
95
|
+
}
|
|
96
|
+
if (item.type === "dynamicToolCall") return JSON.stringify(item.contentItems ?? []);
|
|
97
|
+
if (item.type === "collabAgentToolCall") return JSON.stringify(item.agentsStates ?? []);
|
|
98
|
+
return "";
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function itemIsFailed(item: CodexThreadItem): boolean {
|
|
102
|
+
if ("status" in item && typeof item.status === "string") {
|
|
103
|
+
return item.status === "failed" || item.status === "declined";
|
|
104
|
+
}
|
|
105
|
+
if (item.type === "dynamicToolCall" && item.success === false) return true;
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function itemIsProgressItem(item: CodexThreadItem): boolean {
|
|
110
|
+
return item.type === "commandExecution"
|
|
111
|
+
|| item.type === "fileChange"
|
|
112
|
+
|| item.type === "mcpToolCall"
|
|
113
|
+
|| item.type === "dynamicToolCall"
|
|
114
|
+
|| item.type === "collabAgentToolCall";
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// ============================================================================
|
|
118
|
+
// CodexSession — wraps a single thread
|
|
119
|
+
// ============================================================================
|
|
120
|
+
|
|
121
|
+
export type EventListener = (event: AgentEvent) => void;
|
|
122
|
+
|
|
123
|
+
export class CodexSession {
|
|
124
|
+
private listeners: EventListener[] = [];
|
|
125
|
+
private cleanupFns: Array<() => void> = [];
|
|
126
|
+
private _alive = true;
|
|
127
|
+
private _isStreaming = false;
|
|
128
|
+
private _isCompacting = false;
|
|
129
|
+
private _accumulatedText = "";
|
|
130
|
+
private _activeTurnId: string | null = null;
|
|
131
|
+
private _activeAgentItemId: string | null = null;
|
|
132
|
+
private _currentModel: { provider: string; modelId: string } | null = null;
|
|
133
|
+
|
|
134
|
+
constructor(
|
|
135
|
+
public readonly threadId: string,
|
|
136
|
+
public readonly cwd: string,
|
|
137
|
+
public readonly connection: CodexServerConnection,
|
|
138
|
+
public readonly baseInstructions?: string,
|
|
139
|
+
) {
|
|
140
|
+
this.setupNotifications();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// ---- Public state ----
|
|
144
|
+
|
|
145
|
+
get sessionId(): string {
|
|
146
|
+
return this.threadId;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
get sessionFile(): string {
|
|
150
|
+
// Codex manages threads internally; we don't have .jsonl files
|
|
151
|
+
return "";
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
get isAlive(): boolean {
|
|
155
|
+
return this._alive;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
get isStreaming(): boolean {
|
|
159
|
+
return this._isStreaming;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
get isCompacting(): boolean {
|
|
163
|
+
return this._isCompacting;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
get model(): { provider: string; modelId: string } | null {
|
|
167
|
+
return this._currentModel;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// ---- Event subscription ----
|
|
171
|
+
|
|
172
|
+
onEvent(listener: EventListener): () => void {
|
|
173
|
+
this.listeners.push(listener);
|
|
174
|
+
return () => {
|
|
175
|
+
const i = this.listeners.indexOf(listener);
|
|
176
|
+
if (i !== -1) this.listeners.splice(i, 1);
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
private emit(event: AgentEvent): void {
|
|
181
|
+
for (const l of this.listeners) {
|
|
182
|
+
try { l(event); } catch { /* ignore */ }
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
private assistantMeta(): { model: string; provider: string } {
|
|
187
|
+
return {
|
|
188
|
+
model: this._currentModel?.modelId ?? "",
|
|
189
|
+
provider: this._currentModel?.provider ?? "",
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// ---- Notifications from codex app-server ----
|
|
194
|
+
|
|
195
|
+
private setupNotifications(): void {
|
|
196
|
+
const unsub1 = this.connection.onNotification(
|
|
197
|
+
"item/agentMessage/delta",
|
|
198
|
+
(params: unknown) => this.handleAgentMessageDelta(params as CodexDeltaNotification),
|
|
199
|
+
);
|
|
200
|
+
this.cleanupFns.push(unsub1);
|
|
201
|
+
|
|
202
|
+
const unsub2 = this.connection.onNotification(
|
|
203
|
+
"item/completed",
|
|
204
|
+
(params: unknown) => this.handleItemCompleted(params as CodexItemNotification),
|
|
205
|
+
);
|
|
206
|
+
this.cleanupFns.push(unsub2);
|
|
207
|
+
|
|
208
|
+
const unsub3 = this.connection.onNotification(
|
|
209
|
+
"turn/completed",
|
|
210
|
+
(params: unknown) => this.handleTurnCompleted(params as CodexTurnCompletedNotification),
|
|
211
|
+
);
|
|
212
|
+
this.cleanupFns.push(unsub3);
|
|
213
|
+
|
|
214
|
+
const unsub4 = this.connection.onNotification(
|
|
215
|
+
"thread/status/changed",
|
|
216
|
+
(params: unknown) => this.handleThreadStatusChanged(params as CodexThreadStatusNotification),
|
|
217
|
+
);
|
|
218
|
+
this.cleanupFns.push(unsub4);
|
|
219
|
+
|
|
220
|
+
const unsub5 = this.connection.onNotification(
|
|
221
|
+
"thread/compacted",
|
|
222
|
+
(params: unknown) => this.handleCompacted(params as CodexCompactedNotification),
|
|
223
|
+
);
|
|
224
|
+
this.cleanupFns.push(unsub5);
|
|
225
|
+
|
|
226
|
+
const unsub6 = this.connection.onNotification(
|
|
227
|
+
"item/started",
|
|
228
|
+
(params: unknown) => this.handleItemStarted(params as CodexItemNotification),
|
|
229
|
+
);
|
|
230
|
+
this.cleanupFns.push(unsub6);
|
|
231
|
+
|
|
232
|
+
const unsub7 = this.connection.onNotification(
|
|
233
|
+
"error",
|
|
234
|
+
(params: unknown) => this.handleError(params as { threadId?: string; error?: { message?: string; additionalDetails?: string | null } }),
|
|
235
|
+
);
|
|
236
|
+
this.cleanupFns.push(unsub7);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
private eventBelongsToThread(event: { threadId?: string }): boolean {
|
|
240
|
+
return event.threadId === this.threadId;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
private handleAgentMessageDelta(event: CodexDeltaNotification): void {
|
|
244
|
+
if (!this.eventBelongsToThread(event)) return;
|
|
245
|
+
if (!this._isStreaming) return;
|
|
246
|
+
this._activeTurnId = event.turnId;
|
|
247
|
+
this._activeAgentItemId = event.itemId;
|
|
248
|
+
this._accumulatedText += event.delta ?? "";
|
|
249
|
+
this.emit({
|
|
250
|
+
type: "message_update",
|
|
251
|
+
message: {
|
|
252
|
+
role: "assistant",
|
|
253
|
+
content: [{ type: "text", text: this._accumulatedText }],
|
|
254
|
+
...this.assistantMeta(),
|
|
255
|
+
},
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
private handleItemStarted(event: CodexItemNotification): void {
|
|
260
|
+
if (!this.eventBelongsToThread(event)) return;
|
|
261
|
+
const item = event.item;
|
|
262
|
+
if (!itemIsProgressItem(item)) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
this._activeTurnId = event.turnId;
|
|
266
|
+
if (item.type === "collabAgentToolCall") {
|
|
267
|
+
this.emit({
|
|
268
|
+
type: "subagent_progress",
|
|
269
|
+
runs: subagentRunsFromCollabItem(item, Date.now()),
|
|
270
|
+
});
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
this.emit({
|
|
274
|
+
type: "tool_execution_start",
|
|
275
|
+
toolCallId: item.id,
|
|
276
|
+
toolName: itemToolName(item),
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
private handleItemCompleted(event: CodexItemNotification): void {
|
|
281
|
+
if (!this.eventBelongsToThread(event)) return;
|
|
282
|
+
const item = event.item;
|
|
283
|
+
this._activeTurnId = event.turnId;
|
|
284
|
+
|
|
285
|
+
if (item.type === "agentMessage") {
|
|
286
|
+
const text = itemText(item) || this._accumulatedText;
|
|
287
|
+
this.emit({
|
|
288
|
+
type: "message_end",
|
|
289
|
+
message: {
|
|
290
|
+
role: "assistant",
|
|
291
|
+
content: [{ type: "text", text }],
|
|
292
|
+
...this.assistantMeta(),
|
|
293
|
+
},
|
|
294
|
+
});
|
|
295
|
+
this._accumulatedText = "";
|
|
296
|
+
this._activeAgentItemId = null;
|
|
297
|
+
} else if (item.type === "reasoning") {
|
|
298
|
+
const text = itemText(item);
|
|
299
|
+
if (text) {
|
|
300
|
+
this.emit({
|
|
301
|
+
type: "message_update",
|
|
302
|
+
message: {
|
|
303
|
+
role: "assistant",
|
|
304
|
+
content: [{ type: "thinking", thinking: text }],
|
|
305
|
+
...this.assistantMeta(),
|
|
306
|
+
},
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
} else if (item.type === "collabAgentToolCall") {
|
|
310
|
+
this.emit({
|
|
311
|
+
type: "subagent_progress",
|
|
312
|
+
runs: subagentRunsFromCollabItem(item, Date.now()),
|
|
313
|
+
});
|
|
314
|
+
} else if (item.type === "commandExecution" || item.type === "fileChange" || item.type === "mcpToolCall" || item.type === "dynamicToolCall") {
|
|
315
|
+
this.emit({
|
|
316
|
+
type: "tool_execution_end",
|
|
317
|
+
toolCallId: item.id,
|
|
318
|
+
toolName: itemToolName(item),
|
|
319
|
+
result: itemToolResult(item),
|
|
320
|
+
isError: itemIsFailed(item),
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
private handleTurnCompleted(event: CodexTurnCompletedNotification): void {
|
|
326
|
+
if (!this.eventBelongsToThread(event)) return;
|
|
327
|
+
this._isStreaming = false;
|
|
328
|
+
this._activeTurnId = null;
|
|
329
|
+
if (this._accumulatedText) {
|
|
330
|
+
this.emit({
|
|
331
|
+
type: "message_end",
|
|
332
|
+
message: {
|
|
333
|
+
role: "assistant",
|
|
334
|
+
content: [{ type: "text", text: this._accumulatedText }],
|
|
335
|
+
...this.assistantMeta(),
|
|
336
|
+
},
|
|
337
|
+
});
|
|
338
|
+
this._accumulatedText = "";
|
|
339
|
+
}
|
|
340
|
+
this.emit({
|
|
341
|
+
type: "agent_end",
|
|
342
|
+
...(event.turn?.status === "failed" ? { error: event.turn.error?.message ?? "Turn failed" } : {}),
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
private handleThreadStatusChanged(event: CodexThreadStatusNotification): void {
|
|
347
|
+
if (!this.eventBelongsToThread(event)) return;
|
|
348
|
+
if (event.status?.type === "idle" && this._isStreaming) {
|
|
349
|
+
this._isStreaming = false;
|
|
350
|
+
this._activeTurnId = null;
|
|
351
|
+
this.emit({ type: "agent_end" });
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
private handleCompacted(event: CodexCompactedNotification): void {
|
|
356
|
+
if (!this.eventBelongsToThread(event)) return;
|
|
357
|
+
this._isCompacting = false;
|
|
358
|
+
this.emit({ type: "compaction_end" });
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
private handleError(event: { threadId?: string; error?: { message?: string; additionalDetails?: string | null } }): void {
|
|
362
|
+
if (!this.eventBelongsToThread(event)) return;
|
|
363
|
+
const message = event.error?.message || event.error?.additionalDetails || "Codex turn failed";
|
|
364
|
+
this._isStreaming = false;
|
|
365
|
+
this._activeTurnId = null;
|
|
366
|
+
this.emit({ type: "agent_end", error: message });
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
// ---- Actions ----
|
|
370
|
+
|
|
371
|
+
async prompt(message: string, images?: Array<{ data: string; mimeType: string }>): Promise<void> {
|
|
372
|
+
this._isStreaming = true;
|
|
373
|
+
this._accumulatedText = "";
|
|
374
|
+
|
|
375
|
+
// Emit agent_start so the UI knows we're running
|
|
376
|
+
this.emit({ type: "agent_start" });
|
|
377
|
+
|
|
378
|
+
// Start message
|
|
379
|
+
this.emit({
|
|
380
|
+
type: "message_start",
|
|
381
|
+
message: {
|
|
382
|
+
role: "assistant",
|
|
383
|
+
content: [],
|
|
384
|
+
...this.assistantMeta(),
|
|
385
|
+
},
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
try {
|
|
389
|
+
const result = await this.connection.request("turn/start", {
|
|
390
|
+
threadId: this.threadId,
|
|
391
|
+
input: userInputsFromMessage(message, images),
|
|
392
|
+
...(this.cwd ? { cwd: this.cwd } : {}),
|
|
393
|
+
...(this._currentModel?.modelId ? { model: this._currentModel.modelId } : {}),
|
|
394
|
+
...(this._currentModel?.provider ? { modelProvider: this._currentModel.provider } : {}),
|
|
395
|
+
approvalPolicy: "never",
|
|
396
|
+
sandboxPolicy: {
|
|
397
|
+
type: "workspaceWrite",
|
|
398
|
+
writableRoots: [this.cwd],
|
|
399
|
+
readOnlyAccess: { type: "fullAccess" },
|
|
400
|
+
networkAccess: true,
|
|
401
|
+
excludeTmpdirEnvVar: false,
|
|
402
|
+
excludeSlashTmp: false,
|
|
403
|
+
},
|
|
404
|
+
}) as { turn?: { id?: string } };
|
|
405
|
+
this._activeTurnId = result.turn?.id ?? null;
|
|
406
|
+
} catch (error) {
|
|
407
|
+
this._isStreaming = false;
|
|
408
|
+
this.emit({
|
|
409
|
+
type: "agent_end",
|
|
410
|
+
error: error instanceof Error ? error.message : String(error),
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
async abort(): Promise<void> {
|
|
416
|
+
if (this._activeTurnId) {
|
|
417
|
+
try {
|
|
418
|
+
await this.connection.request("turn/interrupt", {
|
|
419
|
+
threadId: this.threadId,
|
|
420
|
+
turnId: this._activeTurnId,
|
|
421
|
+
});
|
|
422
|
+
} catch {
|
|
423
|
+
// local state still needs to settle even if the server rejected interrupt
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
this._isStreaming = false;
|
|
427
|
+
this._activeTurnId = null;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
async setModel(provider: string, modelId: string): Promise<void> {
|
|
431
|
+
this._currentModel = { provider, modelId };
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* Fork the thread — create a new thread from the current one at an entry point.
|
|
436
|
+
*/
|
|
437
|
+
async fork(): Promise<{ newThreadId: string } | { cancelled: true }> {
|
|
438
|
+
try {
|
|
439
|
+
const result = await this.connection.request("thread/fork", {
|
|
440
|
+
threadId: this.threadId,
|
|
441
|
+
persistExtendedHistory: true,
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
const newThreadId = (result as { thread?: { id?: string } }).thread?.id;
|
|
445
|
+
if (!newThreadId) return { cancelled: true };
|
|
446
|
+
|
|
447
|
+
return { newThreadId };
|
|
448
|
+
} catch {
|
|
449
|
+
return { cancelled: true };
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* Navigate (rollback) to a specific point in the thread.
|
|
455
|
+
*/
|
|
456
|
+
async navigateTree(targetId: string): Promise<{ cancelled: boolean }> {
|
|
457
|
+
try {
|
|
458
|
+
const thread = await this.connection.request("thread/read", {
|
|
459
|
+
threadId: this.threadId,
|
|
460
|
+
includeTurns: true,
|
|
461
|
+
}) as { thread?: CodexThread };
|
|
462
|
+
const turns = thread.thread?.turns ?? [];
|
|
463
|
+
const targetTurnIndex = turns.findIndex((turn) => turn.items.some((item) => item.id === targetId));
|
|
464
|
+
if (targetTurnIndex < 0 || targetTurnIndex >= turns.length - 1) return { cancelled: false };
|
|
465
|
+
const numTurns = turns.length - targetTurnIndex - 1;
|
|
466
|
+
await this.connection.request("thread/rollback", {
|
|
467
|
+
threadId: this.threadId,
|
|
468
|
+
numTurns,
|
|
469
|
+
});
|
|
470
|
+
return { cancelled: false };
|
|
471
|
+
} catch {
|
|
472
|
+
return { cancelled: true };
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Compact the thread context
|
|
478
|
+
*/
|
|
479
|
+
async compact(): Promise<void> {
|
|
480
|
+
this._isCompacting = true;
|
|
481
|
+
this.emit({ type: "compaction_start" });
|
|
482
|
+
|
|
483
|
+
try {
|
|
484
|
+
await this.connection.request("thread/compact/start", {
|
|
485
|
+
threadId: this.threadId,
|
|
486
|
+
});
|
|
487
|
+
} catch (error) {
|
|
488
|
+
this._isCompacting = false;
|
|
489
|
+
this.emit({
|
|
490
|
+
type: "compaction_end",
|
|
491
|
+
errorMessage: error instanceof Error ? error.message : String(error),
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
async rename(name: string): Promise<void> {
|
|
497
|
+
try {
|
|
498
|
+
await this.connection.request("thread/name/set", {
|
|
499
|
+
threadId: this.threadId,
|
|
500
|
+
name,
|
|
501
|
+
});
|
|
502
|
+
} catch {
|
|
503
|
+
// ignore
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
// ---- Lifecycle ----
|
|
508
|
+
|
|
509
|
+
destroy(): void {
|
|
510
|
+
if (!this._alive) return;
|
|
511
|
+
this._alive = false;
|
|
512
|
+
this._isStreaming = false;
|
|
513
|
+
|
|
514
|
+
for (const cleanup of this.cleanupFns) {
|
|
515
|
+
try { cleanup(); } catch { /* ignore */ }
|
|
516
|
+
}
|
|
517
|
+
this.cleanupFns = [];
|
|
518
|
+
this.listeners = [];
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
// ============================================================================
|
|
523
|
+
// Session creation helpers
|
|
524
|
+
// ============================================================================
|
|
525
|
+
|
|
526
|
+
export interface CreateSessionOptions {
|
|
527
|
+
cwd: string;
|
|
528
|
+
message?: string;
|
|
529
|
+
baseInstructions?: string;
|
|
530
|
+
toolNames?: string[];
|
|
531
|
+
model?: { provider: string; modelId: string };
|
|
532
|
+
acceptReturnedModel?: boolean;
|
|
533
|
+
images?: Array<{ type: "image"; data: string; mimeType: string }>;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
export async function createCodexSession(
|
|
537
|
+
connection: CodexServerConnection,
|
|
538
|
+
opts: CreateSessionOptions,
|
|
539
|
+
): Promise<CodexSession> {
|
|
540
|
+
const result = await connection.request("thread/start", {
|
|
541
|
+
cwd: opts.cwd,
|
|
542
|
+
...(opts.baseInstructions ? { baseInstructions: opts.baseInstructions } : {}),
|
|
543
|
+
...(opts.model ? { model: opts.model.modelId, modelProvider: opts.model.provider } : {}),
|
|
544
|
+
approvalPolicy: "never",
|
|
545
|
+
sandbox: "workspace-write",
|
|
546
|
+
experimentalRawEvents: false,
|
|
547
|
+
persistExtendedHistory: true,
|
|
548
|
+
}) as { thread?: { id?: string }; model?: string; modelProvider?: string };
|
|
549
|
+
|
|
550
|
+
const threadId = result.thread?.id;
|
|
551
|
+
if (!threadId) {
|
|
552
|
+
throw new Error("Failed to create codex thread: no thread.id returned");
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
const session = new CodexSession(threadId, opts.cwd, connection, opts.baseInstructions);
|
|
556
|
+
|
|
557
|
+
if (opts.model) {
|
|
558
|
+
session.setModel(opts.model.provider, opts.model.modelId);
|
|
559
|
+
} else if (opts.acceptReturnedModel && result.model) {
|
|
560
|
+
session.setModel(result.modelProvider ?? "codex", result.model);
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
return session;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* Resume an existing codex thread.
|
|
568
|
+
*/
|
|
569
|
+
export async function resumeCodexSession(
|
|
570
|
+
connection: CodexServerConnection,
|
|
571
|
+
threadId: string,
|
|
572
|
+
cwd: string,
|
|
573
|
+
): Promise<CodexSession> {
|
|
574
|
+
// Read thread info to get model etc.
|
|
575
|
+
let model: { provider: string; modelId: string } | null = null;
|
|
576
|
+
const details = await connection.request("thread/read", { threadId, includeTurns: false }) as {
|
|
577
|
+
thread?: { modelProvider?: string };
|
|
578
|
+
model?: string;
|
|
579
|
+
modelProvider?: string;
|
|
580
|
+
};
|
|
581
|
+
if (details?.model) {
|
|
582
|
+
model = { provider: details.modelProvider ?? details.thread?.modelProvider ?? "codex", modelId: details.model };
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
const session = new CodexSession(threadId, cwd, connection);
|
|
586
|
+
if (model) {
|
|
587
|
+
session.setModel(model.provider, model.modelId);
|
|
588
|
+
}
|
|
589
|
+
return session;
|
|
590
|
+
}
|