@openchamber/web 1.24.0 → 1.24.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.
Files changed (131) hide show
  1. package/bin/cli.test.js +7 -6
  2. package/bin/lib/cli-http.js +5 -1
  3. package/dist/assets/{CodeMirrorCommentWidgets-C9kV-n7r.js → CodeMirrorCommentWidgets-DvUH815P.js} +1 -1
  4. package/dist/assets/DiffView-DkC3xlRJ.js +4 -0
  5. package/dist/assets/{FilesView-vjJx7VaM.js → FilesView-D0bM9FVB.js} +6 -6
  6. package/dist/assets/GitView-Bxuv3dfP.js +6 -0
  7. package/dist/assets/GuestAttachDialog-B0u3Q5uO.js +1 -0
  8. package/dist/assets/{JsonTreeView-D_4G5X6-.js → JsonTreeView-BBVPFM5K.js} +1 -1
  9. package/dist/assets/{LinearIssuesView-1uKhePfH.js → LinearIssuesView-UI1FcSC8.js} +1 -1
  10. package/dist/assets/{MarkdownImageGallery-Ix7N_2wp.js → MarkdownImageGallery-CUJxH8Le.js} +1 -1
  11. package/dist/assets/{MarkdownRendererImpl-Deel_y5S.js → MarkdownRendererImpl-D5BZOg8X.js} +1 -1
  12. package/dist/assets/{OnboardingScreen-ToIakxb_.js → OnboardingScreen-5Gou9cGD.js} +1 -1
  13. package/dist/assets/{PatchDiff-BjMgezr1.js → PatchDiff-C4rE5k6z.js} +1 -1
  14. package/dist/assets/{PierreDiffViewer-53Ghfnlr.js → PierreDiffViewer-ByRVu6ss.js} +1 -1
  15. package/dist/assets/{PlanView-BGAzxDwD.js → PlanView-u2yi5XGJ.js} +4 -4
  16. package/dist/assets/PluginPane-QxjsKYeO.js +3 -0
  17. package/dist/assets/SettingsView-Fo5ZqMaT.js +29 -0
  18. package/dist/assets/SettingsWindow-HVDVANjJ.js +1 -0
  19. package/dist/assets/{SubmoduleDiffSummary--YFqK6Ih.js → SubmoduleDiffSummary-D3hzkybB.js} +1 -1
  20. package/dist/assets/{ToolOutputDialog-DRWBvdaJ.js → ToolOutputDialog-3J6IRayW.js} +6 -6
  21. package/dist/assets/{ToolPartDiffPreview-BxZJCU28.js → ToolPartDiffPreview-DarxPjSd.js} +1 -1
  22. package/dist/assets/{VirtualizedFileDiff-DCXjBGRf.js → VirtualizedFileDiff-CZgXWHjU.js} +4 -4
  23. package/dist/assets/{WalkthroughView-CfIPvWWa.js → WalkthroughView-wSpED5L4.js} +2 -2
  24. package/dist/assets/{appThemeRegistry-DDROzcUO.js → appThemeRegistry-Cf8KitzT.js} +1 -1
  25. package/dist/assets/commitAndPush-DZnzlhvc.js +1 -0
  26. package/dist/assets/{computeVirtualFileMetrics-DHgQIkUq.js → computeVirtualFileMetrics-VYnT_A2h.js} +1 -1
  27. package/dist/assets/{de-CX_f-T5U.js → de-BM_8EDD3.js} +4 -4
  28. package/dist/assets/{es-BERmWNn_.js → es-CxZjlqpo.js} +3 -3
  29. package/dist/assets/{fr-BjYYE_-z.js → fr-VCixCnMW.js} +4 -4
  30. package/dist/assets/{index-WjufPkIV.js → index-3U4CtS9b.js} +1 -1
  31. package/dist/assets/index-B9Hvzjwl.css +1 -0
  32. package/dist/assets/index-DLHQogv8.js +40 -0
  33. package/dist/assets/{isDiffPlainText-D9faP70y.js → isDiffPlainText-ImDG3Uhg.js} +1 -1
  34. package/dist/assets/{isFilePlainText-6qOcz5Ky.js → isFilePlainText-D_YDVYDb.js} +1 -1
  35. package/dist/assets/{ja-DxqeAk9N.js → ja-CZ5k_GyD.js} +4 -4
  36. package/dist/assets/{ko-Dty1aUod.js → ko-7YM3A1Xh.js} +4 -4
  37. package/dist/assets/{main-Bjcre_GE.js → main-CycplCph.js} +2 -2
  38. package/dist/assets/main-DFYTCx5o.js +896 -0
  39. package/dist/assets/markdownCore-DHvqMxPn.js +5 -0
  40. package/dist/assets/{miniChat-Dz_bPgMc.js → miniChat-DIQKfY2V.js} +2 -2
  41. package/dist/assets/{mobile-BbZPBJrK.js → mobile-BMwz5q-m.js} +2 -2
  42. package/dist/assets/{patchFileDiff-BvU6KOQC.js → patchFileDiff-DDQ6Rq5e.js} +3 -3
  43. package/dist/assets/{pl-CX-_ROkr.js → pl-BcgDO_w5.js} +4 -4
  44. package/dist/assets/{pt-BR-DhRR1arx.js → pt-BR-CU2u_1q5.js} +3 -3
  45. package/dist/assets/renderElectronMiniChatApp-3_d6g6CU.js +2 -0
  46. package/dist/assets/renderMobileApp-D0Y8DtkA.js +25 -0
  47. package/dist/assets/runtimeEndpointReset-DhC3REb2.js +25 -0
  48. package/dist/assets/{scheduledTasksApi-DW3xqMQ8.js → scheduledTasksApi-D8pq6gQz.js} +1 -1
  49. package/dist/assets/{shikiHighlight-DsxD9QEa.js → shikiHighlight-1imXsir9.js} +1 -1
  50. package/dist/assets/{textMateThemeFromAppTheme-Da7ed8qM.js → textMateThemeFromAppTheme-Dgqc63LZ.js} +1 -1
  51. package/dist/assets/tr-DuYhOzNe.js +7 -0
  52. package/dist/assets/{uk-CD21CXFV.js → uk-Cuk7-uvq.js} +3 -3
  53. package/dist/assets/{useAppFontEffects-hfv2s6mZ.js → useAppFontEffects-BItUWdo4.js} +147 -147
  54. package/dist/assets/{useInlineCommentController-BmtfVbo8.js → useInlineCommentController-CkbKsm7m.js} +2 -2
  55. package/dist/assets/useRootScrollLock-vmzxZjWA.js +2 -0
  56. package/dist/assets/{vendor-codemirror-language-data-BPMJpOpT.js → vendor-codemirror-language-data-BDyxuqK4.js} +2 -2
  57. package/dist/assets/{vendor-tanstack-react-virtual-g05Cx3z9.js → vendor-tanstack-react-virtual-ClYN8CzB.js} +1 -1
  58. package/dist/assets/{vendor-tanstack-virtual-core-Dubg10g5.js → vendor-tanstack-virtual-core-BewVQryB.js} +1 -1
  59. package/dist/assets/{web-components-U-hWbgJo.js → web-components-D7FinaeH.js} +1 -1
  60. package/dist/assets/{zh-CN-BWvlPHY-.js → zh-CN-CUWoiRHd.js} +3 -3
  61. package/dist/assets/{zh-TW-CRp5dJU2.js → zh-TW-CQ8EBSBN.js} +3 -3
  62. package/dist/index.html +3 -3
  63. package/dist/mini-chat.html +3 -3
  64. package/dist/mobile.html +3 -3
  65. package/package.json +4 -3
  66. package/server/index.js +26 -7
  67. package/server/lib/changelog/update-notes.js +2 -1
  68. package/server/lib/changelog/update-notes.test.js +19 -0
  69. package/server/lib/event-stream/DOCUMENTATION.md +23 -0
  70. package/server/lib/event-stream/delta-coalescer.js +0 -0
  71. package/server/lib/event-stream/delta-coalescer.test.js +292 -0
  72. package/server/lib/event-stream/global-hub.js +53 -23
  73. package/server/lib/event-stream/global-hub.test.js +160 -0
  74. package/server/lib/event-stream/global-ws-bridge.js +1 -0
  75. package/server/lib/event-stream/index.js +4 -0
  76. package/server/lib/git/DOCUMENTATION.md +17 -4
  77. package/server/lib/git/routes.js +1 -1
  78. package/server/lib/git/serial-refresh.js +93 -0
  79. package/server/lib/git/serial-refresh.test.js +112 -0
  80. package/server/lib/git/service.js +232 -62
  81. package/server/lib/git/service.test.js +273 -0
  82. package/server/lib/github/pr-status.js +5 -5
  83. package/server/lib/github/pr-status.test.js +1 -1
  84. package/server/lib/github/routes.js +4 -4
  85. package/server/lib/guests/DOCUMENTATION.md +5 -3
  86. package/server/lib/guests/background.test.js +83 -0
  87. package/server/lib/guests/catalog.js +20 -9
  88. package/server/lib/guests/catalog.test.js +5 -5
  89. package/server/lib/guests/routes.js +2 -2
  90. package/server/lib/message-queue/DOCUMENTATION.md +6 -0
  91. package/server/lib/message-queue/runtime.js +5 -0
  92. package/server/lib/message-queue/runtime.test.js +32 -1
  93. package/server/lib/opencode/feature-routes-runtime.js +5 -0
  94. package/server/lib/opencode/settings-helpers.js +3 -0
  95. package/server/lib/opencode/settings-registry.json +8 -0
  96. package/server/lib/permission-auto-accept/DOCUMENTATION.md +8 -0
  97. package/server/lib/permission-auto-accept/runtime.js +13 -0
  98. package/server/lib/permission-auto-accept/runtime.test.js +37 -1
  99. package/server/lib/routing/DOCUMENTATION.md +81 -0
  100. package/server/lib/routing/defaults.js +98 -0
  101. package/server/lib/routing/feature-flag.js +11 -0
  102. package/server/lib/routing/history.js +34 -0
  103. package/server/lib/routing/jev.js +98 -0
  104. package/server/lib/routing/routes.http.test.js +100 -0
  105. package/server/lib/routing/routes.js +81 -0
  106. package/server/lib/routing/runtime.js +217 -0
  107. package/server/lib/routing/runtime.test.js +188 -0
  108. package/server/lib/routing/store.js +249 -0
  109. package/server/lib/routing/store.test.js +96 -0
  110. package/server/lib/security/request-security.js +9 -5
  111. package/server/lib/security/request-security.test.js +37 -0
  112. package/server/lib/ui-auth/DOCUMENTATION.md +8 -0
  113. package/server/lib/ui-auth/session-cookie.js +51 -0
  114. package/server/lib/ui-auth/session-cookie.test.js +46 -0
  115. package/server/lib/ui-auth/ui-auth.js +13 -9
  116. package/server/lib/ui-auth/ui-auth.test.js +56 -0
  117. package/dist/assets/DiffView-B7YkbY-u.js +0 -4
  118. package/dist/assets/DirtyBranchSwitchDialog-CU0A93Zx.js +0 -1
  119. package/dist/assets/GitView-BLhlMYEY.js +0 -6
  120. package/dist/assets/GuestAttachDialog-B-fwE8r3.js +0 -3
  121. package/dist/assets/SettingsView-n2X-jfBB.js +0 -29
  122. package/dist/assets/SettingsWindow-Bi8LE9XI.js +0 -1
  123. package/dist/assets/index-DpzTz2UH.css +0 -1
  124. package/dist/assets/index-Dy8xgawx.js +0 -40
  125. package/dist/assets/main-BOYSXfYn.js +0 -896
  126. package/dist/assets/markdownCore-DPrwM1rU.js +0 -5
  127. package/dist/assets/renderElectronMiniChatApp-uNEUkeAI.js +0 -2
  128. package/dist/assets/renderMobileApp-BK1kFlcJ.js +0 -25
  129. package/dist/assets/runtimeEndpointReset-BULHvOwb.js +0 -25
  130. package/dist/assets/tr-cIQtYBpg.js +0 -7
  131. package/dist/assets/useRootScrollLock-Cwc4kSl2.js +0 -1
@@ -21,6 +21,7 @@ import {
21
21
  getCommitFiles,
22
22
  getLog,
23
23
  getStatus,
24
+ getTrackingBranch,
24
25
  getWorktrees,
25
26
  isGitRepository,
26
27
  observeWorktreeTopology,
@@ -44,6 +45,7 @@ import {
44
45
  validateWorktreeCreate,
45
46
  parseBranchCreationSource,
46
47
  getRangeFiles,
48
+ push,
47
49
  } from './service.js';
48
50
 
49
51
  // ---------------------------------------------------------------------------
@@ -730,6 +732,142 @@ describe('getStatus', () => {
730
732
  process.chdir(previousCwd);
731
733
  }
732
734
  });
735
+
736
+ it('scopes diff stats by staged and working instead of combining a partially staged file', async () => {
737
+ if (!canRunGit()) return;
738
+
739
+ const repo = createTempDir();
740
+ runGit(repo, ['init', '-b', 'main']);
741
+ runGit(repo, ['config', 'user.email', 'test@example.com']);
742
+ runGit(repo, ['config', 'user.name', 'Test User']);
743
+ const file = 'test.txt';
744
+ const filePath = path.join(repo, file);
745
+ fs.writeFileSync(filePath, 'one\ntwo\nthree\n');
746
+ runGit(repo, ['add', file]);
747
+ runGit(repo, ['commit', '-m', 'initial']);
748
+
749
+ // Stage one new line, then keep editing without staging another.
750
+ fs.writeFileSync(filePath, 'one\ntwo\nthree\nstaged\n');
751
+ runGit(repo, ['add', file]);
752
+ fs.writeFileSync(filePath, 'one\ntwo\nthree\nstaged\nworking\n');
753
+
754
+ const status = await getStatus(repo);
755
+
756
+ expect(status.diffStats.staged[file]).toEqual({ insertions: 1, deletions: 0 });
757
+ expect(status.diffStats.working[file]).toEqual({ insertions: 1, deletions: 0 });
758
+ });
759
+
760
+ it('scopes untracked files to working stats and staged additions to staged stats', async () => {
761
+ if (!canRunGit()) return;
762
+
763
+ const repo = createTempDir();
764
+ runGit(repo, ['init', '-b', 'main']);
765
+ runGit(repo, ['config', 'user.email', 'test@example.com']);
766
+ runGit(repo, ['config', 'user.name', 'Test User']);
767
+ fs.writeFileSync(path.join(repo, 'tracked.txt'), 'tracked\n');
768
+ runGit(repo, ['add', 'tracked.txt']);
769
+ runGit(repo, ['commit', '-m', 'initial']);
770
+
771
+ fs.writeFileSync(path.join(repo, 'untracked.txt'), 'a\nb\n');
772
+ fs.writeFileSync(path.join(repo, 'staged.txt'), 'c\nd\ne\n');
773
+ runGit(repo, ['add', 'staged.txt']);
774
+
775
+ const status = await getStatus(repo);
776
+
777
+ expect(status.diffStats.working['untracked.txt']).toEqual({ insertions: 2, deletions: 0 });
778
+ expect(status.diffStats.staged['staged.txt']).toEqual({ insertions: 3, deletions: 0 });
779
+ expect(status.diffStats.working['staged.txt']).toBeUndefined();
780
+ });
781
+ });
782
+
783
+ describe('push', () => {
784
+ it('publishes the current branch with an upstream and leaves other local branches alone', async () => {
785
+ if (!canRunGit()) return;
786
+
787
+ const remote = createTempDir();
788
+ const repo = createTempDir();
789
+ runGit(remote, ['init', '--bare']);
790
+ runGit(repo, ['init', '-b', 'main']);
791
+ runGit(repo, ['config', 'user.email', 'test@example.com']);
792
+ runGit(repo, ['config', 'user.name', 'Test User']);
793
+ fs.writeFileSync(path.join(repo, 'README.md'), '# Test\n');
794
+ runGit(repo, ['add', 'README.md']);
795
+ runGit(repo, ['commit', '-m', 'Initial commit']);
796
+ runGit(repo, ['remote', 'add', 'fork', remote]);
797
+ runGit(repo, ['branch', 'unrelated']);
798
+ runGit(repo, ['checkout', '-b', 'feature']);
799
+ fs.writeFileSync(path.join(repo, 'feature.txt'), 'published\n');
800
+ runGit(repo, ['add', 'feature.txt']);
801
+ runGit(repo, ['commit', '-m', 'Add feature']);
802
+
803
+ const published = await push(repo, { remote: 'fork' });
804
+ expect(published.pushed).toEqual([{ local: 'refs/heads/feature', remote: 'fork' }]);
805
+
806
+ expect(runGit(repo, ['rev-parse', '--abbrev-ref', '--symbolic-full-name', '@{u}']).trim()).toBe('fork/feature');
807
+ expect(runGit(remote, ['rev-parse', 'refs/heads/feature']).trim()).toBe(runGit(repo, ['rev-parse', 'HEAD']).trim());
808
+ expect(() => runGit(remote, ['rev-parse', 'refs/heads/unrelated'])).toThrow();
809
+ expect(() => runGit(remote, ['rev-parse', 'refs/heads/main'])).toThrow();
810
+
811
+ expect((await push(repo)).pushed).toEqual([]);
812
+ fs.appendFileSync(path.join(repo, 'feature.txt'), 'next commit\n');
813
+ runGit(repo, ['commit', '-am', 'Update feature']);
814
+ expect((await push(repo)).pushed).toEqual([{ local: 'refs/heads/feature', remote: 'fork' }]);
815
+ expect(runGit(remote, ['rev-parse', 'feature']).trim()).toBe(runGit(repo, ['rev-parse', 'HEAD']).trim());
816
+
817
+ runGit(repo, ['reset', '--hard', 'HEAD~1']);
818
+ await expect(push(repo)).rejects.toThrow();
819
+ expect((await push(repo, { options: ['--force-with-lease'] })).pushed)
820
+ .toEqual([{ local: 'refs/heads/feature', remote: 'fork' }]);
821
+ expect(runGit(remote, ['rev-parse', 'feature']).trim()).toBe(runGit(repo, ['rev-parse', 'HEAD']).trim());
822
+ });
823
+
824
+ it.each(['remote.pushDefault', 'branch.next.pushRemote'])('preserves the %s destination independently of the fetch remote', async (key) => {
825
+ const { repository, remote: upstream } = createRepositoryWithRemote({ remoteName: 'upstream', defaultBranch: 'next' });
826
+ const fork = createTempDir();
827
+ runGit(fork, ['init', '--bare']);
828
+ runGit(repository, ['remote', 'add', 'fork', fork]);
829
+ runGit(repository, ['branch', '--set-upstream-to=upstream/next']);
830
+ if (key === 'branch.next.pushRemote') runGit(repository, ['config', 'remote.pushDefault', 'upstream']);
831
+ runGit(repository, ['config', key, 'fork']);
832
+ const upstreamHead = runGit(upstream, ['rev-parse', 'next']).trim();
833
+ fs.appendFileSync(path.join(repository, 'README.md'), 'fork change\n');
834
+ runGit(repository, ['commit', '-am', 'Change for fork']);
835
+
836
+ expect((await push(repository)).pushed).toEqual([{ local: 'refs/heads/next', remote: 'fork' }]);
837
+ expect(runGit(fork, ['rev-parse', 'next']).trim()).toBe(runGit(repository, ['rev-parse', 'HEAD']).trim());
838
+ expect(runGit(upstream, ['rev-parse', 'next']).trim()).toBe(upstreamHead);
839
+ expect(readBranchConfig(repository, 'next', 'remote')).toBe('upstream');
840
+ expect((await push(repository)).pushed).toEqual([]);
841
+ });
842
+
843
+ it.each(['remote.pushDefault', 'branch.next.pushRemote'])('uses %s for first publication without an upstream', async (key) => {
844
+ const { repository, remote: origin } = createRepositoryWithRemote();
845
+ const fork = createTempDir();
846
+ runGit(fork, ['init', '--bare']);
847
+ runGit(repository, ['remote', 'add', 'fork', fork]);
848
+ runGit(repository, ['config', key, 'fork']);
849
+ runGit(repository, ['config', 'push.autoSetupRemote', 'false']);
850
+
851
+ expect((await push(repository)).pushed).toEqual([{ local: 'refs/heads/next', remote: 'fork' }]);
852
+ expect(readBranchConfig(repository, 'next', 'remote')).toBe('fork');
853
+ expect(() => runGit(origin, ['rev-parse', 'refs/heads/next'])).toThrow();
854
+ });
855
+
856
+ it('lets an explicit push remote override configured destinations', async () => {
857
+ const { repository, remote: origin } = createRepositoryWithRemote({ defaultBranch: 'next' });
858
+ const fork = createTempDir();
859
+ runGit(fork, ['init', '--bare']);
860
+ runGit(repository, ['remote', 'add', 'fork', fork]);
861
+ runGit(repository, ['branch', '--set-upstream-to=origin/next']);
862
+ runGit(repository, ['config', 'branch.next.pushRemote', 'fork']);
863
+ fs.appendFileSync(path.join(repository, 'README.md'), 'origin change\n');
864
+ runGit(repository, ['commit', '-am', 'Change for origin']);
865
+
866
+ expect((await push(repository, { remote: 'origin' })).pushed)
867
+ .toEqual([{ local: 'refs/heads/next', remote: 'origin' }]);
868
+ expect(runGit(origin, ['rev-parse', 'next']).trim()).toBe(runGit(repository, ['rev-parse', 'HEAD']).trim());
869
+ expect(() => runGit(fork, ['rev-parse', 'next'])).toThrow();
870
+ });
733
871
  });
734
872
 
735
873
  // ---------------------------------------------------------------------------
@@ -2388,3 +2526,138 @@ describe.runIf(canRunGit())('getRangeFiles', () => {
2388
2526
  expect(copyEntry.path).toBe('copied destination.md');
2389
2527
  });
2390
2528
  });
2529
+
2530
+ // ---------------------------------------------------------------------------
2531
+ // getTrackingBranch
2532
+ // ---------------------------------------------------------------------------
2533
+
2534
+ describe('getTrackingBranch', () => {
2535
+ const createCommittedRepo = () => {
2536
+ const repo = createTempDir();
2537
+ runGit(repo, ['init', '-b', 'main']);
2538
+ runGit(repo, ['config', 'user.email', 'test@example.com']);
2539
+ runGit(repo, ['config', 'user.name', 'Test User']);
2540
+ runGit(repo, ['commit', '--allow-empty', '-m', 'Initial commit']);
2541
+ return repo;
2542
+ };
2543
+
2544
+ it('reports the same upstream name as status, including a gone upstream', async () => {
2545
+ if (!canRunGit()) return;
2546
+
2547
+ const repo = createCommittedRepo();
2548
+ await expect(getTrackingBranch(repo)).resolves.toBeNull();
2549
+
2550
+ runGit(repo, ['remote', 'add', 'origin', 'https://example.invalid/repo.git']);
2551
+ runGit(repo, ['config', 'branch.main.remote', 'origin']);
2552
+ runGit(repo, ['config', 'branch.main.merge', 'refs/heads/main']);
2553
+ await expect(getTrackingBranch(repo)).resolves.toBe('origin/main');
2554
+ expect((await getStatus(repo)).tracking).toBe('origin/main');
2555
+
2556
+ runGit(repo, ['update-ref', 'refs/remotes/origin/main', 'HEAD']);
2557
+ await expect(getTrackingBranch(repo)).resolves.toBe('origin/main');
2558
+ });
2559
+
2560
+ it('is null for a detached HEAD and outside a repository', async () => {
2561
+ if (!canRunGit()) return;
2562
+
2563
+ const repo = createCommittedRepo();
2564
+ runGit(repo, ['checkout', '--detach']);
2565
+ await expect(getTrackingBranch(repo)).resolves.toBeNull();
2566
+ await expect(getTrackingBranch(createTempDir())).resolves.toBeNull();
2567
+ });
2568
+ });
2569
+
2570
+ describe('getStatus concurrency', () => {
2571
+ it('answers overlapping reads of one repository and reflects changes made while a read ran', async () => {
2572
+ if (!canRunGit()) return;
2573
+
2574
+ const repo = createTempDir();
2575
+ runGit(repo, ['init', '-b', 'main']);
2576
+ runGit(repo, ['config', 'user.email', 'test@example.com']);
2577
+ runGit(repo, ['config', 'user.name', 'Test User']);
2578
+ runGit(repo, ['commit', '--allow-empty', '-m', 'Initial commit']);
2579
+
2580
+ const first = getStatus(repo);
2581
+ fs.writeFileSync(path.join(repo, 'late.txt'), 'added after the first read was admitted\n');
2582
+ const second = getStatus(repo, { mode: 'light' });
2583
+ const third = getStatus(repo);
2584
+
2585
+ const [firstStatus, secondStatus, thirdStatus] = await Promise.all([first, second, third]);
2586
+ expect(firstStatus.current).toBe('main');
2587
+ expect(secondStatus.files.map((file) => file.path)).toContain('late.txt');
2588
+ expect(thirdStatus.files.map((file) => file.path)).toContain('late.txt');
2589
+ // The follow-up run served both later callers at the widest requested mode.
2590
+ expect(secondStatus.diffStats).toBeDefined();
2591
+ expect(thirdStatus.diffStats).toBeDefined();
2592
+ });
2593
+ });
2594
+
2595
+ describe('getStatus untracked directories', () => {
2596
+ const callDiffRoute = async (endpoint, query) => {
2597
+ const routes = new Map();
2598
+ registerGitRoutes({ get: (url, handler) => routes.set(url, handler), post() {}, put() {}, delete() {} });
2599
+ let status = 200;
2600
+ let body;
2601
+ await routes.get(`/api/git/${endpoint}`)({ query }, {
2602
+ status(value) { status = value; return this; },
2603
+ json(value) { body = value; },
2604
+ });
2605
+ return { status, body };
2606
+ };
2607
+
2608
+ const createCommittedRepo = () => {
2609
+ const repo = createTempDir();
2610
+ runGit(repo, ['init', '-b', 'main']);
2611
+ runGit(repo, ['config', 'user.email', 'test@example.com']);
2612
+ runGit(repo, ['config', 'user.name', 'Test User']);
2613
+ fs.writeFileSync(path.join(repo, 'README.md'), '# Test\n');
2614
+ runGit(repo, ['add', 'README.md']);
2615
+ runGit(repo, ['commit', '-m', 'Initial commit']);
2616
+ return repo;
2617
+ };
2618
+
2619
+ const writeFiles = (root, count) => {
2620
+ fs.mkdirSync(root, { recursive: true });
2621
+ for (let index = 0; index < count; index += 1) {
2622
+ fs.writeFileSync(path.join(root, `file-${String(index).padStart(5, '0')}.txt`), `${index}\n`);
2623
+ }
2624
+ };
2625
+
2626
+ it('lists the files of an ordinary new directory one by one', async () => {
2627
+ if (!canRunGit()) return;
2628
+
2629
+ const repo = createCommittedRepo();
2630
+ writeFiles(path.join(repo, 'feature', 'deep'), 3);
2631
+ fs.writeFileSync(path.join(repo, 'loose.txt'), 'loose\n');
2632
+
2633
+ const paths = (await getStatus(repo)).files.map((file) => file.path);
2634
+ expect(paths).toEqual([
2635
+ 'feature/deep/file-00000.txt',
2636
+ 'feature/deep/file-00001.txt',
2637
+ 'feature/deep/file-00002.txt',
2638
+ 'loose.txt',
2639
+ ]);
2640
+ });
2641
+
2642
+ it('keeps a directory with more than a thousand new files as one entry the diff routes explain', async () => {
2643
+ if (!canRunGit()) return;
2644
+
2645
+ const repo = createCommittedRepo();
2646
+ writeFiles(path.join(repo, 'node_modules', 'pkg'), 1001);
2647
+ writeFiles(path.join(repo, 'small'), 2);
2648
+
2649
+ const status = await getStatus(repo);
2650
+ expect(status.files.map((file) => file.path)).toEqual([
2651
+ 'node_modules/',
2652
+ 'small/file-00000.txt',
2653
+ 'small/file-00001.txt',
2654
+ ]);
2655
+ expect(status.files[0]).toMatchObject({ index: '?', working_dir: '?' });
2656
+
2657
+ for (const endpoint of ['diff', 'file-diff']) {
2658
+ const { status: httpStatus, body } = await callDiffRoute(endpoint, { directory: repo, path: 'node_modules/' });
2659
+ expect(httpStatus).toBe(422);
2660
+ expect(body).toEqual({ code: 'untracked_directory', error: 'Path is a directory of untracked files: node_modules/' });
2661
+ }
2662
+ });
2663
+ });
@@ -1,5 +1,5 @@
1
1
  import { stat } from 'node:fs/promises';
2
- import { getRemotes, getStatus } from '../git/index.js';
2
+ import { getRemotes, getTrackingBranch } from '../git/index.js';
3
3
  import { resolveGitHubRepoFromDirectory } from './repo/index.js';
4
4
  import { noteIfGitHubRateLimit } from './rate-limit.js';
5
5
 
@@ -644,13 +644,13 @@ export async function resolveGitHubPrStatus({ octokit, directory, branch, remote
644
644
  const normalizedBranch = normalizeText(branch);
645
645
  const normalizedRemoteName = normalizeText(remoteName) || 'origin';
646
646
 
647
- const [status, remotes] = await Promise.all([
648
- getStatus(directory).catch(() => null),
647
+ const [tracking, remotes] = await Promise.all([
648
+ getTrackingBranch(directory).catch(() => null),
649
649
  getRemotes(directory).catch(() => []),
650
650
  ]);
651
651
 
652
- const trackingRemoteName = parseTrackingRemoteName(status?.tracking);
653
- const trackingBranchName = parseTrackingBranchName(status?.tracking);
652
+ const trackingRemoteName = parseTrackingRemoteName(tracking);
653
+ const trackingBranchName = parseTrackingBranchName(tracking);
654
654
  const branchCandidates = [];
655
655
  pushUnique(branchCandidates, normalizedBranch);
656
656
  pushUnique(branchCandidates, trackingBranchName);
@@ -4,7 +4,7 @@ const listMock = mock(async () => ({ data: [] }));
4
4
 
5
5
  mock.module('../git/index.js', () => ({
6
6
  getRemotes: async () => [],
7
- getStatus: async () => null,
7
+ getTrackingBranch: async () => null,
8
8
  }));
9
9
 
10
10
  mock.module('./repo/index.js', () => ({
@@ -781,14 +781,14 @@ export function registerGitHubRoutes(app) {
781
781
  // Determine the source remote for the head branch
782
782
  // Priority: 1) explicit headRemote, 2) tracking branch remote, 3) 'origin' if targeting non-origin
783
783
  let sourceRemote = headRemote;
784
- const { getStatus, getRemotes } = await import('../git/index.js');
784
+ const { getTrackingBranch, getRemotes } = await import('../git/index.js');
785
785
 
786
786
  // If no explicit headRemote, check the branch's tracking info
787
787
  if (!sourceRemote) {
788
- const status = await getStatus(directory).catch(() => null);
789
- if (status?.tracking) {
788
+ const tracking = await getTrackingBranch(directory).catch(() => null);
789
+ if (tracking) {
790
790
  // tracking is like "gsxdsm/fix/multi-remote-branch-creation" or "origin/main"
791
- const trackingRemote = status.tracking.split('/')[0];
791
+ const trackingRemote = tracking.split('/')[0];
792
792
  if (trackingRemote) {
793
793
  sourceRemote = trackingRemote;
794
794
  }
@@ -6,10 +6,10 @@ OpenChamber-owned install and static serve for iframe guests. This is not the Op
6
6
 
7
7
  ## Routes
8
8
 
9
- - `POST /api/guests/:id/storage` accepts the SDK's `GuestStorageRequest` and returns `GuestStorageResult`. It requires an installed, enabled, fully approved guest with a panel entry, but no additional capability. The UI host supplies the frame's own identity. Guest-scoped asset tokens cannot call this route. Data lives beside `extensions.json` in `guest-storage/<id>.json`. Each key is 1 to 128 characters, each JSON value at most 64 KiB UTF-8, the whole namespace at most 2 MiB and 2,000 keys. `storage.js` owns serialized authorization/read/write/removal; writes are atomic and failures preserve prior bytes. `uninstallGuest` removes storage for every install source. Missing keys return `found: false`, including after removal; stored JSON null returns `found: true`.
9
+ - `POST /api/guests/:id/storage` accepts the SDK's `GuestStorageRequest` and returns `GuestStorageResult`. It requires an installed, enabled, fully approved guest with either a panel or background entry, but no additional capability. The UI host supplies the frame's own identity. Guest-scoped asset tokens cannot call this route. Data lives beside `extensions.json` in `guest-storage/<id>.json`. Each key is 1 to 128 characters, each JSON value at most 64 KiB UTF-8, the whole namespace at most 2 MiB and 2,000 keys. `storage.js` owns serialized authorization/read/write/removal; writes are atomic and failures preserve prior bytes. `uninstallGuest` removes storage for every install source. Missing keys return `found: false`, including after removal; stored JSON null returns `found: true`.
10
10
  - `GET /api/guests` also exposes `pageEntry` and optional `pageTitle` for `contributes.page`. Full-screen page HTML and its built scripts pass the same install checks as attach HTML. No new serving/auth path is required.
11
11
 
12
- - `GET /api/guests` — installed guests. `attach` is `"panel"` or `"dialog"` on the row when the manifest set it, and `attachEntry` is the dialog page when the manifest's object form declared one. `version` is the package.json semver when present. `integration` is the public slice only: name, description, `auth`, setting field defs. OAuth URLs and token origins stay on the server. `service` is the public slice when the package declared one: `runtime`, optional `permissions` (socket ids + exec names), optional `socketBindings` (resolved paths for this host), and `granted`. `capabilities` is `{ requested, granted }`: `requested` is derived from the manifest (`contributes.capabilities` — `prompt`, `sessions`, `files`, `model` — plus `conversation` for a session action with `payload: ["messages"]`, `service` for a declared service, `network` for a declared integration, and `filesystem` for a declared `contributes.filesystem`), `granted` is what the user approved. `actions`, `commands`, and `tools` are the parsed `contributes.actions` / `contributes.commands` / `contributes.tools` entries as declared (present only when the package has them); the UI decides what to show from `enabled` and the grant, and owns command-name collisions and tool-rule precedence. `filesystem` is the declared pattern list when the package has one, so the approval dialog can show it. `entry` is absent for a page-less package (no `panel.entry`; tools only): the UI mounts no frame for it. A guest whose `granted` does not cover `requested` is installed but inactive: the rail, the + menu, Integrations, and every proxy treat it like a paused one until Settings → Extensions records the approval. `enabled` is false when the user paused the extension. Failure is 500, not an empty list.
12
+ - `GET /api/guests` returns installed guests. `attach` is `"panel"` or `"dialog"` when declared, and `attachEntry` is the dialog's separate HTML. `version` is the package semver. `integration` is the public slice: name, description, `auth`, and settings; OAuth URLs and tokens stay on the server. `service` includes `runtime`, optional `permissions`, optional `socketBindings`, and `granted`. `capabilities` carries `{ requested, granted }`, derived through the SDK's `requestedGuestCapabilities`. `actions`, `commands`, `tools`, and `filesystem` retain their parsed declarations; UI owns menu placement, command collisions, and tool precedence. `entry` is the optional visible panel and `backgroundEntry` is independent on-demand execution HTML. Background-only extensions get no rail surface; tools-only extensions with neither entry mount no frame. A guest without every requested grant is inactive until approval. `enabled: false` pauses it. A failed listing is 500, never an empty list.
13
13
  - `GET /api/guests/:id/oauth/status` — `{ connected, account, hasClient, settings, redirectUri }`. No secrets. Host Linear merges first-party Linear status. `redirectUri` is empty unless `auth` is `oauth`.
14
14
  - `PUT /api/guests/:id/oauth/client` — client id and optional secret from the Integrations form. OAuth guests only.
15
15
  - `PUT /api/guests/:id/token` — pasted API token. Token guests only. The host probes the declared account path. The token never goes to the iframe.
@@ -30,10 +30,12 @@ OpenChamber-owned install and static serve for iframe guests. This is not the Op
30
30
  - `POST /api/guests/updates/check` — `{ force?: boolean }` → `{ updates: Record<guestId, { version }> }` for every git install whose origin now carries a newer `package.json` `version`. The check runs `git fetch --depth 1 origin <ref|HEAD>` inside the installed clone and reads `FETCH_HEAD:package.json` through the SDK manifest parser; the only signal is semver (`updates.js` `compareSemver`, prerelease below release), no commit hashes. Results sit in a memory cache per store file and guest id for `UPDATE_CHECK_TTL_MS` (one hour); `force` asks the network again. That cache is separate from the catalog cache, so a store write does not drop it. One guest's failed fetch never hides another's update. Folder and zip installs are never checked.
31
31
  - `POST /api/guests/:id/update` — replace the installed git copy with a fresh clone of its stored origin. Answers `{ guest }` (the refreshed catalog row) or 400 `{ error }` with `not-git` (folder, zip, or no stored origin), `clone-failed`, `invalid-manifest` (also when the clone declares a different panel id), `missing-build`, `host-too-old` (body may include `required`), or `swap-failed`. Unknown id is 404. Grants, tokens, settings, and the paused flag are keyed by guest id and stay as they were; a version that asks for more capabilities shows up as needs-approval in the catalog and goes through the usual review dialog.
32
32
  - `DELETE /api/guests/:id` — drops the store row, any service grant, and socket overrides; stops a running service. Path-install does not delete the user's folder. Zip and git copies under `{openchamberDataDir}/extensions/` are deleted. Unknown id is 404.
33
- - `GET /api/guests/:id/{*filePath}` — a file inside that guest's package root. Unknown id, escape, missing file, or unknown type is 404. A page-less guest (no `entry`) is served only assets: HTML and JS under its id are 404 (`resolveGuestServedFile` with `hasPage: false`), so nothing of that package can land in a frame; its `.svg` tool icons still serve. Guest HTML gets the request's `oc_url_token` copied onto relative `script` / `link` / `img` URLs so the iframe can load its own files. That token is minted with `scope=guest:<id>` (`POST /auth/url-token?scope=guest:<id>`) and is accepted only under `GET /api/guests/<id>/`; a guest that reads it from its own URL cannot reach `/api/fs/raw` or the event stream. Every response carries `Content-Security-Policy: sandbox allow-scripts`, so a guest document opened outside the rail iframe is still sandboxed and never runs with the user's session on the app origin. Files are served as they sit on disk; the host never compiles guest sources.
33
+ - `GET /api/guests/:id/{*filePath}` serves package-local files. Unknown IDs, escapes, missing files, and unknown types return 404. HTML and JS require either `entry` or `backgroundEntry`, expressed by `resolveGuestServedFile`'s `hasRuntime` option. Tools-only extensions still serve their SVG icons but no executable content. Guest HTML propagates the scoped `oc_url_token` onto relative script/link/image URLs. The token is minted for `guest:<id>` and works only under that guest's asset route, never `/api/fs/raw` or event streams. Every response carries `Content-Security-Policy: sandbox allow-scripts`, including direct document navigation. The host serves built files from disk and never compiles guest sources.
34
34
 
35
35
  ## Install
36
36
 
37
+ `contributes.background.entry` is optional package-local `.html`, separate from `panel.entry`. Install validates its HTML and every referenced built script using the same path confinement as visible panels. `backgroundEntry` is exposed on the catalog independently of `entry`; adding it does not create a rail icon or a visible page. Capabilities, services, integrations, and storage work with either execution entry. The SDK refuses visible contributions without `panel.entry` and all runtime contributions when neither entry exists. See `packages/sdk/DOCUMENTATION.md` for on-demand invocation ownership.
38
+
37
39
  `html-styles.js` appends the SDK's shared scrollbar stylesheet to served HTML, including requests without an asset token. This applies to existing panel, page, and attach bundles in direct and relay mode; the relay loader retains the inline style in `srcDoc`. Appending preserves the doctype and avoids rewriting tag-like text inside scripts or comments. Authored CSP stays intact and can block inline styling. Package files on disk and non-HTML responses are unchanged. Scrollbar colors follow the SDK theme variables inside the frame.
38
40
 
39
41
  Built-ins ship with the app; user extensions are installed separately. Add a folder, local ZIP, HTTPS Git/ZIP URL, or SSH Git address from Settings → Extensions. The ZIP picker and drop zone upload the archive on web and remote desktop instances. A guest with a page must ship built classic-IIFE JavaScript, for example from `bunx openchamber-guest-bundle panel/main.ts panel/main.js`; the sandbox does not support ESM imports. `package.json` needs a semver version. A missing panel SVG or invalid manifest fails installation; page-less tools-only packages skip HTML/script checks. Optional `engines.openchamber` is checked against this host. Provider accounts are connected separately in Settings → Integrations.
@@ -0,0 +1,83 @@
1
+ import { afterEach, expect, test } from 'bun:test';
2
+ import fs from 'node:fs/promises';
3
+ import os from 'node:os';
4
+ import path from 'node:path';
5
+ import express from 'express';
6
+ import request from 'supertest';
7
+ import { inspectGuestPackage, toPublicGuest } from './catalog.js';
8
+ import { registerGuestRoutes } from './routes.js';
9
+
10
+ const roots = [];
11
+ afterEach(async () => { await Promise.all(roots.splice(0).map((root) => fs.rm(root, { recursive: true, force: true }))); });
12
+ const fixture = async () => {
13
+ const root = await fs.mkdtemp(path.join(os.tmpdir(), 'oc-background-')); roots.push(root);
14
+ const packageRoot = path.join(root, 'package');
15
+ await fs.mkdir(packageRoot);
16
+ await fs.writeFile(path.join(packageRoot, 'package.json'), JSON.stringify({ name: 'background-test', version: '1.0.0', openchamber: {
17
+ apiVersion: 1, contributes: {
18
+ panel: { id: 'background-test', name: 'Background Test', icon: 'apps' },
19
+ background: { entry: 'index.html' },
20
+ capabilities: ['files'], commands: [{ name: 'test-background' }],
21
+ actions: [{ id: 'count', label: 'Count', where: 'message', mode: 'background' }],
22
+ },
23
+ } }));
24
+ return { root, packageRoot };
25
+ };
26
+
27
+ test('background-only packages validate HTML and built scripts and expose a separate catalog entry', async () => {
28
+ const { packageRoot } = await fixture();
29
+ expect(await inspectGuestPackage(packageRoot)).toMatchObject({ ok: false, code: 'invalid-manifest' });
30
+ await fs.writeFile(path.join(packageRoot, 'index.html'), '<script src="main.js"></script>');
31
+ await fs.writeFile(path.join(packageRoot, 'main.ts'), 'export {};');
32
+ expect(await inspectGuestPackage(packageRoot)).toMatchObject({ ok: false, code: 'missing-build' });
33
+ await fs.writeFile(path.join(packageRoot, 'main.js'), 'void 0;');
34
+ const result = await inspectGuestPackage(packageRoot);
35
+ expect(result.ok).toBe(true);
36
+ if (!result.ok) throw new Error(result.code);
37
+ const row = toPublicGuest(result.guest);
38
+ expect(row.entry).toBeUndefined();
39
+ expect(row.backgroundEntry).toBe('index.html');
40
+ expect(row.attach).toBeUndefined();
41
+ expect(row.actions).toHaveLength(1);
42
+ expect(row.commands).toHaveLength(1);
43
+ expect(row.capabilities).toEqual({ requested: ['files'], granted: [] });
44
+ });
45
+
46
+ test('background entry and its scripts cannot escape the installed package through symlinks', async () => {
47
+ const { root, packageRoot } = await fixture();
48
+ const outside = path.join(root, 'outside.html');
49
+ await fs.writeFile(outside, '<p>Outside</p>');
50
+ await fs.symlink(outside, path.join(packageRoot, 'index.html'));
51
+ expect(await inspectGuestPackage(packageRoot)).toMatchObject({ ok: false, code: 'invalid-manifest' });
52
+ await fs.unlink(path.join(packageRoot, 'index.html'));
53
+ await fs.writeFile(path.join(packageRoot, 'index.html'), '<script src="main.js"></script>');
54
+ await fs.writeFile(path.join(root, 'outside.js'), 'void 0;');
55
+ await fs.symlink(path.join(root, 'outside.js'), path.join(packageRoot, 'main.js'));
56
+ expect(await inspectGuestPackage(packageRoot)).toMatchObject({ ok: false, code: 'missing-build' });
57
+ });
58
+
59
+ test('background install serves sandboxed assets and storage obeys approval and enabled state', async () => {
60
+ const { root, packageRoot } = await fixture();
61
+ await fs.writeFile(path.join(packageRoot, 'index.html'), '<script src="main.js"></script>');
62
+ await fs.writeFile(path.join(packageRoot, 'main.js'), 'void 0;');
63
+ const app = express(); registerGuestRoutes(app, { openchamberDataDir: root, resolveGitBinaryForSpawn: () => 'git' });
64
+ const installed = await request(app).post('/api/guests').send({ path: packageRoot }).expect(201);
65
+ expect(installed.body.guest.backgroundEntry).toBe('index.html');
66
+ expect(installed.body.guest.entry).toBeUndefined();
67
+ const catalog = await request(app).get('/api/guests').expect(200);
68
+ expect(catalog.body.guests[0].backgroundEntry).toBe('index.html');
69
+ const html = await request(app).get('/api/guests/background-test/index.html?oc_url_token=test-scope').expect(200);
70
+ expect(html.headers['content-security-policy']).toBe('sandbox allow-scripts');
71
+ expect(html.text).toContain('main.js?oc_url_token=test-scope');
72
+ expect((await request(app).get('/api/guests/background-test/main.js').expect(200)).text).toBe('void 0;');
73
+ await request(app).post('/api/guests/background-test/storage').send({ op: 'set', key: 'count', value: 1 }).expect(400);
74
+ await request(app).put('/api/guests/background-test/capabilities').send({ granted: ['files'] }).expect(200);
75
+ await request(app).post('/api/guests/background-test/storage').send({ op: 'set', key: 'count', value: 1 }).expect(200);
76
+ expect((await request(app).post('/api/guests/background-test/storage').send({ op: 'get', key: 'count' }).expect(200)).body).toMatchObject({ found: true, value: 1 });
77
+ await request(app).put('/api/guests/background-test/enabled').send({ enabled: false }).expect(200);
78
+ await request(app).post('/api/guests/background-test/storage').send({ op: 'set', key: 'count', value: 2 }).expect(400);
79
+ await request(app).put('/api/guests/background-test/enabled').send({ enabled: true }).expect(200);
80
+ expect((await request(app).post('/api/guests/background-test/storage').send({ op: 'get', key: 'count' }).expect(200)).body).toMatchObject({ value: 1 });
81
+ await request(app).put('/api/guests/background-test/capabilities').send({ granted: [] }).expect(200);
82
+ await request(app).post('/api/guests/background-test/storage').send({ op: 'get', key: 'count' }).expect(400);
83
+ });
@@ -74,27 +74,26 @@ export const guestAssetContentType = (filePath) => {
74
74
  return MIME_BY_EXT[path.extname(filePath).toLowerCase()] ?? null;
75
75
  };
76
76
 
77
- /** What an iframe loads: the document and its scripts. A page-less guest has neither. */
77
+ /** Documents and scripts are served only to extensions with an execution entry. */
78
78
  const isGuestFrameContentType = (contentType) => (
79
79
  contentType.startsWith('text/html') || contentType.startsWith('text/javascript')
80
80
  );
81
81
 
82
82
  /**
83
83
  * A `.js` URL can be served from a sibling `.ts` that the host compiles.
84
- * `hasPage` is whether the guest declared `panel.entry`; without one only
85
- * assets (its SVG icons) are served, never HTML or JS, so nothing of a
86
- * page-less package can end up mounted in a frame.
84
+ * `hasRuntime` means the guest declared panel.entry or background.entry.
85
+ * Tools-only packages can serve assets, never HTML or JS.
87
86
  */
88
- export const resolveGuestServedFile = async (packageRoot, relativePath, { hasPage = true } = {}) => {
87
+ export const resolveGuestServedFile = async (packageRoot, relativePath, { hasRuntime = true } = {}) => {
89
88
  const filePath = await resolveGuestAssetPath(packageRoot, relativePath);
90
89
  const contentType = filePath ? guestAssetContentType(filePath) : null;
91
- if (contentType && !hasPage && isGuestFrameContentType(contentType)) {
90
+ if (contentType && !hasRuntime && isGuestFrameContentType(contentType)) {
92
91
  return null;
93
92
  }
94
93
  if (filePath && contentType) {
95
94
  return { filePath, contentType };
96
95
  }
97
- if (!hasPage || !relativePath.endsWith('.js')) {
96
+ if (!hasRuntime || !relativePath.endsWith('.js')) {
98
97
  return null;
99
98
  }
100
99
  const tsPath = await resolveGuestAssetPath(packageRoot, `${relativePath.slice(0, -3)}.ts`);
@@ -173,8 +172,7 @@ export const inspectGuestPackage = async (packageRoot, { openchamberVersion, ski
173
172
  }
174
173
  }
175
174
  const panel = parsed.manifest.contributes.panel;
176
- // A page-less package (tools only) has no HTML to check; parse already
177
- // refused every contribution that would need a frame.
175
+ // The visible panel and background runtime are optional independent entries.
178
176
  if (hasGuestPage(parsed.manifest.contributes)) {
179
177
  const entryPath = await resolveGuestAssetPath(packageRoot, panel.entry);
180
178
  if (!entryPath) {
@@ -199,6 +197,16 @@ export const inspectGuestPackage = async (packageRoot, { openchamberVersion, ski
199
197
  if (panel.entry) {
200
198
  guest.entry = panel.entry;
201
199
  }
200
+ const backgroundEntry = parsed.manifest.contributes.background?.entry;
201
+ if (backgroundEntry) {
202
+ if (!await resolveGuestAssetPath(packageRoot, backgroundEntry)) {
203
+ return { ok: false, code: 'invalid-manifest' };
204
+ }
205
+ if (!await guestBuiltScriptsReady(packageRoot, backgroundEntry)) {
206
+ return { ok: false, code: 'missing-build' };
207
+ }
208
+ guest.backgroundEntry = backgroundEntry;
209
+ }
202
210
  if (parsed.version) {
203
211
  guest.version = parsed.version;
204
212
  }
@@ -285,6 +293,9 @@ export const toPublicGuest = (guest) => {
285
293
  if (guest.entry) {
286
294
  row.entry = guest.entry;
287
295
  }
296
+ if (guest.backgroundEntry) {
297
+ row.backgroundEntry = guest.backgroundEntry;
298
+ }
288
299
  if (typeof guest.version === 'string' && guest.version) {
289
300
  row.version = guest.version;
290
301
  }
@@ -263,11 +263,11 @@ describe('page-less packages', () => {
263
263
  expect(row).not.toHaveProperty('entry');
264
264
  expect(row.tools).toEqual([{ match: 'mcp.*', icon: 'icons/tool.svg', output: 'json' }]);
265
265
 
266
- const hasPage = false;
267
- expect((await resolveGuestServedFile(guestRoot, 'icons/tool.svg', { hasPage }))?.contentType).toBe('image/svg+xml');
268
- expect(await resolveGuestServedFile(guestRoot, 'stray.html', { hasPage })).toBeNull();
269
- expect(await resolveGuestServedFile(guestRoot, 'stray.js', { hasPage })).toBeNull();
270
- expect((await resolveGuestServedFile(guestRoot, 'stray.html', { hasPage: true }))?.contentType).toContain('html');
266
+ const hasRuntime = false;
267
+ expect((await resolveGuestServedFile(guestRoot, 'icons/tool.svg', { hasRuntime }))?.contentType).toBe('image/svg+xml');
268
+ expect(await resolveGuestServedFile(guestRoot, 'stray.html', { hasRuntime })).toBeNull();
269
+ expect(await resolveGuestServedFile(guestRoot, 'stray.js', { hasRuntime })).toBeNull();
270
+ expect((await resolveGuestServedFile(guestRoot, 'stray.html', { hasRuntime: true }))?.contentType).toContain('html');
271
271
 
272
272
  await fs.rm(dir, { recursive: true, force: true });
273
273
  });
@@ -575,7 +575,7 @@ export const registerGuestRoutes = (app, {
575
575
  try {
576
576
  const result = await runGuestStorage(persistPath, req.params.id, parsed.data, async () => {
577
577
  const guest = await loadGuest(req.params.id);
578
- if (!guest || guest.enabled === false || !guest.entry) throw new Error('Extension is unavailable.');
578
+ if (!guest || guest.enabled === false || (!guest.entry && !guest.backgroundEntry)) throw new Error('Extension is unavailable.');
579
579
  if (!requestedGuestCapabilities(guest).every((capability) => guest.capabilityGrants.includes(capability))) throw new Error('Extension needs approval.');
580
580
  });
581
581
  return res.json(result);
@@ -805,7 +805,7 @@ export const registerGuestRoutes = (app, {
805
805
  return res.status(404).end();
806
806
  }
807
807
  const served = await resolveGuestServedFile(guest.packageRoot, relativePath, {
808
- hasPage: Boolean(guest.entry),
808
+ hasRuntime: Boolean(guest.entry || guest.backgroundEntry),
809
809
  });
810
810
  if (!served) {
811
811
  return res.status(404).end();
@@ -22,6 +22,12 @@ session-knowledge runtime; routes registered in
22
22
  JSON bodies enabled in `opencode/core-routes.js`; stopped by
23
23
  `opencode/shutdown-runtime.js`.
24
24
 
25
+ ## Auto routing
26
+
27
+ `resolvePromptBody` (the routing runtime) runs on the assembled body right
28
+ before the prompt or command send, turning a queued `openchamber/auto` model
29
+ into a real one. The queue captures the sentinel like any other send config.
30
+
25
31
  ## Item
26
32
 
27
33
  An item is what the UI would have sent itself, captured at queue time so the
@@ -211,6 +211,9 @@ export function createMessageQueueRuntime({
211
211
  sessionKnowledgeRuntime = null,
212
212
  broadcastGlobalUiEvent,
213
213
  onPromptSent,
214
+ // Turns the `openchamber/auto` model into a real one right before the send;
215
+ // absent means the queue never sees the sentinel.
216
+ resolvePromptBody = null,
214
217
  dataDir,
215
218
  fetchImpl = fetch,
216
219
  now = Date.now,
@@ -469,6 +472,7 @@ export function createMessageQueueRuntime({
469
472
  if (agent) body.agent = agent;
470
473
  if (variant) body.variant = variant;
471
474
  if (fileParts.length > 0) body.parts = fileParts;
475
+ await resolvePromptBody?.(body, { sessionId, directory });
472
476
  await openCodeFetch(`/session/${encodeURIComponent(sessionId)}/command`, { directory, method: 'POST', body });
473
477
  return;
474
478
  }
@@ -503,6 +507,7 @@ export function createMessageQueueRuntime({
503
507
  if (agent) body.agent = agent;
504
508
  if (variant) body.variant = variant;
505
509
  body.parts = parts;
510
+ await resolvePromptBody?.(body, { sessionId, directory });
506
511
  await openCodeFetch(`/session/${encodeURIComponent(sessionId)}/prompt_async`, { directory, method: 'POST', body });
507
512
  if (knowledge.text && sessionKnowledgeRuntime) {
508
513
  // After the prompt is accepted, so a rejected dispatch carries it again.