@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
@@ -111,12 +111,13 @@ This module provides OpenCode server integration utilities for the web server ru
111
111
  - `markSessionUnviewed(sessionId, clientId)`
112
112
  - `markUserMessageSent(sessionId)`
113
113
  - `resetAllSessionActivityToIdle()`
114
+ - `interruptBusySessionsAfterRestart()`: settles every session whose authoritative status is `busy`/`retry` or whose activity phase is still busy, broadcasts `openchamber:session-status` idle plus an OpenCode-shaped `session.error`, resets leftover activity/cooldowns, and returns the interrupted session IDs in stable order.
114
115
  - `dispose()`
115
116
 
116
117
  The runtime maintains active-session count incrementally from idempotent activity phase transitions. Upstream stall-timeout and lifecycle health checks read it in O(1); the hourly cleanup removes activity phases older than 24 hours without broadcasting synthetic state transitions. Snapshot generation remains reserved for the session-activity API.
117
118
 
118
119
  ## Public exports (lifecycle.js)
119
- - `createOpenCodeLifecycleRuntime(dependencies)`: creates lifecycle runtime for managed/external OpenCode process orchestration. The optional `onOpenCodeRestarted` dependency (default `null`) is fired after a successful managed restart; `index.js` wires it to `messageStreamRuntime.rebindUpstream()` so event-stream readers rebind to the possibly-new port (a restart can land on a new port while an orphaned process keeps the old one, which would otherwise leave the chat UI silent — issue #2638).
120
+ - `createOpenCodeLifecycleRuntime(dependencies)`: creates lifecycle runtime for managed/external OpenCode process orchestration. The optional `onOpenCodeRestarted` dependency (default `null`) is fired after a successful managed restart. `index.js` rebinds event-stream readers to the possibly-new port (#2638), then calls `interruptBusySessionsAfterRestart()` and broadcasts one `opencode-restart-interrupted` UI notification when interrupted turns exist (#2943).
120
121
  - Returned API:
121
122
  - `startOpenCode()`
122
123
  - `restartOpenCode()`
@@ -147,6 +148,8 @@ macOS `say` voice enumeration starts concurrently with server composition. The s
147
148
 
148
149
  Transport-triggered health checks share the periodic monitor's failure accounting interval. Rapid WS reconnect callbacks therefore cannot exhaust the managed-process restart threshold using one cached unhealthy result; an exited managed process still restarts immediately.
149
150
 
151
+ Managed health failures are classified as `timeout`, `connection_refused`, `connection_reset`, `invalid_response`, or `error`. The lifecycle retains the latest counted failure with a bounded detail string and source. Managed process wrappers continue capturing a sanitized, bounded stderr tail after readiness and retain exit code/signal. Before replacing a managed process, lifecycle snapshots the reason, latest health failure, process diagnostics/aliveness, busy-session count, and timestamp into `lastOpenCodeRestartDiagnostics`; successful startup does not clear this snapshot, and `/health` exposes it for post-restart diagnosis without process environment or credentials.
152
+
150
153
  ## Public exports (env-runtime.js)
151
154
  - `createOpenCodeEnvRuntime(dependencies)`: creates runtime that owns OpenCode CLI environment and binary discovery state.
152
155
  - OpenCode CLI resolution order is persisted settings, environment overrides, bundled Desktop CLI when available, PATH, known install locations, then platform shell discovery.
@@ -204,7 +207,8 @@ Transport-triggered health checks share the periodic monitor's failure accountin
204
207
  - `readSettingsFromDiskMigrated()`
205
208
  - `writeSettingsToDisk(settings)`
206
209
  - `persistSettings(changes)`
207
- - Persistent permission auto-accept policy is stored under `permissionAutoAccept`; execution ownership lives in `lib/permission-auto-accept/`.
210
+ - Persistent permission auto-accept policy is stored under `permissionAutoAccept`; execution ownership lives in `lib/permission-auto-accept/`.
211
+ - Shared sidebar preferences are stored as validated top-level fields: `sidebarProjectDisplayMode`, `sidebarSessionGroupingMode`, `sidebarProjectSortOrder`, and `sidebarShowRecentSection`. Device-local picker selection and sticky-header state do not enter `settings.json`.
208
212
 
209
213
  ## Public exports (settings-helpers.js)
210
214
  - `createSettingsHelpers(dependencies)`: creates settings helper runtime for settings request/response shaping.
@@ -45,12 +45,11 @@ import {
45
45
  import { SKILL_DIR, SKILL_SCOPE, readSkillSupportingFile, writeSkillSupportingFile, deleteSkillSupportingFile } from './shared.js';
46
46
  import { getSkillSources, discoverSkills, mergeDiscoveredSkills, createSkill, updateSkill, deleteSkill, renameSkill, isManagedSkillPath } from './skills.js';
47
47
  import { getCuratedSkillsSources } from '../skills-catalog/curated-sources.js';
48
- import { getCacheKey, getCachedScan, setCachedScan } from '../skills-catalog/cache.js';
49
- import { isClawdHubSource, parseSkillRepoSource } from '../skills-catalog/source.js';
48
+ import { getCacheKey, scanWithCache } from '../skills-catalog/cache.js';
49
+ import { parseSkillRepoSource } from '../skills-catalog/source.js';
50
50
  import { scanSkillsRepository } from '../skills-catalog/scan.js';
51
51
  import { installSkillsFromRepository } from '../skills-catalog/install.js';
52
- import { scanClawdHubPage } from '../skills-catalog/clawdhub/scan.js';
53
- import { installSkillsFromClawdHub } from '../skills-catalog/clawdhub/install.js';
52
+ import { fetchGitHubRepoMetas } from '../skills-catalog/github-meta.js';
54
53
 
55
54
  export const createFeatureRoutesRuntime = (dependencies) => {
56
55
  const {
@@ -287,14 +286,11 @@ export const createFeatureRoutesRuntime = (dependencies) => {
287
286
  SKILL_DIR,
288
287
  getCuratedSkillsSources,
289
288
  getCacheKey,
290
- getCachedScan,
291
- setCachedScan,
289
+ scanWithCache,
292
290
  parseSkillRepoSource,
293
291
  scanSkillsRepository,
294
292
  installSkillsFromRepository,
295
- scanClawdHubPage,
296
- installSkillsFromClawdHub,
297
- isClawdHubSource,
293
+ fetchGitHubRepoMetas,
298
294
  getProfiles,
299
295
  getProfile,
300
296
  });
@@ -22,6 +22,65 @@ const OPENCODE_HEALTH_PATH = '/global/health';
22
22
  // tails are unlikely to be the user's first click and just add background work.
23
23
  const WARMUP_DIRECTORY_LIMIT = 4;
24
24
  const WARMUP_REQUEST_TIMEOUT_MS = 30000;
25
+ const MANAGED_STDERR_TAIL_MAX_BYTES = 32 * 1024;
26
+ const HEALTH_FAILURE_DETAIL_MAX_LENGTH = 256;
27
+
28
+ const getBoundedTextTail = (value, maxBytes) => {
29
+ const buffer = Buffer.from(String(value ?? ''));
30
+ if (buffer.byteLength <= maxBytes) return buffer.toString();
31
+ return buffer.subarray(buffer.byteLength - maxBytes).toString();
32
+ };
33
+
34
+ const sanitizeDiagnosticText = (value) => String(value ?? '')
35
+ .replace(/(https?:\/\/)[^/\s:@]+:[^/\s@]+@/gi, '$1[redacted]@')
36
+ .replace(/\b(Bearer)\s+[^\s,;]+/gi, '$1 [redacted]')
37
+ // Unquoted `Authorization: <scheme> <credential>` values must be handled
38
+ // before the generic key/value rule below: that rule stops at whitespace, so
39
+ // it would redact only the scheme word and leave the credential intact.
40
+ // Scoped to authorization-style keys so ordinary prose using "basic" or
41
+ // "token" is not mangled.
42
+ .replace(
43
+ /(^|[\s,{\[])((?:"|')?[a-z0-9_.-]{0,80}authorization[a-z0-9_.-]{0,80}(?:"|')?\s*[:=]\s*(?:"|')?(?:basic|bearer|token)\s+)[^\s,;"']+/gim,
44
+ '$1$2[redacted]',
45
+ )
46
+ .replace(/([?&][^=&#\s]*(?:token|api[_-]?key|password|secret|authorization|credential|private[_-]?key)[^=&#\s]*=)[^&#\s]+/gi, '$1[redacted]')
47
+ .replace(
48
+ /(^|[\s,{\[])((?:"|')?[a-z0-9_.-]{0,80}(?:token|api[_-]?key|password|secret|authorization|credential|private[_-]?key)[a-z0-9_.-]{0,80}(?:"|')?\s*[:=]\s*)("[^"]*"|'[^']*'|[^\s,;]+)/gim,
49
+ '$1$2[redacted]',
50
+ );
51
+
52
+ const getHealthFailureDetail = (error) => {
53
+ const name = String(error?.name || 'Error');
54
+ const message = String(error?.message || error || 'Unknown error');
55
+ return sanitizeDiagnosticText(`${name}: ${message}`).slice(0, HEALTH_FAILURE_DETAIL_MAX_LENGTH);
56
+ };
57
+
58
+ const classifyHealthProbeError = (error) => {
59
+ const name = String(error?.name || '');
60
+ const code = String(error?.code || '').toUpperCase();
61
+ const message = String(error?.message || error || '');
62
+ const normalizedMessage = message.toLowerCase();
63
+
64
+ if (
65
+ name === 'AbortError'
66
+ || name === 'TimeoutError'
67
+ || normalizedMessage.includes('the operation was aborted')
68
+ || normalizedMessage.includes('abortsignal.timeout')
69
+ ) {
70
+ return { class: 'timeout', detail: getHealthFailureDetail(error) };
71
+ }
72
+ if (code === 'ECONNREFUSED' || normalizedMessage.includes('econnrefused')) {
73
+ return { class: 'connection_refused', detail: getHealthFailureDetail(error) };
74
+ }
75
+ if (
76
+ code === 'ECONNRESET'
77
+ || normalizedMessage.includes('econnreset')
78
+ || normalizedMessage.includes('socket hang up')
79
+ ) {
80
+ return { class: 'connection_reset', detail: getHealthFailureDetail(error) };
81
+ }
82
+ return { class: 'error', detail: getHealthFailureDetail(error) };
83
+ };
25
84
 
26
85
  export const createOpenCodeLifecycleRuntime = (deps) => {
27
86
  const {
@@ -88,6 +147,36 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
88
147
  }
89
148
  };
90
149
 
150
+ const snapshotManagedOpenCodeProcess = (child = state.openCodeProcess) => {
151
+ if (!child) return null;
152
+ const snapshot = {
153
+ pid: child.pid || null,
154
+ exitCode: child.exitCode ?? null,
155
+ signalCode: child.signalCode ?? null,
156
+ stderrTail: getBoundedTextTail(
157
+ sanitizeDiagnosticText(child.stderrTail ?? ''),
158
+ MANAGED_STDERR_TAIL_MAX_BYTES,
159
+ ),
160
+ };
161
+ state.lastManagedOpenCodeProcess = snapshot;
162
+ return snapshot;
163
+ };
164
+
165
+ const captureRestartDiagnostics = (reason) => {
166
+ const processSnapshot = snapshotManagedOpenCodeProcess();
167
+ const diagnostics = {
168
+ reason: sanitizeDiagnosticText(String(reason || 'managed-restart')).slice(0, HEALTH_FAILURE_DETAIL_MAX_LENGTH),
169
+ healthFailure: state.lastOpenCodeHealthFailure ? { ...state.lastOpenCodeHealthFailure } : null,
170
+ process: processSnapshot
171
+ ? { ...processSnapshot, alive: isManagedOpenCodeProcessAlive() }
172
+ : null,
173
+ busySessionCount: getActiveSessionCount(),
174
+ at: new Date(now()).toISOString(),
175
+ };
176
+ state.lastOpenCodeRestartDiagnostics = diagnostics;
177
+ console.warn('[lifecycle] managed OpenCode restart diagnostics', diagnostics);
178
+ };
179
+
91
180
  const waitForChildProcessClose = (child, timeoutMs) => new Promise((resolve) => {
92
181
  if (!child || hasChildProcessExited(child)) {
93
182
  resolve(true);
@@ -297,6 +386,34 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
297
386
  windowsHide: true,
298
387
  stdio: ['ignore', 'pipe', 'pipe'],
299
388
  });
389
+ let runtimeStderrTail = '';
390
+ let runtimeStderrAttached = false;
391
+ let observedExitCode = null;
392
+ let observedSignalCode = null;
393
+
394
+ const getManagedProcessSnapshot = () => ({
395
+ pid: child.pid || null,
396
+ exitCode: observedExitCode ?? child.exitCode ?? null,
397
+ signalCode: observedSignalCode ?? child.signalCode ?? null,
398
+ stderrTail: getBoundedTextTail(sanitizeDiagnosticText(runtimeStderrTail), MANAGED_STDERR_TAIL_MAX_BYTES),
399
+ });
400
+ const recordManagedProcessExit = (code, signal) => {
401
+ if (code !== null && code !== undefined) observedExitCode = code;
402
+ if (signal !== null && signal !== undefined) observedSignalCode = signal;
403
+ state.lastManagedOpenCodeProcess = getManagedProcessSnapshot();
404
+ };
405
+ const attachRuntimeStderrCapture = () => {
406
+ if (runtimeStderrAttached) return;
407
+ runtimeStderrAttached = true;
408
+ child.stderr?.on('data', (chunk) => {
409
+ runtimeStderrTail = getBoundedTextTail(
410
+ `${runtimeStderrTail}${chunk.toString()}`,
411
+ MANAGED_STDERR_TAIL_MAX_BYTES,
412
+ );
413
+ });
414
+ };
415
+ child.on('exit', recordManagedProcessExit);
416
+ child.on('close', recordManagedProcessExit);
300
417
 
301
418
  const url = await new Promise((resolve, reject) => {
302
419
  let stdout = '';
@@ -323,6 +440,7 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
323
440
  finish(reject, new Error(`Failed to parse server url from output: ${line}`));
324
441
  return;
325
442
  }
443
+ attachRuntimeStderrCapture();
326
444
  finish(resolve, match[1]);
327
445
  return;
328
446
  }
@@ -371,10 +489,13 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
371
489
  url,
372
490
  pid: child.pid || null,
373
491
  get exitCode() {
374
- return child.exitCode;
492
+ return observedExitCode ?? child.exitCode;
375
493
  },
376
494
  get signalCode() {
377
- return child.signalCode;
495
+ return observedSignalCode ?? child.signalCode;
496
+ },
497
+ get stderrTail() {
498
+ return getManagedProcessSnapshot().stderrTail;
378
499
  },
379
500
  async close() {
380
501
  await closeManagedOpenCodeChild(child);
@@ -416,9 +537,15 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
416
537
  });
417
538
  };
418
539
 
419
- const isOpenCodeProcessHealthy = async () => {
540
+ const probeOpenCodeHealthDetailed = async () => {
420
541
  if (!state.openCodeProcess || !state.openCodePort) {
421
- return false;
542
+ return {
543
+ healthy: false,
544
+ failure: {
545
+ class: 'error',
546
+ detail: 'Managed OpenCode process or port is unavailable',
547
+ },
548
+ };
422
549
  }
423
550
 
424
551
  try {
@@ -430,14 +557,47 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
430
557
  },
431
558
  signal: AbortSignal.timeout(HEALTH_CHECK_TIMEOUT_MS),
432
559
  });
433
- if (!response.ok) return false;
434
- const body = await response.json().catch(() => null);
435
- return body?.healthy === true;
436
- } catch {
437
- return false;
560
+ if (!response.ok) {
561
+ return {
562
+ healthy: false,
563
+ failure: {
564
+ class: 'invalid_response',
565
+ detail: `Health endpoint returned HTTP ${response.status ?? 'unknown'}`,
566
+ },
567
+ };
568
+ }
569
+ let body;
570
+ try {
571
+ body = await response.json();
572
+ } catch {
573
+ return {
574
+ healthy: false,
575
+ failure: {
576
+ class: 'invalid_response',
577
+ detail: 'Health endpoint returned invalid JSON',
578
+ },
579
+ };
580
+ }
581
+ if (body?.healthy !== true) {
582
+ return {
583
+ healthy: false,
584
+ failure: {
585
+ class: 'invalid_response',
586
+ detail: 'Health endpoint did not report healthy=true',
587
+ },
588
+ };
589
+ }
590
+ return { healthy: true, failure: null };
591
+ } catch (error) {
592
+ return {
593
+ healthy: false,
594
+ failure: classifyHealthProbeError(error),
595
+ };
438
596
  }
439
597
  };
440
598
 
599
+ const isOpenCodeProcessHealthy = async () => (await probeOpenCodeHealthDetailed()).healthy;
600
+
441
601
  const probeExternalOpenCode = async (port, origin) => {
442
602
  if (!port || port <= 0) {
443
603
  return false;
@@ -617,7 +777,7 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
617
777
  throw lastError;
618
778
  };
619
779
 
620
- const restartOpenCode = async () => {
780
+ const restartOpenCode = async (reason = 'managed-restart') => {
621
781
  if (state.isShuttingDown) return;
622
782
  if (state.currentRestartPromise) {
623
783
  await state.currentRestartPromise;
@@ -655,6 +815,7 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
655
815
  return;
656
816
  }
657
817
 
818
+ captureRestartDiagnostics(reason);
658
819
  const portToKill = state.openCodePort;
659
820
 
660
821
  if (state.openCodeProcess) {
@@ -820,7 +981,7 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
820
981
  clearResolvedOpenCodeBinary();
821
982
  await applyOpencodeBinaryFromSettings();
822
983
 
823
- await restartOpenCode();
984
+ await restartOpenCode(reason || 'config-change');
824
985
 
825
986
  // A managed OpenCode process is restarted (and thus re-reads config from
826
987
  // disk) by restartOpenCode(). An external OpenCode server is NOT owned by
@@ -1010,17 +1171,17 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
1010
1171
  const probeOpenCodeHealth = async () => {
1011
1172
  const checkedAt = now();
1012
1173
  if (lastHealthProbeResult && checkedAt - lastHealthProbeResult.at < HEALTH_CHECK_RESULT_CACHE_MS) {
1013
- return lastHealthProbeResult.healthy;
1174
+ return lastHealthProbeResult;
1014
1175
  }
1015
1176
 
1016
1177
  if (healthProbePromise) {
1017
1178
  return healthProbePromise;
1018
1179
  }
1019
1180
 
1020
- healthProbePromise = isOpenCodeProcessHealthy()
1021
- .then((healthy) => {
1022
- lastHealthProbeResult = { at: now(), healthy };
1023
- return healthy;
1181
+ healthProbePromise = probeOpenCodeHealthDetailed()
1182
+ .then((result) => {
1183
+ lastHealthProbeResult = { at: now(), ...result };
1184
+ return lastHealthProbeResult;
1024
1185
  })
1025
1186
  .finally(() => {
1026
1187
  healthProbePromise = null;
@@ -1033,13 +1194,13 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
1033
1194
  const activeCount = getActiveSessionCount();
1034
1195
  if (activeCount === 0) {
1035
1196
  lastUnhealthyWithBusySessionsAt = 0;
1036
- return false;
1197
+ return { skip: false, staleBusy: false };
1037
1198
  }
1038
1199
 
1039
1200
  const checkedAt = now();
1040
1201
  if (!lastUnhealthyWithBusySessionsAt) {
1041
1202
  lastUnhealthyWithBusySessionsAt = checkedAt;
1042
- return true;
1203
+ return { skip: true, staleBusy: false };
1043
1204
  }
1044
1205
 
1045
1206
  if (checkedAt - lastUnhealthyWithBusySessionsAt >= STALE_BUSY_GRACE_MS) {
@@ -1047,10 +1208,10 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
1047
1208
  `[lifecycle] OpenCode unhealthy with ${activeCount} busy session(s) for > 2 min — forcing restart`
1048
1209
  );
1049
1210
  lastUnhealthyWithBusySessionsAt = 0;
1050
- return false;
1211
+ return { skip: false, staleBusy: true };
1051
1212
  }
1052
1213
 
1053
- return true;
1214
+ return { skip: true, staleBusy: false };
1054
1215
  };
1055
1216
 
1056
1217
  const runHealthCheckCycle = async (source) => {
@@ -1058,13 +1219,13 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
1058
1219
  if (healthCheckCyclePromise) return healthCheckCyclePromise;
1059
1220
 
1060
1221
  healthCheckCyclePromise = (async () => {
1061
- const healthy = await probeOpenCodeHealth();
1062
- if (!healthy) {
1222
+ const healthResult = await probeOpenCodeHealth();
1223
+ if (!healthResult.healthy) {
1063
1224
  if (!isManagedOpenCodeProcessAlive()) {
1064
1225
  console.log(`[lifecycle] ${source} health check: OpenCode process exited, restarting...`);
1065
1226
  consecutiveHealthFailures = 0;
1066
1227
  lastHealthProbeResult = null;
1067
- await restartOpenCode();
1228
+ await restartOpenCode(`${source}-process-exited`);
1068
1229
  return;
1069
1230
  }
1070
1231
  const checkedAt = now();
@@ -1073,15 +1234,30 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
1073
1234
  }
1074
1235
  lastCountedHealthFailureAt = checkedAt;
1075
1236
  consecutiveHealthFailures += 1;
1237
+ const healthFailure = healthResult.failure || {
1238
+ class: 'error',
1239
+ detail: 'Health check failed without diagnostic detail',
1240
+ };
1241
+ state.lastOpenCodeHealthFailure = {
1242
+ class: healthFailure.class,
1243
+ detail: healthFailure.detail,
1244
+ at: new Date(checkedAt).toISOString(),
1245
+ source,
1246
+ };
1076
1247
  console.warn(
1077
- `[lifecycle] ${source} health check failed (${consecutiveHealthFailures}/${HEALTH_CHECK_MAX_CONSECUTIVE_FAILURES})`
1248
+ `[lifecycle] ${source} health check failed (${consecutiveHealthFailures}/${HEALTH_CHECK_MAX_CONSECUTIVE_FAILURES}) class=${healthFailure.class}`
1078
1249
  );
1079
1250
  if (consecutiveHealthFailures < HEALTH_CHECK_MAX_CONSECUTIVE_FAILURES) return;
1080
- if (shouldSkipRestartForBusySessions()) return;
1251
+ const busyDecision = shouldSkipRestartForBusySessions();
1252
+ if (busyDecision.skip) return;
1081
1253
  console.log(`[lifecycle] ${source} health check failure threshold reached, restarting OpenCode...`);
1082
1254
  consecutiveHealthFailures = 0;
1083
1255
  lastHealthProbeResult = null;
1084
- await restartOpenCode();
1256
+ await restartOpenCode(
1257
+ busyDecision.staleBusy
1258
+ ? `${source}-stale-busy-health-failure`
1259
+ : `${source}-health-failure`,
1260
+ );
1085
1261
  } else {
1086
1262
  resetHealthFailureState();
1087
1263
  }
@@ -62,6 +62,9 @@ const createRuntime = (overrides = {}, stateOverrides = {}, envOverrides = {}) =
62
62
  openCodeApiPrefixDetected: false,
63
63
  openCodeApiDetectionTimer: null,
64
64
  lastOpenCodeError: null,
65
+ lastOpenCodeHealthFailure: null,
66
+ lastManagedOpenCodeProcess: null,
67
+ lastOpenCodeRestartDiagnostics: null,
65
68
  isOpenCodeReady: false,
66
69
  openCodeNotReadySince: 0,
67
70
  isExternalOpenCode: false,
@@ -75,7 +78,7 @@ const createRuntime = (overrides = {}, stateOverrides = {}, envOverrides = {}) =
75
78
  ...stateOverrides,
76
79
  };
77
80
 
78
- return createOpenCodeLifecycleRuntime({
81
+ const runtime = createOpenCodeLifecycleRuntime({
79
82
  state,
80
83
  env: {
81
84
  ENV_CONFIGURED_OPENCODE_PORT: 45678,
@@ -111,6 +114,8 @@ const createRuntime = (overrides = {}, stateOverrides = {}, envOverrides = {}) =
111
114
  })),
112
115
  ...overrides,
113
116
  });
117
+ runtime.testState = state;
118
+ return runtime;
114
119
  };
115
120
 
116
121
  describe('OpenCode lifecycle', () => {
@@ -234,6 +239,61 @@ describe('OpenCode lifecycle', () => {
234
239
  warn.mockRestore();
235
240
  });
236
241
 
242
+ it.each([
243
+ {
244
+ name: 'timeout',
245
+ expectedClass: 'timeout',
246
+ fetchResult: () => {
247
+ const error = new Error('The operation was aborted');
248
+ error.name = 'AbortError';
249
+ throw error;
250
+ },
251
+ },
252
+ {
253
+ name: 'connection refusal',
254
+ expectedClass: 'connection_refused',
255
+ fetchResult: () => {
256
+ const error = new Error('connect ECONNREFUSED 127.0.0.1:45678');
257
+ error.code = 'ECONNREFUSED';
258
+ throw error;
259
+ },
260
+ },
261
+ {
262
+ name: 'invalid JSON',
263
+ expectedClass: 'invalid_response',
264
+ fetchResult: () => ({
265
+ ok: true,
266
+ json: async () => {
267
+ throw new SyntaxError('Unexpected token');
268
+ },
269
+ }),
270
+ },
271
+ ])('classifies and stores a counted $name health failure', async ({ expectedClass, fetchResult }) => {
272
+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
273
+ globalThis.fetch = vi.fn(fetchResult);
274
+ const runtime = createRuntime({}, {
275
+ openCodePort: 45678,
276
+ openCodeProcess: {
277
+ pid: process.pid,
278
+ exitCode: null,
279
+ signalCode: null,
280
+ close: vi.fn(async () => {}),
281
+ },
282
+ isOpenCodeReady: true,
283
+ });
284
+
285
+ await runtime.triggerHealthCheck();
286
+
287
+ expect(runtime.testState.lastOpenCodeHealthFailure).toEqual({
288
+ class: expectedClass,
289
+ detail: expect.any(String),
290
+ at: expect.any(String),
291
+ source: 'immediate',
292
+ });
293
+ expect(warn).toHaveBeenCalledWith(expect.stringContaining(`class=${expectedClass}`));
294
+ warn.mockRestore();
295
+ });
296
+
237
297
  it('does not mistake a live managed process wrapper for an exited child', async () => {
238
298
  const close = vi.fn(async () => {});
239
299
  const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
@@ -320,6 +380,124 @@ describe('OpenCode lifecycle', () => {
320
380
  expect(onOpenCodeRestarted).toHaveBeenCalledTimes(1);
321
381
  });
322
382
 
383
+ it('retains post-listen stderr and exited process diagnostics across restart', async () => {
384
+ const firstChild = createMockChild();
385
+ const replacement = createMockChild();
386
+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
387
+ globalThis.fetch = vi.fn(async () => ({
388
+ ok: false,
389
+ status: 503,
390
+ json: async () => null,
391
+ }));
392
+ spawnMock.mockImplementationOnce(() => {
393
+ queueMicrotask(() => {
394
+ firstChild.stdout.emit('data', 'opencode server listening on http://127.0.0.1:45678\n');
395
+ });
396
+ return firstChild;
397
+ });
398
+ spawnMock.mockImplementationOnce(() => {
399
+ queueMicrotask(() => {
400
+ replacement.stdout.emit('data', 'opencode server listening on http://127.0.0.1:45678\n');
401
+ });
402
+ return replacement;
403
+ });
404
+ const runtime = createRuntime();
405
+ const server = await runtime.startOpenCode();
406
+ runtime.testState.openCodeProcess = server;
407
+
408
+ firstChild.stderr.emit(
409
+ 'data',
410
+ `${'x'.repeat(40 * 1024)}\ntoken=runtime-secret\nruntime worker failed after startup\n`,
411
+ );
412
+ firstChild.exitCode = 7;
413
+ firstChild.emit('exit', 7, null);
414
+
415
+ expect(server.exitCode).toBe(7);
416
+ expect(Buffer.byteLength(server.stderrTail)).toBeLessThanOrEqual(32 * 1024);
417
+ expect(server.stderrTail).not.toContain('runtime-secret');
418
+ expect(server.stderrTail).toContain('runtime worker failed after startup');
419
+
420
+ await runtime.triggerHealthCheck();
421
+
422
+ expect(runtime.testState.lastOpenCodeRestartDiagnostics).toEqual({
423
+ reason: 'immediate-process-exited',
424
+ healthFailure: null,
425
+ process: {
426
+ pid: 12345,
427
+ exitCode: 7,
428
+ signalCode: null,
429
+ stderrTail: expect.stringContaining('runtime worker failed after startup'),
430
+ alive: false,
431
+ },
432
+ busySessionCount: 0,
433
+ at: expect.any(String),
434
+ });
435
+ expect(runtime.testState.lastManagedOpenCodeProcess).toEqual({
436
+ pid: 12345,
437
+ exitCode: 7,
438
+ signalCode: null,
439
+ stderrTail: expect.stringContaining('runtime worker failed after startup'),
440
+ });
441
+
442
+ await runtime.testState.openCodeProcess.close();
443
+ warn.mockRestore();
444
+ });
445
+
446
+ it('redacts Authorization scheme credentials from stderr diagnostics', async () => {
447
+ const firstChild = createMockChild();
448
+ const replacement = createMockChild();
449
+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
450
+ globalThis.fetch = vi.fn(async () => ({
451
+ ok: false,
452
+ status: 503,
453
+ json: async () => null,
454
+ }));
455
+ spawnMock.mockImplementationOnce(() => {
456
+ queueMicrotask(() => {
457
+ firstChild.stdout.emit('data', 'opencode server listening on http://127.0.0.1:45678\n');
458
+ });
459
+ return firstChild;
460
+ });
461
+ spawnMock.mockImplementationOnce(() => {
462
+ queueMicrotask(() => {
463
+ replacement.stdout.emit('data', 'opencode server listening on http://127.0.0.1:45678\n');
464
+ });
465
+ return replacement;
466
+ });
467
+ const runtime = createRuntime();
468
+ const server = await runtime.startOpenCode();
469
+ runtime.testState.openCodeProcess = server;
470
+
471
+ firstChild.stderr.emit(
472
+ 'data',
473
+ 'request rejected: Authorization: Basic dXNlcjpwYXNz\n'
474
+ + 'authorization: basic bG93ZXI6Y2FzZQ==\n'
475
+ + 'Authorization: Bearer fake-bearer-token-value\n'
476
+ + 'falling back to basic health monitor\n'
477
+ + 'runtime worker failed after startup\n',
478
+ );
479
+ firstChild.exitCode = 7;
480
+ firstChild.emit('exit', 7, null);
481
+
482
+ expect(server.stderrTail).not.toContain('dXNlcjpwYXNz');
483
+ expect(server.stderrTail).not.toContain('bG93ZXI6Y2FzZQ');
484
+ expect(server.stderrTail).not.toContain('fake-bearer-token-value');
485
+ expect(server.stderrTail).toContain('falling back to basic health monitor');
486
+ expect(server.stderrTail).toContain('runtime worker failed after startup');
487
+
488
+ await runtime.triggerHealthCheck();
489
+
490
+ const diagnosticsTail = runtime.testState.lastOpenCodeRestartDiagnostics.process.stderrTail;
491
+ expect(diagnosticsTail).not.toContain('dXNlcjpwYXNz');
492
+ expect(diagnosticsTail).not.toContain('bG93ZXI6Y2FzZQ');
493
+ expect(diagnosticsTail).not.toContain('fake-bearer-token-value');
494
+ expect(diagnosticsTail).toContain('falling back to basic health monitor');
495
+ expect(diagnosticsTail).toContain('runtime worker failed after startup');
496
+
497
+ await runtime.testState.openCodeProcess.close();
498
+ warn.mockRestore();
499
+ });
500
+
323
501
  it('does not call onOpenCodeRestarted when a managed restart fails', async () => {
324
502
  const close = vi.fn(async () => {});
325
503
  const onOpenCodeRestarted = vi.fn();
@@ -9,6 +9,11 @@ import {
9
9
  const PROVIDER_ID_PATTERN = /^[a-z0-9][a-z0-9-_]*$/;
10
10
  const BASE_URL_PATTERN = /^https?:\/\//;
11
11
  const OPENAI_COMPATIBLE_NPM = '@ai-sdk/openai-compatible';
12
+ const CUSTOM_PROVIDER_NPM_PACKAGES = new Set([
13
+ OPENAI_COMPATIBLE_NPM,
14
+ '@ai-sdk/openai',
15
+ '@ai-sdk/anthropic',
16
+ ]);
12
17
 
13
18
  function getProviderSources(providerId, workingDirectory) {
14
19
  const layers = readConfigLayers(workingDirectory);
@@ -42,7 +47,7 @@ function getProviderSources(providerId, workingDirectory) {
42
47
  }
43
48
 
44
49
  /**
45
- * Validate a custom OpenAI-compatible provider config payload before persistence.
50
+ * Validate a custom provider config payload before persistence.
46
51
  * Returns { ok: true, value } or { ok: false, error }.
47
52
  *
48
53
  * Credentials: either config.env contains a variable name, or hasStoredAuth is true
@@ -63,8 +68,8 @@ function validateCustomProviderConfig(providerId, config, options = {}) {
63
68
  }
64
69
 
65
70
  const npm = typeof config.npm === 'string' ? config.npm.trim() : OPENAI_COMPATIBLE_NPM;
66
- if (npm !== OPENAI_COMPATIBLE_NPM) {
67
- return { ok: false, error: `Custom providers must use npm package ${OPENAI_COMPATIBLE_NPM}` };
71
+ if (!CUSTOM_PROVIDER_NPM_PACKAGES.has(npm)) {
72
+ return { ok: false, error: 'Custom providers must use @ai-sdk/openai-compatible, @ai-sdk/openai, or @ai-sdk/anthropic' };
68
73
  }
69
74
 
70
75
  const optionsBlock = isPlainObject(config.options) ? config.options : null;
@@ -102,7 +107,7 @@ function validateCustomProviderConfig(providerId, config, options = {}) {
102
107
  }
103
108
 
104
109
  const normalized = {
105
- npm: OPENAI_COMPATIBLE_NPM,
110
+ npm,
106
111
  name,
107
112
  options: {
108
113
  baseURL,