dsh-model-think-level 2.3.5 → 2.4.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 +197 -73
- package/lib/camouflage-store.d.ts +55 -0
- package/lib/camouflage.d.ts +91 -0
- package/lib/client/AdvancedPane.d.ts +38 -0
- package/lib/client/CamouflageEditor.d.ts +100 -0
- package/lib/client/ConfigPane.d.ts +2 -4
- package/lib/client/HeadersEditor.d.ts +21 -1
- package/lib/client/auto-continue-pref.d.ts +32 -14
- package/lib/client/injection/model-order-drag.d.ts +3 -1
- package/lib/client/locales.d.ts +18 -2
- package/lib/client/styles.d.ts +1 -1
- package/lib/client.js +320 -73
- package/lib/client.js.map +4 -4
- package/lib/constants.d.ts +14 -0
- package/lib/headers-core.d.ts +17 -2
- package/lib/index.js +336 -63
- package/lib/index.js.map +4 -4
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +6 -2
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The request-camouflage section of a provider's advanced configuration.
|
|
3
|
+
*
|
|
4
|
+
* It is a SECTION of the advanced pane, not a second card: it renders inside
|
|
5
|
+
* the request-header section's own container (`HeadersEditor` takes it as
|
|
6
|
+
* `extras`), below the header table and above the pane's single commit row, and
|
|
7
|
+
* separates itself from the headers with the same hairline the host draws
|
|
8
|
+
* between card sections. That is also what puts the pane's 取消/保存 under BOTH
|
|
9
|
+
* sections, which is the shape the pane was supposed to have: one form, one
|
|
10
|
+
* commit row.
|
|
11
|
+
*
|
|
12
|
+
* The choice is a DRAFT until the pane's Save runs. This module therefore only
|
|
13
|
+
* renders the switch; {@link useCamouflage} holds the draft, reads the stored
|
|
14
|
+
* value and commits it, and the pane wires the commit into its own Save. A
|
|
15
|
+
* preset that is clicked and then abandoned with 取消 never reaches the host.
|
|
16
|
+
*
|
|
17
|
+
* The create-provider card has no commit row of its own (its 保存 is the
|
|
18
|
+
* official one that declares the route), so it uses {@link CamouflageField}:
|
|
19
|
+
* the same switch, committed as soon as it is chosen — inert until the route
|
|
20
|
+
* exists, which is exactly the moment that card's 保存 creates it.
|
|
21
|
+
*
|
|
22
|
+
* @module dsh-model-think-level/client/CamouflageEditor
|
|
23
|
+
*/
|
|
24
|
+
import { type ReactNode } from 'react';
|
|
25
|
+
/** One identity the host understands. Kept in step with `camouflage.ts`. */
|
|
26
|
+
type CamouflagePreset = 'codex' | 'claude';
|
|
27
|
+
/** The switch's copy, as the host slot hands it down. */
|
|
28
|
+
type Copy = (key: string, params?: Record<string, string | number>) => string;
|
|
29
|
+
/** Everything the switch needs to paint: no reads, no writes. */
|
|
30
|
+
export interface CamouflageEditorProps {
|
|
31
|
+
/** Localized copy. */
|
|
32
|
+
t: Copy;
|
|
33
|
+
/** The draft the pane currently holds; `undefined` is 关闭. */
|
|
34
|
+
value: CamouflagePreset | undefined;
|
|
35
|
+
/** Whether this build's request seams are in place. */
|
|
36
|
+
installed: boolean;
|
|
37
|
+
/** Disable the options (the stored value is still being read). */
|
|
38
|
+
disabled?: boolean;
|
|
39
|
+
/** Report a choice; the pane decides when it is written. */
|
|
40
|
+
onChange: (next: CamouflagePreset | undefined) => void;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Render the disguise switch.
|
|
44
|
+
*
|
|
45
|
+
* Presentational on purpose: the pane's Save owns the write, so a click here
|
|
46
|
+
* changes what the form holds and nothing else.
|
|
47
|
+
* @param props - draft value, availability and the change sink.
|
|
48
|
+
* @returns the section.
|
|
49
|
+
*/
|
|
50
|
+
export declare function CamouflageEditor({ t, value, installed, disabled, onChange }: CamouflageEditorProps): ReactNode;
|
|
51
|
+
/** The draft one route's pane holds, plus the two seams the pane drives. */
|
|
52
|
+
export interface CamouflageDraft {
|
|
53
|
+
/** The value on screen — the draft, not necessarily the stored one. */
|
|
54
|
+
value: CamouflagePreset | undefined;
|
|
55
|
+
/** The value the host currently has, i.e. what 取消 restores. */
|
|
56
|
+
saved: CamouflagePreset | undefined;
|
|
57
|
+
/** Whether this build's request seams are in place. */
|
|
58
|
+
installed: boolean;
|
|
59
|
+
/** Whether the stored value is still being read. */
|
|
60
|
+
loading: boolean;
|
|
61
|
+
/** Replace the draft. Writes nothing. */
|
|
62
|
+
setValue: (next: CamouflagePreset | undefined) => void;
|
|
63
|
+
/** Restore the stored value (the pane's 取消). */
|
|
64
|
+
reset: () => void;
|
|
65
|
+
/**
|
|
66
|
+
* Write the draft, if it differs from the stored value.
|
|
67
|
+
*
|
|
68
|
+
* Rejects when the host route could not be reached, so the pane can keep
|
|
69
|
+
* itself open instead of dismissing over a write that did not happen.
|
|
70
|
+
* @param next - the value to write instead of the one on screen (an
|
|
71
|
+
* immediate-mode caller passes its own choice: state updates are async).
|
|
72
|
+
*/
|
|
73
|
+
commit: (next?: {
|
|
74
|
+
preset: CamouflagePreset | undefined;
|
|
75
|
+
}) => Promise<void>;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Read, hold and commit one route's disguise.
|
|
79
|
+
*
|
|
80
|
+
* The stored value is read once per route and seeds the draft; nothing is
|
|
81
|
+
* written until {@link CamouflageDraft.commit} runs.
|
|
82
|
+
* @param route - the provider route this pane edits.
|
|
83
|
+
* @param t - localized copy (for the error the caller renders).
|
|
84
|
+
* @returns the draft and its seams.
|
|
85
|
+
*/
|
|
86
|
+
export declare function useCamouflage(route: string, t: Copy): CamouflageDraft;
|
|
87
|
+
/**
|
|
88
|
+
* The create-provider card's copy of the section: the same switch, committed
|
|
89
|
+
* on click.
|
|
90
|
+
*
|
|
91
|
+
* That card has no commit row — the official 保存 declares the route the
|
|
92
|
+
* disguise is addressed to — so holding a draft here would have nothing to
|
|
93
|
+
* release it. The write is inert until that route exists, so choosing here and
|
|
94
|
+
* saving the card is still the one moment the identity starts being sent.
|
|
95
|
+
*/
|
|
96
|
+
export declare function CamouflageField({ route, t }: {
|
|
97
|
+
route: string;
|
|
98
|
+
t: Copy;
|
|
99
|
+
}): ReactNode;
|
|
100
|
+
export {};
|
|
@@ -30,10 +30,8 @@ export declare function ImageGenCard(props: {
|
|
|
30
30
|
t: (key: string, params?: Record<string, unknown>) => string;
|
|
31
31
|
}): ReactNode;
|
|
32
32
|
/**
|
|
33
|
-
* The 「自动继续」 card: one folded settings entry
|
|
34
|
-
*
|
|
35
|
-
* stays under the head, so the folded card keeps the same height as the
|
|
36
|
-
* 「生图」 card; the full what-triggers description folds into the body.
|
|
33
|
+
* The 「自动继续」 card: one folded settings entry with a quiet summary.
|
|
34
|
+
* The expanded card contains only the two compact controls.
|
|
37
35
|
*/
|
|
38
36
|
export declare function AutoContinueCard(props: {
|
|
39
37
|
t: (key: string, params?: Record<string, unknown>) => string;
|
|
@@ -102,6 +102,26 @@ export interface HeadersEditorProps {
|
|
|
102
102
|
* which is the write that declares the route the draft is addressed to.
|
|
103
103
|
*/
|
|
104
104
|
deferred?: DeferredHeaders;
|
|
105
|
+
/**
|
|
106
|
+
* Further sections of this pane, rendered above the commit row.
|
|
107
|
+
*
|
|
108
|
+
* The pane is the route's whole advanced configuration, not just headers:
|
|
109
|
+
* these render after the header table, inside the same section container, so
|
|
110
|
+
* the pane keeps ONE commit row and that row sits under every section. A
|
|
111
|
+
* sibling section rendered outside would need a commit row of its own, and
|
|
112
|
+
* two rows would make the pane read as two forms.
|
|
113
|
+
*/
|
|
114
|
+
extras?: ReactNode;
|
|
115
|
+
/**
|
|
116
|
+
* Commit the extras' draft as part of this pane's Save.
|
|
117
|
+
*
|
|
118
|
+
* Runs after the header write, before the card is dismissed. Rejecting keeps
|
|
119
|
+
* the pane open and reports an error: a dismissal over a write that did not
|
|
120
|
+
* happen would present the old state as the saved one.
|
|
121
|
+
*/
|
|
122
|
+
onCommitExtras?: () => Promise<void>;
|
|
123
|
+
/** Drop the extras' draft (this pane's 取消). */
|
|
124
|
+
onResetExtras?: () => void;
|
|
105
125
|
}
|
|
106
126
|
/** One editable header row; a stable `id` keeps React keys off the name. */
|
|
107
127
|
interface DraftRow {
|
|
@@ -122,5 +142,5 @@ export declare function headersFromDraft(draft: Draft): Record<string, string>;
|
|
|
122
142
|
* @param props - route identity, write seam, copy and the card dismiss seam.
|
|
123
143
|
* @returns the section.
|
|
124
144
|
*/
|
|
125
|
-
export declare function HeadersEditor({ route, api, t, onDismiss, deferred }: HeadersEditorProps): ReactNode;
|
|
145
|
+
export declare function HeadersEditor({ route, api, t, onDismiss, deferred, extras, onCommitExtras, onResetExtras, }: HeadersEditorProps): ReactNode;
|
|
126
146
|
export {};
|
|
@@ -1,33 +1,51 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The auto-continue
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* The auto-continue preferences live in localStorage, deliberately NOT
|
|
3
|
+
* settings.yaml: sending chat messages on the user's behalf defaults to OFF.
|
|
4
|
+
* The legacy enable key is retained; timing and retry limits use a separate
|
|
5
|
+
* versionable record so existing installations keep their explicit choice.
|
|
6
6
|
*
|
|
7
|
-
* Also here: the per-turn
|
|
8
|
-
*
|
|
9
|
-
* 「继续」; the claim (first writer wins, a fresh read losing to a stale one is
|
|
10
|
-
* bounded by the TTL) makes the second tab stand down. The claim outlives a
|
|
11
|
-
* reload on purpose: a page that reopens during the backoff window must not
|
|
12
|
-
* resend for a turn it already claimed.
|
|
7
|
+
* Also here: the per-turn claim preventing two tabs from answering the same
|
|
8
|
+
* interrupted turn. Claims outlive reloads and expire after ten minutes.
|
|
13
9
|
*
|
|
14
10
|
* @module dsh-model-think-level/client/auto-continue-pref
|
|
15
11
|
*/
|
|
16
12
|
/** localStorage key (own namespace, same convention as the slider pref). */
|
|
17
13
|
export declare const AUTO_CONTINUE_PREF_KEY = "dsh-model-think-level.auto-continue.enabled";
|
|
14
|
+
/** Timing and retry limit, independent of the enable switch. */
|
|
15
|
+
export declare const AUTO_CONTINUE_CONFIG_KEY = "dsh-model-think-level.auto-continue.config";
|
|
16
|
+
/** Bounded, whole-number settings exposed by the advanced-config card. */
|
|
17
|
+
export interface AutoContinueConfig {
|
|
18
|
+
readonly waitSeconds: number;
|
|
19
|
+
readonly maxRetries: number;
|
|
20
|
+
}
|
|
21
|
+
export declare const AUTO_CONTINUE_WAIT_MIN = 1;
|
|
22
|
+
export declare const AUTO_CONTINUE_WAIT_MAX = 3600;
|
|
23
|
+
export declare const AUTO_CONTINUE_RETRIES_MIN = 1;
|
|
24
|
+
export declare const AUTO_CONTINUE_RETRIES_MAX = 100;
|
|
25
|
+
export declare const DEFAULT_AUTO_CONTINUE_CONFIG: AutoContinueConfig;
|
|
26
|
+
/** Validate untrusted storage/input without ever producing an unbounded timer or retry chain. */
|
|
27
|
+
export declare function normalizeAutoContinueConfig(value: unknown): AutoContinueConfig;
|
|
28
|
+
/** Decode an incoming storage value; absent/malformed values restore safe defaults. */
|
|
29
|
+
export declare function parseAutoContinueConfig(value: string | null): AutoContinueConfig;
|
|
18
30
|
/** Snapshot the current preference (default OFF). */
|
|
19
31
|
export declare function autoContinueEnabled(): boolean;
|
|
32
|
+
/** Stable immutable snapshot, suitable for useSyncExternalStore. */
|
|
33
|
+
export declare function autoContinueConfig(): AutoContinueConfig;
|
|
20
34
|
/** Save the preference (persisted immediately; a failed write keeps the session value). */
|
|
21
35
|
export declare function setAutoContinueEnabled(next: boolean): void;
|
|
22
|
-
/**
|
|
36
|
+
/** Save just the requested fields; toggling OFF never discards the configured values. */
|
|
37
|
+
export declare function setAutoContinueConfig(patch: Partial<AutoContinueConfig>): void;
|
|
38
|
+
/** Apply a value incoming from another tab (the writer already persisted it). */
|
|
23
39
|
export declare function syncAutoContinueEnabled(next: boolean): void;
|
|
24
|
-
|
|
40
|
+
export declare function syncAutoContinueConfig(next: AutoContinueConfig): void;
|
|
41
|
+
/** Subscribe to enable changes; returns the disposer. */
|
|
25
42
|
export declare function subscribeAutoContinueEnabled(listener: () => void): () => void;
|
|
43
|
+
/** Subscribe to timing/retry-limit changes; returns the disposer. */
|
|
44
|
+
export declare function subscribeAutoContinueConfig(listener: () => void): () => void;
|
|
26
45
|
/**
|
|
27
46
|
* Try to claim one ended turn for THIS tab.
|
|
28
47
|
* @param sessionId - the session the turn belongs to.
|
|
29
48
|
* @param seq - the `turn/end` event's seq, unique per ending.
|
|
30
|
-
* @returns
|
|
31
|
-
* another tab claimed it first (or recently enough that its claim stands).
|
|
49
|
+
* @returns false when another tab already claimed this ending recently.
|
|
32
50
|
*/
|
|
33
51
|
export declare function claimTurn(sessionId: string, seq: number): boolean;
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
* Model-row drag reordering inside one provider's editor on the official Models
|
|
3
3
|
* settings page.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
5
|
+
* Older official editors render a provider's models as
|
|
6
6
|
* `div.modelList > div.modelEntry > div.modelRow` (a four-column grid: id,
|
|
7
7
|
* display name, and two icon buttons), straight from
|
|
8
8
|
* `models.map((model, index) => …)`. React owns those children, so — exactly as
|
|
9
9
|
* for the provider rows — a model is moved with a CSS `order`, and the id
|
|
10
10
|
* sequence that results is stored per provider by `../model-order.js`.
|
|
11
|
+
* Editors with a native `modelDragHandle` own both ordering and responsive
|
|
12
|
+
* layout; those lists must not receive another grip or a legacy grid override.
|
|
11
13
|
*
|
|
12
14
|
* Two differences from the provider list, and both are in the adapter:
|
|
13
15
|
* - the row is a grid of INPUTS, so only the grip drags. A drag that began on
|
package/lib/client/locales.d.ts
CHANGED
|
@@ -146,6 +146,9 @@ export declare const en: {
|
|
|
146
146
|
keysRenamed: string;
|
|
147
147
|
keysReplaced: string;
|
|
148
148
|
keysRemoved: string;
|
|
149
|
+
keysCopy: string;
|
|
150
|
+
keysCopied: string;
|
|
151
|
+
keysCopyFailed: string;
|
|
149
152
|
keysScope: string;
|
|
150
153
|
keysModels: string;
|
|
151
154
|
keysScopeAll: string;
|
|
@@ -188,6 +191,14 @@ export declare const en: {
|
|
|
188
191
|
keysLastEnabledOff: string;
|
|
189
192
|
headersTitle: string;
|
|
190
193
|
headersHint: string;
|
|
194
|
+
camouflageTitle: string;
|
|
195
|
+
camouflageHint: string;
|
|
196
|
+
camouflageOff: string;
|
|
197
|
+
camouflageCodex: string;
|
|
198
|
+
camouflageClaude: string;
|
|
199
|
+
camouflageSaved: string;
|
|
200
|
+
camouflageError: string;
|
|
201
|
+
camouflageUnavailable: string;
|
|
191
202
|
headersEmpty: string;
|
|
192
203
|
headersAdd: string;
|
|
193
204
|
headersName: string;
|
|
@@ -228,8 +239,8 @@ export declare const en: {
|
|
|
228
239
|
configPaneFailed: string;
|
|
229
240
|
imagegenSectionTitle: string;
|
|
230
241
|
imagegenEnable: string;
|
|
231
|
-
|
|
232
|
-
|
|
242
|
+
cardStateOn: string;
|
|
243
|
+
cardStateOff: string;
|
|
233
244
|
imagegenEnabledHint: string;
|
|
234
245
|
imagegenDisabledHint: string;
|
|
235
246
|
imagegenExpand: string;
|
|
@@ -256,6 +267,11 @@ export declare const en: {
|
|
|
256
267
|
autoContinueTitle: string;
|
|
257
268
|
autoContinueDescription: string;
|
|
258
269
|
autoContinueHint: string;
|
|
270
|
+
autoContinueWaitLabel: string;
|
|
271
|
+
autoContinueRetriesLabel: string;
|
|
272
|
+
autoContinueSecondsUnit: string;
|
|
273
|
+
autoContinueRetriesUnit: string;
|
|
274
|
+
autoContinueConfigHint: string;
|
|
259
275
|
autoContinueAria: string;
|
|
260
276
|
autoContinueMessage: string;
|
|
261
277
|
};
|