@openchamber/web 1.19.0 → 1.21.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 (182) hide show
  1. package/dist/assets/{CodeMirrorCommentWidgets-DAvopJvy.js → CodeMirrorCommentWidgets-C2BopIs3.js} +1 -1
  2. package/dist/assets/CommitSection-HJeMUAWb.js +1 -0
  3. package/dist/assets/DiffView-D5cvbEPb.js +4 -0
  4. package/dist/assets/FilesView-DPU8aNPL.js +17 -0
  5. package/dist/assets/GitView-Ct6xWrVH.js +6 -0
  6. package/dist/assets/{JsonTreeView-h4dHASlq.js → JsonTreeView-osju7J70.js} +1 -1
  7. package/dist/assets/MarkdownImageGallery-EujHSZ2M.js +1 -0
  8. package/dist/assets/MarkdownRendererImpl-CPzu4kIr.js +12 -0
  9. package/dist/assets/OnboardingScreen-w2VG4fWY.js +1 -0
  10. package/dist/assets/{PatchDiff-jPKTJje5.js → PatchDiff-Dan3mADn.js} +1 -1
  11. package/dist/assets/PierreDiffViewer-CGoI2v0q.js +157 -0
  12. package/dist/assets/PlanView-Dgg-WTEc.js +4 -0
  13. package/dist/assets/SessionSwitcherDropdown-CJTrc8K7.js +1 -0
  14. package/dist/assets/SettingsView-D9yRuFZw.js +28 -0
  15. package/dist/assets/SettingsWindow-DXF-MTHG.js +1 -0
  16. package/dist/assets/ToolOutputDialog-DrCa1JRk.js +15 -0
  17. package/dist/assets/ToolPartDiffPreview-B_tfvlNF.js +8 -0
  18. package/dist/assets/{VirtualizedFileDiff-B37yB9jZ.js → VirtualizedFileDiff-CN_BctrR.js} +4 -4
  19. package/dist/assets/{Virtualizer-X_7XPoTH.js → Virtualizer-CZlLSacm.js} +1 -1
  20. package/dist/assets/Virtualizer-D_a8gKmg.js +1 -0
  21. package/dist/assets/{WalkthroughView-Bxun3k66.js → WalkthroughView-D9Q4lr5x.js} +2 -2
  22. package/dist/assets/{computeVirtualFileMetrics-DYFv_yZS.js → computeVirtualFileMetrics-Gi1d5eU1.js} +1 -1
  23. package/dist/assets/contextPanelEmbeddedChat-CpzVNWAv.js +1 -0
  24. package/dist/assets/de-B_LdJwEM.js +9 -0
  25. package/dist/assets/es-CubfsAYV.js +15 -0
  26. package/dist/assets/fr-5qJM0nFS.js +13 -0
  27. package/dist/assets/index-BW82eK5v.css +1 -0
  28. package/dist/assets/index-Brm3X9rs.js +1 -0
  29. package/dist/assets/index-rlLjZUM5.js +7 -0
  30. package/dist/assets/{isDiffPlainText-DwHKxDYc.js → isDiffPlainText-pH9kAJQH.js} +1 -1
  31. package/dist/assets/{isFilePlainText-Dwq6ILxo.js → isFilePlainText-CVKy_dgB.js} +1 -1
  32. package/dist/assets/ja-DJYIBUlH.js +15 -0
  33. package/dist/assets/ko-DcUBkB7y.js +15 -0
  34. package/dist/assets/main-DLBxKIoX.js +926 -0
  35. package/dist/assets/main-vUCh0VB0.js +2 -0
  36. package/dist/assets/markdownCore-DG6GHLF4.js +3 -0
  37. package/dist/assets/miniChat-BlzGEYgE.js +2 -0
  38. package/dist/assets/mobile-CkX6H-IT.js +2 -0
  39. package/dist/assets/{patchFileDiff-BEDPDypx.js → patchFileDiff-BCTsE43U.js} +3 -3
  40. package/dist/assets/pl-rB6BLcio.js +15 -0
  41. package/dist/assets/pt-BR-DcwtlO-o.js +15 -0
  42. package/dist/assets/renderElectronMiniChatApp-CJYe_KOL.js +2 -0
  43. package/dist/assets/renderMobileApp-hQJTnr8B.js +25 -0
  44. package/dist/assets/runtimeEndpointReset-BDh7r8BL.js +15 -0
  45. package/dist/assets/scheduledTasksApi-CAGPh_gZ.js +1 -0
  46. package/dist/assets/{shikiHighlight-DXYW46vW.js → shikiHighlight-BgTPSITe.js} +1 -1
  47. package/dist/assets/uk-INZlFD9A.js +15 -0
  48. package/dist/assets/useAppFontEffects-Cll4gnsh.js +7268 -0
  49. package/dist/assets/useInlineCommentController-DFFv0hae.js +2 -0
  50. package/dist/assets/{vendor-base-ui-BYlZTzrw.js → vendor-base-ui-_6j2xOWl.js} +1 -1
  51. package/dist/assets/{vendor-codemirror-language-data-CiAYDJXN.js → vendor-codemirror-language-data-DkQX2EBa.js} +2 -2
  52. package/dist/assets/{vendor-framer-motion-CRSgBxjL.js → vendor-framer-motion-livSKyyV.js} +1 -1
  53. package/dist/assets/vendor-legendapp-list-gg7YLRW7.js +1 -0
  54. package/dist/assets/{vendor-motion-dom-DJLgZh4Q.js → vendor-motion-dom-D_o3BTI3.js} +1 -1
  55. package/dist/assets/vendor-zod-BLfBSgBh.js +39 -0
  56. package/dist/assets/{web-components-DCLjCO9n.js → web-components-DLnGY4fs.js} +4 -4
  57. package/dist/assets/zh-CN-Dzda8xa1.js +15 -0
  58. package/dist/assets/zh-TW-Cwn3rNYZ.js +15 -0
  59. package/dist/index.html +6 -5
  60. package/dist/mini-chat.html +5 -4
  61. package/dist/mobile.html +5 -4
  62. package/package.json +5 -7
  63. package/server/index.js +44 -0
  64. package/server/lib/agent-memory/project-resolution.js +10 -1
  65. package/server/lib/agent-memory/project-resolution.test.js +9 -0
  66. package/server/lib/agent-memory/runtime.js +7 -2
  67. package/server/lib/client-auth/pairing.js +8 -7
  68. package/server/lib/client-auth/pairing.test.js +5 -1
  69. package/server/lib/client-auth/remote-clients.js +9 -1
  70. package/server/lib/client-auth/remote-clients.test.js +17 -0
  71. package/server/lib/dictation/DOCUMENTATION.md +32 -8
  72. package/server/lib/dictation/local/sherpa-recognizer.js +35 -78
  73. package/server/lib/dictation/local/worker-process.js +2 -2
  74. package/server/lib/dictation/openai-compatible-session.js +3 -2
  75. package/server/lib/dictation/stream-manager.js +77 -34
  76. package/server/lib/dictation/stream-manager.test.js +60 -2
  77. package/server/lib/fs/routes.test.js +76 -0
  78. package/server/lib/git/routes.js +43 -0
  79. package/server/lib/git/service.js +85 -5
  80. package/server/lib/git/service.test.js +93 -0
  81. package/server/lib/github/pr-status.js +10 -1
  82. package/server/lib/opencode/DOCUMENTATION.md +6 -2
  83. package/server/lib/opencode/feature-routes-runtime.js +5 -9
  84. package/server/lib/opencode/lifecycle.js +202 -26
  85. package/server/lib/opencode/lifecycle.test.js +179 -1
  86. package/server/lib/opencode/providers.js +9 -4
  87. package/server/lib/opencode/providers.test.js +27 -0
  88. package/server/lib/opencode/restart-session-recovery.test.js +59 -0
  89. package/server/lib/opencode/session-runtime.js +39 -2
  90. package/server/lib/opencode/session-runtime.test.js +74 -0
  91. package/server/lib/opencode/settings-helpers.js +15 -0
  92. package/server/lib/opencode/settings-helpers.test.js +22 -0
  93. package/server/lib/opencode/settings-normalization-runtime.js +3 -0
  94. package/server/lib/opencode/settings-normalization-runtime.test.js +16 -0
  95. package/server/lib/opencode/settings-runtime.js +32 -10
  96. package/server/lib/opencode/settings-runtime.test.js +85 -0
  97. package/server/lib/opencode/skill-routes.js +29 -73
  98. package/server/lib/opencode/skill-routes.test.js +2 -5
  99. package/server/lib/project-context/DOCUMENTATION.md +2 -0
  100. package/server/lib/project-context/runtime.js +7 -2
  101. package/server/lib/projects/project-config.js +7 -2
  102. package/server/lib/quota/DOCUMENTATION.md +1 -1
  103. package/server/lib/quota/providers/claude/index.js +2 -2
  104. package/server/lib/quota/providers/index.js +1 -7
  105. package/server/lib/quota/providers/zai.js +26 -6
  106. package/server/lib/quota/providers/zai.test.js +33 -0
  107. package/server/lib/relay/DOCUMENTATION.md +1 -1
  108. package/server/lib/relay/service.js +34 -2
  109. package/server/lib/relay/service.test.js +69 -0
  110. package/server/lib/session-goal/runtime.js +2 -1
  111. package/server/lib/session-goal/runtime.test.js +4 -2
  112. package/server/lib/session-knowledge/DOCUMENTATION.md +2 -0
  113. package/server/lib/skills-catalog/DOCUMENTATION.md +18 -45
  114. package/server/lib/skills-catalog/cache.js +120 -1
  115. package/server/lib/skills-catalog/cache.test.js +77 -0
  116. package/server/lib/skills-catalog/curated-sources.js +21 -5
  117. package/server/lib/skills-catalog/curated-sources.test.js +4 -4
  118. package/server/lib/skills-catalog/disk-cache.js +52 -0
  119. package/server/lib/skills-catalog/github-meta.js +139 -0
  120. package/server/lib/skills-catalog/github-meta.test.js +71 -0
  121. package/server/lib/skills-catalog/source.js +0 -5
  122. package/server/lib/small-model/DOCUMENTATION.md +74 -6
  123. package/server/lib/small-model/call.js +46 -12
  124. package/server/lib/small-model/call.test.js +79 -0
  125. package/server/lib/small-model/index.js +51 -8
  126. package/server/lib/small-model/index.test.js +73 -3
  127. package/server/lib/small-model/routes.js +1 -1
  128. package/server/lib/small-model/runtime-providers.js +156 -0
  129. package/server/lib/small-model/runtime-providers.test.js +112 -0
  130. package/server/lib/terminal/DOCUMENTATION.md +2 -0
  131. package/server/lib/terminal/runtime.js +29 -1
  132. package/server/lib/terminal/runtime.test.js +26 -0
  133. package/server/lib/ui-auth/ui-auth.js +2 -2
  134. package/server/lib/ui-auth/ui-auth.test.js +2 -2
  135. package/dist/assets/CommitSection-D9cV-qR9.js +0 -1
  136. package/dist/assets/DiagramEditor-B9NCadU7.js +0 -1
  137. package/dist/assets/DiagramView-LKGBwf4G.js +0 -1
  138. package/dist/assets/DiffView-BWNq-0ov.js +0 -4
  139. package/dist/assets/FilesView-DB-Q0Gkz.js +0 -14
  140. package/dist/assets/GitView-DsWXqWx3.js +0 -6
  141. package/dist/assets/MarkdownImageGallery-n0ikH-xm.js +0 -1
  142. package/dist/assets/MarkdownRendererImpl-CT2mjx-s.js +0 -12
  143. package/dist/assets/OnboardingScreen-CDjgzxEe.js +0 -1
  144. package/dist/assets/PierreDiffViewer-D_Gt4A_6.js +0 -136
  145. package/dist/assets/PlanView-UvuxIl9-.js +0 -4
  146. package/dist/assets/SessionSwitcherDropdown-xKU4LRuQ.js +0 -1
  147. package/dist/assets/SettingsView-3B9VN6Ys.js +0 -28
  148. package/dist/assets/SettingsWindow-CqQNDKNd.js +0 -1
  149. package/dist/assets/ToolOutputDialog-PmjlAxVE.js +0 -15
  150. package/dist/assets/ToolPartDiffPreview-B34Xw9wq.js +0 -8
  151. package/dist/assets/contextPanelEmbeddedChat-BO1wRpaN.js +0 -1
  152. package/dist/assets/de-DbV6CLxv.js +0 -9
  153. package/dist/assets/es-CVDlyzZ4.js +0 -15
  154. package/dist/assets/fr-Czc-p0g-.js +0 -13
  155. package/dist/assets/index-1OhiMDBz.css +0 -1
  156. package/dist/assets/index-BSvmTvZl.js +0 -1
  157. package/dist/assets/index-DzriVon2.js +0 -7
  158. package/dist/assets/ja-dwc9NM_S.js +0 -15
  159. package/dist/assets/ko-Ds1DZ8FX.js +0 -15
  160. package/dist/assets/main-BF51IOVF.js +0 -921
  161. package/dist/assets/main-D7UPARut.js +0 -2
  162. package/dist/assets/markdownCore-BgeBDwD3.js +0 -2
  163. package/dist/assets/miniChat-BISXSGOo.js +0 -2
  164. package/dist/assets/mobile-BnYxVuvw.js +0 -2
  165. package/dist/assets/pl-CLiTO7i-.js +0 -15
  166. package/dist/assets/pt-BR-GIimJgpK.js +0 -15
  167. package/dist/assets/renderElectronMiniChatApp-BaOy72Gi.js +0 -2
  168. package/dist/assets/renderMobileApp-BiMbzPq9.js +0 -25
  169. package/dist/assets/runtimeEndpointReset-BMBRhIbf.js +0 -15
  170. package/dist/assets/scheduledTasksApi-01zzfzqH.js +0 -1
  171. package/dist/assets/uk-DLfgD1ki.js +0 -15
  172. package/dist/assets/useAppFontEffects-CbzHzFop.js +0 -7271
  173. package/dist/assets/useInlineCommentController-CegKdDXi.js +0 -2
  174. package/dist/assets/vendor-zod-adaMkgkm.js +0 -39
  175. package/dist/assets/zh-CN-DkeP5awK.js +0 -15
  176. package/dist/assets/zh-TW-BocaFm3d.js +0 -15
  177. package/server/lib/quota/providers/command-code.js +0 -90
  178. package/server/lib/quota/providers/command-code.test.js +0 -72
  179. package/server/lib/skills-catalog/clawdhub/api.js +0 -126
  180. package/server/lib/skills-catalog/clawdhub/install.js +0 -238
  181. package/server/lib/skills-catalog/clawdhub/install.test.js +0 -100
  182. package/server/lib/skills-catalog/clawdhub/scan.js +0 -61
@@ -69,14 +69,11 @@ const startSkillsApp = ({ projectRoot }) => {
69
69
  SKILL_DIR,
70
70
  getCuratedSkillsSources: () => [],
71
71
  getCacheKey: () => 'k',
72
- getCachedScan: () => null,
73
- setCachedScan: () => {},
72
+ scanWithCache: async (_key, loader) => loader(),
74
73
  parseSkillRepoSource: () => ({ ok: false }),
75
74
  scanSkillsRepository: async () => ({ ok: false }),
76
75
  installSkillsFromRepository: async () => ({ ok: false }),
77
- scanClawdHubPage: async () => ({ ok: false }),
78
- installSkillsFromClawdHub: async () => ({ ok: false }),
79
- isClawdHubSource: () => false,
76
+ fetchGitHubRepoMetas: async () => ({}),
80
77
  getProfiles: () => [],
81
78
  getProfile: () => null,
82
79
  });
@@ -3,6 +3,8 @@
3
3
  Server-owned storage for the Project Notes surface: free-form notes, todos, and
4
4
  plan markdown files.
5
5
 
6
+ The managed Chats root (`~/.config/openchamber/chats`) is also one context owner. Every dated per-session directory beneath it resolves to that root, so Notes, Todo, Plans, pinned knowledge, and project memory are shared across ordinary chats without registering Chats as a user project.
7
+
6
8
  ## Ownership
7
9
 
8
10
  | Path | Owner | Contents |
@@ -231,8 +231,13 @@ export const createProjectContextRuntime = (deps) => {
231
231
  const writeJsonAtomic = async (filePath, value) => {
232
232
  const temporaryPath = `${filePath}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
233
233
  await fsPromises.mkdir(path.dirname(filePath), { recursive: true });
234
- await fsPromises.writeFile(temporaryPath, JSON.stringify(value, null, 2), 'utf8');
235
- await fsPromises.rename(temporaryPath, filePath);
234
+ try {
235
+ await fsPromises.writeFile(temporaryPath, JSON.stringify(value, null, 2), 'utf8');
236
+ await fsPromises.rename(temporaryPath, filePath);
237
+ } catch (error) {
238
+ await fsPromises.rm(temporaryPath, { force: true }).catch(() => {});
239
+ throw error;
240
+ }
236
241
  };
237
242
 
238
243
  const withWriteLock = async (projectId, mutate) => {
@@ -536,8 +536,13 @@ export const createProjectConfigRuntime = (deps) => {
536
536
  };
537
537
 
538
538
  await fsPromises.mkdir(parentDirectory, { recursive: true });
539
- await fsPromises.writeFile(temporaryPath, JSON.stringify(merged, null, 2), 'utf8');
540
- await fsPromises.rename(temporaryPath, filePath);
539
+ try {
540
+ await fsPromises.writeFile(temporaryPath, JSON.stringify(merged, null, 2), 'utf8');
541
+ await fsPromises.rename(temporaryPath, filePath);
542
+ } catch (error) {
543
+ await fsPromises.rm(temporaryPath, { force: true }).catch(() => {});
544
+ throw error;
545
+ }
541
546
  };
542
547
 
543
548
  const withProjectWriteLock = async (projectID, mutate) => {
@@ -101,4 +101,4 @@ The provider computes `usedPercent` from whichever of `used`/`remaining` is pres
101
101
  - Keep provider IDs stable; clients use them directly.
102
102
  - Avoid adding alias-based dispatch in `fetchQuotaForProvider`; dispatch currently expects exact provider IDs.
103
103
  - Keep Google behavior changes isolated and review `providers/google/*` together.
104
- - Z.ai Coding Plan exposes separate 5-hour and weekly `TOKENS_LIMIT` entries plus a monthly `TIME_LIMIT` for MCP tools; web and VS Code must preserve all three windows.
104
+ - Z.ai Coding Plan exposes separate 5-hour and weekly token/credit limit entries plus a monthly `TIME_LIMIT` for MCP tools. The API renamed the limit type from `TOKENS_LIMIT` to `CREDIT_LIMIT` (same `unit`/`number` window semantics); `CREDIT_LIMIT` entries additionally carry `usage` (total), `currentValue` (consumed), and `remaining`, surfaced as a credit `valueLabel`, and the payload's `data.level` becomes `planLabel`. Web and VS Code must preserve these windows and stay in sync.
@@ -81,7 +81,7 @@ const fetchQuotaUncoalesced = async () => {
81
81
 
82
82
  if (Date.now() < cooldownUntil) {
83
83
  return cachedResultFor(fingerprint, credential.planLabel)
84
- ?? failure('Rate limited by Anthropic. Retrying shortly.');
84
+ ?? failure('Rate limited. Retrying soon.');
85
85
  }
86
86
 
87
87
  let response;
@@ -100,7 +100,7 @@ const fetchQuotaUncoalesced = async () => {
100
100
  if (response.status === 429) {
101
101
  cooldownUntil = Date.now() + cooldownFromHeader(response);
102
102
  return cachedResultFor(fingerprint, credential.planLabel)
103
- ?? failure('Rate limited by Anthropic. Retrying shortly.');
103
+ ?? failure('Rate limited. Retrying soon.');
104
104
  }
105
105
 
106
106
  if (response.status === 401 || response.status === 403) {
@@ -9,7 +9,6 @@ import { buildResult } from '../utils/index.js';
9
9
 
10
10
  import * as claude from './claude/index.js';
11
11
  import * as codex from './codex.js';
12
- import * as commandCode from './command-code.js';
13
12
  import * as copilot from './copilot.js';
14
13
  import * as crof from './crof.js';
15
14
  import * as cursor from './cursor.js';
@@ -30,12 +29,6 @@ import * as opencodeGo from './opencode-go.js';
30
29
  import * as xai from './xai.js';
31
30
 
32
31
  const registry = {
33
- 'command-code': {
34
- providerId: commandCode.providerId,
35
- providerName: commandCode.providerName,
36
- isConfigured: commandCode.isConfigured,
37
- fetchQuota: commandCode.fetchQuota
38
- },
39
32
  claude: {
40
33
  providerId: claude.providerId,
41
34
  providerName: claude.providerName,
@@ -160,6 +153,7 @@ const registry = {
160
153
 
161
154
  const pendingFetches = new Map();
162
155
 
156
+
163
157
  export const listConfiguredQuotaProviders = () => {
164
158
  const configured = [];
165
159
 
@@ -4,6 +4,7 @@ import {
4
4
  normalizeAuthEntry,
5
5
  buildResult,
6
6
  toUsageWindow,
7
+ toNumber,
7
8
  resolveWindowSeconds,
8
9
  resolveWindowLabel,
9
10
  normalizeTimestamp
@@ -13,6 +14,20 @@ export const providerId = 'zai-coding-plan';
13
14
  export const providerName = 'z.ai';
14
15
  const aliases = ['zai-coding-plan', 'zai', 'z.ai'];
15
16
 
17
+ // CREDIT_LIMIT entries carry `usage` (total credits), `currentValue` (consumed),
18
+ // and `remaining`; TOKENS_LIMIT entries only carry a percentage.
19
+ const formatCreditAmount = (value) => {
20
+ if (value < 1000) return value.toLocaleString('en-US');
21
+ return `${Math.round(value / 100) / 10}k`;
22
+ };
23
+
24
+ const formatCreditValueLabel = (limit) => {
25
+ const used = toNumber(limit?.currentValue);
26
+ const total = toNumber(limit?.usage);
27
+ if (used === null || total === null) return null;
28
+ return `${formatCreditAmount(used)} / ${formatCreditAmount(total)} credits`;
29
+ };
30
+
16
31
  export const isConfigured = () => {
17
32
  const auth = readAuthFile();
18
33
  const entry = normalizeAuthEntry(getAuthEntry(auth, aliases));
@@ -56,16 +71,20 @@ export const fetchQuota = async () => {
56
71
  const payload = await response.json();
57
72
  const limits = Array.isArray(payload?.data?.limits) ? payload.data.limits : [];
58
73
  const windows = {};
59
- for (const tokensLimit of limits.filter((limit) => limit?.type === 'TOKENS_LIMIT')) {
60
- const windowSeconds = resolveWindowSeconds(tokensLimit);
74
+ // The API renamed TOKENS_LIMIT to CREDIT_LIMIT; field semantics stayed the same,
75
+ // so both limit types map to the same windows.
76
+ for (const limit of limits.filter((entry) => entry?.type === 'TOKENS_LIMIT' || entry?.type === 'CREDIT_LIMIT')) {
77
+ const windowSeconds = resolveWindowSeconds(limit);
61
78
  const windowLabel = resolveWindowLabel(windowSeconds);
62
- const resetAt = tokensLimit?.nextResetTime ? normalizeTimestamp(tokensLimit.nextResetTime) : null;
63
- const usedPercent = typeof tokensLimit?.percentage === 'number' ? tokensLimit.percentage : null;
79
+ const resetAt = limit?.nextResetTime ? normalizeTimestamp(limit.nextResetTime) : null;
80
+ const usedPercent = typeof limit?.percentage === 'number' ? limit.percentage : null;
81
+ const creditValueLabel = formatCreditValueLabel(limit);
64
82
 
65
83
  windows[windowLabel] = toUsageWindow({
66
84
  usedPercent,
67
85
  windowSeconds,
68
- resetAt
86
+ resetAt,
87
+ valueLabel: creditValueLabel
69
88
  });
70
89
  }
71
90
 
@@ -83,7 +102,8 @@ export const fetchQuota = async () => {
83
102
  providerName,
84
103
  ok: true,
85
104
  configured: true,
86
- usage: { windows }
105
+ usage: { windows },
106
+ planLabel: typeof payload?.data?.level === 'string' && payload.data.level ? payload.data.level : null
87
107
  });
88
108
  } catch (error) {
89
109
  return buildResult({
@@ -51,4 +51,37 @@ describe('Z.ai quota provider', () => {
51
51
  resetAt: 1787128459979,
52
52
  });
53
53
  });
54
+
55
+ it('maps CREDIT_LIMIT entries to windows with credit value labels and plan level', async () => {
56
+ vi.stubGlobal('fetch', vi.fn().mockResolvedValue(mockResponse({
57
+ code: 200,
58
+ data: {
59
+ limits: [
60
+ { type: 'CREDIT_LIMIT', unit: 3, number: 5, usage: 12000, currentValue: 65, remaining: 11934, percentage: 1, nextResetTime: 1787257978907 },
61
+ { type: 'CREDIT_LIMIT', unit: 6, number: 1, usage: 60000, currentValue: 65, remaining: 59934, percentage: 1, nextResetTime: 1787844668997 },
62
+ ],
63
+ level: 'pro',
64
+ },
65
+ })));
66
+
67
+ const result = await fetchQuota();
68
+ const windows = result.usage.windows;
69
+
70
+ expect(result.ok).toBe(true);
71
+ expect(result.planLabel).toBe('pro');
72
+ expect(windows['5h']).toMatchObject({
73
+ usedPercent: 1,
74
+ remainingPercent: 99,
75
+ windowSeconds: 5 * 60 * 60,
76
+ resetAt: 1787257978907,
77
+ valueLabel: '65 / 12k credits',
78
+ });
79
+ expect(windows.weekly).toMatchObject({
80
+ usedPercent: 1,
81
+ remainingPercent: 99,
82
+ windowSeconds: 7 * 24 * 60 * 60,
83
+ resetAt: 1787844668997,
84
+ valueLabel: '65 / 60k credits',
85
+ });
86
+ });
54
87
  });
@@ -23,7 +23,7 @@ Host side (`packages/web/server/lib/relay/`):
23
23
  - `identity.js` — the host's stable identity: the long-lived signing keypair (shared with the push relay, defines the routing id) plus a long-lived encryption keypair (the E2EE trust anchor). Reused across restarts; never rotated implicitly.
24
24
  - `signing-key.js` — storage/derivation of the signing keypair and the routing id, shared with the notifications runtime.
25
25
  - `host-client.js` — the long-lived connection manager: one outbound control connection to the relay, a per-client data connection for each connected device, reconnect/backoff, and the E2EE responder handshake per connection.
26
- - `host-lock.js` — the per-machine host claim. Every local instance sharing the data dir shares the relay identity (same serverId), so concurrent relay hosts evict each other at the relay worker (`4001: Control replaced`) and paired devices land on whichever local process won last. The claim file (`<data-dir>/relay-host.lock`, `{ pid }`) makes this deterministic: `service.js` only starts the host when no LIVE process holds the claim (stale claims from dead pids are ignored), goes to `standby` otherwise, and a 30s watcher both takes over when the claimant dies and stands down when another process claims. Explicit user intent — creating a pairing link or hitting `/relay/enable` — force-claims; the previous holder's watcher sees the takeover and backs off instead of fighting. The claim is cooperative (the relay worker still enforces the single host slot); it only decides which process keeps retrying.
26
+ - `host-lock.js` — the per-machine host claim. Every local instance sharing the data dir shares the relay identity (same serverId), so concurrent relay hosts evict each other at the relay worker (`4001: Control replaced`) and paired devices land on whichever local process won last. The claim file (`<data-dir>/relay-host.lock`, `{ pid }`) makes this deterministic: `service.js` only starts the host when no LIVE process holds the claim (stale claims from dead pids are ignored), goes to `standby` otherwise, and a 30s watcher both takes over when the claimant dies and stands down when another process claims. A standby watcher waits a 2-minute grace after the claim frees before taking over, so a cleanly restarting host (app update/relaunch) — which reclaims at boot with no wait — always wins the restart window over a bystander instance. Explicit user intent — creating a pairing link or hitting `/relay/enable` — force-claims; the previous holder's watcher sees the takeover and backs off instead of fighting. Instances created with `allowPassiveHost: false` (dev servers via `OPENCHAMBER_RELAY_HOST=off`, the Electron dev shell via `OPENCHAMBER_ELECTRON_DEV`; `OPENCHAMBER_RELAY_HOST=on` overrides) never start the host passively at all — boot, demand reconcile, and watcher takeover leave them in `standby`; only explicit enable/pairing hosts there. The claim is cooperative (the relay worker still enforces the single host slot); it only decides which process keeps retrying.
27
27
  - `tunnel-host.js` — the per-connection dispatcher: decrypts tunnel frames and forwards HTTP/SSE/WS to the local server over loopback, then streams responses back. Enforces a path allowlist and never injects credentials.
28
28
  - `e2ee.js`, `tunnel-codec.js` — host-side (JS) mirrors of the shared crypto and framing (see "Two implementations" below).
29
29
 
@@ -70,6 +70,11 @@ export const createRelayService = ({
70
70
  // evict each other at the relay worker ("Control replaced") and devices land
71
71
  // on a random instance. Optional: without it, behavior is pre-lock.
72
72
  hostLock = null,
73
+ // When false, this instance never starts the relay host on its own (boot,
74
+ // demand reconcile, or claim-watch takeover) — only an explicit user action
75
+ // (enable, pairing) force-claims. Dev/debug instances set this so they do not
76
+ // capture paired devices from the production instance sharing the data dir.
77
+ allowPassiveHost = true,
73
78
  logger = console,
74
79
  }) => {
75
80
  const identityRuntime = createRelayIdentityRuntime({ crypto, readSettingsFromDiskMigrated, writeSettingsToDisk, readSettingsStrict });
@@ -80,6 +85,13 @@ export const createRelayService = ({
80
85
  // claimant dies; a running host stands down when another process claims.
81
86
  let claimWatchTimer = null;
82
87
  const CLAIM_WATCH_INTERVAL_MS = 30_000;
88
+ // A standby instance does not grab a freed claim immediately: a clean restart
89
+ // of the previous host (app update, relaunch) releases the claim for a short
90
+ // while, and taking it during that window strands the devices on this —
91
+ // possibly older — instance. The restarting host reclaims at boot without any
92
+ // wait, so it always wins the window.
93
+ const CLAIM_TAKEOVER_GRACE_MS = 120_000;
94
+ let claimFreeSinceMs = null;
83
95
 
84
96
  const readConfig = async () => {
85
97
  const settings = await readSettingsFromDiskMigrated();
@@ -133,8 +145,19 @@ export const createRelayService = ({
133
145
  }
134
146
  return;
135
147
  }
136
- if (status.state === 'standby' && hostLock.tryClaim()) {
137
- logger.warn('[Relay] host claim is free — taking over the relay host');
148
+ if (status.state !== 'standby' || !allowPassiveHost) return;
149
+ if (hostLock.liveClaimantPid() !== null) {
150
+ claimFreeSinceMs = null;
151
+ return;
152
+ }
153
+ if (claimFreeSinceMs === null) {
154
+ claimFreeSinceMs = Date.now();
155
+ return;
156
+ }
157
+ if (Date.now() - claimFreeSinceMs < CLAIM_TAKEOVER_GRACE_MS) return;
158
+ if (hostLock.tryClaim()) {
159
+ claimFreeSinceMs = null;
160
+ logger.warn('[Relay] host claim stayed free — taking over the relay host');
138
161
  await start(relayUrl);
139
162
  }
140
163
  } catch (error) {
@@ -149,10 +172,19 @@ export const createRelayService = ({
149
172
  if (!claimWatchTimer) return;
150
173
  clearInterval(claimWatchTimer);
151
174
  claimWatchTimer = null;
175
+ claimFreeSinceMs = null;
152
176
  };
153
177
 
154
178
  const start = async (relayUrl, { claim = 'try' } = {}) => {
155
179
  if (hostClient) return;
180
+ if (claim !== 'force' && !allowPassiveHost) {
181
+ status = {
182
+ state: 'standby',
183
+ lastError: 'passive relay hosting is disabled on this instance — enable the relay or create a pairing link to host here',
184
+ connectedClients: 0,
185
+ };
186
+ return;
187
+ }
156
188
  if (hostLock) {
157
189
  const claimed = claim === 'force' ? hostLock.forceClaim() : hostLock.tryClaim();
158
190
  if (!claimed) {
@@ -0,0 +1,69 @@
1
+ import { describe, it, expect, vi } from 'vitest';
2
+ import crypto from 'node:crypto';
3
+
4
+ import { createRelayService } from './service.js';
5
+
6
+ const makeService = (options = {}) => {
7
+ // In-memory settings store with a pre-seeded relay identity so the service
8
+ // never regenerates a signing key during the test.
9
+ const { privateKey, publicKey } = crypto.generateKeyPairSync('ec', { namedCurve: 'P-256' });
10
+ let settings = {
11
+ relaySigningKey: {
12
+ privateJwk: privateKey.export({ format: 'jwk' }),
13
+ publicJwk: publicKey.export({ format: 'jwk' }),
14
+ },
15
+ privateRelay: { enabled: true, relayUrl: 'wss://relay.example.test/ws' },
16
+ ...options.settings,
17
+ };
18
+ const hostLock = {
19
+ tryClaim: vi.fn(() => true),
20
+ forceClaim: vi.fn(() => true),
21
+ holdsClaim: vi.fn(() => true),
22
+ liveClaimantPid: vi.fn(() => null),
23
+ release: vi.fn(),
24
+ };
25
+ const service = createRelayService({
26
+ crypto,
27
+ readSettingsFromDiskMigrated: async () => settings,
28
+ writeSettingsToDisk: async (next) => { settings = next; },
29
+ readSettingsStrict: async () => settings,
30
+ getLocalPort: () => 0,
31
+ hasRelayDemand: options.hasRelayDemand ?? (async () => true),
32
+ hostLock,
33
+ allowPassiveHost: options.allowPassiveHost,
34
+ logger: { warn: () => {} },
35
+ });
36
+ return { service, hostLock, getSettings: () => settings };
37
+ };
38
+
39
+ describe('relay service passive hosting', () => {
40
+ it('never claims or starts the host passively when passive hosting is disabled', async () => {
41
+ const { service, hostLock } = makeService({ allowPassiveHost: false });
42
+ try {
43
+ await service.startIfEnabled();
44
+ let status = await service.getStatus();
45
+ expect(status.state).toBe('standby');
46
+ expect(hostLock.tryClaim).not.toHaveBeenCalled();
47
+ expect(hostLock.forceClaim).not.toHaveBeenCalled();
48
+
49
+ await service.reconcile();
50
+ status = await service.getStatus();
51
+ expect(status.state).toBe('standby');
52
+ expect(status.lastError).toContain('passive relay hosting is disabled');
53
+ expect(hostLock.tryClaim).not.toHaveBeenCalled();
54
+ } finally {
55
+ service.stop();
56
+ }
57
+ });
58
+
59
+ it('force-claims for an explicit pairing even when passive hosting is disabled', async () => {
60
+ const { service, hostLock } = makeService({ allowPassiveHost: false });
61
+ try {
62
+ const candidate = await service.ensureEnabledForPairing();
63
+ expect(candidate?.type).toBe('relay');
64
+ expect(hostLock.forceClaim).toHaveBeenCalled();
65
+ } finally {
66
+ service.stop();
67
+ }
68
+ });
69
+ });
@@ -249,6 +249,7 @@ export const createSessionGoalRuntime = ({
249
249
  getOpenCodeAuthHeaders,
250
250
  getSmallModelService,
251
251
  emitGoalNotification,
252
+ isEnabled = isSessionGoalEnabled,
252
253
  idleQuietMs = IDLE_QUIET_MS,
253
254
  kickoffQuietMs = KICKOFF_QUIET_MS,
254
255
  maxAutoTurns = MAX_AUTO_TURNS,
@@ -444,7 +445,7 @@ export const createSessionGoalRuntime = ({
444
445
  };
445
446
 
446
447
  const tick = async (sessionId, directory) => {
447
- if (!isSessionGoalEnabled()) return;
448
+ if (!isEnabled()) return;
448
449
 
449
450
  const session = await openCodeFetch(`/session/${encodeURIComponent(sessionId)}`, { directory })
450
451
  .catch((error) => {
@@ -35,13 +35,14 @@ const startIdleTick = async (fetchImpl) => {
35
35
  buildOpenCodeUrl: (pathname) => `http://opencode.test${pathname}`,
36
36
  getOpenCodeAuthHeaders: () => ({}),
37
37
  getSmallModelService,
38
+ isEnabled: () => true,
38
39
  idleQuietMs: 10,
39
40
  });
40
41
  runtime.processPayload({
41
42
  type: 'session.status',
42
43
  properties: { sessionID: SESSION_ID, status: { type: 'idle' }, directory: DIRECTORY },
43
44
  });
44
- await vi.advanceTimersByTimeAsync(10);
45
+ await vi.runOnlyPendingTimersAsync();
45
46
  return { runtime, getSmallModelService };
46
47
  };
47
48
 
@@ -156,6 +157,7 @@ describe('session goal live activity gate', () => {
156
157
  buildOpenCodeUrl: (pathname) => `http://opencode.test${pathname}`,
157
158
  getOpenCodeAuthHeaders: () => ({}),
158
159
  getSmallModelService: async () => service,
160
+ isEnabled: () => true,
159
161
  idleQuietMs: 10,
160
162
  });
161
163
 
@@ -163,7 +165,7 @@ describe('session goal live activity gate', () => {
163
165
  type: 'session.status',
164
166
  properties: { sessionID: SESSION_ID, status: { type: 'idle' }, directory: DIRECTORY },
165
167
  });
166
- await vi.advanceTimersByTimeAsync(10);
168
+ await vi.runOnlyPendingTimersAsync();
167
169
 
168
170
  expect(service.generateSmallModelText).toHaveBeenCalledOnce();
169
171
  const patch = requests.find((request) => request.pathname === `/session/${SESSION_ID}` && request.method === 'PATCH');
@@ -24,6 +24,8 @@ attached to that session. Pins never come from project-wide note or plan state.
24
24
  A new-session draft passes its pins into this metadata when its first message
25
25
  creates the session.
26
26
 
27
+ Directories beneath the managed `~/.config/openchamber/chats` root resolve to that root before project context and project memory are read. Every ordinary chat therefore shares one Chats knowledge owner instead of creating an unreachable context store for each dated session directory.
28
+
27
29
  `session.metadata.openchamber.knowledge_context_delivered` holds the signature
28
30
  of what the session is carrying. It lives with the session, so it survives the
29
31
  tab closing and is visible to every sender, including the ones with no tab.
@@ -1,21 +1,17 @@
1
1
  # Skills Catalog Module Documentation
2
2
 
3
3
  ## Purpose
4
- This module provides skill discovery, scanning, and installation capabilities for OpenCode. It supports multiple skill sources including git repositories and the ClawHub registry, with caching and conflict resolution for skill installation.
4
+ This module provides skill discovery, scanning, and installation capabilities for OpenCode. It supports skill sources backed by git repositories, with caching and conflict resolution for skill installation.
5
5
 
6
6
  ## Entrypoints and structure
7
7
  - `packages/web/server/lib/skills-catalog/`: Skills catalog module directory containing all skill-related functionality.
8
8
  - `cache.js`: In-memory cache for scan results with TTL support.
9
- - `curated-sources.js`: Predefined skill sources (Anthropic, ClawHub).
9
+ - `curated-sources.js`: Predefined skill sources (Anthropic, OpenAI, Cursor, Matt Pocock).
10
+ - `github-meta.js`: Best-effort GitHub repository metadata (stars, last push) with in-memory TTL cache.
10
11
  - `git.js`: Git operations helpers for cloning and auth error detection.
11
12
  - `install.js`: Skills installation from git repositories.
12
13
  - `scan.js`: Skills scanning from git repositories.
13
14
  - `source.js`: Source string parsing for git repositories.
14
- - `clawdhub/`: ClawHub registry integration.
15
- - `index.js`: Public API exports for ClawHub.
16
- - `scan.js`: Scanning ClawHub registry with pagination.
17
- - `install.js`: Installation from ClawHub (ZIP download).
18
- - `api.js`: ClawHub API client with rate limiting.
19
15
 
20
16
  ## Public API
21
17
 
@@ -24,13 +20,19 @@ The following functions are exported and used by the web server:
24
20
  ### Cache (`cache.js`)
25
21
  - `getCacheKey({ normalizedRepo, subpath, identityId })`: Generate cache key for scan results.
26
22
  - `getCachedScan(key)`: Retrieve cached scan result if not expired.
27
- - `setCachedScan(key, value, ttlMs)`: Store scan result with TTL (default 30 minutes).
23
+ - `setCachedScan(key, value, ttlMs)`: Store scan result with TTL (default 3 hours).
24
+ - `scanWithCache(key, loader, { refresh })`: Run a scan loader with cache lookup, in-flight deduplication, and a global concurrency limit (2 concurrent scans); only `ok: true` results are cached.
28
25
  - `clearCache()`: Clear all cached scan results.
26
+ - Scan results persist to `skills-catalog-cache.json` in the OpenChamber data dir (debounced, atomic rename) and survive server restarts within the TTL.
29
27
 
30
28
  ### Curated Sources (`curated-sources.js`)
31
- - `getCuratedSkillsSources()`: Return list of curated skill sources (Anthropic, ClawHub).
29
+ - `getCuratedSkillsSources()`: Return list of curated skill sources (Anthropic, OpenAI, Cursor, Matt Pocock).
32
30
  - `CURATED_SKILLS_SOURCES`: Constant array of predefined sources.
33
31
 
32
+ ### GitHub Repository Metadata (`github-meta.js`)
33
+ - `fetchGitHubRepoMetas(normalizedRepos)`: Fetch `{ stars, repoUpdatedAt }` for GitHub `owner/repo` strings. Best-effort: failures resolve to `null`; in-flight requests deduplicate; results cached in memory and on disk (`skills-github-meta.json`) for three hours.
34
+ - `clearGitHubMetaCache()`: Test-only cache reset.
35
+
34
36
  ### Source Parsing (`source.js`)
35
37
  - `parseSkillRepoSource(source, { subpath })`: Parse git repository source string into structured object with SSH/HTTPS clone URLs, normalized repo, and effective subpath. Supports SSH URLs, HTTPS URLs, and shorthand `owner/repo[/subpath]` format.
36
38
 
@@ -40,20 +42,6 @@ The following functions are exported and used by the web server:
40
42
  ### Git Repository Installation (`install.js`)
41
43
  - `installSkillsFromRepository({ source, subpath, defaultSubpath, identity, scope, targetSource, workingDirectory, userSkillDir, selections, conflictPolicy, conflictDecisions })`: Install skills from git repository. Supports user/project scopes, opencode/agents targets, conflict resolution (prompt/skipAll/overwriteAll), and sparse checkout for efficiency.
42
44
 
43
- ### ClawHub Integration (`clawdhub/index.js`)
44
- - `isClawdHubSource(source)`: Check if source string refers to ClawHub.
45
- - `scanClawdHub()`: Scan entire ClawHub registry for all skills (paginated, max 20 pages).
46
- - `scanClawdHubPage({ cursor })`: Scan a single page of ClawHub results with cursor-based pagination.
47
- - `installSkillsFromClawdHub({ scope, targetSource, workingDirectory, userSkillDir, selections, conflictPolicy, conflictDecisions })`: Install skills from ClawHub by downloading ZIP files.
48
- - `fetchClawdHubSkills({ cursor })`: Fetch paginated skills list from ClawHub API.
49
- - `fetchClawdHubSkillVersion(slug, version)`: Fetch specific skill version details.
50
- - `fetchClawdHubSkillInfo(slug)`: Fetch skill metadata without version details.
51
- - `downloadClawdHubSkill(slug, version)`: Download skill package as ZIP buffer.
52
-
53
- ### ClawHub Constants (`clawdhub/index.js`)
54
- - `CLAWDHUB_SOURCE_ID`: Source identifier for curated sources.
55
- - `CLAWDHUB_SOURCE_STRING`: Source string format.
56
-
57
45
  ## Internal Helpers
58
46
 
59
47
  The following functions are internal helpers used by exported functions:
@@ -63,10 +51,10 @@ The following functions are internal helpers used by exported functions:
63
51
  - `looksLikeAuthError(message)`: Detect if error message indicates authentication failure (permission denied, publickey, etc.).
64
52
  - `assertGitAvailable()`: Check if git is available in PATH.
65
53
 
66
- ### Skill Name Validation (used in `install.js`, `scan.js`, `clawdhub/install.js`)
54
+ ### Skill Name Validation (used in `install.js`, `scan.js`)
67
55
  - `validateSkillName(skillName)`: Validate skill name against pattern `/^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$/` (1-64 chars, lowercase alphanumeric with hyphens).
68
56
 
69
- ### File System Helpers (`install.js`, `scan.js`, `clawdhub/install.js`)
57
+ ### File System Helpers (`install.js`, `scan.js`)
70
58
  - `safeRm(dir)`: Safely remove directory recursively (ignores errors).
71
59
  - `ensureDir(dirPath)`: Ensure directory exists with recursive creation.
72
60
  - `copyDirectoryNoSymlinks(srcDir, dstDir)`: Copy directory contents without symlinks, with path traversal protection.
@@ -82,10 +70,6 @@ The following functions are internal helpers used by exported functions:
82
70
  - `toFsPath(repoDir, repoRelPosixPath)`: Convert POSIX path to filesystem path.
83
71
  - `getTargetSkillDir({ scope, targetSource, workingDirectory, userSkillDir, skillName })`: Determine target installation directory based on scope (user/project), targetSource (opencode/agents), and skill name.
84
72
 
85
- ### ClawHub API Helpers (`clawdhub/api.js`)
86
- - `rateLimitedFetch(url, options)`: Fetch with rate limiting (120 req/min limit, 100ms delay between requests, exponential backoff on 429/500 errors).
87
- - `mapClawdHubItem(item)`: Transform ClawHub API response to SkillsCatalogItem format.
88
-
89
73
  ## Response Contracts
90
74
 
91
75
  ### Scan Skills Repository Response
@@ -101,12 +85,6 @@ The following functions are internal helpers used by exported functions:
101
85
  - `skipped`: Array of skipped skills with `{ skillName, reason }`.
102
86
  - `error`: Error object with `{ kind, message, conflicts? }` on failure. Kinds: `authRequired`, `networkError`, `conflicts`, `invalidSource`, `unknown`.
103
87
 
104
- ### ClawHub Scan Response
105
- - `ok`: Boolean indicating success.
106
- - `items`: Array of skill items with ClawHub-specific metadata in `clawdhub` property.
107
- - `nextCursor`: Pagination cursor for next page (only for `scanClawdHubPage`).
108
- - `error`: Error object with `{ kind, message }` on failure.
109
-
110
88
  ### Parse Source Response
111
89
  - `ok`: Boolean indicating success.
112
90
  - `host`: Git host (e.g., `github.com`, `gitlab.com`).
@@ -129,7 +107,7 @@ The following functions are internal helpers used by exported functions:
129
107
 
130
108
  ### Skill Name Validation
131
109
  - All skill names must match `/^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$/` (1-64 chars).
132
- - Skill names are derived from directory basenames for git repos and slugs for ClawHub.
110
+ - Skill names are derived from directory basenames for git repos.
133
111
  - Invalid names result in non-installable skills with appropriate warnings.
134
112
 
135
113
  ### Git Cloning Strategy
@@ -144,17 +122,12 @@ The following functions are internal helpers used by exported functions:
144
122
  - Per-skill decisions override global policy via `conflictDecisions` map.
145
123
  - Conflict response includes `{ skillName, scope, source }` for each conflict.
146
124
 
147
- ### ClawHub Integration
148
- - ClawHub API base URL: `https://clawdhub.com/api/v1`.
149
- - Pagination uses cursor-based approach with `MAX_PAGES=20` safety limit.
150
- - Rate limiting: 120 req/min with 100ms delay between requests.
151
- - Downloaded skills are extracted from ZIP files using `adm-zip`.
152
- - Always validate `SKILL.md` exists before installation.
153
-
154
125
  ### Cache Management
155
126
  - Cache keys include `normalizedRepo`, `subpath`, and `identityId` for isolation.
156
- - Default TTL is 30 minutes; can be overridden via `ttlMs` parameter.
157
- - Cache is in-memory (not persisted across restarts).
127
+ - Default TTL is 3 hours for both scan results and GitHub repository metadata.
128
+ - Scan and GitHub metadata caches persist to JSON files in the OpenChamber data dir, so app restarts and page refreshes reuse previous results instead of re-hitting GitHub.
129
+ - Scans run through a global concurrency limiter (2 at a time) with per-key in-flight deduplication.
130
+ - The refresh button passes `refresh: true` and bypasses the cache.
158
131
 
159
132
  ### Security Considerations
160
133
  - Path traversal protection in `copyDirectoryNoSymlinks`: resolves real paths and checks containment.