dsh-model-think-level 2.0.3 → 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.
- package/README.md +39 -22
- package/lib/autofill.d.ts +20 -2
- package/lib/balance.d.ts +44 -0
- package/lib/client/ComposerSlider.d.ts +19 -0
- package/lib/client/ConfigPane.d.ts +45 -0
- package/lib/client/EffortEditor.d.ts +1 -8
- package/lib/client/KeyManager.d.ts +2 -2
- package/lib/client/balance-client.d.ts +34 -0
- package/lib/client/events.d.ts +31 -2
- package/lib/client/image-config-client.d.ts +52 -0
- package/lib/client/index.d.ts +1 -0
- package/lib/client/injection/autofill-run.d.ts +2 -2
- package/lib/client/injection/compat-guard.d.ts +33 -0
- package/lib/client/injection/config-button-seat.d.ts +96 -0
- package/lib/client/injection/create-key-seat.d.ts +3 -3
- package/lib/client/injection/create-keys-pane.d.ts +4 -2
- package/lib/client/injection/editor-tab-bar.d.ts +1 -1
- package/lib/client/injection/editor-tabs.d.ts +1 -1
- package/lib/client/injection/image-card.d.ts +85 -0
- package/lib/client/injection/imagegen-completion.d.ts +43 -0
- package/lib/client/injection/imagegen-entry.d.ts +22 -0
- package/lib/client/injection/key-prefetch.d.ts +56 -0
- package/lib/client/injection/key-reveal.d.ts +2 -3
- package/lib/client/injection/model-order-drag.d.ts +1 -1
- package/lib/client/injection/models-page-editor.d.ts +25 -29
- package/lib/client/injection/models-page-mutation.d.ts +6 -0
- package/lib/client/injection/models-page.d.ts +15 -3
- package/lib/client/injection/provider-balance.d.ts +94 -0
- package/lib/client/injection/provider-delete-seat.d.ts +4 -1
- package/lib/client/injection/provider-disabled-group.d.ts +4 -1
- package/lib/client/injection/provider-endpoints.d.ts +2 -2
- package/lib/client/injection/provider-order-drag.d.ts +5 -1
- package/lib/client/injection/provider-toggle.d.ts +4 -1
- package/lib/client/injection/row-drag.d.ts +7 -0
- package/lib/client/injection/staged-keys.d.ts +24 -12
- package/lib/client/key-manager-client.d.ts +82 -19
- package/lib/client/locales.d.ts +40 -6
- package/lib/client/model-order.d.ts +9 -0
- package/lib/client/ops.d.ts +1 -0
- package/lib/client/order-sync.d.ts +63 -0
- package/lib/client/styles.d.ts +1 -1
- package/lib/client/types.d.ts +4 -1
- package/lib/client.js +517 -13
- package/lib/client.js.map +4 -4
- package/lib/constants.d.ts +53 -0
- package/lib/fingerprint/estimate.d.ts +16 -0
- package/lib/fingerprint/run.d.ts +6 -0
- package/lib/fingerprint/store.d.ts +2 -2
- package/lib/fingerprint/verdict.d.ts +24 -0
- package/lib/headers-core.d.ts +3 -1
- package/lib/headers-fetch.d.ts +25 -0
- package/lib/image/command.d.ts +84 -0
- package/lib/image/config.d.ts +150 -0
- package/lib/image/generate.d.ts +135 -0
- package/lib/image/legacy-cleanup.d.ts +29 -0
- package/lib/image/sizes.d.ts +28 -0
- package/lib/image/tool.d.ts +107 -0
- package/lib/index.js +3969 -1555
- package/lib/index.js.map +4 -4
- package/lib/key-index.d.ts +48 -7
- package/lib/key-probe.d.ts +42 -17
- package/lib/key-refs.d.ts +43 -19
- package/lib/key-route-core.d.ts +100 -32
- package/lib/key-serves.d.ts +81 -0
- package/lib/knowledge.d.ts +26 -0
- package/lib/listing.d.ts +18 -20
- package/lib/order-store.d.ts +78 -0
- package/package.json +1 -8
|
@@ -53,14 +53,14 @@ export interface StagedKeyDraft {
|
|
|
53
53
|
readonly enabled: boolean;
|
|
54
54
|
}
|
|
55
55
|
/** How far the drain got with one draft: its host reference once the value
|
|
56
|
-
* landed, and
|
|
56
|
+
* landed, and the draft fields the host currently holds for it. */
|
|
57
57
|
interface StagedKeyLanding {
|
|
58
58
|
/** The draft this landing belongs to ({@link StagedKeyDraft.ref}). */
|
|
59
59
|
readonly ref: string;
|
|
60
|
-
/** The reference the host minted when it stored the value. */
|
|
60
|
+
/** The reference the host minted or reused when it stored the value. */
|
|
61
61
|
readonly hostRef: string;
|
|
62
|
-
/**
|
|
63
|
-
|
|
62
|
+
/** Snapshot of the fields currently applied to the host reference. */
|
|
63
|
+
draft: StagedKeyDraft;
|
|
64
64
|
}
|
|
65
65
|
/** One pane's held key list, keyed by the route it will be written to. */
|
|
66
66
|
export interface StagedKeyIntent {
|
|
@@ -68,13 +68,16 @@ export interface StagedKeyIntent {
|
|
|
68
68
|
drafts: readonly StagedKeyDraft[];
|
|
69
69
|
/** Which drafts have already landed, with the host references they landed as. */
|
|
70
70
|
readonly landed: StagedKeyLanding[];
|
|
71
|
-
/**
|
|
71
|
+
/** Changes whenever the pane replaces this intent's desired draft list. */
|
|
72
|
+
revision: number;
|
|
73
|
+
/** Whether this route was already declared when this card first asked. */
|
|
72
74
|
declaredBefore?: boolean;
|
|
73
75
|
/** When the pane that staged this intent unmounted, if it has. */
|
|
74
76
|
releasedAt?: number;
|
|
75
|
-
/** Whether
|
|
76
|
-
* baseline, the one holding state that ends in silence. */
|
|
77
|
+
/** Whether a missing pre-save baseline has already been reported. */
|
|
77
78
|
noted?: boolean;
|
|
79
|
+
/** A post-save route exists, but its pre-save ownership is unknown. */
|
|
80
|
+
baselineMissing?: boolean;
|
|
78
81
|
/** Failed drain passes since the last one that wrote something. */
|
|
79
82
|
attempts: number;
|
|
80
83
|
}
|
|
@@ -83,12 +86,17 @@ export interface StagedKeysState {
|
|
|
83
86
|
/** Held drafts, by route. Readable so a test (and the console) can see what
|
|
84
87
|
* the session is still holding. */
|
|
85
88
|
readonly intents: Map<string, StagedKeyIntent>;
|
|
86
|
-
/**
|
|
87
|
-
* restaged after the drain retired its intent does not have to ask again. */
|
|
89
|
+
/** The first successful pre-save answer for each route. */
|
|
88
90
|
readonly baseline: Map<string, boolean>;
|
|
89
|
-
/**
|
|
90
|
-
|
|
91
|
+
/** Baseline reads currently in flight. */
|
|
92
|
+
readonly baselinePending: Set<string>;
|
|
93
|
+
/** Baseline reads that failed before producing a pre-save answer. */
|
|
94
|
+
readonly baselineFailures: Set<string>;
|
|
95
|
+
/** Active intents keep late add references available to a restaged route. */
|
|
96
|
+
readonly activeIntents: Map<string, StagedKeyIntent>;
|
|
97
|
+
/** One drain at a time, with another pass requested on concurrent edits. */
|
|
91
98
|
draining: boolean;
|
|
99
|
+
drainAgain: boolean;
|
|
92
100
|
}
|
|
93
101
|
/** A fresh, empty ledger. */
|
|
94
102
|
export declare function createStagedKeysState(): StagedKeysState;
|
|
@@ -105,7 +113,7 @@ export declare function createStagedKeysState(): StagedKeysState;
|
|
|
105
113
|
* @param drafts - the complete draft list.
|
|
106
114
|
*/
|
|
107
115
|
export declare function stageKeys(state: StagedKeysState, route: string, drafts: readonly StagedKeyDraft[]): void;
|
|
108
|
-
/** Drop the drafts
|
|
116
|
+
/** Drop the drafts for a route; an active request will stop after it settles. */
|
|
109
117
|
export declare function withdrawKeys(state: StagedKeysState, route: string): void;
|
|
110
118
|
/**
|
|
111
119
|
* Mark one route's drafts as orphaned: the pane that staged them is gone and
|
|
@@ -118,6 +126,10 @@ export declare function releaseKeys(state: StagedKeysState, route: string): void
|
|
|
118
126
|
* intent does not ask twice.
|
|
119
127
|
*/
|
|
120
128
|
export declare function markKeysRouteBaseline(state: StagedKeysState, route: string, declared: boolean): void;
|
|
129
|
+
/** Mark a baseline read as in flight before issuing the pre-save request. */
|
|
130
|
+
export declare function beginKeysRouteBaseline(state: StagedKeysState, route: string): boolean;
|
|
131
|
+
/** Record a failed baseline read without allowing a later route state to replace it. */
|
|
132
|
+
export declare function failKeysRouteBaseline(state: StagedKeysState, route: string): void;
|
|
121
133
|
/**
|
|
122
134
|
* Whether `route` still needs its baseline read.
|
|
123
135
|
* @returns True when the pane should ask the settings document.
|
|
@@ -54,12 +54,29 @@ export interface KeyRow {
|
|
|
54
54
|
* Absent means "unscoped": a catch-all that serves whatever is left.
|
|
55
55
|
*/
|
|
56
56
|
readonly models?: readonly string[];
|
|
57
|
+
/**
|
|
58
|
+
* The model ids this key's OWN listing advertised the last time it answered —
|
|
59
|
+
* observed by the host, not assigned by the user. A relay may resolve each key
|
|
60
|
+
* to a different upstream account with its own catalogue, so one key's list can
|
|
61
|
+
* be smaller than the route's; the panel offers this list as a one-click scope
|
|
62
|
+
* so "this key only carries half the models" can be made explicit instead of
|
|
63
|
+
* being discovered as a 404 at request time. Absent means never listed (or the
|
|
64
|
+
* list named none of the route's models), which is unknown, not empty.
|
|
65
|
+
*/
|
|
66
|
+
readonly observed?: readonly string[];
|
|
57
67
|
/**
|
|
58
68
|
* The wire protocol this key pins. Absent means "follow the provider's own
|
|
59
69
|
* protocol". A pinned protocol makes this key speak a different API shape than
|
|
60
70
|
* the rest of the route (e.g. one Anthropic key on an OpenAI route).
|
|
61
71
|
*/
|
|
62
72
|
readonly protocol?: RouteProtocol;
|
|
73
|
+
/**
|
|
74
|
+
* Whether the key's model scope is the probe's assignment rather than a
|
|
75
|
+
* manual one — the panel shows it so a scope edit knows the checked chips
|
|
76
|
+
* will keep being rewritten on every probe run until the user saves one by
|
|
77
|
+
* hand.
|
|
78
|
+
*/
|
|
79
|
+
readonly auto?: boolean;
|
|
63
80
|
/**
|
|
64
81
|
* The key's cooldown, when it is resting after a failure: how long until it
|
|
65
82
|
* is a normal candidate again, and how many consecutive failures produced
|
|
@@ -78,32 +95,28 @@ export interface KeyRow {
|
|
|
78
95
|
export interface KeyEndpoints {
|
|
79
96
|
readonly openai: string | null;
|
|
80
97
|
readonly anthropic: string | null;
|
|
81
|
-
readonly gemini: string | null;
|
|
82
98
|
}
|
|
83
99
|
/** A successful answer: the whole list, in the host's order. */
|
|
84
100
|
export interface KeyState {
|
|
85
101
|
readonly ok: true;
|
|
86
102
|
readonly route: string;
|
|
87
103
|
readonly entries: readonly KeyRow[];
|
|
104
|
+
/** The exact reference added or reused by an add operation. */
|
|
105
|
+
readonly addedRef?: string;
|
|
88
106
|
/**
|
|
89
107
|
* The models this route actually offers — the universe a key's scope is
|
|
90
108
|
* chosen from (the models already added to the provider, never its whole
|
|
91
109
|
* catalog). Absent when the route declares none yet.
|
|
92
110
|
*/
|
|
93
111
|
readonly models?: readonly string[];
|
|
94
|
-
/**
|
|
95
|
-
* The provider's catalogue merged across its keys: every model any key
|
|
96
|
-
* advertises, in first-advertised order. Absent when no key has been detected
|
|
97
|
-
* yet or the route itself declares no models.
|
|
98
|
-
*/
|
|
99
|
-
readonly mergedModels?: readonly string[];
|
|
100
|
-
/**
|
|
101
|
-
* The part of {@link mergedModels} the route's own `models` does not declare
|
|
102
|
-
* yet — what the panel offers to add. Absent when there is nothing to add.
|
|
103
|
-
*/
|
|
104
|
-
readonly unmergedModels?: readonly string[];
|
|
105
112
|
/** The provider's two base URLs, keyed by protocol family. */
|
|
106
113
|
readonly endpoints: KeyEndpoints;
|
|
114
|
+
/**
|
|
115
|
+
* Whether the host is probing this route's keys right now (the panel button's
|
|
116
|
+
* scope check). The panel follows it with a quiet poll until it clears, so
|
|
117
|
+
* the assignments the probe writes land on screen without a reopen.
|
|
118
|
+
*/
|
|
119
|
+
readonly probing?: boolean;
|
|
107
120
|
}
|
|
108
121
|
/** A refused answer, carrying the host's own words when it sent any. */
|
|
109
122
|
export interface KeyFailure {
|
|
@@ -112,10 +125,51 @@ export interface KeyFailure {
|
|
|
112
125
|
}
|
|
113
126
|
/** What one call to the key route answers. */
|
|
114
127
|
export type KeyAnswer = KeyState | KeyFailure;
|
|
128
|
+
/** A route's two base URLs, as the index file stores them (null when unset). */
|
|
129
|
+
export interface RouteEndpointsAnswer {
|
|
130
|
+
readonly ok: boolean;
|
|
131
|
+
readonly endpoints?: {
|
|
132
|
+
readonly openai: string | null;
|
|
133
|
+
readonly anthropic: string | null;
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
/** A route's balance endpoint, as the index file stores it (null when unset). */
|
|
137
|
+
export interface RouteBalanceAnswer {
|
|
138
|
+
readonly ok: boolean;
|
|
139
|
+
readonly endpoint?: string | null;
|
|
140
|
+
/** The host's wording when the read was refused. */
|
|
141
|
+
readonly error?: string;
|
|
142
|
+
}
|
|
143
|
+
/** Read policy for the masked key list; omitted options always revalidate. */
|
|
144
|
+
export interface KeyListOptions {
|
|
145
|
+
/** Reuse a successful masked answer for up to five seconds. */
|
|
146
|
+
readonly preferCache?: boolean;
|
|
147
|
+
}
|
|
115
148
|
/** The manager's transport, injectable so the panel can be tested without one. */
|
|
116
149
|
export interface KeyManagerClient {
|
|
117
|
-
/** Read the provider's whole key list. */
|
|
118
|
-
list(route: string): Promise<KeyAnswer>;
|
|
150
|
+
/** Read the provider's whole key list (fresh unless cache reuse is requested). */
|
|
151
|
+
list(route: string, options?: KeyListOptions): Promise<KeyAnswer>;
|
|
152
|
+
/**
|
|
153
|
+
* Read only the route's two addresses.
|
|
154
|
+
*
|
|
155
|
+
* The page's endpoint hydration needs nothing else, and asking for the whole
|
|
156
|
+
* list for it cost a settings read plus one credential resolve per key on
|
|
157
|
+
* every hydration -- once per provider card per second -- which is what put
|
|
158
|
+
* an opened card's own list behind that queue. Optional so a test double (or
|
|
159
|
+
* an older host) can keep answering from `list`.
|
|
160
|
+
*/
|
|
161
|
+
endpoints?(route: string): Promise<RouteEndpointsAnswer>;
|
|
162
|
+
/**
|
|
163
|
+
* Read the route's configured balance endpoint.
|
|
164
|
+
*
|
|
165
|
+
* The provider card's balance row hydrates from this without touching the
|
|
166
|
+
* settings document or the credential store: it is one key-index read. A
|
|
167
|
+
* successful answer with `null`/no endpoint means "not configured", which is
|
|
168
|
+
* what keeps the provider row's balance chip absent.
|
|
169
|
+
*/
|
|
170
|
+
balanceEndpoint?(route: string): Promise<RouteBalanceAnswer>;
|
|
171
|
+
/** The last successful masked list, for an immediate re-open paint. */
|
|
172
|
+
cached?(route: string): KeyState | undefined;
|
|
119
173
|
/** Store a new key and list it, returning the list it produced. */
|
|
120
174
|
add(route: string, value: string, alias: string | undefined): Promise<KeyAnswer>;
|
|
121
175
|
/** Relabel one listed reference (undefined clears the label). */
|
|
@@ -135,13 +189,22 @@ export interface KeyManagerClient {
|
|
|
135
189
|
* The whole set travels together — the host stores it as one replacement —
|
|
136
190
|
* so callers merge with what the store holds first.
|
|
137
191
|
*/
|
|
138
|
-
setEndpoints(route: string, openai: string | undefined, anthropic: string | undefined
|
|
192
|
+
setEndpoints(route: string, openai: string | undefined, anthropic: string | undefined): Promise<KeyAnswer>;
|
|
193
|
+
/**
|
|
194
|
+
* Set (or clear, when blank) the route's balance endpoint.
|
|
195
|
+
*
|
|
196
|
+
* Kept apart from {@link setEndpoints}: the balance URL is display-only and
|
|
197
|
+
* must survive an address write from another card, just as the addresses must
|
|
198
|
+
* survive a balance edit.
|
|
199
|
+
*/
|
|
200
|
+
setBalanceEndpoint?(route: string, endpoint: string): Promise<KeyAnswer>;
|
|
139
201
|
/**
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
202
|
+
* Ask the host to probe every key of a multi-key route and check the
|
|
203
|
+
* probe-maintained scopes to what each key actually serves. The answer is
|
|
204
|
+
* the list as it stands when the run was queued — `probing` says the run is
|
|
205
|
+
* on, and the panel follows it to the assignments it writes.
|
|
143
206
|
*/
|
|
144
|
-
|
|
207
|
+
probe(route: string): Promise<KeyAnswer>;
|
|
145
208
|
/** The stored value of one listed reference, or undefined. */
|
|
146
209
|
reveal(route: string, ref: string): Promise<string | undefined>;
|
|
147
210
|
}
|
package/lib/client/locales.d.ts
CHANGED
|
@@ -70,6 +70,7 @@ export declare const en: {
|
|
|
70
70
|
effortRowLabel: string;
|
|
71
71
|
tagVision: string;
|
|
72
72
|
tagThinking: string;
|
|
73
|
+
tagImageGen: string;
|
|
73
74
|
sliderNoCurrent: string;
|
|
74
75
|
sliderCommitSlow: string;
|
|
75
76
|
defaultEffortLabel: string;
|
|
@@ -97,6 +98,8 @@ export declare const en: {
|
|
|
97
98
|
fpRetest: string;
|
|
98
99
|
fpRetry: string;
|
|
99
100
|
fpCost: string;
|
|
101
|
+
fpCostMinutes: string;
|
|
102
|
+
fpCostUnknown: string;
|
|
100
103
|
fpForget: string;
|
|
101
104
|
fpStateUnchecked: string;
|
|
102
105
|
fpStateRunning: string;
|
|
@@ -105,9 +108,14 @@ export declare const en: {
|
|
|
105
108
|
fpStateFailed: string;
|
|
106
109
|
fpQueued: string;
|
|
107
110
|
fpEvidence: string;
|
|
111
|
+
fpSimilarity: string;
|
|
108
112
|
fpDetailShow: string;
|
|
109
113
|
fpDetailHide: string;
|
|
110
114
|
fpFamily: string;
|
|
115
|
+
fpChallengeCounted: string;
|
|
116
|
+
fpChallengeRejected: string;
|
|
117
|
+
fpChallengeSkipped: string;
|
|
118
|
+
fpChallengeTitle: string;
|
|
111
119
|
fpCandidates: string;
|
|
112
120
|
fpClosedSet: string;
|
|
113
121
|
fpCheckedAt: string;
|
|
@@ -145,10 +153,15 @@ export declare const en: {
|
|
|
145
153
|
keysScopeCount: string;
|
|
146
154
|
keysScopeSaved: string;
|
|
147
155
|
keysScopeHint: string;
|
|
156
|
+
keysScopeAutoHint: string;
|
|
157
|
+
keysProbe: string;
|
|
158
|
+
keysProbing: string;
|
|
159
|
+
keysProbeHint: string;
|
|
160
|
+
keysProbeSingle: string;
|
|
161
|
+
keysProbeDone: string;
|
|
162
|
+
keysScopeObserved: string;
|
|
163
|
+
keysScopeObservedHint: string;
|
|
148
164
|
keysScopeEmpty: string;
|
|
149
|
-
keysMergedOffer: string;
|
|
150
|
-
keysMergedApply: string;
|
|
151
|
-
keysMergedApplied: string;
|
|
152
165
|
keysProtocolLabel: string;
|
|
153
166
|
keysProtocolCreate: string;
|
|
154
167
|
keysProtocolCreateHint: string;
|
|
@@ -160,15 +173,14 @@ export declare const en: {
|
|
|
160
173
|
keysProtocolOpenAIHint: string;
|
|
161
174
|
keysProtocolResponses: string;
|
|
162
175
|
keysProtocolResponsesHint: string;
|
|
163
|
-
keysProtocolGemini: string;
|
|
164
|
-
keysProtocolGeminiHint: string;
|
|
165
176
|
keysProtocolShortChat: string;
|
|
166
177
|
keysProtocolShortResponses: string;
|
|
167
178
|
keysProtocolShortAnthropic: string;
|
|
168
179
|
keysProtocolSaved: string;
|
|
169
180
|
keysEndpointOpenAI: string;
|
|
170
181
|
keysEndpointAnthropic: string;
|
|
171
|
-
|
|
182
|
+
keysEndpointBalance: string;
|
|
183
|
+
keysEndpointBalanceHint: string;
|
|
172
184
|
keysMoreEndpoints: string;
|
|
173
185
|
keysEndpointsCount: string;
|
|
174
186
|
keysEndpointInvalid: string;
|
|
@@ -200,6 +212,10 @@ export declare const en: {
|
|
|
200
212
|
providerReorderHint: string;
|
|
201
213
|
providerToggleAria: string;
|
|
202
214
|
providerToggleHint: string;
|
|
215
|
+
providerBalanceLabel: string;
|
|
216
|
+
providerBalanceHint: string;
|
|
217
|
+
providerBalanceRefresh: string;
|
|
218
|
+
providerBalanceUnavailable: string;
|
|
203
219
|
providerDisabledGroupShow: string;
|
|
204
220
|
providerDisabledGroupHide: string;
|
|
205
221
|
providerDisabledGroupHint: string;
|
|
@@ -207,6 +223,24 @@ export declare const en: {
|
|
|
207
223
|
providerRemoveLocked: string;
|
|
208
224
|
modelReorderAria: string;
|
|
209
225
|
modelReorderHint: string;
|
|
226
|
+
configButton: string;
|
|
227
|
+
configButtonHint: string;
|
|
228
|
+
configPaneTitle: string;
|
|
229
|
+
configPaneClose: string;
|
|
230
|
+
configPaneFailed: string;
|
|
231
|
+
imagegenSectionTitle: string;
|
|
232
|
+
imagegenLoading: string;
|
|
233
|
+
imagegenLoadFailed: string;
|
|
234
|
+
imagegenDefaultsLabel: string;
|
|
235
|
+
imagegenDefaultModelLabel: string;
|
|
236
|
+
imagegenDefaultModelNone: string;
|
|
237
|
+
imagegenSizeLabel: string;
|
|
238
|
+
imagegenQualityLabel: string;
|
|
239
|
+
imagegenCountLabel: string;
|
|
240
|
+
imagegenTimeoutLabel: string;
|
|
241
|
+
imagegenTimeoutMinutes: string;
|
|
242
|
+
imagegenTimeoutHint: string;
|
|
243
|
+
imagegenCardRunning: string;
|
|
210
244
|
};
|
|
211
245
|
/** The plugin's locale key union. */
|
|
212
246
|
export type BreKey = keyof typeof en;
|
|
@@ -35,6 +35,15 @@ export declare function modelOrderOf(provider: string): readonly string[];
|
|
|
35
35
|
export declare function setModelOrder(provider: string, next: readonly string[]): void;
|
|
36
36
|
/** Apply a map incoming from another tab (no persist: the writer already stored it). */
|
|
37
37
|
export declare function syncModelOrders(next: ModelOrderMap): void;
|
|
38
|
+
/**
|
|
39
|
+
* Replace the whole map with `next` AND persist it — the boot adoption of the
|
|
40
|
+
* synced order document (`order-sync.ts`). Like `syncModelOrders` it is a
|
|
41
|
+
* wholesale replace; unlike it, the map also lands in localStorage, because
|
|
42
|
+
* the writer here is the file sync, not another tab's own persisting store.
|
|
43
|
+
* Entries with no nameable model left are dropped, exactly as `parseModelOrders`
|
|
44
|
+
* drops them, so an adopted map is a parsed-map shape.
|
|
45
|
+
*/
|
|
46
|
+
export declare function adoptModelOrders(next: ModelOrderMap): void;
|
|
38
47
|
/** Subscribe to order changes; returns the disposer. */
|
|
39
48
|
export declare function subscribeModelOrders(listener: () => void): () => void;
|
|
40
49
|
/**
|
package/lib/client/ops.d.ts
CHANGED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The order document's sync: the browser half's provider/model orderings
|
|
3
|
+
* mirrored into the host's `ui-order.json` (ORDER_PATH).
|
|
4
|
+
*
|
|
5
|
+
* localStorage — the live stores' medium (provider-order.ts / model-order.ts)
|
|
6
|
+
* — is per-install and does not travel; the file does. The sync is a two-way
|
|
7
|
+
* last-writer-wins fold, arbitrated by the `savedAt` stamp each side carries:
|
|
8
|
+
*
|
|
9
|
+
* - Every local ORDER CHANGE is stamped into localStorage immediately (not
|
|
10
|
+
* when the push lands), so a page closed inside the debounce window still
|
|
11
|
+
* reads as the newer side at the next boot and pushes what it holds.
|
|
12
|
+
* - Boot pulls the file: a file newer than the local stamp is ADOPTED into
|
|
13
|
+
* the stores (and with them into localStorage, so the page and the
|
|
14
|
+
* composer follow without a reload); an older or absent file is
|
|
15
|
+
* overwritten by the local state — the seed after an upgrade, and the
|
|
16
|
+
* repair when a previous push never landed.
|
|
17
|
+
* - Every change is pushed, debounced, so a drag burst lands as one write;
|
|
18
|
+
* an adoption schedules nothing (the content already matches).
|
|
19
|
+
*
|
|
20
|
+
* The file holds no secrets — provider routes and model ids only — which is
|
|
21
|
+
* what makes it safe to point a sync tool at. Every fetch failure is silent:
|
|
22
|
+
* the local stores keep working, and the next boot reconciles.
|
|
23
|
+
*
|
|
24
|
+
* @module dsh-model-think-level/client/order-sync
|
|
25
|
+
*/
|
|
26
|
+
/** localStorage key of the last local order change (epoch ms; 0 = unstamped). */
|
|
27
|
+
export declare const ORDER_SAVED_AT_KEY = "dsh-model-think-level.order-saved-at";
|
|
28
|
+
/**
|
|
29
|
+
* Floor between a drag and its push. Long enough to fold a keyboard nudge
|
|
30
|
+
* burst into one write, short enough that closing the page right after a drag
|
|
31
|
+
* usually still lands (and `flushOrderSync` covers the rest).
|
|
32
|
+
*/
|
|
33
|
+
export declare const ORDER_PUSH_DEBOUNCE_MS = 400;
|
|
34
|
+
/** The wire shape of the order document (declared here; the host parses its own). */
|
|
35
|
+
export interface OrderDocumentView {
|
|
36
|
+
savedAt: number;
|
|
37
|
+
providerOrder: readonly string[];
|
|
38
|
+
modelOrder: Readonly<Record<string, readonly string[]>>;
|
|
39
|
+
/**
|
|
40
|
+
* The disabled set the document carries, or `undefined` when it names none —
|
|
41
|
+
* which is not the same as naming an empty one: an explicit empty array is a
|
|
42
|
+
* real "everything is on" a newer file can hold over a local disabled row,
|
|
43
|
+
* while an absent field is an old writer that never knew the field, and must
|
|
44
|
+
* not clear what this machine has.
|
|
45
|
+
*/
|
|
46
|
+
providersDisabled: readonly string[] | undefined;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Push any pending change immediately — the pagehide flush. A drag landing
|
|
50
|
+
* inside the debounce window would otherwise stay local until the next boot.
|
|
51
|
+
* The pending timer is cancelled with it: one change, one push.
|
|
52
|
+
*/
|
|
53
|
+
export declare function flushOrderSync(): void;
|
|
54
|
+
/**
|
|
55
|
+
* Boot pass: pull the file and arbitrate. Resolves once the decision has been
|
|
56
|
+
* acted on (adoption is synchronous; a push is fire-and-forget).
|
|
57
|
+
*/
|
|
58
|
+
export declare function reconcileOrderSync(): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Start the sync: the boot pass plus the change subscription. Returns the
|
|
61
|
+
* disposer; a disposed sync stops pushing and ignores the boot answer.
|
|
62
|
+
*/
|
|
63
|
+
export declare function startOrderSync(): () => void;
|