@aiwayds/dsh-tui-pi 1.0.0 → 1.0.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/lib/model-sync.js DELETED
@@ -1,256 +0,0 @@
1
- /**
2
- * /model-sync (singular) — discover models for CUSTOM provider routes and
3
- * merge them back into the llm-pi-ai settings section.
4
- *
5
- * A custom route is a hand-declared `llm-pi-ai.providers.<id>` profile that
6
- * carries a `baseURL` and is NOT one of the built-in catalog routes
7
- * (provider-catalog.ts): discovery against a catalog route would short-circuit
8
- * back to the installed pi-ai catalog. This command interrogates
9
- * each route's `GET ${baseURL}/models` through the official seam
10
- * (`LlmRuntime.discoverModels`, registered for the `llm-pi-ai` namespace by
11
- * dsh-llm-pi-ai with catalog short-circuit + stored-credential resolution),
12
- * then merges the answer into the profile's `models` array.
13
- *
14
- * The merge is additive-only: existing entries are preserved verbatim (local
15
- * overrides such as reasoningEfforts survive), discovered ids already present
16
- * are skipped, new ids are appended with sanitized metadata. The write goes
17
- * through `settings.mutate` at the revision read at execution time, with one
18
- * retry after SettingsConflictError (the persistDefaultModel pattern in
19
- * session.ts). Pure logic lives here as exported functions; src/index.ts only
20
- * wires the command.
21
- *
22
- * @module dsh-tui-pi/model-sync
23
- */
24
- import { settingsNamespace, SettingsConflictError } from '@deepseek-ai/dsh-settings';
25
- import { catalogEntry } from "./provider-catalog.js";
26
- /** The settings namespace dsh-llm-pi-ai owns its provider routes under. */
27
- const NS_LLM_PI_AI = settingsNamespace('llm-pi-ai');
28
- /**
29
- * Read the providers dict out of an llm-pi-ai descriptor value. Tolerant of
30
- * every malformed shape — a section that is not an object yields no routes.
31
- */
32
- function readProviders(value) {
33
- if (typeof value !== 'object' || value === null)
34
- return {};
35
- const providers = value.providers;
36
- if (typeof providers !== 'object' || providers === null)
37
- return {};
38
- return providers;
39
- }
40
- function readProfile(raw) {
41
- const source = typeof raw === 'object' && raw !== null ? raw : {};
42
- const baseURL = typeof source.baseURL === 'string' && source.baseURL !== '' ? source.baseURL : undefined;
43
- const api = typeof source.api === 'string' && source.api !== '' ? source.api : undefined;
44
- const rawModels = Array.isArray(source.models) ? source.models : [];
45
- // Only well-formed entries are merged against; a malformed stored row is
46
- // left alone rather than deleted (additive-only merge).
47
- const models = rawModels.filter((entry) => typeof entry === 'object' && entry !== null);
48
- return { ...(baseURL !== undefined ? { baseURL } : {}), ...(api !== undefined ? { api } : {}), models };
49
- }
50
- /** The stored entry's id, when it is a non-empty string. */
51
- function storedModelId(entry) {
52
- const id = entry.id;
53
- return typeof id === 'string' && id !== '' ? id : undefined;
54
- }
55
- /**
56
- * Select the custom (hand-declared) routes worth syncing from a providers
57
- * dict: profiles carrying a non-empty `baseURL` whose key is not a built-in
58
- * catalog route — a catalog key would short-circuit discovery back to the
59
- * installed catalog. Sorted by route key so the
60
- * report order is stable regardless of document order.
61
- */
62
- export function selectCustomProviders(providers) {
63
- const selected = [];
64
- for (const [id, raw] of Object.entries(providers ?? {})) {
65
- if (catalogEntry(id) !== undefined)
66
- continue;
67
- const profile = readProfile(raw);
68
- if (profile.baseURL === undefined)
69
- continue;
70
- selected.push({
71
- id,
72
- baseURL: profile.baseURL,
73
- ...(profile.api !== undefined ? { api: profile.api } : {}),
74
- });
75
- }
76
- selected.sort((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
77
- return selected;
78
- }
79
- /**
80
- * Clean one discovered row into a writable models entry. The id is mandatory
81
- * (blank/absent → undefined); name must be a non-blank string; capacities
82
- * must be integers ≥ 1 — the llm-pi-ai schema rejects anything else at write
83
- * time (`contextWindow >= 1`, integer step), and a field that fails stays
84
- * behind rather than sinking the whole row (verified against the shipped
85
- * schema: absent name/contextWindow/maxTokens validate fine).
86
- */
87
- export function sanitizeDiscoveredModel(raw) {
88
- if (typeof raw !== 'object' || raw === null)
89
- return undefined;
90
- const row = raw;
91
- if (typeof row.id !== 'string')
92
- return undefined;
93
- const id = row.id.trim();
94
- if (id === '')
95
- return undefined;
96
- const name = typeof row.name === 'string' && row.name.trim() !== '' ? row.name.trim() : undefined;
97
- const capacity = (value) => typeof value === 'number' && Number.isInteger(value) && value >= 1 ? value : undefined;
98
- const contextWindow = capacity(row.contextWindow);
99
- const maxTokens = capacity(row.maxTokens);
100
- return {
101
- id,
102
- ...(name !== undefined ? { name } : {}),
103
- ...(contextWindow !== undefined ? { contextWindow } : {}),
104
- ...(maxTokens !== undefined ? { maxTokens } : {}),
105
- };
106
- }
107
- /**
108
- * Merge one route's discovery into its stored models — additive-only:
109
- *
110
- * - existing entries are the base and are preserved VERBATIM (local overrides
111
- * like reasoningEfforts/input/compat survive; nothing is overwritten or
112
- * deleted);
113
- * - discovered rows join by id: an id already present (or repeated within the
114
- * batch) counts as skipped, local state wins;
115
- * - new ids are appended with `sanitizeDiscoveredModel`'s cleaned fields;
116
- * - the stored order is never touched: existing entries keep their positions
117
- * (id-less rows included) and new ids join at the end in discovery order.
118
- */
119
- export function mergeModels(existing, discovered) {
120
- const models = existing.map(entry => entry);
121
- const ids = new Set();
122
- for (const entry of models) {
123
- const id = storedModelId(entry);
124
- if (id !== undefined)
125
- ids.add(id);
126
- }
127
- let added = 0;
128
- let skipped = 0;
129
- for (const raw of discovered) {
130
- const clean = sanitizeDiscoveredModel(raw);
131
- if (clean === undefined || ids.has(clean.id)) {
132
- skipped += 1;
133
- continue;
134
- }
135
- ids.add(clean.id);
136
- // A fresh literal (not a cast): interfaces carry no implicit index
137
- // signature, so the entry must be rebuilt as a plain record.
138
- models.push({ ...clean });
139
- added += 1;
140
- }
141
- // No reordering: existing entries stay exactly where the user stored them
142
- // and new ids are appended at the end in discovery order — a no-op sync
143
- // therefore leaves the stored array byte-identical.
144
- return { models, added, kept: existing.length, skipped };
145
- }
146
- /**
147
- * Write one route's merged models with optimistic concurrency: mutate at the
148
- * revision read NOW (not at command start), one retry after
149
- * SettingsConflictError with a freshly read revision — the same bottom pattern
150
- * as persistDefaultModel in session.ts. A second conflict surfaces.
151
- */
152
- async function writeModels(settings, providerId, models) {
153
- const ops = [
154
- { op: 'set', path: ['providers', providerId, 'models'], value: models },
155
- ];
156
- const ns = NS_LLM_PI_AI;
157
- for (let attempt = 0;; attempt++) {
158
- const descriptor = currentDescriptor(settings);
159
- try {
160
- await settings.mutate(ns, ops, descriptor?.revision);
161
- return;
162
- }
163
- catch (error) {
164
- if (attempt === 0 && error instanceof SettingsConflictError)
165
- continue;
166
- throw error;
167
- }
168
- }
169
- }
170
- /** The live llm-pi-ai descriptor, re-read on demand (revision freshness). */
171
- function currentDescriptor(settings) {
172
- return settings.describe().find(d => d.ns === NS_LLM_PI_AI);
173
- }
174
- function errorText(error) {
175
- return error instanceof Error ? error.message : String(error);
176
- }
177
- /**
178
- * Run one /model-sync round: select the target routes (the rawInput-named one,
179
- * or every custom route), discover each endpoint's models, merge, and write
180
- * back. One route's failure never aborts the rest — its line reports the
181
- * reason instead. Agentless by design: nothing here touches a session.
182
- *
183
- * @returns the command result — per-provider `<id>: added N · kept M ·
184
- * skipped K` lines on success, `<id>: <reason>` for failed routes; `kind:
185
- * 'error'` only for preconditions (missing namespace, unknown/non-custom
186
- * named route) or when EVERY route failed.
187
- */
188
- export async function runModelSync(deps, options = {}) {
189
- const descriptor = currentDescriptor(deps.settings);
190
- if (descriptor === undefined) {
191
- return { kind: 'error', text: 'The llm-pi-ai settings namespace is not registered — nothing to sync.' };
192
- }
193
- const wanted = options.rawInput?.trim() ?? '';
194
- let targets;
195
- if (wanted !== '') {
196
- const providers = readProviders(descriptor.value);
197
- if (!(wanted in providers)) {
198
- return { kind: 'error', text: `Provider "${wanted}" is not configured under llm-pi-ai providers.` };
199
- }
200
- targets = selectCustomProviders({ [wanted]: providers[wanted] });
201
- if (targets.length === 0) {
202
- // Two distinct shapes land here: a built-in catalog key (excluded by
203
- // selection even when the profile carries a baseURL) and a genuinely
204
- // non-custom route without a baseURL. Name each accurately.
205
- if (catalogEntry(wanted) !== undefined) {
206
- return {
207
- kind: 'error',
208
- text: `Provider "${wanted}" is a built-in catalog route — /model-sync syncs hand-declared (baseURL) routes only.`,
209
- };
210
- }
211
- return {
212
- kind: 'error',
213
- text: `Provider "${wanted}" has no baseURL — /model-sync syncs hand-declared routes only.`,
214
- };
215
- }
216
- }
217
- else {
218
- targets = selectCustomProviders(readProviders(descriptor.value));
219
- if (targets.length === 0) {
220
- return { kind: 'success', text: 'No hand-declared (baseURL) providers configured — nothing to sync.' };
221
- }
222
- }
223
- const lines = [];
224
- let failures = 0;
225
- for (const target of targets) {
226
- try {
227
- // Re-read the live section per route: an api added/removed between the
228
- // selection and this write still reaches discovery (and a vanished
229
- // namespace degrades into that route's failure line, not a crash).
230
- const liveValue = currentDescriptor(deps.settings)?.value;
231
- const profile = readProfile(readProviders(liveValue)[target.id]);
232
- const discovered = await deps.llm.discoverModels(NS_LLM_PI_AI, {
233
- provider: target.id,
234
- baseURL: target.baseURL,
235
- ...(profile.api !== undefined ? { api: profile.api } : {}),
236
- ...(options.signal !== undefined ? { signal: options.signal } : {}),
237
- });
238
- const merged = mergeModels(profile.models, discovered);
239
- // A no-op sync must produce zero settings mutations: write only when
240
- // discovery actually contributed new ids.
241
- if (merged.added > 0) {
242
- await writeModels(deps.settings, target.id, merged.models);
243
- }
244
- lines.push(`${target.id}: added ${merged.added} · kept ${merged.kept} · skipped ${merged.skipped}`);
245
- }
246
- catch (error) {
247
- failures += 1;
248
- lines.push(`${target.id}: ${errorText(error)}`);
249
- }
250
- }
251
- if (failures === targets.length && failures > 0) {
252
- return { kind: 'error', text: lines.join('\n') };
253
- }
254
- return { kind: 'success', text: lines.join('\n') };
255
- }
256
- //# sourceMappingURL=model-sync.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"model-sync.js","sourceRoot":"","sources":["../src/model-sync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAA;AAGpF,OAAO,EAAE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