@neurocode-ai/app 1.18.8
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/AGENTS.md +35 -0
- package/README.md +50 -0
- package/V1_API_MIGRATION.md +220 -0
- package/bunfig.toml +3 -0
- package/create-effect-simplification-spec.md +515 -0
- package/e2e/performance/AGENTS.md +13 -0
- package/e2e/performance/README.md +79 -0
- package/e2e/performance/benchmark.ts +144 -0
- package/e2e/performance/chrome-trace.ts +95 -0
- package/e2e/performance/playwright.config.ts +20 -0
- package/e2e/performance/playwright.uncapped.config.ts +13 -0
- package/e2e/performance/timeline/first-navigation-benchmark.spec.ts +87 -0
- package/e2e/performance/timeline/first-navigation-metrics.ts +32 -0
- package/e2e/performance/timeline/first-navigation-probe.ts +86 -0
- package/e2e/performance/timeline/home-tab-navigation-benchmark.spec.ts +114 -0
- package/e2e/performance/timeline/navigation-milestones.ts +128 -0
- package/e2e/performance/timeline/review-pane-scaling-benchmark.spec.ts +312 -0
- package/e2e/performance/timeline/session-parent-hydration-benchmark.spec.ts +172 -0
- package/e2e/performance/timeline/session-tab-flash.spec.ts +67 -0
- package/e2e/performance/timeline/session-tab-repaint-probe.ts +251 -0
- package/e2e/performance/timeline/session-tab-switch-benchmark.spec.ts +144 -0
- package/e2e/performance/timeline/session-tab-switch-metrics.ts +59 -0
- package/e2e/performance/timeline/session-tab-switch-probe.ts +226 -0
- package/e2e/performance/timeline/session-timeline-benchmark.fixture.ts +504 -0
- package/e2e/performance/timeline/session-timeline-benchmark.spec.ts +306 -0
- package/e2e/performance/timeline/session-timeline-profile.ts +40 -0
- package/e2e/performance/timeline/session-timeline-stream-probe.ts +547 -0
- package/e2e/performance/timeline/session-timeline-stress.fixture.ts +369 -0
- package/e2e/performance/timeline/timeline-test-helpers.ts +134 -0
- package/e2e/performance/timeline-stability/README.md +61 -0
- package/e2e/performance/timeline-stability/adverse.spec.ts +250 -0
- package/e2e/performance/timeline-stability/context-matrix.spec.ts +192 -0
- package/e2e/performance/timeline-stability/environment-matrix.spec.ts +113 -0
- package/e2e/performance/timeline-stability/file-matrix.spec.ts +121 -0
- package/e2e/performance/timeline-stability/file-mutation.spec.ts +113 -0
- package/e2e/performance/timeline-stability/fixture.test.ts +68 -0
- package/e2e/performance/timeline-stability/fixture.ts +566 -0
- package/e2e/performance/timeline-stability/interaction.spec.ts +242 -0
- package/e2e/performance/timeline-stability/lifecycle.spec.ts +157 -0
- package/e2e/performance/timeline-stability/oracle-browser.spec.ts +75 -0
- package/e2e/performance/timeline-stability/playwright.config.ts +17 -0
- package/e2e/performance/timeline-stability/scroll-interaction.spec.ts +353 -0
- package/e2e/performance/timeline-stability/shell-matrix.spec.ts +255 -0
- package/e2e/performance/timeline-stability/tool-mutation.spec.ts +106 -0
- package/e2e/performance/timeline-stability/tools.spec.ts +198 -0
- package/e2e/performance/timeline-stability/transition-matrix.spec.ts +272 -0
- package/e2e/performance/unit/chrome-trace-write.test.ts +15 -0
- package/e2e/performance/unit/first-navigation-metrics.test.ts +32 -0
- package/e2e/performance/unit/mock-server.test.ts +46 -0
- package/e2e/performance/unit/navigation-milestones.test.ts +34 -0
- package/e2e/performance/unit/session-tab-repaint-probe.test.ts +42 -0
- package/e2e/performance/unit/session-tab-switch-metrics.test.ts +86 -0
- package/e2e/performance/unit/session-tab-switch-probe.test.ts +55 -0
- package/e2e/performance/unit/session-timeline-stream-probe.test.ts +14 -0
- package/e2e/performance/unit/session-timeline-visual-tracking.test.ts +16 -0
- package/e2e/performance/unit/timeline-test-helpers.test.ts +10 -0
- package/e2e/performance/unit/visual-stability.test.ts +392 -0
- package/e2e/regression/cross-server-tab-close.spec.ts +153 -0
- package/e2e/regression/file-browser-sidebar-tab-switch.spec.ts +150 -0
- package/e2e/regression/legacy-new-session.spec.ts +41 -0
- package/e2e/regression/new-session-panel-corner.spec.ts +83 -0
- package/e2e/regression/prompt-input-v2-command-draft.spec.ts +50 -0
- package/e2e/regression/prompt-thinking-level.spec.ts +84 -0
- package/e2e/regression/remote-session-settings.spec.ts +302 -0
- package/e2e/regression/remote-tab-busy.spec.ts +131 -0
- package/e2e/regression/review-image-flash.spec.ts +202 -0
- package/e2e/regression/review-line-comment.spec.ts +158 -0
- package/e2e/regression/review-open-file.spec.ts +163 -0
- package/e2e/regression/review-state-persistence.spec.ts +155 -0
- package/e2e/regression/review-tab-switch.spec.ts +147 -0
- package/e2e/regression/review-terminal-stacked.spec.ts +308 -0
- package/e2e/regression/session-list-path-loading.spec.ts +41 -0
- package/e2e/regression/session-request-docks.spec.ts +221 -0
- package/e2e/regression/session-timeline-accessibility.spec.ts +22 -0
- package/e2e/regression/session-timeline-collapse-state.spec.ts +439 -0
- package/e2e/regression/session-timeline-context-resize.spec.ts +374 -0
- package/e2e/regression/session-timeline-context-state.spec.ts +31 -0
- package/e2e/regression/session-timeline-file-projection.spec.ts +52 -0
- package/e2e/regression/session-timeline-file-state.spec.ts +94 -0
- package/e2e/regression/session-timeline-history-root.spec.ts +242 -0
- package/e2e/regression/session-timeline-lifecycle-state.spec.ts +111 -0
- package/e2e/regression/session-timeline-locale-projection.spec.ts +25 -0
- package/e2e/regression/session-timeline-projection.spec.ts +287 -0
- package/e2e/regression/session-timeline-reasoning-projection.spec.ts +93 -0
- package/e2e/regression/session-timeline-reducer-projection.spec.ts +43 -0
- package/e2e/regression/session-timeline-shell-outline.spec.ts +228 -0
- package/e2e/regression/session-timeline-tool-projection.spec.ts +99 -0
- package/e2e/regression/session-timeline-tool-state.spec.ts +77 -0
- package/e2e/regression/session-timeline-transport.spec.ts +116 -0
- package/e2e/regression/session-todo-dock-navigation.spec.ts +190 -0
- package/e2e/regression/subagent-child-navigation.spec.ts +203 -0
- package/e2e/regression/tab-navigate-mousedown.spec.ts +127 -0
- package/e2e/regression/terminal-composer-focus.spec.ts +227 -0
- package/e2e/regression/terminal-hidden.spec.ts +117 -0
- package/e2e/regression/terminal-tab-switch.spec.ts +165 -0
- package/e2e/reproduction/timeline-suspense/index.html +34 -0
- package/e2e/reproduction/timeline-suspense/main.tsx +315 -0
- package/e2e/reproduction/timeline-suspense/playwright.config.ts +34 -0
- package/e2e/reproduction/timeline-suspense/timeline-suspense.repro.ts +179 -0
- package/e2e/reproduction/timeline-suspense/vite.config.ts +7 -0
- package/e2e/smoke/session-timeline.fixture.ts +315 -0
- package/e2e/smoke/session-timeline.spec.ts +740 -0
- package/e2e/tsconfig.json +20 -0
- package/e2e/utils/errors.ts +18 -0
- package/e2e/utils/mock-server.ts +443 -0
- package/e2e/utils/sse-transport.ts +312 -0
- package/e2e/utils/visual-stability/analyzer.ts +209 -0
- package/e2e/utils/visual-stability/capture.ts +51 -0
- package/e2e/utils/visual-stability/index.ts +8 -0
- package/e2e/utils/visual-stability/invariant.ts +112 -0
- package/e2e/utils/visual-stability/model.ts +47 -0
- package/e2e/utils/visual-stability/probe.ts +226 -0
- package/e2e/utils/visual-stability/regions.ts +18 -0
- package/e2e/utils/visual-stability/reporter.ts +63 -0
- package/e2e/utils/visual-stability/scenario.ts +20 -0
- package/e2e/utils/visual-stability.ts +54 -0
- package/e2e/utils/waits.ts +11 -0
- package/happydom.ts +75 -0
- package/index.html +28 -0
- package/package.json +96 -0
- package/playwright.config.ts +45 -0
- package/public/_headers +17 -0
- package/public/apple-touch-icon-v3.png +1 -0
- package/public/apple-touch-icon.png +1 -0
- package/public/assets/Inter.ttf +0 -0
- package/public/assets/JetBrainsMonoNerdFontMono-Regular.woff2 +0 -0
- package/public/favicon-96x96-v3.png +1 -0
- package/public/favicon-96x96.png +1 -0
- package/public/favicon-v3.ico +1 -0
- package/public/favicon-v3.svg +1 -0
- package/public/favicon.ico +1 -0
- package/public/favicon.svg +1 -0
- package/public/oc-theme-preload.js +40 -0
- package/public/site.webmanifest +1 -0
- package/public/social-share-zen.png +1 -0
- package/public/social-share.png +1 -0
- package/public/web-app-manifest-192x192.png +1 -0
- package/public/web-app-manifest-512x512.png +1 -0
- package/src/addons/serialize.test.ts +327 -0
- package/src/addons/serialize.ts +642 -0
- package/src/app.tsx +659 -0
- package/src/assets/help/home.png +0 -0
- package/src/assets/help/introducing-tabs.mp4 +0 -0
- package/src/assets/help/placeholder.png +0 -0
- package/src/assets/help/tabs.png +0 -0
- package/src/components/command-palette.ts +281 -0
- package/src/components/command-tooltip-keybind.test.ts +22 -0
- package/src/components/command-tooltip-keybind.ts +11 -0
- package/src/components/debug-bar.tsx +550 -0
- package/src/components/dialog-command-palette-v2.css +220 -0
- package/src/components/dialog-command-palette-v2.tsx +342 -0
- package/src/components/dialog-connect-provider.stories.tsx +73 -0
- package/src/components/dialog-connect-provider.tsx +1178 -0
- package/src/components/dialog-custom-provider-form.ts +158 -0
- package/src/components/dialog-custom-provider.test.ts +80 -0
- package/src/components/dialog-custom-provider.tsx +330 -0
- package/src/components/dialog-edit-project-v2.tsx +156 -0
- package/src/components/dialog-edit-project.tsx +170 -0
- package/src/components/dialog-fork.tsx +104 -0
- package/src/components/dialog-manage-models.tsx +265 -0
- package/src/components/dialog-release-notes.tsx +144 -0
- package/src/components/dialog-select-directory-v2.css +107 -0
- package/src/components/dialog-select-directory-v2.tsx +378 -0
- package/src/components/dialog-select-directory.tsx +191 -0
- package/src/components/dialog-select-file.tsx +189 -0
- package/src/components/dialog-select-mcp.tsx +92 -0
- package/src/components/dialog-select-model-search.test.ts +19 -0
- package/src/components/dialog-select-model-search.ts +18 -0
- package/src/components/dialog-select-model-unpaid-v2.stories.tsx +55 -0
- package/src/components/dialog-select-model-unpaid-v2.tsx +175 -0
- package/src/components/dialog-select-model-unpaid.tsx +147 -0
- package/src/components/dialog-select-model.tsx +549 -0
- package/src/components/dialog-select-server.tsx +722 -0
- package/src/components/dialog-settings.tsx +94 -0
- package/src/components/dialog-usage-exceeded.tsx +44 -0
- package/src/components/directory-picker-domain.test.ts +248 -0
- package/src/components/directory-picker-domain.ts +407 -0
- package/src/components/directory-picker-policy.ts +7 -0
- package/src/components/directory-picker.test.ts +21 -0
- package/src/components/directory-picker.tsx +45 -0
- package/src/components/edit-project.ts +122 -0
- package/src/components/file-tree-v2-model.test.ts +74 -0
- package/src/components/file-tree-v2-model.ts +107 -0
- package/src/components/file-tree-v2.tsx +299 -0
- package/src/components/file-tree.test.ts +80 -0
- package/src/components/file-tree.tsx +509 -0
- package/src/components/help-button.tsx +148 -0
- package/src/components/link.tsx +26 -0
- package/src/components/model-tooltip.tsx +124 -0
- package/src/components/pierre-tree.test.ts +23 -0
- package/src/components/prompt-input/attachments.test.ts +108 -0
- package/src/components/prompt-input/attachments.ts +228 -0
- package/src/components/prompt-input/build-request-parts.test.ts +396 -0
- package/src/components/prompt-input/build-request-parts.ts +213 -0
- package/src/components/prompt-input/context-items.tsx +98 -0
- package/src/components/prompt-input/contracts.ts +57 -0
- package/src/components/prompt-input/drag-overlay.tsx +25 -0
- package/src/components/prompt-input/editor-dom.test.ts +99 -0
- package/src/components/prompt-input/editor-dom.ts +148 -0
- package/src/components/prompt-input/files.ts +98 -0
- package/src/components/prompt-input/history-store.ts +47 -0
- package/src/components/prompt-input/history.test.ts +153 -0
- package/src/components/prompt-input/history.ts +256 -0
- package/src/components/prompt-input/image-attachments.css +43 -0
- package/src/components/prompt-input/image-attachments.tsx +168 -0
- package/src/components/prompt-input/paste.ts +24 -0
- package/src/components/prompt-input/placeholder.test.ts +48 -0
- package/src/components/prompt-input/placeholder.ts +20 -0
- package/src/components/prompt-input/slash-popover.tsx +376 -0
- package/src/components/prompt-input/submission-state.ts +33 -0
- package/src/components/prompt-input/submit.test.ts +598 -0
- package/src/components/prompt-input/submit.ts +634 -0
- package/src/components/prompt-input/transient-state.ts +46 -0
- package/src/components/prompt-input-v2.tsx +592 -0
- package/src/components/prompt-input.stories.tsx +223 -0
- package/src/components/prompt-input.tsx +1790 -0
- package/src/components/prompt-project-selector.tsx +593 -0
- package/src/components/prompt-workspace-selector.tsx +128 -0
- package/src/components/server/server-row-menu.tsx +96 -0
- package/src/components/server/server-row.tsx +127 -0
- package/src/components/session/index.ts +7 -0
- package/src/components/session/open-in-app-v2.tsx +98 -0
- package/src/components/session/open-in-app.tsx +229 -0
- package/src/components/session/session-context-breakdown.test.ts +61 -0
- package/src/components/session/session-context-breakdown.ts +132 -0
- package/src/components/session/session-context-format.ts +20 -0
- package/src/components/session/session-context-metrics.test.ts +99 -0
- package/src/components/session/session-context-metrics.ts +65 -0
- package/src/components/session/session-context-tab.tsx +343 -0
- package/src/components/session/session-header.tsx +568 -0
- package/src/components/session/session-new-design-view.tsx +16 -0
- package/src/components/session/session-new-view.tsx +91 -0
- package/src/components/session/session-sortable-tab-v2.tsx +74 -0
- package/src/components/session/session-sortable-tab.tsx +78 -0
- package/src/components/session/session-sortable-terminal-tab-v2.tsx +284 -0
- package/src/components/session/session-sortable-terminal-tab.tsx +193 -0
- package/src/components/session-context-usage.tsx +169 -0
- package/src/components/settings-dialog.tsx +43 -0
- package/src/components/settings-general.tsx +794 -0
- package/src/components/settings-keybinds.tsx +553 -0
- package/src/components/settings-list.tsx +5 -0
- package/src/components/settings-models.tsx +149 -0
- package/src/components/settings-providers.tsx +264 -0
- package/src/components/settings-server-picker.tsx +106 -0
- package/src/components/settings-servers.tsx +33 -0
- package/src/components/settings-v2/dialog-server-v2.tsx +134 -0
- package/src/components/settings-v2/dialog-settings-v2.tsx +98 -0
- package/src/components/settings-v2/general.tsx +722 -0
- package/src/components/settings-v2/index.tsx +1 -0
- package/src/components/settings-v2/interface-transition.stories.tsx +76 -0
- package/src/components/settings-v2/interface-transition.tsx +54 -0
- package/src/components/settings-v2/models.tsx +138 -0
- package/src/components/settings-v2/parts/list.tsx +6 -0
- package/src/components/settings-v2/parts/row.tsx +20 -0
- package/src/components/settings-v2/providers.tsx +264 -0
- package/src/components/settings-v2/servers.tsx +139 -0
- package/src/components/settings-v2/settings-v2.css +675 -0
- package/src/components/status-popover-body.tsx +514 -0
- package/src/components/status-popover-indicator.test.ts +36 -0
- package/src/components/status-popover-indicator.ts +20 -0
- package/src/components/status-popover.tsx +190 -0
- package/src/components/terminal.tsx +759 -0
- package/src/components/titlebar-history.test.ts +63 -0
- package/src/components/titlebar-history.ts +57 -0
- package/src/components/titlebar-session-events.test.ts +32 -0
- package/src/components/titlebar-session-events.ts +35 -0
- package/src/components/titlebar-tab-gesture.test.ts +33 -0
- package/src/components/titlebar-tab-gesture.ts +17 -0
- package/src/components/titlebar-tab-nav.css +100 -0
- package/src/components/titlebar-tab-nav.tsx +429 -0
- package/src/components/titlebar-tab-popover.css +127 -0
- package/src/components/titlebar-tab-popover.tsx +92 -0
- package/src/components/titlebar-tab-strip.tsx +333 -0
- package/src/components/titlebar.css +77 -0
- package/src/components/titlebar.tsx +776 -0
- package/src/components/ui/drawer.tsx +119 -0
- package/src/components/updater-action.test.ts +26 -0
- package/src/components/updater-action.ts +51 -0
- package/src/components/virtual-scroll-element.test.ts +18 -0
- package/src/components/virtual-scroll-element.ts +4 -0
- package/src/components/windows-app-menu.tsx +131 -0
- package/src/constants/file-picker.ts +89 -0
- package/src/context/closed-tabs.ts +40 -0
- package/src/context/command-keybind.test.ts +69 -0
- package/src/context/command.test.ts +55 -0
- package/src/context/command.tsx +467 -0
- package/src/context/comments.test.ts +188 -0
- package/src/context/comments.tsx +261 -0
- package/src/context/directory-sync.ts +155 -0
- package/src/context/file/content-cache.ts +88 -0
- package/src/context/file/path.test.ts +360 -0
- package/src/context/file/path.ts +151 -0
- package/src/context/file/tree-store.ts +174 -0
- package/src/context/file/types.ts +41 -0
- package/src/context/file/view-cache.ts +147 -0
- package/src/context/file/watcher.test.ts +149 -0
- package/src/context/file/watcher.ts +53 -0
- package/src/context/file-content-eviction-accounting.test.ts +65 -0
- package/src/context/file.tsx +303 -0
- package/src/context/global-sync/bootstrap.test.ts +231 -0
- package/src/context/global-sync/bootstrap.ts +536 -0
- package/src/context/global-sync/child-store.test.ts +276 -0
- package/src/context/global-sync/child-store.ts +396 -0
- package/src/context/global-sync/event-reducer.test.ts +616 -0
- package/src/context/global-sync/event-reducer.ts +478 -0
- package/src/context/global-sync/eviction.ts +28 -0
- package/src/context/global-sync/home-session-index.test.ts +154 -0
- package/src/context/global-sync/home-session-index.ts +174 -0
- package/src/context/global-sync/mcp.test.ts +54 -0
- package/src/context/global-sync/mcp.ts +19 -0
- package/src/context/global-sync/queue.test.ts +46 -0
- package/src/context/global-sync/queue.ts +87 -0
- package/src/context/global-sync/session-cache.test.ts +104 -0
- package/src/context/global-sync/session-cache.ts +62 -0
- package/src/context/global-sync/session-load.ts +33 -0
- package/src/context/global-sync/session-trim.test.ts +59 -0
- package/src/context/global-sync/session-trim.ts +57 -0
- package/src/context/global-sync/types.ts +135 -0
- package/src/context/global-sync/utils.test.ts +133 -0
- package/src/context/global-sync/utils.ts +171 -0
- package/src/context/global.tsx +161 -0
- package/src/context/highlights.tsx +233 -0
- package/src/context/language.tsx +243 -0
- package/src/context/layout-helpers.ts +38 -0
- package/src/context/layout-scroll.test.ts +64 -0
- package/src/context/layout-scroll.ts +126 -0
- package/src/context/layout-tabs.test.ts +82 -0
- package/src/context/layout-tabs.ts +103 -0
- package/src/context/layout.test.ts +69 -0
- package/src/context/layout.tsx +1075 -0
- package/src/context/local-agent.test.ts +29 -0
- package/src/context/local-agent.ts +7 -0
- package/src/context/local.tsx +417 -0
- package/src/context/mcp.ts +19 -0
- package/src/context/model-variant.test.ts +86 -0
- package/src/context/model-variant.ts +52 -0
- package/src/context/models.tsx +173 -0
- package/src/context/notification.tsx +478 -0
- package/src/context/permission-auto-respond.test.ts +125 -0
- package/src/context/permission-auto-respond.ts +60 -0
- package/src/context/permission.tsx +484 -0
- package/src/context/platform.tsx +142 -0
- package/src/context/prompt-state.test.ts +29 -0
- package/src/context/prompt-state.ts +266 -0
- package/src/context/prompt.tsx +170 -0
- package/src/context/sdk.tsx +17 -0
- package/src/context/server-sdk.test.ts +196 -0
- package/src/context/server-sdk.tsx +444 -0
- package/src/context/server-session-v2-reducer.test.ts +156 -0
- package/src/context/server-session-v2-reducer.ts +502 -0
- package/src/context/server-session.test.ts +1638 -0
- package/src/context/server-session.ts +1425 -0
- package/src/context/server-sync.test.ts +231 -0
- package/src/context/server-sync.tsx +753 -0
- package/src/context/server.test.ts +245 -0
- package/src/context/server.tsx +360 -0
- package/src/context/settings.test.ts +79 -0
- package/src/context/settings.tsx +531 -0
- package/src/context/sync-optimistic.test.ts +123 -0
- package/src/context/sync.tsx +119 -0
- package/src/context/tab-memory.ts +36 -0
- package/src/context/tabs.test.ts +107 -0
- package/src/context/tabs.tsx +387 -0
- package/src/context/terminal-title.ts +24 -0
- package/src/context/terminal.test.ts +91 -0
- package/src/context/terminal.tsx +546 -0
- package/src/custom-elements.d.ts +1 -0
- package/src/desktop-menu.test.ts +13 -0
- package/src/desktop-menu.ts +223 -0
- package/src/entry.tsx +182 -0
- package/src/env.d.ts +31 -0
- package/src/hooks/provider-catalog.test.ts +59 -0
- package/src/hooks/provider-catalog.ts +27 -0
- package/src/hooks/use-providers.ts +71 -0
- package/src/i18n/ar.ts +1008 -0
- package/src/i18n/br.ts +1024 -0
- package/src/i18n/bs.ts +1100 -0
- package/src/i18n/da.ts +1092 -0
- package/src/i18n/de.ts +1037 -0
- package/src/i18n/en.ts +1102 -0
- package/src/i18n/es.ts +1108 -0
- package/src/i18n/fr.ts +1037 -0
- package/src/i18n/ja.ts +1016 -0
- package/src/i18n/ko.ts +1015 -0
- package/src/i18n/no.ts +1111 -0
- package/src/i18n/parity.test.ts +118 -0
- package/src/i18n/pl.ts +1024 -0
- package/src/i18n/ru.ts +1103 -0
- package/src/i18n/th.ts +1087 -0
- package/src/i18n/tr.ts +1106 -0
- package/src/i18n/uk.ts +1105 -0
- package/src/i18n/zh.ts +1078 -0
- package/src/i18n/zht.ts +1074 -0
- package/src/index.css +330 -0
- package/src/index.ts +30 -0
- package/src/pages/directory-layout.tsx +122 -0
- package/src/pages/error-description.test.ts +17 -0
- package/src/pages/error-description.ts +11 -0
- package/src/pages/error.tsx +372 -0
- package/src/pages/home/home-controller.ts +108 -0
- package/src/pages/home/home-projects-controller.tsx +128 -0
- package/src/pages/home/home-projects-view.tsx +615 -0
- package/src/pages/home/home-projects.tsx +40 -0
- package/src/pages/home/home-scroll-controller.ts +145 -0
- package/src/pages/home/home-session-search-controller.ts +114 -0
- package/src/pages/home/home-sessions-controller.tsx +314 -0
- package/src/pages/home/home-sessions-view.tsx +550 -0
- package/src/pages/home/home-sessions.tsx +48 -0
- package/src/pages/home/legacy-home.tsx +142 -0
- package/src/pages/home-session-archive.test.ts +51 -0
- package/src/pages/home-session-archive.ts +27 -0
- package/src/pages/home-session-open.test.ts +31 -0
- package/src/pages/home-session-open.ts +14 -0
- package/src/pages/home.tsx +50 -0
- package/src/pages/layout/deep-links.ts +50 -0
- package/src/pages/layout/helpers.test.ts +321 -0
- package/src/pages/layout/helpers.ts +150 -0
- package/src/pages/layout/inline-editor.tsx +126 -0
- package/src/pages/layout/project-avatar-state.ts +49 -0
- package/src/pages/layout/session-tab-avatar.tsx +60 -0
- package/src/pages/layout/sidebar-items.tsx +335 -0
- package/src/pages/layout/sidebar-project.tsx +377 -0
- package/src/pages/layout/sidebar-shell.tsx +125 -0
- package/src/pages/layout/sidebar-workspace.tsx +488 -0
- package/src/pages/layout-new.tsx +53 -0
- package/src/pages/layout.tsx +2441 -0
- package/src/pages/new-session.tsx +282 -0
- package/src/pages/session/composer/index.ts +4 -0
- package/src/pages/session/composer/prompt-model-selection.ts +133 -0
- package/src/pages/session/composer/session-composer-controls.ts +129 -0
- package/src/pages/session/composer/session-composer-region-controller.ts +145 -0
- package/src/pages/session/composer/session-composer-region.tsx +168 -0
- package/src/pages/session/composer/session-composer-state.test.ts +138 -0
- package/src/pages/session/composer/session-composer-state.ts +204 -0
- package/src/pages/session/composer/session-followup-dock.tsx +109 -0
- package/src/pages/session/composer/session-permission-dock.tsx +74 -0
- package/src/pages/session/composer/session-question-dock.tsx +640 -0
- package/src/pages/session/composer/session-request-tree.ts +52 -0
- package/src/pages/session/composer/session-revert-dock.stories.tsx +124 -0
- package/src/pages/session/composer/session-revert-dock.tsx +188 -0
- package/src/pages/session/composer/session-todo-dock.tsx +277 -0
- package/src/pages/session/composer/todo-panel-motion.stories.tsx +622 -0
- package/src/pages/session/file-tab-scroll.test.ts +40 -0
- package/src/pages/session/file-tab-scroll.ts +67 -0
- package/src/pages/session/file-tabs.tsx +800 -0
- package/src/pages/session/handoff.ts +36 -0
- package/src/pages/session/helpers.test.ts +214 -0
- package/src/pages/session/helpers.ts +209 -0
- package/src/pages/session/message-gesture.test.ts +62 -0
- package/src/pages/session/message-gesture.ts +21 -0
- package/src/pages/session/message-id-from-hash.ts +6 -0
- package/src/pages/session/new-session-layout.ts +2 -0
- package/src/pages/session/review-tab.tsx +172 -0
- package/src/pages/session/session-layout.ts +30 -0
- package/src/pages/session/session-lineage.ts +69 -0
- package/src/pages/session/session-model-helpers.test.ts +151 -0
- package/src/pages/session/session-model-helpers.ts +63 -0
- package/src/pages/session/session-ownership.ts +37 -0
- package/src/pages/session/session-panel-layout.test.ts +19 -0
- package/src/pages/session/session-panel-layout.ts +6 -0
- package/src/pages/session/session-panel-width.test.ts +52 -0
- package/src/pages/session/session-panel-width.ts +19 -0
- package/src/pages/session/session-side-panel.tsx +865 -0
- package/src/pages/session/terminal-label.ts +16 -0
- package/src/pages/session/terminal-panel-v2.tsx +352 -0
- package/src/pages/session/terminal-panel.test.ts +25 -0
- package/src/pages/session/terminal-panel.tsx +343 -0
- package/src/pages/session/timeline/measure.test.ts +30 -0
- package/src/pages/session/timeline/measure.ts +5 -0
- package/src/pages/session/timeline/message-timeline.tsx +1864 -0
- package/src/pages/session/timeline/model.test.ts +95 -0
- package/src/pages/session/timeline/model.ts +128 -0
- package/src/pages/session/timeline/observe-element-offset.test.ts +199 -0
- package/src/pages/session/timeline/observe-element-offset.ts +73 -0
- package/src/pages/session/timeline/projection.test.ts +96 -0
- package/src/pages/session/timeline/projection.ts +81 -0
- package/src/pages/session/timeline/row-reconciliation.ts +56 -0
- package/src/pages/session/timeline/rows-current.test.ts +170 -0
- package/src/pages/session/timeline/rows.ts +344 -0
- package/src/pages/session/timeline/summary-diffs.test.ts +42 -0
- package/src/pages/session/timeline/summary-diffs.ts +20 -0
- package/src/pages/session/timeline/timeline-row.ts +80 -0
- package/src/pages/session/timeline/virtual-items.ts +3 -0
- package/src/pages/session/usage-exceeded-dialogs.tsx +104 -0
- package/src/pages/session/use-composer-commands.tsx +83 -0
- package/src/pages/session/use-session-commands.tsx +606 -0
- package/src/pages/session/use-session-hash-scroll.test.ts +16 -0
- package/src/pages/session/use-session-hash-scroll.ts +202 -0
- package/src/pages/session/v2/review-diff-kinds.test.ts +70 -0
- package/src/pages/session/v2/review-diff-kinds.ts +62 -0
- package/src/pages/session/v2/review-panel-v2-state.ts +41 -0
- package/src/pages/session/v2/review-panel-v2.tsx +255 -0
- package/src/pages/session/v2/session-file-browser-tab.tsx +181 -0
- package/src/pages/session/v2/session-file-list-v2.tsx +166 -0
- package/src/pages/session.tsx +2385 -0
- package/src/sst-env.d.ts +12 -0
- package/src/theme-preload.test.ts +46 -0
- package/src/updater.ts +17 -0
- package/src/utils/agent.ts +44 -0
- package/src/utils/aim.ts +138 -0
- package/src/utils/base64.ts +10 -0
- package/src/utils/comment-note.ts +88 -0
- package/src/utils/diffs.test.ts +75 -0
- package/src/utils/diffs.ts +50 -0
- package/src/utils/file-manager.ts +24 -0
- package/src/utils/id.ts +93 -0
- package/src/utils/notification-click.test.ts +27 -0
- package/src/utils/notification-click.ts +13 -0
- package/src/utils/path-key.ts +24 -0
- package/src/utils/persist.test.ts +211 -0
- package/src/utils/persist.ts +661 -0
- package/src/utils/prompt.test.ts +44 -0
- package/src/utils/prompt.ts +203 -0
- package/src/utils/refcount.test.ts +49 -0
- package/src/utils/refcount.ts +32 -0
- package/src/utils/runtime-adapters.test.ts +64 -0
- package/src/utils/runtime-adapters.ts +39 -0
- package/src/utils/same.ts +6 -0
- package/src/utils/scoped-cache.test.ts +69 -0
- package/src/utils/scoped-cache.ts +104 -0
- package/src/utils/search-keydown.ts +116 -0
- package/src/utils/server-compat.test.ts +193 -0
- package/src/utils/server-compat.ts +512 -0
- package/src/utils/server-errors.test.ts +175 -0
- package/src/utils/server-errors.ts +109 -0
- package/src/utils/server-health.test.ts +178 -0
- package/src/utils/server-health.ts +172 -0
- package/src/utils/server-protocol.test.ts +40 -0
- package/src/utils/server-protocol.ts +35 -0
- package/src/utils/server-scope.test.ts +61 -0
- package/src/utils/server-scope.ts +73 -0
- package/src/utils/server.test.ts +23 -0
- package/src/utils/server.ts +62 -0
- package/src/utils/session-message.test.ts +214 -0
- package/src/utils/session-message.ts +355 -0
- package/src/utils/session-route.test.ts +71 -0
- package/src/utils/session-route.ts +39 -0
- package/src/utils/session-title.ts +7 -0
- package/src/utils/session.test.ts +94 -0
- package/src/utils/session.ts +37 -0
- package/src/utils/solid-dnd.tsx +49 -0
- package/src/utils/sound.ts +102 -0
- package/src/utils/terminal-websocket-url.test.ts +80 -0
- package/src/utils/terminal-websocket-url.ts +35 -0
- package/src/utils/terminal-writer.test.ts +64 -0
- package/src/utils/terminal-writer.ts +65 -0
- package/src/utils/time.ts +22 -0
- package/src/utils/toast.tsx +34 -0
- package/src/utils/uuid.test.ts +78 -0
- package/src/utils/uuid.ts +12 -0
- package/src/utils/worktree.test.ts +58 -0
- package/src/utils/worktree.ts +76 -0
- package/src/wsl/add-server-probes.ts +57 -0
- package/src/wsl/context.tsx +36 -0
- package/src/wsl/dialog-add-server.tsx +463 -0
- package/src/wsl/dialog-add-wsl-server.css +392 -0
- package/src/wsl/settings-model.test.ts +231 -0
- package/src/wsl/settings-model.ts +341 -0
- package/src/wsl/settings.tsx +173 -0
- package/src/wsl/types.ts +85 -0
- package/sst-env.d.ts +10 -0
- package/test-browser/command-palette.test.ts +78 -0
- package/test-browser/motion-spring.test.ts +20 -0
- package/test-browser/prompt-attachments.test.ts +90 -0
- package/test-browser/prompt-persistence.test.ts +71 -0
- package/test-browser/prompt-scope.test.ts +14 -0
- package/test-browser/prompt-submission-state.test.ts +73 -0
- package/test-browser/prompt-transient-state.test.ts +38 -0
- package/test-browser/review-panel-v2-state.test.ts +65 -0
- package/test-browser/session-lineage.test.ts +231 -0
- package/test-browser/session-ownership.test.ts +45 -0
- package/test-browser/solid-virtual.test.ts +112 -0
- package/test-browser/toast-owner.test.ts +26 -0
- package/tsconfig.json +26 -0
- package/vendor/opencode-ai-client-1.17.13.tgz +0 -0
- package/vite.config.ts +33 -0
- package/vite.js +48 -0
|
@@ -0,0 +1,512 @@
|
|
|
1
|
+
import type { ServerApi } from "./server"
|
|
2
|
+
import type { ServerProtocol } from "./server-protocol"
|
|
3
|
+
import type { AgentPartInput, FilePartInput, NeurocodeClient, Session, TextPartInput } from "@neurocode-ai/sdk/v2/client"
|
|
4
|
+
import type {
|
|
5
|
+
Project,
|
|
6
|
+
ProjectCurrent,
|
|
7
|
+
SessionApi,
|
|
8
|
+
SessionCommandInput,
|
|
9
|
+
SessionCommandOutput,
|
|
10
|
+
SessionCompactInput,
|
|
11
|
+
SessionCompactOutput,
|
|
12
|
+
SessionInfo,
|
|
13
|
+
SessionPromptInput,
|
|
14
|
+
SessionPromptOutput,
|
|
15
|
+
SessionShellInput,
|
|
16
|
+
SessionShellOutput,
|
|
17
|
+
} from "@neurocode-ai/client/promise"
|
|
18
|
+
|
|
19
|
+
type LegacyClient = NeurocodeClient
|
|
20
|
+
type LegacyFor = (directory?: string) => LegacyClient
|
|
21
|
+
type CompatibleSessionApi = Omit<
|
|
22
|
+
SessionApi,
|
|
23
|
+
"prompt" | "command" | "shell" | "compact" | "rename" | "archive" | "remove"
|
|
24
|
+
> & {
|
|
25
|
+
prompt: (input: SessionPromptInput & LegacyPrompt) => Promise<SessionPromptOutput>
|
|
26
|
+
command: (input: SessionCommandInput) => Promise<SessionCommandOutput>
|
|
27
|
+
shell: (input: SessionShellInput & LegacyPrompt) => Promise<SessionShellOutput>
|
|
28
|
+
compact: (input: SessionCompactInput & { model?: LegacyPrompt["model"] }) => Promise<SessionCompactOutput>
|
|
29
|
+
rename: (input: Parameters<SessionApi["rename"]>[0] & LegacyLocation) => ReturnType<SessionApi["rename"]>
|
|
30
|
+
archive: (input: Parameters<SessionApi["archive"]>[0] & LegacyLocation) => ReturnType<SessionApi["archive"]>
|
|
31
|
+
remove: (input: Parameters<SessionApi["remove"]>[0] & LegacyLocation) => ReturnType<SessionApi["remove"]>
|
|
32
|
+
}
|
|
33
|
+
type CompatiblePermissionApi = Omit<ServerApi["permission"], "reply"> & {
|
|
34
|
+
reply: (
|
|
35
|
+
input: Parameters<ServerApi["permission"]["reply"]>[0] & { location?: { directory?: string } },
|
|
36
|
+
) => ReturnType<ServerApi["permission"]["reply"]>
|
|
37
|
+
}
|
|
38
|
+
export type CompatibleApi = Omit<ServerApi, "session" | "permission"> & {
|
|
39
|
+
readonly session: CompatibleSessionApi
|
|
40
|
+
readonly permission: CompatiblePermissionApi
|
|
41
|
+
}
|
|
42
|
+
type LegacyPrompt = {
|
|
43
|
+
agent?: string
|
|
44
|
+
model?: { providerID: string; modelID: string }
|
|
45
|
+
variant?: string
|
|
46
|
+
legacyParts?: (TextPartInput | FilePartInput | AgentPartInput)[]
|
|
47
|
+
}
|
|
48
|
+
type LegacyLocation = { directory?: string }
|
|
49
|
+
type CompatibleInput = {
|
|
50
|
+
protocol: Promise<ServerProtocol>
|
|
51
|
+
current: ServerApi
|
|
52
|
+
legacy: LegacyFor
|
|
53
|
+
directory?: string
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function mime(uri: string) {
|
|
57
|
+
const match = /^data:([^;,]+)/.exec(uri)
|
|
58
|
+
return match?.[1] ?? "application/octet-stream"
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function sessionInfo(session: Session): SessionInfo {
|
|
62
|
+
return {
|
|
63
|
+
id: session.id,
|
|
64
|
+
parentID: session.parentID,
|
|
65
|
+
projectID: session.projectID,
|
|
66
|
+
agent: session.agent,
|
|
67
|
+
model: session.model && {
|
|
68
|
+
id: session.model.id,
|
|
69
|
+
providerID: session.model.providerID,
|
|
70
|
+
variant: session.model.variant,
|
|
71
|
+
},
|
|
72
|
+
cost: session.cost ?? 0,
|
|
73
|
+
tokens: session.tokens ?? { input: 0, output: 0, reasoning: 0, cache: { read: 0, write: 0 } },
|
|
74
|
+
time: session.time,
|
|
75
|
+
title: session.title,
|
|
76
|
+
location: { directory: session.directory, workspaceID: session.workspaceID },
|
|
77
|
+
subpath: session.path,
|
|
78
|
+
revert: session.revert && {
|
|
79
|
+
messageID: session.revert.messageID,
|
|
80
|
+
partID: session.revert.partID,
|
|
81
|
+
snapshot: session.revert.snapshot,
|
|
82
|
+
},
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function createCompatibleApi(input: CompatibleInput): CompatibleApi {
|
|
87
|
+
const v1 = createV1Api(input)
|
|
88
|
+
return lazyApi(
|
|
89
|
+
input.protocol.then((protocol) => (protocol === "v1" ? v1 : input.current)),
|
|
90
|
+
input.current,
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function lazyApi<T extends object>(implementation: Promise<T>, shape: T): T {
|
|
95
|
+
const cache = new Map<PropertyKey, unknown>()
|
|
96
|
+
return new Proxy(shape, {
|
|
97
|
+
get(target, property, receiver) {
|
|
98
|
+
const sample = Reflect.get(target, property, receiver)
|
|
99
|
+
if (typeof sample === "function") {
|
|
100
|
+
return (...args: unknown[]) =>
|
|
101
|
+
implementation.then((value) => {
|
|
102
|
+
const method = Reflect.get(value, property)
|
|
103
|
+
if (typeof method !== "function") throw new Error(`API method unavailable: ${String(property)}`)
|
|
104
|
+
return Reflect.apply(method, value, args)
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
if (sample === null || typeof sample !== "object") return sample
|
|
108
|
+
if (cache.has(property)) return cache.get(property)
|
|
109
|
+
const nested = lazyApi(
|
|
110
|
+
implementation.then((value) => {
|
|
111
|
+
const result = Reflect.get(value, property)
|
|
112
|
+
if (result === null || typeof result !== "object") {
|
|
113
|
+
throw new Error(`API namespace unavailable: ${String(property)}`)
|
|
114
|
+
}
|
|
115
|
+
return result
|
|
116
|
+
}),
|
|
117
|
+
sample,
|
|
118
|
+
)
|
|
119
|
+
cache.set(property, nested)
|
|
120
|
+
return nested
|
|
121
|
+
},
|
|
122
|
+
})
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function createV1Api(input: CompatibleInput): CompatibleApi {
|
|
126
|
+
const directory = (location?: { directory?: string }) => location?.directory ?? input.directory
|
|
127
|
+
const legacy = (location?: { directory?: string }) => input.legacy(directory(location))
|
|
128
|
+
const located = <T>(data: T, value?: { directory?: string }) => ({
|
|
129
|
+
location: {
|
|
130
|
+
directory: directory(value) ?? "",
|
|
131
|
+
project: { id: "", directory: directory(value) ?? "" },
|
|
132
|
+
},
|
|
133
|
+
data,
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
return {
|
|
137
|
+
...input.current,
|
|
138
|
+
session: {
|
|
139
|
+
...input.current.session,
|
|
140
|
+
async list(
|
|
141
|
+
value?: Parameters<ServerApi["session"]["list"]>[0],
|
|
142
|
+
options?: Parameters<ServerApi["session"]["list"]>[1],
|
|
143
|
+
) {
|
|
144
|
+
if (!value?.directory && value?.search !== undefined) {
|
|
145
|
+
const result = await legacy().experimental.session.list(
|
|
146
|
+
{
|
|
147
|
+
roots: value.parentID === null ? true : undefined,
|
|
148
|
+
search: value.search,
|
|
149
|
+
limit: value.limit,
|
|
150
|
+
},
|
|
151
|
+
options,
|
|
152
|
+
)
|
|
153
|
+
return { data: (result.data ?? []).map(sessionInfo), cursor: {} }
|
|
154
|
+
}
|
|
155
|
+
const result = await legacy({ directory: value?.directory }).session.list({
|
|
156
|
+
directory: value?.directory,
|
|
157
|
+
roots: value?.parentID === null ? true : undefined,
|
|
158
|
+
search: value?.search,
|
|
159
|
+
limit: value?.limit,
|
|
160
|
+
})
|
|
161
|
+
return { data: (result.data ?? []).map(sessionInfo), cursor: {} }
|
|
162
|
+
},
|
|
163
|
+
async create(value?: Parameters<ServerApi["session"]["create"]>[0]) {
|
|
164
|
+
const result = await legacy(value?.location ?? undefined).session.create({
|
|
165
|
+
directory: directory(value?.location ?? undefined),
|
|
166
|
+
})
|
|
167
|
+
if (!result.data) throw new Error("Failed to create session")
|
|
168
|
+
return sessionInfo(result.data)
|
|
169
|
+
},
|
|
170
|
+
async get(value: Parameters<ServerApi["session"]["get"]>[0]) {
|
|
171
|
+
const result = await legacy().session.get(value)
|
|
172
|
+
if (!result.data) throw new Error(`Session not found: ${value.sessionID}`)
|
|
173
|
+
return sessionInfo(result.data)
|
|
174
|
+
},
|
|
175
|
+
async active() {
|
|
176
|
+
const result = await legacy().session.status()
|
|
177
|
+
return Object.fromEntries(
|
|
178
|
+
Object.entries(result.data ?? {}).flatMap(([sessionID, status]) =>
|
|
179
|
+
status.type === "idle" ? [] : [[sessionID, { type: "running" as const }]],
|
|
180
|
+
),
|
|
181
|
+
)
|
|
182
|
+
},
|
|
183
|
+
async rename(value: Parameters<ServerApi["session"]["rename"]>[0] & LegacyLocation) {
|
|
184
|
+
await legacy(value).session.update({ sessionID: value.sessionID, title: value.title })
|
|
185
|
+
},
|
|
186
|
+
async archive(value: Parameters<ServerApi["session"]["archive"]>[0] & LegacyLocation) {
|
|
187
|
+
await legacy(value).session.update({ sessionID: value.sessionID, time: { archived: Date.now() } })
|
|
188
|
+
},
|
|
189
|
+
async remove(value: Parameters<ServerApi["session"]["remove"]>[0] & LegacyLocation) {
|
|
190
|
+
await legacy(value).session.delete(value)
|
|
191
|
+
},
|
|
192
|
+
async fork(value: Parameters<ServerApi["session"]["fork"]>[0]) {
|
|
193
|
+
const result = await legacy().session.fork(value)
|
|
194
|
+
if (!result.data) throw new Error("Failed to fork session")
|
|
195
|
+
return sessionInfo(result.data)
|
|
196
|
+
},
|
|
197
|
+
async interrupt(value: Parameters<ServerApi["session"]["interrupt"]>[0]) {
|
|
198
|
+
await legacy().session.abort(value)
|
|
199
|
+
},
|
|
200
|
+
async prompt(value: SessionPromptInput & LegacyPrompt) {
|
|
201
|
+
await legacy().session.promptAsync({
|
|
202
|
+
sessionID: value.sessionID,
|
|
203
|
+
messageID: value.id ?? undefined,
|
|
204
|
+
agent: value.agent,
|
|
205
|
+
model: value.model,
|
|
206
|
+
variant: value.variant,
|
|
207
|
+
parts: value.legacyParts ?? [
|
|
208
|
+
{ type: "text", text: value.text },
|
|
209
|
+
...(value.files ?? []).map((file) => ({
|
|
210
|
+
type: "file" as const,
|
|
211
|
+
mime: file.mention ? "text/plain" : mime(file.uri),
|
|
212
|
+
url: file.uri,
|
|
213
|
+
filename: file.name,
|
|
214
|
+
source: file.mention
|
|
215
|
+
? {
|
|
216
|
+
type: "file" as const,
|
|
217
|
+
text: { value: file.mention.text, start: file.mention.start, end: file.mention.end },
|
|
218
|
+
path: file.uri,
|
|
219
|
+
}
|
|
220
|
+
: undefined,
|
|
221
|
+
})),
|
|
222
|
+
...(value.agents ?? []).map((agent) => ({
|
|
223
|
+
type: "agent" as const,
|
|
224
|
+
name: agent.name,
|
|
225
|
+
source: agent.mention
|
|
226
|
+
? { value: agent.mention.text, start: agent.mention.start, end: agent.mention.end }
|
|
227
|
+
: undefined,
|
|
228
|
+
})),
|
|
229
|
+
],
|
|
230
|
+
})
|
|
231
|
+
return {
|
|
232
|
+
admittedSeq: 0,
|
|
233
|
+
id: value.id ?? "",
|
|
234
|
+
sessionID: value.sessionID,
|
|
235
|
+
timeCreated: Date.now(),
|
|
236
|
+
type: "user",
|
|
237
|
+
data: { text: value.text },
|
|
238
|
+
delivery: value.delivery ?? "steer",
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
async command(value: SessionCommandInput) {
|
|
242
|
+
await legacy().session.command({
|
|
243
|
+
sessionID: value.sessionID,
|
|
244
|
+
messageID: value.id ?? undefined,
|
|
245
|
+
command: value.command,
|
|
246
|
+
arguments: value.arguments ?? "",
|
|
247
|
+
agent: value.agent ?? undefined,
|
|
248
|
+
model: value.model ? `${value.model.providerID}/${value.model.id}` : undefined,
|
|
249
|
+
variant: value.model?.variant,
|
|
250
|
+
parts: value.files?.map((file) => ({
|
|
251
|
+
type: "file" as const,
|
|
252
|
+
mime: mime(file.uri),
|
|
253
|
+
url: file.uri,
|
|
254
|
+
filename: file.name,
|
|
255
|
+
})),
|
|
256
|
+
})
|
|
257
|
+
return {
|
|
258
|
+
admittedSeq: 0,
|
|
259
|
+
id: value.id ?? "",
|
|
260
|
+
sessionID: value.sessionID,
|
|
261
|
+
timeCreated: Date.now(),
|
|
262
|
+
type: "user",
|
|
263
|
+
data: { text: `/${value.command} ${value.arguments ?? ""}`.trim() },
|
|
264
|
+
delivery: value.delivery ?? "steer",
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
async shell(value: SessionShellInput & LegacyPrompt) {
|
|
268
|
+
await legacy().session.shell({
|
|
269
|
+
sessionID: value.sessionID,
|
|
270
|
+
command: value.command,
|
|
271
|
+
agent: value.agent,
|
|
272
|
+
model: value.model,
|
|
273
|
+
})
|
|
274
|
+
},
|
|
275
|
+
compact: async (value: SessionCompactInput & { model?: LegacyPrompt["model"] }) => {
|
|
276
|
+
if (!value.model) throw new Error("A model is required to compact a V1 session")
|
|
277
|
+
await legacy().session.summarize({
|
|
278
|
+
sessionID: value.sessionID,
|
|
279
|
+
providerID: value.model.providerID,
|
|
280
|
+
modelID: value.model.modelID,
|
|
281
|
+
})
|
|
282
|
+
return {
|
|
283
|
+
admittedSeq: 0,
|
|
284
|
+
id: value.id ?? "",
|
|
285
|
+
sessionID: value.sessionID,
|
|
286
|
+
timeCreated: Date.now(),
|
|
287
|
+
type: "compaction",
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
revert: {
|
|
291
|
+
stage: async (value: Parameters<ServerApi["session"]["revert"]["stage"]>[0]) => {
|
|
292
|
+
await legacy().session.revert(value)
|
|
293
|
+
return { messageID: value.messageID }
|
|
294
|
+
},
|
|
295
|
+
clear: async (value: Parameters<ServerApi["session"]["revert"]["clear"]>[0]) => {
|
|
296
|
+
await legacy().session.unrevert(value)
|
|
297
|
+
},
|
|
298
|
+
commit: input.current.session.revert.commit,
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
|
+
project: {
|
|
302
|
+
...input.current.project,
|
|
303
|
+
async list() {
|
|
304
|
+
return ((await legacy().project.list()).data ?? []) as Project[]
|
|
305
|
+
},
|
|
306
|
+
async current(value?: Parameters<ServerApi["project"]["current"]>[0]) {
|
|
307
|
+
const result = await legacy(value?.location).project.current()
|
|
308
|
+
if (!result.data) throw new Error("Project not found")
|
|
309
|
+
return { id: result.data.id, directory: result.data.worktree } satisfies ProjectCurrent
|
|
310
|
+
},
|
|
311
|
+
async update(value: Parameters<ServerApi["project"]["update"]>[0]) {
|
|
312
|
+
const project = (await legacy().project.list()).data?.find((item) => item.id === value.projectID)
|
|
313
|
+
const result = await legacy({ directory: project?.worktree }).project.update({
|
|
314
|
+
...value,
|
|
315
|
+
directory: project?.worktree,
|
|
316
|
+
})
|
|
317
|
+
if (!result.data) throw new Error(`Project not found: ${value.projectID}`)
|
|
318
|
+
return result.data as Project
|
|
319
|
+
},
|
|
320
|
+
async directories(value: Parameters<ServerApi["project"]["directories"]>[0]) {
|
|
321
|
+
const result = await legacy(value.location).worktree.list()
|
|
322
|
+
return (result.data ?? []).map((item) => ({ directory: item }))
|
|
323
|
+
},
|
|
324
|
+
},
|
|
325
|
+
path: {
|
|
326
|
+
...input.current.path,
|
|
327
|
+
async get(value?: Parameters<ServerApi["path"]["get"]>[0]) {
|
|
328
|
+
const result = await legacy(value?.location).path.get()
|
|
329
|
+
if (!result.data) throw new Error("Path unavailable")
|
|
330
|
+
return result.data
|
|
331
|
+
},
|
|
332
|
+
},
|
|
333
|
+
vcs: {
|
|
334
|
+
...input.current.vcs,
|
|
335
|
+
async get(value?: Parameters<ServerApi["vcs"]["get"]>[0]) {
|
|
336
|
+
const result = await legacy(value?.location).vcs.get()
|
|
337
|
+
return located({ branch: result.data?.branch, defaultBranch: result.data?.default_branch }, value?.location)
|
|
338
|
+
},
|
|
339
|
+
async status(value?: Parameters<ServerApi["vcs"]["status"]>[0]) {
|
|
340
|
+
const result = await legacy(value?.location).vcs.status()
|
|
341
|
+
return located(result.data ?? [], value?.location)
|
|
342
|
+
},
|
|
343
|
+
async diff(value: Parameters<ServerApi["vcs"]["diff"]>[0]) {
|
|
344
|
+
const result = await legacy(value.location).vcs.diff({
|
|
345
|
+
mode: value.mode === "working" ? "git" : value.mode,
|
|
346
|
+
context: value.context,
|
|
347
|
+
})
|
|
348
|
+
return located(
|
|
349
|
+
(result.data ?? []).map((file) => ({
|
|
350
|
+
file: file.file,
|
|
351
|
+
patch: file.patch ?? "",
|
|
352
|
+
additions: file.additions,
|
|
353
|
+
deletions: file.deletions,
|
|
354
|
+
status: file.status ?? "modified",
|
|
355
|
+
})),
|
|
356
|
+
value.location,
|
|
357
|
+
)
|
|
358
|
+
},
|
|
359
|
+
},
|
|
360
|
+
file: {
|
|
361
|
+
...input.current.file,
|
|
362
|
+
async list(value?: Parameters<ServerApi["file"]["list"]>[0]) {
|
|
363
|
+
const result = await legacy(value?.location).file.list({ path: value?.path ?? "" })
|
|
364
|
+
return located(result.data ?? [], value?.location)
|
|
365
|
+
},
|
|
366
|
+
async find(value: Parameters<ServerApi["file"]["find"]>[0]) {
|
|
367
|
+
const result = await legacy(value.location).find.files({
|
|
368
|
+
query: value.query,
|
|
369
|
+
dirs: value.type === undefined ? undefined : value.type === "directory" ? "true" : "false",
|
|
370
|
+
limit: value.limit,
|
|
371
|
+
})
|
|
372
|
+
return located(
|
|
373
|
+
(result.data ?? []).map((path) => ({ path, type: value.type ?? "file" })),
|
|
374
|
+
value.location,
|
|
375
|
+
)
|
|
376
|
+
},
|
|
377
|
+
},
|
|
378
|
+
integration: {
|
|
379
|
+
...input.current.integration,
|
|
380
|
+
async get(value: Parameters<ServerApi["integration"]["get"]>[0]) {
|
|
381
|
+
const methods = ((await legacy(value.location).provider.auth()).data?.[value.integrationID] ?? []).map(
|
|
382
|
+
(method, index) =>
|
|
383
|
+
method.type === "api"
|
|
384
|
+
? { type: "key" as const, label: method.label }
|
|
385
|
+
: { type: "oauth" as const, id: String(index), label: method.label, prompts: method.prompts },
|
|
386
|
+
)
|
|
387
|
+
return located(
|
|
388
|
+
{
|
|
389
|
+
id: value.integrationID,
|
|
390
|
+
name: value.integrationID,
|
|
391
|
+
methods,
|
|
392
|
+
connections: [],
|
|
393
|
+
},
|
|
394
|
+
value.location,
|
|
395
|
+
)
|
|
396
|
+
},
|
|
397
|
+
connect: {
|
|
398
|
+
...input.current.integration.connect,
|
|
399
|
+
key: async (value: Parameters<ServerApi["integration"]["connect"]["key"]>[0]) => {
|
|
400
|
+
await legacy(value.location).auth.set({
|
|
401
|
+
providerID: value.integrationID,
|
|
402
|
+
auth: { type: "api", key: value.key },
|
|
403
|
+
})
|
|
404
|
+
},
|
|
405
|
+
},
|
|
406
|
+
oauth: {
|
|
407
|
+
...input.current.integration.oauth,
|
|
408
|
+
connect: async (value: Parameters<ServerApi["integration"]["oauth"]["connect"]>[0]) => {
|
|
409
|
+
const method = Number(value.methodID)
|
|
410
|
+
const result = await legacy(value.location).provider.oauth.authorize(
|
|
411
|
+
{ providerID: value.integrationID, method, inputs: value.inputs },
|
|
412
|
+
{ throwOnError: true },
|
|
413
|
+
)
|
|
414
|
+
if (!result.data) throw new Error("Failed to start OAuth authorization")
|
|
415
|
+
return located(
|
|
416
|
+
{
|
|
417
|
+
attemptID: `${value.integrationID}:${method}`,
|
|
418
|
+
url: result.data.url,
|
|
419
|
+
instructions: result.data.instructions,
|
|
420
|
+
mode: result.data.method,
|
|
421
|
+
time: { created: Date.now(), expires: Date.now() + 10 * 60 * 1000 },
|
|
422
|
+
},
|
|
423
|
+
value.location,
|
|
424
|
+
)
|
|
425
|
+
},
|
|
426
|
+
complete: async (value: Parameters<ServerApi["integration"]["oauth"]["complete"]>[0]) => {
|
|
427
|
+
const method = Number(value.attemptID.split(":").at(-1))
|
|
428
|
+
await legacy(value.location).provider.oauth.callback(
|
|
429
|
+
{ providerID: value.integrationID, method, code: value.code },
|
|
430
|
+
{ throwOnError: true },
|
|
431
|
+
)
|
|
432
|
+
},
|
|
433
|
+
status: async (value: Parameters<ServerApi["integration"]["oauth"]["status"]>[0]) => {
|
|
434
|
+
const method = Number(value.attemptID.split(":").at(-1))
|
|
435
|
+
await legacy(value.location).provider.oauth.callback(
|
|
436
|
+
{ providerID: value.integrationID, method },
|
|
437
|
+
{ throwOnError: true },
|
|
438
|
+
)
|
|
439
|
+
return located(
|
|
440
|
+
{ status: "complete" as const, time: { created: Date.now(), expires: Date.now() } },
|
|
441
|
+
value.location,
|
|
442
|
+
)
|
|
443
|
+
},
|
|
444
|
+
},
|
|
445
|
+
},
|
|
446
|
+
pty: {
|
|
447
|
+
...input.current.pty,
|
|
448
|
+
async shells(value?: Parameters<ServerApi["pty"]["shells"]>[0]) {
|
|
449
|
+
return located((await legacy(value?.location).pty.shells()).data ?? [], value?.location)
|
|
450
|
+
},
|
|
451
|
+
async list(value?: Parameters<ServerApi["pty"]["list"]>[0]) {
|
|
452
|
+
return located((await legacy(value?.location).pty.list()).data ?? [], value?.location)
|
|
453
|
+
},
|
|
454
|
+
async create(value?: Parameters<ServerApi["pty"]["create"]>[0]) {
|
|
455
|
+
const result = await legacy(value?.location).pty.create({
|
|
456
|
+
command: value?.command,
|
|
457
|
+
args: value?.args ? [...value.args] : undefined,
|
|
458
|
+
cwd: value?.cwd,
|
|
459
|
+
title: value?.title,
|
|
460
|
+
env: value?.env,
|
|
461
|
+
})
|
|
462
|
+
if (!result.data) throw new Error("Failed to create terminal")
|
|
463
|
+
return located(result.data, value?.location)
|
|
464
|
+
},
|
|
465
|
+
async get(value: Parameters<ServerApi["pty"]["get"]>[0]) {
|
|
466
|
+
const result = await legacy(value.location).pty.get({ ptyID: value.ptyID })
|
|
467
|
+
if (!result.data) throw new Error(`Terminal not found: ${value.ptyID}`)
|
|
468
|
+
return located(result.data, value.location)
|
|
469
|
+
},
|
|
470
|
+
async update(value: Parameters<ServerApi["pty"]["update"]>[0]) {
|
|
471
|
+
const result = await legacy(value.location).pty.update({
|
|
472
|
+
ptyID: value.ptyID,
|
|
473
|
+
title: value.title,
|
|
474
|
+
size: value.size,
|
|
475
|
+
})
|
|
476
|
+
if (!result.data) throw new Error(`Terminal not found: ${value.ptyID}`)
|
|
477
|
+
return located(result.data, value.location)
|
|
478
|
+
},
|
|
479
|
+
async remove(value: Parameters<ServerApi["pty"]["remove"]>[0]) {
|
|
480
|
+
await legacy(value.location).pty.remove({ ptyID: value.ptyID })
|
|
481
|
+
},
|
|
482
|
+
async connectToken(value: Parameters<ServerApi["pty"]["connectToken"]>[0]) {
|
|
483
|
+
const result = await legacy(value.location).pty.connectToken({ ptyID: value.ptyID })
|
|
484
|
+
if (!result.data) throw new Error(`Failed to connect terminal: ${value.ptyID}`)
|
|
485
|
+
return located(result.data, value.location)
|
|
486
|
+
},
|
|
487
|
+
},
|
|
488
|
+
permission: {
|
|
489
|
+
...input.current.permission,
|
|
490
|
+
async reply(value: Parameters<ServerApi["permission"]["reply"]>[0] & { location?: { directory?: string } }) {
|
|
491
|
+
await legacy(value.location).permission.respond({
|
|
492
|
+
sessionID: value.sessionID,
|
|
493
|
+
permissionID: value.requestID,
|
|
494
|
+
response: value.reply,
|
|
495
|
+
directory: directory(value.location),
|
|
496
|
+
})
|
|
497
|
+
},
|
|
498
|
+
},
|
|
499
|
+
question: {
|
|
500
|
+
...input.current.question,
|
|
501
|
+
async reply(value: Parameters<ServerApi["question"]["reply"]>[0]) {
|
|
502
|
+
await legacy().question.reply({
|
|
503
|
+
requestID: value.requestID,
|
|
504
|
+
answers: value.answers.map((answer) => [...answer]),
|
|
505
|
+
})
|
|
506
|
+
},
|
|
507
|
+
async reject(value: Parameters<ServerApi["question"]["reject"]>[0]) {
|
|
508
|
+
await legacy().question.reject({ requestID: value.requestID })
|
|
509
|
+
},
|
|
510
|
+
},
|
|
511
|
+
}
|
|
512
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test"
|
|
2
|
+
import type { SessionNotFoundError } from "@neurocode-ai/sdk/v2/client"
|
|
3
|
+
import type { ConfigInvalidError, ProviderModelNotFoundError } from "./server-errors"
|
|
4
|
+
import { formatServerError, isSessionNotFoundError, parseReadableConfigInvalidError } from "./server-errors"
|
|
5
|
+
|
|
6
|
+
function fill(text: string, vars?: Record<string, string | number>) {
|
|
7
|
+
if (!vars) return text
|
|
8
|
+
return text.replace(/{{\s*(\w+)\s*}}/g, (_, key: string) => {
|
|
9
|
+
const value = vars[key]
|
|
10
|
+
if (value === undefined) return ""
|
|
11
|
+
return String(value)
|
|
12
|
+
})
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function useLanguageMock() {
|
|
16
|
+
const dict: Record<string, string> = {
|
|
17
|
+
"error.chain.unknown": "Erro desconhecido",
|
|
18
|
+
"error.chain.configInvalid": "Arquivo de config em {{path}} invalido",
|
|
19
|
+
"error.chain.configInvalidWithMessage": "Arquivo de config em {{path}} invalido: {{message}}",
|
|
20
|
+
"error.chain.modelNotFound": "Modelo nao encontrado: {{provider}}/{{model}}",
|
|
21
|
+
"error.chain.didYouMean": "Voce quis dizer: {{suggestions}}",
|
|
22
|
+
"error.chain.checkConfig": "Revise provider/model no config",
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
t(key: string, vars?: Record<string, string | number>) {
|
|
26
|
+
const text = dict[key]
|
|
27
|
+
if (!text) return key
|
|
28
|
+
return fill(text, vars)
|
|
29
|
+
},
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const language = useLanguageMock()
|
|
34
|
+
|
|
35
|
+
describe("parseReadableConfigInvalidError", () => {
|
|
36
|
+
test("formats issues with file path", () => {
|
|
37
|
+
const error = {
|
|
38
|
+
name: "ConfigInvalidError",
|
|
39
|
+
data: {
|
|
40
|
+
path: "neurocode.config.ts",
|
|
41
|
+
issues: [
|
|
42
|
+
{ path: ["settings", "host"], message: "Required" },
|
|
43
|
+
{ path: ["mode"], message: "Invalid" },
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
} satisfies ConfigInvalidError
|
|
47
|
+
|
|
48
|
+
const result = parseReadableConfigInvalidError(error, language.t)
|
|
49
|
+
|
|
50
|
+
expect(result).toBe(
|
|
51
|
+
["Arquivo de config em neurocode.config.ts invalido: settings.host: Required", "mode: Invalid"].join("\n"),
|
|
52
|
+
)
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
test("uses trimmed message when issues are missing", () => {
|
|
56
|
+
const error = {
|
|
57
|
+
name: "ConfigInvalidError",
|
|
58
|
+
data: {
|
|
59
|
+
path: "config",
|
|
60
|
+
message: " Bad value ",
|
|
61
|
+
},
|
|
62
|
+
} satisfies ConfigInvalidError
|
|
63
|
+
|
|
64
|
+
const result = parseReadableConfigInvalidError(error, language.t)
|
|
65
|
+
|
|
66
|
+
expect(result).toBe("Arquivo de config em config invalido: Bad value")
|
|
67
|
+
})
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
describe("formatServerError", () => {
|
|
71
|
+
test("formats config invalid errors", () => {
|
|
72
|
+
const error = {
|
|
73
|
+
name: "ConfigInvalidError",
|
|
74
|
+
data: {
|
|
75
|
+
message: "Missing host",
|
|
76
|
+
},
|
|
77
|
+
} satisfies ConfigInvalidError
|
|
78
|
+
|
|
79
|
+
const result = formatServerError(error, language.t)
|
|
80
|
+
|
|
81
|
+
expect(result).toBe("Arquivo de config em config invalido: Missing host")
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
test("returns error messages", () => {
|
|
85
|
+
expect(formatServerError(new Error("Request failed with status 503"), language.t)).toBe(
|
|
86
|
+
"Request failed with status 503",
|
|
87
|
+
)
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
test("returns provided string errors", () => {
|
|
91
|
+
expect(formatServerError("Failed to connect to server", language.t)).toBe("Failed to connect to server")
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
test("uses translated unknown fallback", () => {
|
|
95
|
+
expect(formatServerError(0, language.t)).toBe("Erro desconhecido")
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
test("falls back for unknown error objects and names", () => {
|
|
99
|
+
expect(formatServerError({ name: "ServerTimeoutError", data: { seconds: 30 } }, language.t)).toBe(
|
|
100
|
+
"Erro desconhecido",
|
|
101
|
+
)
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
test("formats provider model errors using provider/model", () => {
|
|
105
|
+
const error = {
|
|
106
|
+
name: "ProviderModelNotFoundError",
|
|
107
|
+
data: {
|
|
108
|
+
providerID: "openai",
|
|
109
|
+
modelID: "gpt-4.1",
|
|
110
|
+
},
|
|
111
|
+
} satisfies ProviderModelNotFoundError
|
|
112
|
+
|
|
113
|
+
expect(formatServerError(error, language.t)).toBe(
|
|
114
|
+
["Modelo nao encontrado: openai/gpt-4.1", "Revise provider/model no config"].join("\n"),
|
|
115
|
+
)
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
test("formats provider model suggestions", () => {
|
|
119
|
+
const error = {
|
|
120
|
+
name: "ProviderModelNotFoundError",
|
|
121
|
+
data: {
|
|
122
|
+
providerID: "x",
|
|
123
|
+
modelID: "y",
|
|
124
|
+
suggestions: ["x/y2", "x/y3"],
|
|
125
|
+
},
|
|
126
|
+
} satisfies ProviderModelNotFoundError
|
|
127
|
+
|
|
128
|
+
expect(formatServerError(error, language.t)).toBe(
|
|
129
|
+
["Modelo nao encontrado: x/y", "Voce quis dizer: x/y2, x/y3", "Revise provider/model no config"].join("\n"),
|
|
130
|
+
)
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
test("unwraps SDK-wrapped errors from cause.body", () => {
|
|
134
|
+
const body = {
|
|
135
|
+
name: "ConfigInvalidError",
|
|
136
|
+
data: {
|
|
137
|
+
message: "Missing host",
|
|
138
|
+
},
|
|
139
|
+
} satisfies ConfigInvalidError
|
|
140
|
+
|
|
141
|
+
const wrapped = new Error("ConfigInvalidError", { cause: { body, status: 400 } })
|
|
142
|
+
|
|
143
|
+
expect(formatServerError(wrapped, language.t)).toBe("Arquivo de config em config invalido: Missing host")
|
|
144
|
+
})
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
describe("isSessionNotFoundError", () => {
|
|
148
|
+
test("matches an SDK-wrapped error for the requested session", () => {
|
|
149
|
+
const body = {
|
|
150
|
+
_tag: "SessionNotFoundError",
|
|
151
|
+
sessionID: "ses_missing",
|
|
152
|
+
message: "Session not found",
|
|
153
|
+
} satisfies SessionNotFoundError
|
|
154
|
+
|
|
155
|
+
expect(isSessionNotFoundError(new Error(body.message, { cause: { body, status: 404 } }), body.sessionID)).toBe(true)
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
test("rejects errors for other sessions and other 404 responses", () => {
|
|
159
|
+
const body = {
|
|
160
|
+
_tag: "SessionNotFoundError",
|
|
161
|
+
sessionID: "ses_parent",
|
|
162
|
+
message: "Session not found",
|
|
163
|
+
} satisfies SessionNotFoundError
|
|
164
|
+
|
|
165
|
+
expect(isSessionNotFoundError(new Error(body.message, { cause: { body, status: 404 } }), "ses_tab")).toBe(false)
|
|
166
|
+
expect(
|
|
167
|
+
isSessionNotFoundError(
|
|
168
|
+
new Error("Provider not found", {
|
|
169
|
+
cause: { body: { _tag: "ProviderNotFoundError", providerID: "missing" }, status: 404 },
|
|
170
|
+
}),
|
|
171
|
+
"ses_tab",
|
|
172
|
+
),
|
|
173
|
+
).toBe(false)
|
|
174
|
+
})
|
|
175
|
+
})
|