dsh-model-think-level 2.0.0 → 2.0.3

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 (41) hide show
  1. package/LICENSE +13 -0
  2. package/README.md +23 -13
  3. package/assets/NOTICE.md +15 -0
  4. package/assets/unified_bank.json +32910 -0
  5. package/lib/client/EffortEditor.d.ts +53 -21
  6. package/lib/client/FingerprintPane.d.ts +36 -0
  7. package/lib/client/capacity.d.ts +46 -0
  8. package/lib/client/configured-inputs.d.ts +11 -2
  9. package/lib/client/fingerprint-client.d.ts +81 -0
  10. package/lib/client/fingerprint-runner.d.ts +73 -0
  11. package/lib/client/index.d.ts +6 -0
  12. package/lib/client/injection/create-key-seat.d.ts +4 -5
  13. package/lib/client/injection/editor-tab-bar.d.ts +2 -1
  14. package/lib/client/injection/editor-tabs.d.ts +11 -1
  15. package/lib/client/injection/key-reveal.d.ts +12 -0
  16. package/lib/client/injection/models-page-editor.d.ts +117 -2
  17. package/lib/client/injection/provider-card-slot.d.ts +3 -1
  18. package/lib/client/key-manager-client.d.ts +2 -1
  19. package/lib/client/locales.d.ts +37 -9
  20. package/lib/client/ops.d.ts +15 -2
  21. package/lib/client/refresh-scheduler.d.ts +29 -0
  22. package/lib/client/styles.d.ts +1 -1
  23. package/lib/client/types.d.ts +26 -2
  24. package/lib/client.js +701 -225
  25. package/lib/client.js.map +4 -4
  26. package/lib/constants.d.ts +24 -0
  27. package/lib/detection.d.ts +7 -0
  28. package/lib/fingerprint/bank.d.ts +24 -0
  29. package/lib/fingerprint/challenges.d.ts +14 -0
  30. package/lib/fingerprint/core.d.ts +85 -0
  31. package/lib/fingerprint/eligibility.d.ts +8 -0
  32. package/lib/fingerprint/random.d.ts +4 -0
  33. package/lib/fingerprint/run.d.ts +128 -0
  34. package/lib/fingerprint/store.d.ts +31 -0
  35. package/lib/fingerprint/verdict.d.ts +90 -0
  36. package/lib/index.js +1212 -251
  37. package/lib/index.js.map +4 -4
  38. package/lib/key-probe.d.ts +13 -98
  39. package/lib/knowledge.d.ts +21 -0
  40. package/lib/multi-key-listing.d.ts +3 -3
  41. package/package.json +13 -5
@@ -1,21 +1,20 @@
1
1
  /**
2
- * Which endpoint a key's model listing is asked of.
2
+ * Shared facts of per-key model probing.
3
3
  *
4
4
  * A key is not tied to one protocol: a route can answer on an OpenAI-family
5
5
  * address, an Anthropic-family one and a Gemini-family one, and each key may
6
- * pin a protocol of its own. Probing every key against the route's default
7
- * wire would therefore ask half of them a question their credential cannot
8
- * answer — an Anthropic-pinned key returns `401` from an OpenAI gateway, and
9
- * the panel would conclude the key serves nothing. This module derives the
10
- * *protocols a key can actually be used with* from the same facts routing uses
6
+ * pin a protocol of its own. Asking every key against the route's default wire
7
+ * would therefore ask half of them a question their credential cannot answer —
8
+ * an Anthropic-pinned key returns `401` from an OpenAI gateway. The probe
9
+ * targets a key may be asked of are derived from the same facts routing uses
11
10
  * (the pin, the route's api, and the stored endpoints), so a probe is only
12
- * sent where a request would go.
11
+ * sent where a request would go; the fetch overlay that assembles a provider's
12
+ * catalogue (`modelListing` in the entry module) derives them inline.
13
13
  *
14
14
  * The rules mirror routing ({@link module:key-route-core}):
15
15
  * - a pin is honoured only when its family has an address; a cross-family pin
16
16
  * with no address for that family is NOT probed, because no request could be
17
- * served that way either — the key keeps its previous scope and the plan says
18
- * why;
17
+ * served that way either — the key keeps its previous scope;
19
18
  * - a same-family pin (Responses vs Chat Completions) rides the route's own
20
19
  * address: only the wire changes, so the listing is asked there;
21
20
  * - a key with no pin is AUTOMATIC (the request speaks the model family's own
@@ -26,101 +25,17 @@
26
25
  *
27
26
  * @module dsh-model-think-level/key-probe
28
27
  */
29
- import { type EndpointFamily, type RouteEndpoints, type RouteProtocol } from './key-refs.js';
30
- import { listingEntries } from './listing.js';
28
+ import type { EndpointFamily, RouteProtocol } from './key-refs.js';
31
29
  export type { EndpointFamily };
32
30
  /** The protocol a probe speaks on a family when it has no more specific pin. */
33
31
  export declare const FAMILY_PROTOCOL: Readonly<Record<EndpointFamily, RouteProtocol>>;
34
- /** The listing request one key should be sent. */
35
- export interface ProbeTarget {
36
- readonly api: RouteProtocol;
37
- readonly baseURL: string;
38
- readonly family: EndpointFamily;
39
- }
40
- /** What a key's probe would ask, and why it asks nothing when it asks nothing. */
41
- export interface ProbePlan {
42
- readonly targets: readonly ProbeTarget[];
43
- /** Set when no legal request exists for this key (its pin cannot be honoured). */
44
- readonly skipped?: string;
45
- }
46
- /** The routing facts a probe plan is derived from. */
47
- export interface ProbeIntent {
48
- /** The route's own wire (the provider profile's `api`). */
49
- readonly api: unknown;
50
- /** The route's own address. */
51
- readonly baseURL: string;
52
- /** The protocol this key pinned, when it pinned one. */
53
- readonly pinned?: RouteProtocol | undefined;
54
- /** The route's stored endpoint pair, when the storage has one. */
55
- readonly endpoints?: RouteEndpoints | undefined;
56
- }
57
- /**
58
- * The listing requests one key should receive.
59
- *
60
- * Every target is a request a real call could also make: the protocol is one
61
- * the key would be dispatched to, and the address is the one that protocol
62
- * would use. Targets are de-duplicated by what they would actually fetch — a
63
- * same-family pin shares its family's address with the route's own wire, and a
64
- * gateway that spells one listing under both protocols must not be asked twice.
65
- * @param intent - the route's wire and address, the key's pin, the endpoint pair.
66
- * @returns the targets in preference order, or a skip reason when none apply.
67
- */
68
- export declare function probePlanFor(intent: ProbeIntent): ProbePlan;
69
- /** One target's outcome, in the shape the panel can render. */
70
- export interface ProbeTargetOutcome {
71
- readonly api: RouteProtocol;
72
- readonly family: EndpointFamily;
73
- /** The URL asked, with userinfo stripped so a stored `user:pass@` never leaks. */
74
- readonly url: string;
75
- readonly ok: boolean;
76
- /** HTTP status when the endpoint answered at all. */
77
- readonly status?: number;
78
- /** How many distinct models this target advertised. */
79
- readonly models?: number;
80
- /** Why this target did not answer, when it did not. */
81
- readonly error?: string;
82
- }
83
- /** What one key's probe learned. */
32
+ /** What one key's probe learned, as the catalogue merge reads it. */
84
33
  export interface KeyProbeResult {
85
34
  readonly ref: string;
86
35
  /**
87
- * The key's new scope: the union of every target that answered. Undefined
88
- * when no target answered — the caller must then keep the previous scope
89
- * rather than recording "serves nothing".
36
+ * The key's scope: the union of every address that answered. Undefined when
37
+ * no address answered — the caller must then keep the previous scope rather
38
+ * than recording "serves nothing".
90
39
  */
91
40
  readonly models: string[] | undefined;
92
- readonly targets: readonly ProbeTargetOutcome[];
93
- /** Set when the plan had no legal target at all (see {@link probePlanFor}). */
94
- readonly skipped?: string;
95
- }
96
- /** Transport and credentials one key's probe needs. */
97
- export interface ProbeKeyOptions {
98
- readonly ref: string;
99
- readonly intent: ProbeIntent;
100
- /** The resolved credential; a probe is always signed by the key it asks about. */
101
- readonly apiKey: string;
102
- /** The route profile's configured headers (deployment-owned values ride along). */
103
- readonly profileHeaders: unknown;
104
- readonly timeoutMs: number;
105
- readonly send: (url: string, init: RequestInit) => Promise<Response>;
106
- /** How to sign one listing request for one protocol. */
107
- readonly headersFor: (profileHeaders: unknown, apiKey: string, api: RouteProtocol) => Record<string, string>;
108
- /** Reads a bounded listing body. */
109
- readonly read: (response: Response, url: string) => Promise<string>;
110
- /** Parses a listing body into entries; undefined when it names no listing shape. */
111
- readonly entries: (body: unknown) => Record<string, unknown>[] | undefined;
112
41
  }
113
- /**
114
- * Ask one key for its models on every address it can legitimately be used with.
115
- *
116
- * A target that fails is reported and does not cancel the others: a key that
117
- * serves only the Anthropic family still records those models when its OpenAI
118
- * family probe is refused. When at least one target answers, the key's scope
119
- * becomes the union of the answers; an endpoint answering with an empty listing
120
- * is a real answer ("this key serves none") and yields `[]`.
121
- * @param options - the key, its routing facts, and the transport readers.
122
- * @returns the scope to store and the per-target report.
123
- */
124
- export declare function probeKeyModels(options: ProbeKeyOptions): Promise<KeyProbeResult>;
125
- /** Re-exported so the entry module does not import two listing names for one op. */
126
- export { listingEntries as parseListingEntries };
@@ -108,6 +108,15 @@ export interface KnowledgeEntry {
108
108
  * audio, video) is recorded in 'note' until the core vocabulary grows.
109
109
  */
110
110
  input?: InputModalities;
111
+ /**
112
+ * The family is IMAGE GENERATION (生图): these models produce images from
113
+ * prompts and cannot serve a chat turn, so the composer's model switcher
114
+ * hides them and the row editor's modality pills stand down to the single
115
+ * 生图 answer. Such an entry declares `efforts: false` (a generator takes no
116
+ * reasoning_effort) and no `input` — the two chat-input answers would read
117
+ * it back as a vision chat model.
118
+ */
119
+ imageGen?: true;
111
120
  /**
112
121
  * Reference context window in tokens. Rendered as footnote advice, and a
113
122
  * mounted row's official capacity input echoes it (fill-only) when a
@@ -151,6 +160,14 @@ export interface EndpointFacts {
151
160
  * discipline: silence is not refusal.
152
161
  */
153
162
  input?: readonly string[];
163
+ /**
164
+ * The listing's OUTPUT-modality disclosure, normalized to lowercase strings,
165
+ * when it named one (OpenRouter's `architecture.output_modalities` and its
166
+ * flattened copies). This is the disclosure that answers "is this an image
167
+ * generator": a model whose listing says it outputs images and not text
168
+ * cannot serve a chat turn.
169
+ */
170
+ output?: readonly string[];
154
171
  /** Context length the listing disclosed, when it carries one. */
155
172
  contextLength?: number;
156
173
  }
@@ -175,6 +192,8 @@ export interface EffortSuggestion {
175
192
  input?: InputModalities;
176
193
  /** Where the modality part came from -- its confidence rides this. */
177
194
  inputSource?: InputSource;
195
+ /** Whether the model is an image generator (生图), when derivable. */
196
+ imageGen?: boolean;
178
197
  /** Reference context window; echoed into the row's official capacity input when one is mounted. */
179
198
  contextWindow?: number;
180
199
  /** Reference max output tokens (same echo rule as the context window). */
@@ -265,6 +284,8 @@ export declare function sanitizeCompatForProtocol(compat: CompatSuggestion, api:
265
284
  export declare function isSelfHostedRelay(route: RouteFacts): boolean;
266
285
  /** Lowest-confidence modality guess from the model id alone, or undefined. */
267
286
  export declare function inferModalitiesFromName(modelId: string): InputModalities | undefined;
287
+ /** Whether the id alone reads as an image generator (生图) -- the lowest-confidence tier. */
288
+ export declare function inferImageGenFromName(modelId: string): boolean;
268
289
  /**
269
290
  * Resolve the suggestion for one model on one route, fusing the available
270
291
  * signals by confidence:
@@ -25,8 +25,8 @@
25
25
  * key's extras appended, scattering one letter across both ends.
26
26
  *
27
27
  * Probing is the caller's job: {@link collectKeyListings} only bounds how many
28
- * probes run at once and merges what comes back, so the panel, the `discover`
29
- * operation and the fetch overlay all share one merge.
28
+ * probes run at once and merges what comes back, so the fetch overlay and every
29
+ * other catalogue reader share one merge.
30
30
  *
31
31
  * @module dsh-model-think-level/multi-key-listing
32
32
  */
@@ -71,7 +71,7 @@ export declare function mergeKeyListings(results: readonly KeyProbeResult[], las
71
71
  export interface CollectKeyListingsOptions<Key> {
72
72
  /** The keys to ask, in the order the catalogue should read. */
73
73
  readonly keys: readonly Key[];
74
- /** Ask one key for its listing (typically `probeKeyModels`). */
74
+ /** Ask one key for its listing (the overlay's per-key probe). */
75
75
  readonly probe: (key: Key) => Promise<KeyProbeResult>;
76
76
  /**
77
77
  * The ref a key is known by. When given, a probe that THROWS is recorded as
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-model-think-level",
3
- "version": "2.0.0",
3
+ "version": "2.0.3",
4
4
  "description": "DSH 的第三方模型补齐思考等级:在官方 Models 页每个模型行注入 Thinking 开关和强度/模态编辑器,在输入框模型菜单加供应商→模型选择器、视觉徽章与等级行,并带搜索、拖拽排序、供应商启用开关;以及按路由接管请求头与 user-agent。",
5
5
  "license": "MIT",
6
6
  "author": "GaoHu1997 <gaohu9712@163.com>",
@@ -98,10 +98,18 @@
98
98
  "react-dom": "^18.2.0 || ^19.0.0"
99
99
  },
100
100
  "peerDependenciesMeta": {
101
- "@deepseek-ai/cordis": { "optional": true },
102
- "@deepseek-ai/dsh-api-session-controller": { "optional": true },
103
- "@deepseek-ai/dsh-client-ui-model-selection": { "optional": true },
104
- "@deepseek-ai/dsh-client-ui-slots": { "optional": true }
101
+ "@deepseek-ai/cordis": {
102
+ "optional": true
103
+ },
104
+ "@deepseek-ai/dsh-api-session-controller": {
105
+ "optional": true
106
+ },
107
+ "@deepseek-ai/dsh-client-ui-model-selection": {
108
+ "optional": true
109
+ },
110
+ "@deepseek-ai/dsh-client-ui-slots": {
111
+ "optional": true
112
+ }
105
113
  },
106
114
  "devDependencies": {
107
115
  "@deepseek-ai/cordis": "4.0.3",