dsh-model-capability-sync 0.0.0-stage → 0.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.
package/src/types.ts ADDED
@@ -0,0 +1,136 @@
1
+ /**
2
+ * Shared vocabulary between the host half (catalog + matching) and the browser
3
+ * half (preview + write). Types only — nothing here runs.
4
+ * @module dsh-model-capability-sync/types
5
+ */
6
+
7
+ /** Input modalities the DeepSeek Harness LLM seam understands. */
8
+ export type Modality = 'text' | 'image'
9
+
10
+ /**
11
+ * The capability fields this plugin can fill into one provider model entry.
12
+ * The names are the provider's own field names (pi-ai uses these exact ones),
13
+ * so a filled entry is written verbatim into the provider configuration.
14
+ *
15
+ * `name` is deliberately absent: this plugin fills facts, it never renames a
16
+ * model. A label is the user's (or the gateway's) choice, and rewriting it
17
+ * would be a surprise no capability edit justifies.
18
+ */
19
+ export interface CapabilityFields {
20
+ /** Total request+response context capacity in tokens. */
21
+ contextWindow?: number
22
+ /** Per-request output cap in tokens. */
23
+ maxTokens?: number
24
+ /** Accepted input modalities, always including `text`. */
25
+ input?: Modality[]
26
+ /**
27
+ * Reasoning-effort map for providers that take a dict (`{ low: 'low' }`),
28
+ * or `false` when the catalog states the model cannot reason at all.
29
+ */
30
+ reasoningEfforts?: Record<string, string> | false
31
+ }
32
+
33
+ /** How a gateway id was matched against the catalog. */
34
+ export type MatchVia = 'alias' | 'exact' | 'folded' | 'basename' | 'suffix' | 'prefix' | 'vendor' | 'spelling' | 'name' | 'nameSuffix'
35
+
36
+ /** Where the key a `name` match used came from: the stored display name, or its id as a last resort. */
37
+ export type NameSource = 'name' | 'id'
38
+
39
+ /** The catalog entry a gateway id resolved to. */
40
+ export interface MatchInfo {
41
+ /** models.dev provider id the entry lives under (e.g. `openai`). */
42
+ provider: string
43
+ /** models.dev model id inside that provider. */
44
+ modelId: string
45
+ /** Which rule produced this match. */
46
+ via: MatchVia
47
+ /** For a `name`/`nameSuffix` match: the label the id was resolved through. */
48
+ matchedName?: string
49
+ /** For a `name`/`nameSuffix` match: whether that label was the display name or the id. */
50
+ nameSource?: NameSource
51
+ /** True when the entry belongs to the model's first-party vendor, not a reseller. */
52
+ firstParty?: boolean
53
+ /** Human name from the catalog, when present. */
54
+ name?: string
55
+ }
56
+
57
+ /** One preview row: a configured model and what the catalog says about it. */
58
+ export interface PreviewRow {
59
+ /** The gateway model id exactly as configured. */
60
+ id: string
61
+ /** The configured display name, when the request carried one. */
62
+ name?: string
63
+ match?: MatchInfo
64
+ fields?: CapabilityFields
65
+ /** Why no capability could be resolved, when `fields` is absent. */
66
+ reason?: string
67
+ }
68
+
69
+ /** Request payload of the `preview` RPC endpoint. */
70
+ export interface PreviewRequest {
71
+ /** Gateway model ids to resolve, in display order. */
72
+ ids: string[]
73
+ /** Explicit gateway id → models.dev model id overrides, applied first. */
74
+ aliases?: Record<string, string>
75
+ /**
76
+ * Display names by gateway id. A display name often carries facts the id
77
+ * does not — a gateway may expose `qoder/qfmodel` labelled `Qwen3.8-Flash`,
78
+ * or the label may keep the upstream id in front. When the id itself
79
+ * resolves to nothing, these are tried before giving up.
80
+ */
81
+ names?: Record<string, string>
82
+ /** Forward-proxy URL for the catalog download. */
83
+ proxyUrl?: string
84
+ /** Bypass the in-memory catalog cache. */
85
+ refresh?: boolean
86
+ }
87
+
88
+ /** Response payload of the `preview` RPC endpoint. */
89
+ export interface PreviewResponse {
90
+ /** Epoch milliseconds of the catalog fetch backing this answer. */
91
+ fetchedAt: number
92
+ /** Number of models in the downloaded catalog. */
93
+ catalogModels: number
94
+ /** True when the catalog came from the local copy because the download failed. */
95
+ stale?: boolean
96
+ /** One row per requested id, in request order. */
97
+ rows: PreviewRow[]
98
+ }
99
+
100
+ /** Envelope every RPC endpoint answers with. */
101
+ export type RpcEnvelope<T> =
102
+ | { ok: true; value: T }
103
+ | { ok: false; error: { code: string; message: string; details?: Record<string, unknown> } }
104
+
105
+ /**
106
+ * What the harness resolves for one model id right now, read from the adapter
107
+ * that actually owns the route. This is the truth a chat request sees, which
108
+ * is not necessarily the configuration this plugin writes: two plugins may
109
+ * claim the same provider route, and only one of them serves it.
110
+ */
111
+ export interface LiveRow {
112
+ /** The model id as configured. */
113
+ id: string
114
+ /** Input modalities the owning adapter reports, when it reports any. */
115
+ input?: string[]
116
+ /** Context window the owning adapter reports. */
117
+ contextWindow?: number
118
+ /** Default output cap the owning adapter reports. */
119
+ maxTokens?: number
120
+ /** Why the live lookup failed, when it did. */
121
+ error?: string
122
+ }
123
+
124
+ /** Request payload of the `live` RPC endpoint. */
125
+ export interface LiveRequest {
126
+ /** Provider route to inspect (the key inside `providers`). */
127
+ provider: string
128
+ /** Model ids to resolve through the owning adapter. */
129
+ ids: string[]
130
+ }
131
+
132
+ /** Response payload of the `live` RPC endpoint. */
133
+ export interface LiveResponse {
134
+ /** One row per requested id, in request order. */
135
+ rows: LiveRow[]
136
+ }