@aiwayds/dsh-model-sync 0.4.1 → 0.6.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.
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@aiwayds/dsh-model-sync",
3
- "version": "0.4.1",
3
+ "version": "0.6.0",
4
4
  "description": "dsh plugin: keep llm-pi-ai provider routes' model lists in step with the pi.dev gateway, written through the official settings seam",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",
8
+ "icon": "./icon.svg",
8
9
  "license": "MIT",
9
10
  "keywords": [
10
11
  "dsh",
@@ -25,21 +26,25 @@
25
26
  "files": [
26
27
  "lib",
27
28
  "cordis.patch.yml",
28
- "src"
29
+ "src",
30
+ "icon.svg",
31
+ "locale/*.json"
29
32
  ],
30
33
  "scripts": {
31
34
  "build": "tsc -p tsconfig.json",
32
35
  "check": "tsc --noEmit -p tsconfig.json",
33
36
  "pretest": "tsc -p tsconfig.json",
34
- "test": "node --test test/live-catalog.test.mjs test/diff.test.mjs test/translate.test.mjs test/writer.test.mjs test/writer-overrides.test.mjs test/remote-catalog.test.mjs test/serviceability.test.mjs test/command.test.mjs test/real-cordis.test.mjs",
37
+ "test": "node --test test/live-catalog.test.mjs test/diff.test.mjs test/translate.test.mjs test/writer.test.mjs test/writer-overrides.test.mjs test/remote-catalog.test.mjs test/provider-native.test.mjs test/serviceability.test.mjs test/command.test.mjs test/real-cordis.test.mjs test/route-credential.test.mjs",
35
38
  "smoke": "node scripts/smoke-boot.mjs"
36
39
  },
37
40
  "dependencies": {},
38
41
  "peerDependencies": {
39
42
  "@deepseek-ai/cordis": "^4.0.2",
40
- "@deepseek-ai/dsh-commands": ">=0.1.5-rc.2",
41
- "@deepseek-ai/dsh-settings": ">=0.1.5-rc.2",
42
- "@deepseek-ai/schemastery": "^3.18.2"
43
+ "@deepseek-ai/dsh-commands": ">=0.1.7-rc.1",
44
+ "@deepseek-ai/dsh-credentials": ">=0.1.7-rc.1",
45
+ "@deepseek-ai/dsh-launch-environment": ">=0.1.7-rc.1",
46
+ "@deepseek-ai/dsh-settings": ">=0.1.7-rc.1",
47
+ "@deepseek-ai/schemastery": "^3.18.4"
43
48
  },
44
49
  "peerDependenciesMeta": {
45
50
  "@deepseek-ai/cordis": {
@@ -48,6 +53,12 @@
48
53
  "@deepseek-ai/dsh-commands": {
49
54
  "optional": true
50
55
  },
56
+ "@deepseek-ai/dsh-credentials": {
57
+ "optional": true
58
+ },
59
+ "@deepseek-ai/dsh-launch-environment": {
60
+ "optional": true
61
+ },
51
62
  "@deepseek-ai/dsh-settings": {
52
63
  "optional": true
53
64
  },
@@ -58,17 +69,19 @@
58
69
  "devDependencies": {
59
70
  "@types/node": "^24.0.0",
60
71
  "@deepseek-ai/cordis": "4.0.2",
61
- "@deepseek-ai/dsh-agent": "0.1.5-rc.2",
62
- "@deepseek-ai/dsh-attachment": "0.1.5-rc.2",
63
- "@deepseek-ai/dsh-brand": "0.1.5-rc.2",
64
- "@deepseek-ai/dsh-commands": "0.1.5-rc.2",
65
- "@deepseek-ai/dsh-invariants": "0.1.5-rc.2",
66
- "@deepseek-ai/dsh-llm": "0.1.5-rc.2",
67
- "@deepseek-ai/dsh-scope": "0.1.5-rc.2",
68
- "@deepseek-ai/dsh-session": "0.1.5-rc.2",
69
- "@deepseek-ai/dsh-settings": "0.1.5-rc.2",
70
- "@deepseek-ai/dsh-typert-protocol": "0.1.5-rc.2",
71
- "@deepseek-ai/schemastery": "3.18.2",
72
+ "@deepseek-ai/dsh-agent": "0.1.7-rc.1",
73
+ "@deepseek-ai/dsh-attachment": "0.1.7-rc.1",
74
+ "@deepseek-ai/dsh-brand": "0.1.7-rc.1",
75
+ "@deepseek-ai/dsh-commands": "0.1.7-rc.1",
76
+ "@deepseek-ai/dsh-credentials": "0.1.7-rc.1",
77
+ "@deepseek-ai/dsh-invariants": "0.1.7-rc.1",
78
+ "@deepseek-ai/dsh-launch-environment": "0.1.7-rc.1",
79
+ "@deepseek-ai/dsh-llm": "0.1.7-rc.1",
80
+ "@deepseek-ai/dsh-scope": "0.1.7-rc.1",
81
+ "@deepseek-ai/dsh-session": "0.1.7-rc.1",
82
+ "@deepseek-ai/dsh-settings": "0.1.7-rc.1",
83
+ "@deepseek-ai/dsh-typert-protocol": "0.1.7-rc.1",
84
+ "@deepseek-ai/schemastery": "3.18.4",
72
85
  "typescript": "^5.9.0"
73
86
  },
74
87
  "dsh": {
@@ -82,8 +95,8 @@
82
95
  },
83
96
  "pnpm": {
84
97
  "overrides": {
85
- "@deepseek-ai/dsh-system-prompt": "0.1.5-rc.2",
86
- "@deepseek-ai/dsh-session-projection": "0.1.5-rc.2"
98
+ "@deepseek-ai/dsh-system-prompt": "0.1.7-rc.1",
99
+ "@deepseek-ai/dsh-session-projection": "0.1.7-rc.1"
87
100
  }
88
101
  }
89
102
  }
@@ -9,6 +9,15 @@
9
9
  *
10
10
  * To regenerate: run `node scripts/generate-builtin-snapshot.mjs --generate`
11
11
  *
12
+ * Entries marked `deprecated: true` are ids the official default model list
13
+ * dropped (dsh 0.1.7-rc.1 removed deepseek-v4-flash /
14
+ * deepseek-v4-flash-vision-exp; DeepSeek renamed deepseek-v4-flash →
15
+ * deepseek-flash on its own listing). The data is retained for historical
16
+ * user configurations: keepBuiltinOnly emission skips deprecated ids
17
+ * unless keepDeprecatedBuiltin opts back in. Marks and entries survive
18
+ * regeneration — this script re-adds them even when the installed catalog
19
+ * no longer lists the id.
20
+ *
12
21
  * @module dsh-model-sync/builtin-catalog-snapshot
13
22
  */
14
23
 
@@ -27,8 +36,8 @@ export const BUILTIN_CATALOG_SNAPSHOT: BuiltinCatalogSnapshotMap = {
27
36
  { id: 'MiniMax-M3', api: 'anthropic-messages', maxTokens: 512000 }
28
37
  ],
29
38
  'opencode-go': [
30
- { id: 'deepseek-v4-flash', api: 'openai-completions', maxTokens: 384000 },
31
- { id: 'deepseek-v4-flash-vision-exp', api: 'openai-completions', maxTokens: 384000 },
39
+ { id: 'deepseek-v4-flash', api: 'openai-completions', maxTokens: 384000, deprecated: true },
40
+ { id: 'deepseek-v4-flash-vision-exp', api: 'openai-completions', maxTokens: 384000, deprecated: true },
32
41
  { id: 'deepseek-v4-pro', api: 'openai-completions', maxTokens: 384000 },
33
42
  { id: 'glm-5.1', api: 'openai-completions', maxTokens: 32768 },
34
43
  { id: 'glm-5.2', api: 'openai-completions', maxTokens: 131072 },
package/src/index.ts CHANGED
@@ -6,7 +6,8 @@
6
6
  *
7
7
  * Supports two write modes:
8
8
  * - 'settings' (default): self-contained fetch → translate → settings.mutate
9
- * pipeline that writes directly to settings.yaml (zero patch required)
9
+ * pipeline that writes through the host settings service (zero patch
10
+ * required; settings.yaml up to dsh 0.1.6, the profile patch on 0.1.7+)
10
11
  * - 'overlay' (legacy): uses the patched dsh-llm-pi-ai's piAiCatalog.refresh()
11
12
  * to overlay pi.dev entries in memory (requires patch)
12
13
  *
@@ -35,6 +36,7 @@ import {
35
36
  type SettingsModelProfile,
36
37
  type TranslateOptions,
37
38
  type DropWarning,
39
+ type BuiltinModelData,
38
40
  } from './translate.ts'
39
41
  import {
40
42
  syncToSettings,
@@ -44,60 +46,103 @@ import {
44
46
  } from './writer.ts'
45
47
  import { BUILTIN_CATALOG_SNAPSHOT } from './builtin-catalog-snapshot.ts'
46
48
  import { refreshLiveCatalog, getLiveBuiltinCatalogForRoute } from './live-catalog.ts'
49
+ import { checkRouteCredential, type RouteCredentialContext } from './route-credential.ts'
50
+ import {
51
+ PROVIDER_NATIVE_ENDPOINTS,
52
+ fetchProviderNativeModels,
53
+ mergeProviderNativeEntries,
54
+ resolveRouteCredentialValue,
55
+ type NativeCredentialContext,
56
+ } from './provider-native.ts'
47
57
 
48
58
  export const name = 'dsh-model-sync'
49
59
 
50
60
  /** The settings seam this plugin consumes (its own config namespace). */
51
61
  export const inject = ['settings']
52
62
 
53
- // dsh-settings 0.1.2-alpha.3 removed the runtime settingsNamespace() helper:
54
- // register() now brand-checks the namespace at the type level
55
- // (SettingsNamespaceInput) and validates the same pattern at runtime. A plain
56
- // literal is the supported spelling.
57
- const OWN_NS = 'model-sync'
63
+ // dsh-settings 0.1.7 rewrote the seam: the runtime register(ns, schema) call
64
+ // is gone, and a plugin's settings form is projected from its exported
65
+ // `Config` schema — the namespace IS the profile entry id. The bundle patch
66
+ // mounts this plugin under the stable id below, so `dsh-model-sync` is the
67
+ // namespace the settings UI (and the legacy settings.yaml import) address.
68
+ const OWN_ENTRY_ID = 'dsh-model-sync'
58
69
 
59
- /** The `model-sync` settings namespace: user-editable in settings.yaml. */
60
- const ModelSyncConfig = z.object({
70
+ /**
71
+ * The plugin's `Config` schema: the settings form the 0.1.7 host projects from
72
+ * the `dsh-model-sync` entry. Every field is user-adjustable and therefore
73
+ * `.volatile()` — volatile fields are the only ones the settings page can edit
74
+ * (and the only ones the legacy settings.yaml import accepts), and they hot-
75
+ * reload without remounting the plugin. Requires schemastery >= 3.18.4 (the
76
+ * version the dsh 0.1.7 wave ships), which provides `.volatile()`.
77
+ */
78
+ export const Config = z.object({
61
79
  /**
62
80
  * Write mode: 'settings' (default, zero-patch settings.mutate pipeline) or
63
81
  * 'overlay' (legacy, delegates to the patched adapter's piAiCatalog.refresh
64
82
  * and requires the optional patch).
65
83
  */
66
- writeMode: z.union(['settings', 'overlay']).default('settings'),
84
+ writeMode: z.union(['settings', 'overlay']).default('settings').volatile(),
67
85
  /** Minutes between auto refreshes (default 240 = 4 hours); 0 = startup-only. */
68
- intervalMinutes: z.number().step(1).min(0).default(240),
86
+ intervalMinutes: z.number().step(1).min(0).default(240).volatile(),
69
87
  /** Delay before the first auto refresh, so the llm adapter is ready. */
70
- startupDelaySeconds: z.number().step(1).min(0).default(5),
88
+ startupDelaySeconds: z.number().step(1).min(0).default(5).volatile(),
71
89
  /** Abort budget for one forced refresh's network round. */
72
- refreshTimeoutMs: z.number().step(1).min(1000).default(120000),
90
+ refreshTimeoutMs: z.number().step(1).min(1000).default(120000).volatile(),
73
91
  /** Routes to manage (empty = all pi.dev routes). */
74
- managedRoutes: z.array(z.string()).default([]),
92
+ managedRoutes: z.array(z.string()).default([]).volatile(),
75
93
  /** Keep builtin-only models not in pi.dev (smooth migration). */
76
- keepBuiltinOnly: z.boolean().default(true),
94
+ keepBuiltinOnly: z.boolean().default(true).volatile(),
77
95
  /** Drop unserviceable entries (true) or abort the entire route (false). */
78
- dropUnserviceable: z.boolean().default(true),
96
+ dropUnserviceable: z.boolean().default(true).volatile(),
97
+ /**
98
+ * Union each mapped route's first-party /models listing into the pi.dev
99
+ * result (additions only — see provider-native.ts). Default on: the native
100
+ * listing is the fresher source; pi.dev lags (measured 2026-09-22).
101
+ */
102
+ providerNativeFetch: z.boolean().default(true).volatile(),
79
103
  /** Notify on changes (logger + /model-sync report). */
80
- syncNotify: z.boolean().default(false),
104
+ syncNotify: z.boolean().default(false).volatile(),
81
105
  /**
82
106
  * Force all models with a non-empty thinkingFormat to have max reasoning
83
107
  * effort. Skips S2 gate's SRE check, ensures reasoningEfforts contains
84
108
  * max, and forces compat.supportsReasoningEffort=true (S5 gate, openai-
85
109
  * completions only). 400 risk is on the user.
86
110
  */
87
- forceMaxReasoningEffort: z.boolean().default(false),
111
+ forceMaxReasoningEffort: z.boolean().default(false).volatile(),
112
+ /**
113
+ * keepBuiltinOnly may re-emit builtin ids the official default model list
114
+ * dropped (dsh 0.1.7 removed deepseek-v4-flash / deepseek-v4-flash-vision-
115
+ * exp). Those stay in the snapshot for historical user configurations but
116
+ * are excluded from the synced list unless this flag opts them back in —
117
+ * a re-emitted retired id is a model the 0.1.7 host no longer resolves.
118
+ */
119
+ keepDeprecatedBuiltin: z.boolean().default(false).volatile(),
88
120
  })
89
121
 
90
- /** Typed view of the resolved `model-sync` namespace value. */
122
+ /**
123
+ * A stable configuration reference — the protocol the 0.1.7 host hands the
124
+ * plugin for every volatile `Config` field (cosmokit's `Volatile<T>`, declared
125
+ * locally as a structural type so this module stays dependency-free). `get()`
126
+ * returns the current immutable snapshot; the host swaps the value in place on
127
+ * volatile-only edits, so reading per round is always fresh.
128
+ */
129
+ interface VolatileRef<T> {
130
+ get(): T
131
+ }
132
+
133
+ /** Typed view of the resolved `Config` value as delivered to apply(). */
91
134
  interface ModelSyncConfigValue {
92
- writeMode: 'overlay' | 'settings'
93
- intervalMinutes: number
94
- startupDelaySeconds: number
95
- refreshTimeoutMs: number
96
- managedRoutes: string[]
97
- keepBuiltinOnly: boolean
98
- dropUnserviceable: boolean
99
- syncNotify: boolean
100
- forceMaxReasoningEffort: boolean
135
+ writeMode: VolatileRef<'settings' | 'overlay'>
136
+ intervalMinutes: VolatileRef<number>
137
+ startupDelaySeconds: VolatileRef<number>
138
+ refreshTimeoutMs: VolatileRef<number>
139
+ managedRoutes: VolatileRef<readonly string[]>
140
+ keepBuiltinOnly: VolatileRef<boolean>
141
+ dropUnserviceable: VolatileRef<boolean>
142
+ syncNotify: VolatileRef<boolean>
143
+ forceMaxReasoningEffort: VolatileRef<boolean>
144
+ providerNativeFetch: VolatileRef<boolean>
145
+ keepDeprecatedBuiltin: VolatileRef<boolean>
101
146
  }
102
147
 
103
148
  /** The llm seam as this plugin needs it (overlay mode). */
@@ -132,8 +177,17 @@ const DEFAULT_ROUTES = [
132
177
  'xiaomi-token-plan-cn',
133
178
  ]
134
179
 
135
- export function apply(ctx: Context): void {
136
- const scope = ctx.settings.register(OWN_NS, ModelSyncConfig)
180
+ /** Default route list — exported for tests that need to iterate the same set
181
+ * the plugin syncs when `managedRoutes` is empty. Not part of the public
182
+ * runtime surface; subject to change without notice. */
183
+ export const DEFAULT_ROUTES_LIST = DEFAULT_ROUTES
184
+
185
+ export function apply(ctx: Context, config: ModelSyncConfigValue): void {
186
+ // On dsh 0.1.7 the resolved Config arrives as apply()'s second argument:
187
+ // every volatile field is a stable reference (see VolatileRef), so the
188
+ // reads below are live views — no scope.get() and no scope.watch() (both
189
+ // removed from dsh-settings; the hot-reload notification moved to the
190
+ // settings/document-updated event, subscribed at the bottom of apply()).
137
191
 
138
192
  // -----------------------------------------------------------------------
139
193
  // Overlay mode sync (existing behavior)
@@ -174,7 +228,7 @@ export function apply(ctx: Context): void {
174
228
  const before = await list()
175
229
  const errors = await catalog.refresh({
176
230
  force,
177
- signal: AbortSignal.timeout(config.refreshTimeoutMs),
231
+ signal: AbortSignal.timeout(config.refreshTimeoutMs.get()),
178
232
  })
179
233
  const after = await list()
180
234
 
@@ -213,13 +267,29 @@ export function apply(ctx: Context): void {
213
267
  const lines: string[] = []
214
268
 
215
269
  // Determine routes to sync
216
- const routes = config.managedRoutes.length > 0
217
- ? config.managedRoutes
270
+ const managedRoutes = config.managedRoutes.get()
271
+ const routes = managedRoutes.length > 0
272
+ ? [...managedRoutes]
218
273
  : DEFAULT_ROUTES
219
274
 
275
+ const gateDesc = settings?.describe().find((d) => d.ns === 'llm-pi-ai')
276
+ const gateCtx = ctx as RouteCredentialContext
220
277
  for (const route of routes) {
278
+ // Layer 1 follows llm-pi-ai's resolveApiKey: prefer the credentials seam.
279
+ // Layer 2 follows its authContextFrom(ctx).env(): launch environment,
280
+ // or process.env when the service is absent. Both miss → skip fetch,
281
+ // translate and settings.mutate, naming the missing ref in the report.
282
+ // deriveKeyRef replicates the web UI's conventional reference name.
283
+ // Known gap: after credential removal, a same-name shell export allows
284
+ // writes, but requests with the seam present still get MISSING_CREDENTIAL.
285
+ const gate = await checkRouteCredential(gateCtx, gateDesc, route)
286
+ if (!gate.ok) {
287
+ lines.push(`${route}: skipped — credential ${gate.ref} not configured`)
288
+ continue
289
+ }
290
+
221
291
  // Fetch from pi.dev — pass force to bypass revalidation throttle (I-5)
222
- const result = await fetchRemoteCatalog(route, config.refreshTimeoutMs, store, { force })
292
+ const result = await fetchRemoteCatalog(route, config.refreshTimeoutMs.get(), store, { force })
223
293
 
224
294
  if (result.error !== undefined && result.entries.length === 0) {
225
295
  lines.push(`${route}: fetch failed (${result.error}); keeping last-good`)
@@ -233,10 +303,10 @@ export function apply(ctx: Context): void {
233
303
 
234
304
  // Translate
235
305
  const translateOpts: TranslateOptions = {
236
- keepBuiltinOnly: config.keepBuiltinOnly,
237
- dropUnserviceable: config.dropUnserviceable,
306
+ keepBuiltinOnly: config.keepBuiltinOnly.get(),
307
+ dropUnserviceable: config.dropUnserviceable.get(),
238
308
  dropWarnings: [],
239
- forceMaxReasoningEffort: config.forceMaxReasoningEffort,
309
+ forceMaxReasoningEffort: config.forceMaxReasoningEffort.get(),
240
310
  }
241
311
 
242
312
  // For builtin catalog snapshot: we use a mock for now since we can't
@@ -244,13 +314,55 @@ export function apply(ctx: Context): void {
244
314
  // base-matching classification. In a real deployment, this would come
245
315
  // from the built-in snapshot file.
246
316
  const builtinData = getBuiltinCatalogForRoute(route)
317
+
318
+ // Provider-native union: fold the route's first-party /models listing
319
+ // (the fresher source — pi.dev lags; measured 2026-09-22) into the
320
+ // pi.dev result. Additions only, capacities only where the listing
321
+ // states them; any failure degrades to the pi.dev list unchanged so a
322
+ // native hiccup can never lose models.
323
+ let entries = result.entries
324
+ if (config.providerNativeFetch.get() && PROVIDER_NATIVE_ENDPOINTS[route] !== undefined) {
325
+ const apiKey = await resolveRouteCredentialValue(
326
+ ctx as unknown as NativeCredentialContext,
327
+ gateDesc,
328
+ route,
329
+ )
330
+ if (apiKey === undefined) {
331
+ lines.push(`${route}: provider-native skipped — credential value unavailable`)
332
+ } else {
333
+ const native = await fetchProviderNativeModels(route, apiKey, config.refreshTimeoutMs.get())
334
+ if (native.ok) {
335
+ // Base-less synthesis needs the route's one addressable api;
336
+ // unknown or mixed-protocol routes skip synthesis wholesale.
337
+ const routeApis = [...new Set(builtinData.map((b) => b.api))]
338
+ const merged = mergeProviderNativeEntries(
339
+ entries,
340
+ native,
341
+ route,
342
+ routeApis.length === 1 ? routeApis[0] : undefined,
343
+ )
344
+ entries = merged.entries
345
+ if (merged.addedIds.length > 0) {
346
+ lines.push(
347
+ `${route}: provider-native added ${merged.addedIds.join(', ')} (${native.ids.length} ids from first-party listing)`,
348
+ )
349
+ }
350
+ if (merged.skippedReason !== undefined) {
351
+ lines.push(`${route}: provider-native ${merged.skippedReason}`)
352
+ }
353
+ } else {
354
+ lines.push(`${route}: provider-native ${native.error} — pi.dev list only`)
355
+ }
356
+ }
357
+ }
358
+
247
359
  const builtinIds = new Set(builtinData.map((b) => b.id))
248
- const builtinOnlyEntries = config.keepBuiltinOnly
249
- ? getBuiltinOnlyEntries(route, result.entries, builtinIds)
360
+ const builtinOnlyEntries = translateOpts.keepBuiltinOnly
361
+ ? getBuiltinOnlyEntries(route, entries, builtinData, config.keepDeprecatedBuiltin.get())
250
362
  : undefined
251
363
 
252
364
  const translated = translateEntries(
253
- result.entries,
365
+ entries,
254
366
  builtinIds,
255
367
  builtinData,
256
368
  route,
@@ -344,16 +456,19 @@ export function apply(ctx: Context): void {
344
456
  // Unified syncNow
345
457
  // -----------------------------------------------------------------------
346
458
  const syncNow = async (force: boolean): Promise<string> => {
347
- const config = scope.get() as unknown as ModelSyncConfigValue
459
+ // Read the live refs up front; the volatile snapshots are fresh per call.
460
+ const writeMode = config.writeMode.get()
461
+ const managedRoutes = config.managedRoutes.get()
462
+ const routes = managedRoutes.length > 0 ? [...managedRoutes] : DEFAULT_ROUTES
348
463
 
349
464
  // Prefer the host's live pi-ai catalog for this round; the frozen
350
465
  // snapshot is only the no-host fallback. Without this, keepBuiltinOnly
351
466
  // re-emits ids the host's catalog has already dropped. Awaiting keeps the
352
467
  // `which`/`npm` probes off the host's event loop (they used to block every
353
468
  // surface for ~0.2s per round).
354
- await refreshLiveCatalog(config.managedRoutes.length > 0 ? config.managedRoutes : DEFAULT_ROUTES)
469
+ await refreshLiveCatalog(routes)
355
470
 
356
- if (config.writeMode === 'settings') {
471
+ if (writeMode === 'settings') {
357
472
  return syncSettings(config, force)
358
473
  }
359
474
 
@@ -395,16 +510,22 @@ export function apply(ctx: Context): void {
395
510
  if (startupTimer !== undefined) clearTimeout(startupTimer)
396
511
  })
397
512
 
398
- const initial = scope.get() as unknown as ModelSyncConfigValue
399
- startupTimer = setTimeout(runAuto, Math.max(0, initial?.startupDelaySeconds ?? 5) * 1000)
400
- armInterval(initial?.intervalMinutes ?? 240)
401
- scope.watch((next) => {
402
- const value = next as unknown as ModelSyncConfigValue
403
- armInterval(value?.intervalMinutes ?? 0)
513
+ // Volatile fields are stable references, so the initial arms read them once
514
+ // and the interval keeps working; the hot-reload notification arrives as a
515
+ // settings/document-updated event (the 0.1.7 replacement for scope.watch).
516
+ startupTimer = setTimeout(runAuto, Math.max(0, config.startupDelaySeconds.get() ?? 5) * 1000)
517
+ armInterval(config.intervalMinutes.get() ?? 240)
518
+ ctx.effect(() => ctx.on('settings/document-updated', (ns) => {
519
+ // Only this plugin's entry (the bundle-patch id) re-arms the timers; the
520
+ // handler is idempotent — the refs already carry the new values, so the
521
+ // next round reads them fresh. Never throws: an interval re-arm is two
522
+ // timer calls, and a throwing settings listener is a host-side incident.
523
+ if (ns !== OWN_ENTRY_ID) return
524
+ armInterval(config.intervalMinutes.get() ?? 0)
404
525
  // Clear any pending startup timer before setting a new one
405
526
  if (startupTimer !== undefined) clearTimeout(startupTimer)
406
527
  startupTimer = setTimeout(runAuto, 1000)
407
- })
528
+ }), 'dsh-model-sync: settings/document-updated')
408
529
 
409
530
  // The modelSync service stays exposed for UIs that want direct access. The
410
531
  // /model-sync command itself is registered by this plugin (below) through
@@ -458,7 +579,7 @@ export function apply(ctx: Context): void {
458
579
  * gets the whole llm-pi-ai namespace rejected by the alpha line's strict
459
580
  * registration.
460
581
  */
461
- function getBuiltinCatalogForRoute(route: string): Array<{ id: string; api: string; maxTokens?: number }> {
582
+ function getBuiltinCatalogForRoute(route: string): BuiltinModelData[] {
462
583
  return getLiveBuiltinCatalogForRoute(route) ?? BUILTIN_CATALOG_SNAPSHOT[route] ?? []
463
584
  }
464
585
 
@@ -466,17 +587,28 @@ function getBuiltinCatalogForRoute(route: string): Array<{ id: string; api: stri
466
587
  * Get entries from builtin catalog that are not in pi.dev (for keepBuiltinOnly).
467
588
  * Returns minimal RemoteCatalogEntry-shaped objects — translateEntries only
468
589
  * reads entry.id from these, emitting {id} profiles (I-3).
590
+ *
591
+ * Deprecated snapshot entries (the official default model list dropped them —
592
+ * dsh 0.1.7 removed deepseek-v4-flash / deepseek-v4-flash-vision-exp) are
593
+ * excluded unless `includeDeprecated` opts them back in: a re-emitted retired
594
+ * id is a model the 0.1.7 host no longer resolves. The data itself stays in
595
+ * the snapshot for historical user configurations.
596
+ *
597
+ * Exported for the test suite; not part of the public runtime surface.
469
598
  */
470
- function getBuiltinOnlyEntries(
599
+ export function getBuiltinOnlyEntries(
471
600
  route: string,
472
601
  piDevEntries: RemoteCatalogEntry[],
473
- builtinIds: Set<string>,
602
+ builtinData: BuiltinModelData[],
603
+ includeDeprecated = false,
474
604
  ): RemoteCatalogEntry[] {
475
605
  const piDevIds = new Set(piDevEntries.map((e) => e.id))
476
- const builtinData = getBuiltinCatalogForRoute(route)
477
606
 
478
607
  return builtinData
479
- .filter((b) => !piDevIds.has(b.id) && builtinIds.has(b.id))
608
+ .filter((b) =>
609
+ !piDevIds.has(b.id)
610
+ && (includeDeprecated || b.deprecated !== true)
611
+ )
480
612
  .map((b) => ({
481
613
  id: b.id,
482
614
  name: b.id,