@openchamber/web 1.24.2 → 2.0.1
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/bin/lib/commands-connect-url.js +3 -8
- package/bin/lib/commands-tunnel.js +3 -0
- package/dist/assets/{CodeMirrorCommentWidgets-B_vBPQYm.js → CodeMirrorCommentWidgets-zm3C1FvM.js} +1 -1
- package/dist/assets/DiffView-DNExNi1z.js +4 -0
- package/dist/assets/FilesView-DUCLmHBi.js +17 -0
- package/dist/assets/{GitView-k0hUF8KB.js → GitView-Bz9z6gZA.js} +4 -4
- package/dist/assets/{GuestAttachDialog-DIf2U85Z.js → GuestAttachDialog-UGp4KDlK.js} +1 -1
- package/dist/assets/GuestSurfacePane-B3pdB_2u.js +1 -0
- package/dist/assets/{JsonTreeView-4AnJ04Pw.js → JsonTreeView-7lVecnZl.js} +1 -1
- package/dist/assets/LinearIssuesView-CTGRS9Vq.js +1 -0
- package/dist/assets/MarkdownImageGallery-DQk5adUs.js +1 -0
- package/dist/assets/MarkdownRendererImpl-DPF8fZpX.js +12 -0
- package/dist/assets/OnboardingScreen-CBx6cXPP.js +1 -0
- package/dist/assets/{PatchDiff-DpGmHRnV.js → PatchDiff-D7VVpR_l.js} +1 -1
- package/dist/assets/{PierreDiffViewer-CgLl_tp7.js → PierreDiffViewer-Gbfks1pk.js} +3 -3
- package/dist/assets/PlanView-CPSK0x97.js +5 -0
- package/dist/assets/PluginPane-BIGsUx69.js +3 -0
- package/dist/assets/SettingsView-Dql7z6Ww.js +30 -0
- package/dist/assets/SettingsWindow-D6oi-UmV.js +1 -0
- package/dist/assets/SubmoduleDiffSummary-BXA0FAWj.js +1 -0
- package/dist/assets/ToolOutputDialog-BQJsSbDm.js +15 -0
- package/dist/assets/ToolPartDiffPreview-FY9w0TVT.js +8 -0
- package/dist/assets/{VirtualizedFileDiff-BK4aU5qJ.js → VirtualizedFileDiff-B9YhAya5.js} +4 -4
- package/dist/assets/{WalkthroughView-Bk6TPNFw.js → WalkthroughView-CmFgOUFN.js} +2 -2
- package/dist/assets/appThemeRegistry-BebxalUt.js +1 -0
- package/dist/assets/changesTree-CePHbFcj.js +1 -0
- package/dist/assets/commitAndPush-Wfxng_IK.js +1 -0
- package/dist/assets/{computeVirtualFileMetrics-BVTujWSX.js → computeVirtualFileMetrics-BCOqgixN.js} +2 -2
- package/dist/assets/de-CMA45TC-.js +10 -0
- package/dist/assets/es-DPL4fBtl.js +16 -0
- package/dist/assets/fr-OHBKBseP.js +14 -0
- package/dist/assets/index-3TiDNtfN.js +1 -0
- package/dist/assets/index-BLUZa5u0.js +41 -0
- package/dist/assets/index-Cm2rrq69.css +1 -0
- package/dist/assets/{isDiffPlainText-D3yX_vx4.js → isDiffPlainText-DnDYQmWK.js} +1 -1
- package/dist/assets/{isFilePlainText-CZR9TcHV.js → isFilePlainText-BA_AHX7d.js} +1 -1
- package/dist/assets/ja-DvX4WSRf.js +16 -0
- package/dist/assets/ko-BUcLd8YZ.js +16 -0
- package/dist/assets/main-B_jri4i-.js +896 -0
- package/dist/assets/main-DtUmJp9B.js +2 -0
- package/dist/assets/{markdown-shiki.worker-CahLvHIq.js → markdown-shiki.worker-Bg8SoAJJ.js} +8 -5
- package/dist/assets/markdownCore-BSnlUXBf.js +7 -0
- package/dist/assets/miniChat-BYfLUnDK.js +2 -0
- package/dist/assets/mobile-DH3hI6gd.js +2 -0
- package/dist/assets/patchFileDiff--L7lt_GZ.js +13 -0
- package/dist/assets/pl-BkI_xHqz.js +16 -0
- package/dist/assets/pt-BR-7wFtQlV9.js +16 -0
- package/dist/assets/renderElectronMiniChatApp-C7kpNW_-.js +2 -0
- package/dist/assets/renderMobileApp-i0nq7Dwy.js +25 -0
- package/dist/assets/runtimeEndpointReset-CfEYbcCc.js +27 -0
- package/dist/assets/scheduledTasksApi-Cy7uZCaI.js +1 -0
- package/dist/assets/{shikiHighlight-BfjuB3CD.js → shikiHighlight-D4vxipfr.js} +1 -1
- package/dist/assets/{textMateThemeFromAppTheme-BP60t9SX.js → textMateThemeFromAppTheme-BYAHtJwQ.js} +1 -1
- package/dist/assets/tr-TsD-AqEH.js +7 -0
- package/dist/assets/uk-B-qspCmD.js +16 -0
- package/dist/assets/useAppFontEffects-DHZ9-L30.js +7338 -0
- package/dist/assets/useInlineCommentController-CvpOMK-R.js +2 -0
- package/dist/assets/useRootScrollLock-DzNFi-fn.js +2 -0
- package/dist/assets/{vendor-codemirror-language-data-BFm1Ju2w.js → vendor-codemirror-language-data-j3fhlwUM.js} +2 -2
- package/dist/assets/vendor-cron-parser-CjvYVigk.js +2 -0
- package/dist/assets/vendor-opencode-client-DYdsLbCM.js +12 -0
- package/dist/assets/{vendor-remixicon-react-BDmGmFCA.js → vendor-remixicon-react-D6dZ0UwF.js} +1 -1
- package/dist/assets/vendor-zod-BSoePkpP.js +39 -0
- package/dist/assets/{web-components-2vo9YsZc.js → web-components-BvHNFSEG.js} +2 -2
- package/dist/assets/zh-CN-DYuPJV5i.js +16 -0
- package/dist/assets/zh-TW-BX_2D_lV.js +16 -0
- package/dist/index.html +13 -7
- package/dist/mini-chat.html +5 -5
- package/dist/mobile.html +5 -5
- package/package.json +6 -5
- package/server/index.d.ts +1 -0
- package/server/index.js +264 -91
- package/server/lib/agent-tool/DOCUMENTATION.md +38 -16
- package/server/lib/agent-tool/runtime.js +167 -58
- package/server/lib/agent-tool/runtime.test.js +170 -87
- package/server/lib/browser-control/DOCUMENTATION.md +51 -4
- package/server/lib/browser-control/provider.js +217 -0
- package/server/lib/browser-control/provider.test.js +251 -0
- package/server/lib/context-obligatory/runtime.js +61 -50
- package/server/lib/context-obligatory/runtime.test.js +62 -162
- package/server/lib/event-stream/DOCUMENTATION.md +12 -1
- package/server/lib/event-stream/delta-coalescer.js +0 -0
- package/server/lib/event-stream/delta-coalescer.test.js +68 -57
- package/server/lib/event-stream/directory-ws-bridge.js +1 -1
- package/server/lib/event-stream/global-hub.js +10 -1
- package/server/lib/event-stream/global-hub.test.js +27 -26
- package/server/lib/event-stream/index.js +6 -0
- package/server/lib/event-stream/protocol.js +26 -19
- package/server/lib/event-stream/protocol.test.js +18 -7
- package/server/lib/event-stream/rebind.test.js +5 -5
- package/server/lib/event-stream/runtime.test.js +17 -15
- package/server/lib/event-stream/translate-v2.js +313 -0
- package/server/lib/event-stream/translate-v2.test.js +209 -0
- package/server/lib/event-stream/upstream-reader.test.js +16 -16
- package/server/lib/fs/DOCUMENTATION.md +4 -2
- package/server/lib/fs/byte-range.js +35 -0
- package/server/lib/fs/byte-range.test.js +31 -0
- package/server/lib/fs/routes.js +47 -42
- package/server/lib/fs/routes.test.js +123 -18
- package/server/lib/git/DOCUMENTATION.md +1 -1
- package/server/lib/git/service.js +34 -0
- package/server/lib/git/service.test.js +8 -0
- package/server/lib/github/DOCUMENTATION.md +1 -1
- package/server/lib/github/pr-status.js +22 -2
- package/server/lib/github/pr-status.test.js +27 -14
- package/server/lib/guests/DOCUMENTATION.md +16 -2
- package/server/lib/guests/catalog.js +31 -1
- package/server/lib/guests/catalog.test.js +55 -0
- package/server/lib/guests/html-styles.js +5 -3
- package/server/lib/guests/html-styles.test.js +3 -1
- package/server/lib/guests/routes.js +21 -4
- package/server/lib/guests/service.js +197 -14
- package/server/lib/guests/service.test.js +201 -1
- package/server/lib/guests/surface.js +676 -0
- package/server/lib/guests/surface.test.js +536 -0
- package/server/lib/markdown-image-grants/routes.js +18 -5
- package/server/lib/markdown-image-grants/routes.test.js +9 -6
- package/server/lib/message-queue/DOCUMENTATION.md +33 -22
- package/server/lib/message-queue/runtime.js +155 -100
- package/server/lib/message-queue/runtime.test.js +168 -82
- package/server/lib/notifications/DOCUMENTATION.md +38 -0
- package/server/lib/notifications/control-stream.http.test.js +68 -0
- package/server/lib/notifications/emit-route.js +118 -0
- package/server/lib/notifications/emit-route.test.js +112 -0
- package/server/lib/notifications/emitter-runtime.js +15 -0
- package/server/lib/notifications/emitter-runtime.test.js +32 -0
- package/server/lib/notifications/push-runtime.js +5 -1
- package/server/lib/notifications/push-runtime.test.js +2 -2
- package/server/lib/notifications/routes.js +1 -1
- package/server/lib/notifications/runtime.js +115 -26
- package/server/lib/notifications/template-runtime.js +13 -15
- package/server/lib/notifications/template-runtime.test.js +16 -9
- package/server/lib/notifications/trigger-runtime.test.js +187 -0
- package/server/lib/openchamber-control/DOCUMENTATION.md +10 -0
- package/server/lib/openchamber-control/actions.js +19 -4
- package/server/lib/openchamber-control/error.js +1 -1
- package/server/lib/openchamber-control/file-open.js +59 -0
- package/server/lib/openchamber-control/file-open.test.js +57 -0
- package/server/lib/openchamber-control/routes.test.js +12 -0
- package/server/lib/openchamber-control/service.js +125 -49
- package/server/lib/openchamber-control/service.test.js +115 -44
- package/server/lib/openchamber-sessions/archive-store.js +224 -0
- package/server/lib/openchamber-sessions/archive-store.test.js +187 -0
- package/server/lib/openchamber-sessions/fork-inheritance.js +103 -0
- package/server/lib/openchamber-sessions/fork-inheritance.test.js +69 -0
- package/server/lib/openchamber-sessions/opencode-client.js +22 -0
- package/server/lib/openchamber-sessions/routes.js +409 -328
- package/server/lib/openchamber-sessions/routes.test.js +795 -740
- package/server/lib/openchamber-sessions/session-metadata-store.js +285 -0
- package/server/lib/openchamber-sessions/session-metadata-store.test.js +259 -0
- package/server/lib/opencode/DOCUMENTATION.md +458 -29
- package/server/lib/opencode/agents.js +233 -327
- package/server/lib/opencode/auth.js +41 -44
- package/server/lib/opencode/auth.test.js +92 -0
- package/server/lib/opencode/bootstrap-runtime.js +12 -0
- package/server/lib/opencode/cli-upgrade.d.ts +4 -0
- package/server/lib/opencode/cli-upgrade.js +18 -0
- package/server/lib/opencode/cli-upgrade.test.js +36 -0
- package/server/lib/opencode/commands.js +164 -145
- package/server/lib/opencode/compatibility.d.ts +16 -0
- package/server/lib/opencode/compatibility.js +91 -0
- package/server/lib/opencode/compatibility.test.js +70 -0
- package/server/lib/opencode/config-entity-routes.js +58 -29
- package/server/lib/opencode/config-entity-v2.test.js +290 -0
- package/server/lib/opencode/config-mutation-response.js +17 -7
- package/server/lib/opencode/config-mutation-response.test.js +4 -7
- package/server/lib/opencode/config-paths.test.js +2 -2
- package/server/lib/opencode/config-v2.d.ts +185 -0
- package/server/lib/opencode/config-v2.js +843 -0
- package/server/lib/opencode/config-v2.test.js +483 -0
- package/server/lib/opencode/core-routes.js +3 -0
- package/server/lib/opencode/core-routes.test.js +15 -0
- package/server/lib/opencode/credential-db.js +144 -0
- package/server/lib/opencode/credential-db.test.js +104 -0
- package/server/lib/opencode/env-runtime.js +47 -15
- package/server/lib/opencode/env-runtime.test.js +45 -0
- package/server/lib/opencode/feature-routes-runtime.js +16 -5
- package/server/lib/opencode/lifecycle-process.test.js +7 -4
- package/server/lib/opencode/lifecycle.js +113 -30
- package/server/lib/opencode/lifecycle.test.js +107 -8
- package/server/lib/opencode/login-shell-env.js +27 -0
- package/server/lib/opencode/managed-config-file.js +131 -0
- package/server/lib/opencode/managed-config-file.test.js +168 -0
- package/server/lib/opencode/managed-plugin-config.js +33 -13
- package/server/lib/opencode/mcp.js +43 -149
- package/server/lib/opencode/network-runtime.js +6 -7
- package/server/lib/opencode/openchamber-routes.js +29 -11
- package/server/lib/opencode/openchamber-routes.test.js +18 -1
- package/server/lib/opencode/plugin-routes.js +3 -3
- package/server/lib/opencode/plugin-routes.test.js +6 -24
- package/server/lib/opencode/plugins.js +91 -40
- package/server/lib/opencode/plugins.test.js +28 -15
- package/server/lib/opencode/provider-source-route.test.js +59 -0
- package/server/lib/opencode/providers.js +66 -83
- package/server/lib/opencode/providers.test.js +190 -59
- package/server/lib/opencode/proxy-agent-wiring.test.js +4 -2
- package/server/lib/opencode/proxy.js +179 -129
- package/server/lib/opencode/pwa-manifest-routes.js +4 -2
- package/server/lib/opencode/pwa-manifest-routes.test.js +3 -2
- package/server/lib/opencode/response-envelope.js +14 -0
- package/server/lib/opencode/response-envelope.test.js +23 -0
- package/server/lib/opencode/routes-upgrade.test.js +73 -116
- package/server/lib/opencode/routes.js +138 -428
- package/server/lib/opencode/server-utils-runtime.js +10 -4
- package/server/lib/opencode/session-activity.js +78 -0
- package/server/lib/opencode/session-runtime.js +21 -10
- package/server/lib/opencode/session-runtime.test.js +9 -9
- package/server/lib/opencode/settings-helpers.js +15 -8
- package/server/lib/opencode/settings-helpers.test.js +7 -12
- package/server/lib/opencode/settings-registry.json +20 -8
- package/server/lib/opencode/settings-runtime.js +19 -1
- package/server/lib/opencode/settings-runtime.test.js +31 -2
- package/server/lib/opencode/shared.js +86 -24
- package/server/lib/opencode/shared.test.js +87 -5
- package/server/lib/opencode/shutdown-runtime.js +54 -7
- package/server/lib/opencode/shutdown-runtime.test.js +224 -30
- package/server/lib/opencode/skill-routes.js +51 -36
- package/server/lib/opencode/skill-routes.test.js +121 -1
- package/server/lib/opencode/skills.js +7 -5
- package/server/lib/opencode/tunnel-wiring-runtime.js +2 -1
- package/server/lib/opencode/upgrade-capability.js +0 -14
- package/server/lib/opencode/upgrade-capability.test.js +1 -1
- package/server/lib/opencode/v1-migration-topup.js +294 -0
- package/server/lib/opencode/v1-migration-topup.test.js +274 -0
- package/server/lib/opencode/v2-install.d.ts +9 -0
- package/server/lib/opencode/v2-install.js +159 -0
- package/server/lib/opencode/v2-install.test.js +133 -0
- package/server/lib/opencode/watcher.js +10 -3
- package/server/lib/opencode/watcher.test.js +17 -21
- package/server/lib/opencode/websearch-config.js +78 -0
- package/server/lib/permission-auto-accept/runtime.js +38 -22
- package/server/lib/permission-auto-accept/runtime.test.js +39 -17
- package/server/lib/quota/DOCUMENTATION.md +4 -0
- package/server/lib/quota/providers/kimi.js +1 -1
- package/server/lib/quota/providers/xai.js +4 -4
- package/server/lib/relay/tunnel-host.js +4 -1
- package/server/lib/relay/tunnel-host.test.js +7 -0
- package/server/lib/routing/DOCUMENTATION.md +52 -21
- package/server/lib/routing/defaults.js +23 -6
- package/server/lib/routing/jev.js +17 -7
- package/server/lib/routing/routes.http.test.js +68 -33
- package/server/lib/routing/routes.js +65 -22
- package/server/lib/routing/runtime.js +145 -48
- package/server/lib/routing/runtime.test.js +79 -55
- package/server/lib/scheduled-tasks/DOCUMENTATION.md +4 -0
- package/server/lib/scheduled-tasks/issue-2710-double-execution.test.js +51 -46
- package/server/lib/scheduled-tasks/runtime.js +81 -74
- package/server/lib/scheduled-tasks/runtime.test.js +53 -1
- package/server/lib/session-assist/DOCUMENTATION.md +25 -8
- package/server/lib/session-assist/context.js +122 -46
- package/server/lib/session-assist/context.test.js +117 -49
- package/server/lib/session-assist/runtime.js +71 -24
- package/server/lib/session-assist/runtime.test.js +153 -173
- package/server/lib/session-goal/DOCUMENTATION.md +34 -15
- package/server/lib/session-goal/create.js +9 -12
- package/server/lib/session-goal/create.test.js +27 -28
- package/server/lib/session-goal/runtime.js +164 -77
- package/server/lib/session-goal/runtime.test.js +271 -519
- package/server/lib/session-knowledge/DOCUMENTATION.md +5 -0
- package/server/lib/session-knowledge/runtime.js +59 -41
- package/server/lib/session-knowledge/runtime.test.js +90 -20
- package/server/lib/small-model/DOCUMENTATION.md +154 -208
- package/server/lib/small-model/client.js +113 -0
- package/server/lib/small-model/index.js +296 -158
- package/server/lib/small-model/index.test.js +423 -256
- package/server/lib/small-model/routes.js +1 -1
- package/server/lib/spaces/DOCUMENTATION.md +807 -0
- package/server/lib/spaces/code-in-bait.js +185 -0
- package/server/lib/spaces/code-in.js +641 -0
- package/server/lib/spaces/code-in.test.js +1048 -0
- package/server/lib/spaces/errors.js +8 -0
- package/server/lib/spaces/exec-http.js +94 -0
- package/server/lib/spaces/gatekeeper-channel.js +202 -0
- package/server/lib/spaces/gatekeeper-channel.test.js +215 -0
- package/server/lib/spaces/gatekeeper-program.cjs +914 -0
- package/server/lib/spaces/gatekeeper-program.test.js +1391 -0
- package/server/lib/spaces/hardening.js +457 -0
- package/server/lib/spaces/hardening.test.js +368 -0
- package/server/lib/spaces/host-git.js +127 -0
- package/server/lib/spaces/host-git.test.js +137 -0
- package/server/lib/spaces/labels.js +234 -0
- package/server/lib/spaces/labels.test.js +219 -0
- package/server/lib/spaces/layout.js +184 -0
- package/server/lib/spaces/layout.test.js +30 -0
- package/server/lib/spaces/manager.js +82 -0
- package/server/lib/spaces/manager.test.js +114 -0
- package/server/lib/spaces/places/code-in.docker.live.test.js +216 -0
- package/server/lib/spaces/places/contract-suite.js +156 -0
- package/server/lib/spaces/places/contract.docker.live.test.js +7 -0
- package/server/lib/spaces/places/contract.test.js +6 -0
- package/server/lib/spaces/places/docker-engine.js +126 -0
- package/server/lib/spaces/places/docker-live-support.js +202 -0
- package/server/lib/spaces/places/docker-tools.js +186 -0
- package/server/lib/spaces/places/docker.js +587 -0
- package/server/lib/spaces/places/docker.test.js +1610 -0
- package/server/lib/spaces/places/escape-suite.js +1018 -0
- package/server/lib/spaces/places/escape.docker.live.test.js +7 -0
- package/server/lib/spaces/places/fake-docker.js +375 -0
- package/server/lib/spaces/places/memory-place.js +103 -0
- package/server/lib/spaces/places/packed.docker.live.test.js +77 -0
- package/server/lib/spaces/places/registry.js +43 -0
- package/server/lib/spaces/places/registry.test.js +50 -0
- package/server/lib/spaces/places/server.docker.live.test.js +225 -0
- package/server/lib/spaces/run-command.js +261 -0
- package/server/lib/spaces/run-command.test.js +396 -0
- package/server/lib/spaces/space-server.js +190 -0
- package/server/lib/spaces/space-server.test.js +335 -0
- package/server/lib/spaces/tools-filler.js +82 -0
- package/server/lib/spaces/tools-filler.test.js +148 -0
- package/server/lib/spaces/tools-pack.js +49 -0
- package/server/lib/spaces/tools-pack.test.js +57 -0
- package/server/lib/spaces/tools.js +137 -0
- package/server/lib/spaces/tools.test.js +153 -0
- package/server/lib/tts/openai-sdk.js +11 -0
- package/server/lib/tts/service.js +7 -5
- package/server/lib/tts/stt.js +3 -2
- package/server/lib/tunnels/DOCUMENTATION.md +2 -0
- package/server/lib/tunnels/routes.js +7 -0
- package/server/lib/tunnels/routes.test.js +55 -0
- package/server/lib/ui-auth/ui-auth.js +38 -2
- package/server/lib/ui-auth/ui-auth.test.js +42 -0
- package/server/lib/ui-auth/ui-passkeys.js +12 -10
- package/server/lib/walkthrough/DOCUMENTATION.md +10 -1
- package/server/lib/walkthrough/pull-request.js +61 -8
- package/server/lib/walkthrough/pull-request.test.js +54 -1
- package/server/lib/walkthrough/routes.js +20 -0
- package/server/lib/walkthrough/routes.test.js +19 -0
- package/server/opencode-proxy.test.js +190 -166
- package/server/opencode-worktree-readiness.test.js +5 -4
- package/dist/assets/DiffView-Ce0oBXXQ.js +0 -4
- package/dist/assets/FilesView-DtXueAWP.js +0 -13
- package/dist/assets/LinearIssuesView-z_9p2GuO.js +0 -1
- package/dist/assets/MarkdownImageGallery-BC-BNN-s.js +0 -1
- package/dist/assets/MarkdownRendererImpl-DyaBTUbH.js +0 -12
- package/dist/assets/OnboardingScreen-DKU_yTb6.js +0 -1
- package/dist/assets/PlanView-CrfB4qqY.js +0 -5
- package/dist/assets/PluginPane-B5cn-jPy.js +0 -3
- package/dist/assets/SettingsView-DMKKwezx.js +0 -29
- package/dist/assets/SettingsWindow-DwbnVzOC.js +0 -1
- package/dist/assets/SubmoduleDiffSummary-hkGcvs0E.js +0 -1
- package/dist/assets/ToolOutputDialog-DuoIOc0j.js +0 -15
- package/dist/assets/ToolPartDiffPreview-t1Bvq_2Y.js +0 -8
- package/dist/assets/appThemeRegistry-DnOVbJjF.js +0 -1
- package/dist/assets/commitAndPush-DLWNZkkY.js +0 -1
- package/dist/assets/de-zEHaAIi3.js +0 -10
- package/dist/assets/es-CBDgEzgk.js +0 -16
- package/dist/assets/fr-DjiTptT_.js +0 -14
- package/dist/assets/index-AgOdanig.css +0 -1
- package/dist/assets/index-B-2_X4DD.js +0 -40
- package/dist/assets/index-CkA4p2IK.js +0 -1
- package/dist/assets/ja-CerMgj3r.js +0 -16
- package/dist/assets/ko-DHYDAze5.js +0 -16
- package/dist/assets/main-BDka4W43.js +0 -896
- package/dist/assets/main-Dl7Dyge_.js +0 -2
- package/dist/assets/markdownCore-DFmr0rUR.js +0 -5
- package/dist/assets/miniChat-CLKQPPpO.js +0 -2
- package/dist/assets/mobile--giD2Q1L.js +0 -2
- package/dist/assets/patchFileDiff-DRh-AQvd.js +0 -13
- package/dist/assets/pl-BTB_93bq.js +0 -16
- package/dist/assets/pt-BR-BwA3oyCK.js +0 -16
- package/dist/assets/renderElectronMiniChatApp-DmB7zpVK.js +0 -2
- package/dist/assets/renderMobileApp-pMfOuQfl.js +0 -25
- package/dist/assets/runtimeEndpointReset-Gqhmkm3U.js +0 -25
- package/dist/assets/scheduledTasksApi-CeRAIUmW.js +0 -1
- package/dist/assets/tr-CcPsJoNM.js +0 -7
- package/dist/assets/uk-B68WibXi.js +0 -16
- package/dist/assets/useAppFontEffects-DcdrFv2Z.js +0 -7333
- package/dist/assets/useInlineCommentController-Cq4SUjsA.js +0 -2
- package/dist/assets/useRootScrollLock-CSdR6Wnm.js +0 -2
- package/dist/assets/vendor-cron-parser-CUcP7OfX.js +0 -2
- package/dist/assets/vendor-opencode-sdk-BJ73u-bH.js +0 -7
- package/dist/assets/vendor-zod-CgAdXWZO.js +0 -39
- package/dist/assets/zh-CN-DbFHYXwP.js +0 -16
- package/dist/assets/zh-TW-DmXAwdty.js +0 -16
- package/server/lib/opencode/mcp-oauth-callback.test.js +0 -111
- package/server/lib/routing/feature-flag.js +0 -11
- package/server/lib/small-model/call.js +0 -851
- package/server/lib/small-model/call.test.js +0 -1292
- package/server/lib/small-model/catalog.js +0 -13
- package/server/lib/small-model/resolve.js +0 -131
- package/server/lib/small-model/resolve.test.js +0 -197
- package/server/lib/small-model/runtime-providers.js +0 -164
- package/server/lib/small-model/runtime-providers.test.js +0 -118
- package/server/lib/system-prompt/DOCUMENTATION.md +0 -36
- package/server/lib/system-prompt/runtime.js +0 -49
- package/server/lib/system-prompt/runtime.test.js +0 -76
- package/server/lib/walkthrough/reproduce-2607.test.js +0 -148
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One HTTP `Range` header, reduced to the single byte span this server serves.
|
|
3
|
+
*
|
|
4
|
+
* Media elements ask for `bytes=0-` first and then for `bytes=<offset>-` on
|
|
5
|
+
* every seek; without a 206 answer Chromium and WebKit refuse to seek at all,
|
|
6
|
+
* and Safari refuses to play. Multi-range requests are answered with the whole
|
|
7
|
+
* file: no media consumer sends them, and a multipart body is not worth
|
|
8
|
+
* carrying for a viewer.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @param {unknown} header
|
|
13
|
+
* @param {number} size
|
|
14
|
+
* @returns {{ kind: 'range', start: number, end: number } | { kind: 'whole' } | { kind: 'unsatisfiable' }}
|
|
15
|
+
*/
|
|
16
|
+
export const resolveByteRange = (header, size) => {
|
|
17
|
+
if (!header || size <= 0) return { kind: 'whole' };
|
|
18
|
+
const match = /^bytes=(\d*)-(\d*)$/.exec(String(header).trim());
|
|
19
|
+
if (!match) return { kind: 'whole' };
|
|
20
|
+
const [, rawStart, rawEnd] = match;
|
|
21
|
+
if (rawStart === '' && rawEnd === '') return { kind: 'whole' };
|
|
22
|
+
|
|
23
|
+
// `bytes=-500` means the final 500 bytes.
|
|
24
|
+
if (rawStart === '') {
|
|
25
|
+
const suffix = Number(rawEnd);
|
|
26
|
+
if (suffix === 0) return { kind: 'unsatisfiable' };
|
|
27
|
+
return { kind: 'range', start: Math.max(0, size - suffix), end: size - 1 };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const start = Number(rawStart);
|
|
31
|
+
if (start >= size) return { kind: 'unsatisfiable' };
|
|
32
|
+
const end = rawEnd === '' ? size - 1 : Math.min(Number(rawEnd), size - 1);
|
|
33
|
+
if (end < start) return { kind: 'unsatisfiable' };
|
|
34
|
+
return { kind: 'range', start, end };
|
|
35
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import { resolveByteRange } from './byte-range.js';
|
|
4
|
+
|
|
5
|
+
describe('resolveByteRange', () => {
|
|
6
|
+
it('serves the whole file without a header, for an empty file, and for anything but one bytes span', () => {
|
|
7
|
+
expect(resolveByteRange(undefined, 100)).toEqual({ kind: 'whole' });
|
|
8
|
+
expect(resolveByteRange('bytes=0-', 0)).toEqual({ kind: 'whole' });
|
|
9
|
+
expect(resolveByteRange('items=0-1', 100)).toEqual({ kind: 'whole' });
|
|
10
|
+
expect(resolveByteRange('bytes=0-1,5-9', 100)).toEqual({ kind: 'whole' });
|
|
11
|
+
expect(resolveByteRange('bytes=-', 100)).toEqual({ kind: 'whole' });
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('answers the open-ended span a media element sends on seek', () => {
|
|
15
|
+
expect(resolveByteRange('bytes=0-', 100)).toEqual({ kind: 'range', start: 0, end: 99 });
|
|
16
|
+
expect(resolveByteRange('bytes=40-', 100)).toEqual({ kind: 'range', start: 40, end: 99 });
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('clamps a closed span to the file and honours a suffix span', () => {
|
|
20
|
+
expect(resolveByteRange('bytes=10-19', 100)).toEqual({ kind: 'range', start: 10, end: 19 });
|
|
21
|
+
expect(resolveByteRange('bytes=90-500', 100)).toEqual({ kind: 'range', start: 90, end: 99 });
|
|
22
|
+
expect(resolveByteRange('bytes=-30', 100)).toEqual({ kind: 'range', start: 70, end: 99 });
|
|
23
|
+
expect(resolveByteRange('bytes=-300', 100)).toEqual({ kind: 'range', start: 0, end: 99 });
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('rejects a span that starts past the end or runs backwards', () => {
|
|
27
|
+
expect(resolveByteRange('bytes=100-', 100)).toEqual({ kind: 'unsatisfiable' });
|
|
28
|
+
expect(resolveByteRange('bytes=50-40', 100)).toEqual({ kind: 'unsatisfiable' });
|
|
29
|
+
expect(resolveByteRange('bytes=-0', 100)).toEqual({ kind: 'unsatisfiable' });
|
|
30
|
+
});
|
|
31
|
+
});
|
package/server/lib/fs/routes.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createRealpathCache } from '../path-realpath-cache.js';
|
|
2
|
+
import { resolveByteRange } from './byte-range.js';
|
|
2
3
|
import nodeFsPromises from 'node:fs/promises';
|
|
3
4
|
import nodePath from 'node:path';
|
|
4
5
|
|
|
@@ -67,25 +68,6 @@ export const mintOutsideFileGrant = async (targetPath, {
|
|
|
67
68
|
};
|
|
68
69
|
};
|
|
69
70
|
|
|
70
|
-
const resolveOutsideFileGrant = async ({ token, targetPath, scope, fsPromises }) => {
|
|
71
|
-
pruneOutsideFileGrants();
|
|
72
|
-
if (typeof token !== 'string' || !token.trim()) {
|
|
73
|
-
return { ok: false, error: 'Outside workspace file access requires a grant' };
|
|
74
|
-
}
|
|
75
|
-
const grant = outsideFileGrants.get(token.trim());
|
|
76
|
-
if (!grant) {
|
|
77
|
-
return { ok: false, error: 'Outside workspace file grant is invalid or expired' };
|
|
78
|
-
}
|
|
79
|
-
if (!grant.scopes.has(scope)) {
|
|
80
|
-
return { ok: false, error: 'Outside workspace file grant does not allow this operation' };
|
|
81
|
-
}
|
|
82
|
-
const canonicalPath = await fsPromises.realpath(targetPath);
|
|
83
|
-
if (canonicalPath !== grant.canonicalPath) {
|
|
84
|
-
return { ok: false, error: 'Outside workspace file grant does not match requested path' };
|
|
85
|
-
}
|
|
86
|
-
return { ok: true, base: grant.base, resolved: canonicalPath, granted: true };
|
|
87
|
-
};
|
|
88
|
-
|
|
89
71
|
const createCommandTimeoutMs = () => {
|
|
90
72
|
const raw = Number(process.env.OPENCHAMBER_FS_EXEC_TIMEOUT_MS);
|
|
91
73
|
if (Number.isFinite(raw) && raw > 0) return raw;
|
|
@@ -125,14 +107,30 @@ const FILE_MIME_MAP = Object.freeze({
|
|
|
125
107
|
'.xml': 'application/xml',
|
|
126
108
|
'.txt': 'text/plain',
|
|
127
109
|
'.md': 'text/markdown',
|
|
110
|
+
'.mmd': 'text/plain',
|
|
128
111
|
'.pdf': 'application/pdf',
|
|
129
112
|
'.csv': 'text/csv',
|
|
113
|
+
'.tsv': 'text/tab-separated-values',
|
|
130
114
|
'.woff2': 'font/woff2',
|
|
131
115
|
'.woff': 'font/woff',
|
|
132
116
|
'.ttf': 'font/ttf',
|
|
117
|
+
'.otf': 'font/otf',
|
|
133
118
|
'.eot': 'application/vnd.ms-fontobject',
|
|
134
119
|
'.mp3': 'audio/mpeg',
|
|
120
|
+
'.m4a': 'audio/mp4',
|
|
121
|
+
'.aac': 'audio/aac',
|
|
122
|
+
'.wav': 'audio/wav',
|
|
123
|
+
'.flac': 'audio/flac',
|
|
124
|
+
'.ogg': 'audio/ogg',
|
|
125
|
+
'.oga': 'audio/ogg',
|
|
126
|
+
'.opus': 'audio/ogg',
|
|
127
|
+
'.weba': 'audio/webm',
|
|
135
128
|
'.mp4': 'video/mp4',
|
|
129
|
+
'.m4v': 'video/mp4',
|
|
130
|
+
'.webm': 'video/webm',
|
|
131
|
+
'.mov': 'video/quicktime',
|
|
132
|
+
'.ogv': 'video/ogg',
|
|
133
|
+
'.mkv': 'video/x-matroska',
|
|
136
134
|
'.png': 'image/png',
|
|
137
135
|
'.jpg': 'image/jpeg',
|
|
138
136
|
'.jpeg': 'image/jpeg',
|
|
@@ -450,19 +448,14 @@ const escapeCloneSshKeyPath = (sshKeyPath) => {
|
|
|
450
448
|
return `'${normalized.replace(/'/g, "'\\''")}'`;
|
|
451
449
|
};
|
|
452
450
|
|
|
453
|
-
const resolveReadPathFromContext = async ({ req, targetPath,
|
|
451
|
+
const resolveReadPathFromContext = async ({ req, targetPath, resolveProjectDirectory, path, os, fsPromises, normalizeDirectoryPath, managedRoots }) => {
|
|
454
452
|
if (req.query?.allowOutsideWorkspace === 'true') {
|
|
455
453
|
const normalized = normalizeDirectoryPath(targetPath);
|
|
456
454
|
if (!normalized || typeof normalized !== 'string') {
|
|
457
455
|
return { ok: false, error: 'Path is required' };
|
|
458
456
|
}
|
|
459
457
|
const resolved = path.resolve(normalized);
|
|
460
|
-
return
|
|
461
|
-
token: req.query?.outsideFileGrant,
|
|
462
|
-
targetPath: resolved,
|
|
463
|
-
scope,
|
|
464
|
-
fsPromises,
|
|
465
|
-
});
|
|
458
|
+
return { ok: true, base: path.dirname(resolved), resolved };
|
|
466
459
|
}
|
|
467
460
|
|
|
468
461
|
return resolveWorkspacePathFromContext({
|
|
@@ -1088,19 +1081,7 @@ export const registerFsRoutes = (app, dependencies) => {
|
|
|
1088
1081
|
}
|
|
1089
1082
|
|
|
1090
1083
|
const ext = path.extname(canonicalPath).toLowerCase();
|
|
1091
|
-
const
|
|
1092
|
-
'.png': 'image/png',
|
|
1093
|
-
'.jpg': 'image/jpeg',
|
|
1094
|
-
'.jpeg': 'image/jpeg',
|
|
1095
|
-
'.gif': 'image/gif',
|
|
1096
|
-
'.svg': 'image/svg+xml',
|
|
1097
|
-
'.webp': 'image/webp',
|
|
1098
|
-
'.ico': 'image/x-icon',
|
|
1099
|
-
'.bmp': 'image/bmp',
|
|
1100
|
-
'.avif': 'image/avif',
|
|
1101
|
-
'.pdf': 'application/pdf',
|
|
1102
|
-
};
|
|
1103
|
-
const mimeType = mimeMap[ext] || 'application/octet-stream';
|
|
1084
|
+
const mimeType = FILE_MIME_MAP[ext] || 'application/octet-stream';
|
|
1104
1085
|
|
|
1105
1086
|
const download = req.query.download === 'true';
|
|
1106
1087
|
if (download) {
|
|
@@ -1114,11 +1095,35 @@ export const registerFsRoutes = (app, dependencies) => {
|
|
|
1114
1095
|
res.setHeader('Content-Disposition', `attachment; filename="${fallback}"; filename*=UTF-8''${encoded}`);
|
|
1115
1096
|
}
|
|
1116
1097
|
|
|
1117
|
-
const content = await fsPromises.readFile(canonicalPath);
|
|
1118
1098
|
res.setHeader('Cache-Control', 'no-store');
|
|
1119
|
-
|
|
1120
|
-
|
|
1099
|
+
res.setHeader('Referrer-Policy', 'no-referrer');
|
|
1100
|
+
res.setHeader('Accept-Ranges', 'bytes');
|
|
1101
|
+
|
|
1102
|
+
// A byte span is streamed from disk rather than read whole: the audio
|
|
1103
|
+
// and video players ask for one on every seek, and a recording can be
|
|
1104
|
+
// hundreds of megabytes.
|
|
1105
|
+
const range = resolveByteRange(req.headers?.range, stats.size);
|
|
1106
|
+
if (range.kind === 'unsatisfiable') {
|
|
1107
|
+
res.setHeader('Content-Range', `bytes */${stats.size}`);
|
|
1108
|
+
return res.status(416).end();
|
|
1109
|
+
}
|
|
1110
|
+
if (range.kind === 'range') {
|
|
1111
|
+
const handle = await fsPromises.open(canonicalPath, 'r');
|
|
1112
|
+
res.status(206);
|
|
1113
|
+
res.setHeader('Content-Range', `bytes ${range.start}-${range.end}/${stats.size}`);
|
|
1114
|
+
res.setHeader('Content-Length', String(range.end - range.start + 1));
|
|
1115
|
+
res.type(mimeType);
|
|
1116
|
+
// The handle closes with the stream, on success and on failure alike.
|
|
1117
|
+
const stream = handle.createReadStream({ start: range.start, end: range.end });
|
|
1118
|
+
stream.on('error', (error) => {
|
|
1119
|
+
console.error('Failed to stream raw file range:', error);
|
|
1120
|
+
res.destroy(error);
|
|
1121
|
+
});
|
|
1122
|
+
stream.pipe(res);
|
|
1123
|
+
return undefined;
|
|
1121
1124
|
}
|
|
1125
|
+
|
|
1126
|
+
const content = await fsPromises.readFile(canonicalPath);
|
|
1122
1127
|
return res.type(mimeType).send(content);
|
|
1123
1128
|
} catch (error) {
|
|
1124
1129
|
const err = error;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
|
+
import { Readable, Writable } from 'node:stream';
|
|
2
3
|
import path from 'path';
|
|
3
4
|
import { copyFile, mkdir, mkdtemp, rm } from 'node:fs/promises';
|
|
4
5
|
import * as nativeFs from 'node:fs/promises';
|
|
@@ -572,8 +573,7 @@ describe('fs read', () => {
|
|
|
572
573
|
expect(fsPromises.readFile).toHaveBeenCalledWith('/shared/target.txt', 'utf8');
|
|
573
574
|
});
|
|
574
575
|
|
|
575
|
-
it('
|
|
576
|
-
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
576
|
+
it('reads outside workspace files without a grant', async () => {
|
|
577
577
|
const fsPromises = {
|
|
578
578
|
stat: vi.fn(async () => ({ isFile: () => true, size: 3 })),
|
|
579
579
|
readFile: vi.fn(async () => 'secret'),
|
|
@@ -582,10 +582,9 @@ describe('fs read', () => {
|
|
|
582
582
|
|
|
583
583
|
const res = await callRead(handler, { path: '/etc/passwd', allowOutsideWorkspace: 'true' });
|
|
584
584
|
|
|
585
|
-
expect(res.statusCode).toBe(
|
|
586
|
-
expect(res.body).
|
|
587
|
-
expect(fsPromises.readFile).
|
|
588
|
-
warn.mockRestore();
|
|
585
|
+
expect(res.statusCode).toBe(200);
|
|
586
|
+
expect(res.body).toBe('secret');
|
|
587
|
+
expect(fsPromises.readFile).toHaveBeenCalledWith('/etc/passwd', 'utf8');
|
|
589
588
|
});
|
|
590
589
|
|
|
591
590
|
it('allows outside workspace reads with an exact-path grant', async () => {
|
|
@@ -611,7 +610,7 @@ describe('fs read', () => {
|
|
|
611
610
|
expect(res.body).toBe('secret');
|
|
612
611
|
});
|
|
613
612
|
|
|
614
|
-
it('
|
|
613
|
+
it('ignores legacy grants when reading another outside file', async () => {
|
|
615
614
|
const fsPromises = {
|
|
616
615
|
realpath: vi.fn(async (targetPath) => targetPath),
|
|
617
616
|
stat: vi.fn(async () => ({ isFile: () => true, size: 6 })),
|
|
@@ -630,35 +629,58 @@ describe('fs read', () => {
|
|
|
630
629
|
outsideFileGrant: grant.outsideFileGrant,
|
|
631
630
|
});
|
|
632
631
|
|
|
633
|
-
expect(res.statusCode).toBe(
|
|
634
|
-
expect(res.body).
|
|
635
|
-
expect(fsPromises.readFile).
|
|
632
|
+
expect(res.statusCode).toBe(200);
|
|
633
|
+
expect(res.body).toBe('secret');
|
|
634
|
+
expect(fsPromises.readFile).toHaveBeenCalledWith('/outside/b.txt', 'utf8');
|
|
636
635
|
});
|
|
637
636
|
|
|
638
|
-
it('
|
|
637
|
+
it('reads outside raw files without a grant and sets no-referrer', async () => {
|
|
639
638
|
const fsPromises = {
|
|
640
639
|
realpath: vi.fn(async (targetPath) => targetPath),
|
|
641
640
|
stat: vi.fn(async () => ({ isFile: () => true, size: 6 })),
|
|
642
641
|
readFile: vi.fn(async () => Buffer.from('secret')),
|
|
643
642
|
};
|
|
644
|
-
const grant = await mintOutsideFileGrant('/outside/image.png', {
|
|
645
|
-
scopes: ['raw'],
|
|
646
|
-
fsPromises,
|
|
647
|
-
path: path.posix,
|
|
648
|
-
crypto: { randomUUID: () => 'grant-raw' },
|
|
649
|
-
});
|
|
650
643
|
const handler = registerRaw(fsPromises);
|
|
651
644
|
|
|
652
645
|
const res = await callRaw(handler, {
|
|
653
646
|
path: '/outside/image.png',
|
|
654
647
|
allowOutsideWorkspace: 'true',
|
|
655
|
-
outsideFileGrant: grant.outsideFileGrant,
|
|
656
648
|
});
|
|
657
649
|
|
|
658
650
|
expect(res.statusCode).toBe(200);
|
|
659
651
|
expect(res.getHeader('referrer-policy')).toBe('no-referrer');
|
|
660
652
|
});
|
|
661
653
|
|
|
654
|
+
it('stats outside files without a grant', async () => {
|
|
655
|
+
const { app, getRoute } = createRouteRegistry();
|
|
656
|
+
registerFsRoutes(app, {
|
|
657
|
+
path: path.posix,
|
|
658
|
+
os: { homedir: () => '/home/user' },
|
|
659
|
+
fsPromises: {
|
|
660
|
+
realpath: async (targetPath) => targetPath,
|
|
661
|
+
stat: async () => ({ isFile: () => true, size: 100, mtimeMs: 123 }),
|
|
662
|
+
},
|
|
663
|
+
normalizeDirectoryPath: (p) => p,
|
|
664
|
+
resolveProjectDirectory: async () => ({ directory: '/repo' }),
|
|
665
|
+
openchamberUserConfigRoot: '/home/user/.config',
|
|
666
|
+
});
|
|
667
|
+
const res = await callRead(getRoute('GET', '/api/fs/stat'), { path: '/tmp/plan.txt', allowOutsideWorkspace: 'true' });
|
|
668
|
+
expect(res.statusCode).toBe(200);
|
|
669
|
+
expect(res.body).toEqual({ path: '/tmp/plan.txt', isFile: true, size: 100, mtimeMs: 123 });
|
|
670
|
+
});
|
|
671
|
+
|
|
672
|
+
it.each([
|
|
673
|
+
['ENOENT', 404, { error: 'File not found' }],
|
|
674
|
+
['EACCES', 403, { error: 'Access to file denied', reason: 'os-permission' }],
|
|
675
|
+
])('reports %s for outside files instead of requiring a grant', async (code, status, body) => {
|
|
676
|
+
const handler = registerRead({
|
|
677
|
+
realpath: async () => { throw Object.assign(new Error(code), { code }); },
|
|
678
|
+
});
|
|
679
|
+
const res = await callRead(handler, { path: '/tmp/plan.txt', allowOutsideWorkspace: 'true' });
|
|
680
|
+
expect(res.statusCode).toBe(status);
|
|
681
|
+
expect(res.body).toEqual(body);
|
|
682
|
+
});
|
|
683
|
+
|
|
662
684
|
it('rejects outside workspace mkdir without a trusted directory grant', async () => {
|
|
663
685
|
const fsPromises = {
|
|
664
686
|
mkdir: vi.fn(async () => undefined),
|
|
@@ -1012,6 +1034,88 @@ describe('fs exec git-read cache', () => {
|
|
|
1012
1034
|
});
|
|
1013
1035
|
});
|
|
1014
1036
|
|
|
1037
|
+
describe('fs raw byte ranges', () => {
|
|
1038
|
+
const createStreamingResponse = () => {
|
|
1039
|
+
const chunks = [];
|
|
1040
|
+
const headers = new Map();
|
|
1041
|
+
let statusCode = 200;
|
|
1042
|
+
const res = new Writable({
|
|
1043
|
+
write(chunk, _encoding, callback) {
|
|
1044
|
+
chunks.push(Buffer.from(chunk));
|
|
1045
|
+
callback();
|
|
1046
|
+
},
|
|
1047
|
+
});
|
|
1048
|
+
Object.assign(res, {
|
|
1049
|
+
status(code) { statusCode = code; return res; },
|
|
1050
|
+
json(payload) { chunks.push(Buffer.from(JSON.stringify(payload))); return res; },
|
|
1051
|
+
type() { return res; },
|
|
1052
|
+
send(payload) { chunks.push(Buffer.from(payload)); return res; },
|
|
1053
|
+
setHeader(name, value) { headers.set(name.toLowerCase(), value); return res; },
|
|
1054
|
+
getHeader(name) { return headers.get(name.toLowerCase()); },
|
|
1055
|
+
});
|
|
1056
|
+
return {
|
|
1057
|
+
res,
|
|
1058
|
+
finished: new Promise((resolve) => res.on('finish', resolve)),
|
|
1059
|
+
get statusCode() { return statusCode; },
|
|
1060
|
+
get body() { return Buffer.concat(chunks).toString('utf8'); },
|
|
1061
|
+
};
|
|
1062
|
+
};
|
|
1063
|
+
|
|
1064
|
+
const registerRawWithFile = (bytes) => {
|
|
1065
|
+
const open = vi.fn(async () => ({
|
|
1066
|
+
createReadStream: ({ start, end }) => Readable.from([bytes.subarray(start, end + 1)]),
|
|
1067
|
+
}));
|
|
1068
|
+
const readFile = vi.fn(async () => bytes);
|
|
1069
|
+
const handler = registerRaw({
|
|
1070
|
+
stat: async () => ({ isFile: () => true, size: bytes.length }),
|
|
1071
|
+
open,
|
|
1072
|
+
readFile,
|
|
1073
|
+
});
|
|
1074
|
+
return { handler, open, readFile };
|
|
1075
|
+
};
|
|
1076
|
+
|
|
1077
|
+
it('answers a bytes span with 206, the span headers, and only those bytes', async () => {
|
|
1078
|
+
const { handler, open, readFile } = registerRawWithFile(Buffer.from('0123456789'));
|
|
1079
|
+
const response = createStreamingResponse();
|
|
1080
|
+
|
|
1081
|
+
await handler({ query: { path: '/repo/clip.mp4' }, headers: { range: 'bytes=3-' } }, response.res);
|
|
1082
|
+
await response.finished;
|
|
1083
|
+
|
|
1084
|
+
expect(response.statusCode).toBe(206);
|
|
1085
|
+
expect(response.getHeader?.('content-range') ?? response.res.getHeader('content-range')).toBe('bytes 3-9/10');
|
|
1086
|
+
expect(response.res.getHeader('content-length')).toBe('7');
|
|
1087
|
+
expect(response.res.getHeader('accept-ranges')).toBe('bytes');
|
|
1088
|
+
expect(response.body).toBe('3456789');
|
|
1089
|
+
expect(open).toHaveBeenCalledWith('/repo/clip.mp4', 'r');
|
|
1090
|
+
expect(readFile).not.toHaveBeenCalled();
|
|
1091
|
+
});
|
|
1092
|
+
|
|
1093
|
+
it('serves the whole file, advertising ranges, when no span is asked for', async () => {
|
|
1094
|
+
const { handler, open } = registerRawWithFile(Buffer.from('0123456789'));
|
|
1095
|
+
const res = createMockResponse();
|
|
1096
|
+
|
|
1097
|
+
await handler({ query: { path: '/repo/clip.mp4' }, headers: {} }, res);
|
|
1098
|
+
|
|
1099
|
+
expect(res.statusCode).toBe(200);
|
|
1100
|
+
expect(res.getHeader('accept-ranges')).toBe('bytes');
|
|
1101
|
+
expect(res.body.toString('utf8')).toBe('0123456789');
|
|
1102
|
+
expect(open).not.toHaveBeenCalled();
|
|
1103
|
+
});
|
|
1104
|
+
|
|
1105
|
+
it('rejects a span past the end with 416 and the file size', async () => {
|
|
1106
|
+
const { handler, open } = registerRawWithFile(Buffer.from('0123456789'));
|
|
1107
|
+
const res = createMockResponse();
|
|
1108
|
+
res.end = vi.fn(() => res);
|
|
1109
|
+
|
|
1110
|
+
await handler({ query: { path: '/repo/clip.mp4' }, headers: { range: 'bytes=10-' } }, res);
|
|
1111
|
+
|
|
1112
|
+
expect(res.statusCode).toBe(416);
|
|
1113
|
+
expect(res.getHeader('content-range')).toBe('bytes */10');
|
|
1114
|
+
expect(res.end).toHaveBeenCalled();
|
|
1115
|
+
expect(open).not.toHaveBeenCalled();
|
|
1116
|
+
});
|
|
1117
|
+
});
|
|
1118
|
+
|
|
1015
1119
|
describe('fs raw download Content-Disposition', () => {
|
|
1016
1120
|
it('uses RFC 5987 filename*= encoding for non-ASCII filenames on download', async () => {
|
|
1017
1121
|
const fsPromises = {
|
|
@@ -1446,6 +1550,7 @@ describe('fs stat directory error handling', () => {
|
|
|
1446
1550
|
try {
|
|
1447
1551
|
await mkdir(path.join(directory, 'fs'));
|
|
1448
1552
|
await copyFile(new URL('./routes.js', import.meta.url), path.join(directory, 'fs/routes.mjs'));
|
|
1553
|
+
await copyFile(new URL('./byte-range.js', import.meta.url), path.join(directory, 'fs/byte-range.js'));
|
|
1449
1554
|
await copyFile(new URL('../path-realpath-cache.js', import.meta.url), path.join(directory, 'path-realpath-cache.js'));
|
|
1450
1555
|
expect(() => execFileSync('node', [
|
|
1451
1556
|
'--input-type=module',
|
|
@@ -43,7 +43,7 @@ The following functions are exported and used by the web server:
|
|
|
43
43
|
- `applyHunk(directory, filePath, options)`: Apply a single-hunk patch via `git apply`. `options.action` is `stage` (`git apply --cached`), `unstage` (`git apply --cached --reverse`), or `discard` (`git apply --reverse` in the working tree). Inside the index mutation queue, the server verifies that the complete patch exactly matches one current three-context-line hunk for that file and scope, then runs `--check` before applying. Applicability alone cannot prove an unstaged change: old staged or committed hunks can reverse cleanly too. Stale, historical and multi-file patches fail with a refresh error. Temporary patch files are removed on success and failure; hunk content retains CRLF bytes.
|
|
44
44
|
|
|
45
45
|
### Branch Operations
|
|
46
|
-
- `getBranchBase(directory, branch)`: Read a named creation source from reflog. After a rebase, the creation source is no longer a current parent record, so return `null` and let the user choose a base. Explicit per-runtime, directory, and branch choices in the shared UI outrank detection.
|
|
46
|
+
- `getBranchBase(directory, branch)`: Read a named creation source from reflog. After a rebase, the creation source is no longer a current parent record, so return `null` and let the user choose a base. A source that is the branch's own remote copy (`git switch feat` records `Created from refs/remotes/origin/feat`) is not a parent either and also returns `null`. Explicit per-runtime, directory, and branch choices in the shared UI outrank detection.
|
|
47
47
|
- `getBranches(directory)`: Get list of local and remote branches (filtered to active remote branches).
|
|
48
48
|
- `getUnpushedBranchCounts(directory, branchNames)`: Count commits ahead of each locally known upstream for up to five supplied local branches. This reads local refs only and omits branches without an upstream.
|
|
49
49
|
- `createBranch(directory, branchName, options)`: Create and checkout a new branch.
|
|
@@ -2501,6 +2501,18 @@ export async function getTrackingBranch(directory) {
|
|
|
2501
2501
|
return tracking || null;
|
|
2502
2502
|
}
|
|
2503
2503
|
|
|
2504
|
+
// Whether `sha` is reachable from the checked-out HEAD. An object git has never
|
|
2505
|
+
// fetched fails the same way an unrelated commit does: not an ancestor.
|
|
2506
|
+
export async function isAncestorOfHead(directory, sha) {
|
|
2507
|
+
const normalizedDirectory = normalizeDirectoryPath(directory);
|
|
2508
|
+
const normalizedSha = typeof sha === 'string' ? sha.trim() : '';
|
|
2509
|
+
if (!normalizedDirectory || !/^[0-9a-f]{7,64}$/i.test(normalizedSha)) {
|
|
2510
|
+
return false;
|
|
2511
|
+
}
|
|
2512
|
+
const result = await runGitCommand(normalizedDirectory, ['merge-base', '--is-ancestor', normalizedSha, 'HEAD']);
|
|
2513
|
+
return result.success;
|
|
2514
|
+
}
|
|
2515
|
+
|
|
2504
2516
|
async function readStatus(normalizedDirectory, lightMode) {
|
|
2505
2517
|
try {
|
|
2506
2518
|
// Prefer an explicit non-repo check before simple-git status so a missing
|
|
@@ -3085,6 +3097,21 @@ export function parseBranchCreationSource(reflogText) {
|
|
|
3085
3097
|
return null;
|
|
3086
3098
|
}
|
|
3087
3099
|
|
|
3100
|
+
async function isOwnRemoteCopy(git, source, branchName) {
|
|
3101
|
+
const fullName = await git
|
|
3102
|
+
.raw(['rev-parse', '--symbolic-full-name', source])
|
|
3103
|
+
.then((value) => String(value || '').trim())
|
|
3104
|
+
.catch(() => '');
|
|
3105
|
+
if (!fullName.startsWith('refs/remotes/')) return false;
|
|
3106
|
+
const upstream = await git
|
|
3107
|
+
.raw(['rev-parse', '--symbolic-full-name', `refs/heads/${branchName}@{upstream}`])
|
|
3108
|
+
.then((value) => String(value || '').trim())
|
|
3109
|
+
.catch(() => '');
|
|
3110
|
+
if (upstream && fullName === upstream) return true;
|
|
3111
|
+
// Upstream may be unset; a remote ref with the branch's own name is still its copy.
|
|
3112
|
+
return fullName.slice('refs/remotes/'.length).split('/').slice(1).join('/') === branchName;
|
|
3113
|
+
}
|
|
3114
|
+
|
|
3088
3115
|
/**
|
|
3089
3116
|
* Resolve the branch the given branch was created from, from its reflog.
|
|
3090
3117
|
* Returns { base: null } when git has no authoritative record (clone, detached
|
|
@@ -3118,6 +3145,13 @@ export async function getBranchBase(directory, branch) {
|
|
|
3118
3145
|
return { base: null };
|
|
3119
3146
|
}
|
|
3120
3147
|
|
|
3148
|
+
// `git switch feat` from a remote branch records "Created from
|
|
3149
|
+
// refs/remotes/origin/feat": the branch's own remote copy, not a parent.
|
|
3150
|
+
// Comparing against it hides every pushed commit.
|
|
3151
|
+
if (await isOwnRemoteCopy(git, source, branchName)) {
|
|
3152
|
+
return { base: null };
|
|
3153
|
+
}
|
|
3154
|
+
|
|
3121
3155
|
return { base: source };
|
|
3122
3156
|
}
|
|
3123
3157
|
|
|
@@ -2316,6 +2316,14 @@ describe.runIf(canRunGit())('getRangeDiff', () => {
|
|
|
2316
2316
|
}
|
|
2317
2317
|
});
|
|
2318
2318
|
|
|
2319
|
+
it('does not treat a branch checked out from its own remote copy as its base', async () => {
|
|
2320
|
+
const { repository } = createRepositoryWithRemote();
|
|
2321
|
+
runGit(repository, ['checkout', '-b', 'react', '--track', 'origin/react']);
|
|
2322
|
+
expect(await getBranchBase(repository, 'react')).toEqual({ base: null });
|
|
2323
|
+
runGit(repository, ['checkout', '--no-track', '-b', 'loose', 'origin/react']);
|
|
2324
|
+
expect(await getBranchBase(repository, 'loose')).toEqual({ base: 'origin/react' });
|
|
2325
|
+
});
|
|
2326
|
+
|
|
2319
2327
|
it('asks for a new base after restacking and compares against the selected parent', async () => {
|
|
2320
2328
|
const { repository } = createRepositoryWithRemote();
|
|
2321
2329
|
runGit(repository, ['checkout', '-b', 'child', 'origin/react']);
|
|
@@ -83,7 +83,7 @@ that page, so callers cannot mistake a partial page for a complete one.
|
|
|
83
83
|
- It first searches for **open** PRs by likely source owner plus exact head branch.
|
|
84
84
|
- If that fails, it falls back to broader GitHub search for open PRs on the branch name.
|
|
85
85
|
- An **open PR from any candidate repo always wins** over a closed/merged one, so a merged fork PR can never hide an open upstream PR for the same head.
|
|
86
|
-
- Only when no target has an open PR does it return the branch's newest closed/merged PR, as history.
|
|
86
|
+
- Only when no target has an open PR does it return the branch's newest closed/merged PR, as history — and only when that PR's head commit is an ancestor of the checkout's `HEAD`. History is matched by branch name, and names get reused: a fresh worktree cut from the default branch under a name that was merged before must not inherit the old PR.
|
|
87
87
|
- History is looked up **only for the ranked-first remote and the branch's own name** — the repo it actually pushes to. Live status is worth searching the whole fork network for; history is not, and asking every target for it multiplies serial GitHub calls until the route hits its `12s` resolve timeout and returns no status at all.
|
|
88
88
|
- The history answer is remembered per repo+branch so discovery polls do not re-query it: a found closed/merged record for `6h`, and "no history yet" for `10m`. A found record only changes if a second PR appears on the same head, and while that one is open the open-PR path wins without ever reading this cache.
|
|
89
89
|
- Creating, merging, or closing a PR invalidates both the shared repo pull list and that remembered history.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { stat } from 'node:fs/promises';
|
|
2
|
-
import { getRemotes, getTrackingBranch } from '../git/index.js';
|
|
2
|
+
import { getRemotes, getTrackingBranch, isAncestorOfHead } from '../git/index.js';
|
|
3
3
|
import { resolveGitHubRepoFromDirectory } from './repo/index.js';
|
|
4
4
|
import { noteIfGitHubRateLimit } from './rate-limit.js';
|
|
5
5
|
|
|
@@ -543,6 +543,26 @@ const searchFallbackPr = async ({ octokit, branch, repoNames }) => {
|
|
|
543
543
|
|
|
544
544
|
const isTerminalPr = (pr) => Boolean(pr) && (pr.state === 'closed' || Boolean(pr.merged_at));
|
|
545
545
|
|
|
546
|
+
// A closed/merged PR is matched by head branch NAME, and names get reused: a
|
|
547
|
+
// fresh worktree called `feature` cut from the default branch would inherit
|
|
548
|
+
// the merged PR of last month's `feature`. The PR only belongs to this checkout
|
|
549
|
+
// when the commit it was merged or closed at is part of the checkout's history.
|
|
550
|
+
// `isAncestor` is the git check, replaceable so the tests need no git repository.
|
|
551
|
+
const isHistoricalPrOfCheckout = async (directory, pr, { isAncestor = isAncestorOfHead } = {}) => {
|
|
552
|
+
const headSha = normalizeText(pr?.head?.sha);
|
|
553
|
+
if (!headSha) {
|
|
554
|
+
return false;
|
|
555
|
+
}
|
|
556
|
+
try {
|
|
557
|
+
return await isAncestor(directory, headSha);
|
|
558
|
+
} catch {
|
|
559
|
+
return false;
|
|
560
|
+
}
|
|
561
|
+
};
|
|
562
|
+
|
|
563
|
+
// Exported for focused unit tests.
|
|
564
|
+
export { isHistoricalPrOfCheckout };
|
|
565
|
+
|
|
546
566
|
/**
|
|
547
567
|
* Resolve the PRs a branch is associated with in one repo target.
|
|
548
568
|
*
|
|
@@ -764,7 +784,7 @@ export async function resolveGitHubPrStatus({ octokit, directory, branch, remote
|
|
|
764
784
|
}
|
|
765
785
|
}
|
|
766
786
|
|
|
767
|
-
if (historicalMatch) {
|
|
787
|
+
if (historicalMatch && await isHistoricalPrOfCheckout(directory, historicalMatch.pr)) {
|
|
768
788
|
return historicalMatch;
|
|
769
789
|
}
|
|
770
790
|
|
|
@@ -1,21 +1,10 @@
|
|
|
1
1
|
import { afterEach, beforeEach, describe, expect, mock, test, vi } from 'bun:test';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
mock.module('../git/index.js', () => ({
|
|
6
|
-
getRemotes: async () => [],
|
|
7
|
-
getTrackingBranch: async () => null,
|
|
8
|
-
}));
|
|
3
|
+
import { findBranchPrCandidates, invalidateRepoPullsCache, isHistoricalPrOfCheckout } from './pr-status.js';
|
|
9
4
|
|
|
10
|
-
mock
|
|
11
|
-
resolveGitHubRepoFromDirectory: async () => null,
|
|
12
|
-
}));
|
|
13
|
-
|
|
14
|
-
mock.module('./rate-limit.js', () => ({
|
|
15
|
-
noteIfGitHubRateLimit: () => {},
|
|
16
|
-
}));
|
|
5
|
+
const listMock = mock(async () => ({ data: [] }));
|
|
17
6
|
|
|
18
|
-
const
|
|
7
|
+
const isAncestorMock = mock(async () => false);
|
|
19
8
|
|
|
20
9
|
const openPr = {
|
|
21
10
|
number: 15,
|
|
@@ -180,3 +169,27 @@ describe('findBranchPrCandidates', () => {
|
|
|
180
169
|
expect(listMock.mock.calls.length).toBeGreaterThan(callsAfterFirst + 1);
|
|
181
170
|
});
|
|
182
171
|
});
|
|
172
|
+
|
|
173
|
+
describe('isHistoricalPrOfCheckout', () => {
|
|
174
|
+
beforeEach(() => {
|
|
175
|
+
isAncestorMock.mockReset();
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
test('a merged PR whose head commit is in the checkout history belongs to it', async () => {
|
|
179
|
+
isAncestorMock.mockImplementation(async () => true);
|
|
180
|
+
const pr = { ...mergedPr, head: { ...mergedPr.head, sha: 'abc1234' } };
|
|
181
|
+
expect(await isHistoricalPrOfCheckout('/repo', pr, { isAncestor: isAncestorMock })).toBe(true);
|
|
182
|
+
expect(isAncestorMock).toHaveBeenCalledWith('/repo', 'abc1234');
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
test('a reused branch name without the merged commits does not inherit the PR', async () => {
|
|
186
|
+
isAncestorMock.mockImplementation(async () => false);
|
|
187
|
+
const pr = { ...mergedPr, head: { ...mergedPr.head, sha: 'abc1234' } };
|
|
188
|
+
expect(await isHistoricalPrOfCheckout('/repo', pr, { isAncestor: isAncestorMock })).toBe(false);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
test('a PR without a head sha is never attributed', async () => {
|
|
192
|
+
expect(await isHistoricalPrOfCheckout('/repo', mergedPr, { isAncestor: isAncestorMock })).toBe(false);
|
|
193
|
+
expect(isAncestorMock).not.toHaveBeenCalled();
|
|
194
|
+
});
|
|
195
|
+
});
|