@zyro-sec/app 0.0.0-stage → 1.0.0
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 +234 -0
- package/README.md +106 -2
- package/bunfig.toml +3 -0
- package/component-tests/activity-chips.spec.ts +47 -0
- package/component-tests/browser-pane-restore.spec.ts +1294 -0
- package/component-tests/browser-pane.spec.ts +2338 -0
- package/component-tests/browser-settings.spec.ts +315 -0
- package/component-tests/browser-site-chooser.spec.ts +628 -0
- package/component-tests/components-lab.spec.ts +24 -0
- package/component-tests/composer.spec.ts +876 -0
- package/component-tests/debug-bar.spec.ts +237 -0
- package/component-tests/dialog-popups.spec.ts +49 -0
- package/component-tests/file-icon.spec.ts +14 -0
- package/component-tests/focus-rescue.fixture.tsx +30 -0
- package/component-tests/focus-rescue.spec.ts +83 -0
- package/component-tests/focus-ring.spec.ts +112 -0
- package/component-tests/fork-dialog.spec.ts +61 -0
- package/component-tests/grow.fixture.tsx +42 -0
- package/component-tests/grow.spec.ts +74 -0
- package/component-tests/image-preview.spec.ts +157 -0
- package/component-tests/input-surfaces.spec.ts +351 -0
- package/component-tests/line-comment.spec.ts +118 -0
- package/component-tests/list.spec.ts +7 -0
- package/component-tests/model-picker.spec.ts +45 -0
- package/component-tests/new-session-wordmark.spec.ts +135 -0
- package/component-tests/open-in-border.spec.ts +18 -0
- package/component-tests/pairing.spec.ts +40 -0
- package/component-tests/panel-sidebar-side.spec.ts +103 -0
- package/component-tests/plugin-graph.spec.ts +61 -0
- package/component-tests/plugin-host.fixture.tsx +995 -0
- package/component-tests/plugin-host.spec.ts +2362 -0
- package/component-tests/presence.fixture.tsx +59 -0
- package/component-tests/presence.spec.ts +104 -0
- package/component-tests/session-containment.fixture.tsx +79 -0
- package/component-tests/session-containment.spec.ts +145 -0
- package/component-tests/session-location-missing.spec.ts +52 -0
- package/component-tests/session-question-dock.spec.ts +1655 -0
- package/component-tests/sources-experiment.spec.ts +98 -0
- package/component-tests/ssh-reconnect.spec.ts +97 -0
- package/component-tests/subagent-bar.spec.ts +29 -0
- package/component-tests/terminal.spec.ts +148 -0
- package/component-tests/timeline-detail.spec.ts +311 -0
- package/component-tests/timeline-virtualizer.fixture.tsx +272 -0
- package/component-tests/timeline-virtualizer.spec.ts +269 -0
- package/component-tests/toast.spec.ts +23 -0
- package/component-tests/tooltip.spec.ts +169 -0
- package/component-tests/websearch.spec.ts +86 -0
- package/e2e/AGENTS.md +25 -0
- package/e2e/QUARANTINE.md +12 -0
- package/e2e/regression/background-read-failure.spec.ts +43 -0
- package/e2e/regression/btw-sidebar.spec.ts +339 -0
- package/e2e/regression/command-palette.spec.ts +822 -0
- package/e2e/regression/composer.spec.ts +1727 -0
- package/e2e/regression/directory-picker.spec.ts +133 -0
- package/e2e/regression/home.spec.ts +779 -0
- package/e2e/regression/mcp-workspace-toggle.spec.ts +695 -0
- package/e2e/regression/menu-scrollbars.spec.ts +78 -0
- package/e2e/regression/mobile-composer-submit-focus.spec.ts +88 -0
- package/e2e/regression/mobile-model-pickers.spec.ts +433 -0
- package/e2e/regression/mobile-plugin-drawers.spec.ts +194 -0
- package/e2e/regression/mobile-plugins.spec.ts +309 -0
- package/e2e/regression/mobile-session-options.spec.ts +101 -0
- package/e2e/regression/mobile-session.spec.ts +442 -0
- package/e2e/regression/mobile-timeline-scroll.spec.ts +919 -0
- package/e2e/regression/multi-server.spec.ts +498 -0
- package/e2e/regression/new-session.spec.ts +1666 -0
- package/e2e/regression/panel-edges.spec.ts +79 -0
- package/e2e/regression/patch-border.spec.ts +69 -0
- package/e2e/regression/patch-sticky-header.spec.ts +320 -0
- package/e2e/regression/review.spec.ts +2397 -0
- package/e2e/regression/session-header.spec.ts +1020 -0
- package/e2e/regression/session-location-sync.spec.ts +412 -0
- package/e2e/regression/session-notice-truncation.spec.ts +92 -0
- package/e2e/regression/session-panel-scrollbar.spec.ts +46 -0
- package/e2e/regression/session-queue.spec.ts +1704 -0
- package/e2e/regression/session-request-docks.spec.ts +719 -0
- package/e2e/regression/session-summary.spec.ts +1092 -0
- package/e2e/regression/session-timeline-accessibility.spec.ts +216 -0
- package/e2e/regression/session-timeline-locale-projection.spec.ts +24 -0
- package/e2e/regression/session-timeline-reducer-projection.spec.ts +53 -0
- package/e2e/regression/session-timeline-tool-projection.spec.ts +94 -0
- package/e2e/regression/session-websearch-dock.spec.ts +122 -0
- package/e2e/regression/settings-search.spec.ts +516 -0
- package/e2e/regression/settings-wsl.spec.ts +433 -0
- package/e2e/regression/settings.spec.ts +2901 -0
- package/e2e/regression/shell-panel-spacing.spec.ts +95 -0
- package/e2e/regression/side-panels.spec.ts +524 -0
- package/e2e/regression/subagent-child-navigation.spec.ts +540 -0
- package/e2e/regression/tabs.spec.ts +3294 -0
- package/e2e/regression/terminal.spec.ts +691 -0
- package/e2e/regression/timeline-cache.spec.ts +798 -0
- package/e2e/regression/timeline-geometry.spec.ts +1204 -0
- package/e2e/regression/timeline-history.spec.ts +1073 -0
- package/e2e/regression/timeline-stream.spec.ts +3409 -0
- package/e2e/regression/whats-new.spec.ts +242 -0
- package/e2e/reproduction/timeline-suspense/index.html +34 -0
- package/e2e/reproduction/timeline-suspense/main.tsx +335 -0
- package/e2e/reproduction/timeline-suspense/playwright.config.ts +34 -0
- package/e2e/reproduction/timeline-suspense/timeline-suspense.repro.ts +182 -0
- package/e2e/reproduction/timeline-suspense/vite.config.ts +7 -0
- package/e2e/screenshots/session-project-menu.png +0 -0
- package/e2e/service-worker/cache.spec.ts +573 -0
- package/e2e/service-worker/playwright.config.ts +14 -0
- package/e2e/stability/README.md +61 -0
- package/e2e/stability/adverse.spec.ts +279 -0
- package/e2e/stability/environment-matrix.spec.ts +128 -0
- package/e2e/stability/file-matrix.spec.ts +133 -0
- package/e2e/stability/file-mutation.spec.ts +126 -0
- package/e2e/stability/fixture.test.ts +80 -0
- package/e2e/stability/interaction.spec.ts +232 -0
- package/e2e/stability/lifecycle.spec.ts +175 -0
- package/e2e/stability/oracle-browser.spec.ts +81 -0
- package/e2e/stability/oracle.test.ts +388 -0
- package/e2e/stability/playwright.config.ts +31 -0
- package/e2e/stability/scroll-interaction.spec.ts +520 -0
- package/e2e/stability/shell-matrix.spec.ts +299 -0
- package/e2e/stability/tool-mutation.spec.ts +58 -0
- package/e2e/stability/tools.spec.ts +232 -0
- package/e2e/stability/transition-matrix.spec.ts +214 -0
- package/e2e/tsconfig.json +11 -0
- package/e2e/user-story/model-selection-flow.spec.ts +216 -0
- package/e2e/utils/app-direction.fixture.tsx +105 -0
- package/e2e/utils/app-direction.html +25 -0
- package/e2e/utils/app.ts +227 -0
- package/e2e/utils/command-palette.ts +62 -0
- package/e2e/utils/console.ts +23 -0
- package/e2e/utils/direction.ts +28 -0
- package/e2e/utils/drafts.ts +52 -0
- package/e2e/utils/errors.ts +14 -0
- package/e2e/utils/markdown-sessions.ts +120 -0
- package/e2e/utils/mock-api.ts +570 -0
- package/e2e/utils/mock-server.ts +1726 -0
- package/e2e/utils/notifications.ts +51 -0
- package/e2e/utils/persistent-pty.ts +546 -0
- package/e2e/utils/prompt-motion.ts +116 -0
- package/e2e/utils/serve.ts +65 -0
- package/e2e/utils/session-fixture.ts +472 -0
- package/e2e/utils/settings-wsl.fixture.tsx +416 -0
- package/e2e/utils/settings-wsl.html +27 -0
- package/e2e/utils/side-panel.ts +41 -0
- package/e2e/utils/sse-transport.ts +352 -0
- package/e2e/utils/terminal.ts +31 -0
- package/e2e/utils/timeline.ts +1141 -0
- package/e2e/utils/visual-stability/analyzer.ts +259 -0
- package/e2e/utils/visual-stability/capture.ts +57 -0
- package/e2e/utils/visual-stability/index.ts +15 -0
- package/e2e/utils/visual-stability/invariant.ts +113 -0
- package/e2e/utils/visual-stability/model.ts +47 -0
- package/e2e/utils/visual-stability/probe.ts +261 -0
- package/e2e/utils/visual-stability/regions.ts +18 -0
- package/e2e/utils/visual-stability/reporter.ts +71 -0
- package/e2e/utils/visual-stability/scenario.ts +21 -0
- package/e2e/utils/visual-stability.ts +52 -0
- package/e2e/utils/waits.ts +25 -0
- package/e2e/utils/windows-menu.fixture.tsx +99 -0
- package/e2e/utils/windows-menu.html +22 -0
- package/e2e/utils/workspace.ts +222 -0
- package/happydom.ts +77 -0
- package/index.html +29 -0
- package/manifest.json +36 -0
- package/package.json +91 -4
- package/perf/README.md +190 -0
- package/perf/composer.bench.ts +107 -0
- package/perf/desktop.bench.ts +22 -0
- package/perf/diff.bench.ts +104 -0
- package/perf/docks.bench.ts +109 -0
- package/perf/fixtures/composer.ts +166 -0
- package/perf/fixtures/diffs.ts +165 -0
- package/perf/fixtures/drag.ts +73 -0
- package/perf/fixtures/events.ts +106 -0
- package/perf/fixtures/home.ts +274 -0
- package/perf/fixtures/mock.ts +118 -0
- package/perf/fixtures/review.ts +33 -0
- package/perf/fixtures/scripts.ts +37 -0
- package/perf/fixtures/storage.ts +29 -0
- package/perf/fixtures/tabs.ts +21 -0
- package/perf/fixtures/timeline.ts +458 -0
- package/perf/home.bench.ts +74 -0
- package/perf/model-picker.bench.ts +168 -0
- package/perf/navigation.bench.ts +310 -0
- package/perf/question.bench.ts +85 -0
- package/perf/review.bench.ts +109 -0
- package/perf/send.bench.ts +54 -0
- package/perf/stream.bench.ts +108 -0
- package/perf/subagent-pill.bench.ts +348 -0
- package/perf/tabs.bench.ts +229 -0
- package/perf/timeline.bench.ts +167 -0
- package/playwright.components.config.ts +7 -0
- package/playwright.config.ts +85 -0
- package/public/_headers +28 -0
- package/public/assets/Inter.ttf +0 -0
- package/public/assets/JetBrainsMonoNerdFontMono-Bold.woff2 +0 -0
- package/public/assets/JetBrainsMonoNerdFontMono-Regular.woff2 +0 -0
- package/public/oc-theme-preload.js +33 -0
- package/src/app.tsx +142 -0
- package/src/components-lab/browser.tsx +745 -0
- package/src/components-lab/catalog.test.ts +58 -0
- package/src/components-lab/catalog.ts +195 -0
- package/src/components-lab/dialog-story-runtime.tsx +840 -0
- package/src/components-lab/focus-rings.stories.tsx +710 -0
- package/src/components-lab/focus-visibility.stories.tsx +2669 -0
- package/src/components-lab/force-focus.ts +52 -0
- package/src/components-lab/inspector.css +28 -0
- package/src/components-lab/lab.tsx +114 -0
- package/src/components-lab/machine.test.ts +177 -0
- package/src/components-lab/machine.ts +229 -0
- package/src/components-lab/motion.test.ts +17 -0
- package/src/components-lab/motion.ts +100 -0
- package/src/composer/adapter.ts +151 -0
- package/src/composer/attachments/attachments.css +123 -0
- package/src/composer/attachments/attachments.ts +363 -0
- package/src/composer/attachments/destination.ts +81 -0
- package/src/composer/attachments/upload-machine.ts +185 -0
- package/src/composer/attachments/uploads.test.ts +127 -0
- package/src/composer/attachments/uploads.tsx +228 -0
- package/src/composer/client-slash-command.test.ts +20 -0
- package/src/composer/client-slash-command.ts +28 -0
- package/src/composer/commands.tsx +175 -0
- package/src/composer/comment-focus-machine.test.ts +112 -0
- package/src/composer/comment-focus-machine.ts +141 -0
- package/src/composer/comment-note.test.ts +82 -0
- package/src/composer/comment-note.ts +127 -0
- package/src/composer/comments.test.ts +109 -0
- package/src/composer/comments.tsx +279 -0
- package/src/composer/composer-touch.stories.tsx +298 -0
- package/src/composer/composer.stories.tsx +765 -0
- package/src/composer/composer.tsx +244 -0
- package/src/composer/dropzone.tsx +92 -0
- package/src/composer/editor/actions.test.ts +176 -0
- package/src/composer/editor/actions.ts +191 -0
- package/src/composer/editor/dom.test.ts +168 -0
- package/src/composer/editor/dom.ts +274 -0
- package/src/composer/editor/editor.css +101 -0
- package/src/composer/editor/editor.tsx +1764 -0
- package/src/composer/editor/interaction.test.ts +13 -0
- package/src/composer/editor/interaction.ts +838 -0
- package/src/composer/editor/machine.test.ts +47 -0
- package/src/composer/editor/machine.ts +63 -0
- package/src/composer/editor/mention-search-machine.test.ts +111 -0
- package/src/composer/editor/mention-search-machine.ts +226 -0
- package/src/composer/editor/quote-comment.stories.tsx +133 -0
- package/src/composer/editor/quote-comment.tsx +191 -0
- package/src/composer/history/entry.test.ts +100 -0
- package/src/composer/history/entry.ts +140 -0
- package/src/composer/history/store.ts +83 -0
- package/src/composer/machine.test.ts +459 -0
- package/src/composer/machine.ts +561 -0
- package/src/composer/media.ts +18 -0
- package/src/composer/model-chip-machine.test.ts +96 -0
- package/src/composer/model-chip-machine.ts +82 -0
- package/src/composer/model-label.test.ts +177 -0
- package/src/composer/model-label.ts +120 -0
- package/src/composer/model.ts +683 -0
- package/src/composer/persistence.tsx +163 -0
- package/src/composer/prompt-parts.ts +52 -0
- package/src/composer/prompt-status-machine.test.ts +76 -0
- package/src/composer/prompt-status-machine.ts +48 -0
- package/src/composer/prompt.test.ts +320 -0
- package/src/composer/prompt.ts +334 -0
- package/src/composer/quote-comment-machine.test.ts +154 -0
- package/src/composer/quote-comment-machine.ts +211 -0
- package/src/composer/quote-position.ts +32 -0
- package/src/composer/quote-source.ts +48 -0
- package/src/composer/reload-machine.ts +51 -0
- package/src/composer/request.test.ts +360 -0
- package/src/composer/request.ts +245 -0
- package/src/composer/retry.test.ts +107 -0
- package/src/composer/retry.ts +63 -0
- package/src/composer/schema.test.ts +317 -0
- package/src/composer/schema.ts +424 -0
- package/src/composer/selection.ts +354 -0
- package/src/composer/session-match.test.ts +20 -0
- package/src/composer/session-match.ts +18 -0
- package/src/composer/state.ts +271 -0
- package/src/composer/submission-state.ts +3 -0
- package/src/composer/submit.test.ts +1785 -0
- package/src/composer/submit.ts +1073 -0
- package/src/composer/suggestions/machine.test.ts +420 -0
- package/src/composer/suggestions/machine.ts +573 -0
- package/src/composer/types.ts +60 -0
- package/src/desktop.ts +25 -0
- package/src/entry.tsx +119 -0
- package/src/env.d.ts +41 -0
- package/src/home/home.standalone.stories.tsx +260 -0
- package/src/home/machine.test.ts +286 -0
- package/src/home/machine.ts +344 -0
- package/src/home/model.ts +162 -0
- package/src/home/projects/actions.tsx +189 -0
- package/src/home/projects/add.ts +10 -0
- package/src/home/projects/browse-view.tsx +264 -0
- package/src/home/projects/browse.tsx +33 -0
- package/src/home/projects/controller.tsx +109 -0
- package/src/home/projects/file-manager.ts +26 -0
- package/src/home/projects/import-machine.test.ts +117 -0
- package/src/home/projects/import-machine.ts +133 -0
- package/src/home/projects/landing.tsx +77 -0
- package/src/home/projects/menu.tsx +70 -0
- package/src/home/projects/region.tsx +63 -0
- package/src/home/projects/reveal.ts +39 -0
- package/src/home/projects/start.ts +114 -0
- package/src/home/projects/view.css +79 -0
- package/src/home/projects/view.tsx +763 -0
- package/src/home/route.tsx +177 -0
- package/src/home/scroll.ts +180 -0
- package/src/home/sessions/alt-hold.test.ts +45 -0
- package/src/home/sessions/alt-hold.ts +20 -0
- package/src/home/sessions/archive.test.ts +51 -0
- package/src/home/sessions/archive.ts +25 -0
- package/src/home/sessions/controller.tsx +669 -0
- package/src/home/sessions/delete-dialog.stories.tsx +70 -0
- package/src/home/sessions/index.test.ts +171 -0
- package/src/home/sessions/index.ts +60 -0
- package/src/home/sessions/load-machine.test.ts +223 -0
- package/src/home/sessions/load-machine.ts +430 -0
- package/src/home/sessions/open.test.ts +16 -0
- package/src/home/sessions/open.ts +18 -0
- package/src/home/sessions/queries.ts +95 -0
- package/src/home/sessions/records.test.ts +85 -0
- package/src/home/sessions/records.ts +58 -0
- package/src/home/sessions/region.tsx +66 -0
- package/src/home/sessions/row-machine.test.ts +203 -0
- package/src/home/sessions/row-machine.ts +365 -0
- package/src/home/sessions/search-machine.test.ts +117 -0
- package/src/home/sessions/search-machine.ts +181 -0
- package/src/home/sessions/search.ts +218 -0
- package/src/home/sessions/view.css +101 -0
- package/src/home/sessions/view.tsx +1123 -0
- package/src/home/start/command-palette.tsx +88 -0
- package/src/index.css +419 -0
- package/src/index.ts +5 -0
- package/src/new-session/brick-breaker-machine.test.ts +120 -0
- package/src/new-session/brick-breaker-machine.ts +110 -0
- package/src/new-session/brick-breaker.tsx +551 -0
- package/src/new-session/commands.tsx +61 -0
- package/src/new-session/composer-adapter.ts +309 -0
- package/src/new-session/draft.standalone.stories.tsx +214 -0
- package/src/new-session/layout.ts +2 -0
- package/src/new-session/location/dialog.css +204 -0
- package/src/new-session/location/dialog.standalone.stories.tsx +122 -0
- package/src/new-session/location/dialog.tsx +677 -0
- package/src/new-session/location/machine.test.ts +180 -0
- package/src/new-session/location/machine.ts +239 -0
- package/src/new-session/machine.test.ts +344 -0
- package/src/new-session/machine.ts +293 -0
- package/src/new-session/mcp.ts +132 -0
- package/src/new-session/pin-board-machine.test.ts +116 -0
- package/src/new-session/pin-board-machine.ts +188 -0
- package/src/new-session/pin-board.tsx +1072 -0
- package/src/new-session/pin-quads.ts +252 -0
- package/src/new-session/pin-sound.ts +193 -0
- package/src/new-session/project/controller.ts +111 -0
- package/src/new-session/project/selector.test.tsx +101 -0
- package/src/new-session/project/selector.tsx +108 -0
- package/src/new-session/route.tsx +115 -0
- package/src/new-session/screen.tsx +107 -0
- package/src/new-session/view.tsx +424 -0
- package/src/new-session/wordmark-machine.test.ts +236 -0
- package/src/new-session/wordmark-machine.ts +237 -0
- package/src/new-session/wordmark.css +71 -0
- package/src/new-session/wordmark.stories.tsx +109 -0
- package/src/new-session/wordmark.tsx +1222 -0
- package/src/new-session/workspace/branch-machine.test.ts +243 -0
- package/src/new-session/workspace/branch-machine.ts +233 -0
- package/src/new-session/workspace/checkout-machine.test.ts +73 -0
- package/src/new-session/workspace/checkout-machine.ts +69 -0
- package/src/new-session/workspace/controller.test.ts +82 -0
- package/src/new-session/workspace/controller.ts +291 -0
- package/src/new-session/workspace/selector.tsx +230 -0
- package/src/providers/catalog/console-settle.ts +80 -0
- package/src/providers/catalog/console.test.ts +21 -0
- package/src/providers/catalog/console.ts +37 -0
- package/src/providers/catalog/integrations.ts +30 -0
- package/src/providers/catalog/order.ts +10 -0
- package/src/providers/catalog/plugin.ts +15 -0
- package/src/providers/catalog/providers.ts +111 -0
- package/src/providers/catalog/settle-machine.test.ts +123 -0
- package/src/providers/catalog/settle-machine.ts +109 -0
- package/src/providers/connect/chatgpt-usage-limit.stories.tsx +25 -0
- package/src/providers/connect/chatgpt-usage-limit.tsx +83 -0
- package/src/providers/connect/chatgpt-welcome.stories.tsx +23 -0
- package/src/providers/connect/chatgpt-welcome.tsx +37 -0
- package/src/providers/connect/console.tsx +67 -0
- package/src/providers/connect/controller.ts +672 -0
- package/src/providers/connect/dialog-machine.test.ts +654 -0
- package/src/providers/connect/dialog-machine.ts +875 -0
- package/src/providers/connect/dialog.standalone.stories.tsx +187 -0
- package/src/providers/connect/dialog.tsx +1564 -0
- package/src/providers/connect/form-machine.test.ts +200 -0
- package/src/providers/connect/form-machine.ts +419 -0
- package/src/providers/connect/go-upsell-hero-art.test.ts +194 -0
- package/src/providers/connect/go-upsell-hero-art.ts +749 -0
- package/src/providers/connect/go-upsell-hero-machine.test.ts +88 -0
- package/src/providers/connect/go-upsell-hero-machine.ts +68 -0
- package/src/providers/connect/go-upsell-hero.tsx +17 -0
- package/src/providers/connect/machine.test.ts +513 -0
- package/src/providers/connect/machine.ts +644 -0
- package/src/providers/connect/mcp-dialog.stories.tsx +89 -0
- package/src/providers/connect/mcp-dialog.tsx +316 -0
- package/src/providers/connect/mcp-machine.test.ts +239 -0
- package/src/providers/connect/mcp-machine.ts +328 -0
- package/src/providers/connect/mcp-sign-in.tsx +112 -0
- package/src/providers/connect/mcp.tsx +298 -0
- package/src/providers/connect/models.css +71 -0
- package/src/providers/connect/remote.test.ts +50 -0
- package/src/providers/connect/remote.tsx +10 -0
- package/src/providers/connect/step-actions.tsx +18 -0
- package/src/providers/connect/tip.tsx +110 -0
- package/src/providers/connect/usage-exceeded.tsx +62 -0
- package/src/providers/custom-managed-provider.svg +31 -0
- package/src/providers/models/agent.test.ts +25 -0
- package/src/providers/models/agent.ts +7 -0
- package/src/providers/models/configured.ts +33 -0
- package/src/providers/models/details.tsx +168 -0
- package/src/providers/models/manage.css +97 -0
- package/src/providers/models/manage.standalone.stories.tsx +59 -0
- package/src/providers/models/manage.tsx +170 -0
- package/src/providers/models/models.test.ts +55 -0
- package/src/providers/models/models.tsx +279 -0
- package/src/providers/models/provider-group.tsx +293 -0
- package/src/providers/models/search.test.ts +13 -0
- package/src/providers/models/search.ts +20 -0
- package/src/providers/models/select-dialog-machine.test.ts +455 -0
- package/src/providers/models/select-dialog-machine.ts +702 -0
- package/src/providers/models/select-dialog.css +240 -0
- package/src/providers/models/select-dialog.standalone.stories.tsx +225 -0
- package/src/providers/models/select-dialog.tsx +1359 -0
- package/src/providers/models/selection-machine.test.ts +290 -0
- package/src/providers/models/selection-machine.ts +408 -0
- package/src/providers/models/selection.tsx +787 -0
- package/src/providers/models/speed.test.ts +17 -0
- package/src/providers/models/speed.ts +17 -0
- package/src/providers/models/tooltip.tsx +152 -0
- package/src/providers/models/unpaid.standalone.stories.tsx +76 -0
- package/src/providers/models/unpaid.tsx +199 -0
- package/src/providers/models/variant.test.ts +79 -0
- package/src/providers/models/variant.ts +74 -0
- package/src/providers/opencode-logo.tsx +17 -0
- package/src/runtime/animated-presence.ts +66 -0
- package/src/runtime/array-move.test.ts +19 -0
- package/src/runtime/array-move.ts +8 -0
- package/src/runtime/i18n/am.ts +1409 -0
- package/src/runtime/i18n/ar.ts +1560 -0
- package/src/runtime/i18n/az.ts +1481 -0
- package/src/runtime/i18n/bg.ts +1491 -0
- package/src/runtime/i18n/bn.ts +1477 -0
- package/src/runtime/i18n/br.ts +1527 -0
- package/src/runtime/i18n/bs.ts +1561 -0
- package/src/runtime/i18n/ca.ts +1523 -0
- package/src/runtime/i18n/cs.ts +1520 -0
- package/src/runtime/i18n/da.ts +1527 -0
- package/src/runtime/i18n/de.ts +1517 -0
- package/src/runtime/i18n/desktop-native.test.ts +84 -0
- package/src/runtime/i18n/desktop-native.ts +366 -0
- package/src/runtime/i18n/dv.ts +1519 -0
- package/src/runtime/i18n/dz.ts +1504 -0
- package/src/runtime/i18n/el.ts +1509 -0
- package/src/runtime/i18n/en.ts +1560 -0
- package/src/runtime/i18n/es.ts +1583 -0
- package/src/runtime/i18n/et.ts +1456 -0
- package/src/runtime/i18n/fa.ts +1470 -0
- package/src/runtime/i18n/fi.ts +1472 -0
- package/src/runtime/i18n/fo.ts +1469 -0
- package/src/runtime/i18n/fr.ts +1543 -0
- package/src/runtime/i18n/he.ts +1455 -0
- package/src/runtime/i18n/hi.ts +1475 -0
- package/src/runtime/i18n/hr.ts +1506 -0
- package/src/runtime/i18n/hu.ts +1492 -0
- package/src/runtime/i18n/hy.ts +1478 -0
- package/src/runtime/i18n/id.ts +1541 -0
- package/src/runtime/i18n/is.ts +1468 -0
- package/src/runtime/i18n/it.ts +1517 -0
- package/src/runtime/i18n/ja.ts +1484 -0
- package/src/runtime/i18n/ka.ts +1476 -0
- package/src/runtime/i18n/km.ts +1461 -0
- package/src/runtime/i18n/ko.ts +1469 -0
- package/src/runtime/i18n/language.test.ts +35 -0
- package/src/runtime/i18n/language.tsx +468 -0
- package/src/runtime/i18n/lo.ts +1454 -0
- package/src/runtime/i18n/lt.ts +1529 -0
- package/src/runtime/i18n/lv.ts +1509 -0
- package/src/runtime/i18n/machine.test.ts +148 -0
- package/src/runtime/i18n/machine.ts +164 -0
- package/src/runtime/i18n/mk.ts +1488 -0
- package/src/runtime/i18n/mn.ts +1485 -0
- package/src/runtime/i18n/ms.ts +1480 -0
- package/src/runtime/i18n/my.ts +1489 -0
- package/src/runtime/i18n/ne.ts +1478 -0
- package/src/runtime/i18n/nl.ts +1491 -0
- package/src/runtime/i18n/no.ts +1536 -0
- package/src/runtime/i18n/pa.ts +1478 -0
- package/src/runtime/i18n/pl.ts +1540 -0
- package/src/runtime/i18n/ro.ts +1511 -0
- package/src/runtime/i18n/ru.ts +1596 -0
- package/src/runtime/i18n/si.ts +1477 -0
- package/src/runtime/i18n/sk.ts +1526 -0
- package/src/runtime/i18n/sl.ts +1527 -0
- package/src/runtime/i18n/sq.ts +1480 -0
- package/src/runtime/i18n/sr.ts +1502 -0
- package/src/runtime/i18n/sv.ts +1478 -0
- package/src/runtime/i18n/tg.ts +1493 -0
- package/src/runtime/i18n/th.ts +1505 -0
- package/src/runtime/i18n/tk.ts +1472 -0
- package/src/runtime/i18n/tr.ts +1550 -0
- package/src/runtime/i18n/uk.ts +1598 -0
- package/src/runtime/i18n/ur.ts +1488 -0
- package/src/runtime/i18n/uz.ts +1490 -0
- package/src/runtime/i18n/vi.ts +1473 -0
- package/src/runtime/i18n/zh.ts +1474 -0
- package/src/runtime/i18n/zht.ts +1468 -0
- package/src/runtime/persistence/README.md +151 -0
- package/src/runtime/persistence/base64.ts +11 -0
- package/src/runtime/persistence/consumers.test.ts +168 -0
- package/src/runtime/persistence/drafts-machine.test.ts +214 -0
- package/src/runtime/persistence/drafts-machine.ts +385 -0
- package/src/runtime/persistence/drafts.test.ts +515 -0
- package/src/runtime/persistence/drafts.ts +687 -0
- package/src/runtime/persistence/equality.ts +9 -0
- package/src/runtime/persistence/namespace-machine.test.ts +232 -0
- package/src/runtime/persistence/namespace-machine.ts +304 -0
- package/src/runtime/persistence/namespace.test.ts +304 -0
- package/src/runtime/persistence/namespace.ts +126 -0
- package/src/runtime/persistence/persist-machine.test.ts +185 -0
- package/src/runtime/persistence/persist-machine.ts +192 -0
- package/src/runtime/persistence/persist.test.ts +243 -0
- package/src/runtime/persistence/persist.ts +159 -0
- package/src/runtime/persistence/schema.test.ts +208 -0
- package/src/runtime/persistence/schema.ts +130 -0
- package/src/runtime/persistence/storage-machine.test.ts +61 -0
- package/src/runtime/persistence/storage-machine.ts +57 -0
- package/src/runtime/persistence/storage.test.ts +70 -0
- package/src/runtime/persistence/storage.ts +707 -0
- package/src/runtime/platform/base-path-router.tsx +66 -0
- package/src/runtime/platform/base-path.test.ts +50 -0
- package/src/runtime/platform/base-path.ts +28 -0
- package/src/runtime/platform/drag-out.test.ts +58 -0
- package/src/runtime/platform/drag-out.ts +53 -0
- package/src/runtime/platform/external-link.tsx +21 -0
- package/src/runtime/platform/keyboard.ts +41 -0
- package/src/runtime/platform/platform.tsx +185 -0
- package/src/runtime/platform/pwa.ts +50 -0
- package/src/runtime/platform/web.ts +63 -0
- package/src/runtime/plugin/app-links.test.ts +17 -0
- package/src/runtime/plugin/app-links.ts +88 -0
- package/src/runtime/plugin/attach-machine.test.ts +174 -0
- package/src/runtime/plugin/attach-machine.ts +152 -0
- package/src/runtime/plugin/attachment.ts +15 -0
- package/src/runtime/plugin/builtins.ts +15 -0
- package/src/runtime/plugin/closed-tabs-view.tsx +315 -0
- package/src/runtime/plugin/closed-tabs.test.ts +82 -0
- package/src/runtime/plugin/closed-tabs.ts +196 -0
- package/src/runtime/plugin/commands.test.ts +23 -0
- package/src/runtime/plugin/commands.tsx +86 -0
- package/src/runtime/plugin/composer-write-machine.test.ts +151 -0
- package/src/runtime/plugin/composer-write-machine.ts +111 -0
- package/src/runtime/plugin/deferred-menu-machine.test.ts +127 -0
- package/src/runtime/plugin/deferred-menu-machine.ts +163 -0
- package/src/runtime/plugin/dialog-machine.test.ts +62 -0
- package/src/runtime/plugin/dialog-machine.ts +81 -0
- package/src/runtime/plugin/dialogs.stories.tsx +66 -0
- package/src/runtime/plugin/dialogs.tsx +177 -0
- package/src/runtime/plugin/embed-flight-machine.test.ts +350 -0
- package/src/runtime/plugin/embed-flight-machine.ts +468 -0
- package/src/runtime/plugin/embed-geometry.test.ts +18 -0
- package/src/runtime/plugin/embed-geometry.ts +19 -0
- package/src/runtime/plugin/embed-snapshot-machine.test.ts +242 -0
- package/src/runtime/plugin/embed-snapshot-machine.ts +267 -0
- package/src/runtime/plugin/embeds.tsx +773 -0
- package/src/runtime/plugin/extension-plugins.tsx +299 -0
- package/src/runtime/plugin/hmr.tsx +33 -0
- package/src/runtime/plugin/host-apis.tsx +1315 -0
- package/src/runtime/plugin/host-layout-machine.test.ts +214 -0
- package/src/runtime/plugin/host-layout-machine.ts +269 -0
- package/src/runtime/plugin/host.tsx +1106 -0
- package/src/runtime/plugin/instance-machine.test.ts +387 -0
- package/src/runtime/plugin/instance-machine.ts +409 -0
- package/src/runtime/plugin/ipc-machine.test.ts +172 -0
- package/src/runtime/plugin/ipc-machine.ts +213 -0
- package/src/runtime/plugin/ipc.test.ts +166 -0
- package/src/runtime/plugin/ipc.ts +220 -0
- package/src/runtime/plugin/link-check-machine.test.ts +115 -0
- package/src/runtime/plugin/link-check-machine.ts +142 -0
- package/src/runtime/plugin/link-check.ts +82 -0
- package/src/runtime/plugin/located-machine.test.ts +124 -0
- package/src/runtime/plugin/located-machine.ts +125 -0
- package/src/runtime/plugin/located.ts +82 -0
- package/src/runtime/plugin/machine.test.ts +222 -0
- package/src/runtime/plugin/machine.ts +318 -0
- package/src/runtime/plugin/menubar-items.ts +28 -0
- package/src/runtime/plugin/mobile.tsx +199 -0
- package/src/runtime/plugin/module.test.ts +57 -0
- package/src/runtime/plugin/module.ts +64 -0
- package/src/runtime/plugin/mounted-session.ts +420 -0
- package/src/runtime/plugin/new-tab-machine.test.ts +207 -0
- package/src/runtime/plugin/new-tab-machine.ts +240 -0
- package/src/runtime/plugin/pane-drag-machine.test.ts +217 -0
- package/src/runtime/plugin/pane-drag-machine.ts +263 -0
- package/src/runtime/plugin/pane-drag.tsx +290 -0
- package/src/runtime/plugin/panel-keys.ts +15 -0
- package/src/runtime/plugin/panel-menu.ts +29 -0
- package/src/runtime/plugin/panel-trigger.tsx +180 -0
- package/src/runtime/plugin/panels.tsx +733 -0
- package/src/runtime/plugin/plugin-gui-machine.test.ts +186 -0
- package/src/runtime/plugin/plugin-gui-machine.ts +178 -0
- package/src/runtime/plugin/plugins.tsx +137 -0
- package/src/runtime/plugin/prompt-gate.test.ts +113 -0
- package/src/runtime/plugin/prompt-gate.ts +36 -0
- package/src/runtime/plugin/render.tsx +348 -0
- package/src/runtime/plugin/root.tsx +141 -0
- package/src/runtime/plugin/server-shell.tsx +113 -0
- package/src/runtime/plugin/servers.tsx +270 -0
- package/src/runtime/plugin/session-store-machine.test.ts +82 -0
- package/src/runtime/plugin/session-store-machine.ts +140 -0
- package/src/runtime/plugin/settings-page-view.tsx +53 -0
- package/src/runtime/plugin/settings-pages.ts +23 -0
- package/src/runtime/plugin/side-region.tsx +635 -0
- package/src/runtime/plugin/startup.ts +107 -0
- package/src/runtime/plugin/store-machine.test.ts +69 -0
- package/src/runtime/plugin/store-machine.ts +139 -0
- package/src/runtime/plugin/stores.ts +339 -0
- package/src/runtime/plugin/tab-strip-scroll.test.ts +40 -0
- package/src/runtime/plugin/tab-strip-scroll.ts +130 -0
- package/src/runtime/plugin/titlebar-items.css +20 -0
- package/src/runtime/plugin/titlebar-items.stories.tsx +97 -0
- package/src/runtime/plugin/titlebar-items.tsx +96 -0
- package/src/runtime/plugin/ui.tsx +292 -0
- package/src/runtime/plugin/web-href.test.ts +11 -0
- package/src/runtime/plugin/web-href.ts +10 -0
- package/src/runtime/polyfills.test.ts +61 -0
- package/src/runtime/polyfills.ts +39 -0
- package/src/runtime/presence-machine.test.ts +260 -0
- package/src/runtime/presence-machine.ts +329 -0
- package/src/runtime/presence.ts +165 -0
- package/src/runtime/server/api.test.ts +64 -0
- package/src/runtime/server/api.ts +58 -0
- package/src/runtime/server/client.test.ts +131 -0
- package/src/runtime/server/client.tsx +308 -0
- package/src/runtime/server/current.tsx +55 -0
- package/src/runtime/server/data.test.ts +440 -0
- package/src/runtime/server/data.ts +286 -0
- package/src/runtime/server/errors.test.ts +151 -0
- package/src/runtime/server/errors.ts +135 -0
- package/src/runtime/server/global-sync/bootstrap.test.ts +179 -0
- package/src/runtime/server/global-sync/bootstrap.ts +96 -0
- package/src/runtime/server/global-sync/child-store.test.ts +47 -0
- package/src/runtime/server/global-sync/child-store.ts +206 -0
- package/src/runtime/server/global-sync/machine.test.ts +96 -0
- package/src/runtime/server/global-sync/machine.ts +84 -0
- package/src/runtime/server/global-sync/types.ts +46 -0
- package/src/runtime/server/global-sync/utils.test.ts +154 -0
- package/src/runtime/server/global-sync/utils.ts +165 -0
- package/src/runtime/server/health-machine.test.ts +227 -0
- package/src/runtime/server/health-machine.ts +357 -0
- package/src/runtime/server/health.test.ts +169 -0
- package/src/runtime/server/health.ts +236 -0
- package/src/runtime/server/image.test.ts +214 -0
- package/src/runtime/server/image.ts +40 -0
- package/src/runtime/server/loopback.test.ts +17 -0
- package/src/runtime/server/loopback.ts +22 -0
- package/src/runtime/server/machine.test.ts +162 -0
- package/src/runtime/server/machine.ts +275 -0
- package/src/runtime/server/media.ts +88 -0
- package/src/runtime/server/persistence.test.ts +117 -0
- package/src/runtime/server/persistence.ts +105 -0
- package/src/runtime/server/plugin-machine.test.ts +128 -0
- package/src/runtime/server/plugin-machine.ts +170 -0
- package/src/runtime/server/refcount.test.ts +30 -0
- package/src/runtime/server/refcount.ts +37 -0
- package/src/runtime/server/registry.test.ts +152 -0
- package/src/runtime/server/registry.tsx +363 -0
- package/src/runtime/server/request-queue-machine.test.ts +151 -0
- package/src/runtime/server/request-queue-machine.ts +307 -0
- package/src/runtime/server/request-queue.test.ts +315 -0
- package/src/runtime/server/request-queue.ts +173 -0
- package/src/runtime/server/runtime.tsx +396 -0
- package/src/runtime/server/scope.test.ts +52 -0
- package/src/runtime/server/scope.ts +69 -0
- package/src/runtime/server/scoped-cache.test.ts +72 -0
- package/src/runtime/server/scoped-cache.ts +119 -0
- package/src/runtime/server/server-sync/connection.ts +34 -0
- package/src/runtime/server/server-sync/endpoint-machine.test.ts +87 -0
- package/src/runtime/server/server-sync/endpoint-machine.ts +62 -0
- package/src/runtime/server/server-sync/machine.test.ts +86 -0
- package/src/runtime/server/server-sync/machine.ts +70 -0
- package/src/runtime/server/session-index.ts +23 -0
- package/src/runtime/server/sync.tsx +206 -0
- package/src/runtime/server/types.ts +151 -0
- package/src/servers/connect/browser.ts +15 -0
- package/src/servers/connect/connect.fixture.tsx +222 -0
- package/src/servers/connect/controller.ts +237 -0
- package/src/servers/connect/dialog.stories.tsx +67 -0
- package/src/servers/connect/dialog.tsx +255 -0
- package/src/servers/connect/machine.test.ts +487 -0
- package/src/servers/connect/machine.ts +427 -0
- package/src/servers/connect/method.tsx +31 -0
- package/src/servers/connect/pairing.test.ts +67 -0
- package/src/servers/connect/pairing.ts +134 -0
- package/src/servers/connect/redeem.ts +50 -0
- package/src/servers/connect/scanner-machine.test.ts +114 -0
- package/src/servers/connect/scanner-machine.ts +164 -0
- package/src/servers/connect/scanner.css +47 -0
- package/src/servers/connect/scanner.tsx +173 -0
- package/src/servers/connect/screen.css +108 -0
- package/src/servers/connect/screen.stories.tsx +63 -0
- package/src/servers/connect/screen.tsx +164 -0
- package/src/servers/registry/add-menu.tsx +62 -0
- package/src/servers/registry/controller.test.ts +26 -0
- package/src/servers/registry/controller.ts +86 -0
- package/src/servers/registry/label.tsx +23 -0
- package/src/servers/registry/management.test.ts +40 -0
- package/src/servers/registry/management.ts +17 -0
- package/src/servers/registry/plugin-row.tsx +57 -0
- package/src/servers/registry/row-items.tsx +18 -0
- package/src/servers/registry/row-menu.tsx +152 -0
- package/src/servers/registry/row.stories.tsx +51 -0
- package/src/servers/registry/row.tsx +47 -0
- package/src/session/commands/dialog-jump-to-message.tsx +197 -0
- package/src/session/commands/export-machine.test.ts +99 -0
- package/src/session/commands/export-machine.ts +117 -0
- package/src/session/commands/export-session.tsx +108 -0
- package/src/session/commands/export.test.ts +105 -0
- package/src/session/commands/export.ts +89 -0
- package/src/session/commands/fork-dialog.stories.tsx +68 -0
- package/src/session/commands/fork-dialog.tsx +198 -0
- package/src/session/commands/jump-to-message-machine.test.ts +123 -0
- package/src/session/commands/jump-to-message-machine.ts +161 -0
- package/src/session/commands/jump-to-message.stories.tsx +226 -0
- package/src/session/commands/jump-to-message.tsx +161 -0
- package/src/session/commands/machine.test.ts +305 -0
- package/src/session/commands/machine.ts +272 -0
- package/src/session/commands/rename-session.ts +31 -0
- package/src/session/commands/use-session-commands.tsx +813 -0
- package/src/session/composer/activity-chips.css +242 -0
- package/src/session/composer/activity-chips.stories.tsx +280 -0
- package/src/session/composer/activity-chips.tsx +485 -0
- package/src/session/composer/adapter.ts +74 -0
- package/src/session/composer/composer-docks.stories.tsx +278 -0
- package/src/session/composer/composer-lane.css +93 -0
- package/src/session/composer/composer-lane.tsx +45 -0
- package/src/session/composer/controller.ts +86 -0
- package/src/session/composer/focus-machine.test.ts +285 -0
- package/src/session/composer/focus-machine.ts +212 -0
- package/src/session/composer/focus.tsx +161 -0
- package/src/session/composer/free-limit-panel.standalone.stories.tsx +45 -0
- package/src/session/composer/free-limit-panel.tsx +133 -0
- package/src/session/composer/go-limit-tray.tsx +137 -0
- package/src/session/composer/location-missing-machine.test.ts +97 -0
- package/src/session/composer/location-missing-machine.ts +144 -0
- package/src/session/composer/location-missing.css +73 -0
- package/src/session/composer/location-missing.standalone.stories.tsx +161 -0
- package/src/session/composer/location-missing.tsx +193 -0
- package/src/session/composer/plugin-pills.tsx +215 -0
- package/src/session/composer/queue-machine.test.ts +565 -0
- package/src/session/composer/queue-machine.ts +934 -0
- package/src/session/composer/queue-panel-machine.test.ts +121 -0
- package/src/session/composer/queue-panel-machine.ts +229 -0
- package/src/session/composer/queue-panel.css +10 -0
- package/src/session/composer/queue-panel.stories.tsx +86 -0
- package/src/session/composer/queue-panel.tsx +314 -0
- package/src/session/composer/queue.test.ts +314 -0
- package/src/session/composer/queue.ts +610 -0
- package/src/session/composer/recovery-story.tsx +38 -0
- package/src/session/composer/region.tsx +689 -0
- package/src/session/composer/selection.test.ts +28 -0
- package/src/session/composer/selection.ts +28 -0
- package/src/session/composer/session-composer-region-controller.ts +28 -0
- package/src/session/composer/session-composer-region.tsx +115 -0
- package/src/session/composer/shell-panel-machine.test.ts +261 -0
- package/src/session/composer/shell-panel-machine.ts +338 -0
- package/src/session/composer/shell-panel.ts +181 -0
- package/src/session/composer/spring-height-machine.test.ts +380 -0
- package/src/session/composer/spring-height-machine.ts +489 -0
- package/src/session/composer/spring-height.tsx +586 -0
- package/src/session/composer/subagent-bar.tsx +116 -0
- package/src/session/composer/timeline-actions.ts +49 -0
- package/src/session/composer/todo-pill.css +32 -0
- package/src/session/composer/todo-pill.stories.tsx +158 -0
- package/src/session/composer/todo-pill.tsx +157 -0
- package/src/session/composer/todos.ts +43 -0
- package/src/session/delete-machine.test.ts +83 -0
- package/src/session/delete-machine.ts +128 -0
- package/src/session/fork-machine.test.ts +152 -0
- package/src/session/fork-machine.ts +169 -0
- package/src/session/fork.ts +164 -0
- package/src/session/handoff-machine.test.ts +262 -0
- package/src/session/handoff-machine.ts +256 -0
- package/src/session/handoff.ts +112 -0
- package/src/session/header/drag-area.tsx +86 -0
- package/src/session/header/fit-machine.test.ts +143 -0
- package/src/session/header/fit-machine.ts +95 -0
- package/src/session/header/fit.ts +134 -0
- package/src/session/header/separator.tsx +22 -0
- package/src/session/header/session-header-actions.stories.tsx +45 -0
- package/src/session/header/session-header-actions.tsx +89 -0
- package/src/session/header/session-header.tsx +12 -0
- package/src/session/header/session-working-indicator.tsx +44 -0
- package/src/session/helpers.ts +42 -0
- package/src/session/list.test.ts +64 -0
- package/src/session/list.ts +18 -0
- package/src/session/message-id-from-hash.test.ts +10 -0
- package/src/session/message-id-from-hash.ts +8 -0
- package/src/session/model.ts +150 -0
- package/src/session/preparing-composer.tsx +72 -0
- package/src/session/question-switch.stories.tsx +380 -0
- package/src/session/requests/auto-approve-machine.test.ts +345 -0
- package/src/session/requests/auto-approve-machine.ts +247 -0
- package/src/session/requests/auto-approve.ts +274 -0
- package/src/session/requests/background.ts +312 -0
- package/src/session/requests/elicitation-controller.ts +129 -0
- package/src/session/requests/elicitation-machine.test.ts +209 -0
- package/src/session/requests/elicitation-machine.ts +277 -0
- package/src/session/requests/job-list.test.ts +18 -0
- package/src/session/requests/model.ts +348 -0
- package/src/session/requests/permission-machine.test.ts +130 -0
- package/src/session/requests/permission-machine.ts +105 -0
- package/src/session/requests/question-controller.ts +130 -0
- package/src/session/requests/question-keys.test.ts +106 -0
- package/src/session/requests/question-keys.ts +81 -0
- package/src/session/requests/question-machine.test.ts +257 -0
- package/src/session/requests/question-machine.ts +293 -0
- package/src/session/requests/question-motion.ts +26 -0
- package/src/session/requests/question-state.ts +21 -0
- package/src/session/requests/question-switch-machine.test.ts +114 -0
- package/src/session/requests/question-switch-machine.ts +130 -0
- package/src/session/requests/session-elicitation-dock.css +49 -0
- package/src/session/requests/session-elicitation-dock.tsx +223 -0
- package/src/session/requests/session-permission-dock.tsx +108 -0
- package/src/session/requests/session-question-dock-classic.tsx +726 -0
- package/src/session/requests/session-question-dock-experimental.tsx +1510 -0
- package/src/session/requests/session-question-dock.tsx +15 -0
- package/src/session/requests/session-request-tree.test.ts +119 -0
- package/src/session/requests/session-request-tree.ts +87 -0
- package/src/session/requests/session-websearch-dock.css +61 -0
- package/src/session/requests/session-websearch-dock.tsx +112 -0
- package/src/session/requests/steer-background.test.ts +66 -0
- package/src/session/requests/steer-background.ts +28 -0
- package/src/session/requests/websearch-machine.test.ts +425 -0
- package/src/session/requests/websearch-machine.ts +627 -0
- package/src/session/requests/websearch.ts +152 -0
- package/src/session/resolution-machine.test.ts +414 -0
- package/src/session/resolution-machine.ts +330 -0
- package/src/session/revert-machine.test.ts +365 -0
- package/src/session/revert-machine.ts +345 -0
- package/src/session/revert.ts +340 -0
- package/src/session/route-error.tsx +73 -0
- package/src/session/route.tsx +299 -0
- package/src/session/screen-layout.ts +147 -0
- package/src/session/screen.tsx +625 -0
- package/src/session/search.ts +3 -0
- package/src/session/server-unavailable-panel.standalone.stories.tsx +88 -0
- package/src/session/server-unavailable-panel.tsx +86 -0
- package/src/session/session-domain.test.ts +57 -0
- package/src/session/session-domain.ts +33 -0
- package/src/session/session-frame.tsx +28 -0
- package/src/session/session-identity-header.css +142 -0
- package/src/session/session-identity-header.tsx +674 -0
- package/src/session/session-layout.ts +73 -0
- package/src/session/session-model-helpers.test.ts +29 -0
- package/src/session/session-model-helpers.ts +33 -0
- package/src/session/session-panel-width.test.ts +25 -0
- package/src/session/session-panel-width.ts +58 -0
- package/src/session/session-read-menu-item.tsx +54 -0
- package/src/session/session-reference-menu.tsx +106 -0
- package/src/session/session-resolution.ts +141 -0
- package/src/session/session-screen.stories.tsx +363 -0
- package/src/session/sizing-machine.test.ts +89 -0
- package/src/session/sizing-machine.ts +74 -0
- package/src/session/story-model.tsx +420 -0
- package/src/session/timeline/background-work.stories.tsx +27 -0
- package/src/session/timeline/cache-machine.test.ts +50 -0
- package/src/session/timeline/cache-machine.ts +37 -0
- package/src/session/timeline/cache.ts +200 -0
- package/src/session/timeline/cold-mount.test.ts +162 -0
- package/src/session/timeline/cold-mount.ts +179 -0
- package/src/session/timeline/controller-projection.test.ts +305 -0
- package/src/session/timeline/controller-projection.ts +131 -0
- package/src/session/timeline/controller.tsx +467 -0
- package/src/session/timeline/cursor-machine.test.ts +398 -0
- package/src/session/timeline/cursor-machine.ts +433 -0
- package/src/session/timeline/cursor.ts +207 -0
- package/src/session/timeline/follow.ts +40 -0
- package/src/session/timeline/header-actions-machine.test.ts +126 -0
- package/src/session/timeline/header-actions-machine.ts +204 -0
- package/src/session/timeline/history-machine.test.ts +304 -0
- package/src/session/timeline/history-machine.ts +296 -0
- package/src/session/timeline/inline-quotes.ts +4 -0
- package/src/session/timeline/interaction.ts +474 -0
- package/src/session/timeline/machine.test.ts +290 -0
- package/src/session/timeline/machine.ts +271 -0
- package/src/session/timeline/message-timeline.tsx +779 -0
- package/src/session/timeline/model.test.ts +393 -0
- package/src/session/timeline/model.ts +201 -0
- package/src/session/timeline/observe-element-offset.test.ts +323 -0
- package/src/session/timeline/observe-element-offset.ts +106 -0
- package/src/session/timeline/projection.ts +7 -0
- package/src/session/timeline/quote-background.ts +141 -0
- package/src/session/timeline/quote-highlight.ts +203 -0
- package/src/session/timeline/quote-machine.test.ts +277 -0
- package/src/session/timeline/quote-machine.ts +360 -0
- package/src/session/timeline/quote-text.ts +332 -0
- package/src/session/timeline/quote.stories.tsx +88 -0
- package/src/session/timeline/quote.tsx +547 -0
- package/src/session/timeline/reconnect-machine.test.ts +115 -0
- package/src/session/timeline/reconnect-machine.ts +130 -0
- package/src/session/timeline/search-bar.css +19 -0
- package/src/session/timeline/search-bar.stories.tsx +122 -0
- package/src/session/timeline/search-bar.tsx +94 -0
- package/src/session/timeline/search-controller.ts +364 -0
- package/src/session/timeline/search-machine.test.ts +320 -0
- package/src/session/timeline/search-machine.ts +342 -0
- package/src/session/timeline/selected-effect.ts +19 -0
- package/src/session/timeline/sources.stories.tsx +352 -0
- package/src/session/timeline/sync-machine.ts +265 -0
- package/src/session/timeline/turn-diff-machine.ts +115 -0
- package/src/session/timeline/turn-diffs.test.ts +178 -0
- package/src/session/timeline/turn-diffs.ts +67 -0
- package/src/session/timeline/virtual-items.ts +3 -0
- package/src/session/timeline/virtualizer.tsx +1321 -0
- package/src/session/timeline/voice-delegation.test.ts +69 -0
- package/src/session/timeline/voice-delegation.ts +38 -0
- package/src/session/title.ts +15 -0
- package/src/session/usage-exceeded-dialogs.test.ts +41 -0
- package/src/session/usage-exceeded-dialogs.tsx +158 -0
- package/src/session/viewed-machine.test.ts +27 -0
- package/src/session/viewed-machine.ts +24 -0
- package/src/settings/about/about.tsx +199 -0
- package/src/settings/about/animated-wordmark.tsx +85 -0
- package/src/settings/about/anomaly-brush.svg +1 -0
- package/src/settings/about/contributors.test.ts +17 -0
- package/src/settings/about/contributors.ts +27 -0
- package/src/settings/about/legal.svg +9 -0
- package/src/settings/about/machine.test.ts +90 -0
- package/src/settings/about/machine.ts +119 -0
- package/src/settings/about/notices/apache-2.0.txt +201 -0
- package/src/settings/about/notices/betteroffice-notice.txt +2 -0
- package/src/settings/about/notices/crates.ts +770 -0
- package/src/settings/about/notices/dialog.tsx +113 -0
- package/src/settings/about/notices/fonts/OFL-1.1.txt +91 -0
- package/src/settings/about/notices/fonts.ts +107 -0
- package/src/settings/about/notices/notices.ts +37 -0
- package/src/settings/appearance/appearance.tsx +176 -0
- package/src/settings/command.tsx +29 -0
- package/src/settings/experimental/experimental.tsx +93 -0
- package/src/settings/extension-load-machine.test.ts +117 -0
- package/src/settings/extension-load-machine.ts +158 -0
- package/src/settings/extension-load.tsx +85 -0
- package/src/settings/general/behavior.ts +102 -0
- package/src/settings/general/controllers.test.ts +56 -0
- package/src/settings/general/controllers.ts +271 -0
- package/src/settings/general/general.tsx +404 -0
- package/src/settings/general/interface-mode.css +261 -0
- package/src/settings/general/interface-mode.tsx +190 -0
- package/src/settings/general/machine.test.ts +188 -0
- package/src/settings/general/machine.ts +224 -0
- package/src/settings/general/sound-preview-machine.test.ts +114 -0
- package/src/settings/general/sound-preview-machine.ts +109 -0
- package/src/settings/keybinds/keybinds.tsx +624 -0
- package/src/settings/keybinds/machine.test.ts +142 -0
- package/src/settings/keybinds/machine.ts +149 -0
- package/src/settings/keybinds/migration.ts +42 -0
- package/src/settings/list.tsx +10 -0
- package/src/settings/model.test.ts +249 -0
- package/src/settings/model.tsx +685 -0
- package/src/settings/models/machine.test.ts +123 -0
- package/src/settings/models/machine.ts +161 -0
- package/src/settings/models/models.tsx +285 -0
- package/src/settings/navigation.tsx +223 -0
- package/src/settings/notifications/notifications.tsx +160 -0
- package/src/settings/pages.ts +33 -0
- package/src/settings/palette.ts +44 -0
- package/src/settings/providers/account-actions.ts +112 -0
- package/src/settings/providers/account-name.tsx +46 -0
- package/src/settings/providers/accounts.test.ts +29 -0
- package/src/settings/providers/accounts.ts +11 -0
- package/src/settings/providers/console-extensions.test.ts +103 -0
- package/src/settings/providers/console-extensions.ts +110 -0
- package/src/settings/providers/console-link.tsx +121 -0
- package/src/settings/providers/extensions.tsx +425 -0
- package/src/settings/providers/machine.test.ts +270 -0
- package/src/settings/providers/machine.ts +357 -0
- package/src/settings/providers/plugin-update-machine.test.ts +155 -0
- package/src/settings/providers/plugin-update-machine.ts +151 -0
- package/src/settings/providers/providers.tsx +702 -0
- package/src/settings/rename-machine.test.ts +123 -0
- package/src/settings/rename-machine.ts +167 -0
- package/src/settings/rename.ts +120 -0
- package/src/settings/route.test.ts +117 -0
- package/src/settings/route.ts +160 -0
- package/src/settings/row.tsx +21 -0
- package/src/settings/scroller.ts +6 -0
- package/src/settings/search-catalog.ts +319 -0
- package/src/settings/search-empty.tsx +87 -0
- package/src/settings/search-field.tsx +101 -0
- package/src/settings/search-index.ts +193 -0
- package/src/settings/search-machine.test.ts +249 -0
- package/src/settings/search-machine.ts +308 -0
- package/src/settings/search-results.test.ts +151 -0
- package/src/settings/search-results.ts +75 -0
- package/src/settings/search-reveal.ts +76 -0
- package/src/settings/search.css +168 -0
- package/src/settings/search.tsx +283 -0
- package/src/settings/server-scope.tsx +12 -0
- package/src/settings/servers/inventory.test.ts +50 -0
- package/src/settings/servers/inventory.ts +100 -0
- package/src/settings/servers/machine.test.ts +148 -0
- package/src/settings/servers/machine.ts +176 -0
- package/src/settings/servers/servers.tsx +178 -0
- package/src/settings/servers/switcher.tsx +77 -0
- package/src/settings/servers/unavailable.tsx +99 -0
- package/src/settings/settings.css +2478 -0
- package/src/settings/shell.standalone.stories.tsx +60 -0
- package/src/settings/shell.tsx +434 -0
- package/src/settings/surface.tsx +297 -0
- package/src/settings/tab-header.ts +12 -0
- package/src/settings/timeline-detail.css +334 -0
- package/src/settings/timeline-detail.stories.tsx +54 -0
- package/src/settings/timeline-detail.tsx +221 -0
- package/src/settings/workspaces/delete-machine.test.ts +298 -0
- package/src/settings/workspaces/delete-machine.ts +392 -0
- package/src/settings/workspaces/project-extensions.tsx +537 -0
- package/src/settings/workspaces/project-folder-missing.tsx +29 -0
- package/src/settings/workspaces/project-lsp.test.ts +65 -0
- package/src/settings/workspaces/project-lsp.ts +31 -0
- package/src/settings/workspaces/project-machine.test.ts +285 -0
- package/src/settings/workspaces/project-machine.ts +374 -0
- package/src/settings/workspaces/project-model.ts +201 -0
- package/src/settings/workspaces/project-options.tsx +81 -0
- package/src/settings/workspaces/project-row.tsx +121 -0
- package/src/settings/workspaces/project.css +397 -0
- package/src/settings/workspaces/project.tsx +266 -0
- package/src/settings/workspaces/projects.tsx +199 -0
- package/src/settings/workspaces/queries.ts +66 -0
- package/src/settings/workspaces/workspaces.tsx +705 -0
- package/src/shell/commands/command-search.tsx +41 -0
- package/src/shell/commands/command.test.ts +118 -0
- package/src/shell/commands/command.tsx +584 -0
- package/src/shell/commands/desktop-menu.test.ts +48 -0
- package/src/shell/commands/desktop-menu.ts +322 -0
- package/src/shell/commands/desktop.tsx +27 -0
- package/src/shell/commands/dialog.css +263 -0
- package/src/shell/commands/dialog.standalone.stories.tsx +247 -0
- package/src/shell/commands/dialog.tsx +318 -0
- package/src/shell/commands/highlight-machine.test.ts +64 -0
- package/src/shell/commands/highlight-machine.ts +54 -0
- package/src/shell/commands/key-sequence.tsx +38 -0
- package/src/shell/commands/keymap.test.ts +219 -0
- package/src/shell/commands/keymap.ts +275 -0
- package/src/shell/commands/palette.ts +466 -0
- package/src/shell/commands/safe-triangle.ts +64 -0
- package/src/shell/commands/search-machine.test.ts +218 -0
- package/src/shell/commands/search-machine.ts +274 -0
- package/src/shell/commands/search.ts +136 -0
- package/src/shell/commands/session-search.tsx +111 -0
- package/src/shell/commands/suspend-machine.test.ts +59 -0
- package/src/shell/commands/suspend-machine.ts +46 -0
- package/src/shell/deep-links/deep-links.ts +65 -0
- package/src/shell/deep-links/machine.test.ts +67 -0
- package/src/shell/deep-links/machine.ts +67 -0
- package/src/shell/errors/description.test.ts +32 -0
- package/src/shell/errors/description.ts +32 -0
- package/src/shell/errors/error.tsx +515 -0
- package/src/shell/errors/machine.test.ts +178 -0
- package/src/shell/errors/machine.ts +217 -0
- package/src/shell/layout/helpers.test.ts +76 -0
- package/src/shell/layout/helpers.ts +78 -0
- package/src/shell/layout/project-avatar-state.ts +157 -0
- package/src/shell/layout/project-icon.tsx +31 -0
- package/src/shell/layout/project-icons.tsx +34 -0
- package/src/shell/layout/session-tab-avatar.tsx +28 -0
- package/src/shell/mobile-drawer.css +90 -0
- package/src/shell/mobile-drawer.tsx +53 -0
- package/src/shell/mobile-panel-drawer.css +34 -0
- package/src/shell/mobile-panel-drawer.tsx +98 -0
- package/src/shell/notifications/coordinator.ts +160 -0
- package/src/shell/notifications/focus-lock-machine.test.ts +79 -0
- package/src/shell/notifications/focus-lock-machine.ts +76 -0
- package/src/shell/notifications/machine.test.ts +297 -0
- package/src/shell/notifications/machine.ts +313 -0
- package/src/shell/notifications/notification.test.ts +28 -0
- package/src/shell/notifications/notification.tsx +526 -0
- package/src/shell/notifications/sound.ts +113 -0
- package/src/shell/notifications/toast.tsx +53 -0
- package/src/shell/palette-menu.css +105 -0
- package/src/shell/panel-motion-machine.test.ts +167 -0
- package/src/shell/panel-motion-machine.ts +217 -0
- package/src/shell/panel-motion.test.ts +26 -0
- package/src/shell/panel-motion.ts +435 -0
- package/src/shell/project-navigation.ts +21 -0
- package/src/shell/routes/routes.tsx +140 -0
- package/src/shell/routes/session-reference-lookup-machine.test.ts +111 -0
- package/src/shell/routes/session-reference-lookup-machine.ts +86 -0
- package/src/shell/routes/session-ui-navigate-machine.test.ts +124 -0
- package/src/shell/routes/session-ui-navigate-machine.ts +127 -0
- package/src/shell/routes/session-ui-provider.tsx +267 -0
- package/src/shell/routes/session.test.ts +46 -0
- package/src/shell/routes/session.ts +30 -0
- package/src/shell/search-list.css +366 -0
- package/src/shell/shell.tsx +340 -0
- package/src/shell/sidebar-peek-machine.test.ts +240 -0
- package/src/shell/sidebar-peek-machine.ts +331 -0
- package/src/shell/sidebar-peek.css +28 -0
- package/src/shell/sidebar-peek.ts +482 -0
- package/src/shell/sidebar-toggle.tsx +255 -0
- package/src/shell/state/helpers.ts +69 -0
- package/src/shell/state/intent-machine.test.ts +155 -0
- package/src/shell/state/intent-machine.ts +216 -0
- package/src/shell/state/layout.test.ts +169 -0
- package/src/shell/state/layout.tsx +794 -0
- package/src/shell/state/scoped-machine.test.ts +69 -0
- package/src/shell/state/scoped-machine.ts +77 -0
- package/src/shell/state/scroll-machine.test.ts +109 -0
- package/src/shell/state/scroll-machine.ts +94 -0
- package/src/shell/state/scroll.test.ts +83 -0
- package/src/shell/state/scroll.ts +124 -0
- package/src/shell/state/session-preferences.ts +62 -0
- package/src/shell/state/session-tabs.test.ts +188 -0
- package/src/shell/state/session-tabs.ts +257 -0
- package/src/shell/tabs/closed.ts +83 -0
- package/src/shell/tabs/hydration-machine.test.ts +98 -0
- package/src/shell/tabs/hydration-machine.ts +115 -0
- package/src/shell/tabs/memory.ts +41 -0
- package/src/shell/tabs/navigation-switch.ts +75 -0
- package/src/shell/tabs/pins.test.ts +68 -0
- package/src/shell/tabs/pins.ts +194 -0
- package/src/shell/tabs/preview-machine.test.ts +89 -0
- package/src/shell/tabs/preview-machine.ts +46 -0
- package/src/shell/tabs/preview.test.ts +153 -0
- package/src/shell/tabs/preview.ts +102 -0
- package/src/shell/tabs/project-sessions.ts +60 -0
- package/src/shell/tabs/promotion-machine.test.ts +203 -0
- package/src/shell/tabs/promotion-machine.ts +194 -0
- package/src/shell/tabs/schema.ts +86 -0
- package/src/shell/tabs/tabs.test.ts +331 -0
- package/src/shell/tabs/tabs.tsx +927 -0
- package/src/shell/time.test.ts +23 -0
- package/src/shell/time.ts +31 -0
- package/src/shell/titlebar/auto-tab-groups.test.ts +76 -0
- package/src/shell/titlebar/auto-tab-groups.ts +88 -0
- package/src/shell/titlebar/auto-tab-sections.tsx +207 -0
- package/src/shell/titlebar/history-machine.test.ts +184 -0
- package/src/shell/titlebar/history-machine.ts +149 -0
- package/src/shell/titlebar/history.ts +64 -0
- package/src/shell/titlebar/inbox-branch-machine.test.ts +146 -0
- package/src/shell/titlebar/inbox-branch-machine.ts +265 -0
- package/src/shell/titlebar/inbox-card.stories.tsx +197 -0
- package/src/shell/titlebar/inbox-list.stories.tsx +342 -0
- package/src/shell/titlebar/inbox-model.ts +539 -0
- package/src/shell/titlebar/inbox-settle-machine.test.ts +108 -0
- package/src/shell/titlebar/inbox-settle-machine.ts +141 -0
- package/src/shell/titlebar/inbox-working.test.ts +26 -0
- package/src/shell/titlebar/inbox-working.ts +22 -0
- package/src/shell/titlebar/inbox.tsx +985 -0
- package/src/shell/titlebar/mobile-tabs-machine.test.ts +105 -0
- package/src/shell/titlebar/mobile-tabs-machine.ts +102 -0
- package/src/shell/titlebar/navigation-story.tsx +207 -0
- package/src/shell/titlebar/pinned-area.css +164 -0
- package/src/shell/titlebar/pinned-area.tsx +629 -0
- package/src/shell/titlebar/project-session-row.tsx +334 -0
- package/src/shell/titlebar/recent-sessions-model.test.ts +657 -0
- package/src/shell/titlebar/recent-sessions-model.ts +469 -0
- package/src/shell/titlebar/recent-sessions.tsx +1415 -0
- package/src/shell/titlebar/recent-view-menu.tsx +147 -0
- package/src/shell/titlebar/recent-view.test.ts +99 -0
- package/src/shell/titlebar/recent-view.ts +183 -0
- package/src/shell/titlebar/recently-closed-tabs-menu.css +25 -0
- package/src/shell/titlebar/recently-closed-tabs-menu.tsx +260 -0
- package/src/shell/titlebar/route-machine.test.ts +259 -0
- package/src/shell/titlebar/route-machine.ts +206 -0
- package/src/shell/titlebar/route-sync.ts +191 -0
- package/src/shell/titlebar/session-events.test.ts +23 -0
- package/src/shell/titlebar/session-events.ts +41 -0
- package/src/shell/titlebar/session-rename-dialog-machine.test.ts +151 -0
- package/src/shell/titlebar/session-rename-dialog-machine.ts +159 -0
- package/src/shell/titlebar/sidebar-customized.standalone.stories.tsx +16 -0
- package/src/shell/titlebar/sidebar-customized.tsx +747 -0
- package/src/shell/titlebar/sidebar-pins.tsx +462 -0
- package/src/shell/titlebar/sidebar-sessions.test.ts +96 -0
- package/src/shell/titlebar/sidebar-sessions.ts +29 -0
- package/src/shell/titlebar/sidebar-view-menu.tsx +191 -0
- package/src/shell/titlebar/sidebar-view.test.ts +185 -0
- package/src/shell/titlebar/sidebar-view.ts +208 -0
- package/src/shell/titlebar/tab-group-drag-machine.ts +1479 -0
- package/src/shell/titlebar/tab-groups-ui.tsx +1246 -0
- package/src/shell/titlebar/tab-groups.css +269 -0
- package/src/shell/titlebar/tab-groups.test.ts +667 -0
- package/src/shell/titlebar/tab-groups.ts +496 -0
- package/src/shell/titlebar/tab-hints-machine.test.ts +97 -0
- package/src/shell/titlebar/tab-hints-machine.ts +79 -0
- package/src/shell/titlebar/tab-load-machine.test.ts +178 -0
- package/src/shell/titlebar/tab-load-machine.ts +233 -0
- package/src/shell/titlebar/tab-nav.css +581 -0
- package/src/shell/titlebar/tab-nav.tsx +891 -0
- package/src/shell/titlebar/tab-order.test.ts +22 -0
- package/src/shell/titlebar/tab-order.ts +24 -0
- package/src/shell/titlebar/tab-popover-machine.test.ts +79 -0
- package/src/shell/titlebar/tab-popover-machine.ts +92 -0
- package/src/shell/titlebar/tab-popover.css +129 -0
- package/src/shell/titlebar/tab-popover.tsx +144 -0
- package/src/shell/titlebar/tab-rename-machine.test.ts +206 -0
- package/src/shell/titlebar/tab-rename-machine.ts +297 -0
- package/src/shell/titlebar/tab-strip.standalone.stories.tsx +19 -0
- package/src/shell/titlebar/tab-strip.tsx +1228 -0
- package/src/shell/titlebar/tab-title.test.ts +14 -0
- package/src/shell/titlebar/tab-title.ts +6 -0
- package/src/shell/titlebar/titlebar.css +197 -0
- package/src/shell/titlebar/titlebar.tsx +1075 -0
- package/src/shell/titlebar/windows-menu.test.ts +20 -0
- package/src/shell/titlebar/windows-menu.tsx +193 -0
- package/src/sst-env.d.ts +12 -0
- package/src/theme-preload.test.ts +56 -0
- package/src/tips/model.ts +155 -0
- package/src/tips/queue.test.ts +43 -0
- package/src/tips/queue.ts +46 -0
- package/src/usage/dialog.css +8 -0
- package/src/usage/dialog.standalone.stories.tsx +137 -0
- package/src/usage/dialog.tsx +570 -0
- package/src/usage/format.ts +39 -0
- package/src/usage/limits.test.ts +141 -0
- package/src/usage/limits.ts +189 -0
- package/src/usage/machine.test.ts +128 -0
- package/src/usage/machine.ts +159 -0
- package/src/usage/model.tsx +55 -0
- package/src/voice/call-machine.test.ts +245 -0
- package/src/voice/call-machine.ts +327 -0
- package/src/voice/call.ts +362 -0
- package/src/voice/composer.tsx +300 -0
- package/src/voice/context.tsx +152 -0
- package/src/voice/coordination.test.ts +58 -0
- package/src/voice/fixtures/history.ts +51 -0
- package/src/voice/gate-machine.test.ts +91 -0
- package/src/voice/gate-machine.ts +148 -0
- package/src/voice/handoff.test.ts +35 -0
- package/src/voice/handoff.ts +20 -0
- package/src/voice/machine.test.ts +303 -0
- package/src/voice/machine.ts +349 -0
- package/src/voice/messages.test.ts +49 -0
- package/src/voice/messages.ts +15 -0
- package/src/voice/panel-machine.test.ts +106 -0
- package/src/voice/panel-machine.ts +167 -0
- package/src/voice/protocol.ts +62 -0
- package/src/voice/replies.ts +71 -0
- package/src/voice/reply-machine.test.ts +290 -0
- package/src/voice/reply-machine.ts +303 -0
- package/src/voice/search.test.ts +35 -0
- package/src/voice/search.ts +134 -0
- package/src/voice/spec.ts +114 -0
- package/src/voice/tail-machine.test.ts +124 -0
- package/src/voice/tail-machine.ts +155 -0
- package/src/voice/tail.ts +55 -0
- package/src/voice/tools.test.ts +320 -0
- package/src/voice/tools.ts +336 -0
- package/src/voice/transport-machine.test.ts +295 -0
- package/src/voice/transport-machine.ts +338 -0
- package/src/voice/transport.test.ts +295 -0
- package/src/voice/transport.ts +313 -0
- package/src/voice/voice.css +84 -0
- package/src/workspaces/create.test.ts +120 -0
- package/src/workspaces/create.ts +23 -0
- package/src/workspaces/files/artifact.test.ts +103 -0
- package/src/workspaces/files/artifact.ts +74 -0
- package/src/workspaces/files/content-cache-accounting.test.ts +79 -0
- package/src/workspaces/files/content-cache.ts +74 -0
- package/src/workspaces/files/content-machine.test.ts +269 -0
- package/src/workspaces/files/content-machine.ts +243 -0
- package/src/workspaces/files/model.tsx +423 -0
- package/src/workspaces/files/path.test.ts +76 -0
- package/src/workspaces/files/path.ts +143 -0
- package/src/workspaces/files/tree-machine.test.ts +300 -0
- package/src/workspaces/files/tree-machine.ts +286 -0
- package/src/workspaces/files/tree-store.ts +142 -0
- package/src/workspaces/files/types.ts +85 -0
- package/src/workspaces/files/view-cache.ts +164 -0
- package/src/workspaces/files/watcher.test.ts +114 -0
- package/src/workspaces/files/watcher.ts +42 -0
- package/src/workspaces/inventory.test.ts +151 -0
- package/src/workspaces/inventory.ts +64 -0
- package/src/workspaces/location-machine.test.ts +135 -0
- package/src/workspaces/location-machine.ts +159 -0
- package/src/workspaces/location.tsx +111 -0
- package/src/workspaces/path-key.ts +5 -0
- package/src/workspaces/paths.test.ts +193 -0
- package/src/workspaces/paths.ts +123 -0
- package/src/workspaces/selection/combobox-machine.test.ts +286 -0
- package/src/workspaces/selection/combobox-machine.ts +331 -0
- package/src/workspaces/selection/dialog.css +234 -0
- package/src/workspaces/selection/dialog.standalone.stories.tsx +66 -0
- package/src/workspaces/selection/dialog.tsx +867 -0
- package/src/workspaces/selection/domain.test.ts +603 -0
- package/src/workspaces/selection/domain.ts +609 -0
- package/src/workspaces/selection/picker.test.ts +37 -0
- package/src/workspaces/selection/picker.tsx +77 -0
- package/src/workspaces/selection/policy.ts +8 -0
- package/src/workspaces/selection/queue-machine.test.ts +116 -0
- package/src/workspaces/selection/queue-machine.ts +203 -0
- package/src/workspaces/selection/tree-machine.test.ts +293 -0
- package/src/workspaces/selection/tree-machine.ts +506 -0
- package/test-browser/animated-presence-state.test.ts +134 -0
- package/test-browser/auto-scroll.test.ts +111 -0
- package/test-browser/browser-pane-model.test.ts +522 -0
- package/test-browser/child-store-eviction.test.ts +86 -0
- package/test-browser/command-palette-search.test.ts +157 -0
- package/test-browser/command-palette.test.ts +262 -0
- package/test-browser/composer-attachment-errors.test.tsx +140 -0
- package/test-browser/composer-attachment-ownership.test.tsx +132 -0
- package/test-browser/composer-drag-cancel.test.tsx +41 -0
- package/test-browser/composer-file-search.test.ts +183 -0
- package/test-browser/composer-ime.test.ts +58 -0
- package/test-browser/composer-submit-loading.test.ts +235 -0
- package/test-browser/composer-write-batch.test.ts +201 -0
- package/test-browser/draft-history-cache.test.ts +139 -0
- package/test-browser/elicitation-dock.test.ts +110 -0
- package/test-browser/file-tree-store.test.ts +113 -0
- package/test-browser/fixtures/model-selection.ts +646 -0
- package/test-browser/message-page-publication.test.ts +46 -0
- package/test-browser/model-selection.test.ts +25 -0
- package/test-browser/motion-dom.test.ts +367 -0
- package/test-browser/motion-spring.test.ts +75 -0
- package/test-browser/pane-drag.test.tsx +136 -0
- package/test-browser/panel-motion.test.ts +398 -0
- package/test-browser/persisted-consumers.test.ts +40 -0
- package/test-browser/playwright-config.test.ts +72 -0
- package/test-browser/plugin-catalog.test.ts +67 -0
- package/test-browser/plugin-link-check.test.ts +102 -0
- package/test-browser/plugin-migrations.test.ts +170 -0
- package/test-browser/plugin-primitives.test.ts +616 -0
- package/test-browser/plugin-server-stream.test.ts +88 -0
- package/test-browser/presence.test.ts +236 -0
- package/test-browser/project-avatar-hover.test.ts +143 -0
- package/test-browser/prompt-motion.test.ts +10 -0
- package/test-browser/prompt-persistence.test.ts +312 -0
- package/test-browser/prompt-scope.test.ts +15 -0
- package/test-browser/provider-catalog.test.ts +54 -0
- package/test-browser/pwa-route.test.ts +96 -0
- package/test-browser/question-dock.test.ts +128 -0
- package/test-browser/schema-persistence.test.ts +294 -0
- package/test-browser/selected-effect.test.ts +36 -0
- package/test-browser/server-connection-sync.test.ts +34 -0
- package/test-browser/server-notification-state.test.ts +662 -0
- package/test-browser/session-activity-elapsed.test.ts +62 -0
- package/test-browser/session-background.test.ts +377 -0
- package/test-browser/session-message-handoffs.test.ts +118 -0
- package/test-browser/session-resolution.test.ts +385 -0
- package/test-browser/settings-keybinds.test.ts +196 -0
- package/test-browser/shell-panel.test.ts +219 -0
- package/test-browser/sidebar-peek.test.ts +149 -0
- package/test-browser/solid-router-cleanup.test.ts +66 -0
- package/test-browser/solid-runtime.test.ts +95 -0
- package/test-browser/solid-virtual.test.ts +249 -0
- package/test-browser/ssh-composer.test.ts +41 -0
- package/test-browser/ssh-health.test.ts +142 -0
- package/test-browser/theme-preload.test.ts +9 -0
- package/test-browser/timeline-cache.test.ts +571 -0
- package/test-browser/timeline-projection.test.ts +363 -0
- package/test-browser/toast-owner.test.ts +66 -0
- package/test-browser/websearch-request.test.ts +277 -0
- package/tsconfig.json +35 -0
- package/vite.config.ts +62 -0
- package/vite.icons.test.ts +133 -0
- package/vite.icons.ts +65 -0
- package/vite.js +142 -0
- package/vite.pwa.ts +69 -0
|
@@ -0,0 +1,1726 @@
|
|
|
1
|
+
import type { Page } from "@playwright/test"
|
|
2
|
+
import type { OpenCodeEvent, SessionMessageInfo } from "@zyro-sec/client/promise"
|
|
3
|
+
import { Permission } from "@zyro-sec/schema/permission"
|
|
4
|
+
import { artifactKind, artifactMime } from "@zyro-sec/util/artifact"
|
|
5
|
+
import { Model } from "@zyro-sec/schema/model"
|
|
6
|
+
import { Worktree } from "@zyro-sec/schema/worktree"
|
|
7
|
+
import { Effect, Layer, Option, Predicate, Schema } from "effect"
|
|
8
|
+
import { HttpRouter, HttpServer, HttpServerResponse } from "effect/http"
|
|
9
|
+
import { HttpApiBuilder, HttpApiSchema } from "effect/http-api"
|
|
10
|
+
import { SERVER } from "./app"
|
|
11
|
+
import {
|
|
12
|
+
MockApi,
|
|
13
|
+
MockBadRequest,
|
|
14
|
+
MockInternal,
|
|
15
|
+
MockNotFound,
|
|
16
|
+
MockPtyFeatureUnsupported,
|
|
17
|
+
MockPtyNotFound,
|
|
18
|
+
MockServiceUnavailable,
|
|
19
|
+
MockShellNotFound,
|
|
20
|
+
MockUnauthorized,
|
|
21
|
+
MockUnsupported,
|
|
22
|
+
} from "./mock-api"
|
|
23
|
+
import { createPersistentPty, type MockPersistentPtyConfig, type MockServerEvent } from "./persistent-pty"
|
|
24
|
+
import { installSseTransport } from "./sse-transport"
|
|
25
|
+
|
|
26
|
+
type Resolvable<T> = T | (() => T)
|
|
27
|
+
|
|
28
|
+
// A hook's replacement response.
|
|
29
|
+
export type MockAnswer = { status: number; body: unknown }
|
|
30
|
+
|
|
31
|
+
// The legacy `/provider` catalog: `all` lists providers with `id`, `name` and `models` keyed by model ID.
|
|
32
|
+
export type MockProviderCatalog = {
|
|
33
|
+
all?: readonly unknown[]
|
|
34
|
+
connected?: readonly string[]
|
|
35
|
+
default?: { providerID?: string; modelID?: string }
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// A session in any shape a scenario seeds, current or legacy (`directory`, `path`); `currentSession` reads it.
|
|
39
|
+
// oxlint-disable-next-line anti-slop/no-unsafe-dictionary-type -- scenarios seed arbitrary session fields
|
|
40
|
+
export type MockSession = { id: string } & Record<string, unknown>
|
|
41
|
+
|
|
42
|
+
export type MockMcpStatus = { status: string; error?: string }
|
|
43
|
+
|
|
44
|
+
export type MockFileContent =
|
|
45
|
+
| string
|
|
46
|
+
| { type?: string; content: string; encoding?: string; mimeType?: string }
|
|
47
|
+
| undefined
|
|
48
|
+
|
|
49
|
+
export interface MockServerConfig {
|
|
50
|
+
server?: string
|
|
51
|
+
// The machine name `/api/info` reports; omitted like a server that predates it.
|
|
52
|
+
hostname?: string
|
|
53
|
+
provider: Resolvable<MockProviderCatalog>
|
|
54
|
+
integrations?: Resolvable<unknown[]>
|
|
55
|
+
// Runs on POST /api/credential/:id/activate; the fixture swaps its integrations and catalog to the new account.
|
|
56
|
+
onCredentialActivate?: (credentialID: string) => void
|
|
57
|
+
// Runs on PATCH /api/credential/:id with the request body; the fixture applies the new label.
|
|
58
|
+
onCredentialUpdate?: (credentialID: string, body: { label?: string }) => void
|
|
59
|
+
// Runs on POST /api/integration/:id/connect/key; returning `{ error }` rejects the key with a 400 and that message.
|
|
60
|
+
onConnectKey?: (input: { integrationID: string; body: unknown }) => void | { error: string }
|
|
61
|
+
// Terminal shells the settings offer (`/api/config/shell`).
|
|
62
|
+
shells?: unknown[]
|
|
63
|
+
// Background shell commands (`GET /api/shell`).
|
|
64
|
+
shellCommands?: Resolvable<unknown[]>
|
|
65
|
+
// All output a shell command has captured so far in `directory`, or undefined for an unknown command (404
|
|
66
|
+
// ShellNotFoundError). The mock pages it like the server: from the request's byte `cursor`, at most `limit` bytes
|
|
67
|
+
// (default 65,536).
|
|
68
|
+
shellOutput?: (input: { id: string; directory: string }) => string | undefined
|
|
69
|
+
// Records `POST /api/experimental/fs/write` (attachment uploads), which answers the requested path.
|
|
70
|
+
// Without it, writes answer 501 MockUnsupported.
|
|
71
|
+
onFileWrite?: (input: { path: string; directory: string; body: string }) => void
|
|
72
|
+
configEntries?: unknown[]
|
|
73
|
+
directory: string
|
|
74
|
+
project: unknown
|
|
75
|
+
// Replaces the `/api/project` inventory, which defaults to `[project]`. A location inside a listed project
|
|
76
|
+
// resolves to that project; any other location resolves to `project`.
|
|
77
|
+
projects?: Resolvable<unknown[]>
|
|
78
|
+
// Runs on GET /api/location for a named directory before it answers, as the server registers the project of a
|
|
79
|
+
// directory it resolves.
|
|
80
|
+
onLocationGet?: (directory: string) => void
|
|
81
|
+
sessions: MockSession[]
|
|
82
|
+
pageMessages: (
|
|
83
|
+
sessionId: string,
|
|
84
|
+
limit: number,
|
|
85
|
+
before?: string,
|
|
86
|
+
) => {
|
|
87
|
+
items: SessionMessageInfo[]
|
|
88
|
+
cursor?: string
|
|
89
|
+
}
|
|
90
|
+
vcs?: { current?: string; default: string } | ((directory: string) => { current?: string; default: string })
|
|
91
|
+
branches?: (input: { directory: string; search?: string; limit?: number }) => string[] | Promise<string[]>
|
|
92
|
+
// Initializes the mock project's VCS; without a handler this mutation answers 501.
|
|
93
|
+
onVcsInit?: (input: { directory: string; provider?: string }) => void
|
|
94
|
+
// `directory` is the requested `location[directory]`, such as an untracked folder the review opened.
|
|
95
|
+
/** `context` is the patch's lines of context, sent when the review asks for a large file's full patch. */
|
|
96
|
+
vcsDiff?: unknown[] | ((input: { mode?: string; directory: string; context?: string }) => unknown[])
|
|
97
|
+
beforeMessagesResponse?: (input: { sessionID: string; before?: string }) => Promise<void>
|
|
98
|
+
beforeAgentsResponse?: () => Promise<void>
|
|
99
|
+
onMessages?: (input: { sessionID: string; before?: string; phase: "start" | "end" }) => void
|
|
100
|
+
message?: (sessionID: string, messageID: string) => SessionMessageInfo | undefined
|
|
101
|
+
onMessage?: (input: { sessionID: string; messageID: string }) => void
|
|
102
|
+
onRevertStage?: (input: { sessionID: string; messageID: string }) => void
|
|
103
|
+
onSession?: (sessionID: string) => void
|
|
104
|
+
events?: () => OpenCodeEvent[]
|
|
105
|
+
eventRetry?: number
|
|
106
|
+
// Idle event streams send a comment every 15 s like the real server. Set false only to test the client's stall watchdog.
|
|
107
|
+
keepalive?: boolean
|
|
108
|
+
permissions?: unknown[] | (() => unknown[])
|
|
109
|
+
// Requests only listed by `/api/session/:id/permission`, keyed by session ID.
|
|
110
|
+
sessionPermissions?: Record<string, unknown[]>
|
|
111
|
+
// Returning true fails the next `/api/permission/request` listing with a 500.
|
|
112
|
+
permissionListFailures?: () => boolean
|
|
113
|
+
// Without it, permission replies answer 501 MockUnsupported.
|
|
114
|
+
onPermissionReply?: (input: { sessionID: string; permissionID: string; body: unknown }) => void
|
|
115
|
+
forms?: unknown[] | (() => unknown[])
|
|
116
|
+
// Records form replies. The mock keeps listing a replied form unless `forms` stops returning it.
|
|
117
|
+
onFormReply?: (input: { sessionID: string; formID: string; body: unknown }) => void
|
|
118
|
+
// Web search providers (`GET /api/websearch/provider`), none by default.
|
|
119
|
+
websearchProviders?: Resolvable<unknown[]>
|
|
120
|
+
// MCP servers. A list serves every workspace; a function receives the requested directory.
|
|
121
|
+
mcp?: unknown[] | ((directory: string) => unknown[])
|
|
122
|
+
// Connect/disconnect record the server's new status in that workspace (`connected`/`disabled`); the hook may return
|
|
123
|
+
// another status (for example `{ status: "failed", error }`). Unknown servers answer 404.
|
|
124
|
+
onMcpAction?: (input: { server: string; action: "connect" | "disconnect"; directory: string }) => void | MockMcpStatus
|
|
125
|
+
// Starts an OAuth attempt (POST .../connect/oauth) and returns its authorization URL; the attempt then stays pending.
|
|
126
|
+
// Without it, OAuth connects answer 501 MockUnsupported.
|
|
127
|
+
// `paste` starts a sign-in that also accepts the redirect URL pasted from the browser.
|
|
128
|
+
onIntegrationOAuth?: (input: { integrationID: string; directory: string; body: unknown }) => {
|
|
129
|
+
url: string
|
|
130
|
+
paste?: boolean
|
|
131
|
+
}
|
|
132
|
+
// Answers status polls for an OAuth attempt; without it every attempt stays pending.
|
|
133
|
+
onIntegrationOAuthStatus?: (attemptID: string) => "pending" | "complete"
|
|
134
|
+
// Accepts a pasted redirect URL (POST .../connect/oauth/:attemptID/complete). Without it, pastes answer 501.
|
|
135
|
+
onIntegrationOAuthComplete?: (input: { attemptID: string; body: unknown }) => void
|
|
136
|
+
// Returning true fails the next `/api/mcp/resource` listing with a 500.
|
|
137
|
+
mcpResourceFailures?: () => boolean
|
|
138
|
+
// Runs on DELETE .../connect/oauth/:attemptID, which closes an OAuth attempt the dialog left.
|
|
139
|
+
onIntegrationOAuthCancel?: (attemptID: string) => void
|
|
140
|
+
plugins?: Resolvable<unknown[]>
|
|
141
|
+
skills?: Resolvable<unknown[]>
|
|
142
|
+
// Replaces the `/api/worktree` inventory, which defaults to the directory plus project sandboxes.
|
|
143
|
+
worktrees?: Resolvable<unknown[]>
|
|
144
|
+
// Without them, creating or removing a worktree answers 501 MockUnsupported. `onWorktreeCreate` may hold the request
|
|
145
|
+
// and return the answer; by default it creates `<directory>/<name>`. A created directory joins the project's sandboxes.
|
|
146
|
+
onWorktreeCreate?: (input: Schema.Json) => void | MockAnswer | Promise<void | MockAnswer>
|
|
147
|
+
onWorktreeRemove?: (input: Worktree.RemoveInput) => void | Promise<void>
|
|
148
|
+
// POST /api/session keeps the client-reserved `id` and `location`. Return an answer to fail the attempt (1-based); the
|
|
149
|
+
// hook may hold the request.
|
|
150
|
+
onSessionCreate?: (body: Schema.JsonObject, attempt: number) => void | MockAnswer | Promise<void | MockAnswer>
|
|
151
|
+
// Title of created sessions (default: the request's title, else "New session").
|
|
152
|
+
createdSessionTitle?: string
|
|
153
|
+
// Slash commands served by `/api/command`.
|
|
154
|
+
commands?: Resolvable<unknown[]>
|
|
155
|
+
// Records POST /api/session/:id/command (204). Without it, commands answer 501 MockUnsupported.
|
|
156
|
+
onCommand?: (input: { sessionID: string; body: unknown }) => void
|
|
157
|
+
fileList?: (path: string) => unknown[] | Promise<unknown[]>
|
|
158
|
+
fileContent?: (path: string) => MockFileContent | Promise<MockFileContent>
|
|
159
|
+
// Paths become directory entries.
|
|
160
|
+
findFiles?: (input: { query: string; dirs?: string; limit?: number; directory: string }) => unknown[]
|
|
161
|
+
sessionStatus?: Resolvable<Record<string, { type: string }>>
|
|
162
|
+
inbox?: unknown[] | (() => unknown[])
|
|
163
|
+
onPrompt?: (input: { sessionID: string; body: Schema.JsonObject }) => void
|
|
164
|
+
onCompact?: (input: { sessionID: string; body: Schema.JsonObject }) => void
|
|
165
|
+
// POST /api/session/:id/fork creates `<id>_fork` in the same directory. The hook may hold the request, or return an
|
|
166
|
+
// answer to replace the response.
|
|
167
|
+
onFork?: (input: { sessionID: string; body: Schema.JsonObject }) => void | MockAnswer | Promise<void | MockAnswer>
|
|
168
|
+
generate?: (input: { sessionID: string; prompt: string }) => { text: string } | Promise<{ text: string }>
|
|
169
|
+
onInboxChange?: (input: { sessionID: string; inboxID: string; action: "cancel" | "steer" | "queue" }) => void
|
|
170
|
+
onBackground?: (input: { sessionID: string }) => void
|
|
171
|
+
// Serves the session-scoped persistent PTY routes and their connect WebSockets (`e2e/utils/persistent-pty.ts`).
|
|
172
|
+
// Without it, the server has a working daemon and no terminals; `capability: false` makes the routes answer 503.
|
|
173
|
+
persistentPty?: MockPersistentPtyConfig
|
|
174
|
+
// Answers 500 InvalidDirectory when a request names a directory this server does not own.
|
|
175
|
+
strictDirectory?: boolean
|
|
176
|
+
// Answers 401 UnauthorizedError unless a request carries this password; a function may change it mid-test.
|
|
177
|
+
password?: Resolvable<string>
|
|
178
|
+
// Serves GET /auth/connect/:code: `code` redeems once for `token` (send it as the password); others answer 401.
|
|
179
|
+
pairing?: { code: string; token: string }
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// The page relays events as opaque values.
|
|
183
|
+
type MockStream = { push: (payloads: readonly unknown[]) => void }
|
|
184
|
+
|
|
185
|
+
type MockStreamState = {
|
|
186
|
+
controller?: ReadableStreamDefaultController<Uint8Array>
|
|
187
|
+
buffer: string[]
|
|
188
|
+
connections: number
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// The `installSseTransport` command that delivers events.
|
|
192
|
+
type MockSendCommand = { type: "send"; deliveries: { payload: unknown }[]; burst: boolean }
|
|
193
|
+
|
|
194
|
+
type MockStreamWindow = Window & {
|
|
195
|
+
// Set to any value by a harness that brings its own event stream, such as the strobe benchmarks' event source.
|
|
196
|
+
__testSseTransport?: unknown
|
|
197
|
+
// `installSseTransport` registrations.
|
|
198
|
+
__testSseTransports?: Record<string, { command: (input: MockSendCommand) => void }>
|
|
199
|
+
// Per-origin mock event streams, which `push` delivers through.
|
|
200
|
+
__mockServerStreams?: Record<string, MockStream>
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export async function mockOpenCodeServer(page: Page, config: MockServerConfig) {
|
|
204
|
+
const server = config.server ?? SERVER
|
|
205
|
+
|
|
206
|
+
mockedOrigins(page).add(server)
|
|
207
|
+
|
|
208
|
+
await page.addInitScript(
|
|
209
|
+
({ server, retry, keepalive: idle }) => {
|
|
210
|
+
// SAFETY: only this script, `installSseTransport`, and the benchmarks' event source write these globals, in the declared shapes.
|
|
211
|
+
const host = window as MockStreamWindow
|
|
212
|
+
|
|
213
|
+
if (host.__testSseTransport || host.__testSseTransports?.[server] || host.__mockServerStreams?.[server]) return
|
|
214
|
+
const originalFetch = window.fetch.bind(window)
|
|
215
|
+
const encoder = new TextEncoder()
|
|
216
|
+
const state: MockStreamState = { buffer: [], connections: 0 }
|
|
217
|
+
const frame = (data: string) => `data: ${data}\n\n`
|
|
218
|
+
|
|
219
|
+
const stream: MockStream = {
|
|
220
|
+
push(payloads) {
|
|
221
|
+
const frames = payloads.map((payload) => frame(JSON.stringify(payload)))
|
|
222
|
+
const controller = state.controller
|
|
223
|
+
|
|
224
|
+
if (!controller) {
|
|
225
|
+
state.buffer.push(...frames)
|
|
226
|
+
|
|
227
|
+
return
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
frames.forEach((item) => controller.enqueue(encoder.encode(item)))
|
|
231
|
+
},
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
host.__mockServerStreams = { ...host.__mockServerStreams, [server]: stream }
|
|
235
|
+
|
|
236
|
+
const fetch = (input: RequestInfo | URL, init?: RequestInit) => {
|
|
237
|
+
const request = new Request(input, init)
|
|
238
|
+
const url = new URL(request.url)
|
|
239
|
+
|
|
240
|
+
if (url.origin !== server || url.pathname !== "/api/event") return originalFetch(request)
|
|
241
|
+
state.connections += 1
|
|
242
|
+
const id = state.connections
|
|
243
|
+
let ended = false
|
|
244
|
+
let own: ReadableStreamDefaultController<Uint8Array> | undefined
|
|
245
|
+
let keepalive: ReturnType<typeof setInterval> | undefined
|
|
246
|
+
|
|
247
|
+
const body = new ReadableStream<Uint8Array>({
|
|
248
|
+
start(controller) {
|
|
249
|
+
own = controller
|
|
250
|
+
state.controller = controller
|
|
251
|
+
|
|
252
|
+
if (retry !== undefined) controller.enqueue(encoder.encode(`retry: ${retry}\n\n`))
|
|
253
|
+
controller.enqueue(
|
|
254
|
+
encoder.encode(
|
|
255
|
+
frame(JSON.stringify({ id: `evt_mock_connected_${id}`, type: "server.connected", data: {} })),
|
|
256
|
+
),
|
|
257
|
+
)
|
|
258
|
+
state.buffer.splice(0).forEach((item) => controller.enqueue(encoder.encode(item)))
|
|
259
|
+
|
|
260
|
+
// Match the real server's idle stream so long scenarios do not
|
|
261
|
+
// trigger the client's 45-second stall watchdog and reload history.
|
|
262
|
+
if (idle) keepalive = setInterval(() => controller.enqueue(encoder.encode(": keepalive\n\n")), 15_000)
|
|
263
|
+
request.signal.addEventListener(
|
|
264
|
+
"abort",
|
|
265
|
+
() => {
|
|
266
|
+
if (ended) return
|
|
267
|
+
ended = true
|
|
268
|
+
clearInterval(keepalive)
|
|
269
|
+
|
|
270
|
+
if (state.controller === controller) state.controller = undefined
|
|
271
|
+
controller.error(request.signal.reason ?? new DOMException("The operation was aborted", "AbortError"))
|
|
272
|
+
},
|
|
273
|
+
{ once: true },
|
|
274
|
+
)
|
|
275
|
+
},
|
|
276
|
+
cancel() {
|
|
277
|
+
if (ended) return
|
|
278
|
+
ended = true
|
|
279
|
+
clearInterval(keepalive)
|
|
280
|
+
|
|
281
|
+
if (state.controller === own) state.controller = undefined
|
|
282
|
+
},
|
|
283
|
+
})
|
|
284
|
+
|
|
285
|
+
return Promise.resolve(
|
|
286
|
+
new Response(body, {
|
|
287
|
+
status: 200,
|
|
288
|
+
headers: { "cache-control": "no-cache", "content-type": "text/event-stream" },
|
|
289
|
+
}),
|
|
290
|
+
)
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
Object.defineProperty(window, "fetch", { configurable: true, writable: true, value: fetch })
|
|
294
|
+
},
|
|
295
|
+
{ server, retry: config.eventRetry, keepalive: config.keepalive !== false },
|
|
296
|
+
)
|
|
297
|
+
|
|
298
|
+
// Delivers events on this server's mock stream; buffered until the app connects.
|
|
299
|
+
// An origin served by an SSE transport receives the events as one burst on its active connection.
|
|
300
|
+
const push = (payloads: readonly MockServerEvent[]) =>
|
|
301
|
+
page.evaluate<void, { server: string; payloads: readonly unknown[] }>(
|
|
302
|
+
({ server, payloads }) => {
|
|
303
|
+
// SAFETY: only the init script, `installSseTransport`, and the benchmarks' event source write these globals, in the declared shapes.
|
|
304
|
+
const host = window as MockStreamWindow
|
|
305
|
+
const stream = host.__mockServerStreams?.[server]
|
|
306
|
+
|
|
307
|
+
if (stream) return stream.push(payloads)
|
|
308
|
+
const transport = host.__testSseTransports?.[server]
|
|
309
|
+
|
|
310
|
+
if (!transport) throw new Error(`No mock event stream for ${server}`)
|
|
311
|
+
transport.command({ type: "send", deliveries: payloads.map((payload) => ({ payload })), burst: true })
|
|
312
|
+
},
|
|
313
|
+
{ server, payloads },
|
|
314
|
+
)
|
|
315
|
+
|
|
316
|
+
// Server-side events the mock publishes itself; delivery failures other than a missing document fail the test.
|
|
317
|
+
const emit = (events: MockServerEvent[]) =>
|
|
318
|
+
void push(events).catch((cause: unknown) => {
|
|
319
|
+
if (page.isClosed() || retryableDelivery(cause)) return
|
|
320
|
+
throw cause
|
|
321
|
+
})
|
|
322
|
+
|
|
323
|
+
if (config.events) {
|
|
324
|
+
// Batches stay queued until the page accepts them; failures other than a missing document fail the test.
|
|
325
|
+
const pending: OpenCodeEvent[] = []
|
|
326
|
+
const pump = { busy: false, pending }
|
|
327
|
+
|
|
328
|
+
const timer = setInterval(() => {
|
|
329
|
+
if (pump.busy) return
|
|
330
|
+
pump.pending.push(...(config.events?.() ?? []))
|
|
331
|
+
|
|
332
|
+
if (pump.pending.length === 0) return
|
|
333
|
+
pump.busy = true
|
|
334
|
+
const batch = pump.pending.slice()
|
|
335
|
+
void push(batch)
|
|
336
|
+
.then(
|
|
337
|
+
() => {
|
|
338
|
+
pump.pending.splice(0, batch.length)
|
|
339
|
+
},
|
|
340
|
+
(cause: unknown) => {
|
|
341
|
+
if (page.isClosed()) return clearInterval(timer)
|
|
342
|
+
|
|
343
|
+
if (retryableDelivery(cause)) return
|
|
344
|
+
clearInterval(timer)
|
|
345
|
+
throw cause
|
|
346
|
+
},
|
|
347
|
+
)
|
|
348
|
+
.finally(() => {
|
|
349
|
+
pump.busy = false
|
|
350
|
+
})
|
|
351
|
+
}, 50)
|
|
352
|
+
|
|
353
|
+
page.on("close", () => clearInterval(timer))
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
const transport = createMockServerHandler(config, emit)
|
|
357
|
+
page.on("close", () => void transport.dispose())
|
|
358
|
+
|
|
359
|
+
await page.route("**/api/**", async (route) => {
|
|
360
|
+
const url = new URL(route.request().url())
|
|
361
|
+
|
|
362
|
+
if (!answers(page, server, url)) return route.fallback()
|
|
363
|
+
|
|
364
|
+
// Production serves the UI and API from one origin; leave app assets to Vite.
|
|
365
|
+
if (!url.pathname.startsWith("/api/")) return route.fallback()
|
|
366
|
+
|
|
367
|
+
if (route.request().method() === "OPTIONS") {
|
|
368
|
+
return route.fulfill({ status: 204, headers: corsHeaders })
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
const password = config.password === undefined ? undefined : resolve(config.password)
|
|
372
|
+
|
|
373
|
+
if (
|
|
374
|
+
password !== undefined &&
|
|
375
|
+
(await route.request().headerValue("authorization")) !== `Basic ${btoa(`opencode:${password}`)}`
|
|
376
|
+
) {
|
|
377
|
+
return route.fulfill({
|
|
378
|
+
status: 401,
|
|
379
|
+
headers: corsHeaders,
|
|
380
|
+
json: Schema.encodeSync(MockUnauthorized)(new MockUnauthorized({ message: "Authentication required" })),
|
|
381
|
+
})
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
const directory = url.searchParams.get("directory") ?? url.searchParams.get("location[directory]")
|
|
385
|
+
|
|
386
|
+
if (config.strictDirectory && directory && !ownedDirectories(config).has(directory)) {
|
|
387
|
+
return route.fulfill({ status: 500, headers: corsHeaders, json: { name: "InvalidDirectory" } })
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
const body = route.request().postDataBuffer()
|
|
391
|
+
|
|
392
|
+
const response = await transport.handler(
|
|
393
|
+
new Request(url, {
|
|
394
|
+
method: route.request().method(),
|
|
395
|
+
headers: route.request().headers(),
|
|
396
|
+
body: body ? Uint8Array.from(body) : undefined,
|
|
397
|
+
}),
|
|
398
|
+
)
|
|
399
|
+
|
|
400
|
+
const payload = Buffer.from(await response.arrayBuffer())
|
|
401
|
+
|
|
402
|
+
// A handler's 404 carries a tagged error; a route the mock does not define must not reach the app server, whose
|
|
403
|
+
// SPA fallback would answer HTML 200. Answer 501 and fail the test from the route handler.
|
|
404
|
+
if (response.status === 404 && !payload.toString().includes('"_tag"')) {
|
|
405
|
+
const request = `${route.request().method()} ${url.pathname}`
|
|
406
|
+
await route.fulfill({
|
|
407
|
+
status: 501,
|
|
408
|
+
headers: corsHeaders,
|
|
409
|
+
json: { name: "MockUnsupported", message: `The mock server has no route for ${request}` },
|
|
410
|
+
})
|
|
411
|
+
throw new Error(`Unmocked API request: ${request} (add it to e2e/utils/mock-server.ts)`)
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
return route.fulfill({
|
|
415
|
+
status: response.status,
|
|
416
|
+
headers: { ...Object.fromEntries(response.headers), ...corsHeaders },
|
|
417
|
+
body: payload,
|
|
418
|
+
})
|
|
419
|
+
})
|
|
420
|
+
|
|
421
|
+
if (config.pairing) {
|
|
422
|
+
const pairing = { ...config.pairing, redeemed: false }
|
|
423
|
+
|
|
424
|
+
await page.route(`${server}/auth/connect/*`, (route) => {
|
|
425
|
+
if (route.request().method() === "OPTIONS") return route.fulfill({ status: 204, headers: corsHeaders })
|
|
426
|
+
const code = decodeURIComponent(new URL(route.request().url()).pathname.split("/").at(-1) ?? "")
|
|
427
|
+
|
|
428
|
+
if (code !== pairing.code || pairing.redeemed) {
|
|
429
|
+
return route.fulfill({
|
|
430
|
+
status: 401,
|
|
431
|
+
headers: corsHeaders,
|
|
432
|
+
json: Schema.encodeSync(MockUnauthorized)(
|
|
433
|
+
new MockUnauthorized({ message: "Pairing link expired or already used" }),
|
|
434
|
+
),
|
|
435
|
+
})
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
pairing.redeemed = true
|
|
439
|
+
|
|
440
|
+
return route.fulfill({ headers: corsHeaders, json: { token: pairing.token } })
|
|
441
|
+
})
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
const host = new URL(server).host
|
|
445
|
+
await page.routeWebSocket(
|
|
446
|
+
(url) => url.host === host && /^\/api\/experimental\/persistent-pty\/[^/]+\/connect$/.test(url.pathname),
|
|
447
|
+
(ws) => transport.persistentPty.connect(ws),
|
|
448
|
+
)
|
|
449
|
+
|
|
450
|
+
return { server, persistentPty: transport.persistentPty, push }
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
// Answers every Location-scoped request for `directory` as the server does once that folder is deleted.
|
|
454
|
+
export function mockMissingLocation(page: Page, directory: string) {
|
|
455
|
+
return page.route(
|
|
456
|
+
(url) => url.pathname.startsWith("/api/") && url.searchParams.get("location[directory]") === directory,
|
|
457
|
+
(route) =>
|
|
458
|
+
route.fulfill({
|
|
459
|
+
status: 404,
|
|
460
|
+
// SAFETY: the server's wire body for a missing Location, which the client decodes into its own error.
|
|
461
|
+
// oxlint-disable-next-line anti-slop-effect/no-manual-tagged-construction -- see SAFETY above
|
|
462
|
+
json: { _tag: "LocationNotFoundError", location: { directory }, message: `Location not found: ${directory}` },
|
|
463
|
+
headers: { "access-control-allow-origin": "*" },
|
|
464
|
+
}),
|
|
465
|
+
)
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
// Answers the first model list as a cold Location does when its plugins outlast the server's wait.
|
|
469
|
+
export function mockPluginsActivating(page: Page) {
|
|
470
|
+
const pending = { model: true }
|
|
471
|
+
|
|
472
|
+
return page.route(/\/api\/model(\?|$)/, (route) => {
|
|
473
|
+
if (!pending.model) return route.fallback()
|
|
474
|
+
pending.model = false
|
|
475
|
+
|
|
476
|
+
return route.fulfill({
|
|
477
|
+
status: 503,
|
|
478
|
+
// SAFETY: the server's wire body for a plugin wait timeout, which the client decodes into its own error.
|
|
479
|
+
json: {
|
|
480
|
+
// oxlint-disable-next-line anti-slop-effect/no-manual-tagged-construction -- see SAFETY above
|
|
481
|
+
_tag: "ServiceUnavailableError",
|
|
482
|
+
message: "Location plugins did not finish activating",
|
|
483
|
+
service: "plugin",
|
|
484
|
+
},
|
|
485
|
+
headers: { "access-control-allow-origin": "*" },
|
|
486
|
+
})
|
|
487
|
+
})
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
// Mocks several servers on one page. Each origin gets its own handler and its own SSE transport for events.
|
|
491
|
+
export async function mockServers(page: Page, servers: Record<string, Omit<MockServerConfig, "server" | "events">>) {
|
|
492
|
+
return Object.fromEntries(
|
|
493
|
+
await Promise.all(
|
|
494
|
+
Object.entries(servers).map(async ([origin, config]) => {
|
|
495
|
+
const transport = await installSseTransport(page, {
|
|
496
|
+
server: origin,
|
|
497
|
+
retry: config.eventRetry,
|
|
498
|
+
keepalive: config.keepalive,
|
|
499
|
+
})
|
|
500
|
+
|
|
501
|
+
const mock = await mockOpenCodeServer(page, { ...config, server: origin })
|
|
502
|
+
|
|
503
|
+
return [origin, { transport, persistentPty: mock.persistentPty }] as const
|
|
504
|
+
}),
|
|
505
|
+
),
|
|
506
|
+
)
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
// `emit` publishes the events a real server sends after a mutation (without a page, nothing is published).
|
|
510
|
+
function createMockServerHandler(config: MockServerConfig, emit: (events: MockServerEvent[]) => void = () => {}) {
|
|
511
|
+
const persistentPty = createPersistentPty({ config: config.persistentPty, directory: config.directory }, emit)
|
|
512
|
+
|
|
513
|
+
const web = HttpRouter.toWebHandler(
|
|
514
|
+
HttpApiBuilder.layer(MockApi).pipe(
|
|
515
|
+
Layer.provide(
|
|
516
|
+
mockHandlers(config, {
|
|
517
|
+
cursors: new Map<string, string>(),
|
|
518
|
+
nextCursor: 0,
|
|
519
|
+
sessionCreates: 0,
|
|
520
|
+
persistentPty,
|
|
521
|
+
emit,
|
|
522
|
+
mcp: new Map<string, MockMcpStatus>(),
|
|
523
|
+
attempts: new Map<string, number>(),
|
|
524
|
+
}),
|
|
525
|
+
),
|
|
526
|
+
Layer.provide(HttpServer.layerServices),
|
|
527
|
+
),
|
|
528
|
+
{ disableLogger: true },
|
|
529
|
+
)
|
|
530
|
+
|
|
531
|
+
return { ...web, persistentPty }
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
const corsHeaders = {
|
|
535
|
+
"access-control-allow-origin": "*",
|
|
536
|
+
"access-control-allow-headers": "*",
|
|
537
|
+
"access-control-allow-methods": "GET, POST, PUT, PATCH, DELETE, OPTIONS",
|
|
538
|
+
"access-control-expose-headers": "x-next-cursor",
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
const APP_ORIGIN = new URL(
|
|
542
|
+
process.env.PLAYWRIGHT_BASE_URL ?? `http://127.0.0.1:${process.env.PLAYWRIGHT_PORT ?? "3000"}`,
|
|
543
|
+
).origin
|
|
544
|
+
|
|
545
|
+
const registeredOrigins = new WeakMap<Page, Set<string>>()
|
|
546
|
+
|
|
547
|
+
function mockedOrigins(page: Page) {
|
|
548
|
+
const found = registeredOrigins.get(page)
|
|
549
|
+
|
|
550
|
+
if (found) return found
|
|
551
|
+
const created = new Set<string>()
|
|
552
|
+
registeredOrigins.set(page, created)
|
|
553
|
+
|
|
554
|
+
return created
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
// A server answers its own origin. Production builds call the API on the app origin, which the default server also
|
|
558
|
+
// answers unless a server was configured for the app origin explicitly.
|
|
559
|
+
function answers(page: Page, server: string, url: URL) {
|
|
560
|
+
if (url.origin === server) return true
|
|
561
|
+
|
|
562
|
+
return server === SERVER && url.origin === APP_ORIGIN && !mockedOrigins(page).has(APP_ORIGIN)
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
// The document is not loaded yet or is being replaced; the pump retries on its next tick.
|
|
566
|
+
function retryableDelivery(cause: unknown) {
|
|
567
|
+
const message = cause instanceof Error ? cause.message : String(cause)
|
|
568
|
+
|
|
569
|
+
return [
|
|
570
|
+
"No mock event stream",
|
|
571
|
+
"Execution context was destroyed",
|
|
572
|
+
"Target page, context or browser has been closed",
|
|
573
|
+
].some((text) => message.includes(text))
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
// Every directory this server's configuration names: its own, project and inventory worktrees, and session locations.
|
|
577
|
+
function ownedDirectories(config: MockServerConfig) {
|
|
578
|
+
const projects = [config.project, ...(config.projects ? resolve(config.projects) : [])].flatMap((item) =>
|
|
579
|
+
Option.toArray(decodeProject(item)),
|
|
580
|
+
)
|
|
581
|
+
|
|
582
|
+
return new Set(
|
|
583
|
+
[
|
|
584
|
+
config.directory,
|
|
585
|
+
...projects.flatMap((item) => [item.worktree, item.canonical, ...(item.sandboxes ?? [])]),
|
|
586
|
+
...(config.worktrees ? resolve(config.worktrees) : []).filter(Predicate.isObject).map((item) => item.directory),
|
|
587
|
+
...config.sessions.map((session) =>
|
|
588
|
+
Predicate.isObject(session.location) ? session.location.directory : session.directory,
|
|
589
|
+
),
|
|
590
|
+
].filter(Predicate.isString),
|
|
591
|
+
)
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
function addSandbox(config: MockServerConfig, directory: string) {
|
|
595
|
+
// SAFETY: a scenario that creates worktrees seeds its project as an object whose `sandboxes` lists directories.
|
|
596
|
+
const project = config.project as { sandboxes?: string[] }
|
|
597
|
+
|
|
598
|
+
if (project.sandboxes?.includes(directory)) return
|
|
599
|
+
project.sandboxes = [...(project.sandboxes ?? []), directory]
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
// The requested `location[directory]`; absent or empty (a server-level read) means the server directory.
|
|
603
|
+
function requestDirectory(config: MockServerConfig, request: { url: string }) {
|
|
604
|
+
return new URL(request.url, "http://localhost").searchParams.get("location[directory]") || config.directory
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
function resolve<T>(value: Resolvable<T>) {
|
|
608
|
+
// SAFETY: no resolvable scenario value is itself a function, so a function is the value's resolver.
|
|
609
|
+
return Predicate.isFunction(value) ? (value as () => T)() : value
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
function mockHandlers(
|
|
613
|
+
config: MockServerConfig,
|
|
614
|
+
state: {
|
|
615
|
+
cursors: Map<string, string>
|
|
616
|
+
nextCursor: number
|
|
617
|
+
sessionCreates: number
|
|
618
|
+
persistentPty: ReturnType<typeof createPersistentPty>
|
|
619
|
+
emit: (events: MockServerEvent[]) => void
|
|
620
|
+
// MCP status overrides by `<directory>\n<server>`, and OAuth attempt creation times by attempt ID.
|
|
621
|
+
mcp: Map<string, MockMcpStatus>
|
|
622
|
+
attempts: Map<string, number>
|
|
623
|
+
},
|
|
624
|
+
) {
|
|
625
|
+
const noContent = Effect.succeed(HttpApiSchema.NoContent.make())
|
|
626
|
+
const configEntries = config.configEntries ?? []
|
|
627
|
+
|
|
628
|
+
// Without a persistent PTY config the mock is a server with a working daemon and no terminals, since the desktop
|
|
629
|
+
// lists a session's terminals whenever its side panel renders.
|
|
630
|
+
const persistentPtyEnabled = Effect.suspend(() =>
|
|
631
|
+
state.persistentPty.capability !== false
|
|
632
|
+
? Effect.void
|
|
633
|
+
: Effect.fail(new MockServiceUnavailable({ message: "opencode-pty is not available", service: "opencode-pty" })),
|
|
634
|
+
)
|
|
635
|
+
|
|
636
|
+
const findPersistentPty = (id: string) =>
|
|
637
|
+
persistentPtyEnabled.pipe(
|
|
638
|
+
Effect.andThen(() =>
|
|
639
|
+
Effect.suspend(() => {
|
|
640
|
+
const found = state.persistentPty.find(id)
|
|
641
|
+
|
|
642
|
+
return found
|
|
643
|
+
? Effect.succeed(found)
|
|
644
|
+
: Effect.fail(new MockPtyNotFound({ ptyID: id, message: `PTY session not found: ${id}` }))
|
|
645
|
+
}),
|
|
646
|
+
),
|
|
647
|
+
)
|
|
648
|
+
|
|
649
|
+
const mcpServers = (directory: string) =>
|
|
650
|
+
(Predicate.isFunction(config.mcp) ? config.mcp(directory) : (config.mcp ?? [])).map((server) => {
|
|
651
|
+
if (!Predicate.isObject(server)) return server
|
|
652
|
+
const status = state.mcp.get(`${directory}\n${String(server.name)}`)
|
|
653
|
+
|
|
654
|
+
return status ? { ...server, status } : server
|
|
655
|
+
})
|
|
656
|
+
|
|
657
|
+
const mcpAction = (server: string, action: "connect" | "disconnect", request: { url: string }) =>
|
|
658
|
+
Effect.suspend(() => {
|
|
659
|
+
const directory = requestDirectory(config, request)
|
|
660
|
+
|
|
661
|
+
if (!mcpServers(directory).some((item) => Predicate.isObject(item) && item.name === server))
|
|
662
|
+
return Effect.fail(new MockNotFound({ message: `MCP server ${server} not found` }))
|
|
663
|
+
|
|
664
|
+
const status = config.onMcpAction?.({ server, action, directory }) ?? {
|
|
665
|
+
status: action === "connect" ? "connected" : "disabled",
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
state.mcp.set(`${directory}\n${server}`, status)
|
|
669
|
+
|
|
670
|
+
return noContent
|
|
671
|
+
})
|
|
672
|
+
|
|
673
|
+
const unsupported = (operation: string, handler: string) =>
|
|
674
|
+
Effect.fail(
|
|
675
|
+
new MockUnsupported({ message: `The mock server does not ${operation}; configure ${handler} for this scenario` }),
|
|
676
|
+
)
|
|
677
|
+
|
|
678
|
+
return HttpApiBuilder.group(MockApi, "mock", (handlers) =>
|
|
679
|
+
handlers
|
|
680
|
+
.handleRaw("event", () => {
|
|
681
|
+
const events = config.events?.()
|
|
682
|
+
const retry = config.eventRetry === undefined ? "" : `retry: ${config.eventRetry}\n\n`
|
|
683
|
+
|
|
684
|
+
const body = [{ id: "evt_mock_connected", type: "server.connected", data: {} }, ...(events ?? [])]
|
|
685
|
+
.map((event) => `data: ${JSON.stringify(event)}\n\n`)
|
|
686
|
+
.join("")
|
|
687
|
+
|
|
688
|
+
return Effect.succeed(HttpServerResponse.text(retry + body, { contentType: "text/event-stream" }))
|
|
689
|
+
})
|
|
690
|
+
.handleRaw("fsRead", (ctx) =>
|
|
691
|
+
Effect.gen(function* () {
|
|
692
|
+
const path = decodeURIComponent(new URL(ctx.request.url, "http://localhost").pathname.slice(13))
|
|
693
|
+
const value = yield* Effect.promise(() => Promise.resolve(config.fileContent?.(path)))
|
|
694
|
+
|
|
695
|
+
// Like the server, every read is a sandboxed download; media keeps its type so elements can play it.
|
|
696
|
+
const options = {
|
|
697
|
+
contentType: ["image", "audio", "video"].includes(artifactKind(path))
|
|
698
|
+
? artifactMime(path)
|
|
699
|
+
: "application/octet-stream",
|
|
700
|
+
headers: {
|
|
701
|
+
"content-disposition": "attachment",
|
|
702
|
+
"content-security-policy": "default-src 'none'; img-src 'self'; media-src 'self'; sandbox",
|
|
703
|
+
"x-content-type-options": "nosniff",
|
|
704
|
+
},
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
if (Predicate.isString(value)) return HttpServerResponse.uint8Array(new TextEncoder().encode(value), options)
|
|
708
|
+
|
|
709
|
+
// Like the server, stream base64 content as the bytes it encodes.
|
|
710
|
+
return HttpServerResponse.uint8Array(
|
|
711
|
+
value?.encoding === "base64"
|
|
712
|
+
? Buffer.from(value.content, "base64")
|
|
713
|
+
: new TextEncoder().encode(value?.content ?? ""),
|
|
714
|
+
options,
|
|
715
|
+
)
|
|
716
|
+
}),
|
|
717
|
+
)
|
|
718
|
+
// Serves a listed skill's inline content as its SKILL.md.
|
|
719
|
+
.handleRaw("skillFile", (ctx) =>
|
|
720
|
+
Effect.sync(() => {
|
|
721
|
+
const path = `skill://${decodeURIComponent(new URL(ctx.request.url, "http://localhost").pathname.slice("/api/experimental/skill/".length)).replace("/file/", "/")}`
|
|
722
|
+
|
|
723
|
+
const skill = resolve(config.skills ?? []).find(
|
|
724
|
+
(item) => Predicate.hasProperty(item, "path") && item.path === path,
|
|
725
|
+
)
|
|
726
|
+
|
|
727
|
+
if (Predicate.hasProperty(skill, "content") && Predicate.isString(skill.content))
|
|
728
|
+
return HttpServerResponse.uint8Array(new TextEncoder().encode(skill.content))
|
|
729
|
+
|
|
730
|
+
return HttpServerResponse.jsonUnsafe(
|
|
731
|
+
// SAFETY: the server's wire body for a missing file, which the client decodes into its own error.
|
|
732
|
+
// oxlint-disable-next-line anti-slop-effect/no-manual-tagged-construction -- see SAFETY above
|
|
733
|
+
{ _tag: "FileNotFoundError", path, message: `File not found: ${path}` },
|
|
734
|
+
{ status: 404 },
|
|
735
|
+
)
|
|
736
|
+
}),
|
|
737
|
+
)
|
|
738
|
+
// Raw, so a hook's answer can replace the status and body.
|
|
739
|
+
.handleRaw("worktreeCreate", (ctx) =>
|
|
740
|
+
Effect.gen(function* () {
|
|
741
|
+
const create = config.onWorktreeCreate
|
|
742
|
+
|
|
743
|
+
if (!create) return yield* unsupported("create worktrees", "onWorktreeCreate")
|
|
744
|
+
|
|
745
|
+
const input = yield* Effect.orDie(
|
|
746
|
+
ctx.request.json.pipe(Effect.flatMap(Schema.decodeUnknownEffect(Schema.Json))),
|
|
747
|
+
)
|
|
748
|
+
|
|
749
|
+
const payload = Option.getOrUndefined(decodeWorktreeRequest(input))
|
|
750
|
+
|
|
751
|
+
const answer = (yield* Effect.promise(async () => create(input))) || {
|
|
752
|
+
status: 200,
|
|
753
|
+
body: { directory: `${payload?.directory ?? config.directory}/${payload?.name ?? "copy"}` },
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
const created = answer.status === 200 ? decodeWorktreeAnswer(answer.body) : Option.none()
|
|
757
|
+
|
|
758
|
+
if (Option.isSome(created)) addSandbox(config, created.value.directory)
|
|
759
|
+
|
|
760
|
+
return HttpServerResponse.jsonUnsafe(answer.body, { status: answer.status })
|
|
761
|
+
}),
|
|
762
|
+
)
|
|
763
|
+
.handleRaw("sessionCreate", (ctx) =>
|
|
764
|
+
Effect.gen(function* () {
|
|
765
|
+
const input = yield* Effect.orDie(ctx.request.json)
|
|
766
|
+
const payload = Option.getOrElse(decodeJsonObject(input), () => ({}))
|
|
767
|
+
const fields = Option.getOrUndefined(decodeSessionCreate(payload))
|
|
768
|
+
state.sessionCreates += 1
|
|
769
|
+
const attempt = state.sessionCreates
|
|
770
|
+
const answer = yield* Effect.promise(async () => config.onSessionCreate?.(payload, attempt))
|
|
771
|
+
|
|
772
|
+
if (answer) return HttpServerResponse.jsonUnsafe(answer.body, { status: answer.status })
|
|
773
|
+
|
|
774
|
+
const created = currentSession(
|
|
775
|
+
{
|
|
776
|
+
...payload,
|
|
777
|
+
id: fields?.id ?? "ses_mock_created",
|
|
778
|
+
projectID: projectSeed(config)?.id,
|
|
779
|
+
title: config.createdSessionTitle ?? fields?.title ?? "New session",
|
|
780
|
+
parentID: fields?.parentID,
|
|
781
|
+
},
|
|
782
|
+
config.directory,
|
|
783
|
+
)
|
|
784
|
+
|
|
785
|
+
config.sessions.push(created)
|
|
786
|
+
|
|
787
|
+
return HttpServerResponse.jsonUnsafe({ data: created })
|
|
788
|
+
}),
|
|
789
|
+
)
|
|
790
|
+
.handleRaw("sessionFork", (ctx) =>
|
|
791
|
+
Effect.gen(function* () {
|
|
792
|
+
const input = yield* Effect.orDie(ctx.request.json)
|
|
793
|
+
const body = Option.getOrElse(decodeJsonObject(input), (): Schema.JsonObject => ({}))
|
|
794
|
+
const answer = yield* Effect.promise(async () => config.onFork?.({ sessionID: ctx.params.sessionID, body }))
|
|
795
|
+
|
|
796
|
+
if (answer) return HttpServerResponse.jsonUnsafe(answer.body, { status: answer.status })
|
|
797
|
+
|
|
798
|
+
const parent = config.sessions.find((item) => item.id === ctx.params.sessionID)
|
|
799
|
+
const id = `${ctx.params.sessionID}_fork`
|
|
800
|
+
|
|
801
|
+
const forked = currentSession(
|
|
802
|
+
{ ...parent, id, title: `${parent?.title ?? ctx.params.sessionID} (fork)` },
|
|
803
|
+
config.directory,
|
|
804
|
+
)
|
|
805
|
+
|
|
806
|
+
if (!config.sessions.some((item) => item.id === id)) config.sessions.push(forked)
|
|
807
|
+
|
|
808
|
+
return HttpServerResponse.jsonUnsafe({ data: forked })
|
|
809
|
+
}),
|
|
810
|
+
)
|
|
811
|
+
.handleAll({
|
|
812
|
+
info: () =>
|
|
813
|
+
Effect.succeed({
|
|
814
|
+
version: "2.0.0",
|
|
815
|
+
pid: 1,
|
|
816
|
+
hostname: config.hostname,
|
|
817
|
+
urls: config.server ? [config.server] : [],
|
|
818
|
+
paths: { tmp: "/tmp/opencode" },
|
|
819
|
+
capabilities:
|
|
820
|
+
state.persistentPty.capability === undefined
|
|
821
|
+
? undefined
|
|
822
|
+
: { persistentPty: state.persistentPty.capability },
|
|
823
|
+
}),
|
|
824
|
+
config: () => Effect.succeed(configEntries),
|
|
825
|
+
reference: () => Effect.succeed({ location: location(config), data: [] }),
|
|
826
|
+
// `beforeAgentsResponse` holds the Location's agent list, as a cold Location does while its plugins activate.
|
|
827
|
+
agent: (ctx) =>
|
|
828
|
+
Effect.promise(async () => config.beforeAgentsResponse?.()).pipe(
|
|
829
|
+
Effect.as({
|
|
830
|
+
location: location(config, requestDirectory(config, ctx.request)),
|
|
831
|
+
data: [
|
|
832
|
+
{
|
|
833
|
+
id: "build",
|
|
834
|
+
name: "Build",
|
|
835
|
+
mode: "primary",
|
|
836
|
+
hidden: false,
|
|
837
|
+
request: { settings: {}, headers: {}, body: {} },
|
|
838
|
+
permissions: [],
|
|
839
|
+
},
|
|
840
|
+
],
|
|
841
|
+
}),
|
|
842
|
+
),
|
|
843
|
+
provider: () =>
|
|
844
|
+
Effect.succeed({ location: location(config), data: currentProviders(resolve(config.provider)) }),
|
|
845
|
+
model: () => Effect.succeed({ location: location(config), data: currentModels(resolve(config.provider)) }),
|
|
846
|
+
modelDefault: () =>
|
|
847
|
+
Effect.succeed({ location: location(config), data: currentDefaultModel(resolve(config.provider)) }),
|
|
848
|
+
integrationList: () =>
|
|
849
|
+
Effect.sync(() => ({ location: location(config), data: resolve(config.integrations ?? []) })),
|
|
850
|
+
integrationGet: (ctx) =>
|
|
851
|
+
Effect.sync(() => ({
|
|
852
|
+
location: location(config),
|
|
853
|
+
data: resolve(config.integrations ?? [])
|
|
854
|
+
.filter(Predicate.isObject)
|
|
855
|
+
.find((integration) => integration.id === ctx.params.integrationID) ?? {
|
|
856
|
+
id: ctx.params.integrationID,
|
|
857
|
+
name: ctx.params.integrationID,
|
|
858
|
+
methods: [{ type: "key", label: "API key" }],
|
|
859
|
+
connections: [],
|
|
860
|
+
},
|
|
861
|
+
})),
|
|
862
|
+
integrationConnect: (ctx) =>
|
|
863
|
+
Effect.suspend(() => {
|
|
864
|
+
const rejected = config.onConnectKey?.({ integrationID: ctx.params.integrationID, body: ctx.payload })
|
|
865
|
+
|
|
866
|
+
if (rejected) return Effect.fail(new MockBadRequest({ message: rejected.error }))
|
|
867
|
+
|
|
868
|
+
return noContent
|
|
869
|
+
}),
|
|
870
|
+
integrationOAuthConnect: (ctx) => {
|
|
871
|
+
const start = config.onIntegrationOAuth
|
|
872
|
+
|
|
873
|
+
if (!start) return unsupported("start OAuth connections", "onIntegrationOAuth")
|
|
874
|
+
|
|
875
|
+
return Effect.sync(() => {
|
|
876
|
+
const directory = requestDirectory(config, ctx.request)
|
|
877
|
+
const created = Date.now()
|
|
878
|
+
const attemptID = `con_mock_${state.attempts.size + 1}`
|
|
879
|
+
state.attempts.set(attemptID, created)
|
|
880
|
+
const started = start({ integrationID: ctx.params.integrationID, directory, body: ctx.payload })
|
|
881
|
+
|
|
882
|
+
const data = {
|
|
883
|
+
attemptID,
|
|
884
|
+
url: started.url,
|
|
885
|
+
instructions: "",
|
|
886
|
+
mode: "auto",
|
|
887
|
+
time: { created, expires: created + 600_000 },
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
return { location: location(config, directory), data: started.paste ? { ...data, paste: true } : data }
|
|
891
|
+
})
|
|
892
|
+
},
|
|
893
|
+
integrationOAuthStatus: (ctx) =>
|
|
894
|
+
Effect.suspend(() => {
|
|
895
|
+
const created = state.attempts.get(ctx.params.attemptID)
|
|
896
|
+
|
|
897
|
+
if (created === undefined) return Effect.fail(new MockNotFound({ message: "OAuth attempt not found" }))
|
|
898
|
+
|
|
899
|
+
return Effect.succeed({
|
|
900
|
+
location: location(config, requestDirectory(config, ctx.request)),
|
|
901
|
+
data: {
|
|
902
|
+
status: config.onIntegrationOAuthStatus?.(ctx.params.attemptID) ?? "pending",
|
|
903
|
+
time: { created, expires: created + 600_000 },
|
|
904
|
+
},
|
|
905
|
+
})
|
|
906
|
+
}),
|
|
907
|
+
integrationOAuthComplete: (ctx) => {
|
|
908
|
+
const complete = config.onIntegrationOAuthComplete
|
|
909
|
+
|
|
910
|
+
if (!complete) return unsupported("complete pasted OAuth sign-ins", "onIntegrationOAuthComplete")
|
|
911
|
+
|
|
912
|
+
return Effect.sync(() => complete({ attemptID: ctx.params.attemptID, body: ctx.payload })).pipe(
|
|
913
|
+
Effect.andThen(noContent),
|
|
914
|
+
)
|
|
915
|
+
},
|
|
916
|
+
integrationOAuthCancel: (ctx) =>
|
|
917
|
+
Effect.sync(() => config.onIntegrationOAuthCancel?.(ctx.params.attemptID)).pipe(Effect.andThen(noContent)),
|
|
918
|
+
integrationConnectExternal: () => noContent,
|
|
919
|
+
credentialActivate: (ctx) =>
|
|
920
|
+
Effect.sync(() => config.onCredentialActivate?.(ctx.params.credentialID)).pipe(Effect.andThen(noContent)),
|
|
921
|
+
credentialUpdate: (ctx) =>
|
|
922
|
+
Effect.sync(() => config.onCredentialUpdate?.(ctx.params.credentialID, ctx.payload)).pipe(
|
|
923
|
+
Effect.andThen(noContent),
|
|
924
|
+
),
|
|
925
|
+
credentialRemove: () => noContent,
|
|
926
|
+
command: (ctx) =>
|
|
927
|
+
Effect.sync(() => ({
|
|
928
|
+
location: location(config, requestDirectory(config, ctx.request)),
|
|
929
|
+
data: resolve(config.commands ?? []),
|
|
930
|
+
})),
|
|
931
|
+
skill: () => Effect.sync(() => ({ location: location(config), data: resolve(config.skills ?? []) })),
|
|
932
|
+
plugin: () => Effect.sync(() => ({ location: location(config), data: resolve(config.plugins ?? []) })),
|
|
933
|
+
mcp: (ctx) =>
|
|
934
|
+
Effect.sync(() => {
|
|
935
|
+
const directory = requestDirectory(config, ctx.request)
|
|
936
|
+
|
|
937
|
+
return { location: location(config, directory), data: mcpServers(directory) }
|
|
938
|
+
}),
|
|
939
|
+
mcpConnect: (ctx) => mcpAction(ctx.params.server, "connect", ctx.request),
|
|
940
|
+
mcpDisconnect: (ctx) => mcpAction(ctx.params.server, "disconnect", ctx.request),
|
|
941
|
+
mcpResource: (ctx) =>
|
|
942
|
+
Effect.suspend(() =>
|
|
943
|
+
config.mcpResourceFailures?.()
|
|
944
|
+
? Effect.fail(new MockInternal({ message: "MCP resource list failed" }))
|
|
945
|
+
: Effect.succeed({
|
|
946
|
+
location: location(config, requestDirectory(config, ctx.request)),
|
|
947
|
+
data: { resources: [], templates: [] },
|
|
948
|
+
}),
|
|
949
|
+
),
|
|
950
|
+
projectList: () =>
|
|
951
|
+
Effect.sync(() => {
|
|
952
|
+
if (config.projects) return resolve(config.projects)
|
|
953
|
+
const seed = projectSeed(config)
|
|
954
|
+
|
|
955
|
+
return [{ ...projectFields(config), canonical: seed?.canonical ?? seed?.worktree ?? config.directory }]
|
|
956
|
+
}),
|
|
957
|
+
projectUpdate: (ctx) =>
|
|
958
|
+
Effect.succeed({
|
|
959
|
+
...projectFields(config),
|
|
960
|
+
...ctx.payload,
|
|
961
|
+
id: ctx.params.projectID,
|
|
962
|
+
canonical: projectSeed(config)?.canonical ?? config.directory,
|
|
963
|
+
}),
|
|
964
|
+
configShells: () => Effect.succeed(config.shells ?? []),
|
|
965
|
+
configUpdate: () => noContent,
|
|
966
|
+
websearchProviders: () =>
|
|
967
|
+
Effect.sync(() => ({ location: location(config), data: resolve(config.websearchProviders ?? []) })),
|
|
968
|
+
// No scenario signs in to an OpenCode Console workspace, so none has usage limits.
|
|
969
|
+
usageLimits: () => Effect.succeed({ location: location(config), data: null }),
|
|
970
|
+
// No scenario runs background jobs (Code Mode scripts or subagent work), so none is running.
|
|
971
|
+
jobList: () => Effect.succeed({ data: [] }),
|
|
972
|
+
worktreeList: () =>
|
|
973
|
+
Effect.sync(() => {
|
|
974
|
+
if (config.worktrees) return resolve(config.worktrees)
|
|
975
|
+
|
|
976
|
+
return [
|
|
977
|
+
{ directory: config.directory },
|
|
978
|
+
...(projectSeed(config)?.sandboxes ?? []).map((directory) => ({
|
|
979
|
+
directory,
|
|
980
|
+
strategy: "git",
|
|
981
|
+
})),
|
|
982
|
+
]
|
|
983
|
+
}),
|
|
984
|
+
worktreeRemove: (ctx) => {
|
|
985
|
+
const remove = config.onWorktreeRemove
|
|
986
|
+
|
|
987
|
+
if (!remove) return unsupported("remove worktrees", "onWorktreeRemove")
|
|
988
|
+
|
|
989
|
+
return Effect.promise(async () => remove(ctx.payload)).pipe(Effect.andThen(noContent))
|
|
990
|
+
},
|
|
991
|
+
// Discovery against a static inventory changes nothing, and the app refreshes whenever worktree settings open.
|
|
992
|
+
worktreeRefresh: () => noContent,
|
|
993
|
+
location: (ctx) =>
|
|
994
|
+
Effect.sync(() => {
|
|
995
|
+
const requested = new URL(ctx.request.url, "http://localhost").searchParams.get("location[directory]")
|
|
996
|
+
|
|
997
|
+
if (requested) config.onLocationGet?.(requested)
|
|
998
|
+
|
|
999
|
+
return location(config, requested || config.directory)
|
|
1000
|
+
}),
|
|
1001
|
+
permissionRequests: () =>
|
|
1002
|
+
Effect.suspend(() =>
|
|
1003
|
+
config.permissionListFailures?.()
|
|
1004
|
+
? Effect.fail(new MockInternal({ message: "Permission list failed" }))
|
|
1005
|
+
: Effect.succeed({
|
|
1006
|
+
location: location(config),
|
|
1007
|
+
data: currentPermissions(resolve(config.permissions ?? [])),
|
|
1008
|
+
}),
|
|
1009
|
+
),
|
|
1010
|
+
formRequests: () => Effect.succeed({ location: location(config), data: resolve(config.forms ?? []) }),
|
|
1011
|
+
vcs: (ctx) =>
|
|
1012
|
+
Effect.succeed({
|
|
1013
|
+
location: location(config, requestDirectory(config, ctx.request)),
|
|
1014
|
+
data: {
|
|
1015
|
+
branch: Predicate.isFunction(config.vcs)
|
|
1016
|
+
? config.vcs(requestDirectory(config, ctx.request))
|
|
1017
|
+
: (config.vcs ?? { current: "main", default: "main" }),
|
|
1018
|
+
},
|
|
1019
|
+
}),
|
|
1020
|
+
vcsInit: (ctx) => {
|
|
1021
|
+
if (!config.onVcsInit) return unsupported("initialize VCS", "onVcsInit")
|
|
1022
|
+
|
|
1023
|
+
return Effect.sync(() => {
|
|
1024
|
+
const url = new URL(ctx.request.url, "http://localhost")
|
|
1025
|
+
const provider = url.searchParams.get("provider") ?? undefined
|
|
1026
|
+
config.onVcsInit?.({ directory: requestDirectory(config, ctx.request), provider })
|
|
1027
|
+
// SAFETY: a scenario that initializes VCS seeds its project as an object with an ID.
|
|
1028
|
+
const project = config.project as { id: string; vcs?: string }
|
|
1029
|
+
project.vcs = provider ?? "git"
|
|
1030
|
+
state.emit([
|
|
1031
|
+
{
|
|
1032
|
+
id: "evt_vcs_initialized",
|
|
1033
|
+
type: "worktree.updated",
|
|
1034
|
+
created: Date.now(),
|
|
1035
|
+
data: { projectID: project.id },
|
|
1036
|
+
},
|
|
1037
|
+
])
|
|
1038
|
+
}).pipe(Effect.andThen(noContent))
|
|
1039
|
+
},
|
|
1040
|
+
vcsStatus: () => Effect.succeed({ location: location(config), data: [] }),
|
|
1041
|
+
vcsBranches: (ctx) => {
|
|
1042
|
+
const query = new URL(ctx.request.url, "http://localhost").searchParams
|
|
1043
|
+
const search = query.get("search") ?? ""
|
|
1044
|
+
const limit = Number(query.get("limit") ?? 50)
|
|
1045
|
+
|
|
1046
|
+
return Effect.promise(() =>
|
|
1047
|
+
Promise.resolve(
|
|
1048
|
+
config.branches?.({
|
|
1049
|
+
directory: requestDirectory(config, ctx.request),
|
|
1050
|
+
search,
|
|
1051
|
+
limit,
|
|
1052
|
+
}) ?? ["main"],
|
|
1053
|
+
),
|
|
1054
|
+
).pipe(
|
|
1055
|
+
Effect.map((items) => ({
|
|
1056
|
+
location: location(config, requestDirectory(config, ctx.request)),
|
|
1057
|
+
data: items.filter((branch) => branch.toLowerCase().includes(search.toLowerCase())).slice(0, limit),
|
|
1058
|
+
})),
|
|
1059
|
+
)
|
|
1060
|
+
},
|
|
1061
|
+
vcsDiff: (ctx) =>
|
|
1062
|
+
Effect.sync(() => ({
|
|
1063
|
+
location: location(config),
|
|
1064
|
+
data: Predicate.isFunction(config.vcsDiff)
|
|
1065
|
+
? config.vcsDiff({
|
|
1066
|
+
mode: ctx.query.mode,
|
|
1067
|
+
directory: requestDirectory(config, ctx.request),
|
|
1068
|
+
context: ctx.query.context,
|
|
1069
|
+
})
|
|
1070
|
+
: (config.vcsDiff ?? []),
|
|
1071
|
+
})),
|
|
1072
|
+
fsList: (ctx) =>
|
|
1073
|
+
Effect.promise(() => Promise.resolve(config.fileList?.(ctx.query.path ?? ""))).pipe(
|
|
1074
|
+
Effect.map((data) => ({ location: location(config), data })),
|
|
1075
|
+
),
|
|
1076
|
+
fsFind: (ctx) =>
|
|
1077
|
+
Effect.promise(() =>
|
|
1078
|
+
Promise.resolve(
|
|
1079
|
+
config.findFiles?.({
|
|
1080
|
+
query: ctx.query.query ?? "",
|
|
1081
|
+
dirs: ctx.query.type,
|
|
1082
|
+
limit: ctx.query.limit,
|
|
1083
|
+
directory: requestDirectory(config, ctx.request),
|
|
1084
|
+
}),
|
|
1085
|
+
),
|
|
1086
|
+
).pipe(
|
|
1087
|
+
Effect.map((entries) => ({
|
|
1088
|
+
location: location(config, requestDirectory(config, ctx.request)),
|
|
1089
|
+
data: Array.isArray(entries)
|
|
1090
|
+
? entries.map((entry) =>
|
|
1091
|
+
Predicate.isString(entry)
|
|
1092
|
+
? {
|
|
1093
|
+
name: entry.split(/[\\/]/).at(-1) ?? entry,
|
|
1094
|
+
path: entry,
|
|
1095
|
+
absolute: `${requestDirectory(config, ctx.request)}/${entry}`,
|
|
1096
|
+
type: "directory",
|
|
1097
|
+
ignored: false,
|
|
1098
|
+
}
|
|
1099
|
+
: entry,
|
|
1100
|
+
)
|
|
1101
|
+
: entries,
|
|
1102
|
+
})),
|
|
1103
|
+
),
|
|
1104
|
+
fsWatch: () => Effect.void,
|
|
1105
|
+
fsUnwatch: () => Effect.void,
|
|
1106
|
+
fsWrite: (ctx) => {
|
|
1107
|
+
const write = config.onFileWrite
|
|
1108
|
+
|
|
1109
|
+
if (!write) return unsupported("write files", "onFileWrite")
|
|
1110
|
+
|
|
1111
|
+
return Effect.sync(() => {
|
|
1112
|
+
const directory = requestDirectory(config, ctx.request)
|
|
1113
|
+
const path = new URL(ctx.request.url, "http://localhost").searchParams.get("path") ?? ""
|
|
1114
|
+
write({ path, directory, body: new TextDecoder().decode(ctx.payload) })
|
|
1115
|
+
|
|
1116
|
+
return { location: location(config, directory), data: { path } }
|
|
1117
|
+
})
|
|
1118
|
+
},
|
|
1119
|
+
shell: (ctx) =>
|
|
1120
|
+
Effect.sync(() => ({
|
|
1121
|
+
location: location(config, requestDirectory(config, ctx.request)),
|
|
1122
|
+
data: resolve(config.shellCommands ?? []),
|
|
1123
|
+
})),
|
|
1124
|
+
shellOutput: (ctx) =>
|
|
1125
|
+
Effect.suspend(() => {
|
|
1126
|
+
const directory = requestDirectory(config, ctx.request)
|
|
1127
|
+
const output = config.shellOutput?.({ id: ctx.params.id, directory })
|
|
1128
|
+
|
|
1129
|
+
if (output === undefined)
|
|
1130
|
+
return Effect.fail(
|
|
1131
|
+
new MockShellNotFound({ id: ctx.params.id, message: `Shell command not found: ${ctx.params.id}` }),
|
|
1132
|
+
)
|
|
1133
|
+
const bytes = new TextEncoder().encode(output)
|
|
1134
|
+
const query = new URL(ctx.request.url, "http://localhost").searchParams
|
|
1135
|
+
const cursor = Math.min(Number(query.get("cursor") ?? 0), bytes.length)
|
|
1136
|
+
// The server answers at most one page (`Shell.output` defaults `limit` to 65,536 bytes).
|
|
1137
|
+
const end = Math.min(bytes.length, cursor + Number(query.get("limit") ?? 65_536))
|
|
1138
|
+
|
|
1139
|
+
return Effect.succeed({
|
|
1140
|
+
location: location(config, directory),
|
|
1141
|
+
data: {
|
|
1142
|
+
output: new TextDecoder().decode(bytes.subarray(cursor, end)),
|
|
1143
|
+
cursor: end,
|
|
1144
|
+
size: bytes.length,
|
|
1145
|
+
truncated: false,
|
|
1146
|
+
},
|
|
1147
|
+
})
|
|
1148
|
+
}),
|
|
1149
|
+
// Like the server, which also answers 204 for a shell that already ended.
|
|
1150
|
+
shellRemove: () => noContent,
|
|
1151
|
+
persistentPtyList: (ctx) =>
|
|
1152
|
+
persistentPtyEnabled.pipe(
|
|
1153
|
+
Effect.andThen(() =>
|
|
1154
|
+
state.persistentPty.listFails
|
|
1155
|
+
? Effect.fail(new MockInternal({ message: "Listing terminals failed" }))
|
|
1156
|
+
: Effect.succeed({ data: state.persistentPty.list(ctx.params.sessionID) }),
|
|
1157
|
+
),
|
|
1158
|
+
),
|
|
1159
|
+
persistentPtyCreate: (ctx) =>
|
|
1160
|
+
persistentPtyEnabled.pipe(
|
|
1161
|
+
Effect.map(() => {
|
|
1162
|
+
const session = config.sessions.find((item) => item.id === ctx.params.sessionID)
|
|
1163
|
+
const directory = session ? currentSession(session, config.directory).location.directory : undefined
|
|
1164
|
+
|
|
1165
|
+
return {
|
|
1166
|
+
data: state.persistentPty.create(ctx.params.sessionID, {
|
|
1167
|
+
...ctx.payload,
|
|
1168
|
+
cwd: ctx.payload.cwd ?? directory,
|
|
1169
|
+
}),
|
|
1170
|
+
}
|
|
1171
|
+
}),
|
|
1172
|
+
),
|
|
1173
|
+
persistentPtyGet: (ctx) => findPersistentPty(ctx.params.ptyID).pipe(Effect.map((data) => ({ data }))),
|
|
1174
|
+
persistentPtyUpdate: (ctx) =>
|
|
1175
|
+
findPersistentPty(ctx.params.ptyID).pipe(
|
|
1176
|
+
Effect.flatMap((found) =>
|
|
1177
|
+
ctx.payload.title !== undefined && !state.persistentPty.renameSupported
|
|
1178
|
+
? Effect.fail(
|
|
1179
|
+
new MockPtyFeatureUnsupported({
|
|
1180
|
+
feature: "rename",
|
|
1181
|
+
message: "Terminal renaming will be available after OpenCode's terminal service restarts",
|
|
1182
|
+
}),
|
|
1183
|
+
)
|
|
1184
|
+
: Effect.sync(() => ({ data: state.persistentPty.update(found.id, ctx.payload) })),
|
|
1185
|
+
),
|
|
1186
|
+
),
|
|
1187
|
+
persistentPtyRemove: (ctx) =>
|
|
1188
|
+
findPersistentPty(ctx.params.ptyID).pipe(
|
|
1189
|
+
Effect.map((found) => {
|
|
1190
|
+
state.persistentPty.remove(found.id)
|
|
1191
|
+
|
|
1192
|
+
return HttpApiSchema.NoContent.make()
|
|
1193
|
+
}),
|
|
1194
|
+
),
|
|
1195
|
+
persistentPtySnapshot: (ctx) =>
|
|
1196
|
+
findPersistentPty(ctx.params.ptyID).pipe(
|
|
1197
|
+
Effect.map((found) => ({ data: state.persistentPty.snapshot(found.id) })),
|
|
1198
|
+
),
|
|
1199
|
+
persistentPtyConnectToken: (ctx) =>
|
|
1200
|
+
findPersistentPty(ctx.params.ptyID).pipe(
|
|
1201
|
+
Effect.map((found) => ({
|
|
1202
|
+
data: {
|
|
1203
|
+
ticket: state.persistentPty.issue(found.id, Object.fromEntries(Object.entries(ctx.request.headers))),
|
|
1204
|
+
expires_in: 60,
|
|
1205
|
+
},
|
|
1206
|
+
})),
|
|
1207
|
+
),
|
|
1208
|
+
sessionList: (ctx) => {
|
|
1209
|
+
const sessions = config.sessions
|
|
1210
|
+
.filter(
|
|
1211
|
+
(session) =>
|
|
1212
|
+
!ctx.query.directory ||
|
|
1213
|
+
(Predicate.isObject(session.location) && session.location.directory === ctx.query.directory) ||
|
|
1214
|
+
session.directory === ctx.query.directory,
|
|
1215
|
+
)
|
|
1216
|
+
.filter((session) => {
|
|
1217
|
+
if (ctx.query.parentID === undefined) return true
|
|
1218
|
+
|
|
1219
|
+
if (ctx.query.parentID === "null") return session.parentID === undefined
|
|
1220
|
+
|
|
1221
|
+
return session.parentID === ctx.query.parentID
|
|
1222
|
+
})
|
|
1223
|
+
.filter(
|
|
1224
|
+
(session) =>
|
|
1225
|
+
!!currentSession(session, config.directory).time.archived === (ctx.query.archived === "true"),
|
|
1226
|
+
)
|
|
1227
|
+
.filter((session) =>
|
|
1228
|
+
ctx.query.search === undefined
|
|
1229
|
+
? true
|
|
1230
|
+
: String(session.title ?? "")
|
|
1231
|
+
.toLowerCase()
|
|
1232
|
+
.includes(ctx.query.search.toLowerCase()),
|
|
1233
|
+
)
|
|
1234
|
+
|
|
1235
|
+
const ordered = ctx.query.order === "asc" ? sessions : sessions.toReversed()
|
|
1236
|
+
const offset = Number(ctx.query.cursor ?? 0)
|
|
1237
|
+
const limit = ctx.query.limit ?? 50
|
|
1238
|
+
const data = ordered.slice(offset, offset + limit)
|
|
1239
|
+
|
|
1240
|
+
return Effect.succeed({
|
|
1241
|
+
data: data.map((session) => currentSession(session, config.directory)),
|
|
1242
|
+
cursor: { next: offset + limit < ordered.length ? String(offset + limit) : undefined },
|
|
1243
|
+
})
|
|
1244
|
+
},
|
|
1245
|
+
// The goal plugin's pill reads each routed session's goal; no scenario sets one.
|
|
1246
|
+
rpcCall: (ctx) =>
|
|
1247
|
+
ctx.params.rpcID === "opencode.goal" && ctx.params.method === "get"
|
|
1248
|
+
? Effect.succeed({ output: null })
|
|
1249
|
+
: Effect.fail(
|
|
1250
|
+
new MockUnsupported({
|
|
1251
|
+
message: `The mock server has no ${ctx.params.rpcID}.${ctx.params.method} RPC`,
|
|
1252
|
+
}),
|
|
1253
|
+
),
|
|
1254
|
+
sessionActive: () => {
|
|
1255
|
+
const status = resolve(config.sessionStatus ?? {})
|
|
1256
|
+
|
|
1257
|
+
return Effect.succeed({
|
|
1258
|
+
data: Object.fromEntries(
|
|
1259
|
+
[
|
|
1260
|
+
...Object.entries(status).flatMap(([id, value]) => (value.type === "idle" ? [] : [id])),
|
|
1261
|
+
...Object.entries(config.sessionPermissions ?? {}).flatMap(([id, list]) =>
|
|
1262
|
+
currentPermissions(list).length > 0 && status[id]?.type !== "idle" ? [id] : [],
|
|
1263
|
+
),
|
|
1264
|
+
// Location elicitations (`sessionID: "global"`) belong to no Session.
|
|
1265
|
+
...resolve(config.forms ?? []).flatMap((form) =>
|
|
1266
|
+
Predicate.isObject(form) &&
|
|
1267
|
+
Predicate.isString(form.sessionID) &&
|
|
1268
|
+
form.sessionID !== "global" &&
|
|
1269
|
+
status[form.sessionID]?.type !== "idle"
|
|
1270
|
+
? [form.sessionID]
|
|
1271
|
+
: [],
|
|
1272
|
+
),
|
|
1273
|
+
].map((id) => [id, { type: "running" as const }]),
|
|
1274
|
+
),
|
|
1275
|
+
})
|
|
1276
|
+
},
|
|
1277
|
+
sessionGet: (ctx) =>
|
|
1278
|
+
Effect.suspend(() => {
|
|
1279
|
+
config.onSession?.(ctx.params.sessionID)
|
|
1280
|
+
const session = config.sessions.find((item) => item.id === ctx.params.sessionID)
|
|
1281
|
+
|
|
1282
|
+
return session
|
|
1283
|
+
? Effect.succeed({ data: currentSession(session, config.directory) })
|
|
1284
|
+
: Effect.fail(new MockNotFound({ message: "Session not found" }))
|
|
1285
|
+
}),
|
|
1286
|
+
sessionRemove: () => noContent,
|
|
1287
|
+
sessionShell: () => noContent,
|
|
1288
|
+
sessionView: (ctx) =>
|
|
1289
|
+
Effect.sync(() => {
|
|
1290
|
+
const session = config.sessions.find((item) => item.id === ctx.params.sessionID)
|
|
1291
|
+
|
|
1292
|
+
if (!session) return
|
|
1293
|
+
const time = currentSession(session, config.directory).time
|
|
1294
|
+
|
|
1295
|
+
session.time = { ...time, viewed: Math.max(time.viewed ?? 0, ctx.payload.idle) }
|
|
1296
|
+
state.emit([
|
|
1297
|
+
{
|
|
1298
|
+
id: `evt_viewed_${session.id}_${ctx.payload.idle}`,
|
|
1299
|
+
created: Date.now(),
|
|
1300
|
+
type: "session.viewed",
|
|
1301
|
+
durable: { aggregateID: session.id, seq: 1, version: 1 },
|
|
1302
|
+
location: { directory: requestDirectory(config, ctx.request) },
|
|
1303
|
+
data: { sessionID: session.id, idle: ctx.payload.idle },
|
|
1304
|
+
},
|
|
1305
|
+
])
|
|
1306
|
+
}).pipe(Effect.andThen(noContent)),
|
|
1307
|
+
sessionForm: (ctx) =>
|
|
1308
|
+
Effect.succeed({
|
|
1309
|
+
data: resolve(config.forms ?? []).filter(
|
|
1310
|
+
(form) => Predicate.isObject(form) && form.sessionID === ctx.params.sessionID,
|
|
1311
|
+
),
|
|
1312
|
+
}),
|
|
1313
|
+
sessionFormReply: (ctx) =>
|
|
1314
|
+
Effect.sync(() =>
|
|
1315
|
+
config.onFormReply?.({ sessionID: ctx.params.sessionID, formID: ctx.params.formID, body: ctx.payload }),
|
|
1316
|
+
).pipe(Effect.andThen(noContent)),
|
|
1317
|
+
sessionFormCancel: () => noContent,
|
|
1318
|
+
sessionBackground: (ctx) =>
|
|
1319
|
+
Effect.sync(() => config.onBackground?.({ sessionID: ctx.params.sessionID })).pipe(Effect.andThen(noContent)),
|
|
1320
|
+
sessionInbox: (ctx) =>
|
|
1321
|
+
Effect.sync(() => ({
|
|
1322
|
+
data: resolve(config.inbox ?? []).filter(
|
|
1323
|
+
(item) => Predicate.isObject(item) && item.sessionID === ctx.params.sessionID,
|
|
1324
|
+
),
|
|
1325
|
+
})),
|
|
1326
|
+
sessionPrompt: (ctx) =>
|
|
1327
|
+
Effect.sync(() => {
|
|
1328
|
+
const body = Option.getOrElse(decodeJsonObject(ctx.payload), () => ({}))
|
|
1329
|
+
config.onPrompt?.({ sessionID: ctx.params.sessionID, body })
|
|
1330
|
+
const prompt = Option.getOrUndefined(decodePromptRequest(body))
|
|
1331
|
+
|
|
1332
|
+
return {
|
|
1333
|
+
data: {
|
|
1334
|
+
id: prompt?.id ?? `inb_mock_${Date.now()}`,
|
|
1335
|
+
sessionID: ctx.params.sessionID,
|
|
1336
|
+
time: { created: Date.now() },
|
|
1337
|
+
type: "user",
|
|
1338
|
+
// Keys the request omits stay omitted.
|
|
1339
|
+
payload: { text: "", ...Option.getOrUndefined(decodePromptPayload(body)) },
|
|
1340
|
+
delivery: prompt?.delivery ?? "steer",
|
|
1341
|
+
},
|
|
1342
|
+
}
|
|
1343
|
+
}),
|
|
1344
|
+
// Like the server, a compaction is admitted as a steered inbox item under the proposed ID.
|
|
1345
|
+
sessionCompact: (ctx) =>
|
|
1346
|
+
Effect.sync(() => {
|
|
1347
|
+
const body = Option.getOrElse(decodeJsonObject(ctx.payload), (): Schema.JsonObject => ({}))
|
|
1348
|
+
config.onCompact?.({ sessionID: ctx.params.sessionID, body })
|
|
1349
|
+
|
|
1350
|
+
return {
|
|
1351
|
+
data: {
|
|
1352
|
+
id: Predicate.isString(body.id) ? body.id : `inb_mock_${Date.now()}`,
|
|
1353
|
+
sessionID: ctx.params.sessionID,
|
|
1354
|
+
time: { created: Date.now() },
|
|
1355
|
+
type: "compaction",
|
|
1356
|
+
payload: {},
|
|
1357
|
+
delivery: "steer",
|
|
1358
|
+
},
|
|
1359
|
+
}
|
|
1360
|
+
}),
|
|
1361
|
+
sessionGenerate: (ctx) =>
|
|
1362
|
+
Effect.promise(async () => ({
|
|
1363
|
+
data: (await config.generate?.({ sessionID: ctx.params.sessionID, prompt: ctx.payload.prompt })) ?? {
|
|
1364
|
+
text: "Side-question answer",
|
|
1365
|
+
},
|
|
1366
|
+
})),
|
|
1367
|
+
sessionInboxCancel: (ctx) =>
|
|
1368
|
+
Effect.sync(() =>
|
|
1369
|
+
config.onInboxChange?.({ sessionID: ctx.params.sessionID, inboxID: ctx.params.inboxID, action: "cancel" }),
|
|
1370
|
+
).pipe(Effect.andThen(noContent)),
|
|
1371
|
+
sessionInboxUpdate: (ctx) =>
|
|
1372
|
+
Effect.sync(() =>
|
|
1373
|
+
config.onInboxChange?.({
|
|
1374
|
+
sessionID: ctx.params.sessionID,
|
|
1375
|
+
inboxID: ctx.params.inboxID,
|
|
1376
|
+
action: ctx.payload.delivery,
|
|
1377
|
+
}),
|
|
1378
|
+
).pipe(Effect.andThen(noContent)),
|
|
1379
|
+
sessionSwitchAgent: () => noContent,
|
|
1380
|
+
sessionSwitchModel: () => noContent,
|
|
1381
|
+
// Only the session's own list; location requests (`permissions`) come from `/api/permission/request`.
|
|
1382
|
+
sessionPermission: (ctx) =>
|
|
1383
|
+
Effect.sync(() => ({
|
|
1384
|
+
data: currentPermissions(config.sessionPermissions?.[ctx.params.sessionID] ?? []).filter(
|
|
1385
|
+
(permission) => permission.sessionID === ctx.params.sessionID,
|
|
1386
|
+
),
|
|
1387
|
+
})),
|
|
1388
|
+
// Like the server, a reply publishes `permission.replied`, and later reads no longer list the request.
|
|
1389
|
+
sessionPermissionReply: (ctx) => {
|
|
1390
|
+
const reply = config.onPermissionReply
|
|
1391
|
+
|
|
1392
|
+
if (!reply) return unsupported("record permission replies", "onPermissionReply")
|
|
1393
|
+
|
|
1394
|
+
return Effect.sync(() => {
|
|
1395
|
+
const sessionID = ctx.params.sessionID
|
|
1396
|
+
const permissionID = ctx.params.permissionID
|
|
1397
|
+
reply({ sessionID, permissionID, body: ctx.payload })
|
|
1398
|
+
|
|
1399
|
+
const pending = [config.sessionPermissions?.[sessionID] ?? [], resolve(config.permissions ?? [])]
|
|
1400
|
+
|
|
1401
|
+
pending.forEach((list) => {
|
|
1402
|
+
const index = list.findIndex((item) => Predicate.isObject(item) && item.id === permissionID)
|
|
1403
|
+
|
|
1404
|
+
if (index >= 0) list.splice(index, 1)
|
|
1405
|
+
})
|
|
1406
|
+
state.emit([
|
|
1407
|
+
{
|
|
1408
|
+
id: `evt_permission_replied_${permissionID}`,
|
|
1409
|
+
created: Date.now(),
|
|
1410
|
+
type: "permission.replied",
|
|
1411
|
+
location: { directory: requestDirectory(config, ctx.request) },
|
|
1412
|
+
data: {
|
|
1413
|
+
sessionID,
|
|
1414
|
+
requestID: permissionID,
|
|
1415
|
+
reply: Option.getOrUndefined(decodePermissionReply(ctx.payload))?.decision ?? "once",
|
|
1416
|
+
},
|
|
1417
|
+
},
|
|
1418
|
+
])
|
|
1419
|
+
}).pipe(Effect.andThen(noContent))
|
|
1420
|
+
},
|
|
1421
|
+
sessionRename: (ctx) =>
|
|
1422
|
+
Effect.sync(() => {
|
|
1423
|
+
const update = Option.getOrUndefined(decodeSessionUpdate(ctx.payload))
|
|
1424
|
+
|
|
1425
|
+
const session = config.sessions.find((item) => item.id === ctx.params.sessionID)
|
|
1426
|
+
|
|
1427
|
+
if (!session || !update) return
|
|
1428
|
+
|
|
1429
|
+
if (update.title !== undefined) session.title = update.title
|
|
1430
|
+
|
|
1431
|
+
if (update.archived !== undefined) {
|
|
1432
|
+
session.time = {
|
|
1433
|
+
...currentSession(session, config.directory).time,
|
|
1434
|
+
archived: update.archived ? Date.now() : undefined,
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
}).pipe(Effect.andThen(noContent)),
|
|
1438
|
+
sessionCommand: (ctx) => {
|
|
1439
|
+
const recordCommand = config.onCommand
|
|
1440
|
+
|
|
1441
|
+
if (!recordCommand) return unsupported("run session commands", "onCommand")
|
|
1442
|
+
|
|
1443
|
+
return Effect.sync(() => recordCommand({ sessionID: ctx.params.sessionID, body: ctx.payload })).pipe(
|
|
1444
|
+
Effect.andThen(noContent),
|
|
1445
|
+
)
|
|
1446
|
+
},
|
|
1447
|
+
// Like the server: an idle session has nothing running to interrupt.
|
|
1448
|
+
sessionInterrupt: (ctx) =>
|
|
1449
|
+
Effect.succeed({
|
|
1450
|
+
interrupted: resolve(config.sessionStatus ?? {})[ctx.params.sessionID]?.type === "running",
|
|
1451
|
+
}),
|
|
1452
|
+
// The mock runs no agent loop, so every session is already idle.
|
|
1453
|
+
sessionWait: () => noContent,
|
|
1454
|
+
sessionRevertStage: (ctx) => {
|
|
1455
|
+
const request = decodeRevertStage(ctx.payload)
|
|
1456
|
+
|
|
1457
|
+
if (Option.isNone(request)) return Effect.fail(new MockBadRequest({ message: "Invalid revert request" }))
|
|
1458
|
+
const messageID = request.value.messageID
|
|
1459
|
+
|
|
1460
|
+
return Effect.sync(() => config.onRevertStage?.({ sessionID: ctx.params.sessionID, messageID })).pipe(
|
|
1461
|
+
Effect.as({ data: { messageID } }),
|
|
1462
|
+
)
|
|
1463
|
+
},
|
|
1464
|
+
sessionRevertClear: () => noContent,
|
|
1465
|
+
sessionRevertCommit: () => noContent,
|
|
1466
|
+
messageGet: (ctx) =>
|
|
1467
|
+
Effect.gen(function* () {
|
|
1468
|
+
config.onMessage?.({ sessionID: ctx.params.sessionID, messageID: ctx.params.messageID })
|
|
1469
|
+
|
|
1470
|
+
const message =
|
|
1471
|
+
config.message?.(ctx.params.sessionID, ctx.params.messageID) ??
|
|
1472
|
+
config
|
|
1473
|
+
.pageMessages(ctx.params.sessionID, Number.MAX_SAFE_INTEGER)
|
|
1474
|
+
.items.find((item) => item.id === ctx.params.messageID)
|
|
1475
|
+
|
|
1476
|
+
if (!message) return yield* new MockNotFound({ message: "Message not found" })
|
|
1477
|
+
|
|
1478
|
+
return { data: message }
|
|
1479
|
+
}),
|
|
1480
|
+
messageList: (ctx) => {
|
|
1481
|
+
const token = ctx.query.cursor
|
|
1482
|
+
const before = token ? state.cursors.get(token) : undefined
|
|
1483
|
+
|
|
1484
|
+
if (token && !before) return Effect.fail(new MockBadRequest({ message: "Invalid cursor" }))
|
|
1485
|
+
|
|
1486
|
+
return Effect.gen(function* () {
|
|
1487
|
+
config.onMessages?.({ sessionID: ctx.params.sessionID, before, phase: "start" })
|
|
1488
|
+
|
|
1489
|
+
if (config.beforeMessagesResponse) {
|
|
1490
|
+
yield* Effect.promise(() => config.beforeMessagesResponse!({ sessionID: ctx.params.sessionID, before }))
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
const pageData = config.pageMessages(ctx.params.sessionID, ctx.query.limit ?? 50, before)
|
|
1494
|
+
config.onMessages?.({ sessionID: ctx.params.sessionID, before, phase: "end" })
|
|
1495
|
+
const cursor = pageData.cursor ? `cursor_${++state.nextCursor}` : undefined
|
|
1496
|
+
|
|
1497
|
+
if (cursor) state.cursors.set(cursor, pageData.cursor!)
|
|
1498
|
+
|
|
1499
|
+
return {
|
|
1500
|
+
data: ctx.query.order === "asc" ? pageData.items : pageData.items.toReversed(),
|
|
1501
|
+
cursor: { next: cursor },
|
|
1502
|
+
}
|
|
1503
|
+
})
|
|
1504
|
+
},
|
|
1505
|
+
}),
|
|
1506
|
+
)
|
|
1507
|
+
}
|
|
1508
|
+
|
|
1509
|
+
// The requested workspace (directory) inside its listed project, else inside the configured project.
|
|
1510
|
+
function location(config: MockServerConfig, directory = config.directory) {
|
|
1511
|
+
const listed = (config.projects ? resolve(config.projects) : [])
|
|
1512
|
+
.flatMap((item) => Option.toArray(decodeProject(item)))
|
|
1513
|
+
.find((item) =>
|
|
1514
|
+
[item.canonical ?? item.worktree, ...(item.sandboxes ?? [])].some(
|
|
1515
|
+
(root) => root !== undefined && (directory === root || directory.startsWith(`${root}/`)),
|
|
1516
|
+
),
|
|
1517
|
+
)
|
|
1518
|
+
|
|
1519
|
+
const root = listed ? (listed.canonical ?? listed.worktree) : undefined
|
|
1520
|
+
|
|
1521
|
+
if (listed && root) return { directory, project: { id: listed.id, directory: root, canonical: root } }
|
|
1522
|
+
|
|
1523
|
+
return {
|
|
1524
|
+
directory,
|
|
1525
|
+
project: { id: projectSeed(config)?.id, directory: config.directory, canonical: config.directory },
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1529
|
+
// The project fields the mock reads.
|
|
1530
|
+
function projectSeed(config: MockServerConfig) {
|
|
1531
|
+
return Option.getOrUndefined(decodeProject(config.project))
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
// Every field of the configured project, for answers that echo it.
|
|
1535
|
+
function projectFields(config: MockServerConfig) {
|
|
1536
|
+
return Predicate.isObject(config.project) ? config.project : undefined
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1539
|
+
function currentProviders(catalog: MockProviderCatalog) {
|
|
1540
|
+
const connected = new Set(catalog.connected ?? [])
|
|
1541
|
+
|
|
1542
|
+
return (catalog.all ?? [])
|
|
1543
|
+
.flatMap((item) => Option.toArray(decodeProvider(item)))
|
|
1544
|
+
.map((provider) => ({
|
|
1545
|
+
id: provider.id,
|
|
1546
|
+
name: provider.name,
|
|
1547
|
+
canonical: provider.canonical,
|
|
1548
|
+
integrationID: provider.integrationID,
|
|
1549
|
+
package: provider.id,
|
|
1550
|
+
activation: connected.has(provider.id) ? "enabled" : "auto",
|
|
1551
|
+
}))
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
function currentModels(catalog: MockProviderCatalog) {
|
|
1555
|
+
return (catalog.all ?? [])
|
|
1556
|
+
.flatMap((item) => Option.toArray(decodeModelProvider(item)))
|
|
1557
|
+
.flatMap((provider) =>
|
|
1558
|
+
Object.values(provider.models)
|
|
1559
|
+
.flatMap((item) => Option.toArray(decodeModel(item)))
|
|
1560
|
+
.map((model) => ({
|
|
1561
|
+
id: model.id,
|
|
1562
|
+
modelID: model.api?.id ?? model.id,
|
|
1563
|
+
providerID: provider.id,
|
|
1564
|
+
name: model.name,
|
|
1565
|
+
capabilities: model.capabilities ?? { tools: true, input: ["text"], output: ["text"] },
|
|
1566
|
+
variants: Object.entries(model.variants ?? {}).map(([id, settings]) =>
|
|
1567
|
+
Predicate.isObject(settings) ? { id, settings } : { id },
|
|
1568
|
+
),
|
|
1569
|
+
time: model.time ?? { released: Date.now() },
|
|
1570
|
+
cost: [{ input: model.cost?.input ?? 0, output: model.cost?.output ?? 0, cache: { read: 0, write: 0 } }],
|
|
1571
|
+
status: "active",
|
|
1572
|
+
enabled: true,
|
|
1573
|
+
limit: { context: model.limit?.context ?? 200_000, output: model.limit?.output ?? 32_000 },
|
|
1574
|
+
})),
|
|
1575
|
+
)
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
function currentDefaultModel(catalog: MockProviderCatalog) {
|
|
1579
|
+
const selected = catalog.default
|
|
1580
|
+
|
|
1581
|
+
if (!selected) return null
|
|
1582
|
+
|
|
1583
|
+
return (
|
|
1584
|
+
currentModels(catalog).find((model) => model.providerID === selected.providerID && model.id === selected.modelID) ??
|
|
1585
|
+
null
|
|
1586
|
+
)
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1589
|
+
// Legacy requests (`permission`, `patterns`, `always`, `tool`) become current ones; current ones (`action`) pass as is.
|
|
1590
|
+
function currentPermissions(values: readonly unknown[]) {
|
|
1591
|
+
return values.flatMap((permission) => {
|
|
1592
|
+
if (!Predicate.isObject(permission)) return []
|
|
1593
|
+
|
|
1594
|
+
if (permission.action) return [permission]
|
|
1595
|
+
const tool = Predicate.isObject(permission.tool) ? permission.tool : undefined
|
|
1596
|
+
|
|
1597
|
+
return [
|
|
1598
|
+
{
|
|
1599
|
+
id: permission.id,
|
|
1600
|
+
sessionID: permission.sessionID,
|
|
1601
|
+
action: permission.permission,
|
|
1602
|
+
resources: permission.patterns ?? [],
|
|
1603
|
+
save: permission.always,
|
|
1604
|
+
metadata: permission.metadata,
|
|
1605
|
+
source:
|
|
1606
|
+
tool?.messageID && (tool.id || tool.callID)
|
|
1607
|
+
? { type: "tool", messageID: tool.messageID, id: tool.id ?? tool.callID }
|
|
1608
|
+
: undefined,
|
|
1609
|
+
},
|
|
1610
|
+
]
|
|
1611
|
+
})
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1614
|
+
export function currentSession(session: MockSession, fallbackDirectory?: string) {
|
|
1615
|
+
const seed = decodeSession(session)
|
|
1616
|
+
|
|
1617
|
+
return {
|
|
1618
|
+
id: session.id,
|
|
1619
|
+
parentID: session.parentID,
|
|
1620
|
+
projectID: session.projectID ?? "project",
|
|
1621
|
+
agent: session.agent ?? "build",
|
|
1622
|
+
model: session.model,
|
|
1623
|
+
cost: session.cost ?? 0,
|
|
1624
|
+
tokens: session.tokens ?? { input: 0, output: 0, reasoning: 0, cache: { read: 0, write: 0 } },
|
|
1625
|
+
...decodeSessionOutcome(session),
|
|
1626
|
+
time: { created: seed.time?.created ?? 0, updated: seed.time?.updated ?? 0, ...seed.time },
|
|
1627
|
+
title: session.title ?? session.id,
|
|
1628
|
+
location: { directory: seed.location?.directory ?? seed.directory ?? fallbackDirectory },
|
|
1629
|
+
subpath: session.subpath ?? session.path,
|
|
1630
|
+
revert: session.revert,
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1634
|
+
// An optional field that decodes as absent when its value is invalid, so one bad field does not discard the rest.
|
|
1635
|
+
function lenient<S extends Schema.Top>(schema: S) {
|
|
1636
|
+
return Schema.optionalKey(schema.pipe(Schema.catchDecoding(() => Effect.succeedNone)))
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1639
|
+
const decodeJsonObject = Schema.decodeUnknownOption(Schema.JsonObject)
|
|
1640
|
+
|
|
1641
|
+
const decodeProject = Schema.decodeUnknownOption(
|
|
1642
|
+
Schema.Struct({
|
|
1643
|
+
id: lenient(Schema.String),
|
|
1644
|
+
worktree: lenient(Schema.String),
|
|
1645
|
+
canonical: lenient(Schema.String),
|
|
1646
|
+
sandboxes: lenient(Schema.Array(Schema.String)),
|
|
1647
|
+
}),
|
|
1648
|
+
)
|
|
1649
|
+
|
|
1650
|
+
const decodeWorktreeRequest = Schema.decodeUnknownOption(
|
|
1651
|
+
Schema.Struct({ directory: lenient(Schema.String), name: lenient(Schema.String) }),
|
|
1652
|
+
)
|
|
1653
|
+
|
|
1654
|
+
const decodeWorktreeAnswer = Schema.decodeUnknownOption(Schema.Struct({ directory: Schema.String }))
|
|
1655
|
+
|
|
1656
|
+
const decodeSessionCreate = Schema.decodeUnknownOption(
|
|
1657
|
+
Schema.Struct({ id: lenient(Schema.String), title: lenient(Schema.String), parentID: lenient(Schema.String) }),
|
|
1658
|
+
)
|
|
1659
|
+
|
|
1660
|
+
const decodeSessionUpdate = Schema.decodeUnknownOption(
|
|
1661
|
+
Schema.Struct({ title: Schema.optionalKey(Schema.String), archived: Schema.optionalKey(Schema.Boolean) }),
|
|
1662
|
+
)
|
|
1663
|
+
|
|
1664
|
+
const decodeRevertStage = Schema.decodeUnknownOption(Schema.Struct({ messageID: Schema.String }))
|
|
1665
|
+
|
|
1666
|
+
const decodePermissionReply = Schema.decodeUnknownOption(Schema.Struct({ decision: Permission.Reply }))
|
|
1667
|
+
|
|
1668
|
+
const decodePromptRequest = Schema.decodeUnknownOption(
|
|
1669
|
+
Schema.Struct({ id: lenient(Schema.String), delivery: lenient(Schema.Literal("queue")) }),
|
|
1670
|
+
)
|
|
1671
|
+
|
|
1672
|
+
const decodePromptPayload = Schema.decodeUnknownOption(
|
|
1673
|
+
Schema.Struct({
|
|
1674
|
+
text: lenient(Schema.String),
|
|
1675
|
+
files: Schema.optionalKey(Schema.Json),
|
|
1676
|
+
agents: Schema.optionalKey(Schema.Json),
|
|
1677
|
+
skills: Schema.optionalKey(Schema.Json),
|
|
1678
|
+
metadata: Schema.optionalKey(Schema.Json),
|
|
1679
|
+
}),
|
|
1680
|
+
)
|
|
1681
|
+
|
|
1682
|
+
const decodeProvider = Schema.decodeUnknownOption(
|
|
1683
|
+
Schema.Struct({
|
|
1684
|
+
id: Schema.String,
|
|
1685
|
+
name: Schema.String,
|
|
1686
|
+
canonical: lenient(Schema.String),
|
|
1687
|
+
integrationID: lenient(Schema.String),
|
|
1688
|
+
}),
|
|
1689
|
+
)
|
|
1690
|
+
|
|
1691
|
+
const decodeModelProvider = Schema.decodeUnknownOption(
|
|
1692
|
+
Schema.Struct({ id: Schema.String, models: Schema.Record(Schema.String, Schema.Unknown) }),
|
|
1693
|
+
)
|
|
1694
|
+
|
|
1695
|
+
const decodeModel = Schema.decodeUnknownOption(
|
|
1696
|
+
Schema.Struct({
|
|
1697
|
+
id: Schema.String,
|
|
1698
|
+
name: Schema.String,
|
|
1699
|
+
api: lenient(Schema.Struct({ id: Schema.String })),
|
|
1700
|
+
limit: lenient(Schema.Struct({ context: lenient(Schema.Number), output: lenient(Schema.Number) })),
|
|
1701
|
+
cost: lenient(Schema.Struct({ input: lenient(Schema.Number), output: lenient(Schema.Number) })),
|
|
1702
|
+
capabilities: lenient(Model.Capabilities),
|
|
1703
|
+
variants: lenient(Schema.Record(Schema.String, Schema.Unknown)),
|
|
1704
|
+
time: lenient(Schema.Struct({ released: Schema.Number })),
|
|
1705
|
+
}),
|
|
1706
|
+
)
|
|
1707
|
+
|
|
1708
|
+
// Every field is lenient, so any session object decodes.
|
|
1709
|
+
const decodeSession = Schema.decodeUnknownSync(
|
|
1710
|
+
Schema.Struct({
|
|
1711
|
+
time: lenient(
|
|
1712
|
+
Schema.Struct({
|
|
1713
|
+
created: lenient(Schema.Number),
|
|
1714
|
+
updated: lenient(Schema.Number),
|
|
1715
|
+
busy: lenient(Schema.Number),
|
|
1716
|
+
idle: lenient(Schema.Number),
|
|
1717
|
+
viewed: lenient(Schema.Number),
|
|
1718
|
+
archived: Schema.optionalKey(Schema.Unknown),
|
|
1719
|
+
}),
|
|
1720
|
+
),
|
|
1721
|
+
location: lenient(Schema.Struct({ directory: lenient(Schema.String) })),
|
|
1722
|
+
directory: lenient(Schema.String),
|
|
1723
|
+
}),
|
|
1724
|
+
)
|
|
1725
|
+
|
|
1726
|
+
const decodeSessionOutcome = Schema.decodeUnknownSync(Schema.Struct({ outcome: lenient(Schema.String) }))
|