dsh-model-think-level 2.1.0 → 2.2.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.
@@ -177,3 +177,14 @@ export declare function withRouteBalance(document: KeyIndexDocument, route: stri
177
177
  * @param ref - the credential reference to forget.
178
178
  */
179
179
  export declare function withoutKeyEntry(document: KeyIndexDocument, route: string, ref: string): KeyIndexDocument;
180
+ /**
181
+ * Drop one route entirely: its key list, its extra endpoints and its balance
182
+ * URL. This is what a provider's deletion from the settings document reads as
183
+ * — {@link withoutKeyEntry} only empties a list the user cleaned key by key,
184
+ * and it deliberately leaves the endpoint maps alone, so a provider removed
185
+ * wholesale by the host would otherwise leave its addresses and balance URL
186
+ * behind for ever.
187
+ * @param document - the current document.
188
+ * @param route - the provider route key.
189
+ */
190
+ export declare function withoutRoute(document: KeyIndexDocument, route: string): KeyIndexDocument;
@@ -275,6 +275,32 @@ export declare function isSelfHostedEndpoint(baseURL: string | undefined): boole
275
275
  * such a profile keeps exactly what it already stores.
276
276
  */
277
277
  export declare function sanitizeCompatForProtocol(compat: CompatSuggestion, api: string): CompatSuggestion | undefined;
278
+ /**
279
+ * Compat switches the openai-completions gate offers and NO sibling wire
280
+ * protocol takes (llm-pi-ai COMPLETIONS_COMPAT_GATE vs RESPONSES_COMPAT_GATE
281
+ * and the anthropic gate). These are exactly the keys this plugin's knowledge
282
+ * base and editors write, so a route switched off openai-completions leaves
283
+ * them behind on its models -- and the kernel then refuses every model that
284
+ * still carries one ("sets compat ..., but its api is ..., which does not
285
+ * take it"), dropping it from the served catalog.
286
+ */
287
+ export declare const COMPLETIONS_ONLY_COMPAT: readonly string[];
288
+ /** The anthropic-messages gate's exclusive switch (see sanitizeCompatForProtocol). */
289
+ export declare const ANTHROPIC_ONLY_COMPAT: readonly string[];
290
+ /**
291
+ * Drop the compat switches one STORED block carries that its route's wire
292
+ * protocol does not take -- the repair for a protocol switched after the
293
+ * switches were written: openai-completions → openai-responses leaves
294
+ * `supportsReasoningEffort` behind, and the kernel then refuses the model at
295
+ * catalog resolution. Returns the cleaned copy, or undefined when there is
296
+ * nothing to drop (the common case, so a caller never writes speculatively).
297
+ *
298
+ * Deliberately a denylist of the keys this plugin writes, not an allowlist of
299
+ * each gate: a hand-tuned key this plugin does not know stays exactly as
300
+ * stored -- the same courtesy {@link sanitizeCompatForProtocol} extends to
301
+ * suggestions. A protocol this module does not know strips nothing.
302
+ */
303
+ export declare function stripForeignCompat(compat: Record<string, unknown>, api: string): Record<string, unknown> | undefined;
278
304
  /**
279
305
  * Whether a route is a self-hosted relay whose upstreams cannot be assumed
280
306
  * to accept role:developer: openai-completions protocol on a baseURL whose
@@ -0,0 +1,78 @@
1
+ /**
2
+ * The UI-order document: the sequence the user set by dragging the provider
3
+ * rows, and every provider's model-row sequence, mirrored host-side.
4
+ *
5
+ * The live preference lives in the browser half's localStorage
6
+ * (provider-order.ts / model-order.ts) — fast, and shared across tabs through
7
+ * storage events. localStorage does not travel, though, and the orderings are
8
+ * exactly the kind of setting a user wants on every machine, so the document
9
+ * is mirrored into `<DSH_HOME>/dsh-model-think-level/ui-order.json` beside the
10
+ * key index: a file the user can carry through any sync mechanism. The client
11
+ * is the only writer (it pulls at boot and pushes every drag, last-writer-wins
12
+ * on the `savedAt` stamp); the host only reads, stores and serves it.
13
+ *
14
+ * The file holds no secrets — provider routes and model ids only — which is
15
+ * what makes it safe to point a sync tool at. It is parsed leniently: an
16
+ * unreadable or malformed document degrades to "nothing stored", never an
17
+ * error, and a partial payload MERGES over what is already stored, so a
18
+ * buggy writer cannot wipe a good file with an empty one. Every write is
19
+ * atomic, like the key index's.
20
+ *
21
+ * @module dsh-model-think-level/order-store
22
+ */
23
+ /** The whole synced ordering state, stamped by the writing client. */
24
+ export interface UiOrderDocument {
25
+ readonly version: 1;
26
+ /**
27
+ * Epoch ms of the writing client's last ORDER CHANGE — set by the browser
28
+ * at change time, not by the host at write time, so machines can arbitrate
29
+ * which side is newer. Zero means "unstamped" (a hand-made file).
30
+ */
31
+ readonly savedAt: number;
32
+ /** The dragged provider-row sequence, first row first. */
33
+ readonly providerOrder: readonly string[];
34
+ /** Every provider's dragged model-row sequence, keyed by provider id. */
35
+ readonly modelOrder: Readonly<Record<string, readonly string[]>>;
36
+ /**
37
+ * The provider ids switched OFF on the Models page. The DISABLED set, not
38
+ * the enabled one — an empty list means "everything is on", which is a real
39
+ * state a machine can hold and another machine must be able to adopt, not
40
+ * the absence of an opinion.
41
+ */
42
+ readonly providersDisabled: readonly string[];
43
+ }
44
+ /** A fresh, empty document. */
45
+ export declare function emptyUiOrder(): UiOrderDocument;
46
+ /** Absolute path of the document beside the key index. */
47
+ export declare function uiOrderFilePath(home?: string): string;
48
+ /**
49
+ * Parse an already-decoded payload, dropping whatever does not fit. Never
50
+ * throws: this file is a UI preference, so a corrupt one is an empty one.
51
+ * @param raw - the decoded JSON value (or anything else).
52
+ */
53
+ export declare function parseUiOrder(raw: unknown): UiOrderDocument;
54
+ /**
55
+ * Fold a (possibly partial) payload over a current document: a field the
56
+ * payload carries in a usable shape replaces the stored one, every other
57
+ * field keeps the stored value. A writer that can only name what it knows —
58
+ * or a corrupted body — therefore can never blank a good file.
59
+ * @param current - the stored document.
60
+ * @param patch - the incoming payload, as posted by the client.
61
+ * @param at - the savedAt to stamp when the payload carries no usable one.
62
+ */
63
+ export declare function mergeUiOrder(current: UiOrderDocument, patch: unknown, at: number): UiOrderDocument;
64
+ /**
65
+ * Read the document. Never throws: an absent file and an unreadable one both
66
+ * mean "nothing stored yet" — the client decides whether to adopt or to seed.
67
+ * @param file - document path (tests pass a temp file).
68
+ */
69
+ export declare function readUiOrder(file?: string): UiOrderDocument;
70
+ /** Write the document at one path, atomically. */
71
+ export declare function writeUiOrder(document: UiOrderDocument, file?: string): void;
72
+ /**
73
+ * Read, fold a payload over it, and write back — the POST route's whole body.
74
+ * The read and the write bracket one synchronous section, so two overlapping
75
+ * requests cannot interleave the read-modify-write.
76
+ * @returns the document as it now stands on disk.
77
+ */
78
+ export declare function commitUiOrder(patch: unknown, at: number, file?: string): UiOrderDocument;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-model-think-level",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "DSH 的第三方模型补齐思考等级:在官方 Models 页每个模型行注入 Thinking 开关和强度/模态编辑器,在输入框模型菜单加供应商→模型选择器、视觉徽章与等级行,并带搜索、拖拽排序、供应商启用开关;以及按路由接管请求头与 user-agent。",
5
5
  "license": "MIT",
6
6
  "author": "GaoHu1997 <gaohu9712@163.com>",