@aiwayds/dsh-model-sync 0.2.0 → 0.2.2
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/README.md +2 -2
- package/README.zh-CN.md +2 -2
- package/lib/builtin-catalog-snapshot.js +18 -6
- package/lib/builtin-catalog-snapshot.js.map +1 -1
- package/lib/index.js +37 -6
- package/lib/index.js.map +1 -1
- package/lib/live-catalog.d.ts +15 -0
- package/lib/live-catalog.js +105 -0
- package/lib/live-catalog.js.map +1 -0
- package/lib/remote-catalog.d.ts +8 -0
- package/lib/remote-catalog.js +52 -6
- package/lib/remote-catalog.js.map +1 -1
- package/lib/writer.d.ts +65 -14
- package/lib/writer.js +186 -21
- package/lib/writer.js.map +1 -1
- package/package.json +6 -6
- package/src/builtin-catalog-snapshot.ts +18 -6
- package/src/index.ts +36 -5
- package/src/live-catalog.ts +112 -0
- package/src/remote-catalog.ts +58 -6
- package/src/writer.ts +272 -27
package/lib/writer.d.ts
CHANGED
|
@@ -1,23 +1,47 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Write translated model profiles to dsh settings via the settings.mutate API.
|
|
3
3
|
*
|
|
4
|
-
* Key behaviors (design doc §4
|
|
4
|
+
* Key behaviors (design doc §4, revised for the modelOverrides mutual
|
|
5
|
+
* exclusion, 2026-09-03):
|
|
5
6
|
* - Change-only writes: compare the merged target (target ⊕ modelOverrides)
|
|
6
7
|
* against the raw user segment (desc.user), not resolved values (which have
|
|
7
8
|
* schema defaults applied)
|
|
8
9
|
* - modelOverrides are the user's own per-model channel (think levels,
|
|
9
|
-
* narrowed context windows).
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
10
|
+
* narrowed context windows). The dsh llm-pi-ai validation refuses a route
|
|
11
|
+
* whose settings carry a models list beside non-empty modelOverrides, so a
|
|
12
|
+
* models write must clear the key in the same mutate: the overrides are
|
|
13
|
+
* folded into the written models, an `unset` op removes the key (set+unset
|
|
14
|
+
* apply atomically), and the raw overrides are staged in the models-store
|
|
15
|
+
* BEFORE the mutate (store-first). Store-first is the data-safety
|
|
16
|
+
* invariant: settings is the authoritative, lossless source in every
|
|
17
|
+
* failure window — a failed/rejected mutate leaves the key in place and
|
|
18
|
+
* the settings-wins rule (see Replay below) suppresses the staged copy,
|
|
19
|
+
* while a failed store write skips the mutate entirely ('store-unavailable',
|
|
20
|
+
* settings untouched), so the key is never unset without a stored copy.
|
|
21
|
+
* Earlier behaviors both failed:
|
|
22
|
+
* v0.1.5 unset without persisting (the next round clobbered the folded
|
|
23
|
+
* fields), v0.1.6 preserved the key forever (every mutate was rejected by
|
|
24
|
+
* the mutual-exclusion validation and nothing landed).
|
|
25
|
+
* - Replay: when settings carries no overrides but the models-store does, the
|
|
26
|
+
* stored values fold into the target with no unset op — the merged view is
|
|
27
|
+
* re-derived identically every round, so change-only detection stays
|
|
28
|
+
* stable and the customizations survive. Settings overrides win over
|
|
29
|
+
* stored ones (a re-added key is the user's latest intent).
|
|
14
30
|
* - Revision conflict retry: catch SETTINGS_CONFLICT, re-read, re-translate,
|
|
15
31
|
* re-write once
|
|
16
32
|
* - Never touches ~/.dsh/settings.yaml directly — only through settings.mutate
|
|
33
|
+
* - Store read failure: when the models-store read fails (corrupt JSON,
|
|
34
|
+
* EACCES, …) AND settings carries no overrides key, skip the round with
|
|
35
|
+
* reason 'store-unavailable' and leave settings.models untouched — the
|
|
36
|
+
* already-landed folded values are the authoritative fallback. A write
|
|
37
|
+
* triggered from a settings-side key is unaffected: settings-wins, and the
|
|
38
|
+
* atomic writeDoc replaces it on disk (heals the corruption as a side
|
|
39
|
+
* effect).
|
|
17
40
|
*
|
|
18
41
|
* @module dsh-model-sync/writer
|
|
19
42
|
*/
|
|
20
43
|
import type { SettingsModelProfile } from './translate.ts';
|
|
44
|
+
import type { ModelsStoreAccessor } from './remote-catalog.ts';
|
|
21
45
|
/**
|
|
22
46
|
* The settings seam this module needs — injected via parameter, not imported
|
|
23
47
|
* from dsh internals (design doc §4.1: "writer.ts 不能直接 import dsh 的
|
|
@@ -46,7 +70,22 @@ export interface Logger {
|
|
|
46
70
|
}
|
|
47
71
|
export interface SyncResult {
|
|
48
72
|
wrote: boolean;
|
|
49
|
-
reason: 'no-change' | 'wrote' | 'conflict-retry-ok' | 'conflict-retry-failed' | 'mutate-rejected' | 'skipped';
|
|
73
|
+
reason: 'no-change' | 'wrote' | 'conflict-retry-ok' | 'conflict-retry-failed' | 'mutate-rejected' | 'store-unavailable' | 'skipped';
|
|
74
|
+
/**
|
|
75
|
+
* Where the folded overrides came from: 'settings' = the key was present
|
|
76
|
+
* (folded + unset in the same mutate, staged in the models-store before
|
|
77
|
+
* the mutate — store-first); 'store' = replayed from the models-store (no
|
|
78
|
+
* unset). Absent when no overrides were involved at all.
|
|
79
|
+
*/
|
|
80
|
+
overridesSource?: 'settings' | 'store';
|
|
81
|
+
/**
|
|
82
|
+
* Override ids with no matching entry in the written target. 'settings'
|
|
83
|
+
* source: they were dropped from settings by the unset but are kept in the
|
|
84
|
+
* models-store verbatim (and apply again if the id shows up in a later
|
|
85
|
+
* target). 'store' source: they simply stay stored. Undefined when no
|
|
86
|
+
* overrides were involved.
|
|
87
|
+
*/
|
|
88
|
+
droppedOverrideIds?: string[];
|
|
50
89
|
}
|
|
51
90
|
/**
|
|
52
91
|
* Deep equality check for two settings model profile arrays.
|
|
@@ -56,19 +95,31 @@ export declare function profilesEqual(current: SettingsModelProfile[], target: S
|
|
|
56
95
|
/**
|
|
57
96
|
* Write translated model profiles to settings for a given route.
|
|
58
97
|
*
|
|
59
|
-
* Implements the full §4 protocol
|
|
98
|
+
* Implements the full §4 protocol (revised for the modelOverrides mutual
|
|
99
|
+
* exclusion):
|
|
60
100
|
* 1. Get revision from describe()
|
|
61
|
-
* 2.
|
|
62
|
-
*
|
|
101
|
+
* 2. Resolve the overrides to fold: the settings key when non-empty, the
|
|
102
|
+
* models-store replay otherwise; merge into the target (override wins per
|
|
103
|
+
* field)
|
|
63
104
|
* 3. Change-only write: skip when the raw user-segment models already equal
|
|
64
|
-
* the merged target
|
|
65
|
-
*
|
|
66
|
-
*
|
|
105
|
+
* the merged target — except when the settings key is present, because the
|
|
106
|
+
* models+overrides combo is refused by the llm-pi-ai validation (the
|
|
107
|
+
* set+unset must run to move the document out of the refused shape)
|
|
108
|
+
* 4. Store-first: when the settings key is present, stage the raw overrides
|
|
109
|
+
* in the models-store BEFORE the mutate; a store write failure skips the
|
|
110
|
+
* mutate entirely and reports 'store-unavailable' (settings untouched —
|
|
111
|
+
* the key is never unset without a stored copy). Then call mutate with
|
|
112
|
+
* expectedRevision: one `set` on the models path, plus an `unset` on the
|
|
113
|
+
* modelOverrides path (atomic in a single mutate).
|
|
114
|
+
* 5. On SETTINGS_CONFLICT: re-read, re-translate (caller's job), re-resolve
|
|
115
|
+
* the overrides from the fresh descriptor, stage again (store-first),
|
|
116
|
+
* re-write once
|
|
67
117
|
*
|
|
68
118
|
* @param settings The settings service (injected, not imported)
|
|
69
119
|
* @param route The provider route id
|
|
70
120
|
* @param target Translated settings-writable entries (sorted by id)
|
|
71
121
|
* @param logger Logger for warnings/errors
|
|
72
122
|
* @param retranslate Callback to re-translate on conflict (receives new revision)
|
|
123
|
+
* @param store The models-store accessor for the overrides replay/persist
|
|
73
124
|
*/
|
|
74
|
-
export declare function syncToSettings(settings: SettingsService | undefined, route: string, target: SettingsModelProfile[], logger: Logger, retranslate?: (newRevision: number) => Promise<SettingsModelProfile[]
|
|
125
|
+
export declare function syncToSettings(settings: SettingsService | undefined, route: string, target: SettingsModelProfile[], logger: Logger, retranslate?: (newRevision: number) => Promise<SettingsModelProfile[]>, store?: ModelsStoreAccessor): Promise<SyncResult>;
|
package/lib/writer.js
CHANGED
|
@@ -98,7 +98,91 @@ function mergeOverrides(target, overrides) {
|
|
|
98
98
|
const override = overrides[entry.id];
|
|
99
99
|
if (override === undefined)
|
|
100
100
|
return entry;
|
|
101
|
-
|
|
101
|
+
// Force the entry's own id back on: an override object that happens to
|
|
102
|
+
// carry an `id` field must not silently re-key the entry in the written
|
|
103
|
+
// models list.
|
|
104
|
+
return { ...entry, ...override, id: entry.id };
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Override ids that cannot fold into the target (no entry carries the id).
|
|
109
|
+
* Sorted so the report line is deterministic.
|
|
110
|
+
*/
|
|
111
|
+
function droppedOverrideIds(overrides, mergedTarget) {
|
|
112
|
+
if (overrides === undefined)
|
|
113
|
+
return undefined;
|
|
114
|
+
const targetIds = new Set(mergedTarget.map((entry) => entry.id));
|
|
115
|
+
return Object.keys(overrides).filter((id) => !targetIds.has(id)).sort();
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Resolve the overrides to fold for one route: a non-empty settings key wins
|
|
119
|
+
* (a re-added key is the user's latest intent); otherwise the models-store
|
|
120
|
+
* replay applies. An empty `{}` key counts as absent — the dsh validation
|
|
121
|
+
* only refuses non-empty overrides beside a models list, and there is nothing
|
|
122
|
+
* in it to preserve.
|
|
123
|
+
*/
|
|
124
|
+
async function resolveOverrides(desc, route, store) {
|
|
125
|
+
const raw = getRawUserModelOverrides(desc, route);
|
|
126
|
+
if (raw !== undefined && Object.keys(raw).length > 0) {
|
|
127
|
+
return { overrides: raw, source: 'settings' };
|
|
128
|
+
}
|
|
129
|
+
if (store !== undefined) {
|
|
130
|
+
// The store read may now throw on corruption / permission failures
|
|
131
|
+
// (remote-catalog readDoc propagates anything other than ENOENT). We
|
|
132
|
+
// bubble it up: with no settings overrides to fall back on, the caller
|
|
133
|
+
// must skip the round rather than fold an unreplayed target into
|
|
134
|
+
// settings and clobber the folded values. With a settings key in play
|
|
135
|
+
// (the earlier branch above) this code path is never reached, so a
|
|
136
|
+
// settings-side write always proceeds and the atomic writeDoc heals the
|
|
137
|
+
// corruption on its next write.
|
|
138
|
+
const stored = await store.read(route);
|
|
139
|
+
if (stored?.overrides !== undefined && Object.keys(stored.overrides).length > 0) {
|
|
140
|
+
return { overrides: stored.overrides, source: 'store' };
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return { overrides: undefined, source: undefined };
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Stage overrides in the models-store BEFORE the mutate that unsets them
|
|
147
|
+
* from settings (store-first). The read runs outside the store's serialized
|
|
148
|
+
* write queue — only the merged entry write goes through the queue — so the
|
|
149
|
+
* route's models/checkedAt/etag, written by the fetch earlier in this round,
|
|
150
|
+
* stay intact. While the settings key is present it always wins over the
|
|
151
|
+
* store (resolveOverrides order); the stored copy is only ever replayed
|
|
152
|
+
* once the key is gone. Callers must treat a throw from here as "skip the
|
|
153
|
+
* mutate": unsetting without a staged copy is the v0.1.5 data loss.
|
|
154
|
+
*
|
|
155
|
+
* The store read may now fail on corruption / permission errors (readDoc
|
|
156
|
+
* propagates everything except ENOENT). Swallowing it here is intentional:
|
|
157
|
+
* the settings key carries the only authoritative copy of the overrides, the
|
|
158
|
+
* atomic writeDoc below replaces the (possibly corrupt) file with a fresh
|
|
159
|
+
* entry that carries the overrides — which is what heals the store. The
|
|
160
|
+
* fetch side will re-populate models/checkedAt/etag on its next round.
|
|
161
|
+
* (A storeless call — store undefined — cannot stage anything and keeps the
|
|
162
|
+
* legacy unset-without-copy behavior; production wiring in index.ts always
|
|
163
|
+
* passes a store.)
|
|
164
|
+
*/
|
|
165
|
+
async function persistOverridesToStore(store, route, overrides) {
|
|
166
|
+
if (store === undefined)
|
|
167
|
+
return;
|
|
168
|
+
let stored;
|
|
169
|
+
try {
|
|
170
|
+
stored = await store.read(route);
|
|
171
|
+
}
|
|
172
|
+
catch (readErr) {
|
|
173
|
+
// Cache lost — fall through with no cached metadata. The atomic
|
|
174
|
+
// writeDoc below replaces the bad file with a fresh entry carrying
|
|
175
|
+
// only the overrides. The fetch side re-populates the rest on its
|
|
176
|
+
// next round. The settings key remains the authoritative source of
|
|
177
|
+
// truth in the meantime.
|
|
178
|
+
void readErr;
|
|
179
|
+
}
|
|
180
|
+
await store.write(route, {
|
|
181
|
+
models: stored?.models ?? [],
|
|
182
|
+
checkedAt: stored?.checkedAt ?? Date.now(),
|
|
183
|
+
lastModified: stored?.lastModified ?? 0,
|
|
184
|
+
etag: stored?.etag,
|
|
185
|
+
overrides,
|
|
102
186
|
});
|
|
103
187
|
}
|
|
104
188
|
// ---------------------------------------------------------------------------
|
|
@@ -107,22 +191,34 @@ function mergeOverrides(target, overrides) {
|
|
|
107
191
|
/**
|
|
108
192
|
* Write translated model profiles to settings for a given route.
|
|
109
193
|
*
|
|
110
|
-
* Implements the full §4 protocol
|
|
194
|
+
* Implements the full §4 protocol (revised for the modelOverrides mutual
|
|
195
|
+
* exclusion):
|
|
111
196
|
* 1. Get revision from describe()
|
|
112
|
-
* 2.
|
|
113
|
-
*
|
|
197
|
+
* 2. Resolve the overrides to fold: the settings key when non-empty, the
|
|
198
|
+
* models-store replay otherwise; merge into the target (override wins per
|
|
199
|
+
* field)
|
|
114
200
|
* 3. Change-only write: skip when the raw user-segment models already equal
|
|
115
|
-
* the merged target
|
|
116
|
-
*
|
|
117
|
-
*
|
|
201
|
+
* the merged target — except when the settings key is present, because the
|
|
202
|
+
* models+overrides combo is refused by the llm-pi-ai validation (the
|
|
203
|
+
* set+unset must run to move the document out of the refused shape)
|
|
204
|
+
* 4. Store-first: when the settings key is present, stage the raw overrides
|
|
205
|
+
* in the models-store BEFORE the mutate; a store write failure skips the
|
|
206
|
+
* mutate entirely and reports 'store-unavailable' (settings untouched —
|
|
207
|
+
* the key is never unset without a stored copy). Then call mutate with
|
|
208
|
+
* expectedRevision: one `set` on the models path, plus an `unset` on the
|
|
209
|
+
* modelOverrides path (atomic in a single mutate).
|
|
210
|
+
* 5. On SETTINGS_CONFLICT: re-read, re-translate (caller's job), re-resolve
|
|
211
|
+
* the overrides from the fresh descriptor, stage again (store-first),
|
|
212
|
+
* re-write once
|
|
118
213
|
*
|
|
119
214
|
* @param settings The settings service (injected, not imported)
|
|
120
215
|
* @param route The provider route id
|
|
121
216
|
* @param target Translated settings-writable entries (sorted by id)
|
|
122
217
|
* @param logger Logger for warnings/errors
|
|
123
218
|
* @param retranslate Callback to re-translate on conflict (receives new revision)
|
|
219
|
+
* @param store The models-store accessor for the overrides replay/persist
|
|
124
220
|
*/
|
|
125
|
-
export async function syncToSettings(settings, route, target, logger, retranslate) {
|
|
221
|
+
export async function syncToSettings(settings, route, target, logger, retranslate, store) {
|
|
126
222
|
if (settings === undefined) {
|
|
127
223
|
logger.debug('settings service unavailable; skip write for route %s', route);
|
|
128
224
|
return { wrote: false, reason: 'skipped' };
|
|
@@ -134,22 +230,60 @@ export async function syncToSettings(settings, route, target, logger, retranslat
|
|
|
134
230
|
return { wrote: false, reason: 'skipped' };
|
|
135
231
|
}
|
|
136
232
|
const rawModels = getRawUserModels(desc, route);
|
|
137
|
-
|
|
138
|
-
|
|
233
|
+
let effectiveOverrides;
|
|
234
|
+
let overridesSource;
|
|
235
|
+
try {
|
|
236
|
+
({ overrides: effectiveOverrides, source: overridesSource } =
|
|
237
|
+
await resolveOverrides(desc, route, store));
|
|
238
|
+
}
|
|
239
|
+
catch (readErr) {
|
|
240
|
+
// The store is unreadable (corrupted JSON, EACCES, …) and settings
|
|
241
|
+
// carries no overrides key — there is no authoritative source for the
|
|
242
|
+
// user's folded values other than the existing settings.models. Skip
|
|
243
|
+
// the round with reason 'store-unavailable': writing the raw pi.dev
|
|
244
|
+
// target now would overwrite settings.models with unreplayed values
|
|
245
|
+
// and silently clobber the user's fold (the same data-loss shape
|
|
246
|
+
// v0.1.5 hit, just via a different path). The next refresh attempts
|
|
247
|
+
// the same round again; a manual re-add of the key (or a fresh
|
|
248
|
+
// successful settings-side write that heals the file) unblocks it.
|
|
249
|
+
logger.warn('models-store read failed for route %s: %s', route, readErr instanceof Error ? readErr.message : String(readErr));
|
|
250
|
+
return { wrote: false, reason: 'store-unavailable' };
|
|
251
|
+
}
|
|
252
|
+
const hasSettingsOverrides = overridesSource === 'settings';
|
|
253
|
+
const mergedTarget = mergeOverrides(target, effectiveOverrides);
|
|
139
254
|
// Change-only write (§4.4): skip when the stored models already reflect
|
|
140
|
-
// target ⊕ overrides.
|
|
141
|
-
//
|
|
142
|
-
//
|
|
143
|
-
if (rawModels !== undefined && profilesEqual(rawModels, mergedTarget)) {
|
|
255
|
+
// target ⊕ overrides. Skipped when the settings key is present — the unset
|
|
256
|
+
// must run in this mutate to clear the refused models+overrides combo, and
|
|
257
|
+
// after it lands the replay keeps later rounds change-only.
|
|
258
|
+
if (!hasSettingsOverrides && rawModels !== undefined && profilesEqual(rawModels, mergedTarget)) {
|
|
144
259
|
logger.debug('no change for route %s; skip write', route);
|
|
145
260
|
return { wrote: false, reason: 'no-change' };
|
|
146
261
|
}
|
|
262
|
+
const dropped = droppedOverrideIds(effectiveOverrides, mergedTarget);
|
|
147
263
|
const ops = [
|
|
148
264
|
{ op: 'set', path: ['providers', route, 'models'], value: mergedTarget },
|
|
149
265
|
];
|
|
266
|
+
if (hasSettingsOverrides) {
|
|
267
|
+
ops.push({ op: 'unset', path: ['providers', route, 'modelOverrides'] });
|
|
268
|
+
}
|
|
269
|
+
// Store-first: stage the raw overrides in the models-store BEFORE the
|
|
270
|
+
// mutate that unsets them from settings. A store write failure must skip
|
|
271
|
+
// the mutate entirely — unsetting without a staged copy is the v0.1.5
|
|
272
|
+
// data loss — and settings stays untouched, so it remains the
|
|
273
|
+
// authoritative source. Reported honestly as 'store-unavailable': the
|
|
274
|
+
// mutate never ran, so 'mutate-rejected' would be a lie.
|
|
275
|
+
if (hasSettingsOverrides && effectiveOverrides !== undefined) {
|
|
276
|
+
try {
|
|
277
|
+
await persistOverridesToStore(store, route, effectiveOverrides);
|
|
278
|
+
}
|
|
279
|
+
catch (persistErr) {
|
|
280
|
+
logger.warn('models-store persist failed for route %s: %s', route, persistErr instanceof Error ? persistErr.message : String(persistErr));
|
|
281
|
+
return { wrote: false, reason: 'store-unavailable' };
|
|
282
|
+
}
|
|
283
|
+
}
|
|
150
284
|
try {
|
|
151
285
|
await settings.mutate('llm-pi-ai', ops, desc.revision);
|
|
152
|
-
return { wrote: true, reason: 'wrote' };
|
|
286
|
+
return { wrote: true, reason: 'wrote', overridesSource, droppedOverrideIds: dropped };
|
|
153
287
|
}
|
|
154
288
|
catch (err) {
|
|
155
289
|
// Check for SETTINGS_CONFLICT
|
|
@@ -172,15 +306,46 @@ export async function syncToSettings(settings, route, target, logger, retranslat
|
|
|
172
306
|
return { wrote: false, reason: 'conflict-retry-failed' };
|
|
173
307
|
}
|
|
174
308
|
const newTarget = await retranslate(newDesc.revision);
|
|
309
|
+
let retry;
|
|
310
|
+
try {
|
|
311
|
+
retry = await resolveOverrides(newDesc, route, store);
|
|
312
|
+
}
|
|
313
|
+
catch (readErr) {
|
|
314
|
+
// Same fail-closed contract as the main path: with the settings key
|
|
315
|
+
// gone between the two attempts, the store replay is the only way
|
|
316
|
+
// to recover the fold; an unreadable store leaves the user values
|
|
317
|
+
// stranded in settings.models. Skip the retry, report honestly.
|
|
318
|
+
logger.warn('models-store read failed for route %s on retry: %s', route, readErr instanceof Error ? readErr.message : String(readErr));
|
|
319
|
+
return { wrote: false, reason: 'store-unavailable' };
|
|
320
|
+
}
|
|
321
|
+
const retryHasSettingsOverrides = retry.source === 'settings';
|
|
322
|
+
const retryMerged = mergeOverrides(newTarget, retry.overrides);
|
|
323
|
+
const retryDropped = droppedOverrideIds(retry.overrides, retryMerged);
|
|
175
324
|
const retryOps = [
|
|
176
|
-
{
|
|
177
|
-
op: 'set',
|
|
178
|
-
path: ['providers', route, 'models'],
|
|
179
|
-
value: mergeOverrides(newTarget, getRawUserModelOverrides(newDesc, route)),
|
|
180
|
-
},
|
|
325
|
+
{ op: 'set', path: ['providers', route, 'models'], value: retryMerged },
|
|
181
326
|
];
|
|
327
|
+
if (retryHasSettingsOverrides) {
|
|
328
|
+
retryOps.push({ op: 'unset', path: ['providers', route, 'modelOverrides'] });
|
|
329
|
+
}
|
|
330
|
+
// Store-first again on the retry: the overrides were re-resolved from
|
|
331
|
+
// the fresh descriptor, so stage them before the retry mutate (the
|
|
332
|
+
// user may have changed or removed the key between the attempts).
|
|
333
|
+
if (retryHasSettingsOverrides && retry.overrides !== undefined) {
|
|
334
|
+
try {
|
|
335
|
+
await persistOverridesToStore(store, route, retry.overrides);
|
|
336
|
+
}
|
|
337
|
+
catch (persistErr) {
|
|
338
|
+
logger.warn('models-store persist failed for route %s: %s', route, persistErr instanceof Error ? persistErr.message : String(persistErr));
|
|
339
|
+
return { wrote: false, reason: 'store-unavailable' };
|
|
340
|
+
}
|
|
341
|
+
}
|
|
182
342
|
await settings.mutate('llm-pi-ai', retryOps, newDesc.revision);
|
|
183
|
-
return {
|
|
343
|
+
return {
|
|
344
|
+
wrote: true,
|
|
345
|
+
reason: 'conflict-retry-ok',
|
|
346
|
+
overridesSource: retry.source,
|
|
347
|
+
droppedOverrideIds: retryDropped,
|
|
348
|
+
};
|
|
184
349
|
}
|
|
185
350
|
catch (retryErr) {
|
|
186
351
|
logger.warn('conflict retry failed for route %s: %s', route, retryErr instanceof Error ? retryErr.message : String(retryErr));
|
package/lib/writer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writer.js","sourceRoot":"","sources":["../src/writer.ts"],"names":[],"mappings":"AAAA,sFAAsF;
|
|
1
|
+
{"version":3,"file":"writer.js","sourceRoot":"","sources":["../src/writer.ts"],"names":[],"mappings":"AAAA,sFAAsF;AA6GtF,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E,2DAA2D;AAC3D,MAAM,iBAAiB,GAAG,mBAAmB,CAAA;AAE7C,8EAA8E;AAC9E,kCAAkC;AAClC,8EAA8E;AAE9E;;;GAGG;AACH,MAAM,UAAU,aAAa,CAC3B,OAA+B,EAC/B,MAA8B;IAE9B,IAAI,OAAO,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM;QAAE,OAAO,KAAK,CAAA;IAClD,KAAK,IAAI,CAAC,GAAG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C,CAChE,CAAA;YACD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,uBAAuB,EAAE,CAAA;QAC1D,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiwayds/dsh-model-sync",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
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",
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
"build": "tsc -p tsconfig.json",
|
|
32
32
|
"check": "tsc --noEmit -p tsconfig.json",
|
|
33
33
|
"pretest": "tsc -p tsconfig.json",
|
|
34
|
-
"test": "node --test test/diff.test.mjs test/translate.test.mjs test/writer.test.mjs test/remote-catalog.test.mjs test/serviceability.test.mjs test/command.test.mjs test/real-cordis.test.mjs"
|
|
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"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@deepseek-ai/cordis": "^4.0.2",
|
|
39
|
-
"@deepseek-ai/dsh-commands": ">=0.1.2-alpha.
|
|
40
|
-
"@deepseek-ai/dsh-settings": ">=0.1.2-alpha.
|
|
39
|
+
"@deepseek-ai/dsh-commands": ">=0.1.2-alpha.4",
|
|
40
|
+
"@deepseek-ai/dsh-settings": ">=0.1.2-alpha.4",
|
|
41
41
|
"@deepseek-ai/schemastery": "^3.18.2"
|
|
42
42
|
},
|
|
43
43
|
"peerDependenciesMeta": {
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@types/node": "^24.0.0",
|
|
59
59
|
"@deepseek-ai/cordis": "4.0.2",
|
|
60
|
-
"@deepseek-ai/dsh-commands": "0.1.2-alpha.
|
|
61
|
-
"@deepseek-ai/dsh-settings": "0.1.2-alpha.
|
|
60
|
+
"@deepseek-ai/dsh-commands": "0.1.2-alpha.4",
|
|
61
|
+
"@deepseek-ai/dsh-settings": "0.1.2-alpha.4",
|
|
62
62
|
"@deepseek-ai/schemastery": "3.18.2",
|
|
63
63
|
"typescript": "^5.9.0"
|
|
64
64
|
},
|
|
@@ -24,37 +24,49 @@ export const BUILTIN_CATALOG_SNAPSHOT: BuiltinCatalogSnapshotMap = {
|
|
|
24
24
|
'minimax-cn': [
|
|
25
25
|
{ id: 'MiniMax-M2.7', api: 'anthropic-messages', maxTokens: 131072 },
|
|
26
26
|
{ id: 'MiniMax-M2.7-highspeed', api: 'anthropic-messages', maxTokens: 131072 },
|
|
27
|
-
{ id: 'MiniMax-M3', api: 'anthropic-messages', maxTokens:
|
|
27
|
+
{ id: 'MiniMax-M3', api: 'anthropic-messages', maxTokens: 512000 }
|
|
28
28
|
],
|
|
29
29
|
'opencode-go': [
|
|
30
30
|
{ id: 'deepseek-v4-flash', api: 'openai-completions', maxTokens: 384000 },
|
|
31
|
+
{ id: 'deepseek-v4-flash-vision-exp', api: 'openai-completions', maxTokens: 384000 },
|
|
31
32
|
{ id: 'deepseek-v4-pro', api: 'openai-completions', maxTokens: 384000 },
|
|
32
33
|
{ id: 'glm-5.1', api: 'openai-completions', maxTokens: 32768 },
|
|
33
34
|
{ id: 'glm-5.2', api: 'openai-completions', maxTokens: 131072 },
|
|
34
|
-
{ id: '
|
|
35
|
+
{ id: 'glm-5.3', api: 'openai-completions', maxTokens: 131072 },
|
|
36
|
+
{ id: 'glm-5.3-flash', api: 'openai-completions', maxTokens: 131072 },
|
|
37
|
+
{ id: 'gpt-5.6-luna', api: 'openai-responses', maxTokens: 128000 },
|
|
38
|
+
{ id: 'grok-4.6', api: 'openai-responses', maxTokens: 500000 },
|
|
35
39
|
{ id: 'hy3', api: 'openai-completions', maxTokens: 64000 },
|
|
40
|
+
{ id: 'hy4-preview', api: 'openai-completions', maxTokens: 64000 },
|
|
36
41
|
{ id: 'kimi-k2.6', api: 'openai-completions', maxTokens: 65536 },
|
|
37
42
|
{ id: 'kimi-k2.7-code', api: 'openai-completions', maxTokens: 262144 },
|
|
38
43
|
{ id: 'kimi-k3', api: 'openai-completions', maxTokens: 131072 },
|
|
44
|
+
{ id: 'longcat-2.0', api: 'openai-completions', maxTokens: 131072 },
|
|
39
45
|
{ id: 'mimo-v2.5', api: 'openai-completions', maxTokens: 128000 },
|
|
40
46
|
{ id: 'mimo-v2.5-pro', api: 'openai-completions', maxTokens: 128000 },
|
|
41
47
|
{ id: 'minimax-m2.7', api: 'openai-completions', maxTokens: 131072 },
|
|
42
48
|
{ id: 'minimax-m3', api: 'anthropic-messages', maxTokens: 131072 },
|
|
49
|
+
{ id: 'muse-spark-1.2-contributor', api: 'openai-responses', maxTokens: 131072 },
|
|
43
50
|
{ id: 'qwen3.6-plus', api: 'openai-completions', maxTokens: 65536 },
|
|
44
|
-
{ id: 'qwen3.7-max', api: '
|
|
45
|
-
{ id: 'qwen3.7-plus', api: '
|
|
51
|
+
{ id: 'qwen3.7-max', api: 'openai-completions', maxTokens: 65536 },
|
|
52
|
+
{ id: 'qwen3.7-plus', api: 'openai-completions', maxTokens: 65536 },
|
|
53
|
+
{ id: 'qwen3.8-flash', api: 'anthropic-messages', maxTokens: 131072 },
|
|
54
|
+
{ id: 'qwen3.8-max', api: 'openai-completions', maxTokens: 131072 }
|
|
46
55
|
],
|
|
47
56
|
'xiaomi-token-plan-cn': [
|
|
48
|
-
{ id: 'mimo-v2-pro', api: 'openai-completions', maxTokens: 131072 },
|
|
49
57
|
{ id: 'mimo-v2.5', api: 'openai-completions', maxTokens: 131072 },
|
|
50
58
|
{ id: 'mimo-v2.5-pro', api: 'openai-completions', maxTokens: 131072 }
|
|
51
59
|
],
|
|
52
60
|
'zai-coding-cn': [
|
|
53
|
-
{ id: 'glm-4.
|
|
61
|
+
{ id: 'glm-4.6v', api: 'openai-completions', maxTokens: 32768 },
|
|
54
62
|
{ id: 'glm-4.7', api: 'openai-completions', maxTokens: 131072 },
|
|
55
63
|
{ id: 'glm-5-turbo', api: 'openai-completions', maxTokens: 131072 },
|
|
56
64
|
{ id: 'glm-5.1', api: 'openai-completions', maxTokens: 131072 },
|
|
57
65
|
{ id: 'glm-5.2', api: 'openai-completions', maxTokens: 131072 },
|
|
66
|
+
{ id: 'glm-5.2-highspeed', api: 'openai-completions', maxTokens: 131072 },
|
|
67
|
+
{ id: 'glm-5.3', api: 'openai-completions', maxTokens: 131072 },
|
|
68
|
+
{ id: 'glm-5.3-flash', api: 'openai-completions', maxTokens: 131072 },
|
|
69
|
+
{ id: 'glm-5.3-highspeed', api: 'openai-completions', maxTokens: 131072 },
|
|
58
70
|
{ id: 'glm-5v-turbo', api: 'openai-completions', maxTokens: 131072 }
|
|
59
71
|
]
|
|
60
72
|
}
|
package/src/index.ts
CHANGED
|
@@ -43,6 +43,7 @@ import {
|
|
|
43
43
|
type Logger,
|
|
44
44
|
} from './writer.ts'
|
|
45
45
|
import { BUILTIN_CATALOG_SNAPSHOT } from './builtin-catalog-snapshot.ts'
|
|
46
|
+
import { refreshLiveCatalog, getLiveBuiltinCatalogForRoute } from './live-catalog.ts'
|
|
46
47
|
|
|
47
48
|
export const name = 'dsh-model-sync'
|
|
48
49
|
|
|
@@ -287,7 +288,8 @@ export function apply(ctx: Context): void {
|
|
|
287
288
|
}
|
|
288
289
|
}
|
|
289
290
|
|
|
290
|
-
// Write to settings (change-only, with conflict retry)
|
|
291
|
+
// Write to settings (change-only, with conflict retry); the store
|
|
292
|
+
// carries the modelOverrides replay/persist (mutual-exclusion fix)
|
|
291
293
|
const syncResult = await syncToSettings(
|
|
292
294
|
settings,
|
|
293
295
|
route,
|
|
@@ -300,16 +302,36 @@ export function apply(ctx: Context): void {
|
|
|
300
302
|
void newRevision // revision is used by the caller
|
|
301
303
|
return translated.entries
|
|
302
304
|
},
|
|
305
|
+
store,
|
|
303
306
|
)
|
|
304
307
|
|
|
305
308
|
if (syncResult.wrote) {
|
|
306
|
-
|
|
309
|
+
// Detail suffix for the override flows; routes without overrides keep
|
|
310
|
+
// the classic "(wrote)" line byte-for-byte.
|
|
311
|
+
const reason = syncResult.reason === 'wrote' ? '' : `${syncResult.reason}; `
|
|
312
|
+
let detail: string | undefined
|
|
313
|
+
if (syncResult.overridesSource === 'settings') {
|
|
314
|
+
detail = `${reason}folded user modelOverrides, unset the key`
|
|
315
|
+
} else if (syncResult.overridesSource === 'store') {
|
|
316
|
+
detail = `${reason}applied stored modelOverrides`
|
|
317
|
+
}
|
|
318
|
+
if (detail !== undefined && syncResult.droppedOverrideIds !== undefined && syncResult.droppedOverrideIds.length > 0) {
|
|
319
|
+
detail += `; override ids not in target kept in models-store: ${syncResult.droppedOverrideIds.join(', ')}`
|
|
320
|
+
}
|
|
321
|
+
lines.push(detail !== undefined
|
|
322
|
+
? `${route}: wrote ${translated.entries.length} models (${detail})`
|
|
323
|
+
: `${route}: wrote ${translated.entries.length} models (${syncResult.reason})`)
|
|
307
324
|
} else if (syncResult.reason === 'no-change') {
|
|
308
325
|
lines.push(`${route}: up to date (${translated.entries.length} models)`)
|
|
309
326
|
} else if (syncResult.reason === 'skipped') {
|
|
310
327
|
lines.push(`${route}: skipped — settings service unavailable or llm-pi-ai namespace not registered`)
|
|
311
328
|
} else if (syncResult.reason === 'mutate-rejected') {
|
|
312
329
|
lines.push(`${route}: rejected by settings validation (see log)`)
|
|
330
|
+
} else if (syncResult.reason === 'store-unavailable') {
|
|
331
|
+
// The store failed (corrupt/permission on read, or filesystem on
|
|
332
|
+
// write); settings.models was the authoritative source and stays
|
|
333
|
+
// untouched either way — the user's folded values are preserved.
|
|
334
|
+
lines.push(`${route}: skipped (models-store unavailable; settings untouched)`)
|
|
313
335
|
} else {
|
|
314
336
|
lines.push(`${route}: ${syncResult.reason} (${translated.entries.length} models)`)
|
|
315
337
|
}
|
|
@@ -324,6 +346,11 @@ export function apply(ctx: Context): void {
|
|
|
324
346
|
const syncNow = async (force: boolean): Promise<string> => {
|
|
325
347
|
const config = scope.get() as unknown as ModelSyncConfigValue
|
|
326
348
|
|
|
349
|
+
// Prefer the host's live pi-ai catalog for this round; the frozen
|
|
350
|
+
// snapshot is only the no-host fallback. Without this, keepBuiltinOnly
|
|
351
|
+
// re-emits ids the host's catalog has already dropped.
|
|
352
|
+
refreshLiveCatalog(config.managedRoutes.length > 0 ? config.managedRoutes : DEFAULT_ROUTES)
|
|
353
|
+
|
|
327
354
|
if (config.writeMode === 'settings') {
|
|
328
355
|
return syncSettings(config, force)
|
|
329
356
|
}
|
|
@@ -413,11 +440,15 @@ export function apply(ctx: Context): void {
|
|
|
413
440
|
// ---------------------------------------------------------------------------
|
|
414
441
|
|
|
415
442
|
/**
|
|
416
|
-
* Get builtin catalog data for a route
|
|
417
|
-
*
|
|
443
|
+
* Get builtin catalog data for a route: the host's live pi-ai catalog when it
|
|
444
|
+
* can be located, the frozen build-time snapshot otherwise. Live-first is the
|
|
445
|
+
* point — the snapshot rots when the host's bundled pi-ai drops models
|
|
446
|
+
* (grok-4.5 was removed in pi-ai 0.84.4), and a stale keepBuiltinOnly entry
|
|
447
|
+
* gets the whole llm-pi-ai namespace rejected by the alpha line's strict
|
|
448
|
+
* registration.
|
|
418
449
|
*/
|
|
419
450
|
function getBuiltinCatalogForRoute(route: string): Array<{ id: string; api: string; maxTokens?: number }> {
|
|
420
|
-
return BUILTIN_CATALOG_SNAPSHOT[route] ?? []
|
|
451
|
+
return getLiveBuiltinCatalogForRoute(route) ?? BUILTIN_CATALOG_SNAPSHOT[route] ?? []
|
|
421
452
|
}
|
|
422
453
|
|
|
423
454
|
/**
|