@openchamber/web 1.18.4 → 1.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. package/README.md +1 -0
  2. package/dist/assets/{CodeMirrorCommentWidgets-4qZbrEXU.js → CodeMirrorCommentWidgets-DAvopJvy.js} +1 -1
  3. package/dist/assets/{CommitSection-MJmntVPJ.js → CommitSection-D9cV-qR9.js} +1 -1
  4. package/dist/assets/{DiagramEditor-jnG3Hbxg.js → DiagramEditor-B9NCadU7.js} +1 -1
  5. package/dist/assets/DiagramView-LKGBwf4G.js +1 -0
  6. package/dist/assets/{DiffView-DZIoOnV7.js → DiffView-BWNq-0ov.js} +2 -2
  7. package/dist/assets/FilesView-DB-Q0Gkz.js +14 -0
  8. package/dist/assets/{GitView-DBFrDDBv.js → GitView-DsWXqWx3.js} +3 -3
  9. package/dist/assets/{JsonTreeView-DLW2Wy1g.js → JsonTreeView-h4dHASlq.js} +1 -1
  10. package/dist/assets/MarkdownImageGallery-n0ikH-xm.js +1 -0
  11. package/dist/assets/MarkdownRendererImpl-CT2mjx-s.js +12 -0
  12. package/dist/assets/OnboardingScreen-CDjgzxEe.js +1 -0
  13. package/dist/assets/{PatchDiff-BuLPx7AN.js → PatchDiff-jPKTJje5.js} +1 -1
  14. package/dist/assets/{PierreDiffViewer-BHm4Yr0X.js → PierreDiffViewer-D_Gt4A_6.js} +1 -1
  15. package/dist/assets/PlanView-UvuxIl9-.js +4 -0
  16. package/dist/assets/SessionSwitcherDropdown-xKU4LRuQ.js +1 -0
  17. package/dist/assets/SettingsView-3B9VN6Ys.js +28 -0
  18. package/dist/assets/SettingsWindow-CqQNDKNd.js +1 -0
  19. package/dist/assets/{ToolOutputDialog-Za6V4VMJ.js → ToolOutputDialog-PmjlAxVE.js} +6 -6
  20. package/dist/assets/{ToolPartDiffPreview-BL-9ixyC.js → ToolPartDiffPreview-B34Xw9wq.js} +1 -1
  21. package/dist/assets/{VirtualizedFileDiff-CwGocYQd.js → VirtualizedFileDiff-B37yB9jZ.js} +3 -3
  22. package/dist/assets/{WalkthroughView-5DyvN03T.js → WalkthroughView-Bxun3k66.js} +2 -2
  23. package/dist/assets/{computeVirtualFileMetrics-Da00Jg7M.js → computeVirtualFileMetrics-DYFv_yZS.js} +2 -2
  24. package/dist/assets/contextPanelEmbeddedChat-BO1wRpaN.js +1 -0
  25. package/dist/assets/de-DbV6CLxv.js +9 -0
  26. package/dist/assets/document-attachments-DFAWlG3U.js +31 -0
  27. package/dist/assets/es-CVDlyzZ4.js +15 -0
  28. package/dist/assets/fr-Czc-p0g-.js +13 -0
  29. package/dist/assets/index-1OhiMDBz.css +1 -0
  30. package/dist/assets/index-BSvmTvZl.js +1 -0
  31. package/dist/assets/index-DzriVon2.js +7 -0
  32. package/dist/assets/{isDiffPlainText-D9YpoLrV.js → isDiffPlainText-DwHKxDYc.js} +1 -1
  33. package/dist/assets/{isFilePlainText-gTibdNIe.js → isFilePlainText-Dwq6ILxo.js} +1 -1
  34. package/dist/assets/ja-dwc9NM_S.js +15 -0
  35. package/dist/assets/ko-Ds1DZ8FX.js +15 -0
  36. package/dist/assets/{lua-BgMRiT3U.js → lua-VAEuO923.js} +1 -1
  37. package/dist/assets/main-BF51IOVF.js +921 -0
  38. package/dist/assets/{main-D7UcL3VQ.js → main-D7UPARut.js} +2 -2
  39. package/dist/assets/markdownCore-BgeBDwD3.js +2 -0
  40. package/dist/assets/{miniChat-O_GVoEbc.js → miniChat-BISXSGOo.js} +2 -2
  41. package/dist/assets/mobile-BnYxVuvw.js +2 -0
  42. package/dist/assets/{patchFileDiff-KNkxM1C1.js → patchFileDiff-BEDPDypx.js} +2 -2
  43. package/dist/assets/pl-CLiTO7i-.js +15 -0
  44. package/dist/assets/pt-BR-GIimJgpK.js +15 -0
  45. package/dist/assets/renderElectronMiniChatApp-BaOy72Gi.js +2 -0
  46. package/dist/assets/{renderMobileApp-toj9cXoh.js → renderMobileApp-BiMbzPq9.js} +7 -7
  47. package/dist/assets/runtimeEndpointReset-BMBRhIbf.js +15 -0
  48. package/dist/assets/scheduledTasksApi-01zzfzqH.js +1 -0
  49. package/dist/assets/{shikiHighlight-C7LTbwFx.js → shikiHighlight-DXYW46vW.js} +1 -1
  50. package/dist/assets/uk-DLfgD1ki.js +15 -0
  51. package/dist/assets/{useAppFontEffects-BikB6enL.js → useAppFontEffects-CbzHzFop.js} +139 -142
  52. package/dist/assets/{useInlineCommentController-CYPvYJDt.js → useInlineCommentController-CegKdDXi.js} +2 -2
  53. package/dist/assets/{vendor-base-ui-D_V6hAcE.js → vendor-base-ui-BYlZTzrw.js} +1 -1
  54. package/dist/assets/vendor-codemirror-autocomplete-DzPz9Wgq.js +1 -0
  55. package/dist/assets/vendor-codemirror-commands-B7H_j0iU.js +1 -0
  56. package/dist/assets/{vendor-codemirror-lang-angular-CgY7_gQ1.js → vendor-codemirror-lang-angular-DEPs2M5t.js} +1 -1
  57. package/dist/assets/{vendor-codemirror-lang-cpp-B5Ta4enQ.js → vendor-codemirror-lang-cpp-DhkseaMo.js} +1 -1
  58. package/dist/assets/{vendor-codemirror-lang-css-VgNqFSH-.js → vendor-codemirror-lang-css-O0cZX78y.js} +1 -1
  59. package/dist/assets/{vendor-codemirror-lang-go-LxLz62pp.js → vendor-codemirror-lang-go-fMdQYcON.js} +1 -1
  60. package/dist/assets/vendor-codemirror-lang-html-CfgK872x.js +1 -0
  61. package/dist/assets/{vendor-codemirror-lang-java-Bksi1PH4.js → vendor-codemirror-lang-java-CQj4S3zl.js} +1 -1
  62. package/dist/assets/vendor-codemirror-lang-javascript-Cc2ZYbgX.js +13 -0
  63. package/dist/assets/{vendor-codemirror-lang-jinja-C7npuDD7.js → vendor-codemirror-lang-jinja-BmZZv8g-.js} +1 -1
  64. package/dist/assets/{vendor-codemirror-lang-json-ryCw7nab.js → vendor-codemirror-lang-json-CMBS2tG9.js} +1 -1
  65. package/dist/assets/{vendor-codemirror-lang-less-BxsZJD6N.js → vendor-codemirror-lang-less-C6Eo8hVS.js} +1 -1
  66. package/dist/assets/{vendor-codemirror-lang-liquid-De6qch10.js → vendor-codemirror-lang-liquid-DSTR47-H.js} +1 -1
  67. package/dist/assets/vendor-codemirror-lang-markdown-BPGOH9ye.js +1 -0
  68. package/dist/assets/{vendor-codemirror-lang-php-Cm1es33p.js → vendor-codemirror-lang-php-DD9udfPH.js} +1 -1
  69. package/dist/assets/{vendor-codemirror-lang-python-N414WYK-.js → vendor-codemirror-lang-python-HahnQaAS.js} +1 -1
  70. package/dist/assets/{vendor-codemirror-lang-rust-C_WuUStH.js → vendor-codemirror-lang-rust-nLTovbjv.js} +1 -1
  71. package/dist/assets/{vendor-codemirror-lang-sass-8UHTCAOM.js → vendor-codemirror-lang-sass-pL2Yc72v.js} +1 -1
  72. package/dist/assets/{vendor-codemirror-lang-sql-CV3sMA5D.js → vendor-codemirror-lang-sql-BVBnan19.js} +1 -1
  73. package/dist/assets/{vendor-codemirror-lang-vue-DzvC1Dhk.js → vendor-codemirror-lang-vue-BqGzJVm1.js} +1 -1
  74. package/dist/assets/{vendor-codemirror-lang-wast-jlr-LDdA.js → vendor-codemirror-lang-wast-B0_m5DqU.js} +1 -1
  75. package/dist/assets/{vendor-codemirror-lang-xml-CrO63OVp.js → vendor-codemirror-lang-xml-Dj3voadT.js} +1 -1
  76. package/dist/assets/{vendor-codemirror-lang-yaml-dxi6CISW.js → vendor-codemirror-lang-yaml-yu-9Z5u7.js} +1 -1
  77. package/dist/assets/vendor-codemirror-language-BgPj_McA.js +3 -0
  78. package/dist/assets/{vendor-codemirror-language-data-CLHw8NWn.js → vendor-codemirror-language-data-CiAYDJXN.js} +2 -2
  79. package/dist/assets/vendor-codemirror-search-BmS-GmcX.js +2 -0
  80. package/dist/assets/{vendor-codemirror-state-CNWM3Q8V.js → vendor-codemirror-state-C9awkmn-.js} +5 -5
  81. package/dist/assets/vendor-codemirror-view-CiLROUVV.js +4 -0
  82. package/dist/assets/vendor-replit-codemirror-vim-B2DJlAhT.js +6 -0
  83. package/dist/assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js +34 -0
  84. package/dist/assets/vendor-zod-adaMkgkm.js +39 -0
  85. package/dist/assets/{web-components-GMc3oR3i.js → web-components-DCLjCO9n.js} +1 -1
  86. package/dist/assets/zh-CN-DkeP5awK.js +15 -0
  87. package/dist/assets/zh-TW-BocaFm3d.js +15 -0
  88. package/dist/index.html +4 -4
  89. package/dist/mini-chat.html +3 -3
  90. package/dist/mobile.html +3 -3
  91. package/package.json +1 -1
  92. package/server/index.js +116 -3
  93. package/server/lib/agent-memory/actions.js +243 -0
  94. package/server/lib/agent-memory/actions.test.js +343 -0
  95. package/server/lib/agent-memory/feature-flag.js +19 -0
  96. package/server/lib/agent-memory/feature-flag.test.js +38 -0
  97. package/server/lib/agent-memory/project-resolution.js +56 -0
  98. package/server/lib/agent-memory/project-resolution.test.js +85 -0
  99. package/server/lib/agent-memory/routes.http.test.js +270 -0
  100. package/server/lib/agent-memory/routes.js +169 -0
  101. package/server/lib/agent-memory/runtime.js +427 -0
  102. package/server/lib/agent-memory/runtime.test.js +344 -0
  103. package/server/lib/agent-memory/threat-patterns.js +61 -0
  104. package/server/lib/agent-memory/threat-patterns.test.js +61 -0
  105. package/server/lib/agent-tool/DOCUMENTATION.md +14 -0
  106. package/server/lib/agent-tool/runtime.js +63 -13
  107. package/server/lib/agent-tool/runtime.test.js +85 -2
  108. package/server/lib/context-obligatory/runtime.js +34 -3
  109. package/server/lib/context-obligatory/runtime.test.js +114 -0
  110. package/server/lib/fs/DOCUMENTATION.md +3 -0
  111. package/server/lib/fs/routes.js +149 -32
  112. package/server/lib/fs/routes.test.js +225 -0
  113. package/server/lib/git/DOCUMENTATION.md +8 -0
  114. package/server/lib/git/service.js +121 -67
  115. package/server/lib/git/service.test.js +129 -0
  116. package/server/lib/github/DOCUMENTATION.md +14 -3
  117. package/server/lib/github/pr-status.js +188 -83
  118. package/server/lib/github/pr-status.test.js +182 -0
  119. package/server/lib/github/routes.js +36 -30
  120. package/server/lib/notifications/template-runtime.js +2 -3
  121. package/server/lib/openchamber-control/action-resolution.test.js +65 -0
  122. package/server/lib/openchamber-control/actions.js +78 -0
  123. package/server/lib/openchamber-control/service.js +7 -0
  124. package/server/lib/openchamber-sessions/routes.js +14 -0
  125. package/server/lib/opencode/DOCUMENTATION.md +6 -4
  126. package/server/lib/opencode/claude-cli-auth.js +60 -0
  127. package/server/lib/opencode/claude-cli-auth.test.js +54 -0
  128. package/server/lib/opencode/feature-routes-runtime.js +11 -0
  129. package/server/lib/opencode/plugins.js +12 -3
  130. package/server/lib/opencode/plugins.test.js +18 -0
  131. package/server/lib/opencode/proxy-agent-wiring.test.js +152 -0
  132. package/server/lib/opencode/proxy.js +116 -6
  133. package/server/lib/opencode/proxy.test.js +158 -1
  134. package/server/lib/opencode/routes.js +4 -1
  135. package/server/lib/opencode/settings-helpers.js +11 -0
  136. package/server/lib/opencode/settings-helpers.test.js +35 -0
  137. package/server/lib/opencode/settings-runtime.js +51 -0
  138. package/server/lib/opencode/shared.js +120 -16
  139. package/server/lib/opencode/shared.test.js +185 -1
  140. package/server/lib/project-context/DOCUMENTATION.md +158 -0
  141. package/server/lib/project-context/routes.http.test.js +264 -0
  142. package/server/lib/project-context/routes.js +237 -0
  143. package/server/lib/project-context/runtime.js +667 -0
  144. package/server/lib/project-context/runtime.test.js +498 -0
  145. package/server/lib/quota/DOCUMENTATION.md +16 -1
  146. package/server/lib/quota/providers/claude/auth.js +113 -0
  147. package/server/lib/quota/providers/claude/auth.test.js +117 -0
  148. package/server/lib/quota/providers/claude/index.js +151 -0
  149. package/server/lib/quota/providers/claude/index.test.js +147 -0
  150. package/server/lib/quota/providers/claude/transforms.js +127 -0
  151. package/server/lib/quota/providers/claude/transforms.test.js +82 -0
  152. package/server/lib/quota/providers/command-code.js +90 -0
  153. package/server/lib/quota/providers/command-code.test.js +72 -0
  154. package/server/lib/quota/providers/index.js +22 -2
  155. package/server/lib/quota/providers/index.test.js +10 -1
  156. package/server/lib/quota/utils/formatters.js +2 -1
  157. package/server/lib/scheduled-tasks/runtime.js +21 -2
  158. package/server/lib/session-knowledge/DOCUMENTATION.md +87 -0
  159. package/server/lib/session-knowledge/routes.js +107 -0
  160. package/server/lib/session-knowledge/runtime.js +331 -0
  161. package/server/lib/session-knowledge/runtime.test.js +275 -0
  162. package/server/lib/skills-catalog/DOCUMENTATION.md +22 -22
  163. package/server/lib/skills-catalog/curated-sources.js +1 -1
  164. package/server/lib/skills-catalog/curated-sources.test.js +10 -0
  165. package/server/lib/small-model/index.js +8 -0
  166. package/server/lib/small-model/index.test.js +31 -1
  167. package/server/lib/small-model/routes.js +3 -1
  168. package/dist/assets/DiagramView-CFXxgg_a.js +0 -1
  169. package/dist/assets/FilesView-BKL6YlKG.js +0 -14
  170. package/dist/assets/MarkdownImageGallery-DKIylIK7.js +0 -1
  171. package/dist/assets/MarkdownRendererImpl-CLv8hxvv.js +0 -12
  172. package/dist/assets/OnboardingScreen-D2Y6djMw.js +0 -1
  173. package/dist/assets/PlanView-ZYEJn8A_.js +0 -4
  174. package/dist/assets/SessionSwitcherDropdown-rro-SsaO.js +0 -1
  175. package/dist/assets/SettingsView-5RmswFZe.js +0 -28
  176. package/dist/assets/SettingsWindow-BZhAYFdS.js +0 -1
  177. package/dist/assets/contextPanelEmbeddedChat-B-bSg3P5.js +0 -1
  178. package/dist/assets/de-u7gSnqWs.js +0 -9
  179. package/dist/assets/document-attachments-CX_YaDsu.js +0 -30
  180. package/dist/assets/es-T9O7aAOr.js +0 -15
  181. package/dist/assets/fr-Oor7ewbE.js +0 -13
  182. package/dist/assets/index-BzIpNlNE.css +0 -1
  183. package/dist/assets/index-C0yNhuZw.js +0 -1
  184. package/dist/assets/index-DRpChWux.js +0 -7
  185. package/dist/assets/ja-DHpqbVmr.js +0 -15
  186. package/dist/assets/ko-CwLkS3nx.js +0 -15
  187. package/dist/assets/main-DPMd2iKS.js +0 -915
  188. package/dist/assets/markdownCore-DDrHVneM.js +0 -2
  189. package/dist/assets/mobile-Br4TtAqc.js +0 -2
  190. package/dist/assets/pl-CcZILN8q.js +0 -15
  191. package/dist/assets/pt-BR-DYHhVK6o.js +0 -15
  192. package/dist/assets/renderElectronMiniChatApp-CJpdxTT1.js +0 -2
  193. package/dist/assets/runtimeEndpointReset-BVmispdD.js +0 -13
  194. package/dist/assets/scheduledTasksApi-ByKya3Un.js +0 -1
  195. package/dist/assets/uk-BA2kZR38.js +0 -15
  196. package/dist/assets/vendor-codemirror-autocomplete-BjbBRsUA.js +0 -1
  197. package/dist/assets/vendor-codemirror-commands-ARAOgp1x.js +0 -1
  198. package/dist/assets/vendor-codemirror-lang-html-B3Qe3OpS.js +0 -1
  199. package/dist/assets/vendor-codemirror-lang-javascript-Bbw3D7r0.js +0 -13
  200. package/dist/assets/vendor-codemirror-lang-markdown-FGQydhTc.js +0 -1
  201. package/dist/assets/vendor-codemirror-language-DUOssd4j.js +0 -3
  202. package/dist/assets/vendor-codemirror-search-8kyQdB3f.js +0 -2
  203. package/dist/assets/vendor-codemirror-view-DSzLbZiS.js +0 -4
  204. package/dist/assets/vendor-replit-codemirror-vim-B0Ecqnlh.js +0 -39
  205. package/dist/assets/zh-CN-dlOQK6v9.js +0 -15
  206. package/dist/assets/zh-TW-BnqQ-WL5.js +0 -15
  207. package/server/lib/quota/providers/claude.js +0 -107
@@ -0,0 +1,65 @@
1
+ import { describe, expect, test } from 'bun:test';
2
+
3
+ import { resolveAgentToolAction } from './actions.js';
4
+
5
+ /**
6
+ * Both cases here are from one real conversation: the model called `read` and
7
+ * then `get` on `openchamber_memory`, having dropped the namespace its own tool
8
+ * name appeared to supply, and gave up after the second bare "unsupported".
9
+ */
10
+ describe('a namespace the tool name already implies', () => {
11
+ test('resolves a bare action inside the calling tool', () => {
12
+ expect(resolveAgentToolAction('read', 'openchamber_memory')).toEqual({ action: 'memory.read' });
13
+ expect(resolveAgentToolAction('save', 'openchamber_memory')).toEqual({ action: 'memory.save' });
14
+ });
15
+
16
+ test('resolves a bare name that is ambiguous only across tools', () => {
17
+ // `delete` belongs to schedule and to memory; inside one tool it is plain.
18
+ expect(resolveAgentToolAction('delete', 'openchamber_memory')).toEqual({ action: 'memory.delete' });
19
+ expect(resolveAgentToolAction('delete', 'openchamber')).toEqual({ action: 'schedule.delete' });
20
+ });
21
+
22
+ test('keeps a fully qualified action as it is', () => {
23
+ expect(resolveAgentToolAction('memory.read', 'openchamber_memory')).toEqual({ action: 'memory.read' });
24
+ });
25
+
26
+ test('does not reach outside the tool that asked', () => {
27
+ // The memory tool asking for `open` must fail, not drive the browser.
28
+ expect(resolveAgentToolAction('open', 'openchamber_memory').action).toBeUndefined();
29
+ });
30
+ });
31
+
32
+ describe('an unidentified caller', () => {
33
+ test('still resolves a bare name that means one thing everywhere', () => {
34
+ expect(resolveAgentToolAction('snapshot', null)).toEqual({ action: 'browser.snapshot' });
35
+ });
36
+
37
+ test('refuses a bare name that several actions share', () => {
38
+ expect(resolveAgentToolAction('list', null).action).toBeUndefined();
39
+ });
40
+ });
41
+
42
+ describe('what an unresolvable action reports', () => {
43
+ test('names the actions the calling tool actually has', () => {
44
+ const { error } = resolveAgentToolAction('get', 'openchamber_memory');
45
+
46
+ expect(error).toContain('memory.read');
47
+ expect(error).toContain('memory.save');
48
+ // Listing every action of every tool would bury the four that apply.
49
+ expect(error).not.toContain('browser.open');
50
+ });
51
+
52
+ test('reports a missing action rather than resolving to something', () => {
53
+ const { error, action } = resolveAgentToolAction('', 'openchamber_memory');
54
+
55
+ expect(action).toBeUndefined();
56
+ expect(error).toContain('missing');
57
+ });
58
+
59
+ test('an unknown tool falls back to the full action list', () => {
60
+ const { error } = resolveAgentToolAction('nonsense', 'openchamber_future');
61
+
62
+ expect(error).toContain('memory.read');
63
+ expect(error).toContain('browser.open');
64
+ });
65
+ });
@@ -53,8 +53,86 @@ export const OPENCHAMBER_WEB_ACTIONS = Object.freeze(
53
53
  OPENCHAMBER_WEB_ACTION_DEFINITIONS.map(({ action }) => action),
54
54
  );
55
55
 
56
+ /**
57
+ * Memory is its own tool for the same reason web is: remembering across
58
+ * sessions is a distinct intent from controlling one, and a shared description
59
+ * would blur both. It also has to switch off cleanly and completely, which a
60
+ * shared schema cannot do.
61
+ *
62
+ * The session already carries an index of stored titles, so the descriptions
63
+ * push the model toward reading one entry it can already see rather than
64
+ * listing everything again — and toward reading it at all, since a title that
65
+ * reads as a complete fact is exactly the one whose conditions get lost.
66
+ */
67
+ export const OPENCHAMBER_MEMORY_ACTION_DEFINITIONS = Object.freeze([
68
+ { action: 'memory.read', title: 'Read a stored memory', description: 'Read the full text of one memory listed in the session index. The index shows titles only, and a title omits the conditions that decide how the memory applies, so read before acting rather than working from the title. Requires title (as the index spells it) or memoryId; scope is optional and both stores are searched without it' },
69
+ { action: 'memory.list', title: 'List stored memories', description: 'List stored memory titles when the session index is missing or stale; scope is global, project, or both (default)' },
70
+ { action: 'memory.save', title: 'Remember something', description: 'Store a durable fact, preference, or reference; requires title and body, plus scope global (about the user) or project (about this codebase). Restating something already stored updates it. Do not store secrets, one-off task state, or anything the user asked you not to keep' },
71
+ { action: 'memory.delete', title: 'Forget a memory', description: 'Delete a memory that turned out to be wrong or obsolete; requires memoryId and scope' },
72
+ ]);
73
+
74
+ export const OPENCHAMBER_MEMORY_ACTIONS = Object.freeze(
75
+ OPENCHAMBER_MEMORY_ACTION_DEFINITIONS.map(({ action }) => action),
76
+ );
77
+
78
+ /**
79
+ * Which actions each managed tool may ask for.
80
+ *
81
+ * The callback needs this because models routinely drop the namespace: asked
82
+ * for `memory.read` from a tool already called `openchamber_memory`, they send
83
+ * `read`, since the tool's own name appears to have said "memory" already. The
84
+ * name is unambiguous inside one tool's action set even when it is not across
85
+ * all of them (`delete` belongs to both schedule and memory), so resolution
86
+ * starts from the tool that asked.
87
+ */
88
+ const ACTIONS_BY_TOOL = Object.freeze({
89
+ openchamber: OPENCHAMBER_AGENT_TOOL_ACTIONS,
90
+ openchamber_web: OPENCHAMBER_WEB_ACTIONS,
91
+ openchamber_memory: OPENCHAMBER_MEMORY_ACTIONS,
92
+ });
93
+
94
+ const bareName = (action) => {
95
+ const separator = action.indexOf('.');
96
+ return separator === -1 ? action : action.slice(separator + 1);
97
+ };
98
+
99
+ const uniqueMatch = (candidates, requested) => {
100
+ const matches = candidates.filter((candidate) => bareName(candidate) === requested);
101
+ return matches.length === 1 ? matches[0] : null;
102
+ };
103
+
104
+ /**
105
+ * The canonical action for what a tool asked, or the reason it could not be
106
+ * resolved. The reason lists what the tool can actually do: an error that only
107
+ * says "unsupported" leaves the model to guess again, which is how one wrong
108
+ * name becomes three.
109
+ */
110
+ export const resolveAgentToolAction = (requested, toolName) => {
111
+ const value = typeof requested === 'string' ? requested.trim() : '';
112
+ const scoped = ACTIONS_BY_TOOL[toolName] ?? null;
113
+ const known = scoped ?? OPENCHAMBER_ALL_ACTIONS;
114
+
115
+ if (value && known.includes(value)) {
116
+ return { action: value };
117
+ }
118
+ if (value) {
119
+ const resolved = uniqueMatch(known, value)
120
+ // A tool that did not identify itself still gets the benefit when the
121
+ // bare name means only one thing across every action.
122
+ ?? (scoped ? null : uniqueMatch(OPENCHAMBER_ALL_ACTIONS, value));
123
+ if (resolved) {
124
+ return { action: resolved };
125
+ }
126
+ }
127
+
128
+ return {
129
+ error: `Unsupported OpenChamber action: ${value || 'missing'}. Use one of: ${known.join(', ')}`,
130
+ };
131
+ };
132
+
56
133
  /** Everything the callback route will dispatch, whichever tool asked. */
57
134
  export const OPENCHAMBER_ALL_ACTIONS = Object.freeze([
58
135
  ...OPENCHAMBER_CONTROL_ACTIONS,
59
136
  ...OPENCHAMBER_WEB_ACTIONS,
137
+ ...OPENCHAMBER_MEMORY_ACTIONS,
60
138
  ]);
@@ -144,6 +144,7 @@ export const createOpenChamberControlService = (dependencies) => {
144
144
  sessionService,
145
145
  scheduledTaskService,
146
146
  browserControl = null,
147
+ agentMemoryActions = null,
147
148
  createClient = createOpencodeClient,
148
149
  sleep = (duration) => new Promise((resolve) => setTimeout(resolve, duration)),
149
150
  now = Date.now,
@@ -458,6 +459,12 @@ export const createOpenChamberControlService = (dependencies) => {
458
459
  if (!CONTROL_ACTIONS.has(action)) {
459
460
  throw new OpenChamberControlError(`Unsupported OpenChamber action: ${action || 'missing'}`, 400);
460
461
  }
462
+ if (action.startsWith('memory.')) {
463
+ if (!agentMemoryActions) {
464
+ throw new OpenChamberControlError('Agent memory is not available on this server', 503);
465
+ }
466
+ return agentMemoryActions.execute(action, input, contextDirectory);
467
+ }
461
468
  if (action.startsWith('browser.')) {
462
469
  if (!browserControl) {
463
470
  throw new OpenChamberControlError('The in-app browser is not available on this server', 503);
@@ -357,6 +357,7 @@ export const createOpenChamberSessionService = (dependencies) => {
357
357
  waitForOpenCodeReady,
358
358
  emitSessionCreatedEvent,
359
359
  createSessionGoal: createSessionGoalOverride,
360
+ sessionKnowledgeRuntime = null,
360
361
  } = dependencies;
361
362
 
362
363
  // Last user message of an existing session, as a selection to reuse. Returns
@@ -520,6 +521,13 @@ export const createOpenChamberSessionService = (dependencies) => {
520
521
  }
521
522
  } else {
522
523
  const baseline = await latestUserMessageID({ client, sessionID, directory });
524
+ // A session the agent dispatched has no UI to attach the project's
525
+ // standing context, so it is asked for here. Never fails the dispatch:
526
+ // a session that runs without its background beats one that never runs.
527
+ const knowledge = sessionKnowledgeRuntime
528
+ ? await sessionKnowledgeRuntime.resolvePendingForSession(sessionID, directory)
529
+ .catch(() => ({ text: '', signature: '' }))
530
+ : { text: '', signature: '' };
523
531
  try {
524
532
  await runPromptAsync({
525
533
  baseUrl,
@@ -531,6 +539,7 @@ export const createOpenChamberSessionService = (dependencies) => {
531
539
  ...(agent ? { agent } : {}),
532
540
  ...(variant ? { variant } : {}),
533
541
  parts: [
542
+ ...(knowledge.text ? [{ type: 'text', text: knowledge.text, synthetic: true }] : []),
534
543
  { type: 'text', text: expandedPrompt },
535
544
  ...(goalInput.enabled
536
545
  ? [{ type: 'text', text: buildGoalIntroText(goalInput.tokenBudget), synthetic: true }]
@@ -541,6 +550,11 @@ export const createOpenChamberSessionService = (dependencies) => {
541
550
  } catch (error) {
542
551
  throw markGoalPartial(error);
543
552
  }
553
+ if (knowledge.text && sessionKnowledgeRuntime) {
554
+ // After the prompt is accepted, so a rejected dispatch carries it again.
555
+ await sessionKnowledgeRuntime.recordDelivered(sessionID, directory, knowledge.signature)
556
+ .catch(() => undefined);
557
+ }
544
558
  const landed = await waitForPromptLanded({
545
559
  client,
546
560
  sessionID,
@@ -70,10 +70,12 @@ This module provides OpenCode server integration utilities for the web server ru
70
70
  - `AGENT_SCOPE`, `COMMAND_SCOPE`, `SKILL_SCOPE`: Scope constants with USER and PROJECT values.
71
71
  - `ensureDirs()`: Creates required OpenCode directories.
72
72
  - `parseMdFile(filePath)`, `writeMdFile(filePath, frontmatter, body)`: Markdown file operations with YAML frontmatter.
73
- - `getConfigPaths(workingDirectory)`, `readConfigLayers(workingDirectory)`, `readConfig(workingDirectory)`: Config file operations with layer merging (user, project, custom).
74
- - `writeConfig(config, filePath)`: Writes config with automatic backup.
75
- - `getJsonEntrySource(layers, sectionKey, entryName)`: Resolves which config layer provides an entry.
76
- - `getJsonWriteTarget(layers, preferredScope)`: Determines write target for config updates.
73
+ - `getConfigPaths(workingDirectory)`, `readConfigLayers(workingDirectory)`, `readConfig(workingDirectory)`: Config file operations with layer merging (user, project, custom). `readConfigLayers` isolates `INVALID_JSONC` per layer: a broken file is omitted from the merge (`{}` for that layer only), recorded on `layerErrors`, and does not block valid sibling layers. Writes still refuse to overwrite the broken file.
74
+ - `readConfigFile(filePath)`: Reads one config file. Missing, whitespace-only, and comment-only files return `{}`; a comment-only file is recognized by `ValueExpected` being the only parse error. A `jsonc-parser` error that produces a partial or non-object tree throws `INVALID_JSONC` — partial parse trees must never be treated as authoritative (avoids rewriting a `$schema`-only stub over a full config). Content that yields no JSON value for any other reason (YAML, plain text) also throws instead of reading as empty.
75
+ - `readConfigLayer(filePath)`: Same parse as `readConfigFile`, but isolates `INVALID_JSONC` to `{ config: {}, error }` so plugin/MCP/agent readers can skip one broken layer without aborting valid siblings. Writes still refuse to overwrite the broken file.
76
+ - `writeConfig(config, filePath)`: Writes config with automatic backup. Refuses to overwrite an existing non-empty file that fails the same JSONC parse check.
77
+ - `getJsonEntrySource(layers, sectionKey, entryName)`: Resolves which config layer provides an entry. A failed custom or user layer throws `INVALID_JSONC` instead of treating that file as empty. A failed project layer is skipped so a valid user/custom entry can still be found.
78
+ - `getJsonWriteTarget(layers, preferredScope)`: Determines write target for config updates. Throws `INVALID_JSONC` when the chosen target file is the unparseable layer.
77
79
  - `getAncestors(startDir, stopDir)`, `findWorktreeRoot(startDir)`: Git worktree helpers.
78
80
  - `isPromptFileReference(value)`, `resolvePromptFilePath(reference)`, `writePromptFile(filePath, content)`: Prompt file reference handling.
79
81
  - `walkSkillMdFiles(rootDir)`: Recursively finds all SKILL.md files.
@@ -0,0 +1,60 @@
1
+ import { spawnSync } from 'node:child_process';
2
+
3
+ const readStatus = (spawnSyncFn, command, env) => spawnSyncFn(command, ['auth', 'status', '--json'], {
4
+ encoding: 'utf8',
5
+ timeout: 6000,
6
+ env,
7
+ windowsHide: true,
8
+ });
9
+
10
+ const resolveFromLoginShell = (spawnSyncFn, env, platform) => {
11
+ if (platform === 'win32') {
12
+ const result = spawnSyncFn('where', ['claude'], {
13
+ encoding: 'utf8',
14
+ timeout: 6000,
15
+ env,
16
+ windowsHide: true,
17
+ });
18
+ return `${result.stdout || ''}`.split(/\r?\n/).map((line) => line.trim()).find(Boolean) || null;
19
+ }
20
+
21
+ const shell = env.SHELL || '/bin/zsh';
22
+ const result = spawnSyncFn(shell, ['-lic', 'command -v claude'], {
23
+ encoding: 'utf8',
24
+ timeout: 6000,
25
+ env,
26
+ windowsHide: true,
27
+ });
28
+ return `${result.stdout || ''}`.trim().split(/\s+/).pop() || null;
29
+ };
30
+
31
+ export const getClaudeCliAuthStatus = ({
32
+ spawnSyncFn = spawnSync,
33
+ env = process.env,
34
+ platform = process.platform,
35
+ } = {}) => {
36
+ const childEnv = { ...env };
37
+ delete childEnv.ANTHROPIC_API_KEY;
38
+ delete childEnv.ANTHROPIC_AUTH_TOKEN;
39
+ delete childEnv.CLAUDE_CODE_OAUTH_TOKEN;
40
+
41
+ try {
42
+ let result = readStatus(spawnSyncFn, 'claude', childEnv);
43
+ if (!`${result.stdout || ''}`.trim() && result.error) {
44
+ const resolved = resolveFromLoginShell(spawnSyncFn, childEnv, platform);
45
+ if (resolved) result = readStatus(spawnSyncFn, resolved, childEnv);
46
+ }
47
+ const output = `${result.stdout || ''}`.trim();
48
+ if (!output) return { connected: false, reason: 'empty-status' };
49
+ const payload = JSON.parse(output);
50
+ return {
51
+ connected: payload?.loggedIn === true,
52
+ reason: payload?.loggedIn === true ? 'logged-in' : 'logged-out',
53
+ };
54
+ } catch (error) {
55
+ return {
56
+ connected: false,
57
+ reason: error instanceof Error ? error.message : String(error),
58
+ };
59
+ }
60
+ };
@@ -0,0 +1,54 @@
1
+ import { describe, expect, test } from 'bun:test';
2
+
3
+ import { getClaudeCliAuthStatus } from './claude-cli-auth.js';
4
+
5
+ describe('getClaudeCliAuthStatus', () => {
6
+ test('reports the authoritative Claude CLI login state', () => {
7
+ let invocation = null;
8
+ const status = getClaudeCliAuthStatus({
9
+ env: {
10
+ PATH: '/usr/bin',
11
+ CLAUDE_CODE_OAUTH_TOKEN: 'must-not-leak',
12
+ },
13
+ spawnSyncFn(command, args, options) {
14
+ invocation = { command, args, options };
15
+ return { stdout: JSON.stringify({ loggedIn: true, authMethod: 'oauth' }) };
16
+ },
17
+ });
18
+
19
+ expect(status).toEqual({ connected: true, reason: 'logged-in' });
20
+ expect(invocation.command).toBe('claude');
21
+ expect(invocation.args).toEqual(['auth', 'status', '--json']);
22
+ expect(invocation.options.env.CLAUDE_CODE_OAUTH_TOKEN).toBeUndefined();
23
+ });
24
+
25
+ test('ignores a stale OpenCode marker when the CLI is logged out', () => {
26
+ const status = getClaudeCliAuthStatus({
27
+ spawnSyncFn: () => ({ stdout: JSON.stringify({ loggedIn: false }) }),
28
+ });
29
+
30
+ expect(status).toEqual({ connected: false, reason: 'logged-out' });
31
+ });
32
+
33
+ test('finds Claude through a login shell when a desktop PATH cannot', () => {
34
+ const invocations = [];
35
+ const status = getClaudeCliAuthStatus({
36
+ env: { HOME: '/Users/test', PATH: '/usr/bin:/bin', SHELL: '/bin/zsh' },
37
+ platform: 'darwin',
38
+ spawnSyncFn(command, args, options) {
39
+ invocations.push({ command, args, options });
40
+ if (command === 'claude') return { stdout: '', error: new Error('spawnSync claude ENOENT') };
41
+ if (command === '/bin/zsh') return { stdout: '/Users/test/.local/bin/claude\n' };
42
+ return { stdout: JSON.stringify({ loggedIn: true, authMethod: 'claude.ai' }) };
43
+ },
44
+ });
45
+
46
+ expect(status).toEqual({ connected: true, reason: 'logged-in' });
47
+ expect(invocations.map(({ command }) => command)).toEqual([
48
+ 'claude',
49
+ '/bin/zsh',
50
+ '/Users/test/.local/bin/claude',
51
+ ]);
52
+ expect(invocations[1].args).toEqual(['-lic', 'command -v claude']);
53
+ });
54
+ });
@@ -8,6 +8,9 @@ import { registerGitRoutes } from '../git/routes.js';
8
8
  import { registerDevServerRoutes } from '../dev-servers/routes.js';
9
9
  import { registerMagicPromptRoutes } from '../magic-prompts/routes.js';
10
10
  import { registerSessionFoldersRoutes } from '../session-folders/routes.js';
11
+ import { registerProjectContextRoutes } from '../project-context/routes.js';
12
+ import { registerAgentMemoryRoutes } from '../agent-memory/routes.js';
13
+ import { registerSessionKnowledgeRoutes } from '../session-knowledge/routes.js';
11
14
  import { registerPermissionAutoAcceptRoutes } from '../permission-auto-accept/runtime.js';
12
15
  import { registerConfigEntityRoutes } from './config-entity-routes.js';
13
16
  import { registerSettingsUtilityRoutes } from './core-routes.js';
@@ -116,6 +119,10 @@ export const createFeatureRoutesRuntime = (dependencies) => {
116
119
  devServerScanner,
117
120
  buildAugmentedPath,
118
121
  projectConfigRuntime,
122
+ projectContextRuntime,
123
+ agentMemoryRuntime,
124
+ isAgentMemoryEnabled,
125
+ sessionKnowledgeRuntime,
119
126
  scheduledTasksRuntime,
120
127
  scheduledTaskService,
121
128
  openChamberSessionService,
@@ -304,6 +311,10 @@ export const createFeatureRoutesRuntime = (dependencies) => {
304
311
  path,
305
312
  openchamberDataDir,
306
313
  });
314
+ registerProjectContextRoutes(app, { projectContextRuntime });
315
+ registerAgentMemoryRoutes(app, { agentMemoryRuntime, isAgentMemoryEnabled });
316
+ registerSessionKnowledgeRoutes(app, { sessionKnowledgeRuntime });
317
+
307
318
  registerSessionFoldersRoutes(app, {
308
319
  fsPromises,
309
320
  path,
@@ -4,6 +4,7 @@ import path from 'path';
4
4
  import {
5
5
  AGENT_SCOPE,
6
6
  readConfigFile,
7
+ readConfigLayer,
7
8
  writeConfig,
8
9
  } from './shared.js';
9
10
  import { isPathSpec } from './plugin-spec.js';
@@ -111,15 +112,23 @@ function readPluginConfigLayers(workingDirectory) {
111
112
  const customPath = getActiveCustomConfigPath();
112
113
  const userPath = getPrimaryUserConfigPath();
113
114
  const projectPath = getProjectConfigPath(workingDirectory);
115
+ const userLayer = readConfigLayer(userPath);
116
+ const projectLayer = readConfigLayer(projectPath);
117
+ const customLayer = readConfigLayer(customPath);
114
118
  return {
115
- userConfig: readConfigFile(userPath),
116
- projectConfig: readConfigFile(projectPath),
117
- customConfig: readConfigFile(customPath),
119
+ userConfig: userLayer.config,
120
+ projectConfig: projectLayer.config,
121
+ customConfig: customLayer.config,
118
122
  paths: {
119
123
  userPath,
120
124
  projectPath,
121
125
  customPath,
122
126
  },
127
+ layerErrors: [
128
+ userLayer.error && { path: userPath, code: userLayer.error.code, message: userLayer.error.message },
129
+ projectLayer.error && projectPath && { path: projectPath, code: projectLayer.error.code, message: projectLayer.error.message },
130
+ customLayer.error && customPath && { path: customPath, code: customLayer.error.code, message: customLayer.error.message },
131
+ ].filter(Boolean),
123
132
  };
124
133
  }
125
134
 
@@ -121,6 +121,24 @@ describe('opencode plugins data layer', () => {
121
121
  expect(readJson(userConfigPath)).toEqual({});
122
122
  });
123
123
 
124
+ test('lists user plugins when a project layer is unparseable', () => {
125
+ const partialProject = [
126
+ '{',
127
+ ' "$schema": "https://opencode.ai/config.json",',
128
+ ' plugin: ["broken-project-plugin"],',
129
+ '}',
130
+ '',
131
+ ].join('\n');
132
+ writeJson(userConfigPath, { plugin: ['user-plugin'] });
133
+ const projectFile = path.join(projectDir, '.opencode', 'opencode.jsonc');
134
+ fs.mkdirSync(path.dirname(projectFile), { recursive: true });
135
+ fs.writeFileSync(projectFile, partialProject, 'utf8');
136
+
137
+ expect(plugins.listPluginEntries(projectDir).map((entry) => entry.spec)).toEqual(['user-plugin']);
138
+ expect(fs.readFileSync(projectFile, 'utf8')).toBe(partialProject);
139
+ expect(fs.existsSync(`${projectFile}.openchamber.backup`)).toBe(false);
140
+ });
141
+
124
142
  test('lists entries from user and project layers with scopes and parsed kinds', () => {
125
143
  writeJson(userConfigPath, { plugin: ['npm-plugin', '/abs/plugin.js', '@scope/pkg@1.0.0'] });
126
144
  writeJson(path.join(projectDir, '.opencode', 'opencode.json'), { plugin: ['./local-plugin.js'] });
@@ -0,0 +1,152 @@
1
+ import http from 'node:http';
2
+ import https from 'node:https';
3
+
4
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
5
+
6
+ const { createProxyMiddlewareMock } = vi.hoisted(() => ({
7
+ createProxyMiddlewareMock: vi.fn(),
8
+ }));
9
+
10
+ vi.mock('http-proxy-middleware', () => ({
11
+ createProxyMiddleware: createProxyMiddlewareMock,
12
+ }));
13
+
14
+ const { registerOpenCodeProxy } = await import('./proxy.js');
15
+
16
+ const createStubApp = () => {
17
+ const settings = new Map();
18
+ const noop = () => {};
19
+
20
+ return {
21
+ get: (...args) => (args.length === 1 ? settings.get(args[0]) : undefined),
22
+ set: (key, value) => {
23
+ settings.set(key, value);
24
+ },
25
+ use: noop,
26
+ post: noop,
27
+ put: noop,
28
+ patch: noop,
29
+ delete: noop,
30
+ all: noop,
31
+ };
32
+ };
33
+
34
+ /**
35
+ * `state` is intentionally mutable so a test can model the production ordering:
36
+ * the proxy is registered before OpenCode bootstraps, so the port/base URL only
37
+ * become resolvable afterwards.
38
+ */
39
+ const createStubDeps = (state) => ({
40
+ fs: { promises: { realpath: async (value) => value } },
41
+ os: {},
42
+ path: {},
43
+ OPEN_CODE_READY_GRACE_MS: 0,
44
+ LONG_REQUEST_TIMEOUT_MS: 1_000,
45
+ getRuntime: () => ({ openCodePort: state.port, openCodeBaseUrl: state.baseUrl }),
46
+ getOpenCodeAuthHeaders: () => ({}),
47
+ // Mirrors network-runtime.js: throws until the port is known.
48
+ buildOpenCodeUrl: (pathname) => {
49
+ if (!state.port) {
50
+ throw new Error('OpenCode port is not available');
51
+ }
52
+ return `${state.baseUrl}${pathname}`;
53
+ },
54
+ ensureOpenCodeApiPrefix: (pathname) => pathname,
55
+ });
56
+
57
+ const managedState = () => ({ port: 49303, baseUrl: 'http://127.0.0.1:49303' });
58
+ const coldState = () => ({ port: null, baseUrl: null });
59
+
60
+ const agentsFromCalls = () => createProxyMiddlewareMock.mock.calls.map(([options]) => options.agent);
61
+
62
+ describe('OpenCode API proxy agent wiring', () => {
63
+ beforeEach(() => {
64
+ createProxyMiddlewareMock.mockReset();
65
+ createProxyMiddlewareMock.mockImplementation(() => (_req, _res, next) => next?.());
66
+ });
67
+
68
+ it('constructs every proxy with a keep-alive agent', () => {
69
+ registerOpenCodeProxy(createStubApp(), createStubDeps(managedState()));
70
+
71
+ expect(createProxyMiddlewareMock).toHaveBeenCalled();
72
+
73
+ for (const agent of agentsFromCalls()) {
74
+ // Without an explicit agent, http-proxy falls back to `agent: false`,
75
+ // which forces `Connection: close` and burns one ephemeral port per
76
+ // request. See createOpenCodeProxyAgent in ./proxy.js.
77
+ expect(agent).toBeTruthy();
78
+ expect(agent.options?.keepAlive).toBe(true);
79
+ }
80
+ });
81
+
82
+ it('shares one agent instance across the API and OAuth proxies', () => {
83
+ registerOpenCodeProxy(createStubApp(), createStubDeps(managedState()));
84
+
85
+ const agents = agentsFromCalls();
86
+
87
+ expect(agents.length).toBeGreaterThan(1);
88
+ expect(agents.every(Boolean)).toBe(true);
89
+ expect(new Set(agents).size).toBe(1);
90
+ });
91
+
92
+ it('memoizes the agent per scheme rather than allocating one per resolution', () => {
93
+ registerOpenCodeProxy(createStubApp(), createStubDeps(managedState()));
94
+
95
+ const [options] = createProxyMiddlewareMock.mock.calls[0];
96
+
97
+ expect(options.agent).toBe(options.agent);
98
+ });
99
+
100
+ // Production ordering: startup-pipeline-runtime.js calls setupProxy() before
101
+ // bootstrapOpenCodeAtStartup(), so at registration the port is null,
102
+ // buildOpenCodeUrl throws, and resolveProxyTarget() falls back to the http
103
+ // loopback default. An external https server configured via OPENCODE_HOST is
104
+ // only visible after bootstrap, so the agent must be resolved lazily.
105
+ it('resolves an https agent after bootstrap even though registration ran cold', () => {
106
+ const state = coldState();
107
+ registerOpenCodeProxy(createStubApp(), createStubDeps(state));
108
+
109
+ // Cold: nothing resolvable yet, so the http fallback target applies.
110
+ for (const agent of agentsFromCalls()) {
111
+ expect(agent).not.toBeInstanceOf(https.Agent);
112
+ }
113
+
114
+ // Bootstrap completes against an external https server.
115
+ state.baseUrl = 'https://opencode.example.com:4096';
116
+
117
+ for (const agent of agentsFromCalls()) {
118
+ expect(agent).toBeInstanceOf(https.Agent);
119
+ // Asserted on the live resolver path, not just the exported factory:
120
+ // the https branch is the one a mutation could silently strip.
121
+ expect(agent.options?.keepAlive).toBe(true);
122
+ expect(agent.options?.maxFreeSockets).toBe(256);
123
+ }
124
+ });
125
+
126
+ it('keeps a plain http agent when bootstrap resolves an http target', () => {
127
+ const state = coldState();
128
+ registerOpenCodeProxy(createStubApp(), createStubDeps(state));
129
+
130
+ Object.assign(state, managedState());
131
+
132
+ for (const agent of agentsFromCalls()) {
133
+ // https.Agent extends http.Agent, so the negative assertion is load-bearing.
134
+ expect(agent).toBeInstanceOf(http.Agent);
135
+ expect(agent).not.toBeInstanceOf(https.Agent);
136
+ }
137
+ });
138
+
139
+ it('derives an https agent when the target is already https at registration', () => {
140
+ registerOpenCodeProxy(
141
+ createStubApp(),
142
+ createStubDeps({ port: 4096, baseUrl: 'https://opencode.example.com:4096' }),
143
+ );
144
+
145
+ const agents = agentsFromCalls();
146
+
147
+ expect(agents.length).toBeGreaterThan(0);
148
+ for (const agent of agents) {
149
+ expect(agent).toBeInstanceOf(https.Agent);
150
+ }
151
+ });
152
+ });