dsh-composer-ux 0.26.0 → 0.27.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/lib/client.js CHANGED
@@ -6,6 +6,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
7
  var __getProtoOf = Object.getPrototypeOf;
8
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __esm = (fn, res) => function __init() {
10
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
11
+ };
9
12
  var __export = (target, all) => {
10
13
  for (var name2 in all)
11
14
  __defProp(target, name2, { get: all[name2], enumerable: true });
@@ -28,407 +31,385 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
31
  ));
29
32
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
33
 
31
- // src/client.tsx
32
- var client_exports = {};
33
- __export(client_exports, {
34
- apply: () => apply,
35
- inject: () => inject,
36
- name: () => name
37
- });
38
- module.exports = __toCommonJS(client_exports);
39
- var import_dsh_client_store = require("@deepseek-ai/dsh-client-store");
40
-
41
34
  // src/provider-prices.ts
42
- var PROVIDER_PRICES_SNAPSHOT_AT = "2026-09-29";
43
- var BUILTIN_PROVIDER_PRICES = {
44
- "openai": {
45
- "gpt-3.5-turbo": { miss: 0.5, hit: 0, out: 1.5 },
46
- "gpt-4": { miss: 30, hit: 30, out: 60 },
47
- "gpt-4-turbo": { miss: 10, hit: 10, out: 30 },
48
- "gpt-4.1": { miss: 2, hit: 0.5, out: 8 },
49
- "gpt-4.1-mini": { miss: 0.4, hit: 0.1, out: 1.6 },
50
- "gpt-4.1-nano": { miss: 0.1, hit: 0.025, out: 0.4 },
51
- "gpt-4o": { miss: 2.5, hit: 1.25, out: 10 },
52
- "gpt-4o-2024-05-13": { miss: 5, hit: 5, out: 15 },
53
- "gpt-4o-2024-08-06": { miss: 2.5, hit: 1.25, out: 10 },
54
- "gpt-4o-2024-11-20": { miss: 2.5, hit: 1.25, out: 10 },
55
- "gpt-4o-mini": { miss: 0.15, hit: 0.075, out: 0.6 },
56
- "gpt-5": { miss: 1.25, hit: 0.125, out: 10 },
57
- "gpt-5-mini": { miss: 0.25, hit: 0.025, out: 2 },
58
- "gpt-5-nano": { miss: 0.05, hit: 5e-3, out: 0.4 },
59
- "gpt-5-pro": { miss: 15, hit: 15, out: 120 },
60
- "gpt-5.1": { miss: 1.25, hit: 0.125, out: 10 },
61
- "gpt-5.2": { miss: 1.75, hit: 0.175, out: 14 },
62
- "gpt-5.2-chat-latest": { miss: 1.75, hit: 0.175, out: 14 },
63
- "gpt-5.2-pro": { miss: 21, hit: 21, out: 168 },
64
- "gpt-5.3-chat-latest": { miss: 1.75, hit: 0.175, out: 14 },
65
- "gpt-5.3-codex": { miss: 1.75, hit: 0.175, out: 14 },
66
- "gpt-5.3-codex-spark": { miss: 1.75, hit: 0.175, out: 14 },
67
- "gpt-5.4": { miss: 2.5, hit: 0.25, out: 15 },
68
- "gpt-5.4-mini": { miss: 0.75, hit: 0.075, out: 4.5 },
69
- "gpt-5.4-nano": { miss: 0.2, hit: 0.02, out: 1.25 },
70
- "gpt-5.4-pro": { miss: 30, hit: 30, out: 180 },
71
- "gpt-5.5": { miss: 5, hit: 0.5, out: 30 },
72
- "gpt-5.5-pro": { miss: 30, hit: 30, out: 180 },
73
- "gpt-5.6": { miss: 4, hit: 0.4, out: 20 },
74
- "gpt-5.6-luna": { miss: 0.2, hit: 0.02, out: 1.2 },
75
- "gpt-5.6-sol": { miss: 4, hit: 0.4, out: 20 },
76
- "gpt-5.6-terra": { miss: 2, hit: 0.2, out: 12 },
77
- "gpt-6-astra": { miss: 10, hit: 1, out: 50 },
78
- "gpt-6-luna": { miss: 0.1, hit: 0.01, out: 0.5 },
79
- "gpt-6-sol": { miss: 2, hit: 0.2, out: 10 },
80
- "gpt-daybreak-blue-latest": { miss: 4, hit: 0.4, out: 20 },
81
- "gpt-daybreak-red-latest": { miss: 12.5, hit: 1.25, out: 75 },
82
- "gpt-image-2": { miss: 5, hit: 1.25, out: 30 },
83
- "gpt-realtime-2.1": { miss: 4, hit: 0.4, out: 24 },
84
- "o1": { miss: 15, hit: 7.5, out: 60 },
85
- "o1-pro": { miss: 150, hit: 150, out: 600 },
86
- "o3": { miss: 2, hit: 0.5, out: 8 },
87
- "o3-mini": { miss: 1.1, hit: 0.55, out: 4.4 },
88
- "o3-pro": { miss: 20, hit: 20, out: 80 },
89
- "o4-mini": { miss: 1.1, hit: 0.275, out: 4.4 },
90
- "text-embedding-3-large": { miss: 0.13, hit: 0.13, out: 0 },
91
- "text-embedding-3-small": { miss: 0.02, hit: 0.02, out: 0 },
92
- "text-embedding-ada-002": { miss: 0.1, hit: 0.1, out: 0 }
93
- },
94
- "anthropic": {
95
- "claude-fable-5": { miss: 10, hit: 1, out: 50 },
96
- "claude-fable-5-1": { miss: 10, hit: 0.25, out: 50 },
97
- "claude-haiku-4-5": { miss: 1, hit: 0.1, out: 5 },
98
- "claude-haiku-4-5-20251001": { miss: 1, hit: 0.1, out: 5 },
99
- "claude-opus-4-5": { miss: 5, hit: 0.5, out: 25 },
100
- "claude-opus-4-5-20251101": { miss: 5, hit: 0.5, out: 25 },
101
- "claude-opus-4-6": { miss: 5, hit: 0.5, out: 25 },
102
- "claude-opus-4-7": { miss: 5, hit: 0.5, out: 25 },
103
- "claude-opus-4-8": { miss: 5, hit: 0.5, out: 25 },
104
- "claude-opus-5": { miss: 5, hit: 0.5, out: 25 },
105
- "claude-opus-5-5": { miss: 4, hit: 0.2, out: 20 },
106
- "claude-sonnet-4-5": { miss: 3, hit: 0.3, out: 15 },
107
- "claude-sonnet-4-5-20250929": { miss: 3, hit: 0.3, out: 15 },
108
- "claude-sonnet-4-6": { miss: 3, hit: 0.3, out: 15 },
109
- "claude-sonnet-5": { miss: 2, hit: 0.2, out: 10 }
110
- },
111
- "google": {
112
- "deep-research-max-preview-04-2026": { miss: 2, hit: 0.2, out: 12 },
113
- "deep-research-preview-04-2026": { miss: 2, hit: 0.2, out: 12 },
114
- "gemini-2.5-computer-use-preview-10-2025": { miss: 1.25, hit: 1.25, out: 10 },
115
- "gemini-2.5-flash": { miss: 0.3, hit: 0.03, out: 2.5 },
116
- "gemini-2.5-flash-image": { miss: 0.3, hit: 0.075, out: 30 },
117
- "gemini-2.5-flash-lite": { miss: 0.1, hit: 0.01, out: 0.4 },
118
- "gemini-2.5-flash-preview-tts": { miss: 0.5, hit: 0.5, out: 10 },
119
- "gemini-2.5-pro": { miss: 1.25, hit: 0.125, out: 10 },
120
- "gemini-2.5-pro-preview-tts": { miss: 1, hit: 1, out: 20 },
121
- "gemini-3-flash-preview": { miss: 0.5, hit: 0.05, out: 3 },
122
- "gemini-3-pro-image": { miss: 2, hit: 2, out: 120 },
123
- "gemini-3-pro-image-preview": { miss: 2, hit: 2, out: 120 },
124
- "gemini-3.1-flash-image": { miss: 0.5, hit: 0.5, out: 60 },
125
- "gemini-3.1-flash-image-preview": { miss: 0.5, hit: 0.5, out: 60 },
126
- "gemini-3.1-flash-lite": { miss: 0.25, hit: 0.025, out: 1.5 },
127
- "gemini-3.1-flash-lite-image": { miss: 0.25, hit: 0.25, out: 30 },
128
- "gemini-3.1-flash-lite-preview": { miss: 0.25, hit: 0.025, out: 1.5 },
129
- "gemini-3.1-flash-live-preview": { miss: 0.75, hit: 0.75, out: 4.5 },
130
- "gemini-3.1-flash-tts-preview": { miss: 1, hit: 1, out: 20 },
131
- "gemini-3.1-pro-preview": { miss: 2, hit: 0.2, out: 12 },
132
- "gemini-3.1-pro-preview-customtools": { miss: 2, hit: 0.2, out: 12 },
133
- "gemini-3.5-flash": { miss: 1.5, hit: 0.15, out: 9 },
134
- "gemini-3.5-flash-lite": { miss: 0.3, hit: 0.03, out: 2.5 },
135
- "gemini-3.5-live-translate-preview": { miss: 3.5, hit: 3.5, out: 21 },
136
- "gemini-3.6-flash": { miss: 0.75, hit: 0.075, out: 3.75 },
137
- "gemini-3.7-flash": { miss: 0.75, hit: 0.075, out: 3.75 },
138
- "gemini-3.8-flash": { miss: 0.75, hit: 0.075, out: 3.75 },
139
- "gemini-embedding-001": { miss: 0.15, hit: 0.15, out: 0 },
140
- "gemini-embedding-2": { miss: 0.2, hit: 0.2, out: 0 },
141
- "gemini-flash-latest": { miss: 0.75, hit: 0.075, out: 3.75 },
142
- "gemini-flash-lite-latest": { miss: 0.3, hit: 0.03, out: 2.5 },
143
- "gemini-omni-flash-preview": { miss: 1.5, hit: 1.5, out: 17.5 },
144
- "lyria-3-clip-preview": { miss: 0, hit: 0, out: 0 },
145
- "lyria-3-pro-preview": { miss: 0, hit: 0, out: 0 }
146
- },
147
- "moonshotai": {
148
- "kimi-k2.6": { miss: 0.95, hit: 0.16, out: 4 },
149
- "kimi-k2.7-code": { miss: 0.95, hit: 0.19, out: 4 },
150
- "kimi-k2.7-code-highspeed": { miss: 1.9, hit: 0.38, out: 8 },
151
- "kimi-k3": { miss: 3, hit: 0.3, out: 15 }
152
- },
153
- "zhipuai": {
154
- "glm-4.5": { miss: 0.6, hit: 0.11, out: 2.2 },
155
- "glm-4.5-air": { miss: 0.2, hit: 0.03, out: 1.1 },
156
- "glm-4.5-flash": { miss: 0, hit: 0, out: 0 },
157
- "glm-4.5v": { miss: 0.6, hit: 0.6, out: 1.8 },
158
- "glm-4.6": { miss: 0.6, hit: 0.11, out: 2.2 },
159
- "glm-4.6v": { miss: 0.3, hit: 0.3, out: 0.9 },
160
- "glm-4.6v-flash": { miss: 0, hit: 0, out: 0 },
161
- "glm-4.7": { miss: 0.6, hit: 0.11, out: 2.2 },
162
- "glm-4.7-flash": { miss: 0, hit: 0, out: 0 },
163
- "glm-4.7-flashx": { miss: 0.07, hit: 0.01, out: 0.4 },
164
- "glm-5": { miss: 1, hit: 0.2, out: 3.2 },
165
- "glm-5.1": { miss: 1.4, hit: 0.26, out: 4.4 },
166
- "glm-5.2": { miss: 1.4, hit: 0.26, out: 4.4 },
167
- "glm-5.3": { miss: 1.4, hit: 0.26, out: 4.4 },
168
- "glm-5.3-flash": { miss: 0.15, hit: 0.03, out: 0.5 },
169
- "glm-5.3-flashx": { miss: 0.37, hit: 0.075, out: 1.25 },
170
- "glm-5v-turbo": { miss: 5, hit: 1.2, out: 22 }
171
- },
172
- "minimax": {
173
- "minimax-m2": { miss: 0.3, hit: 0.3, out: 1.2 },
174
- "minimax-m2.1": { miss: 0.3, hit: 0.03, out: 1.2 },
175
- "minimax-m2.5": { miss: 0.3, hit: 0.03, out: 1.2 },
176
- "minimax-m2.5-highspeed": { miss: 0.6, hit: 0.06, out: 2.4 },
177
- "minimax-m2.7": { miss: 0.3, hit: 0.06, out: 1.2 },
178
- "minimax-m2.7-highspeed": { miss: 0.6, hit: 0.06, out: 2.4 },
179
- "minimax-m3": { miss: 0.3, hit: 0.06, out: 1.2 }
180
- },
181
- "alibaba": {
182
- "deepseek-v4-flash-0731": { miss: 0.2, hit: 0.04, out: 0.4 },
183
- "glm-5.2": { miss: 1.4, hit: 0.28, out: 4.4 },
184
- "kimi-k3": { miss: 3, hit: 0.3, out: 15 },
185
- "qvq-max": { miss: 1.2, hit: 1.2, out: 4.8 },
186
- "qwen-flash": { miss: 0.05, hit: 0.05, out: 0.4 },
187
- "qwen-max": { miss: 1.6, hit: 1.6, out: 6.4 },
188
- "qwen-mt-plus": { miss: 2.46, hit: 2.46, out: 7.37 },
189
- "qwen-mt-turbo": { miss: 0.16, hit: 0.16, out: 0.49 },
190
- "qwen-omni-turbo": { miss: 0.07, hit: 0.07, out: 0.27 },
191
- "qwen-omni-turbo-realtime": { miss: 0.27, hit: 0.27, out: 1.07 },
192
- "qwen-plus": { miss: 0.4, hit: 0.4, out: 1.2 },
193
- "qwen-plus-character-ja": { miss: 0.5, hit: 0.5, out: 1.4 },
194
- "qwen-turbo": { miss: 0.05, hit: 0.05, out: 0.2 },
195
- "qwen-vl-max": { miss: 0.8, hit: 0.8, out: 3.2 },
196
- "qwen-vl-ocr": { miss: 0.72, hit: 0.72, out: 0.72 },
197
- "qwen-vl-plus": { miss: 0.21, hit: 0.21, out: 0.63 },
198
- "qwen2-5-14b-instruct": { miss: 0.35, hit: 0.35, out: 1.4 },
199
- "qwen2-5-32b-instruct": { miss: 0.7, hit: 0.7, out: 2.8 },
200
- "qwen2-5-72b-instruct": { miss: 1.4, hit: 1.4, out: 5.6 },
201
- "qwen2-5-7b-instruct": { miss: 0.175, hit: 0.175, out: 0.7 },
202
- "qwen2-5-omni-7b": { miss: 0.1, hit: 0.1, out: 0.4 },
203
- "qwen2-5-vl-72b-instruct": { miss: 2.8, hit: 2.8, out: 8.4 },
204
- "qwen2-5-vl-7b-instruct": { miss: 0.35, hit: 0.35, out: 1.05 },
205
- "qwen3-14b": { miss: 0.35, hit: 0.35, out: 1.4 },
206
- "qwen3-235b-a22b": { miss: 0.7, hit: 0.7, out: 2.8 },
207
- "qwen3-32b": { miss: 0.7, hit: 0.7, out: 2.8 },
208
- "qwen3-8b": { miss: 0.18, hit: 0.18, out: 0.7 },
209
- "qwen3-asr-flash": { miss: 0.035, hit: 0.035, out: 0.035 },
210
- "qwen3-coder-30b-a3b-instruct": { miss: 0.45, hit: 0.45, out: 2.25 },
211
- "qwen3-coder-480b-a35b-instruct": { miss: 1.5, hit: 1.5, out: 7.5 },
212
- "qwen3-coder-flash": { miss: 0.3, hit: 0.3, out: 1.5 },
213
- "qwen3-coder-plus": { miss: 1, hit: 1, out: 5 },
214
- "qwen3-livetranslate-flash-realtime": { miss: 10, hit: 10, out: 10 },
215
- "qwen3-max": { miss: 1.2, hit: 1.2, out: 6 },
216
- "qwen3-next-80b-a3b-instruct": { miss: 0.5, hit: 0.5, out: 2 },
217
- "qwen3-next-80b-a3b-thinking": { miss: 0.5, hit: 0.5, out: 6 },
218
- "qwen3-omni-flash": { miss: 0.43, hit: 0.43, out: 1.66 },
219
- "qwen3-omni-flash-realtime": { miss: 0.52, hit: 0.52, out: 1.99 },
220
- "qwen3-vl-235b-a22b": { miss: 0.7, hit: 0.7, out: 2.8 },
221
- "qwen3-vl-30b-a3b": { miss: 0.2, hit: 0.2, out: 0.8 },
222
- "qwen3-vl-plus": { miss: 0.2, hit: 0.2, out: 1.6 },
223
- "qwen3.5-122b-a10b": { miss: 0.4, hit: 0.4, out: 3.2 },
224
- "qwen3.5-27b": { miss: 0.3, hit: 0.3, out: 2.4 },
225
- "qwen3.5-35b-a3b": { miss: 0.25, hit: 0.25, out: 2 },
226
- "qwen3.5-397b-a17b": { miss: 0.6, hit: 0.6, out: 3.6 },
227
- "qwen3.5-flash": { miss: 0.1, hit: 0.01, out: 0.4 },
228
- "qwen3.5-plus": { miss: 0.4, hit: 0.4, out: 2.4 },
229
- "qwen3.6-27b": { miss: 0.6, hit: 0.6, out: 3.6 },
230
- "qwen3.6-35b-a3b": { miss: 0.248, hit: 0.248, out: 1.485 },
231
- "qwen3.6-flash": { miss: 0.1875, hit: 0.1875, out: 1.125 },
232
- "qwen3.6-max-preview": { miss: 1.3, hit: 0.13, out: 7.8 },
233
- "qwen3.6-plus": { miss: 0.5, hit: 0.05, out: 3 },
234
- "qwen3.7-flash": { miss: 0.03, hit: 3e-3, out: 0.13 },
235
- "qwen3.7-max": { miss: 2.5, hit: 0.5, out: 7.5 },
236
- "qwen3.7-plus": { miss: 0.4, hit: 0.04, out: 1.6 },
237
- "qwen3.8-flash": { miss: 0.15, hit: 0.016, out: 0.47 },
238
- "qwen3.8-max": { miss: 2, hit: 0.25, out: 6 },
239
- "qwen3.8-omni-flash": { miss: 0.15, hit: 0.016, out: 0.47 },
240
- "qwq-plus": { miss: 0.8, hit: 0.8, out: 2.4 }
241
- },
242
- "xai": {
243
- "grok-4.20-0309-non-reasoning": { miss: 1.25, hit: 0.2, out: 2.5 },
244
- "grok-4.20-0309-reasoning": { miss: 1.25, hit: 0.2, out: 2.5 },
245
- "grok-4.20-multi-agent-0309": { miss: 1.25, hit: 0.2, out: 2.5 },
246
- "grok-4.3": { miss: 1.25, hit: 0.2, out: 2.5 },
247
- "grok-4.5": { miss: 2, hit: 0.3, out: 6 },
248
- "grok-4.6": { miss: 2, hit: 0.5, out: 6 },
249
- "grok-4.7": { miss: 2, hit: 0.5, out: 6 },
250
- "grok-build-0.1": { miss: 1, hit: 0.2, out: 2 }
251
- },
252
- "xiaomi": {
253
- "mimo-v2-flash": { miss: 0.14, hit: 28e-4, out: 0.28 },
254
- "mimo-v2-omni": { miss: 0.14, hit: 28e-4, out: 0.28 },
255
- "mimo-v2-pro": { miss: 0.435, hit: 36e-4, out: 0.87 },
256
- "mimo-v2.5": { miss: 0.14, hit: 28e-4, out: 0.28 },
257
- "mimo-v2.5-pro": { miss: 0.435, hit: 36e-4, out: 0.87 },
258
- "mimo-v2.5-pro-ultraspeed": { miss: 1.305, hit: 0.0108, out: 2.61 },
259
- "mimo-v2.6-flash": { miss: 0.14, hit: 28e-4, out: 0.28 },
260
- "mimo-v2.6-pro": { miss: 0.435, hit: 36e-4, out: 0.87 },
261
- "mimo-v2.6-pro-ultraspeed": { miss: 4.35, hit: 0.036, out: 8.7 }
262
- },
263
- "opencode": {
264
- "big-pickle": { miss: 0, hit: 0, out: 0 },
265
- "claude-3-5-haiku": { miss: 0.8, hit: 0.08, out: 4 },
266
- "claude-fable-5": { miss: 10, hit: 1, out: 50 },
267
- "claude-fable-5-1": { miss: 10, hit: 0.25, out: 50 },
268
- "claude-haiku-4-5": { miss: 1, hit: 0.1, out: 5 },
269
- "claude-opus-4-1": { miss: 15, hit: 1.5, out: 75 },
270
- "claude-opus-4-5": { miss: 5, hit: 0.5, out: 25 },
271
- "claude-opus-4-6": { miss: 5, hit: 0.5, out: 25 },
272
- "claude-opus-4-7": { miss: 5, hit: 0.5, out: 25 },
273
- "claude-opus-4-8": { miss: 5, hit: 0.5, out: 25 },
274
- "claude-opus-5": { miss: 5, hit: 0.5, out: 25 },
275
- "claude-opus-5-5": { miss: 4, hit: 0.2, out: 20 },
276
- "claude-sonnet-4": { miss: 3, hit: 0.3, out: 15 },
277
- "claude-sonnet-4-5": { miss: 3, hit: 0.3, out: 15 },
278
- "claude-sonnet-4-6": { miss: 3, hit: 0.3, out: 15 },
279
- "claude-sonnet-5": { miss: 2, hit: 0.2, out: 10 },
280
- "deepseek-v4-flash": { miss: 0.14, hit: 0.028, out: 0.28 },
281
- "deepseek-v4-flash-free": { miss: 0, hit: 0, out: 0 },
282
- "deepseek-v4-flash-vision-exp": { miss: 0.14, hit: 0.028, out: 0.28 },
283
- "deepseek-v4-pro": { miss: 1.74, hit: 0.145, out: 3.84 },
284
- "deepseek-v4.1-flash": { miss: 0.3, hit: 6e-3, out: 1.2 },
285
- "gemini-3-flash": { miss: 0.5, hit: 0.05, out: 3 },
286
- "gemini-3-pro": { miss: 2, hit: 0.2, out: 12 },
287
- "gemini-3.1-pro": { miss: 2, hit: 0.2, out: 12 },
288
- "gemini-3.5-flash": { miss: 1.5, hit: 0.15, out: 9 },
289
- "gemini-3.5-flash-lite": { miss: 0.3, hit: 0.03, out: 2.5 },
290
- "gemini-3.6-flash": { miss: 1.5, hit: 0.15, out: 7.5 },
291
- "gemini-3.7-flash": { miss: 1.5, hit: 0.15, out: 7.5 },
292
- "gemini-3.8-flash": { miss: 1.5, hit: 0.15, out: 7.5 },
293
- "glm-4.6": { miss: 0.6, hit: 0.1, out: 2.2 },
294
- "glm-4.7": { miss: 0.6, hit: 0.1, out: 2.2 },
295
- "glm-4.7-free": { miss: 0, hit: 0, out: 0 },
296
- "glm-5": { miss: 1, hit: 0.2, out: 3.2 },
297
- "glm-5-free": { miss: 0, hit: 0, out: 0 },
298
- "glm-5.1": { miss: 1.4, hit: 0.26, out: 4.4 },
299
- "glm-5.2": { miss: 1.4, hit: 0.26, out: 4.4 },
300
- "glm-5.3": { miss: 1.4, hit: 0.26, out: 4.4 },
301
- "glm-5.3-flash": { miss: 0.15, hit: 0.03, out: 0.5 },
302
- "gpt-5": { miss: 1.07, hit: 0.107, out: 8.5 },
303
- "gpt-5-codex": { miss: 1.07, hit: 0.107, out: 8.5 },
304
- "gpt-5-nano": { miss: 0.05, hit: 5e-3, out: 0.4 },
305
- "gpt-5.1": { miss: 1.07, hit: 0.107, out: 8.5 },
306
- "gpt-5.1-codex": { miss: 1.07, hit: 0.107, out: 8.5 },
307
- "gpt-5.1-codex-max": { miss: 1.25, hit: 0.125, out: 10 },
308
- "gpt-5.1-codex-mini": { miss: 0.25, hit: 0.025, out: 2 },
309
- "gpt-5.2": { miss: 1.75, hit: 0.175, out: 14 },
310
- "gpt-5.2-codex": { miss: 1.75, hit: 0.175, out: 14 },
311
- "gpt-5.3-codex": { miss: 1.75, hit: 0.175, out: 14 },
312
- "gpt-5.3-codex-spark": { miss: 1.75, hit: 0.175, out: 14 },
313
- "gpt-5.4": { miss: 2.5, hit: 0.25, out: 15 },
314
- "gpt-5.4-mini": { miss: 0.75, hit: 0.075, out: 4.5 },
315
- "gpt-5.4-nano": { miss: 0.2, hit: 0.02, out: 1.25 },
316
- "gpt-5.4-pro": { miss: 30, hit: 30, out: 180 },
317
- "gpt-5.5": { miss: 5, hit: 0.5, out: 30 },
318
- "gpt-5.5-pro": { miss: 30, hit: 30, out: 180 },
319
- "gpt-5.6-luna": { miss: 0.2, hit: 0.02, out: 1.2 },
320
- "gpt-5.6-sol": { miss: 4, hit: 0.4, out: 20 },
321
- "gpt-5.6-terra": { miss: 2.5, hit: 0.25, out: 15 },
322
- "gpt-6-astra": { miss: 10, hit: 1, out: 50 },
323
- "gpt-6-luna": { miss: 0.1, hit: 0.01, out: 0.5 },
324
- "gpt-6-sol": { miss: 2, hit: 0.2, out: 10 },
325
- "grok-4.5": { miss: 2, hit: 0.3, out: 6 },
326
- "grok-4.6": { miss: 2, hit: 0.5, out: 6 },
327
- "grok-4.7": { miss: 1.4, hit: 0.35, out: 4.2 },
328
- "grok-build-0.1": { miss: 1, hit: 0.2, out: 2 },
329
- "grok-code": { miss: 0, hit: 0, out: 0 },
330
- "hy3-free": { miss: 0, hit: 0, out: 0 },
331
- "hy3-preview-free": { miss: 0, hit: 0, out: 0 },
332
- "kimi-k2": { miss: 0.4, hit: 0.4, out: 2.5 },
333
- "kimi-k2-thinking": { miss: 0.4, hit: 0.4, out: 2.5 },
334
- "kimi-k2.5": { miss: 0.6, hit: 0.08, out: 3 },
335
- "kimi-k2.5-free": { miss: 0, hit: 0, out: 0 },
336
- "kimi-k2.6": { miss: 0.95, hit: 0.16, out: 4 },
337
- "kimi-k2.7-code": { miss: 0.95, hit: 0.19, out: 4 },
338
- "kimi-k3": { miss: 3, hit: 0.3, out: 15 },
339
- "laguna-s-2.1-free": { miss: 0, hit: 0, out: 0 },
340
- "ling-2.6-flash-free": { miss: 0, hit: 0, out: 0 },
341
- "ling-3.0-flash-fin-free": { miss: 0, hit: 0, out: 0 },
342
- "ling-3.0-flash-free": { miss: 0, hit: 0, out: 0 },
343
- "ling-3.0-tiny-free": { miss: 0, hit: 0, out: 0 },
344
- "longcat-2.0-free": { miss: 0, hit: 0, out: 0 },
345
- "longcat-2.5-preview-free": { miss: 0, hit: 0, out: 0 },
346
- "mimo-v2-flash-free": { miss: 0, hit: 0, out: 0 },
347
- "mimo-v2-omni-free": { miss: 0, hit: 0, out: 0 },
348
- "mimo-v2-pro-free": { miss: 0, hit: 0, out: 0 },
349
- "mimo-v2.5-free": { miss: 0, hit: 0, out: 0 },
350
- "mimo-v2.6-flash-free": { miss: 0, hit: 0, out: 0 },
351
- "minimax-m2.1": { miss: 0.3, hit: 0.1, out: 1.2 },
352
- "minimax-m2.1-free": { miss: 0, hit: 0, out: 0 },
353
- "minimax-m2.5": { miss: 0.3, hit: 0.06, out: 1.2 },
354
- "minimax-m2.5-free": { miss: 0, hit: 0, out: 0 },
355
- "minimax-m2.7": { miss: 0.3, hit: 0.06, out: 1.2 },
356
- "minimax-m3": { miss: 0.3, hit: 0.06, out: 1.2 },
357
- "minimax-m3-free": { miss: 0, hit: 0, out: 0 },
358
- "muse-spark-1.2": { miss: 1.25, hit: 0.15, out: 4.25 },
359
- "muse-spark-1.2-contributor-free": { miss: 0, hit: 0, out: 0 },
360
- "muse-spark-1.3": { miss: 1.25, hit: 0.15, out: 4.25 },
361
- "muse-spark-1.3-contributor-free": { miss: 0, hit: 0, out: 0 },
362
- "nemotron-3-super-free": { miss: 0, hit: 0, out: 0 },
363
- "nemotron-3-ultra-free": { miss: 0, hit: 0, out: 0 },
364
- "nemotron-3.5-lightning-free": { miss: 0, hit: 0, out: 0 },
365
- "north-mini-code-free": { miss: 0, hit: 0, out: 0 },
366
- "qwen3-coder": { miss: 0.45, hit: 0.45, out: 1.8 },
367
- "qwen3.5-plus": { miss: 0.2, hit: 0.02, out: 1.2 },
368
- "qwen3.6-plus": { miss: 0.5, hit: 0.05, out: 3 },
369
- "qwen3.6-plus-free": { miss: 0, hit: 0, out: 0 },
370
- "qwen3.8-flash": { miss: 0.15, hit: 0.016, out: 0.47 },
371
- "qwen3.8-max": { miss: 2, hit: 0.25, out: 6 },
372
- "ring-2.6-1t-free": { miss: 0, hit: 0, out: 0 },
373
- "space-bunny-free": { miss: 0, hit: 0, out: 0 },
374
- "trinity-large-preview-free": { miss: 0, hit: 0, out: 0 },
375
- "x-preview-f-free": { miss: 0, hit: 0, out: 0 }
376
- },
377
- "opencode-go": {
378
- "deepseek-v4-flash": { miss: 0.15, hit: 3e-3, out: 0.6 },
379
- "deepseek-v4-flash-vision-exp": { miss: 0.15, hit: 3e-3, out: 0.6 },
380
- "deepseek-v4-pro": { miss: 0.66, hit: 0.022, out: 1.98 },
381
- "deepseek-v4.1-flash": { miss: 0.15, hit: 3e-3, out: 0.6 },
382
- "glm-5.2": { miss: 1.4, hit: 0.26, out: 4.4 },
383
- "glm-5.3": { miss: 1.4, hit: 0.26, out: 4.4 },
384
- "glm-5.3-flash": { miss: 0.15, hit: 0.03, out: 0.5 },
385
- "gpt-5.6-luna": { miss: 0.2, hit: 0.02, out: 1.2 },
386
- "gpt-6-luna": { miss: 0.1, hit: 0.01, out: 0.5 },
387
- "grok-4.5": { miss: 2, hit: 0.3, out: 6 },
388
- "grok-4.6": { miss: 2, hit: 0.5, out: 6 },
389
- "grok-4.7": { miss: 2, hit: 0.5, out: 6 },
390
- "hy3": { miss: 0.14, hit: 0.035, out: 0.58 },
391
- "hy4-preview": { miss: 0.834, hit: 0.042, out: 2.501 },
392
- "kimi-k2.6": { miss: 0.95, hit: 0.16, out: 4 },
393
- "kimi-k2.7-code": { miss: 0.95, hit: 0.19, out: 4 },
394
- "kimi-k3": { miss: 3, hit: 0.3, out: 15 },
395
- "longcat-2.0": { miss: 0.3, hit: 6e-3, out: 1.2 },
396
- "longcat-2.5-preview-free": { miss: 0, hit: 0, out: 0 },
397
- "mimo-v2.5": { miss: 0.14, hit: 28e-4, out: 0.28 },
398
- "mimo-v2.5-pro": { miss: 0.435, hit: 3625e-6, out: 0.87 },
399
- "mimo-v2.6-flash": { miss: 0.14, hit: 28e-4, out: 0.28 },
400
- "mimo-v2.6-pro": { miss: 0.435, hit: 3625e-6, out: 0.87 },
401
- "minimax-m2.7": { miss: 0.3, hit: 0.06, out: 1.2 },
402
- "minimax-m3": { miss: 0.3, hit: 0.06, out: 1.2 },
403
- "muse-spark-1.2-contributor": { miss: 0.1, hit: 2e-3, out: 0.2 },
404
- "muse-spark-1.3-contributor": { miss: 0.1, hit: 2e-3, out: 0.2 },
405
- "qwen3.6-plus": { miss: 0.5, hit: 0.05, out: 3 },
406
- "qwen3.7-max": { miss: 2.5, hit: 0.5, out: 7.5 },
407
- "qwen3.7-plus": { miss: 0.4, hit: 0.04, out: 1.6 },
408
- "qwen3.8-flash": { miss: 0.15, hit: 0.016, out: 0.47 },
409
- "qwen3.8-max": { miss: 2, hit: 0.25, out: 6 },
410
- "space-bunny-free": { miss: 0, hit: 0, out: 0 }
35
+ var PROVIDER_PRICES_SNAPSHOT_AT, BUILTIN_PROVIDER_PRICES;
36
+ var init_provider_prices = __esm({
37
+ "src/provider-prices.ts"() {
38
+ PROVIDER_PRICES_SNAPSHOT_AT = "2026-09-29";
39
+ BUILTIN_PROVIDER_PRICES = {
40
+ "openai": {
41
+ "gpt-3.5-turbo": { miss: 0.5, hit: 0, out: 1.5 },
42
+ "gpt-4": { miss: 30, hit: 30, out: 60 },
43
+ "gpt-4-turbo": { miss: 10, hit: 10, out: 30 },
44
+ "gpt-4.1": { miss: 2, hit: 0.5, out: 8 },
45
+ "gpt-4.1-mini": { miss: 0.4, hit: 0.1, out: 1.6 },
46
+ "gpt-4.1-nano": { miss: 0.1, hit: 0.025, out: 0.4 },
47
+ "gpt-4o": { miss: 2.5, hit: 1.25, out: 10 },
48
+ "gpt-4o-2024-05-13": { miss: 5, hit: 5, out: 15 },
49
+ "gpt-4o-2024-08-06": { miss: 2.5, hit: 1.25, out: 10 },
50
+ "gpt-4o-2024-11-20": { miss: 2.5, hit: 1.25, out: 10 },
51
+ "gpt-4o-mini": { miss: 0.15, hit: 0.075, out: 0.6 },
52
+ "gpt-5": { miss: 1.25, hit: 0.125, out: 10 },
53
+ "gpt-5-mini": { miss: 0.25, hit: 0.025, out: 2 },
54
+ "gpt-5-nano": { miss: 0.05, hit: 5e-3, out: 0.4 },
55
+ "gpt-5-pro": { miss: 15, hit: 15, out: 120 },
56
+ "gpt-5.1": { miss: 1.25, hit: 0.125, out: 10 },
57
+ "gpt-5.2": { miss: 1.75, hit: 0.175, out: 14 },
58
+ "gpt-5.2-chat-latest": { miss: 1.75, hit: 0.175, out: 14 },
59
+ "gpt-5.2-pro": { miss: 21, hit: 21, out: 168 },
60
+ "gpt-5.3-chat-latest": { miss: 1.75, hit: 0.175, out: 14 },
61
+ "gpt-5.3-codex": { miss: 1.75, hit: 0.175, out: 14 },
62
+ "gpt-5.3-codex-spark": { miss: 1.75, hit: 0.175, out: 14 },
63
+ "gpt-5.4": { miss: 2.5, hit: 0.25, out: 15 },
64
+ "gpt-5.4-mini": { miss: 0.75, hit: 0.075, out: 4.5 },
65
+ "gpt-5.4-nano": { miss: 0.2, hit: 0.02, out: 1.25 },
66
+ "gpt-5.4-pro": { miss: 30, hit: 30, out: 180 },
67
+ "gpt-5.5": { miss: 5, hit: 0.5, out: 30 },
68
+ "gpt-5.5-pro": { miss: 30, hit: 30, out: 180 },
69
+ "gpt-5.6": { miss: 4, hit: 0.4, out: 20 },
70
+ "gpt-5.6-luna": { miss: 0.2, hit: 0.02, out: 1.2 },
71
+ "gpt-5.6-sol": { miss: 4, hit: 0.4, out: 20 },
72
+ "gpt-5.6-terra": { miss: 2, hit: 0.2, out: 12 },
73
+ "gpt-6-astra": { miss: 10, hit: 1, out: 50 },
74
+ "gpt-6-luna": { miss: 0.1, hit: 0.01, out: 0.5 },
75
+ "gpt-6-sol": { miss: 2, hit: 0.2, out: 10 },
76
+ "gpt-daybreak-blue-latest": { miss: 4, hit: 0.4, out: 20 },
77
+ "gpt-daybreak-red-latest": { miss: 12.5, hit: 1.25, out: 75 },
78
+ "gpt-image-2": { miss: 5, hit: 1.25, out: 30 },
79
+ "gpt-realtime-2.1": { miss: 4, hit: 0.4, out: 24 },
80
+ "o1": { miss: 15, hit: 7.5, out: 60 },
81
+ "o1-pro": { miss: 150, hit: 150, out: 600 },
82
+ "o3": { miss: 2, hit: 0.5, out: 8 },
83
+ "o3-mini": { miss: 1.1, hit: 0.55, out: 4.4 },
84
+ "o3-pro": { miss: 20, hit: 20, out: 80 },
85
+ "o4-mini": { miss: 1.1, hit: 0.275, out: 4.4 },
86
+ "text-embedding-3-large": { miss: 0.13, hit: 0.13, out: 0 },
87
+ "text-embedding-3-small": { miss: 0.02, hit: 0.02, out: 0 },
88
+ "text-embedding-ada-002": { miss: 0.1, hit: 0.1, out: 0 }
89
+ },
90
+ "anthropic": {
91
+ "claude-fable-5": { miss: 10, hit: 1, out: 50 },
92
+ "claude-fable-5-1": { miss: 10, hit: 0.25, out: 50 },
93
+ "claude-haiku-4-5": { miss: 1, hit: 0.1, out: 5 },
94
+ "claude-haiku-4-5-20251001": { miss: 1, hit: 0.1, out: 5 },
95
+ "claude-opus-4-5": { miss: 5, hit: 0.5, out: 25 },
96
+ "claude-opus-4-5-20251101": { miss: 5, hit: 0.5, out: 25 },
97
+ "claude-opus-4-6": { miss: 5, hit: 0.5, out: 25 },
98
+ "claude-opus-4-7": { miss: 5, hit: 0.5, out: 25 },
99
+ "claude-opus-4-8": { miss: 5, hit: 0.5, out: 25 },
100
+ "claude-opus-5": { miss: 5, hit: 0.5, out: 25 },
101
+ "claude-opus-5-5": { miss: 4, hit: 0.2, out: 20 },
102
+ "claude-sonnet-4-5": { miss: 3, hit: 0.3, out: 15 },
103
+ "claude-sonnet-4-5-20250929": { miss: 3, hit: 0.3, out: 15 },
104
+ "claude-sonnet-4-6": { miss: 3, hit: 0.3, out: 15 },
105
+ "claude-sonnet-5": { miss: 2, hit: 0.2, out: 10 }
106
+ },
107
+ "google": {
108
+ "deep-research-max-preview-04-2026": { miss: 2, hit: 0.2, out: 12 },
109
+ "deep-research-preview-04-2026": { miss: 2, hit: 0.2, out: 12 },
110
+ "gemini-2.5-computer-use-preview-10-2025": { miss: 1.25, hit: 1.25, out: 10 },
111
+ "gemini-2.5-flash": { miss: 0.3, hit: 0.03, out: 2.5 },
112
+ "gemini-2.5-flash-image": { miss: 0.3, hit: 0.075, out: 30 },
113
+ "gemini-2.5-flash-lite": { miss: 0.1, hit: 0.01, out: 0.4 },
114
+ "gemini-2.5-flash-preview-tts": { miss: 0.5, hit: 0.5, out: 10 },
115
+ "gemini-2.5-pro": { miss: 1.25, hit: 0.125, out: 10 },
116
+ "gemini-2.5-pro-preview-tts": { miss: 1, hit: 1, out: 20 },
117
+ "gemini-3-flash-preview": { miss: 0.5, hit: 0.05, out: 3 },
118
+ "gemini-3-pro-image": { miss: 2, hit: 2, out: 120 },
119
+ "gemini-3-pro-image-preview": { miss: 2, hit: 2, out: 120 },
120
+ "gemini-3.1-flash-image": { miss: 0.5, hit: 0.5, out: 60 },
121
+ "gemini-3.1-flash-image-preview": { miss: 0.5, hit: 0.5, out: 60 },
122
+ "gemini-3.1-flash-lite": { miss: 0.25, hit: 0.025, out: 1.5 },
123
+ "gemini-3.1-flash-lite-image": { miss: 0.25, hit: 0.25, out: 30 },
124
+ "gemini-3.1-flash-lite-preview": { miss: 0.25, hit: 0.025, out: 1.5 },
125
+ "gemini-3.1-flash-live-preview": { miss: 0.75, hit: 0.75, out: 4.5 },
126
+ "gemini-3.1-flash-tts-preview": { miss: 1, hit: 1, out: 20 },
127
+ "gemini-3.1-pro-preview": { miss: 2, hit: 0.2, out: 12 },
128
+ "gemini-3.1-pro-preview-customtools": { miss: 2, hit: 0.2, out: 12 },
129
+ "gemini-3.5-flash": { miss: 1.5, hit: 0.15, out: 9 },
130
+ "gemini-3.5-flash-lite": { miss: 0.3, hit: 0.03, out: 2.5 },
131
+ "gemini-3.5-live-translate-preview": { miss: 3.5, hit: 3.5, out: 21 },
132
+ "gemini-3.6-flash": { miss: 0.75, hit: 0.075, out: 3.75 },
133
+ "gemini-3.7-flash": { miss: 0.75, hit: 0.075, out: 3.75 },
134
+ "gemini-3.8-flash": { miss: 0.75, hit: 0.075, out: 3.75 },
135
+ "gemini-embedding-001": { miss: 0.15, hit: 0.15, out: 0 },
136
+ "gemini-embedding-2": { miss: 0.2, hit: 0.2, out: 0 },
137
+ "gemini-flash-latest": { miss: 0.75, hit: 0.075, out: 3.75 },
138
+ "gemini-flash-lite-latest": { miss: 0.3, hit: 0.03, out: 2.5 },
139
+ "gemini-omni-flash-preview": { miss: 1.5, hit: 1.5, out: 17.5 },
140
+ "lyria-3-clip-preview": { miss: 0, hit: 0, out: 0 },
141
+ "lyria-3-pro-preview": { miss: 0, hit: 0, out: 0 }
142
+ },
143
+ "moonshotai": {
144
+ "kimi-k2.6": { miss: 0.95, hit: 0.16, out: 4 },
145
+ "kimi-k2.7-code": { miss: 0.95, hit: 0.19, out: 4 },
146
+ "kimi-k2.7-code-highspeed": { miss: 1.9, hit: 0.38, out: 8 },
147
+ "kimi-k3": { miss: 3, hit: 0.3, out: 15 }
148
+ },
149
+ "zhipuai": {
150
+ "glm-4.5": { miss: 0.6, hit: 0.11, out: 2.2 },
151
+ "glm-4.5-air": { miss: 0.2, hit: 0.03, out: 1.1 },
152
+ "glm-4.5-flash": { miss: 0, hit: 0, out: 0 },
153
+ "glm-4.5v": { miss: 0.6, hit: 0.6, out: 1.8 },
154
+ "glm-4.6": { miss: 0.6, hit: 0.11, out: 2.2 },
155
+ "glm-4.6v": { miss: 0.3, hit: 0.3, out: 0.9 },
156
+ "glm-4.6v-flash": { miss: 0, hit: 0, out: 0 },
157
+ "glm-4.7": { miss: 0.6, hit: 0.11, out: 2.2 },
158
+ "glm-4.7-flash": { miss: 0, hit: 0, out: 0 },
159
+ "glm-4.7-flashx": { miss: 0.07, hit: 0.01, out: 0.4 },
160
+ "glm-5": { miss: 1, hit: 0.2, out: 3.2 },
161
+ "glm-5.1": { miss: 1.4, hit: 0.26, out: 4.4 },
162
+ "glm-5.2": { miss: 1.4, hit: 0.26, out: 4.4 },
163
+ "glm-5.3": { miss: 1.4, hit: 0.26, out: 4.4 },
164
+ "glm-5.3-flash": { miss: 0.15, hit: 0.03, out: 0.5 },
165
+ "glm-5.3-flashx": { miss: 0.37, hit: 0.075, out: 1.25 },
166
+ "glm-5v-turbo": { miss: 5, hit: 1.2, out: 22 }
167
+ },
168
+ "minimax": {
169
+ "minimax-m2": { miss: 0.3, hit: 0.3, out: 1.2 },
170
+ "minimax-m2.1": { miss: 0.3, hit: 0.03, out: 1.2 },
171
+ "minimax-m2.5": { miss: 0.3, hit: 0.03, out: 1.2 },
172
+ "minimax-m2.5-highspeed": { miss: 0.6, hit: 0.06, out: 2.4 },
173
+ "minimax-m2.7": { miss: 0.3, hit: 0.06, out: 1.2 },
174
+ "minimax-m2.7-highspeed": { miss: 0.6, hit: 0.06, out: 2.4 },
175
+ "minimax-m3": { miss: 0.3, hit: 0.06, out: 1.2 }
176
+ },
177
+ "alibaba": {
178
+ "deepseek-v4-flash-0731": { miss: 0.2, hit: 0.04, out: 0.4 },
179
+ "glm-5.2": { miss: 1.4, hit: 0.28, out: 4.4 },
180
+ "kimi-k3": { miss: 3, hit: 0.3, out: 15 },
181
+ "qvq-max": { miss: 1.2, hit: 1.2, out: 4.8 },
182
+ "qwen-flash": { miss: 0.05, hit: 0.05, out: 0.4 },
183
+ "qwen-max": { miss: 1.6, hit: 1.6, out: 6.4 },
184
+ "qwen-mt-plus": { miss: 2.46, hit: 2.46, out: 7.37 },
185
+ "qwen-mt-turbo": { miss: 0.16, hit: 0.16, out: 0.49 },
186
+ "qwen-omni-turbo": { miss: 0.07, hit: 0.07, out: 0.27 },
187
+ "qwen-omni-turbo-realtime": { miss: 0.27, hit: 0.27, out: 1.07 },
188
+ "qwen-plus": { miss: 0.4, hit: 0.4, out: 1.2 },
189
+ "qwen-plus-character-ja": { miss: 0.5, hit: 0.5, out: 1.4 },
190
+ "qwen-turbo": { miss: 0.05, hit: 0.05, out: 0.2 },
191
+ "qwen-vl-max": { miss: 0.8, hit: 0.8, out: 3.2 },
192
+ "qwen-vl-ocr": { miss: 0.72, hit: 0.72, out: 0.72 },
193
+ "qwen-vl-plus": { miss: 0.21, hit: 0.21, out: 0.63 },
194
+ "qwen2-5-14b-instruct": { miss: 0.35, hit: 0.35, out: 1.4 },
195
+ "qwen2-5-32b-instruct": { miss: 0.7, hit: 0.7, out: 2.8 },
196
+ "qwen2-5-72b-instruct": { miss: 1.4, hit: 1.4, out: 5.6 },
197
+ "qwen2-5-7b-instruct": { miss: 0.175, hit: 0.175, out: 0.7 },
198
+ "qwen2-5-omni-7b": { miss: 0.1, hit: 0.1, out: 0.4 },
199
+ "qwen2-5-vl-72b-instruct": { miss: 2.8, hit: 2.8, out: 8.4 },
200
+ "qwen2-5-vl-7b-instruct": { miss: 0.35, hit: 0.35, out: 1.05 },
201
+ "qwen3-14b": { miss: 0.35, hit: 0.35, out: 1.4 },
202
+ "qwen3-235b-a22b": { miss: 0.7, hit: 0.7, out: 2.8 },
203
+ "qwen3-32b": { miss: 0.7, hit: 0.7, out: 2.8 },
204
+ "qwen3-8b": { miss: 0.18, hit: 0.18, out: 0.7 },
205
+ "qwen3-asr-flash": { miss: 0.035, hit: 0.035, out: 0.035 },
206
+ "qwen3-coder-30b-a3b-instruct": { miss: 0.45, hit: 0.45, out: 2.25 },
207
+ "qwen3-coder-480b-a35b-instruct": { miss: 1.5, hit: 1.5, out: 7.5 },
208
+ "qwen3-coder-flash": { miss: 0.3, hit: 0.3, out: 1.5 },
209
+ "qwen3-coder-plus": { miss: 1, hit: 1, out: 5 },
210
+ "qwen3-livetranslate-flash-realtime": { miss: 10, hit: 10, out: 10 },
211
+ "qwen3-max": { miss: 1.2, hit: 1.2, out: 6 },
212
+ "qwen3-next-80b-a3b-instruct": { miss: 0.5, hit: 0.5, out: 2 },
213
+ "qwen3-next-80b-a3b-thinking": { miss: 0.5, hit: 0.5, out: 6 },
214
+ "qwen3-omni-flash": { miss: 0.43, hit: 0.43, out: 1.66 },
215
+ "qwen3-omni-flash-realtime": { miss: 0.52, hit: 0.52, out: 1.99 },
216
+ "qwen3-vl-235b-a22b": { miss: 0.7, hit: 0.7, out: 2.8 },
217
+ "qwen3-vl-30b-a3b": { miss: 0.2, hit: 0.2, out: 0.8 },
218
+ "qwen3-vl-plus": { miss: 0.2, hit: 0.2, out: 1.6 },
219
+ "qwen3.5-122b-a10b": { miss: 0.4, hit: 0.4, out: 3.2 },
220
+ "qwen3.5-27b": { miss: 0.3, hit: 0.3, out: 2.4 },
221
+ "qwen3.5-35b-a3b": { miss: 0.25, hit: 0.25, out: 2 },
222
+ "qwen3.5-397b-a17b": { miss: 0.6, hit: 0.6, out: 3.6 },
223
+ "qwen3.5-flash": { miss: 0.1, hit: 0.01, out: 0.4 },
224
+ "qwen3.5-plus": { miss: 0.4, hit: 0.4, out: 2.4 },
225
+ "qwen3.6-27b": { miss: 0.6, hit: 0.6, out: 3.6 },
226
+ "qwen3.6-35b-a3b": { miss: 0.248, hit: 0.248, out: 1.485 },
227
+ "qwen3.6-flash": { miss: 0.1875, hit: 0.1875, out: 1.125 },
228
+ "qwen3.6-max-preview": { miss: 1.3, hit: 0.13, out: 7.8 },
229
+ "qwen3.6-plus": { miss: 0.5, hit: 0.05, out: 3 },
230
+ "qwen3.7-flash": { miss: 0.03, hit: 3e-3, out: 0.13 },
231
+ "qwen3.7-max": { miss: 2.5, hit: 0.5, out: 7.5 },
232
+ "qwen3.7-plus": { miss: 0.4, hit: 0.04, out: 1.6 },
233
+ "qwen3.8-flash": { miss: 0.15, hit: 0.016, out: 0.47 },
234
+ "qwen3.8-max": { miss: 2, hit: 0.25, out: 6 },
235
+ "qwen3.8-omni-flash": { miss: 0.15, hit: 0.016, out: 0.47 },
236
+ "qwq-plus": { miss: 0.8, hit: 0.8, out: 2.4 }
237
+ },
238
+ "xai": {
239
+ "grok-4.20-0309-non-reasoning": { miss: 1.25, hit: 0.2, out: 2.5 },
240
+ "grok-4.20-0309-reasoning": { miss: 1.25, hit: 0.2, out: 2.5 },
241
+ "grok-4.20-multi-agent-0309": { miss: 1.25, hit: 0.2, out: 2.5 },
242
+ "grok-4.3": { miss: 1.25, hit: 0.2, out: 2.5 },
243
+ "grok-4.5": { miss: 2, hit: 0.3, out: 6 },
244
+ "grok-4.6": { miss: 2, hit: 0.5, out: 6 },
245
+ "grok-4.7": { miss: 2, hit: 0.5, out: 6 },
246
+ "grok-build-0.1": { miss: 1, hit: 0.2, out: 2 }
247
+ },
248
+ "xiaomi": {
249
+ "mimo-v2-flash": { miss: 0.14, hit: 28e-4, out: 0.28 },
250
+ "mimo-v2-omni": { miss: 0.14, hit: 28e-4, out: 0.28 },
251
+ "mimo-v2-pro": { miss: 0.435, hit: 36e-4, out: 0.87 },
252
+ "mimo-v2.5": { miss: 0.14, hit: 28e-4, out: 0.28 },
253
+ "mimo-v2.5-pro": { miss: 0.435, hit: 36e-4, out: 0.87 },
254
+ "mimo-v2.5-pro-ultraspeed": { miss: 1.305, hit: 0.0108, out: 2.61 },
255
+ "mimo-v2.6-flash": { miss: 0.14, hit: 28e-4, out: 0.28 },
256
+ "mimo-v2.6-pro": { miss: 0.435, hit: 36e-4, out: 0.87 },
257
+ "mimo-v2.6-pro-ultraspeed": { miss: 4.35, hit: 0.036, out: 8.7 }
258
+ },
259
+ "opencode": {
260
+ "big-pickle": { miss: 0, hit: 0, out: 0 },
261
+ "claude-3-5-haiku": { miss: 0.8, hit: 0.08, out: 4 },
262
+ "claude-fable-5": { miss: 10, hit: 1, out: 50 },
263
+ "claude-fable-5-1": { miss: 10, hit: 0.25, out: 50 },
264
+ "claude-haiku-4-5": { miss: 1, hit: 0.1, out: 5 },
265
+ "claude-opus-4-1": { miss: 15, hit: 1.5, out: 75 },
266
+ "claude-opus-4-5": { miss: 5, hit: 0.5, out: 25 },
267
+ "claude-opus-4-6": { miss: 5, hit: 0.5, out: 25 },
268
+ "claude-opus-4-7": { miss: 5, hit: 0.5, out: 25 },
269
+ "claude-opus-4-8": { miss: 5, hit: 0.5, out: 25 },
270
+ "claude-opus-5": { miss: 5, hit: 0.5, out: 25 },
271
+ "claude-opus-5-5": { miss: 4, hit: 0.2, out: 20 },
272
+ "claude-sonnet-4": { miss: 3, hit: 0.3, out: 15 },
273
+ "claude-sonnet-4-5": { miss: 3, hit: 0.3, out: 15 },
274
+ "claude-sonnet-4-6": { miss: 3, hit: 0.3, out: 15 },
275
+ "claude-sonnet-5": { miss: 2, hit: 0.2, out: 10 },
276
+ "deepseek-v4-flash": { miss: 0.14, hit: 0.028, out: 0.28 },
277
+ "deepseek-v4-flash-free": { miss: 0, hit: 0, out: 0 },
278
+ "deepseek-v4-flash-vision-exp": { miss: 0.14, hit: 0.028, out: 0.28 },
279
+ "deepseek-v4-pro": { miss: 1.74, hit: 0.145, out: 3.84 },
280
+ "deepseek-v4.1-flash": { miss: 0.3, hit: 6e-3, out: 1.2 },
281
+ "gemini-3-flash": { miss: 0.5, hit: 0.05, out: 3 },
282
+ "gemini-3-pro": { miss: 2, hit: 0.2, out: 12 },
283
+ "gemini-3.1-pro": { miss: 2, hit: 0.2, out: 12 },
284
+ "gemini-3.5-flash": { miss: 1.5, hit: 0.15, out: 9 },
285
+ "gemini-3.5-flash-lite": { miss: 0.3, hit: 0.03, out: 2.5 },
286
+ "gemini-3.6-flash": { miss: 1.5, hit: 0.15, out: 7.5 },
287
+ "gemini-3.7-flash": { miss: 1.5, hit: 0.15, out: 7.5 },
288
+ "gemini-3.8-flash": { miss: 1.5, hit: 0.15, out: 7.5 },
289
+ "glm-4.6": { miss: 0.6, hit: 0.1, out: 2.2 },
290
+ "glm-4.7": { miss: 0.6, hit: 0.1, out: 2.2 },
291
+ "glm-4.7-free": { miss: 0, hit: 0, out: 0 },
292
+ "glm-5": { miss: 1, hit: 0.2, out: 3.2 },
293
+ "glm-5-free": { miss: 0, hit: 0, out: 0 },
294
+ "glm-5.1": { miss: 1.4, hit: 0.26, out: 4.4 },
295
+ "glm-5.2": { miss: 1.4, hit: 0.26, out: 4.4 },
296
+ "glm-5.3": { miss: 1.4, hit: 0.26, out: 4.4 },
297
+ "glm-5.3-flash": { miss: 0.15, hit: 0.03, out: 0.5 },
298
+ "gpt-5": { miss: 1.07, hit: 0.107, out: 8.5 },
299
+ "gpt-5-codex": { miss: 1.07, hit: 0.107, out: 8.5 },
300
+ "gpt-5-nano": { miss: 0.05, hit: 5e-3, out: 0.4 },
301
+ "gpt-5.1": { miss: 1.07, hit: 0.107, out: 8.5 },
302
+ "gpt-5.1-codex": { miss: 1.07, hit: 0.107, out: 8.5 },
303
+ "gpt-5.1-codex-max": { miss: 1.25, hit: 0.125, out: 10 },
304
+ "gpt-5.1-codex-mini": { miss: 0.25, hit: 0.025, out: 2 },
305
+ "gpt-5.2": { miss: 1.75, hit: 0.175, out: 14 },
306
+ "gpt-5.2-codex": { miss: 1.75, hit: 0.175, out: 14 },
307
+ "gpt-5.3-codex": { miss: 1.75, hit: 0.175, out: 14 },
308
+ "gpt-5.3-codex-spark": { miss: 1.75, hit: 0.175, out: 14 },
309
+ "gpt-5.4": { miss: 2.5, hit: 0.25, out: 15 },
310
+ "gpt-5.4-mini": { miss: 0.75, hit: 0.075, out: 4.5 },
311
+ "gpt-5.4-nano": { miss: 0.2, hit: 0.02, out: 1.25 },
312
+ "gpt-5.4-pro": { miss: 30, hit: 30, out: 180 },
313
+ "gpt-5.5": { miss: 5, hit: 0.5, out: 30 },
314
+ "gpt-5.5-pro": { miss: 30, hit: 30, out: 180 },
315
+ "gpt-5.6-luna": { miss: 0.2, hit: 0.02, out: 1.2 },
316
+ "gpt-5.6-sol": { miss: 4, hit: 0.4, out: 20 },
317
+ "gpt-5.6-terra": { miss: 2.5, hit: 0.25, out: 15 },
318
+ "gpt-6-astra": { miss: 10, hit: 1, out: 50 },
319
+ "gpt-6-luna": { miss: 0.1, hit: 0.01, out: 0.5 },
320
+ "gpt-6-sol": { miss: 2, hit: 0.2, out: 10 },
321
+ "grok-4.5": { miss: 2, hit: 0.3, out: 6 },
322
+ "grok-4.6": { miss: 2, hit: 0.5, out: 6 },
323
+ "grok-4.7": { miss: 1.4, hit: 0.35, out: 4.2 },
324
+ "grok-build-0.1": { miss: 1, hit: 0.2, out: 2 },
325
+ "grok-code": { miss: 0, hit: 0, out: 0 },
326
+ "hy3-free": { miss: 0, hit: 0, out: 0 },
327
+ "hy3-preview-free": { miss: 0, hit: 0, out: 0 },
328
+ "kimi-k2": { miss: 0.4, hit: 0.4, out: 2.5 },
329
+ "kimi-k2-thinking": { miss: 0.4, hit: 0.4, out: 2.5 },
330
+ "kimi-k2.5": { miss: 0.6, hit: 0.08, out: 3 },
331
+ "kimi-k2.5-free": { miss: 0, hit: 0, out: 0 },
332
+ "kimi-k2.6": { miss: 0.95, hit: 0.16, out: 4 },
333
+ "kimi-k2.7-code": { miss: 0.95, hit: 0.19, out: 4 },
334
+ "kimi-k3": { miss: 3, hit: 0.3, out: 15 },
335
+ "laguna-s-2.1-free": { miss: 0, hit: 0, out: 0 },
336
+ "ling-2.6-flash-free": { miss: 0, hit: 0, out: 0 },
337
+ "ling-3.0-flash-fin-free": { miss: 0, hit: 0, out: 0 },
338
+ "ling-3.0-flash-free": { miss: 0, hit: 0, out: 0 },
339
+ "ling-3.0-tiny-free": { miss: 0, hit: 0, out: 0 },
340
+ "longcat-2.0-free": { miss: 0, hit: 0, out: 0 },
341
+ "longcat-2.5-preview-free": { miss: 0, hit: 0, out: 0 },
342
+ "mimo-v2-flash-free": { miss: 0, hit: 0, out: 0 },
343
+ "mimo-v2-omni-free": { miss: 0, hit: 0, out: 0 },
344
+ "mimo-v2-pro-free": { miss: 0, hit: 0, out: 0 },
345
+ "mimo-v2.5-free": { miss: 0, hit: 0, out: 0 },
346
+ "mimo-v2.6-flash-free": { miss: 0, hit: 0, out: 0 },
347
+ "minimax-m2.1": { miss: 0.3, hit: 0.1, out: 1.2 },
348
+ "minimax-m2.1-free": { miss: 0, hit: 0, out: 0 },
349
+ "minimax-m2.5": { miss: 0.3, hit: 0.06, out: 1.2 },
350
+ "minimax-m2.5-free": { miss: 0, hit: 0, out: 0 },
351
+ "minimax-m2.7": { miss: 0.3, hit: 0.06, out: 1.2 },
352
+ "minimax-m3": { miss: 0.3, hit: 0.06, out: 1.2 },
353
+ "minimax-m3-free": { miss: 0, hit: 0, out: 0 },
354
+ "muse-spark-1.2": { miss: 1.25, hit: 0.15, out: 4.25 },
355
+ "muse-spark-1.2-contributor-free": { miss: 0, hit: 0, out: 0 },
356
+ "muse-spark-1.3": { miss: 1.25, hit: 0.15, out: 4.25 },
357
+ "muse-spark-1.3-contributor-free": { miss: 0, hit: 0, out: 0 },
358
+ "nemotron-3-super-free": { miss: 0, hit: 0, out: 0 },
359
+ "nemotron-3-ultra-free": { miss: 0, hit: 0, out: 0 },
360
+ "nemotron-3.5-lightning-free": { miss: 0, hit: 0, out: 0 },
361
+ "north-mini-code-free": { miss: 0, hit: 0, out: 0 },
362
+ "qwen3-coder": { miss: 0.45, hit: 0.45, out: 1.8 },
363
+ "qwen3.5-plus": { miss: 0.2, hit: 0.02, out: 1.2 },
364
+ "qwen3.6-plus": { miss: 0.5, hit: 0.05, out: 3 },
365
+ "qwen3.6-plus-free": { miss: 0, hit: 0, out: 0 },
366
+ "qwen3.8-flash": { miss: 0.15, hit: 0.016, out: 0.47 },
367
+ "qwen3.8-max": { miss: 2, hit: 0.25, out: 6 },
368
+ "ring-2.6-1t-free": { miss: 0, hit: 0, out: 0 },
369
+ "space-bunny-free": { miss: 0, hit: 0, out: 0 },
370
+ "trinity-large-preview-free": { miss: 0, hit: 0, out: 0 },
371
+ "x-preview-f-free": { miss: 0, hit: 0, out: 0 }
372
+ },
373
+ "opencode-go": {
374
+ "deepseek-v4-flash": { miss: 0.15, hit: 3e-3, out: 0.6 },
375
+ "deepseek-v4-flash-vision-exp": { miss: 0.15, hit: 3e-3, out: 0.6 },
376
+ "deepseek-v4-pro": { miss: 0.66, hit: 0.022, out: 1.98 },
377
+ "deepseek-v4.1-flash": { miss: 0.15, hit: 3e-3, out: 0.6 },
378
+ "glm-5.2": { miss: 1.4, hit: 0.26, out: 4.4 },
379
+ "glm-5.3": { miss: 1.4, hit: 0.26, out: 4.4 },
380
+ "glm-5.3-flash": { miss: 0.15, hit: 0.03, out: 0.5 },
381
+ "gpt-5.6-luna": { miss: 0.2, hit: 0.02, out: 1.2 },
382
+ "gpt-6-luna": { miss: 0.1, hit: 0.01, out: 0.5 },
383
+ "grok-4.5": { miss: 2, hit: 0.3, out: 6 },
384
+ "grok-4.6": { miss: 2, hit: 0.5, out: 6 },
385
+ "grok-4.7": { miss: 2, hit: 0.5, out: 6 },
386
+ "hy3": { miss: 0.14, hit: 0.035, out: 0.58 },
387
+ "hy4-preview": { miss: 0.834, hit: 0.042, out: 2.501 },
388
+ "kimi-k2.6": { miss: 0.95, hit: 0.16, out: 4 },
389
+ "kimi-k2.7-code": { miss: 0.95, hit: 0.19, out: 4 },
390
+ "kimi-k3": { miss: 3, hit: 0.3, out: 15 },
391
+ "longcat-2.0": { miss: 0.3, hit: 6e-3, out: 1.2 },
392
+ "longcat-2.5-preview-free": { miss: 0, hit: 0, out: 0 },
393
+ "mimo-v2.5": { miss: 0.14, hit: 28e-4, out: 0.28 },
394
+ "mimo-v2.5-pro": { miss: 0.435, hit: 3625e-6, out: 0.87 },
395
+ "mimo-v2.6-flash": { miss: 0.14, hit: 28e-4, out: 0.28 },
396
+ "mimo-v2.6-pro": { miss: 0.435, hit: 3625e-6, out: 0.87 },
397
+ "minimax-m2.7": { miss: 0.3, hit: 0.06, out: 1.2 },
398
+ "minimax-m3": { miss: 0.3, hit: 0.06, out: 1.2 },
399
+ "muse-spark-1.2-contributor": { miss: 0.1, hit: 2e-3, out: 0.2 },
400
+ "muse-spark-1.3-contributor": { miss: 0.1, hit: 2e-3, out: 0.2 },
401
+ "qwen3.6-plus": { miss: 0.5, hit: 0.05, out: 3 },
402
+ "qwen3.7-max": { miss: 2.5, hit: 0.5, out: 7.5 },
403
+ "qwen3.7-plus": { miss: 0.4, hit: 0.04, out: 1.6 },
404
+ "qwen3.8-flash": { miss: 0.15, hit: 0.016, out: 0.47 },
405
+ "qwen3.8-max": { miss: 2, hit: 0.25, out: 6 },
406
+ "space-bunny-free": { miss: 0, hit: 0, out: 0 }
407
+ }
408
+ };
411
409
  }
412
- };
410
+ });
413
411
 
414
412
  // src/pricing.ts
415
- var ZERO_TRIPLE = { miss: 0, hit: 0, out: 0 };
416
- var CNY_PER_USD = 6.82;
417
- var PEAK_UTC_RANGES = [[1, 4], [6, 10]];
418
- var PEAK_RULE_AT_MS = Date.parse("2026-08-16T16:00:00Z");
419
- var WEEKEND_OFFPEAK_AT_MS = Date.parse("2026-08-22T16:00:00Z");
420
- var DEFAULT_PEAK_HOLIDAYS = [
421
- "2026-09-25",
422
- "2026-09-26",
423
- "2026-09-27",
424
- "2026-10-01",
425
- "2026-10-02",
426
- "2026-10-03",
427
- "2026-10-04",
428
- "2026-10-05",
429
- "2026-10-06",
430
- "2026-10-07"
431
- ];
432
413
  function beijingDayKey(ms) {
433
414
  const shifted = Number.isFinite(ms) ? ms + 8 * 36e5 : 0;
434
415
  return new Date(shifted).toISOString().slice(0, 10);
@@ -499,74 +480,6 @@ function peakPhaseAt(atMs, options = {}) {
499
480
  weekend
500
481
  };
501
482
  }
502
- var ERA_LEGACY = {
503
- id: "legacy",
504
- fromMs: 0,
505
- label: "\u5CF0\u8C37\u5236\u4E4B\u524D\uFF08\u5355\u4E00\u6863\u4EF7\uFF09",
506
- source: 'https://api-docs.deepseek.com/zh-cn/updates\uFF082026-07-31 V4-Flash-0731 \u4E0A\u7EBF\u65F6\u7684\u4EF7\u76EE\uFF1B2026-08-13 \u6DA8\u4EF7\u516C\u544A\u7684"\u6DA8\u524D\u4EF7"\u9010\u9879\u5BF9\u4E0A\uFF1AFlash \u547D\u4E2D 0.02 / \u672A\u547D\u4E2D 1 / \u8F93\u51FA 2\uFF0CPro \u547D\u4E2D 0.025 / \u672A\u547D\u4E2D 3 / \u8F93\u51FA 6\uFF09',
507
- table: {
508
- "deepseek-flash": {
509
- peak: { cny: { miss: 1, hit: 0.02, out: 2 }, usd: { miss: 0.14, hit: 28e-4, out: 0.28 } },
510
- offPeak: { cny: { miss: 1, hit: 0.02, out: 2 }, usd: { miss: 0.14, hit: 28e-4, out: 0.28 } }
511
- },
512
- "deepseek-v4-pro": {
513
- peak: { cny: { miss: 3, hit: 0.025, out: 6 }, usd: { miss: 0.435, hit: 3625e-6, out: 0.87 } },
514
- offPeak: { cny: { miss: 3, hit: 0.025, out: 6 }, usd: { miss: 0.435, hit: 3625e-6, out: 0.87 } }
515
- }
516
- }
517
- };
518
- var ERA_2026_08 = {
519
- id: "peak-2026-08",
520
- fromMs: PEAK_RULE_AT_MS,
521
- label: "\u5CF0\u8C37\u4E24\u6863\uFF082026-08 \u4EF7\uFF09",
522
- source: "https://api-docs.deepseek.com/zh-cn/quick_start/pricing\uFF082026-08 \u7248\uFF09",
523
- table: {
524
- "deepseek-flash": {
525
- offPeak: { cny: { miss: 1.5, hit: 0.05, out: 4.5 }, usd: { miss: 0.22, hit: 7e-3, out: 0.66 } },
526
- peak: { cny: { miss: 3, hit: 0.1, out: 9 }, usd: { miss: 0.44, hit: 0.014, out: 1.32 } }
527
- },
528
- "deepseek-v4-pro": {
529
- offPeak: { cny: { miss: 4.5, hit: 0.15, out: 13.5 }, usd: { miss: 0.66, hit: 0.022, out: 1.98 } },
530
- peak: { cny: { miss: 9, hit: 0.3, out: 27 }, usd: { miss: 1.32, hit: 0.044, out: 3.96 } }
531
- }
532
- }
533
- };
534
- var ERA_2026_09 = {
535
- id: "flash-2026-09-10",
536
- fromMs: Date.parse("2026-09-10T04:00:00Z"),
537
- label: "Flash \u964D\u4EF7\u540E\uFF082026-09-10 \u8D77\uFF09",
538
- source: "https://api-docs.deepseek.com/zh-cn/quick_start/pricing + https://intl.cloud.tencent.com/ind/announce/detail/101513",
539
- table: {
540
- "deepseek-flash": {
541
- offPeak: { cny: { miss: 1, hit: 0.02, out: 4 }, usd: { miss: 0.15, hit: 3e-3, out: 0.6 } },
542
- peak: { cny: { miss: 2, hit: 0.04, out: 8 }, usd: { miss: 0.3, hit: 6e-3, out: 1.2 } }
543
- },
544
- "deepseek-v4-pro": {
545
- offPeak: { cny: { miss: 4.5, hit: 0.15, out: 13.5 }, usd: { miss: 0.66, hit: 0.022, out: 1.98 } },
546
- peak: { cny: { miss: 9, hit: 0.3, out: 27 }, usd: { miss: 1.32, hit: 0.044, out: 3.96 } }
547
- }
548
- }
549
- };
550
- var PRICE_ERAS = [ERA_LEGACY, ERA_2026_08, ERA_2026_09];
551
- var CURRENT_ERA_ID = ERA_2026_09.id;
552
- var PRICE_TABLE = ERA_2026_09.table;
553
- var MODEL_ALIASES = {
554
- // 官方脚注:`deepseek-v4-flash`、`deepseek-v4-flash-vision-exp` 仍可调用,
555
- // 但对应模型已下线、请求由 V4.1-Flash 服务,**并按 Flash 价计费**。
556
- "deepseek-v4-flash": "deepseek-flash",
557
- "deepseek-v4-flash-vision-exp": "deepseek-flash",
558
- "deepseek-v4.1-flash": "deepseek-flash",
559
- // 更早的两代名(V4 首发时的兼容名),只作历史日志的兜底映射。
560
- // ⚠️ 官方更新日志(2026-04-24,中英两版都写了):`deepseek-chat` 与 `deepseek-reasoner`
561
- // **都指向 `deepseek-v4-flash`** —— 前者是非思考模式、后者是思考模式,
562
- // 与 `deepseek-v4-pro` **没有**对应关系,且这两个名字已于 2026-07-24 停用。
563
- // (0.10.0 一度把 reasoner 映到 Pro,那会把 flash 的用量按 Pro 价算,约 3 倍;已修。)
564
- "deepseek-chat": "deepseek-flash",
565
- "deepseek-reasoner": "deepseek-flash"
566
- };
567
- var DEFAULT_PRICING_MODEL = "deepseek-flash";
568
- var BUILTIN_PRICING_MODELS = Object.keys(PRICE_TABLE);
569
- var PRICE_VERIFIED_AT = "2026-09-29";
570
483
  function allEras(extra) {
571
484
  if (extra === void 0 || extra.length === 0) return PRICE_ERAS;
572
485
  return [...PRICE_ERAS, ...extra].sort((left, right) => left.fromMs - right.fromMs);
@@ -642,13 +555,6 @@ function parseTriple(raw) {
642
555
  if (miss < 0 || hit < 0 || out < 0) return void 0;
643
556
  return { miss, hit, out };
644
557
  }
645
- var PROVIDER_ALIASES = {
646
- "deepseek-official": "deepseek",
647
- "llm-deepseek": "deepseek",
648
- "kimi-coding": "moonshotai",
649
- "minimax-cn": "minimax",
650
- "zai-coding-cn": "zhipuai"
651
- };
652
558
  function isDeepSeekRoute(provider, model) {
653
559
  const providerText = typeof provider === "string" ? provider.trim().toLowerCase() : "";
654
560
  if (providerText.includes("deepseek")) return true;
@@ -672,7 +578,6 @@ function providerRateOf(table, provider, model) {
672
578
  }
673
579
  return matches.length === 1 ? { provider: matches[0].provider, model: rawModel, rate: matches[0].rate } : void 0;
674
580
  }
675
- var PRICE_FIELDS = ["miss", "hit", "out"];
676
581
  function finite(value) {
677
582
  return typeof value === "number" && Number.isFinite(value) ? value : void 0;
678
583
  }
@@ -944,6 +849,105 @@ function parsePriceText(text) {
944
849
  if (!Number.isFinite(value) || value < 0) return { kind: "invalid" };
945
850
  return { kind: "number", value };
946
851
  }
852
+ var ZERO_TRIPLE, CNY_PER_USD, PEAK_UTC_RANGES, PEAK_RULE_AT_MS, WEEKEND_OFFPEAK_AT_MS, DEFAULT_PEAK_HOLIDAYS, ERA_LEGACY, ERA_2026_08, ERA_2026_09, PRICE_ERAS, CURRENT_ERA_ID, PRICE_TABLE, MODEL_ALIASES, DEFAULT_PRICING_MODEL, BUILTIN_PRICING_MODELS, PRICE_VERIFIED_AT, PROVIDER_ALIASES, PRICE_FIELDS;
853
+ var init_pricing = __esm({
854
+ "src/pricing.ts"() {
855
+ init_provider_prices();
856
+ ZERO_TRIPLE = { miss: 0, hit: 0, out: 0 };
857
+ CNY_PER_USD = 6.82;
858
+ PEAK_UTC_RANGES = [[1, 4], [6, 10]];
859
+ PEAK_RULE_AT_MS = Date.parse("2026-08-16T16:00:00Z");
860
+ WEEKEND_OFFPEAK_AT_MS = Date.parse("2026-08-22T16:00:00Z");
861
+ DEFAULT_PEAK_HOLIDAYS = [
862
+ "2026-09-25",
863
+ "2026-09-26",
864
+ "2026-09-27",
865
+ "2026-10-01",
866
+ "2026-10-02",
867
+ "2026-10-03",
868
+ "2026-10-04",
869
+ "2026-10-05",
870
+ "2026-10-06",
871
+ "2026-10-07"
872
+ ];
873
+ ERA_LEGACY = {
874
+ id: "legacy",
875
+ fromMs: 0,
876
+ label: "\u5CF0\u8C37\u5236\u4E4B\u524D\uFF08\u5355\u4E00\u6863\u4EF7\uFF09",
877
+ source: 'https://api-docs.deepseek.com/zh-cn/updates\uFF082026-07-31 V4-Flash-0731 \u4E0A\u7EBF\u65F6\u7684\u4EF7\u76EE\uFF1B2026-08-13 \u6DA8\u4EF7\u516C\u544A\u7684"\u6DA8\u524D\u4EF7"\u9010\u9879\u5BF9\u4E0A\uFF1AFlash \u547D\u4E2D 0.02 / \u672A\u547D\u4E2D 1 / \u8F93\u51FA 2\uFF0CPro \u547D\u4E2D 0.025 / \u672A\u547D\u4E2D 3 / \u8F93\u51FA 6\uFF09',
878
+ table: {
879
+ "deepseek-flash": {
880
+ peak: { cny: { miss: 1, hit: 0.02, out: 2 }, usd: { miss: 0.14, hit: 28e-4, out: 0.28 } },
881
+ offPeak: { cny: { miss: 1, hit: 0.02, out: 2 }, usd: { miss: 0.14, hit: 28e-4, out: 0.28 } }
882
+ },
883
+ "deepseek-v4-pro": {
884
+ peak: { cny: { miss: 3, hit: 0.025, out: 6 }, usd: { miss: 0.435, hit: 3625e-6, out: 0.87 } },
885
+ offPeak: { cny: { miss: 3, hit: 0.025, out: 6 }, usd: { miss: 0.435, hit: 3625e-6, out: 0.87 } }
886
+ }
887
+ }
888
+ };
889
+ ERA_2026_08 = {
890
+ id: "peak-2026-08",
891
+ fromMs: PEAK_RULE_AT_MS,
892
+ label: "\u5CF0\u8C37\u4E24\u6863\uFF082026-08 \u4EF7\uFF09",
893
+ source: "https://api-docs.deepseek.com/zh-cn/quick_start/pricing\uFF082026-08 \u7248\uFF09",
894
+ table: {
895
+ "deepseek-flash": {
896
+ offPeak: { cny: { miss: 1.5, hit: 0.05, out: 4.5 }, usd: { miss: 0.22, hit: 7e-3, out: 0.66 } },
897
+ peak: { cny: { miss: 3, hit: 0.1, out: 9 }, usd: { miss: 0.44, hit: 0.014, out: 1.32 } }
898
+ },
899
+ "deepseek-v4-pro": {
900
+ offPeak: { cny: { miss: 4.5, hit: 0.15, out: 13.5 }, usd: { miss: 0.66, hit: 0.022, out: 1.98 } },
901
+ peak: { cny: { miss: 9, hit: 0.3, out: 27 }, usd: { miss: 1.32, hit: 0.044, out: 3.96 } }
902
+ }
903
+ }
904
+ };
905
+ ERA_2026_09 = {
906
+ id: "flash-2026-09-10",
907
+ fromMs: Date.parse("2026-09-10T04:00:00Z"),
908
+ label: "Flash \u964D\u4EF7\u540E\uFF082026-09-10 \u8D77\uFF09",
909
+ source: "https://api-docs.deepseek.com/zh-cn/quick_start/pricing + https://intl.cloud.tencent.com/ind/announce/detail/101513",
910
+ table: {
911
+ "deepseek-flash": {
912
+ offPeak: { cny: { miss: 1, hit: 0.02, out: 4 }, usd: { miss: 0.15, hit: 3e-3, out: 0.6 } },
913
+ peak: { cny: { miss: 2, hit: 0.04, out: 8 }, usd: { miss: 0.3, hit: 6e-3, out: 1.2 } }
914
+ },
915
+ "deepseek-v4-pro": {
916
+ offPeak: { cny: { miss: 4.5, hit: 0.15, out: 13.5 }, usd: { miss: 0.66, hit: 0.022, out: 1.98 } },
917
+ peak: { cny: { miss: 9, hit: 0.3, out: 27 }, usd: { miss: 1.32, hit: 0.044, out: 3.96 } }
918
+ }
919
+ }
920
+ };
921
+ PRICE_ERAS = [ERA_LEGACY, ERA_2026_08, ERA_2026_09];
922
+ CURRENT_ERA_ID = ERA_2026_09.id;
923
+ PRICE_TABLE = ERA_2026_09.table;
924
+ MODEL_ALIASES = {
925
+ // 官方脚注:`deepseek-v4-flash`、`deepseek-v4-flash-vision-exp` 仍可调用,
926
+ // 但对应模型已下线、请求由 V4.1-Flash 服务,**并按 Flash 价计费**。
927
+ "deepseek-v4-flash": "deepseek-flash",
928
+ "deepseek-v4-flash-vision-exp": "deepseek-flash",
929
+ "deepseek-v4.1-flash": "deepseek-flash",
930
+ // 更早的两代名(V4 首发时的兼容名),只作历史日志的兜底映射。
931
+ // ⚠️ 官方更新日志(2026-04-24,中英两版都写了):`deepseek-chat` 与 `deepseek-reasoner`
932
+ // **都指向 `deepseek-v4-flash`** —— 前者是非思考模式、后者是思考模式,
933
+ // 与 `deepseek-v4-pro` **没有**对应关系,且这两个名字已于 2026-07-24 停用。
934
+ // (0.10.0 一度把 reasoner 映到 Pro,那会把 flash 的用量按 Pro 价算,约 3 倍;已修。)
935
+ "deepseek-chat": "deepseek-flash",
936
+ "deepseek-reasoner": "deepseek-flash"
937
+ };
938
+ DEFAULT_PRICING_MODEL = "deepseek-flash";
939
+ BUILTIN_PRICING_MODELS = Object.keys(PRICE_TABLE);
940
+ PRICE_VERIFIED_AT = "2026-09-29";
941
+ PROVIDER_ALIASES = {
942
+ "deepseek-official": "deepseek",
943
+ "llm-deepseek": "deepseek",
944
+ "kimi-coding": "moonshotai",
945
+ "minimax-cn": "minimax",
946
+ "zai-coding-cn": "zhipuai"
947
+ };
948
+ PRICE_FIELDS = ["miss", "hit", "out"];
949
+ }
950
+ });
947
951
 
948
952
  // src/terminal/discover.ts
949
953
  function normalizePath(value) {
@@ -951,32 +955,12 @@ function normalizePath(value) {
951
955
  const slashed = trimmed.replace(/\\/g, "/").replace(/\/{2,}/g, "/");
952
956
  return slashed.length > 1 ? slashed.replace(/\/+$/, "") : slashed;
953
957
  }
958
+ var init_discover = __esm({
959
+ "src/terminal/discover.ts"() {
960
+ }
961
+ });
954
962
 
955
963
  // src/terminal/contracts.ts
956
- var TERMINAL_MODE_FIELD = "terminalMode";
957
- var TERMINAL_BASH_PATH_FIELD = "terminalBashPath";
958
- var TERMINAL_CANDIDATES_FIELD = "terminalCandidates";
959
- var TERMINAL_STATUS_FIELD = "terminalStatus";
960
- var TERMINAL_EFFECTIVE_FIELD = "terminalEffective";
961
- var TERMINAL_API_PATH = "/composer-ux/terminal";
962
- var TERMINAL_MODES = [
963
- {
964
- id: "auto",
965
- label: "\u81EA\u52A8",
966
- hint: "\u63A2\u6D4B\u5230 Git Bash \u5C31\u7528\u5B83\uFF08\u627E\u4E0D\u5230\u5219\u4FDD\u6301 PowerShell\uFF09\uFF1B\u5F00\u7BB1\u5373\u7528\uFF0C\u4E0D\u7528\u624B\u586B\u8DEF\u5F84"
967
- },
968
- {
969
- id: "gitbash",
970
- label: "Git Bash",
971
- hint: "\u5F3A\u5236\u6362\u6210 Git Bash\uFF1B\u6CA1\u63A2\u6D4B\u5230\u5C31\u56DE\u843D PowerShell\uFF0C\u5E76\u5728\u72B6\u6001\u884C\u5199\u660E\u539F\u56E0"
972
- },
973
- {
974
- id: "pwsh",
975
- label: "PowerShell",
976
- hint: "\u4FDD\u6301 DSH \u9ED8\u8BA4\uFF08\u672C\u63D2\u4EF6\u5B8C\u5168\u4E0D\u78B0\u7EC8\u7AEF\u5DE5\u5177\u9762\uFF09"
977
- }
978
- ];
979
- var DEFAULT_TERMINAL_MODE = "auto";
980
964
  function terminalModeFrom(value) {
981
965
  return value === "auto" || value === "gitbash" || value === "pwsh" ? value : DEFAULT_TERMINAL_MODE;
982
966
  }
@@ -999,185 +983,67 @@ function sanitizeTerminalCandidates(value) {
999
983
  }
1000
984
  return out;
1001
985
  }
986
+ var TERMINAL_MODE_FIELD, TERMINAL_BASH_PATH_FIELD, TERMINAL_CANDIDATES_FIELD, TERMINAL_STATUS_FIELD, TERMINAL_EFFECTIVE_FIELD, TERMINAL_API_PATH, TERMINAL_MODES, DEFAULT_TERMINAL_MODE;
987
+ var init_contracts = __esm({
988
+ "src/terminal/contracts.ts"() {
989
+ init_discover();
990
+ TERMINAL_MODE_FIELD = "terminalMode";
991
+ TERMINAL_BASH_PATH_FIELD = "terminalBashPath";
992
+ TERMINAL_CANDIDATES_FIELD = "terminalCandidates";
993
+ TERMINAL_STATUS_FIELD = "terminalStatus";
994
+ TERMINAL_EFFECTIVE_FIELD = "terminalEffective";
995
+ TERMINAL_API_PATH = "/composer-ux/terminal";
996
+ TERMINAL_MODES = [
997
+ {
998
+ id: "auto",
999
+ label: "\u81EA\u52A8",
1000
+ hint: "\u63A2\u6D4B\u5230 Git Bash \u5C31\u7528\u5B83\uFF08\u627E\u4E0D\u5230\u5219\u4FDD\u6301 PowerShell\uFF09\uFF1B\u5F00\u7BB1\u5373\u7528\uFF0C\u4E0D\u7528\u624B\u586B\u8DEF\u5F84"
1001
+ },
1002
+ {
1003
+ id: "gitbash",
1004
+ label: "Git Bash",
1005
+ hint: "\u5F3A\u5236\u6362\u6210 Git Bash\uFF1B\u6CA1\u63A2\u6D4B\u5230\u5C31\u56DE\u843D PowerShell\uFF0C\u5E76\u5728\u72B6\u6001\u884C\u5199\u660E\u539F\u56E0"
1006
+ },
1007
+ {
1008
+ id: "pwsh",
1009
+ label: "PowerShell",
1010
+ hint: "\u4FDD\u6301 DSH \u9ED8\u8BA4\uFF08\u672C\u63D2\u4EF6\u5B8C\u5168\u4E0D\u78B0\u7EC8\u7AEF\u5DE5\u5177\u9762\uFF09"
1011
+ }
1012
+ ];
1013
+ DEFAULT_TERMINAL_MODE = "auto";
1014
+ }
1015
+ });
1002
1016
 
1003
1017
  // src/settings-contract.ts
1004
- var NAMESPACE = "composer-ux";
1005
- var REPO_URL = "https://github.com/fangwen9527/dsh-composer-ux";
1006
- var SITE_URL = "https://www.deepseek.com/harness/";
1007
- var RESTART_API_PATH = "/composer-ux/restart";
1008
- var USAGE_API_PATH = "/composer-ux/usage";
1009
- var QUOTA_API_PATH = "/composer-ux/quota";
1010
- var MODELS_API_PATH = "/composer-ux/models";
1011
- var RESTART_CSRF_HEADER = "x-composer-ux-restart";
1012
- var RESTART_CSRF_VALUE = "1";
1013
- var SYNC_API_PATH = "/composer-ux/sync-prices";
1014
- var ENABLED_FIELD = "enabled";
1015
- var NOTIFY_ENABLED_FIELD = "notifyEnabled";
1016
- var NOTIFY_CHANNEL_FIELD = "notifyChannel";
1017
- var NOTIFY_PUSHPLUS_FIELD = "notifyPushplusToken";
1018
- var NOTIFY_WECOM_FIELD = "notifyWecomWebhook";
1019
- var NOTIFY_KINDS_FIELD = "notifyKinds";
1020
- var NOTIFY_TEST_API_PATH = "/composer-ux/notify/test";
1021
- var DIRECTORY_PICK_ENABLED_FIELD = "directoryPickEnabled";
1022
- var KEYS_ENABLED_FIELD = "keysEnabled";
1023
- var MENU_ENABLED_FIELD = "menuEnabled";
1024
- var QUICK_ENABLED_FIELD = "quickEnabled";
1025
- var PANEL_ENABLED_FIELD = "panelEnabled";
1026
- var TERMINAL_ENABLED_FIELD = "terminalEnabled";
1027
- var STATS_ENABLED_FIELD = "statsEnabled";
1028
- var PRICE_OVERRIDES_FIELD = "priceOverrides";
1029
- var PEAK_HOLIDAYS_FIELD = "peakHolidays";
1030
- var HOLIDAY_SOURCE_LABEL = "holiday-cn\uFF08\u6570\u636E\u53D6\u81EA\u56FD\u52A1\u9662\u529E\u516C\u5385\u901A\u77E5\uFF09";
1031
- var PEAK_ALERT_FIELD = "peakAlert";
1032
- var PRICE_AUTO_SYNC_FIELD = "priceAutoSync";
1033
- var BALANCE_ENABLED_FIELD = "balanceEnabled";
1034
- var SYNCED_PRICES_FIELD = "syncedPrices";
1035
- var DEFAULT_PEAK_ALERT = {
1036
- enabled: true,
1037
- aheadMinutes: 5,
1038
- onPeak: true,
1039
- onOffPeak: true,
1040
- webNotify: false
1041
- };
1042
- var SEND_KEY_FIELD = "sendKey";
1043
- var NEWLINE_KEY_FIELD = "newlineKey";
1044
- var PANEL_RESIZE_FIELD = "panelResize";
1045
- var PANEL_WIDTH_FIELD = "panelWidth";
1046
- var PANEL_HEIGHT_FIELD = "panelHeight";
1047
- var MENU_FIELDS = [
1048
- "menuUndo",
1049
- "menuRedo",
1050
- "menuCut",
1051
- "menuCopy",
1052
- "menuPaste",
1053
- "menuDelete",
1054
- "menuSelectAll"
1055
- ];
1056
- var MENU_MODE_FIELD = "menuMode";
1057
- var MENU_NATIVE_FIELD = "menuNative";
1058
- var MENU_MODES = [
1059
- {
1060
- id: "official",
1061
- label: "\u5B98\u65B9",
1062
- hint: "\u672C\u63D2\u4EF6\u5B8C\u5168\u4E0D\u4ECB\u5165\uFF1ADSH \u4E0E\u5176\u5B83\u63D2\u4EF6\u81EA\u5DF1\u7684\u53F3\u952E\u5904\u7406\u539F\u6837\u751F\u6548\uFF08DSH \u5B98\u65B9\u8F93\u5165\u6846\u672C\u8EAB\u6CA1\u6709\u53F3\u952E\u83DC\u5355\uFF0C\u901A\u5E38\u770B\u5230\u7684\u5C31\u662F\u6D4F\u89C8\u5668\u7684\u83DC\u5355\uFF09"
1063
- },
1064
- {
1065
- id: "browser",
1066
- label: "\u6D4F\u89C8\u5668",
1067
- hint: "\u56FA\u5B9A\u4F7F\u7528\u6D4F\u89C8\u5668\u81EA\u5E26\u7684\u83DC\u5355\uFF0C\u5E76\u5728\u672C\u63D2\u4EF6\u8FD9\u4E00\u5C42\u6321\u4F4F\u5176\u5B83\u63D2\u4EF6\u7684\u83DC\u5355\uFF1B\u7C98\u8D34\u514D\u6388\u6743\u3001\u96F6\u914D\u7F6E"
1068
- },
1069
- {
1070
- id: "custom",
1071
- label: "\u81EA\u5B9A\u4E49",
1072
- hint: "\u4F7F\u7528\u672C\u63D2\u4EF6\u7684\u56FA\u5B9A\u6837\u5F0F\u83DC\u5355\uFF1B\u672A\u9009\u4E2D\u6587\u672C\u65F6\u300C\u526A\u5207 / \u590D\u5236 / \u5220\u9664\u300D\u7F6E\u7070\uFF0C\u7C98\u8D34\u9700\u8981\u6D4F\u89C8\u5668\u526A\u8D34\u677F\u6388\u6743"
1073
- }
1074
- ];
1075
1018
  function menuModeFrom(storedMode, legacyNative) {
1076
1019
  if (storedMode === "official" || storedMode === "browser" || storedMode === "custom") return storedMode;
1077
1020
  if (legacyNative === true) return "browser";
1078
1021
  if (legacyNative === false) return "custom";
1079
1022
  return DEFAULT_SETTINGS.menuMode;
1080
1023
  }
1081
- var QUICK_PROMPTS_FIELD = "quickPrompts";
1082
- var OPTIMIZER_TIER_FIELD = "optimizerTier";
1083
- var OPTIMIZER_CONTEXT_FIELD = "optimizerContext";
1084
- var OPTIMIZER_LEDGER_FIELD = "optimizerLedger";
1085
- var OPTIMIZE_KEEP_DOCK_FIELD = "optimizeKeepDock";
1086
- var OPTIMIZE_READ_TOOLS_FIELD = "optimizeReadTools";
1087
- var OPTIMIZER_FRAMING_FIELD = "optimizerFraming";
1088
- var OPTIMIZER_FRAMINGS = [
1089
- { id: "neutral", label: "\u666E\u901A", hint: "\u7167\u5E38\u7684\u4E66\u9762\u8BED\u57DF\u3002" },
1090
- { id: "hard", label: "\u786C\u90A6\u90A6", hint: "\u6574\u4EFD\u8F85\u52A9\u5305\u90FD\u7528\u53E3\u8BED\u3001\u76F4\u7ED9\u3001\u5E26\u52B2\u7684\u5199\u6CD5\uFF08\u53EA\u6539\u5199\u6CD5\uFF0C\u6761\u76EE\u4E0E\u4F9D\u636E\u89C4\u5219\u4E0D\u53D8\uFF09\u3002" }
1091
- ];
1092
- var DEFAULT_OPTIMIZER_FRAMING = "neutral";
1093
- var OPTIMIZER_PERMISSION_FIELD = "optimizerPermission";
1094
- var OPTIMIZER_PERMISSIONS = [
1095
- { id: "review", label: "\u5BA1\u67E5", hint: "\u6210\u54C1\u8FDB\u7ED3\u679C\u6846\uFF0C\u4F60\u770B\u8FC7\u518D\u70B9\u300C\u63D2\u5165\u8F93\u5165\u6846\u300D\u5199\u56DE\u3002" },
1096
- { id: "auto", label: "\u81EA\u52A8", hint: "\u8DD1\u5B8C\u81EA\u52A8\u628A\u6210\u54C1\u5199\u56DE\u8F93\u5165\u6846\uFF08\u8986\u76D6\u5168\u6587\uFF0CCtrl+Z \u53EF\u8FD8\u539F\uFF09\uFF1B\u4E0D\u4F1A\u81EA\u52A8\u53D1\u9001\u3002" }
1097
- ];
1098
- var DEFAULT_OPTIMIZER_PERMISSION = "review";
1099
- var OPTIMIZER_MODEL_FIELD = "optimizerModel";
1100
- var OPTIMIZER_MODEL_MAX = 120;
1101
- var OPTIMIZER_HISTORY_FIELD = "optimizerHistory";
1102
- var OPTIMIZER_TURNS_FIELD = "optimizerTurns";
1103
- var OPTIMIZER_TURNS_MIN = 0;
1104
- var OPTIMIZER_TURNS_MAX = 10;
1105
- var DEFAULT_OPTIMIZER_TURNS = 6;
1106
- var OPTIMIZE_BASH_FIELD = "optimizeBash";
1107
1024
  function normalizeOptimizerTurns(value) {
1108
1025
  if (typeof value !== "number" || !Number.isFinite(value)) return DEFAULT_OPTIMIZER_TURNS;
1109
1026
  return Math.min(OPTIMIZER_TURNS_MAX, Math.max(OPTIMIZER_TURNS_MIN, Math.round(value)));
1110
1027
  }
1111
- var QUICK_PROMPT_MAX = 60;
1112
- var QUICK_CATEGORY_MAX = 20;
1113
- var QUICK_CATEGORY_NAME_MAX = 40;
1114
- var QUICK_LABEL_MAX = 40;
1115
- var QUICK_TEXT_MAX = 2e5;
1116
- var QUICK_PROMPTS_API_PATH = "/composer-ux/prompts";
1117
- var QUICK_BOOK_VERSION = 2;
1118
- var DEFAULT_CATEGORY_NAME = "\u9ED8\u8BA4";
1119
- var OPTIMIZE_STATE_API_PATH = "/composer-ux/optimize-state";
1120
- var OPTIMIZER_API_PATH = "/composer-ux/optimize";
1121
- var SLASH_COMMAND_RE = /^(\/[A-Za-z][\w-]*)(?:\s+([\s\S]+))?$/;
1122
1028
  function splitSlashCommand(text) {
1123
1029
  const matched = SLASH_COMMAND_RE.exec(text);
1124
1030
  if (matched === null) return { prefix: "", body: text };
1125
1031
  return { prefix: matched[1] ?? "", body: (matched[2] ?? "").trim() };
1126
1032
  }
1127
- var INSERT_MODES = [
1128
- { id: "never", label: "\u5173", hint: "\u70B9\u6761\u76EE\u53EA\u63D2\u5165\u8F93\u5165\u6846\uFF0C\u53D1\u9001\u65F6\u4E0D\u9644\u52A0" },
1129
- { id: "always", label: "\u6BCF\u6B21", hint: "\u6BCF\u6B21\u53D1\u9001\u90FD\u628A\u8FD9\u6761\u9644\u52A0\u5230\u6D88\u606F\u672B\u5C3E" },
1130
- { id: "first", label: "\u4EC5\u9996\u6B21", hint: "\u53EA\u5728\u5F53\u524D\u4F1A\u8BDD\u7684\u7B2C\u4E00\u6761\u6D88\u606F\u4E0A\u9644\u52A0" }
1131
- ];
1132
1033
  function insertModeOf(prompt) {
1133
1034
  if (prompt.always) return "always";
1134
1035
  if (prompt.firstOnly) return "first";
1135
1036
  return "never";
1136
1037
  }
1137
- var OPTIMIZER_TIERS = [
1138
- { id: "off", label: "\u5173\u95ED", hint: "\u5B8C\u5168\u4E0D\u4F18\u5316\uFF1A\u4E0D\u8C03\u7528\u6A21\u578B\u3001\u4E0D\u78B0\u4F60\u7684\u8F93\u5165\u6846\uFF08\u7B49\u4E8E\u6CA1\u88C5\u8FD9\u4E2A\u529F\u80FD\uFF09\u3002" },
1139
- { id: "light", label: "\u8F7B\u5EA6", hint: "\u5355\u4E00\u89E3\u8BFB\uFF1A\u53EA\u628A\u300C\u4F60\u8FD9\u4E00\u8F6E\u5230\u5E95\u8981\u4EC0\u4E48\u300D\u7406\u6E05\u695A\uFF0C\u6700\u591A 4 \u6761\uFF0C\u4E0D\u4EA7\u51FA\u5E76\u5217\u5019\u9009\u3002" },
1140
- { id: "standard", label: "\u6807\u51C6", hint: "\u6761\u76EE\u5185\u5E76\u5217\uFF1A\u8D28\u91CF\u8BCD\u843D\u5230\u53EF\u68C0\u7EF4\u5EA6\uFF08\u81F3\u5C11 1 \u6761\uFF09\uFF0C\u6700\u591A 8 \u6761\u3002" },
1141
- { id: "heavy", label: "\u91CD\u5EA6", hint: "\u591A\u5047\u8BBE\u5206\u652F\uFF1A\u540C\u4E00\u53E5\u8BDD\u6709\u51E0\u79CD\u8BFB\u6CD5\u5C31\u5217\u5019\u9009\uFF08\u6700\u591A 3 \u4E2A\uFF09\uFF0C\u8D28\u91CF\u7EF4\u5EA6\u81F3\u5C11 2 \u6761\uFF0C\u6700\u591A 12 \u6761\uFF0C\u601D\u8003\u66F4\u6DF1\u3002" }
1142
- ];
1143
- var DEFAULT_OPTIMIZER_TIER = "standard";
1144
- var LEGACY_OPTIMIZER_TIERS = Object.freeze({
1145
- basic: "light",
1146
- advanced: "standard",
1147
- extreme: "heavy"
1148
- });
1149
1038
  function normalizeOptimizerTier(value) {
1150
1039
  const raw = typeof value === "string" ? value.trim() : "";
1151
1040
  if (raw === "off" || raw === "light" || raw === "standard" || raw === "heavy") return raw;
1152
1041
  return LEGACY_OPTIMIZER_TIERS[raw] ?? DEFAULT_OPTIMIZER_TIER;
1153
1042
  }
1154
- var OPTIMIZER_PROMPT_FIELDS = {
1155
- light: "optimizerPromptLight",
1156
- standard: "optimizerPromptStandard",
1157
- heavy: "optimizerPromptHeavy"
1158
- };
1159
- var LEGACY_OPTIMIZER_PROMPT_FIELDS = {
1160
- light: "optimizerPromptBasic",
1161
- standard: "optimizerPromptAdvanced",
1162
- heavy: "optimizerPromptExtreme"
1163
- };
1164
- var OPTIMIZER_PROMPT_FIELD_LIST = OPTIMIZER_TIERS.filter((item) => item.id !== "off").map((item) => OPTIMIZER_PROMPT_FIELDS[item.id]);
1165
- var OPTIMIZER_PROMPT_MAX = 2e4;
1166
1043
  function optimizerPromptFieldOf(tier) {
1167
1044
  if (tier === "off") return "";
1168
1045
  return OPTIMIZER_PROMPT_FIELDS[tier] ?? OPTIMIZER_PROMPT_FIELDS[DEFAULT_OPTIMIZER_TIER];
1169
1046
  }
1170
- var DEFAULT_QUICK_PROMPTS = [
1171
- { id: "builtin-1", label: "\u4E00\u95EE\u4E00\u7B54", prompt: "\u4F60\u4E0D\u61C2\u7684\u5C31\u95EE\u6211\uFF0C\u4E00\u95EE\u4E00\u7B54\uFF1B\u540C\u65F6\u8BF4\u6E05\u695A\u4F60\u4E3A\u4EC0\u4E48\u8981\u95EE\u8BE5\u95EE\u9898\uFF1B\u76F4\u5230\u4F60\u5BF9\u6211\u7684\u76EE\u6807\u6709\u660E\u786E\u8BA4\u77E5\u540E\u518D\u5F00\u59CB\u5E72\u6D3B\u3002", always: false, firstOnly: false },
1172
- { id: "builtin-2", label: "\u4EA4\u63A5\u6587\u6863", prompt: "\u628A\u8FD9\u6B21\u4EFB\u52A1\u3001\u5DF2\u5B8C\u6210\u5185\u5BB9\u3001\u5F53\u524D\u5361\u70B9\u3001\u4E0B\u4E00\u6B65\u8BA1\u5212\u3001\u8E29\u8FC7\u7684\u5751\uFF0C\u6574\u7406\u6210\u4E00\u4EFD\u4EA4\u63A5\u6587\u6863\uFF0C\u5199\u7ED9\u65B0\u4F1A\u8BDD\u770B\u3002", always: false, firstOnly: false },
1173
- { id: "builtin-3", label: "\u4EC5\u8BF4\u660E\u539F\u56E0", prompt: "\u4EC5\u8BF4\u660E\u539F\u56E0\uFF0C\u4E0D\u8981\u505A\u5176\u4ED6\u52A8\u4F5C\u3002", always: false, firstOnly: false },
1174
- { id: "builtin-4", label: "\u5206\u6790\u540E\u76F4\u63A5\u5E72", prompt: "\u5206\u6790\u539F\u56E0\uFF0C\u7136\u540E\u76F4\u63A5\u5F00\u59CB\u5E72\u6D3B\uFF0C\u4E0D\u9700\u8981\u8FC7\u95EE\u6211\u3002", always: false, firstOnly: false },
1175
- { id: "builtin-5", label: "\u63D0\u4EA4\u4EE3\u7801", prompt: "\u8BF7\u5E2E\u6211\u63D0\u4EA4\u4EE3\u7801\uFF1A\u68C0\u67E5\u5F53\u524D git \u53D8\u66F4\uFF0C\u751F\u6210\u89C4\u8303\u7684 commit message \u5E76\u6267\u884C\u63D0\u4EA4\u3002", always: false, firstOnly: false },
1176
- { id: "builtin-6", label: "\u7ED9\u65B9\u6848", prompt: "\u8BF7\u9488\u5BF9\u4E0A\u9762\u7684\u95EE\u9898\u7ED9\u51FA\u4E00\u4E2A\u5B8C\u6574\u65B9\u6848\uFF0C\u5305\u62EC\u601D\u8DEF\u3001\u6B65\u9AA4\u3001\u6CE8\u610F\u4E8B\u9879\u548C\u98CE\u9669\u3002", always: false, firstOnly: false },
1177
- { id: "builtin-7", label: "\u89E3\u91CA\u4EE3\u7801", prompt: "\u8BF7\u89E3\u91CA\u8FD9\u6BB5\u4EE3\u7801\u7684\u4F5C\u7528\u548C\u5B9E\u73B0\u601D\u8DEF\u3002", always: false, firstOnly: false },
1178
- { id: "builtin-8", label: "\u5199\u6D4B\u8BD5", prompt: "\u8BF7\u4E3A\u4E0B\u9762\u7684\u4EE3\u7801\u7F16\u5199\u5355\u5143\u6D4B\u8BD5\u3002", always: false, firstOnly: false },
1179
- { id: "builtin-9", label: "\u4EE3\u7801\u5BA1\u67E5", prompt: "\u8BF7\u5BF9\u4E0B\u9762\u7684\u4EE3\u7801\u8FDB\u884C\u4EE3\u7801\u5BA1\u67E5\uFF0C\u6307\u51FA\u95EE\u9898\u5E76\u7ED9\u51FA\u6539\u8FDB\u5EFA\u8BAE\u3002", always: false, firstOnly: false }
1180
- ];
1181
1047
  function newQuickPromptId() {
1182
1048
  return `qp-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
1183
1049
  }
@@ -1275,90 +1141,6 @@ function appendBatchForSend(book, blank) {
1275
1141
  if (!blank) return every;
1276
1142
  return [...every, ...firstOnlyQuickPrompts(book)];
1277
1143
  }
1278
- var HEADER_ENABLED_FIELD = "headerEnabled";
1279
- var HEADER_NAME_FIELD = "headerName";
1280
- var HEADER_VALUE_FIELD = "headerValue";
1281
- var HEADER_ROUTES_FIELD = "headerRoutes";
1282
- var HEADER_APPLIED_NAME_FIELD = "headerAppliedName";
1283
- var HEADER_APPLIED_VALUE_FIELD = "headerAppliedValue";
1284
- var HEADER_STATUS_FIELD = "headerStatus";
1285
- var NATIVE_STATUS_PREFIX = "\u5BBF\u4E3B\u5DF2\u539F\u751F\u652F\u6301";
1286
- var DEFAULT_HEADER_NAME = "x-opencode-session";
1287
- var HEADER_VALUE_MAX = 200;
1288
- var HEADER_NAME_MAX = 64;
1289
- var DEFAULT_SETTINGS = {
1290
- // 微信通知:默认全关全空(0.17.0)。
1291
- notifyEnabled: false,
1292
- notifyChannel: "pushplus",
1293
- notifyPushplusToken: "",
1294
- notifyWecomWebhook: "",
1295
- notifyKinds: { "needs-input": true, done: true, error: true },
1296
- // 工作区目录选择自适应:默认**关**(0.19.0)。接管官方槽位这件事必须由用户自己点。
1297
- directoryPickEnabled: false,
1298
- // 总开关默认开:它只是总闸,真正"要不要用这一栏"由下面五个开关决定(默认关)。
1299
- enabled: true,
1300
- // 五栏默认关(老文档由 sectionEnabledOf 迁移成"碰过就开")。
1301
- keysEnabled: false,
1302
- menuEnabled: false,
1303
- quickEnabled: false,
1304
- panelEnabled: false,
1305
- terminalEnabled: false,
1306
- sendKey: "Enter",
1307
- newlineKey: "Shift+Enter",
1308
- menuUndo: true,
1309
- menuRedo: true,
1310
- menuCut: true,
1311
- menuCopy: true,
1312
- menuPaste: true,
1313
- menuDelete: true,
1314
- menuSelectAll: true,
1315
- menuMode: "official",
1316
- panelResize: true,
1317
- headerEnabled: false,
1318
- headerName: DEFAULT_HEADER_NAME,
1319
- headerValue: "",
1320
- headerRoutes: "",
1321
- headerAppliedName: "",
1322
- headerAppliedValue: "",
1323
- headerStatus: "",
1324
- quickPrompts: DEFAULT_QUICK_PROMPTS,
1325
- optimizerTier: DEFAULT_OPTIMIZER_TIER,
1326
- optimizerContext: true,
1327
- // 台账默认开:只写数字与原因,不写一个字原文,所以默认开不冒隐私风险。
1328
- optimizerLedger: true,
1329
- // 默认开:重启/刷新后上一轮结果还在框里(关掉就每次都要重跑一遍模型)。
1330
- optimizeKeepDock: true,
1331
- // 只读工具默认**关**:它会真的多花时间与 token(开了才走工具轮次)。
1332
- optimizeReadTools: false,
1333
- optimizerFraming: DEFAULT_OPTIMIZER_FRAMING,
1334
- optimizerPermission: DEFAULT_OPTIMIZER_PERMISSION,
1335
- optimizerModel: "",
1336
- optimizerHistory: "turns",
1337
- optimizerTurns: DEFAULT_OPTIMIZER_TURNS,
1338
- optimizeBash: false,
1339
- // 空串 = 用内置提示词。默认必须是空串:它同时就是「恢复内置」要写回去的值。
1340
- optimizerPromptLight: "",
1341
- optimizerPromptStandard: "",
1342
- optimizerPromptHeavy: "",
1343
- terminalMode: DEFAULT_TERMINAL_MODE,
1344
- terminalBashPath: "",
1345
- terminalCandidates: [],
1346
- terminalStatus: "",
1347
- terminalEffective: "",
1348
- // 「统计行」(0.7.0):默认开 —— 用户 2026-09-28 要的是"装完立刻看得到效果",
1349
- // 所以这一栏不参与下面那套"碰过才开"的迁移(见 STATS_ENABLED_FIELD 上方的说明)。
1350
- statsEnabled: true,
1351
- // 「金额」(0.9.1):默认没有覆盖价 = 全部按内置刊例价估算(与 0.8.0 的行为一致)。
1352
- priceOverrides: void 0,
1353
- // 「金额」(0.10.0):节假日表留空 = 用内置(国务院 2026 年安排那份)。
1354
- peakHolidays: void 0,
1355
- peakAlert: DEFAULT_PEAK_ALERT,
1356
- // 余额默认开:它是"看一眼就知道还能不能跑"的东西;关掉是给不想出网的人留的开关。
1357
- balanceEnabled: true,
1358
- syncedPrices: void 0,
1359
- // 自动同步默认**关**:用户没点过就不该有定时出网。
1360
- priceAutoSync: false
1361
- };
1362
1144
  function activeSections(settings) {
1363
1145
  const on = settings.enabled;
1364
1146
  return {
@@ -1371,17 +1153,6 @@ function activeSections(settings) {
1371
1153
  stats: on && settings.statsEnabled
1372
1154
  };
1373
1155
  }
1374
- var SEND_PRESETS = ["Enter", "Ctrl+Enter", "Alt+Enter", "Shift+Enter"];
1375
- var NEWLINE_PRESETS = ["Shift+Enter", "Enter", "Ctrl+Enter", "Alt+Enter"];
1376
- var MENU_ITEMS = [
1377
- { field: "menuUndo", label: "\u64A4\u9500", shortcut: "Ctrl+Z" },
1378
- { field: "menuRedo", label: "\u91CD\u505A", shortcut: "Ctrl+Y" },
1379
- { field: "menuCut", label: "\u526A\u5207", shortcut: "Ctrl+X" },
1380
- { field: "menuCopy", label: "\u590D\u5236", shortcut: "Ctrl+C" },
1381
- { field: "menuPaste", label: "\u7C98\u8D34", shortcut: "Ctrl+V" },
1382
- { field: "menuDelete", label: "\u5220\u9664", shortcut: "" },
1383
- { field: "menuSelectAll", label: "\u5168\u9009", shortcut: "Ctrl+A" }
1384
- ];
1385
1156
  function newSessionId() {
1386
1157
  const bag = globalThis;
1387
1158
  if (typeof bag.crypto?.randomUUID === "function") return bag.crypto.randomUUID();
@@ -1391,15 +1162,6 @@ function newSessionId() {
1391
1162
  ).join("");
1392
1163
  return `${hex(8)}-${hex(4)}-4${hex(3)}-a${hex(3)}-${hex(12)}`;
1393
1164
  }
1394
- var SECTION_SIGNALS = {
1395
- [KEYS_ENABLED_FIELD]: (source) => touched(source, SEND_KEY_FIELD, DEFAULT_SETTINGS.sendKey) || touched(source, NEWLINE_KEY_FIELD, DEFAULT_SETTINGS.newlineKey),
1396
- // 「官方」=本插件不介入,等价于关;所以只有选过另外两档才算"碰过"。
1397
- // (`menuModeFrom` 对"两个键都没有"给的就是 'official',天然满足"缺省 = 默认"。)
1398
- [MENU_ENABLED_FIELD]: (source) => menuModeFrom(source[MENU_MODE_FIELD], source[MENU_NATIVE_FIELD]) !== "official",
1399
- [QUICK_ENABLED_FIELD]: (source) => Array.isArray(source[QUICK_PROMPTS_FIELD]) && source[QUICK_PROMPTS_FIELD].length !== DEFAULT_QUICK_PROMPTS.length || touched(source, OPTIMIZER_TIER_FIELD, DEFAULT_OPTIMIZER_TIER),
1400
- [PANEL_ENABLED_FIELD]: (source) => touched(source, PANEL_RESIZE_FIELD, true) || source[PANEL_WIDTH_FIELD] !== void 0 || source[PANEL_HEIGHT_FIELD] !== void 0,
1401
- [TERMINAL_ENABLED_FIELD]: (source) => touched(source, TERMINAL_MODE_FIELD, DEFAULT_TERMINAL_MODE) || touched(source, TERMINAL_BASH_PATH_FIELD, "")
1402
- };
1403
1165
  function touched(source, field, untouched) {
1404
1166
  const value = source[field];
1405
1167
  return value !== void 0 && value !== untouched;
@@ -1594,10 +1356,363 @@ function sanitizeSettings(value) {
1594
1356
  priceAutoSync: asBool(PRICE_AUTO_SYNC_FIELD)
1595
1357
  };
1596
1358
  }
1597
- var AUTOSTART_API_PATH = "/composer-ux/autostart";
1598
- var DOCTOR_API_PATH = "/composer-ux/doctor";
1359
+ var NAMESPACE, REPO_URL, SITE_URL, RESTART_API_PATH, USAGE_API_PATH, QUOTA_API_PATH, NAV_FOLD_API_PATH, MODELS_API_PATH, RESTART_CSRF_HEADER, RESTART_CSRF_VALUE, SYNC_API_PATH, ENABLED_FIELD, NOTIFY_ENABLED_FIELD, NOTIFY_CHANNEL_FIELD, NOTIFY_PUSHPLUS_FIELD, NOTIFY_WECOM_FIELD, NOTIFY_KINDS_FIELD, NOTIFY_TEST_API_PATH, DIRECTORY_PICK_ENABLED_FIELD, KEYS_ENABLED_FIELD, MENU_ENABLED_FIELD, QUICK_ENABLED_FIELD, PANEL_ENABLED_FIELD, TERMINAL_ENABLED_FIELD, STATS_ENABLED_FIELD, PRICE_OVERRIDES_FIELD, PEAK_HOLIDAYS_FIELD, HOLIDAY_SOURCE_LABEL, PEAK_ALERT_FIELD, PRICE_AUTO_SYNC_FIELD, BALANCE_ENABLED_FIELD, SYNCED_PRICES_FIELD, DEFAULT_PEAK_ALERT, SEND_KEY_FIELD, NEWLINE_KEY_FIELD, PANEL_RESIZE_FIELD, PANEL_WIDTH_FIELD, PANEL_HEIGHT_FIELD, MENU_FIELDS, MENU_MODE_FIELD, MENU_NATIVE_FIELD, MENU_MODES, QUICK_PROMPTS_FIELD, OPTIMIZER_TIER_FIELD, OPTIMIZER_CONTEXT_FIELD, OPTIMIZER_LEDGER_FIELD, OPTIMIZE_KEEP_DOCK_FIELD, OPTIMIZE_READ_TOOLS_FIELD, OPTIMIZER_FRAMING_FIELD, OPTIMIZER_FRAMINGS, DEFAULT_OPTIMIZER_FRAMING, OPTIMIZER_PERMISSION_FIELD, OPTIMIZER_PERMISSIONS, DEFAULT_OPTIMIZER_PERMISSION, OPTIMIZER_MODEL_FIELD, OPTIMIZER_MODEL_MAX, OPTIMIZER_HISTORY_FIELD, OPTIMIZER_TURNS_FIELD, OPTIMIZER_TURNS_MIN, OPTIMIZER_TURNS_MAX, DEFAULT_OPTIMIZER_TURNS, OPTIMIZE_BASH_FIELD, QUICK_PROMPT_MAX, QUICK_CATEGORY_MAX, QUICK_CATEGORY_NAME_MAX, QUICK_LABEL_MAX, QUICK_TEXT_MAX, QUICK_PROMPTS_API_PATH, QUICK_BOOK_VERSION, DEFAULT_CATEGORY_NAME, OPTIMIZE_STATE_API_PATH, OPTIMIZER_API_PATH, SLASH_COMMAND_RE, INSERT_MODES, OPTIMIZER_TIERS, DEFAULT_OPTIMIZER_TIER, LEGACY_OPTIMIZER_TIERS, OPTIMIZER_PROMPT_FIELDS, LEGACY_OPTIMIZER_PROMPT_FIELDS, OPTIMIZER_PROMPT_FIELD_LIST, OPTIMIZER_PROMPT_MAX, DEFAULT_QUICK_PROMPTS, HEADER_ENABLED_FIELD, HEADER_NAME_FIELD, HEADER_VALUE_FIELD, HEADER_ROUTES_FIELD, HEADER_APPLIED_NAME_FIELD, HEADER_APPLIED_VALUE_FIELD, HEADER_STATUS_FIELD, NATIVE_STATUS_PREFIX, DEFAULT_HEADER_NAME, HEADER_VALUE_MAX, HEADER_NAME_MAX, DEFAULT_SETTINGS, SEND_PRESETS, NEWLINE_PRESETS, MENU_ITEMS, SECTION_SIGNALS, AUTOSTART_API_PATH, DOCTOR_API_PATH;
1360
+ var init_settings_contract = __esm({
1361
+ "src/settings-contract.ts"() {
1362
+ init_pricing();
1363
+ init_contracts();
1364
+ NAMESPACE = "composer-ux";
1365
+ REPO_URL = "https://github.com/fangwen9527/dsh-composer-ux";
1366
+ SITE_URL = "https://www.deepseek.com/harness/";
1367
+ RESTART_API_PATH = "/composer-ux/restart";
1368
+ USAGE_API_PATH = "/composer-ux/usage";
1369
+ QUOTA_API_PATH = "/composer-ux/quota";
1370
+ NAV_FOLD_API_PATH = "/composer-ux/nav-fold";
1371
+ MODELS_API_PATH = "/composer-ux/models";
1372
+ RESTART_CSRF_HEADER = "x-composer-ux-restart";
1373
+ RESTART_CSRF_VALUE = "1";
1374
+ SYNC_API_PATH = "/composer-ux/sync-prices";
1375
+ ENABLED_FIELD = "enabled";
1376
+ NOTIFY_ENABLED_FIELD = "notifyEnabled";
1377
+ NOTIFY_CHANNEL_FIELD = "notifyChannel";
1378
+ NOTIFY_PUSHPLUS_FIELD = "notifyPushplusToken";
1379
+ NOTIFY_WECOM_FIELD = "notifyWecomWebhook";
1380
+ NOTIFY_KINDS_FIELD = "notifyKinds";
1381
+ NOTIFY_TEST_API_PATH = "/composer-ux/notify/test";
1382
+ DIRECTORY_PICK_ENABLED_FIELD = "directoryPickEnabled";
1383
+ KEYS_ENABLED_FIELD = "keysEnabled";
1384
+ MENU_ENABLED_FIELD = "menuEnabled";
1385
+ QUICK_ENABLED_FIELD = "quickEnabled";
1386
+ PANEL_ENABLED_FIELD = "panelEnabled";
1387
+ TERMINAL_ENABLED_FIELD = "terminalEnabled";
1388
+ STATS_ENABLED_FIELD = "statsEnabled";
1389
+ PRICE_OVERRIDES_FIELD = "priceOverrides";
1390
+ PEAK_HOLIDAYS_FIELD = "peakHolidays";
1391
+ HOLIDAY_SOURCE_LABEL = "holiday-cn\uFF08\u6570\u636E\u53D6\u81EA\u56FD\u52A1\u9662\u529E\u516C\u5385\u901A\u77E5\uFF09";
1392
+ PEAK_ALERT_FIELD = "peakAlert";
1393
+ PRICE_AUTO_SYNC_FIELD = "priceAutoSync";
1394
+ BALANCE_ENABLED_FIELD = "balanceEnabled";
1395
+ SYNCED_PRICES_FIELD = "syncedPrices";
1396
+ DEFAULT_PEAK_ALERT = {
1397
+ enabled: true,
1398
+ aheadMinutes: 5,
1399
+ onPeak: true,
1400
+ onOffPeak: true,
1401
+ webNotify: false
1402
+ };
1403
+ SEND_KEY_FIELD = "sendKey";
1404
+ NEWLINE_KEY_FIELD = "newlineKey";
1405
+ PANEL_RESIZE_FIELD = "panelResize";
1406
+ PANEL_WIDTH_FIELD = "panelWidth";
1407
+ PANEL_HEIGHT_FIELD = "panelHeight";
1408
+ MENU_FIELDS = [
1409
+ "menuUndo",
1410
+ "menuRedo",
1411
+ "menuCut",
1412
+ "menuCopy",
1413
+ "menuPaste",
1414
+ "menuDelete",
1415
+ "menuSelectAll"
1416
+ ];
1417
+ MENU_MODE_FIELD = "menuMode";
1418
+ MENU_NATIVE_FIELD = "menuNative";
1419
+ MENU_MODES = [
1420
+ {
1421
+ id: "official",
1422
+ label: "\u5B98\u65B9",
1423
+ hint: "\u672C\u63D2\u4EF6\u5B8C\u5168\u4E0D\u4ECB\u5165\uFF1ADSH \u4E0E\u5176\u5B83\u63D2\u4EF6\u81EA\u5DF1\u7684\u53F3\u952E\u5904\u7406\u539F\u6837\u751F\u6548\uFF08DSH \u5B98\u65B9\u8F93\u5165\u6846\u672C\u8EAB\u6CA1\u6709\u53F3\u952E\u83DC\u5355\uFF0C\u901A\u5E38\u770B\u5230\u7684\u5C31\u662F\u6D4F\u89C8\u5668\u7684\u83DC\u5355\uFF09"
1424
+ },
1425
+ {
1426
+ id: "browser",
1427
+ label: "\u6D4F\u89C8\u5668",
1428
+ hint: "\u56FA\u5B9A\u4F7F\u7528\u6D4F\u89C8\u5668\u81EA\u5E26\u7684\u83DC\u5355\uFF0C\u5E76\u5728\u672C\u63D2\u4EF6\u8FD9\u4E00\u5C42\u6321\u4F4F\u5176\u5B83\u63D2\u4EF6\u7684\u83DC\u5355\uFF1B\u7C98\u8D34\u514D\u6388\u6743\u3001\u96F6\u914D\u7F6E"
1429
+ },
1430
+ {
1431
+ id: "custom",
1432
+ label: "\u81EA\u5B9A\u4E49",
1433
+ hint: "\u4F7F\u7528\u672C\u63D2\u4EF6\u7684\u56FA\u5B9A\u6837\u5F0F\u83DC\u5355\uFF1B\u672A\u9009\u4E2D\u6587\u672C\u65F6\u300C\u526A\u5207 / \u590D\u5236 / \u5220\u9664\u300D\u7F6E\u7070\uFF0C\u7C98\u8D34\u9700\u8981\u6D4F\u89C8\u5668\u526A\u8D34\u677F\u6388\u6743"
1434
+ }
1435
+ ];
1436
+ QUICK_PROMPTS_FIELD = "quickPrompts";
1437
+ OPTIMIZER_TIER_FIELD = "optimizerTier";
1438
+ OPTIMIZER_CONTEXT_FIELD = "optimizerContext";
1439
+ OPTIMIZER_LEDGER_FIELD = "optimizerLedger";
1440
+ OPTIMIZE_KEEP_DOCK_FIELD = "optimizeKeepDock";
1441
+ OPTIMIZE_READ_TOOLS_FIELD = "optimizeReadTools";
1442
+ OPTIMIZER_FRAMING_FIELD = "optimizerFraming";
1443
+ OPTIMIZER_FRAMINGS = [
1444
+ { id: "neutral", label: "\u666E\u901A", hint: "\u7167\u5E38\u7684\u4E66\u9762\u8BED\u57DF\u3002" },
1445
+ { id: "hard", label: "\u786C\u90A6\u90A6", hint: "\u6574\u4EFD\u8F85\u52A9\u5305\u90FD\u7528\u53E3\u8BED\u3001\u76F4\u7ED9\u3001\u5E26\u52B2\u7684\u5199\u6CD5\uFF08\u53EA\u6539\u5199\u6CD5\uFF0C\u6761\u76EE\u4E0E\u4F9D\u636E\u89C4\u5219\u4E0D\u53D8\uFF09\u3002" }
1446
+ ];
1447
+ DEFAULT_OPTIMIZER_FRAMING = "neutral";
1448
+ OPTIMIZER_PERMISSION_FIELD = "optimizerPermission";
1449
+ OPTIMIZER_PERMISSIONS = [
1450
+ { id: "review", label: "\u5BA1\u67E5", hint: "\u6210\u54C1\u8FDB\u7ED3\u679C\u6846\uFF0C\u4F60\u770B\u8FC7\u518D\u70B9\u300C\u63D2\u5165\u8F93\u5165\u6846\u300D\u5199\u56DE\u3002" },
1451
+ { id: "auto", label: "\u81EA\u52A8", hint: "\u8DD1\u5B8C\u81EA\u52A8\u628A\u6210\u54C1\u5199\u56DE\u8F93\u5165\u6846\uFF08\u8986\u76D6\u5168\u6587\uFF0CCtrl+Z \u53EF\u8FD8\u539F\uFF09\uFF1B\u4E0D\u4F1A\u81EA\u52A8\u53D1\u9001\u3002" }
1452
+ ];
1453
+ DEFAULT_OPTIMIZER_PERMISSION = "review";
1454
+ OPTIMIZER_MODEL_FIELD = "optimizerModel";
1455
+ OPTIMIZER_MODEL_MAX = 120;
1456
+ OPTIMIZER_HISTORY_FIELD = "optimizerHistory";
1457
+ OPTIMIZER_TURNS_FIELD = "optimizerTurns";
1458
+ OPTIMIZER_TURNS_MIN = 0;
1459
+ OPTIMIZER_TURNS_MAX = 10;
1460
+ DEFAULT_OPTIMIZER_TURNS = 6;
1461
+ OPTIMIZE_BASH_FIELD = "optimizeBash";
1462
+ QUICK_PROMPT_MAX = 60;
1463
+ QUICK_CATEGORY_MAX = 20;
1464
+ QUICK_CATEGORY_NAME_MAX = 40;
1465
+ QUICK_LABEL_MAX = 40;
1466
+ QUICK_TEXT_MAX = 2e5;
1467
+ QUICK_PROMPTS_API_PATH = "/composer-ux/prompts";
1468
+ QUICK_BOOK_VERSION = 2;
1469
+ DEFAULT_CATEGORY_NAME = "\u9ED8\u8BA4";
1470
+ OPTIMIZE_STATE_API_PATH = "/composer-ux/optimize-state";
1471
+ OPTIMIZER_API_PATH = "/composer-ux/optimize";
1472
+ SLASH_COMMAND_RE = /^(\/[A-Za-z][\w-]*)(?:\s+([\s\S]+))?$/;
1473
+ INSERT_MODES = [
1474
+ { id: "never", label: "\u5173", hint: "\u70B9\u6761\u76EE\u53EA\u63D2\u5165\u8F93\u5165\u6846\uFF0C\u53D1\u9001\u65F6\u4E0D\u9644\u52A0" },
1475
+ { id: "always", label: "\u6BCF\u6B21", hint: "\u6BCF\u6B21\u53D1\u9001\u90FD\u628A\u8FD9\u6761\u9644\u52A0\u5230\u6D88\u606F\u672B\u5C3E" },
1476
+ { id: "first", label: "\u4EC5\u9996\u6B21", hint: "\u53EA\u5728\u5F53\u524D\u4F1A\u8BDD\u7684\u7B2C\u4E00\u6761\u6D88\u606F\u4E0A\u9644\u52A0" }
1477
+ ];
1478
+ OPTIMIZER_TIERS = [
1479
+ { id: "off", label: "\u5173\u95ED", hint: "\u5B8C\u5168\u4E0D\u4F18\u5316\uFF1A\u4E0D\u8C03\u7528\u6A21\u578B\u3001\u4E0D\u78B0\u4F60\u7684\u8F93\u5165\u6846\uFF08\u7B49\u4E8E\u6CA1\u88C5\u8FD9\u4E2A\u529F\u80FD\uFF09\u3002" },
1480
+ { id: "light", label: "\u8F7B\u5EA6", hint: "\u5355\u4E00\u89E3\u8BFB\uFF1A\u53EA\u628A\u300C\u4F60\u8FD9\u4E00\u8F6E\u5230\u5E95\u8981\u4EC0\u4E48\u300D\u7406\u6E05\u695A\uFF0C\u6700\u591A 4 \u6761\uFF0C\u4E0D\u4EA7\u51FA\u5E76\u5217\u5019\u9009\u3002" },
1481
+ { id: "standard", label: "\u6807\u51C6", hint: "\u6761\u76EE\u5185\u5E76\u5217\uFF1A\u8D28\u91CF\u8BCD\u843D\u5230\u53EF\u68C0\u7EF4\u5EA6\uFF08\u81F3\u5C11 1 \u6761\uFF09\uFF0C\u6700\u591A 8 \u6761\u3002" },
1482
+ { id: "heavy", label: "\u91CD\u5EA6", hint: "\u591A\u5047\u8BBE\u5206\u652F\uFF1A\u540C\u4E00\u53E5\u8BDD\u6709\u51E0\u79CD\u8BFB\u6CD5\u5C31\u5217\u5019\u9009\uFF08\u6700\u591A 3 \u4E2A\uFF09\uFF0C\u8D28\u91CF\u7EF4\u5EA6\u81F3\u5C11 2 \u6761\uFF0C\u6700\u591A 12 \u6761\uFF0C\u601D\u8003\u66F4\u6DF1\u3002" }
1483
+ ];
1484
+ DEFAULT_OPTIMIZER_TIER = "standard";
1485
+ LEGACY_OPTIMIZER_TIERS = Object.freeze({
1486
+ basic: "light",
1487
+ advanced: "standard",
1488
+ extreme: "heavy"
1489
+ });
1490
+ OPTIMIZER_PROMPT_FIELDS = {
1491
+ light: "optimizerPromptLight",
1492
+ standard: "optimizerPromptStandard",
1493
+ heavy: "optimizerPromptHeavy"
1494
+ };
1495
+ LEGACY_OPTIMIZER_PROMPT_FIELDS = {
1496
+ light: "optimizerPromptBasic",
1497
+ standard: "optimizerPromptAdvanced",
1498
+ heavy: "optimizerPromptExtreme"
1499
+ };
1500
+ OPTIMIZER_PROMPT_FIELD_LIST = OPTIMIZER_TIERS.filter((item) => item.id !== "off").map((item) => OPTIMIZER_PROMPT_FIELDS[item.id]);
1501
+ OPTIMIZER_PROMPT_MAX = 2e4;
1502
+ DEFAULT_QUICK_PROMPTS = [
1503
+ { id: "builtin-1", label: "\u4E00\u95EE\u4E00\u7B54", prompt: "\u4F60\u4E0D\u61C2\u7684\u5C31\u95EE\u6211\uFF0C\u4E00\u95EE\u4E00\u7B54\uFF1B\u540C\u65F6\u8BF4\u6E05\u695A\u4F60\u4E3A\u4EC0\u4E48\u8981\u95EE\u8BE5\u95EE\u9898\uFF1B\u76F4\u5230\u4F60\u5BF9\u6211\u7684\u76EE\u6807\u6709\u660E\u786E\u8BA4\u77E5\u540E\u518D\u5F00\u59CB\u5E72\u6D3B\u3002", always: false, firstOnly: false },
1504
+ { id: "builtin-2", label: "\u4EA4\u63A5\u6587\u6863", prompt: "\u628A\u8FD9\u6B21\u4EFB\u52A1\u3001\u5DF2\u5B8C\u6210\u5185\u5BB9\u3001\u5F53\u524D\u5361\u70B9\u3001\u4E0B\u4E00\u6B65\u8BA1\u5212\u3001\u8E29\u8FC7\u7684\u5751\uFF0C\u6574\u7406\u6210\u4E00\u4EFD\u4EA4\u63A5\u6587\u6863\uFF0C\u5199\u7ED9\u65B0\u4F1A\u8BDD\u770B\u3002", always: false, firstOnly: false },
1505
+ { id: "builtin-3", label: "\u4EC5\u8BF4\u660E\u539F\u56E0", prompt: "\u4EC5\u8BF4\u660E\u539F\u56E0\uFF0C\u4E0D\u8981\u505A\u5176\u4ED6\u52A8\u4F5C\u3002", always: false, firstOnly: false },
1506
+ { id: "builtin-4", label: "\u5206\u6790\u540E\u76F4\u63A5\u5E72", prompt: "\u5206\u6790\u539F\u56E0\uFF0C\u7136\u540E\u76F4\u63A5\u5F00\u59CB\u5E72\u6D3B\uFF0C\u4E0D\u9700\u8981\u8FC7\u95EE\u6211\u3002", always: false, firstOnly: false },
1507
+ { id: "builtin-5", label: "\u63D0\u4EA4\u4EE3\u7801", prompt: "\u8BF7\u5E2E\u6211\u63D0\u4EA4\u4EE3\u7801\uFF1A\u68C0\u67E5\u5F53\u524D git \u53D8\u66F4\uFF0C\u751F\u6210\u89C4\u8303\u7684 commit message \u5E76\u6267\u884C\u63D0\u4EA4\u3002", always: false, firstOnly: false },
1508
+ { id: "builtin-6", label: "\u7ED9\u65B9\u6848", prompt: "\u8BF7\u9488\u5BF9\u4E0A\u9762\u7684\u95EE\u9898\u7ED9\u51FA\u4E00\u4E2A\u5B8C\u6574\u65B9\u6848\uFF0C\u5305\u62EC\u601D\u8DEF\u3001\u6B65\u9AA4\u3001\u6CE8\u610F\u4E8B\u9879\u548C\u98CE\u9669\u3002", always: false, firstOnly: false },
1509
+ { id: "builtin-7", label: "\u89E3\u91CA\u4EE3\u7801", prompt: "\u8BF7\u89E3\u91CA\u8FD9\u6BB5\u4EE3\u7801\u7684\u4F5C\u7528\u548C\u5B9E\u73B0\u601D\u8DEF\u3002", always: false, firstOnly: false },
1510
+ { id: "builtin-8", label: "\u5199\u6D4B\u8BD5", prompt: "\u8BF7\u4E3A\u4E0B\u9762\u7684\u4EE3\u7801\u7F16\u5199\u5355\u5143\u6D4B\u8BD5\u3002", always: false, firstOnly: false },
1511
+ { id: "builtin-9", label: "\u4EE3\u7801\u5BA1\u67E5", prompt: "\u8BF7\u5BF9\u4E0B\u9762\u7684\u4EE3\u7801\u8FDB\u884C\u4EE3\u7801\u5BA1\u67E5\uFF0C\u6307\u51FA\u95EE\u9898\u5E76\u7ED9\u51FA\u6539\u8FDB\u5EFA\u8BAE\u3002", always: false, firstOnly: false }
1512
+ ];
1513
+ HEADER_ENABLED_FIELD = "headerEnabled";
1514
+ HEADER_NAME_FIELD = "headerName";
1515
+ HEADER_VALUE_FIELD = "headerValue";
1516
+ HEADER_ROUTES_FIELD = "headerRoutes";
1517
+ HEADER_APPLIED_NAME_FIELD = "headerAppliedName";
1518
+ HEADER_APPLIED_VALUE_FIELD = "headerAppliedValue";
1519
+ HEADER_STATUS_FIELD = "headerStatus";
1520
+ NATIVE_STATUS_PREFIX = "\u5BBF\u4E3B\u5DF2\u539F\u751F\u652F\u6301";
1521
+ DEFAULT_HEADER_NAME = "x-opencode-session";
1522
+ HEADER_VALUE_MAX = 200;
1523
+ HEADER_NAME_MAX = 64;
1524
+ DEFAULT_SETTINGS = {
1525
+ // 微信通知:默认全关全空(0.17.0)。
1526
+ notifyEnabled: false,
1527
+ notifyChannel: "pushplus",
1528
+ notifyPushplusToken: "",
1529
+ notifyWecomWebhook: "",
1530
+ notifyKinds: { "needs-input": true, done: true, error: true },
1531
+ // 工作区目录选择自适应:默认**关**(0.19.0)。接管官方槽位这件事必须由用户自己点。
1532
+ directoryPickEnabled: false,
1533
+ // 总开关默认开:它只是总闸,真正"要不要用这一栏"由下面五个开关决定(默认关)。
1534
+ enabled: true,
1535
+ // 五栏默认关(老文档由 sectionEnabledOf 迁移成"碰过就开")。
1536
+ keysEnabled: false,
1537
+ menuEnabled: false,
1538
+ quickEnabled: false,
1539
+ panelEnabled: false,
1540
+ terminalEnabled: false,
1541
+ sendKey: "Enter",
1542
+ newlineKey: "Shift+Enter",
1543
+ menuUndo: true,
1544
+ menuRedo: true,
1545
+ menuCut: true,
1546
+ menuCopy: true,
1547
+ menuPaste: true,
1548
+ menuDelete: true,
1549
+ menuSelectAll: true,
1550
+ menuMode: "official",
1551
+ panelResize: true,
1552
+ headerEnabled: false,
1553
+ headerName: DEFAULT_HEADER_NAME,
1554
+ headerValue: "",
1555
+ headerRoutes: "",
1556
+ headerAppliedName: "",
1557
+ headerAppliedValue: "",
1558
+ headerStatus: "",
1559
+ quickPrompts: DEFAULT_QUICK_PROMPTS,
1560
+ optimizerTier: DEFAULT_OPTIMIZER_TIER,
1561
+ optimizerContext: true,
1562
+ // 台账默认开:只写数字与原因,不写一个字原文,所以默认开不冒隐私风险。
1563
+ optimizerLedger: true,
1564
+ // 默认开:重启/刷新后上一轮结果还在框里(关掉就每次都要重跑一遍模型)。
1565
+ optimizeKeepDock: true,
1566
+ // 只读工具默认**关**:它会真的多花时间与 token(开了才走工具轮次)。
1567
+ optimizeReadTools: false,
1568
+ optimizerFraming: DEFAULT_OPTIMIZER_FRAMING,
1569
+ optimizerPermission: DEFAULT_OPTIMIZER_PERMISSION,
1570
+ optimizerModel: "",
1571
+ optimizerHistory: "turns",
1572
+ optimizerTurns: DEFAULT_OPTIMIZER_TURNS,
1573
+ optimizeBash: false,
1574
+ // 空串 = 用内置提示词。默认必须是空串:它同时就是「恢复内置」要写回去的值。
1575
+ optimizerPromptLight: "",
1576
+ optimizerPromptStandard: "",
1577
+ optimizerPromptHeavy: "",
1578
+ terminalMode: DEFAULT_TERMINAL_MODE,
1579
+ terminalBashPath: "",
1580
+ terminalCandidates: [],
1581
+ terminalStatus: "",
1582
+ terminalEffective: "",
1583
+ // 「统计行」(0.7.0):默认开 —— 用户 2026-09-28 要的是"装完立刻看得到效果",
1584
+ // 所以这一栏不参与下面那套"碰过才开"的迁移(见 STATS_ENABLED_FIELD 上方的说明)。
1585
+ statsEnabled: true,
1586
+ // 「金额」(0.9.1):默认没有覆盖价 = 全部按内置刊例价估算(与 0.8.0 的行为一致)。
1587
+ priceOverrides: void 0,
1588
+ // 「金额」(0.10.0):节假日表留空 = 用内置(国务院 2026 年安排那份)。
1589
+ peakHolidays: void 0,
1590
+ peakAlert: DEFAULT_PEAK_ALERT,
1591
+ // 余额默认开:它是"看一眼就知道还能不能跑"的东西;关掉是给不想出网的人留的开关。
1592
+ balanceEnabled: true,
1593
+ syncedPrices: void 0,
1594
+ // 自动同步默认**关**:用户没点过就不该有定时出网。
1595
+ priceAutoSync: false
1596
+ };
1597
+ SEND_PRESETS = ["Enter", "Ctrl+Enter", "Alt+Enter", "Shift+Enter"];
1598
+ NEWLINE_PRESETS = ["Shift+Enter", "Enter", "Ctrl+Enter", "Alt+Enter"];
1599
+ MENU_ITEMS = [
1600
+ { field: "menuUndo", label: "\u64A4\u9500", shortcut: "Ctrl+Z" },
1601
+ { field: "menuRedo", label: "\u91CD\u505A", shortcut: "Ctrl+Y" },
1602
+ { field: "menuCut", label: "\u526A\u5207", shortcut: "Ctrl+X" },
1603
+ { field: "menuCopy", label: "\u590D\u5236", shortcut: "Ctrl+C" },
1604
+ { field: "menuPaste", label: "\u7C98\u8D34", shortcut: "Ctrl+V" },
1605
+ { field: "menuDelete", label: "\u5220\u9664", shortcut: "" },
1606
+ { field: "menuSelectAll", label: "\u5168\u9009", shortcut: "Ctrl+A" }
1607
+ ];
1608
+ SECTION_SIGNALS = {
1609
+ [KEYS_ENABLED_FIELD]: (source) => touched(source, SEND_KEY_FIELD, DEFAULT_SETTINGS.sendKey) || touched(source, NEWLINE_KEY_FIELD, DEFAULT_SETTINGS.newlineKey),
1610
+ // 「官方」=本插件不介入,等价于关;所以只有选过另外两档才算"碰过"。
1611
+ // (`menuModeFrom` 对"两个键都没有"给的就是 'official',天然满足"缺省 = 默认"。)
1612
+ [MENU_ENABLED_FIELD]: (source) => menuModeFrom(source[MENU_MODE_FIELD], source[MENU_NATIVE_FIELD]) !== "official",
1613
+ [QUICK_ENABLED_FIELD]: (source) => Array.isArray(source[QUICK_PROMPTS_FIELD]) && source[QUICK_PROMPTS_FIELD].length !== DEFAULT_QUICK_PROMPTS.length || touched(source, OPTIMIZER_TIER_FIELD, DEFAULT_OPTIMIZER_TIER),
1614
+ [PANEL_ENABLED_FIELD]: (source) => touched(source, PANEL_RESIZE_FIELD, true) || source[PANEL_WIDTH_FIELD] !== void 0 || source[PANEL_HEIGHT_FIELD] !== void 0,
1615
+ [TERMINAL_ENABLED_FIELD]: (source) => touched(source, TERMINAL_MODE_FIELD, DEFAULT_TERMINAL_MODE) || touched(source, TERMINAL_BASH_PATH_FIELD, "")
1616
+ };
1617
+ AUTOSTART_API_PATH = "/composer-ux/autostart";
1618
+ DOCTOR_API_PATH = "/composer-ux/doctor";
1619
+ }
1620
+ });
1621
+
1622
+ // src/client/nav-fold-store.ts
1623
+ var nav_fold_store_exports = {};
1624
+ __export(nav_fold_store_exports, {
1625
+ DEFAULT_NAV_FOLD: () => DEFAULT_NAV_FOLD,
1626
+ NAV_FOLD_MODES: () => NAV_FOLD_MODES,
1627
+ loadNavFold: () => loadNavFold,
1628
+ navFoldSnapshot: () => navFoldSnapshot,
1629
+ sanitizeNavFold: () => sanitizeNavFold,
1630
+ saveNavFold: () => saveNavFold,
1631
+ subscribeNavFold: () => subscribeNavFold,
1632
+ useNavFold: () => useNavFold
1633
+ });
1634
+ function navFoldSnapshot() {
1635
+ return state2;
1636
+ }
1637
+ function subscribeNavFold(listener) {
1638
+ listeners.add(listener);
1639
+ return () => {
1640
+ listeners.delete(listener);
1641
+ };
1642
+ }
1643
+ function setLocal(next) {
1644
+ const merged = { ...state2, ...next };
1645
+ if (merged.mode === state2.mode && merged.collapsed === state2.collapsed) return;
1646
+ state2 = merged;
1647
+ for (const listener of listeners) listener();
1648
+ }
1649
+ function sanitizeNavFold(value) {
1650
+ const raw = value ?? {};
1651
+ const mode = raw.mode === "off" || raw.mode === "icons" || raw.mode === "bar" ? raw.mode : DEFAULT_NAV_FOLD.mode;
1652
+ return { mode, collapsed: typeof raw.collapsed === "boolean" ? raw.collapsed : DEFAULT_NAV_FOLD.collapsed };
1653
+ }
1654
+ async function loadNavFold() {
1655
+ try {
1656
+ const response = await fetch(NAV_FOLD_API_PATH, { headers: { accept: "application/json" } });
1657
+ if (!response.ok) return;
1658
+ const payload = await response.json();
1659
+ setLocal(sanitizeNavFold(payload));
1660
+ } catch {
1661
+ }
1662
+ }
1663
+ async function saveNavFold(patch) {
1664
+ setLocal(patch);
1665
+ try {
1666
+ const response = await fetch(NAV_FOLD_API_PATH, {
1667
+ method: "POST",
1668
+ headers: { "content-type": "application/json" },
1669
+ body: JSON.stringify(patch)
1670
+ });
1671
+ if (!response.ok) return `\u4FDD\u5B58\u6298\u53E0\u72B6\u6001\u5931\u8D25\uFF1A\u5BBF\u4E3B\u8FD4\u56DE HTTP ${response.status}`;
1672
+ const payload = await response.json();
1673
+ if (payload.ok === true) return "";
1674
+ return `\u4FDD\u5B58\u6298\u53E0\u72B6\u6001\u5931\u8D25\uFF1A${payload.error === void 0 || payload.error === "" ? "\u5BBF\u4E3B\u62D2\u7EDD" : payload.error}`;
1675
+ } catch (error) {
1676
+ return `\u4FDD\u5B58\u6298\u53E0\u72B6\u6001\u5931\u8D25\uFF1A${error instanceof Error ? error.message : String(error)}`;
1677
+ }
1678
+ }
1679
+ function useNavFold() {
1680
+ const [snapshot, setSnapshot] = (0, import_react3.useState)(state2);
1681
+ (0, import_react3.useEffect)(() => subscribeNavFold(() => {
1682
+ setSnapshot(state2);
1683
+ }), []);
1684
+ return snapshot;
1685
+ }
1686
+ var import_react3, NAV_FOLD_MODES, DEFAULT_NAV_FOLD, state2, listeners;
1687
+ var init_nav_fold_store = __esm({
1688
+ "src/client/nav-fold-store.ts"() {
1689
+ import_react3 = require("react");
1690
+ init_settings_contract();
1691
+ NAV_FOLD_MODES = [
1692
+ { id: "off", label: "\u4E0D\u6298\u53E0" },
1693
+ { id: "bar", label: "\u6536\u6210\u4E00\u6761" },
1694
+ { id: "icons", label: "\u53EA\u7559\u56FE\u6807" }
1695
+ ];
1696
+ DEFAULT_NAV_FOLD = { mode: "bar", collapsed: true };
1697
+ state2 = DEFAULT_NAV_FOLD;
1698
+ listeners = /* @__PURE__ */ new Set();
1699
+ }
1700
+ });
1701
+
1702
+ // src/client.tsx
1703
+ var client_exports = {};
1704
+ __export(client_exports, {
1705
+ apply: () => apply,
1706
+ inject: () => inject,
1707
+ name: () => name
1708
+ });
1709
+ module.exports = __toCommonJS(client_exports);
1710
+ var import_dsh_client_store = require("@deepseek-ai/dsh-client-store");
1711
+ init_settings_contract();
1712
+ init_contracts();
1599
1713
 
1600
1714
  // src/client/prompt-book.ts
1715
+ init_settings_contract();
1601
1716
  async function requestBook(method, body) {
1602
1717
  try {
1603
1718
  const response = await fetch(QUICK_PROMPTS_API_PATH, {
@@ -1862,6 +1977,7 @@ function displayChord(chord) {
1862
1977
  }
1863
1978
 
1864
1979
  // src/client/quick-commands.ts
1980
+ init_settings_contract();
1865
1981
  var COMPOSER_SELECTOR = "[data-composer-input]";
1866
1982
  var CARD_SELECTOR = "[data-composer-card]";
1867
1983
  var state = { actions: null, draft: "", sessionId: "", blank: false };
@@ -2108,6 +2224,7 @@ async function optimizeDraftStream(text, tier, handlers = {}, signal) {
2108
2224
  }
2109
2225
 
2110
2226
  // src/client/interceptors.ts
2227
+ init_settings_contract();
2111
2228
  var INPUT_SELECTOR = "[data-composer-input]";
2112
2229
  var OVERLAY_SELECTOR = "[data-trigger-menu], [data-conversation-composer-overlay]";
2113
2230
  function findComposerRoot(target) {
@@ -3671,6 +3788,7 @@ function ContextMenuHost({ useMenu, useLive, actions }) {
3671
3788
  // src/client/PanelResizeHandles.tsx
3672
3789
  var import_react2 = require("react");
3673
3790
  var import_react_dom = require("react-dom");
3791
+ init_settings_contract();
3674
3792
  var import_jsx_runtime2 = require("react/jsx-runtime");
3675
3793
  var EDGES = ["left", "right", "top", "bottom", "br"];
3676
3794
  function PanelResizeHandles({ useLive, actions }) {
@@ -3802,10 +3920,180 @@ function PanelResizeHandles({ useLive, actions }) {
3802
3920
  );
3803
3921
  }
3804
3922
 
3923
+ // src/client/NavFoldHost.tsx
3924
+ var import_react4 = require("react");
3925
+ init_nav_fold_store();
3926
+
3927
+ // src/client/sidebar-nav.ts
3928
+ var NAV_LABELS = ["\u5168\u5C40\u9762\u677F", "Global panels"];
3929
+ var PANEL_HINTS = ["\u63D2\u4EF6", "Plugins", "\u81EA\u52A8\u5316\u4EFB\u52A1", "\u4E0A\u4E0B\u6587\u6D1E\u5BDF", "MCP\u8FDE\u63A5\u5668", "\u66F4\u591A", "More"];
3930
+ var NAV_FOLD_HEADER_TEXT = "\u5168\u5C40\u9762\u677F";
3931
+ var NAV_FOLD_ATTR = "data-ux-nav-fold";
3932
+ var NAV_FOLD_HEAD_ATTR = "data-ux-nav-fold-head";
3933
+ var NAV_FOLD_STYLE_ATTR = "data-ux-nav-fold-style";
3934
+ var NAV_FOLD_TITLE_ATTR = "data-ux-nav-title";
3935
+ function navFoldAttrOf(state3) {
3936
+ if (state3.mode === "off") return null;
3937
+ if (state3.mode === "icons") return "icons";
3938
+ return state3.collapsed ? "bar-collapsed" : "bar-open";
3939
+ }
3940
+ var NAV_FOLD_CSS = `
3941
+ nav[${NAV_FOLD_ATTR}='bar-collapsed'] { display: none !important; }
3942
+ nav[${NAV_FOLD_ATTR}='icons'] { flex-direction: row; flex-wrap: wrap; gap: 4px; }
3943
+ nav[${NAV_FOLD_ATTR}='icons'] > button {
3944
+ width: 34px;
3945
+ min-width: 34px;
3946
+ padding-left: 0;
3947
+ padding-right: 0;
3948
+ justify-content: center;
3949
+ }
3950
+ /* \u56FE\u6807\u90A3\u4E00\u9897\u5E26 aria-hidden\uFF0C\u6587\u5B57\u90A3\u9897\u4E0D\u5E26 \u2014\u2014 \u9760\u8BED\u4E49\u85CF\u6587\u5B57\uFF0C\u4E0D\u8BA4\u54C8\u5E0C\u7C7B\u540D\u3002 */
3951
+ nav[${NAV_FOLD_ATTR}='icons'] > button > span:not([aria-hidden='true']) { display: none !important; }
3952
+ /* \u300C\u66F4\u591A\u300D\u90A3\u9897\u6309\u94AE\u7684\u6807\u7B7E\u662F**\u88F8\u6587\u672C\u8282\u70B9**\uFF08\u6CA1\u6709 span\uFF09\uFF0C\u4E0A\u9762\u90A3\u6761\u89C4\u5219\u7BA1\u4E0D\u5230\u5B83\uFF1B
3953
+ \u6240\u4EE5\u56FE\u6807\u6A21\u5F0F\u518D\u8865\u4E00\u5200 fontSize:0\uFF08\u56FE\u6807\u662F SVG\uFF0C\u4E0D\u53D7\u5B57\u53F7\u5F71\u54CD\uFF09\u3002 */
3954
+ nav[${NAV_FOLD_ATTR}='icons'] > button { font-size: 0; }
3955
+ [${NAV_FOLD_HEAD_ATTR}] {
3956
+ display: flex;
3957
+ align-items: center;
3958
+ gap: 6px;
3959
+ width: 100%;
3960
+ box-sizing: border-box;
3961
+ padding: 6px 8px;
3962
+ border: 0;
3963
+ border-radius: 6px;
3964
+ background: transparent;
3965
+ color: var(--dsw-alias-label-tertiary);
3966
+ font: inherit;
3967
+ font-size: 12.5px;
3968
+ text-align: left;
3969
+ cursor: pointer;
3970
+ }
3971
+ [${NAV_FOLD_HEAD_ATTR}]:hover { background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-label-secondary); }
3972
+ [${NAV_FOLD_HEAD_ATTR}]:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary); outline-offset: -2px; }
3973
+ [${NAV_FOLD_HEAD_ATTR}] > span[data-ux-nav-fold-chevron] { margin-left: auto; opacity: .7; }
3974
+ `;
3975
+ function findPanelNav(doc) {
3976
+ const navs = [...doc.querySelectorAll("nav")];
3977
+ for (const nav of navs) {
3978
+ const label = (nav.getAttribute("aria-label") ?? "").trim();
3979
+ if (NAV_LABELS.includes(label)) return nav;
3980
+ }
3981
+ for (const nav of navs) {
3982
+ const texts = [...nav.querySelectorAll("button")].map((button) => (button.getAttribute("aria-label") ?? button.textContent ?? "").trim());
3983
+ if (texts.some((text) => PANEL_HINTS.includes(text))) return nav;
3984
+ }
3985
+ return null;
3986
+ }
3987
+ function ensureStyle(doc) {
3988
+ let tag = doc.querySelector(`style[${NAV_FOLD_STYLE_ATTR}]`);
3989
+ if (tag === null) {
3990
+ tag = doc.createElement("style");
3991
+ tag.setAttribute(NAV_FOLD_STYLE_ATTR, "");
3992
+ doc.head.appendChild(tag);
3993
+ }
3994
+ if (tag.textContent !== NAV_FOLD_CSS) tag.textContent = NAV_FOLD_CSS;
3995
+ }
3996
+ function applyTitles(nav, on) {
3997
+ for (const button of [...nav.querySelectorAll(":scope > button")]) {
3998
+ if (on) {
3999
+ const label = (button.getAttribute("aria-label") ?? "").trim();
4000
+ if (label !== "" && button.getAttribute(NAV_FOLD_TITLE_ATTR) !== label) {
4001
+ button.setAttribute("title", label);
4002
+ button.setAttribute(NAV_FOLD_TITLE_ATTR, label);
4003
+ }
4004
+ for (const span of [...button.querySelectorAll("span")]) {
4005
+ if (span.querySelector("svg") !== null) continue;
4006
+ span.style.display = "none";
4007
+ }
4008
+ continue;
4009
+ }
4010
+ if (button.hasAttribute(NAV_FOLD_TITLE_ATTR)) {
4011
+ button.removeAttribute("title");
4012
+ button.removeAttribute(NAV_FOLD_TITLE_ATTR);
4013
+ }
4014
+ for (const span of [...button.querySelectorAll("span")]) {
4015
+ if (span.style.display === "none") span.style.display = "";
4016
+ }
4017
+ }
4018
+ }
4019
+ function ensureHeader(doc, nav, state3, onToggle) {
4020
+ const want = state3.mode === "bar";
4021
+ let head = doc.querySelector(`button[${NAV_FOLD_HEAD_ATTR}]`);
4022
+ if (!want) {
4023
+ head?.remove();
4024
+ return;
4025
+ }
4026
+ if (head === null) {
4027
+ head = doc.createElement("button");
4028
+ head.type = "button";
4029
+ head.setAttribute(NAV_FOLD_HEAD_ATTR, "");
4030
+ nav.parentElement?.insertBefore(head, nav);
4031
+ }
4032
+ const open = !state3.collapsed;
4033
+ head.setAttribute("aria-expanded", open ? "true" : "false");
4034
+ head.setAttribute("title", open ? "\u6536\u8D77\u5168\u5C40\u9762\u677F" : "\u5C55\u5F00\u5168\u5C40\u9762\u677F");
4035
+ head.textContent = "";
4036
+ const label = doc.createElement("span");
4037
+ label.textContent = NAV_FOLD_HEADER_TEXT;
4038
+ const chevron = doc.createElement("span");
4039
+ chevron.setAttribute("data-ux-nav-fold-chevron", "");
4040
+ chevron.setAttribute("aria-hidden", "true");
4041
+ chevron.textContent = open ? "\u25B4" : "\u25BE";
4042
+ head.append(label, chevron);
4043
+ head.onclick = () => {
4044
+ onToggle(!state3.collapsed);
4045
+ };
4046
+ }
4047
+ function applyNavFold(doc, state3, onToggle) {
4048
+ ensureStyle(doc);
4049
+ const nav = findPanelNav(doc);
4050
+ if (nav === null) return false;
4051
+ const attr = navFoldAttrOf(state3);
4052
+ if (attr === null) nav.removeAttribute(NAV_FOLD_ATTR);
4053
+ else if (nav.getAttribute(NAV_FOLD_ATTR) !== attr) nav.setAttribute(NAV_FOLD_ATTR, attr);
4054
+ applyTitles(nav, state3.mode === "icons");
4055
+ ensureHeader(doc, nav, state3, onToggle);
4056
+ return true;
4057
+ }
4058
+
4059
+ // src/client/NavFoldHost.tsx
4060
+ function NavFoldHost() {
4061
+ const { mode, collapsed } = useNavFold();
4062
+ (0, import_react4.useEffect)(() => {
4063
+ let frame = 0;
4064
+ const apply2 = () => {
4065
+ applyNavFold(document, { mode, collapsed }, (next) => {
4066
+ void Promise.resolve().then(() => (init_nav_fold_store(), nav_fold_store_exports)).then((store) => store.saveNavFold({ collapsed: next }));
4067
+ });
4068
+ };
4069
+ apply2();
4070
+ const nav = findPanelNav(document);
4071
+ const scope = nav?.parentElement ?? document.body;
4072
+ if (scope === null) return void 0;
4073
+ const observer = new MutationObserver(() => {
4074
+ if (frame !== 0) return;
4075
+ frame = window.requestAnimationFrame(() => {
4076
+ frame = 0;
4077
+ apply2();
4078
+ });
4079
+ });
4080
+ observer.observe(scope, { childList: true, subtree: true });
4081
+ return () => {
4082
+ observer.disconnect();
4083
+ if (frame !== 0) window.cancelAnimationFrame(frame);
4084
+ };
4085
+ }, [mode, collapsed]);
4086
+ return null;
4087
+ }
4088
+
4089
+ // src/client.tsx
4090
+ init_nav_fold_store();
4091
+
3805
4092
  // src/client/RestartTitlebarButton.tsx
3806
- var import_react3 = require("react");
4093
+ var import_react5 = require("react");
3807
4094
 
3808
4095
  // src/client/restart-screen.ts
4096
+ init_settings_contract();
3809
4097
  var RESTART_SCREEN_MAX_ATTEMPTS = 120;
3810
4098
  var RESTART_PROGRESS_CAP = 95;
3811
4099
  var RESTART_EXPECTED_DEFAULT_MS = 45e3;
@@ -4005,16 +4293,16 @@ function enterRestartScreen(overrides) {
4005
4293
  el.addEventListener("click", onClick);
4006
4294
  return el;
4007
4295
  };
4008
- let state2 = beginRestartTrack(deps.oldBoot, deps.now());
4296
+ let state3 = beginRestartTrack(deps.oldBoot, deps.now());
4009
4297
  const expected = readLastRestartMs(deps.storage);
4010
4298
  let timer = null;
4011
4299
  let stopped = false;
4012
4300
  const paint = () => {
4013
- const { percent, slow } = restartProgress(state2, deps.now(), expected);
4014
- phase.textContent = restartMessage(state2.phase);
4301
+ const { percent, slow } = restartProgress(state3, deps.now(), expected);
4302
+ phase.textContent = restartMessage(state3.phase);
4015
4303
  bar.style.width = `${String(percent)}%`;
4016
- detail2.textContent = slow && state2.phase !== "up" ? `\u6BD4\u9884\u671F\u6162\u4E00\u4E9B\uFF08\u9884\u671F\u7EA6 ${String(Math.round(expected / 1e3))} \u79D2\uFF09\u2026 \u518D\u7B49\u7B49\uFF0C\u4E0D\u8981\u5173\u6389\u8FD9\u4E2A\u9875\u9762\u3002` : "\u65E7\u8FDB\u7A0B\u9000\u51FA\u540E\u4F1A\u81EA\u52A8\u628A\u65B0\u8FDB\u7A0B\u62C9\u8D77\u6765\uFF0C\u670D\u52A1\u4E00\u56DE\u6765\u8FD9\u4E2A\u9875\u9762\u5C31\u4F1A\u81EA\u5DF1\u5237\u65B0\u3002";
4017
- if (state2.phase === "stuck") {
4304
+ detail2.textContent = slow && state3.phase !== "up" ? `\u6BD4\u9884\u671F\u6162\u4E00\u4E9B\uFF08\u9884\u671F\u7EA6 ${String(Math.round(expected / 1e3))} \u79D2\uFF09\u2026 \u518D\u7B49\u7B49\uFF0C\u4E0D\u8981\u5173\u6389\u8FD9\u4E2A\u9875\u9762\u3002` : "\u65E7\u8FDB\u7A0B\u9000\u51FA\u540E\u4F1A\u81EA\u52A8\u628A\u65B0\u8FDB\u7A0B\u62C9\u8D77\u6765\uFF0C\u670D\u52A1\u4E00\u56DE\u6765\u8FD9\u4E2A\u9875\u9762\u5C31\u4F1A\u81EA\u5DF1\u5237\u65B0\u3002";
4305
+ if (state3.phase === "stuck") {
4018
4306
  spinner.style.display = "none";
4019
4307
  title.textContent = "\u8FD9\u6B21\u91CD\u542F\u53EF\u80FD\u6CA1\u751F\u6548";
4020
4308
  detail2.textContent = deps.logPath === "" ? "\u670D\u52A1\u4E00\u76F4\u5728\u7EBF\uFF0C\u4E14\u6CA1\u6709\u89C2\u5BDF\u5230\u65B0\u8FDB\u7A0B\u3002\u53EF\u4EE5\u624B\u52A8\u5237\u65B0\u9875\u9762\u770B\u770B\u3002" : `\u670D\u52A1\u4E00\u76F4\u5728\u7EBF\uFF0C\u4E14\u6CA1\u6709\u89C2\u5BDF\u5230\u65B0\u8FDB\u7A0B\u3002\u91CD\u542F\u65E5\u5FD7\uFF1A${deps.logPath}`;
@@ -4029,7 +4317,7 @@ function enterRestartScreen(overrides) {
4029
4317
  }
4030
4318
  };
4031
4319
  const finish = () => {
4032
- writeLastRestartMs(deps.storage, deps.now() - state2.startedAt);
4320
+ writeLastRestartMs(deps.storage, deps.now() - state3.startedAt);
4033
4321
  paint();
4034
4322
  deps.reload(restartReloadHref(deps.href));
4035
4323
  stop();
@@ -4038,13 +4326,13 @@ function enterRestartScreen(overrides) {
4038
4326
  if (stopped) return;
4039
4327
  void deps.probe().then((probe) => {
4040
4328
  if (stopped) return;
4041
- state2 = advanceRestartTrack(state2, probe, limit);
4329
+ state3 = advanceRestartTrack(state3, probe, limit);
4042
4330
  paint();
4043
- if (state2.phase === "up") {
4331
+ if (state3.phase === "up") {
4044
4332
  finish();
4045
4333
  return;
4046
4334
  }
4047
- if (state2.phase === "stuck") return;
4335
+ if (state3.phase === "stuck") return;
4048
4336
  timer = deps.setTimer(tick, pollMs);
4049
4337
  });
4050
4338
  };
@@ -4138,7 +4426,7 @@ var STYLE = [
4138
4426
  ".composer-ux-titlebar>button:disabled{cursor:default;opacity:.85}",
4139
4427
  ".composer-ux-titlebar>button[data-error]{border-color:rgba(229,72,77,.6);color:#ffb7b9}"
4140
4428
  ].join("");
4141
- function ensureStyle() {
4429
+ function ensureStyle2() {
4142
4430
  if (typeof document === "undefined" || document.getElementById(STYLE_ID) !== null) return;
4143
4431
  const style = document.createElement("style");
4144
4432
  style.id = STYLE_ID;
@@ -4163,12 +4451,12 @@ function Icon({ spin }) {
4163
4451
  );
4164
4452
  }
4165
4453
  function RestartTitlebarButton() {
4166
- const [armed, setArmed] = (0, import_react3.useState)(false);
4167
- const [busy, setBusy] = (0, import_react3.useState)(false);
4168
- const [error, setError] = (0, import_react3.useState)("");
4169
- const [visible, setVisible] = (0, import_react3.useState)(false);
4170
- (0, import_react3.useEffect)(() => {
4171
- ensureStyle();
4454
+ const [armed, setArmed] = (0, import_react5.useState)(false);
4455
+ const [busy, setBusy] = (0, import_react5.useState)(false);
4456
+ const [error, setError] = (0, import_react5.useState)("");
4457
+ const [visible, setVisible] = (0, import_react5.useState)(false);
4458
+ (0, import_react5.useEffect)(() => {
4459
+ ensureStyle2();
4172
4460
  try {
4173
4461
  setVisible(document.documentElement.hasAttribute("data-windows-titlebar"));
4174
4462
  } catch {
@@ -4216,10 +4504,11 @@ function RestartTitlebarButton() {
4216
4504
  }
4217
4505
 
4218
4506
  // src/client/SettingsSection.tsx
4219
- var import_react10 = require("react");
4507
+ var import_react12 = require("react");
4220
4508
 
4221
4509
  // src/client/DoctorCard.tsx
4222
- var import_react4 = require("react");
4510
+ var import_react6 = require("react");
4511
+ init_settings_contract();
4223
4512
  var import_jsx_runtime4 = require("react/jsx-runtime");
4224
4513
  var LEVEL_COLOR = {
4225
4514
  ok: "var(--dsw-alias-label-primary)",
@@ -4245,8 +4534,8 @@ function sanitizeRows(value) {
4245
4534
  });
4246
4535
  }
4247
4536
  function DoctorCard() {
4248
- const [state2, setState] = (0, import_react4.useState)({ kind: "idle" });
4249
- const run = (0, import_react4.useCallback)(() => {
4537
+ const [state3, setState] = (0, import_react6.useState)({ kind: "idle" });
4538
+ const run = (0, import_react6.useCallback)(() => {
4250
4539
  setState({ kind: "loading" });
4251
4540
  void fetch(DOCTOR_API_PATH, { headers: { accept: "application/json" } }).then(async (response) => {
4252
4541
  const raw = await response.text();
@@ -4278,19 +4567,19 @@ function DoctorCard() {
4278
4567
  {
4279
4568
  type: "button",
4280
4569
  className: "dsh-ux-restartButton",
4281
- disabled: state2.kind === "loading",
4570
+ disabled: state3.kind === "loading",
4282
4571
  onMouseDown: (event) => {
4283
4572
  event.preventDefault();
4284
4573
  },
4285
4574
  onClick: run,
4286
- children: state2.kind === "loading" ? "\u81EA\u68C0\u4E2D\u2026" : "\u8FD0\u884C\u81EA\u68C0"
4575
+ children: state3.kind === "loading" ? "\u81EA\u68C0\u4E2D\u2026" : "\u8FD0\u884C\u81EA\u68C0"
4287
4576
  }
4288
4577
  ) }),
4289
- state2.kind === "error" && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { style: optHint, children: [
4578
+ state3.kind === "error" && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { style: optHint, children: [
4290
4579
  "\u81EA\u68C0\u5931\u8D25\uFF1A",
4291
- state2.message
4580
+ state3.message
4292
4581
  ] }),
4293
- state2.kind === "ok" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { children: state2.rows.map((row2) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", gap: 6, margin: "4px 0" }, children: [
4582
+ state3.kind === "ok" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { children: state3.rows.map((row2) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", gap: 6, margin: "4px 0" }, children: [
4294
4583
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "aria-hidden": true, style: { color: LEVEL_COLOR[row2.level], flex: "0 0 auto" }, children: LEVEL_MARK[row2.level] }),
4295
4584
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { flex: "0 0 auto", color: LEVEL_COLOR[row2.level] }, children: row2.label }),
4296
4585
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { color: "var(--dsw-alias-label-secondary)", minWidth: 0 }, children: row2.detail })
@@ -4302,7 +4591,7 @@ function DoctorCard() {
4302
4591
  var import_jsx_runtime5 = require("react/jsx-runtime");
4303
4592
  function AutostartCard(props) {
4304
4593
  const { view } = props;
4305
- const state2 = view.state;
4594
+ const state3 = view.state;
4306
4595
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
4307
4596
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("p", { style: description, children: [
4308
4597
  "\u6253\u5F00\u540E\uFF0C",
@@ -4319,20 +4608,20 @@ function AutostartCard(props) {
4319
4608
  "\u4E3A\u51C6 \u2014\u2014 \u4F60\u5728\u6CE8\u518C\u8868\u91CC\u624B\u52A8\u5220\u4E86\uFF0C\u8FD9\u91CC\u5C31\u663E\u793A\u5173\u3002"
4320
4609
  ] })
4321
4610
  ] }),
4322
- state2 === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { style: optHint, children: view.error !== "" ? `\u8BFB\u4E0D\u5230\u542F\u52A8\u9879\u72B6\u6001\uFF1A${view.error}` : "\u6B63\u5728\u8BFB\u542F\u52A8\u9879\u72B6\u6001\u2026" }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { margin: "10px 0", fontSize: 12, lineHeight: 1.7 }, children: [
4611
+ state3 === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { style: optHint, children: view.error !== "" ? `\u8BFB\u4E0D\u5230\u542F\u52A8\u9879\u72B6\u6001\uFF1A${view.error}` : "\u6B63\u5728\u8BFB\u542F\u52A8\u9879\u72B6\u6001\u2026" }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { margin: "10px 0", fontSize: 12, lineHeight: 1.7 }, children: [
4323
4612
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
4324
4613
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: { opacity: 0.7 }, children: "\u767B\u5F55\u540E\u4F1A\u6267\u884C\uFF1A" }),
4325
- state2.describe === "" ? "\uFF08\u62FF\u4E0D\u5230\uFF0C\u89C1\u4E0B\u9762\u7684\u63D0\u793A\uFF09" : state2.describe
4614
+ state3.describe === "" ? "\uFF08\u62FF\u4E0D\u5230\uFF0C\u89C1\u4E0B\u9762\u7684\u63D0\u793A\uFF09" : state3.describe
4326
4615
  ] }),
4327
4616
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
4328
4617
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: { opacity: 0.7 }, children: "\u542F\u52A8\u9879\u503C\u540D\uFF1A" }),
4329
- state2.entryName === "" ? "\uFF08\u62FF\u4E0D\u5230\uFF09" : state2.entryName
4618
+ state3.entryName === "" ? "\uFF08\u62FF\u4E0D\u5230\uFF09" : state3.entryName
4330
4619
  ] }),
4331
- state2.supported && state2.registeredValue !== "" && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
4620
+ state3.supported && state3.registeredValue !== "" && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
4332
4621
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: { opacity: 0.7 }, children: "\u7CFB\u7EDF\u91CC\u73B0\u5728\u662F\uFF1A" }),
4333
- state2.registeredValue
4622
+ state3.registeredValue
4334
4623
  ] }),
4335
- !state2.supported && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { color: "#b26a00" }, children: "\u8FD9\u4E00\u680F\u53EA\u5728 Windows \u4E0A\u6709\u610F\u4E49\uFF0C\u5F53\u524D\u5E73\u53F0\u4E0D\u751F\u6548\u3002" })
4624
+ !state3.supported && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { color: "#b26a00" }, children: "\u8FD9\u4E00\u680F\u53EA\u5728 Windows \u4E0A\u6709\u610F\u4E49\uFF0C\u5F53\u524D\u5E73\u53F0\u4E0D\u751F\u6548\u3002" })
4336
4625
  ] }),
4337
4626
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: 8, margin: "10px 0" }, children: [
4338
4627
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
@@ -4340,7 +4629,7 @@ function AutostartCard(props) {
4340
4629
  {
4341
4630
  type: "button",
4342
4631
  className: "dsh-ux-restartButton",
4343
- disabled: view.busy || state2 === void 0,
4632
+ disabled: view.busy || state3 === void 0,
4344
4633
  onMouseDown: (event) => {
4345
4634
  event.preventDefault();
4346
4635
  },
@@ -4350,7 +4639,7 @@ function AutostartCard(props) {
4350
4639
  ),
4351
4640
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: { fontSize: 12, opacity: 0.75 }, children: "\u7528\u81EA\u542F\u52A8\u90A3\u6761\u547D\u4EE4\u771F\u7684\u62C9\u4E00\u6B21\uFF08\u7F51\u9875\u7248\u4F1A\u6700\u5C0F\u5316\u5230\u4EFB\u52A1\u680F\uFF09\uFF0C\u9A8C\u8BC1\u5B83\u5728\u4F60\u8FD9\u53F0\u673A\u5668\u4E0A\u786E\u5B9E\u6709\u6548\u3002" })
4352
4641
  ] }),
4353
- state2 !== void 0 && state2.note !== "" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { style: optHint, children: state2.note }),
4642
+ state3 !== void 0 && state3.note !== "" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { style: optHint, children: state3.note }),
4354
4643
  view.error !== "" && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("p", { style: optHint, children: [
4355
4644
  "\u64CD\u4F5C\u5931\u8D25\uFF1A",
4356
4645
  view.error
@@ -4360,7 +4649,8 @@ function AutostartCard(props) {
4360
4649
  }
4361
4650
 
4362
4651
  // src/client/autostart.ts
4363
- var import_react5 = require("react");
4652
+ var import_react7 = require("react");
4653
+ init_settings_contract();
4364
4654
  var EMPTY = {
4365
4655
  supported: false,
4366
4656
  enabled: false,
@@ -4409,17 +4699,17 @@ async function call(body) {
4409
4699
  }
4410
4700
  }
4411
4701
  function useAutostart(onEnabledChange) {
4412
- const [state2, setState] = (0, import_react5.useState)(void 0);
4413
- const [busy, setBusy] = (0, import_react5.useState)(false);
4414
- const [message, setMessage] = (0, import_react5.useState)("");
4415
- const [error, setError] = (0, import_react5.useState)("");
4416
- const apply2 = (0, import_react5.useCallback)((next) => {
4702
+ const [state3, setState] = (0, import_react7.useState)(void 0);
4703
+ const [busy, setBusy] = (0, import_react7.useState)(false);
4704
+ const [message, setMessage] = (0, import_react7.useState)("");
4705
+ const [error, setError] = (0, import_react7.useState)("");
4706
+ const apply2 = (0, import_react7.useCallback)((next) => {
4417
4707
  setState(next.state);
4418
4708
  setMessage(next.message);
4419
4709
  setError(next.error);
4420
4710
  onEnabledChange?.(next.state.enabled);
4421
4711
  }, [onEnabledChange]);
4422
- const refresh = (0, import_react5.useCallback)(() => {
4712
+ const refresh = (0, import_react7.useCallback)(() => {
4423
4713
  setBusy(true);
4424
4714
  void call().then((result) => {
4425
4715
  apply2({ ...result, message: result.error === "" ? result.message : "" });
@@ -4427,7 +4717,7 @@ function useAutostart(onEnabledChange) {
4427
4717
  setBusy(false);
4428
4718
  });
4429
4719
  }, [apply2]);
4430
- const set = (0, import_react5.useCallback)((next) => {
4720
+ const set = (0, import_react7.useCallback)((next) => {
4431
4721
  setBusy(true);
4432
4722
  setMessage(next ? "\u6B63\u5728\u6CE8\u518C\u2026" : "\u6B63\u5728\u64A4\u9500\u2026");
4433
4723
  void call({ enabled: next }).then((result) => {
@@ -4436,7 +4726,7 @@ function useAutostart(onEnabledChange) {
4436
4726
  setBusy(false);
4437
4727
  });
4438
4728
  }, [apply2]);
4439
- const tryOnce = (0, import_react5.useCallback)(() => {
4729
+ const tryOnce = (0, import_react7.useCallback)(() => {
4440
4730
  setBusy(true);
4441
4731
  void call({ action: "try" }).then((result) => {
4442
4732
  apply2(result);
@@ -4444,14 +4734,19 @@ function useAutostart(onEnabledChange) {
4444
4734
  setBusy(false);
4445
4735
  });
4446
4736
  }, [apply2]);
4447
- (0, import_react5.useEffect)(() => {
4737
+ (0, import_react7.useEffect)(() => {
4448
4738
  refresh();
4449
4739
  }, [refresh]);
4450
- return { state: state2, busy, message, error, set, refresh, tryOnce };
4740
+ return { state: state3, busy, message, error, set, refresh, tryOnce };
4451
4741
  }
4452
4742
 
4743
+ // src/client/SettingsSection.tsx
4744
+ init_settings_contract();
4745
+ init_nav_fold_store();
4746
+ init_contracts();
4747
+
4453
4748
  // src/client/AddPromptRow.tsx
4454
- var import_react6 = require("react");
4749
+ var import_react8 = require("react");
4455
4750
  var import_jsx_runtime6 = require("react/jsx-runtime");
4456
4751
  var rowBase = {
4457
4752
  display: "flex",
@@ -4494,12 +4789,12 @@ function AddPromptRow({
4494
4789
  onMove,
4495
4790
  variant = "settings"
4496
4791
  }) {
4497
- const [mode, setMode] = (0, import_react6.useState)("closed");
4498
- const ref = (0, import_react6.useRef)(null);
4499
- (0, import_react6.useEffect)(() => {
4792
+ const [mode, setMode] = (0, import_react8.useState)("closed");
4793
+ const ref = (0, import_react8.useRef)(null);
4794
+ (0, import_react8.useEffect)(() => {
4500
4795
  setMode("closed");
4501
4796
  }, [categoryId]);
4502
- (0, import_react6.useEffect)(() => {
4797
+ (0, import_react8.useEffect)(() => {
4503
4798
  if (mode === "closed") return;
4504
4799
  const onPointerDown = (event) => {
4505
4800
  if (ref.current !== null && event.target instanceof Node && ref.current.contains(event.target)) return;
@@ -4630,7 +4925,9 @@ function AddPromptRow({
4630
4925
  }
4631
4926
 
4632
4927
  // src/client/CostCard.tsx
4633
- var import_react8 = __toESM(require("react"), 1);
4928
+ var import_react10 = __toESM(require("react"), 1);
4929
+ init_pricing();
4930
+ init_settings_contract();
4634
4931
 
4635
4932
  // src/subscription-plans.ts
4636
4933
  var QUOTA_WINDOW_LABEL = {
@@ -4645,26 +4942,30 @@ function formatUsd(usd) {
4645
4942
  return `$${usd.toFixed(2)}`;
4646
4943
  }
4647
4944
 
4945
+ // src/client/CostCard.tsx
4946
+ init_provider_prices();
4947
+
4648
4948
  // src/client/money-admin.ts
4649
- var import_react7 = __toESM(require("react"), 1);
4949
+ var import_react9 = __toESM(require("react"), 1);
4950
+ init_settings_contract();
4650
4951
 
4651
4952
  // src/balance.ts
4652
4953
  var BALANCE_API_PATH = "/composer-ux/balance";
4653
4954
 
4654
4955
  // src/client/money-admin.ts
4655
4956
  function usePriceSync(onDone) {
4656
- const [busy, setBusy] = import_react7.default.useState(null);
4657
- const [note2, setNote] = import_react7.default.useState("");
4658
- const [ok, setOk] = import_react7.default.useState(true);
4659
- const alive = import_react7.default.useRef(true);
4660
- const busyRef = import_react7.default.useRef(false);
4661
- import_react7.default.useEffect(() => {
4957
+ const [busy, setBusy] = import_react9.default.useState(null);
4958
+ const [note2, setNote] = import_react9.default.useState("");
4959
+ const [ok, setOk] = import_react9.default.useState(true);
4960
+ const alive = import_react9.default.useRef(true);
4961
+ const busyRef = import_react9.default.useRef(false);
4962
+ import_react9.default.useEffect(() => {
4662
4963
  alive.current = true;
4663
4964
  return () => {
4664
4965
  alive.current = false;
4665
4966
  };
4666
4967
  }, []);
4667
- const sync = import_react7.default.useCallback((target) => {
4968
+ const sync = import_react9.default.useCallback((target) => {
4668
4969
  if (busyRef.current) return;
4669
4970
  busyRef.current = true;
4670
4971
  setBusy(target);
@@ -4692,16 +4993,16 @@ function usePriceSync(onDone) {
4692
4993
  }
4693
4994
  function useBalance(settings) {
4694
4995
  const enabled = settings.balanceEnabled === true;
4695
- const [state2, setState] = import_react7.default.useState({ status: enabled ? "idle" : "off" });
4696
- const [nonce, setNonce] = import_react7.default.useState(0);
4697
- const alive = import_react7.default.useRef(true);
4698
- import_react7.default.useEffect(() => {
4996
+ const [state3, setState] = import_react9.default.useState({ status: enabled ? "idle" : "off" });
4997
+ const [nonce, setNonce] = import_react9.default.useState(0);
4998
+ const alive = import_react9.default.useRef(true);
4999
+ import_react9.default.useEffect(() => {
4699
5000
  alive.current = true;
4700
5001
  return () => {
4701
5002
  alive.current = false;
4702
5003
  };
4703
5004
  }, []);
4704
- import_react7.default.useEffect(() => {
5005
+ import_react9.default.useEffect(() => {
4705
5006
  if (!enabled) {
4706
5007
  setState({ status: "off" });
4707
5008
  return;
@@ -4724,7 +5025,7 @@ function useBalance(settings) {
4724
5025
  setState({ status: "error", message: error instanceof Error ? error.message : String(error) });
4725
5026
  });
4726
5027
  }, [enabled, nonce]);
4727
- return { ...state2, refresh: () => {
5028
+ return { ...state3, refresh: () => {
4728
5029
  setNonce((current) => current + 1);
4729
5030
  } };
4730
5031
  }
@@ -4776,8 +5077,8 @@ function resetText(iso) {
4776
5077
  return ` \xB7 ${Math.round(hours / 24)} \u5929\u540E\u91CD\u7F6E`;
4777
5078
  }
4778
5079
  function usePlanQuota() {
4779
- const [state2, setState] = import_react8.default.useState({ plans: [], error: "" });
4780
- import_react8.default.useEffect(() => {
5080
+ const [state3, setState] = import_react10.default.useState({ plans: [], error: "" });
5081
+ import_react10.default.useEffect(() => {
4781
5082
  let alive = true;
4782
5083
  const load = () => {
4783
5084
  void fetch(QUOTA_API_PATH, { headers: { accept: "application/json" } }).then((response) => response.json()).then((next) => {
@@ -4797,7 +5098,7 @@ function usePlanQuota() {
4797
5098
  clearInterval(timer);
4798
5099
  };
4799
5100
  }, []);
4800
- return state2;
5101
+ return state3;
4801
5102
  }
4802
5103
  function QuotaBars(props) {
4803
5104
  const windows = props.plan.windows ?? [];
@@ -4834,32 +5135,32 @@ function QuotaBars(props) {
4834
5135
  }
4835
5136
  function CostCardBody(props) {
4836
5137
  const { settings, setField, clearField } = props;
4837
- const [table, setTable] = import_react8.default.useState(settings.priceOverrides);
4838
- const [drafts, setDrafts] = import_react8.default.useState({});
4839
- const [invalid, setInvalid] = import_react8.default.useState({});
4840
- const [name2, setName] = import_react8.default.useState("");
4841
- const [addNote, setAddNote] = import_react8.default.useState("");
4842
- const [pending, setPending] = import_react8.default.useState([]);
4843
- const [holidayText, setHolidayText] = import_react8.default.useState(() => (settings.peakHolidays ?? []).join("\n"));
4844
- const [holidayNote, setHolidayNote] = import_react8.default.useState("");
4845
- const lastWritten = import_react8.default.useRef(settings.priceOverrides);
4846
- const tableRef = import_react8.default.useRef(table);
4847
- const timer = import_react8.default.useRef(null);
5138
+ const [table, setTable] = import_react10.default.useState(settings.priceOverrides);
5139
+ const [drafts, setDrafts] = import_react10.default.useState({});
5140
+ const [invalid, setInvalid] = import_react10.default.useState({});
5141
+ const [name2, setName] = import_react10.default.useState("");
5142
+ const [addNote, setAddNote] = import_react10.default.useState("");
5143
+ const [pending, setPending] = import_react10.default.useState([]);
5144
+ const [holidayText, setHolidayText] = import_react10.default.useState(() => (settings.peakHolidays ?? []).join("\n"));
5145
+ const [holidayNote, setHolidayNote] = import_react10.default.useState("");
5146
+ const lastWritten = import_react10.default.useRef(settings.priceOverrides);
5147
+ const tableRef = import_react10.default.useRef(table);
5148
+ const timer = import_react10.default.useRef(null);
4848
5149
  tableRef.current = table;
4849
5150
  const sync = usePriceSync();
4850
5151
  const balance = useBalance(settings);
4851
5152
  const syncedEras = settings.syncedPrices?.eras;
4852
- import_react8.default.useEffect(() => {
5153
+ import_react10.default.useEffect(() => {
4853
5154
  if (canonical(settings.priceOverrides) === canonical(lastWritten.current)) return;
4854
5155
  lastWritten.current = settings.priceOverrides;
4855
5156
  tableRef.current = settings.priceOverrides;
4856
5157
  setTable(settings.priceOverrides);
4857
5158
  }, [settings.priceOverrides]);
4858
5159
  const savedHolidayText = (settings.peakHolidays ?? []).join("\n");
4859
- import_react8.default.useEffect(() => {
5160
+ import_react10.default.useEffect(() => {
4860
5161
  setHolidayText(savedHolidayText);
4861
5162
  }, [savedHolidayText]);
4862
- import_react8.default.useEffect(() => () => {
5163
+ import_react10.default.useEffect(() => () => {
4863
5164
  if (timer.current !== null) clearTimeout(timer.current);
4864
5165
  }, []);
4865
5166
  const commit = (next) => {
@@ -5385,6 +5686,9 @@ function CostCardBody(props) {
5385
5686
  ] });
5386
5687
  }
5387
5688
 
5689
+ // src/client/OptimizerPromptEditor.tsx
5690
+ init_settings_contract();
5691
+
5388
5692
  // src/optimizer-transplant.ts
5389
5693
  var UPSTREAM_MISSION = [
5390
5694
  "\u3010\u6700\u91CD\u8981\u7684\u4E00\u6761\u3011\u7528\u6237\u539F\u8BDD\u4F1A\u88AB\u539F\u6837\u4FDD\u7559\u3002\u4F60\u4E0D\u6539\u5199\u5B83\uFF0C\u4F60\u53EA\u8865\u5B83\u6CA1\u8BF4\u7684\u3001\u800C\u5DE5\u4F5C AI \u65E0\u6CD5\u81EA\u77E5\u7684\u4E1C\u897F\u3002"
@@ -5629,6 +5933,9 @@ function OptimizerPromptEditor({ tier, value, onChange }) {
5629
5933
  ] });
5630
5934
  }
5631
5935
 
5936
+ // src/client/InsertModeControl.tsx
5937
+ init_settings_contract();
5938
+
5632
5939
  // src/client/PillChoice.tsx
5633
5940
  var import_jsx_runtime9 = require("react/jsx-runtime");
5634
5941
  var base = {
@@ -5700,6 +6007,7 @@ function InsertModeControl({ mode, onChange, compact = false, label }) {
5700
6007
  }
5701
6008
 
5702
6009
  // src/client/stats-line.ts
6010
+ init_settings_contract();
5703
6011
  var STATS_ROOT_SELECTOR = "[data-composer-stats]";
5704
6012
  var HIT_DIGITS = 3;
5705
6013
  var MAX_DIGITS = 15;
@@ -5751,14 +6059,17 @@ function statsLineEnabled(settings) {
5751
6059
  return activeSections(settings).stats;
5752
6060
  }
5753
6061
 
6062
+ // src/client/SettingsSection.tsx
6063
+ init_pricing();
6064
+
5754
6065
  // src/client/ui-kit.tsx
5755
- var import_react9 = require("react");
6066
+ var import_react11 = require("react");
5756
6067
  var import_react_dom2 = require("react-dom");
5757
6068
  var import_jsx_runtime11 = require("react/jsx-runtime");
5758
6069
  var HINT_EDGE = 12;
5759
6070
  var HINT_WIDTH = 280;
5760
6071
  var HINT_FLIP_ROOM = 120;
5761
- var useIsoLayoutEffect = typeof window === "undefined" ? import_react9.useEffect : import_react9.useLayoutEffect;
6072
+ var useIsoLayoutEffect = typeof window === "undefined" ? import_react11.useEffect : import_react11.useLayoutEffect;
5762
6073
  function Card(props) {
5763
6074
  const classes = ["dsh-ux-card"];
5764
6075
  if (props.open === true) classes.push("dsh-ux-cardOpen");
@@ -5798,12 +6109,12 @@ function CardChevron(props) {
5798
6109
  }
5799
6110
  function Hint(props) {
5800
6111
  const { text, insideButton = false } = props;
5801
- const badge = (0, import_react9.useRef)(null);
5802
- const [hover, setHover] = (0, import_react9.useState)(false);
5803
- const [pinned, setPinned] = (0, import_react9.useState)(false);
5804
- const [placement, setPlacement] = (0, import_react9.useState)(null);
6112
+ const badge = (0, import_react11.useRef)(null);
6113
+ const [hover, setHover] = (0, import_react11.useState)(false);
6114
+ const [pinned, setPinned] = (0, import_react11.useState)(false);
6115
+ const [placement, setPlacement] = (0, import_react11.useState)(null);
5805
6116
  const open = hover || pinned;
5806
- const measure = (0, import_react9.useCallback)(() => {
6117
+ const measure = (0, import_react11.useCallback)(() => {
5807
6118
  const rect = badge.current?.getBoundingClientRect();
5808
6119
  if (rect === void 0) {
5809
6120
  setPlacement(null);
@@ -5825,7 +6136,7 @@ function Hint(props) {
5825
6136
  }
5826
6137
  measure();
5827
6138
  }, [open, measure]);
5828
- (0, import_react9.useEffect)(() => {
6139
+ (0, import_react11.useEffect)(() => {
5829
6140
  if (!open) return;
5830
6141
  const relayout = () => {
5831
6142
  measure();
@@ -5837,7 +6148,7 @@ function Hint(props) {
5837
6148
  window.removeEventListener("resize", relayout);
5838
6149
  };
5839
6150
  }, [open, measure]);
5840
- (0, import_react9.useEffect)(() => {
6151
+ (0, import_react11.useEffect)(() => {
5841
6152
  if (!pinned) return;
5842
6153
  const onPointerDown = (event) => {
5843
6154
  const target = event.target;
@@ -5971,7 +6282,7 @@ function GroupLabel(props) {
5971
6282
  // src/client/SettingsSection.tsx
5972
6283
  var import_jsx_runtime12 = require("react/jsx-runtime");
5973
6284
  function FoldCard(props) {
5974
- const [open, setOpen] = (0, import_react10.useState)(false);
6285
+ const [open, setOpen] = (0, import_react12.useState)(false);
5975
6286
  const off = props.toggle !== void 0 && props.toggle.checked === false;
5976
6287
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
5977
6288
  Card,
@@ -6021,9 +6332,9 @@ function FoldCard(props) {
6021
6332
  }
6022
6333
  function KeyRow(props) {
6023
6334
  const { title, desc, value, presets, conflict, onChange, first } = props;
6024
- const [recording, setRecording] = (0, import_react10.useState)(false);
6025
- const [error, setError] = (0, import_react10.useState)(null);
6026
- (0, import_react10.useEffect)(() => {
6335
+ const [recording, setRecording] = (0, import_react12.useState)(false);
6336
+ const [error, setError] = (0, import_react12.useState)(null);
6337
+ (0, import_react12.useEffect)(() => {
6027
6338
  if (!recording) return;
6028
6339
  const onKeyDown = (event) => {
6029
6340
  event.preventDefault();
@@ -6158,9 +6469,9 @@ function ToggleRow(props) {
6158
6469
  }
6159
6470
  function TextFieldRow(props) {
6160
6471
  const { title, desc, value, placeholder, maxLength, onChange, action, first } = props;
6161
- const [draft, setDraft] = (0, import_react10.useState)(value);
6162
- const focused = (0, import_react10.useRef)(false);
6163
- (0, import_react10.useEffect)(() => {
6472
+ const [draft, setDraft] = (0, import_react12.useState)(value);
6473
+ const focused = (0, import_react12.useRef)(false);
6474
+ (0, import_react12.useEffect)(() => {
6164
6475
  if (!focused.current) setDraft(value);
6165
6476
  }, [value]);
6166
6477
  const commit = () => {
@@ -6201,12 +6512,12 @@ function TextFieldRow(props) {
6201
6512
  ] }) });
6202
6513
  }
6203
6514
  function QuickPromptsEditor(props) {
6204
- const [draft, setDraft] = (0, import_react10.useState)(() => props.book);
6205
- const [activeId, setActiveId] = (0, import_react10.useState)(() => props.book.categories[0]?.id ?? "");
6206
- const [dirty, setDirty] = (0, import_react10.useState)(false);
6207
- const [newName, setNewName] = (0, import_react10.useState)("");
6208
- const [note2, setNote] = (0, import_react10.useState)("");
6209
- (0, import_react10.useEffect)(() => {
6515
+ const [draft, setDraft] = (0, import_react12.useState)(() => props.book);
6516
+ const [activeId, setActiveId] = (0, import_react12.useState)(() => props.book.categories[0]?.id ?? "");
6517
+ const [dirty, setDirty] = (0, import_react12.useState)(false);
6518
+ const [newName, setNewName] = (0, import_react12.useState)("");
6519
+ const [note2, setNote] = (0, import_react12.useState)("");
6520
+ (0, import_react12.useEffect)(() => {
6210
6521
  if (dirty) return;
6211
6522
  setDraft(props.book);
6212
6523
  if (!props.book.categories.some((category) => category.id === activeId)) {
@@ -6444,8 +6755,8 @@ var candidatePill = {
6444
6755
  };
6445
6756
  function DefaultTerminalBody(props) {
6446
6757
  const { settings, setField, hideMode = false } = props;
6447
- const [note2, setNote] = (0, import_react10.useState)("");
6448
- const [busy, setBusy] = (0, import_react10.useState)(false);
6758
+ const [note2, setNote] = (0, import_react12.useState)("");
6759
+ const [busy, setBusy] = (0, import_react12.useState)(false);
6449
6760
  const candidates = settings.terminalCandidates;
6450
6761
  if (settings.terminalEffective === "unsupported") {
6451
6762
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { style: hintInfo, children: "\u672C\u63D2\u4EF6\u53EA\u5728 Windows \u4E0A\u63A5\u7BA1\u7EC8\u7AEF\uFF08Windows \u4E0A DSH \u9ED8\u8BA4\u7ED9\u6A21\u578B\u7684\u662F PowerShell\uFF09\u3002\u5F53\u524D\u5E73\u53F0\u4E0D\u9700\u8981\u5B83\uFF0C \u8FD9\u91CC\u7684\u8BBE\u7F6E\u4E0D\u4F1A\u751F\u6548\u3002" });
@@ -6543,9 +6854,9 @@ function blockedText(blocked) {
6543
6854
  return `\u8FD9\u4E2A\u5BBF\u4E3B\u5F53\u524D\u4E0D\u5141\u8BB8\u4ECE\u754C\u9762\u91CD\u542F\uFF08${blocked}\uFF09\u3002`;
6544
6855
  }
6545
6856
  function useRestart() {
6546
- const [stage, setStage] = (0, import_react10.useState)("idle");
6547
- const [detail2, setDetail] = (0, import_react10.useState)("");
6548
- const [blocked, setBlocked] = (0, import_react10.useState)(null);
6857
+ const [stage, setStage] = (0, import_react12.useState)("idle");
6858
+ const [detail2, setDetail] = (0, import_react12.useState)("");
6859
+ const [blocked, setBlocked] = (0, import_react12.useState)(null);
6549
6860
  const readFacts = async () => {
6550
6861
  const response = await fetch(RESTART_API_PATH, {
6551
6862
  cache: "no-store",
@@ -6654,8 +6965,8 @@ function NotifyCard({ settings, setField }) {
6654
6965
  const on = settings.notifyEnabled;
6655
6966
  const channel = settings.notifyChannel;
6656
6967
  const kinds = settings.notifyKinds;
6657
- const [busy, setBusy] = (0, import_react10.useState)(false);
6658
- const [note2, setNote] = (0, import_react10.useState)("");
6968
+ const [busy, setBusy] = (0, import_react12.useState)(false);
6969
+ const [note2, setNote] = (0, import_react12.useState)("");
6659
6970
  const send = () => {
6660
6971
  setBusy(true);
6661
6972
  setNote("");
@@ -6860,10 +7171,10 @@ function SettingsSection({ useLive, useBook, useBookStatus, useWriteNotice, acti
6860
7171
  const book = useBook((item) => item);
6861
7172
  const bookStatus = useBookStatus((item) => item);
6862
7173
  const writeNotice = useWriteNotice((item) => item);
6863
- const [conflict, setConflict] = (0, import_react10.useState)(null);
7174
+ const [conflict, setConflict] = (0, import_react12.useState)(null);
6864
7175
  const restart = useRestart();
6865
7176
  const sections = activeSections(settings);
6866
- const [autostartEnabled, setAutostartEnabled] = (0, import_react10.useState)(false);
7177
+ const [autostartEnabled, setAutostartEnabled] = (0, import_react12.useState)(false);
6867
7178
  const autostart = useAutostart(setAutostartEnabled);
6868
7179
  const setKey = (side, chord) => {
6869
7180
  const other = side === "send" ? settings.newlineKey : settings.sendKey;
@@ -6881,6 +7192,7 @@ function SettingsSection({ useLive, useBook, useBookStatus, useWriteNotice, acti
6881
7192
  const panelSize = typeof settings.panelWidth === "number" && typeof settings.panelHeight === "number" ? `${settings.panelWidth}\xD7${settings.panelHeight}` : "\u5C3A\u5BF8\u7528\u5B98\u65B9\u9ED8\u8BA4";
6882
7193
  const panelSummary = `\u8FB9\u7F18\u7F29\u653E ${settings.panelResize ? "\u5F00" : "\u5173"} \xB7 ${panelSize}`;
6883
7194
  const headerNative = settings.headerStatus.startsWith(NATIVE_STATUS_PREFIX);
7195
+ const navFold = useNavFold();
6884
7196
  const headerSummary = headerNative ? "\u5BBF\u4E3B\u5DF2\u539F\u751F\u652F\u6301\uFF08\u4E0D\u9700\u8981\uFF09" : settings.headerEnabled ? settings.headerStatus === "" ? "\u5DF2\u542F\u7528" : settings.headerStatus : "\u65E7\u5BBF\u4E3B\u624D\u9700\u8981\uFF0C\u8FD9\u4E00\u680F\u73B0\u5728\u4E0D\u8D77\u4F5C\u7528";
6885
7197
  const quickCounts = bookCounts(book);
6886
7198
  const quickSummary = `${quickCounts.categories} \u4E2A\u5206\u7C7B \xB7 ${quickCounts.prompts} \u6761 \xB7 \u6BCF\u6B21 ${quickCounts.always} \xB7 \u4EC5\u9996\u6B21 ${quickCounts.first} \xB7 \u4F18\u5316\u6863\u4F4D ${OPTIMIZER_TIERS.find((item) => item.id === settings.optimizerTier)?.label ?? "\u9AD8\u7EA7"}`;
@@ -7306,7 +7618,42 @@ function SettingsSection({ useLive, useBook, useBookStatus, useWriteNotice, acti
7306
7618
  children: "\u5BBD\u655E\uFF081040\xD7760\uFF09"
7307
7619
  }
7308
7620
  )
7309
- ] })
7621
+ ] }),
7622
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(GroupLabel, { hint: "\u6298\u53E0\u7684\u662F\u5DE6\u4FA7\u90A3\u4E00\u7EC4\u5165\u53E3\uFF08\u63D2\u4EF6 / \u81EA\u52A8\u5316\u4EFB\u52A1 / \u4E0A\u4E0B\u6587\u6D1E\u5BDF / MCP\u8FDE\u63A5\u5668 / \u66F4\u591A\uFF09\u3002\u4F1A\u8BDD\u5217\u8868\u4E0D\u53D7\u5F71\u54CD\uFF0CDSH \u81EA\u5E26\u7684\u300C\u6536\u8D77\u4FA7\u8FB9\u680F\u300D\u4E5F\u4E0D\u53D7\u5F71\u54CD\u3002", children: "\u4FA7\u8FB9\u680F" }),
7623
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Row, { title: "\u5168\u5C40\u9762\u677F", desc: "\u90A3\u4E00\u7EC4\u5165\u53E3\u600E\u4E48\u6446", first: true, stacked: true, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
7624
+ Segmented,
7625
+ {
7626
+ ariaLabel: "\u5168\u5C40\u9762\u677F\u6298\u53E0\u5F62\u6001",
7627
+ items: NAV_FOLD_MODES.map((mode) => ({
7628
+ id: mode.id,
7629
+ label: mode.label,
7630
+ hint: mode.id === "off" ? "\u4FDD\u6301 DSH \u539F\u6837" : mode.id === "bar" ? "\u6536\u6210\u4E00\u6761\u300C\u5168\u5C40\u9762\u677F\u300D\uFF0C\u70B9\u4E00\u4E0B\u5C55\u5F00" : "\u53EA\u7559\u4E00\u884C\u56FE\u6807\uFF0C\u60AC\u505C\u51FA\u540D\u5B57"
7631
+ })),
7632
+ value: navFold.mode,
7633
+ onChange: (mode) => {
7634
+ void saveNavFold({ mode });
7635
+ }
7636
+ }
7637
+ ) }),
7638
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
7639
+ Row,
7640
+ {
7641
+ title: "\u73B0\u5728\u6536\u8D77",
7642
+ desc: navFold.mode === "off" ? "\u5F62\u6001\u662F\u300C\u4E0D\u6298\u53E0\u300D\uFF0C\u8FD9\u4E2A\u5F00\u5173\u4E0D\u8D77\u4F5C\u7528" : "\u8BB0\u4F4F\u8FD9\u4E2A\u72B6\u6001\uFF1A\u4E0B\u6B21\u6253\u5F00 DSH \u6CBF\u7528",
7643
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
7644
+ Switch,
7645
+ {
7646
+ small: true,
7647
+ label: "\u73B0\u5728\u6536\u8D77\u5168\u5C40\u9762\u677F",
7648
+ checked: navFold.collapsed,
7649
+ disabled: navFold.mode === "off",
7650
+ onChange: (next) => {
7651
+ void saveNavFold({ collapsed: next });
7652
+ }
7653
+ }
7654
+ )
7655
+ }
7656
+ )
7310
7657
  ]
7311
7658
  }
7312
7659
  ),
@@ -7452,7 +7799,7 @@ function SettingsSection({ useLive, useBook, useBookStatus, useWriteNotice, acti
7452
7799
  }
7453
7800
 
7454
7801
  // src/client/StatsLineEntry.tsx
7455
- var import_react11 = __toESM(require("react"), 1);
7802
+ var import_react13 = __toESM(require("react"), 1);
7456
7803
 
7457
7804
  // src/client/stats-dom.ts
7458
7805
  var MAX_HOST_DEPTH = 6;
@@ -7489,8 +7836,8 @@ function StatsLineEntry({ useLive, useProjection }) {
7489
7836
  const active2 = statsLineEnabled(settings);
7490
7837
  const usage = typeof useProjection === "function" ? useProjection("tokenUsage") : void 0;
7491
7838
  const target = cacheHitDisplay(usage, active2 ? HIT_DIGITS : 0);
7492
- const anchor = import_react11.default.useRef(null);
7493
- import_react11.default.useLayoutEffect(() => {
7839
+ const anchor = import_react13.default.useRef(null);
7840
+ import_react13.default.useLayoutEffect(() => {
7494
7841
  const host = hostOf(anchor.current);
7495
7842
  if (host === null) return;
7496
7843
  let timer;
@@ -7534,8 +7881,9 @@ function StatsLineEntry({ useLive, useProjection }) {
7534
7881
  }
7535
7882
 
7536
7883
  // src/client/CostChipEntry.tsx
7537
- var import_react14 = __toESM(require("react"), 1);
7884
+ var import_react16 = __toESM(require("react"), 1);
7538
7885
  var import_react_dom3 = require("react-dom");
7886
+ init_pricing();
7539
7887
 
7540
7888
  // src/usage-fold.ts
7541
7889
  var UNKNOWN_ROUTE = "\u672A\u77E5";
@@ -7564,14 +7912,15 @@ function agreesWithProjection(fold, projection) {
7564
7912
  }
7565
7913
 
7566
7914
  // src/client/peak-alert.ts
7567
- var import_react12 = __toESM(require("react"), 1);
7915
+ var import_react14 = __toESM(require("react"), 1);
7916
+ init_pricing();
7568
7917
  var TICK_MS = 1e4;
7569
7918
  var notifiedSwitchAt = Number.NaN;
7570
7919
  function usePeakPhase(holidays) {
7571
7920
  const table = holidays ?? DEFAULT_PEAK_HOLIDAYS;
7572
- const [phase, setPhase] = import_react12.default.useState(() => peakPhaseAt(Date.now(), { holidays: table }));
7921
+ const [phase, setPhase] = import_react14.default.useState(() => peakPhaseAt(Date.now(), { holidays: table }));
7573
7922
  const tableKey = table.join(",");
7574
- import_react12.default.useEffect(() => {
7923
+ import_react14.default.useEffect(() => {
7575
7924
  const compute = () => {
7576
7925
  setPhase(peakPhaseAt(Date.now(), { holidays: table }));
7577
7926
  };
@@ -7594,7 +7943,7 @@ function usePeakAlert(settings, holidays) {
7594
7943
  const phase = usePeakPhase(holidays);
7595
7944
  const alert = settings.peakAlert;
7596
7945
  const text = peakNoticeText(phase);
7597
- import_react12.default.useEffect(() => {
7946
+ import_react14.default.useEffect(() => {
7598
7947
  if (!alert.enabled || !alert.webNotify) return;
7599
7948
  if (!Number.isFinite(phase.nextAtMs)) return;
7600
7949
  if (phase.minutesUntil > alert.aheadMinutes) return;
@@ -7613,28 +7962,32 @@ function usePeakAlert(settings, holidays) {
7613
7962
  return { phase, text };
7614
7963
  }
7615
7964
 
7965
+ // src/client/CostChipEntry.tsx
7966
+ init_provider_prices();
7967
+
7616
7968
  // src/client/session-cost.ts
7617
- var import_react13 = __toESM(require("react"), 1);
7969
+ var import_react15 = __toESM(require("react"), 1);
7970
+ init_settings_contract();
7618
7971
  var MIN_INTERVAL_MS = 600;
7619
7972
  function useSessionCost(sessionId, fingerprint, force) {
7620
- const [entry, setEntry] = import_react13.default.useState(null);
7621
- const [loading, setLoading] = import_react13.default.useState(false);
7622
- const lastAt = import_react13.default.useRef(0);
7623
- const timer = import_react13.default.useRef(null);
7624
- const inflight = import_react13.default.useRef(false);
7625
- const again = import_react13.default.useRef(false);
7626
- const serial = import_react13.default.useRef(0);
7627
- const alive = import_react13.default.useRef(true);
7628
- const runRef = import_react13.default.useRef(() => {
7973
+ const [entry, setEntry] = import_react15.default.useState(null);
7974
+ const [loading, setLoading] = import_react15.default.useState(false);
7975
+ const lastAt = import_react15.default.useRef(0);
7976
+ const timer = import_react15.default.useRef(null);
7977
+ const inflight = import_react15.default.useRef(false);
7978
+ const again = import_react15.default.useRef(false);
7979
+ const serial = import_react15.default.useRef(0);
7980
+ const alive = import_react15.default.useRef(true);
7981
+ const runRef = import_react15.default.useRef(() => {
7629
7982
  });
7630
- import_react13.default.useEffect(() => {
7983
+ import_react15.default.useEffect(() => {
7631
7984
  alive.current = true;
7632
7985
  return () => {
7633
7986
  alive.current = false;
7634
7987
  if (timer.current !== null) clearTimeout(timer.current);
7635
7988
  };
7636
7989
  }, []);
7637
- const run = import_react13.default.useCallback(() => {
7990
+ const run = import_react15.default.useCallback(() => {
7638
7991
  if (typeof sessionId !== "string" || sessionId === "") return;
7639
7992
  if (inflight.current) {
7640
7993
  again.current = true;
@@ -7665,7 +8018,7 @@ function useSessionCost(sessionId, fingerprint, force) {
7665
8018
  });
7666
8019
  }, [sessionId]);
7667
8020
  runRef.current = run;
7668
- import_react13.default.useEffect(() => {
8021
+ import_react15.default.useEffect(() => {
7669
8022
  if (typeof sessionId !== "string" || sessionId === "") return;
7670
8023
  const wait = Math.max(0, MIN_INTERVAL_MS - (Date.now() - lastAt.current));
7671
8024
  if (wait === 0 || force) {
@@ -7697,7 +8050,7 @@ function tokenTotal(buckets) {
7697
8050
  return num(buckets.inputTokens) + num(buckets.outputTokens) + num(buckets.cacheReadTokens) + num(buckets.cacheWriteTokens);
7698
8051
  }
7699
8052
  function detail(label, value, key) {
7700
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_react14.default.Fragment, { children: [
8053
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_react16.default.Fragment, { children: [
7701
8054
  /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("dt", { style: { minWidth: 0, margin: 0, color: "var(--dsw-alias-label-tertiary)", overflowWrap: "anywhere" }, children: label }),
7702
8055
  /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("dd", { style: {
7703
8056
  minWidth: 0,
@@ -7720,10 +8073,10 @@ function CostChipEntry({ useLive, sessionId, useProjection }) {
7720
8073
  const project = typeof useProjection === "function" ? useProjection : () => void 0;
7721
8074
  const usage = project("tokenUsage");
7722
8075
  const selection = project("modelSelection");
7723
- const [open, setOpen] = import_react14.default.useState(false);
7724
- const [hover, setHover] = import_react14.default.useState(false);
7725
- const [anchor, setAnchor] = import_react14.default.useState(null);
7726
- const chip = import_react14.default.useRef(null);
8076
+ const [open, setOpen] = import_react16.default.useState(false);
8077
+ const [hover, setHover] = import_react16.default.useState(false);
8078
+ const [anchor, setAnchor] = import_react16.default.useState(null);
8079
+ const chip = import_react16.default.useRef(null);
7727
8080
  const buckets = costBucketsOf(usage);
7728
8081
  const write = num(usage?.cacheWriteTokens);
7729
8082
  const model = selection?.lastUsed?.model;
@@ -7735,7 +8088,7 @@ function CostChipEntry({ useLive, sessionId, useProjection }) {
7735
8088
  const estimate = resolvePrice(model, { overrides, ...lastProvider === void 0 ? {} : { provider: lastProvider }, ...eras === void 0 ? {} : { eras } });
7736
8089
  const estimateParts = costPartsOf(buckets, estimate.prices);
7737
8090
  const { text: peakText } = usePeakAlert(settings, data?.holidays ?? settings.peakHolidays ?? DEFAULT_PEAK_HOLIDAYS);
7738
- const close = import_react14.default.useCallback(() => {
8091
+ const close = import_react16.default.useCallback(() => {
7739
8092
  setOpen(false);
7740
8093
  setAnchor(null);
7741
8094
  }, []);
@@ -7754,7 +8107,7 @@ function CostChipEntry({ useLive, sessionId, useProjection }) {
7754
8107
  setAnchor({ left, top: rect.top - 8 });
7755
8108
  setOpen(true);
7756
8109
  };
7757
- import_react14.default.useEffect(() => {
8110
+ import_react16.default.useEffect(() => {
7758
8111
  if (!open) return;
7759
8112
  const onPointerDown = (event) => {
7760
8113
  const target = event.target;
@@ -7989,6 +8342,7 @@ function CostChipEntry({ useLive, sessionId, useProjection }) {
7989
8342
  ] }),
7990
8343
  hasQuota ? note(`\u8BA2\u9605\u5185 \xB7 \u6309\u520A\u4F8B\u4EF7\u6298\u7B97 ${formatMoney(view.total)}\uFF08\u4E24\u5957\u53E3\u5F84\u5E76\u5B58\uFF1A\u4E0A\u9762\u662F\u5B9E\u9645\u88AB\u6263\u7684\u5957\u9910\u989D\u5EA6\uFF0C\u8FD9\u91CC\u662F\u8FD9\u4E9B token \u6309\u5B98\u65B9\u4EF7\u6298\u7B97\u503C\u591A\u5C11\u94B1\uFF09`, "__quota_head__") : null,
7991
8344
  /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { style: { marginBottom: 10, borderTop: "0.5px solid var(--dsw-alias-border-l2)" } }),
8345
+ data?.ok === true && typeof data.readError === "string" && data.readError !== "" ? note(`\u8BFB\u4E0D\u5230\u4F1A\u8BDD\u65E5\u5FD7\uFF1A${data.readError}\uFF08\u91D1\u989D\u6309 0 \u8BA1\uFF09`, "__read_error__") : null,
7992
8346
  /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { style: {
7993
8347
  display: "grid",
7994
8348
  gridTemplateColumns: "minmax(76px, auto) minmax(0, 1fr)",
@@ -8054,7 +8408,8 @@ function CostChipEntry({ useLive, sessionId, useProjection }) {
8054
8408
  }
8055
8409
 
8056
8410
  // src/client/QuickCommandsButton.tsx
8057
- var import_react15 = require("react");
8411
+ var import_react17 = require("react");
8412
+ init_settings_contract();
8058
8413
  var import_jsx_runtime15 = require("react/jsx-runtime");
8059
8414
  function QuickCommandsButton({
8060
8415
  useInput,
@@ -8067,10 +8422,10 @@ function QuickCommandsButton({
8067
8422
  }) {
8068
8423
  const settings = useLive((item) => item);
8069
8424
  const anchor = usePanel((item) => item);
8070
- const draft = useInput((state2) => state2.draft);
8071
- const blank = useSession((state2) => state2?.blank === true);
8072
- const ref = (0, import_react15.useRef)(null);
8073
- (0, import_react15.useEffect)(() => {
8425
+ const draft = useInput((state3) => state3.draft);
8426
+ const blank = useSession((state3) => state3?.blank === true);
8427
+ const ref = (0, import_react17.useRef)(null);
8428
+ (0, import_react17.useEffect)(() => {
8074
8429
  const sid = typeof sessionId === "string" ? sessionId : "";
8075
8430
  publishInputBridge({
8076
8431
  actions: inputActions ?? null,
@@ -8128,12 +8483,15 @@ function QuickCommandsButton({
8128
8483
  }
8129
8484
 
8130
8485
  // src/client/QuickCommandsPanel.tsx
8131
- var import_react19 = require("react");
8486
+ var import_react21 = require("react");
8487
+ init_settings_contract();
8132
8488
 
8133
8489
  // src/client/OptimizeOptionsCard.tsx
8134
- var import_react16 = __toESM(require("react"), 1);
8490
+ var import_react18 = __toESM(require("react"), 1);
8491
+ init_settings_contract();
8135
8492
 
8136
8493
  // src/client/model-catalog.ts
8494
+ init_settings_contract();
8137
8495
  var textOf = (value) => typeof value === "string" ? value.trim() : "";
8138
8496
  async function fetchModelCatalog(options = {}) {
8139
8497
  const url = options.fresh === true ? `${MODELS_API_PATH}?fresh=1` : MODELS_API_PATH;
@@ -8218,13 +8576,13 @@ function currentPrompt(settings) {
8218
8576
  return settings.optimizerPromptStandard;
8219
8577
  }
8220
8578
  function OptimizeOptionsCard({ settings, actions, open, onToggle }) {
8221
- const [detailOpen, setDetailOpen] = (0, import_react16.useState)(false);
8222
- const [modelText, setModelText] = (0, import_react16.useState)(settings.optimizerModel);
8223
- const [pickerOpen, setPickerOpen] = (0, import_react16.useState)(false);
8224
- const [catalog, setCatalog] = (0, import_react16.useState)(null);
8225
- const [manual, setManual] = (0, import_react16.useState)(false);
8226
- const [retrySeq, setRetrySeq] = (0, import_react16.useState)(0);
8227
- (0, import_react16.useEffect)(() => {
8579
+ const [detailOpen, setDetailOpen] = (0, import_react18.useState)(false);
8580
+ const [modelText, setModelText] = (0, import_react18.useState)(settings.optimizerModel);
8581
+ const [pickerOpen, setPickerOpen] = (0, import_react18.useState)(false);
8582
+ const [catalog, setCatalog] = (0, import_react18.useState)(null);
8583
+ const [manual, setManual] = (0, import_react18.useState)(false);
8584
+ const [retrySeq, setRetrySeq] = (0, import_react18.useState)(0);
8585
+ (0, import_react18.useEffect)(() => {
8228
8586
  if (!pickerOpen) return;
8229
8587
  let alive = true;
8230
8588
  setCatalog({ kind: "loading" });
@@ -8354,7 +8712,7 @@ function OptimizeOptionsCard({ settings, actions, open, onToggle }) {
8354
8712
  )
8355
8713
  ] }) : /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
8356
8714
  catalog.groups.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { style: optHint, children: "\u5BBF\u4E3B\u6CA1\u62A5\u51FA\u4EFB\u4F55 provider\uFF08\u5728\u8BBE\u7F6E\u91CC\u770B\u8FC7\u6A21\u578B\u8DEF\u7531\u5417\uFF1F\uFF09" }),
8357
- catalog.groups.map((group) => /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_react16.default.Fragment, { children: [
8715
+ catalog.groups.map((group) => /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_react18.default.Fragment, { children: [
8358
8716
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { style: optPickerGroup, children: group.name }),
8359
8717
  group.models.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { style: optHint, children: group.error === void 0 ? "\u8FD9\u4E00\u7EC4\u6CA1\u6709\u6A21\u578B" : `\u8FD9\u4E00\u7EC4\u8BFB\u4E0D\u5230\uFF1A${group.error}` }),
8360
8718
  group.models.map((model) => {
@@ -8526,12 +8884,12 @@ function OptimizeOptionsCard({ settings, actions, open, onToggle }) {
8526
8884
  }
8527
8885
 
8528
8886
  // src/client/optimize-clock.ts
8529
- var import_react17 = require("react");
8887
+ var import_react19 = require("react");
8530
8888
  var TICK_MS2 = 1e3;
8531
8889
  function useOptimizeElapsed(startedAt) {
8532
8890
  const running = startedAt > 0;
8533
- const [seconds, setSeconds] = (0, import_react17.useState)(() => elapsedSeconds(startedAt, Date.now()));
8534
- (0, import_react17.useEffect)(() => {
8891
+ const [seconds, setSeconds] = (0, import_react19.useState)(() => elapsedSeconds(startedAt, Date.now()));
8892
+ (0, import_react19.useEffect)(() => {
8535
8893
  setSeconds(elapsedSeconds(startedAt, Date.now()));
8536
8894
  if (!running) return void 0;
8537
8895
  const timer = setInterval(() => {
@@ -8559,10 +8917,10 @@ function sectionForDock(dockPresent, current) {
8559
8917
  }
8560
8918
 
8561
8919
  // src/client/OptimizeDock.tsx
8562
- var import_react18 = require("react");
8920
+ var import_react20 = require("react");
8563
8921
 
8564
8922
  // src/client/optimize-dock.ts
8565
- function dockReducer(state2, event) {
8923
+ function dockReducer(state3, event) {
8566
8924
  switch (event.type) {
8567
8925
  case "restore":
8568
8926
  return event.snapshot;
@@ -8587,21 +8945,21 @@ function dockReducer(state2, event) {
8587
8945
  slashPrefix: event.prefix
8588
8946
  };
8589
8947
  case "item": {
8590
- if (state2 === null) return state2;
8591
- if (state2.items.some((row2) => row2.id === event.item.id)) return state2;
8592
- return { ...state2, items: [...state2.items, event.item] };
8948
+ if (state3 === null) return state3;
8949
+ if (state3.items.some((row2) => row2.id === event.item.id)) return state3;
8950
+ return { ...state3, items: [...state3.items, event.item] };
8593
8951
  }
8594
8952
  case "dropped": {
8595
- if (state2 === null) return state2;
8596
- if (state2.dropped.some((row2) => row2.id === event.row.id)) return state2;
8597
- return { ...state2, dropped: [...state2.dropped, event.row] };
8953
+ if (state3 === null) return state3;
8954
+ if (state3.dropped.some((row2) => row2.id === event.row.id)) return state3;
8955
+ return { ...state3, dropped: [...state3.dropped, event.row] };
8598
8956
  }
8599
8957
  case "done": {
8600
- if (state2 === null) return state2;
8958
+ if (state3 === null) return state3;
8601
8959
  const outcome = event.outcome;
8602
8960
  const ok = outcome.ok === true;
8603
8961
  return {
8604
- ...state2,
8962
+ ...state3,
8605
8963
  phase: ok ? "done" : "error",
8606
8964
  text: ok ? outcome.text ?? "" : "",
8607
8965
  edited: false,
@@ -8611,18 +8969,18 @@ function dockReducer(state2, event) {
8611
8969
  fallback: outcome.fallback === true,
8612
8970
  retried: outcome.retried === true,
8613
8971
  promptSource: outcome.promptSource ?? "",
8614
- itemCount: typeof outcome.itemCount === "number" ? outcome.itemCount : state2.items.length,
8972
+ itemCount: typeof outcome.itemCount === "number" ? outcome.itemCount : state3.items.length,
8615
8973
  startedAt: 0,
8616
- elapsedMs: elapsed(state2.startedAt, event.at)
8974
+ elapsedMs: elapsed(state3.startedAt, event.at)
8617
8975
  };
8618
8976
  }
8619
8977
  case "cancel": {
8620
- if (state2 === null) return state2;
8621
- return { ...state2, phase: "cancelled", startedAt: 0, elapsedMs: elapsed(state2.startedAt, event.at), error: "" };
8978
+ if (state3 === null) return state3;
8979
+ return { ...state3, phase: "cancelled", startedAt: 0, elapsedMs: elapsed(state3.startedAt, event.at), error: "" };
8622
8980
  }
8623
8981
  case "edit": {
8624
- if (state2 === null) return state2;
8625
- return { ...state2, text: event.text, edited: true };
8982
+ if (state3 === null) return state3;
8983
+ return { ...state3, text: event.text, edited: true };
8626
8984
  }
8627
8985
  case "clear":
8628
8986
  return null;
@@ -8632,27 +8990,27 @@ function elapsed(startedAt, at) {
8632
8990
  if (startedAt <= 0 || !Number.isFinite(at)) return 0;
8633
8991
  return at > startedAt ? at - startedAt : 0;
8634
8992
  }
8635
- function insertDecision(state2, currentDraft2, confirmed) {
8636
- if (state2 === null || state2.phase !== "done" || state2.text.trim() === "") return "empty";
8993
+ function insertDecision(state3, currentDraft2, confirmed) {
8994
+ if (state3 === null || state3.phase !== "done" || state3.text.trim() === "") return "empty";
8637
8995
  if (confirmed) return "insert";
8638
- return sameDraft(state2.draftAtStart, currentDraft2) ? "insert" : "confirm";
8996
+ return sameDraft(state3.draftAtStart, currentDraft2) ? "insert" : "confirm";
8639
8997
  }
8640
- function dockSummary(state2) {
8998
+ function dockSummary(state3) {
8641
8999
  const bits = [];
8642
- if (state2.fallback) bits.push("\u6A21\u578B\u6CA1\u6309\u6761\u76EE\u5951\u7EA6\u8F93\u51FA\uFF0C\u5DF2\u6574\u6BB5\u7167\u6536\uFF08\u672A\u6821\u9A8C\u4F9D\u636E\uFF09");
9000
+ if (state3.fallback) bits.push("\u6A21\u578B\u6CA1\u6309\u6761\u76EE\u5951\u7EA6\u8F93\u51FA\uFF0C\u5DF2\u6574\u6BB5\u7167\u6536\uFF08\u672A\u6821\u9A8C\u4F9D\u636E\uFF09");
8643
9001
  else {
8644
- const count2 = state2.phase === "done" && state2.itemCount > 0 ? state2.itemCount : state2.items.length;
9002
+ const count2 = state3.phase === "done" && state3.itemCount > 0 ? state3.itemCount : state3.items.length;
8645
9003
  bits.push(`${String(count2)} \u6761\u8865\u5168`);
8646
9004
  }
8647
- if (state2.dropped.length > 0) bits.push(`\u4E22\u5F03 ${String(state2.dropped.length)} \u6761`);
8648
- if (state2.promptSource === "custom") bits.push("\u81EA\u5B9A\u4E49\u63D0\u793A\u8BCD");
8649
- if (state2.retried) bits.push("\u91CD\u8BD5\u8FC7\u4E00\u6B21");
8650
- if (state2.truncated) bits.push("\u7BC7\u5E45\u95F8\u95E8\u52A8\u8FC7\u624B\uFF08\u7701\u7565\u4E86\u53EF\u9009\u7684\u8282\uFF09");
8651
- if (state2.edited) bits.push("\u4F60\u624B\u6539\u8FC7");
9005
+ if (state3.dropped.length > 0) bits.push(`\u4E22\u5F03 ${String(state3.dropped.length)} \u6761`);
9006
+ if (state3.promptSource === "custom") bits.push("\u81EA\u5B9A\u4E49\u63D0\u793A\u8BCD");
9007
+ if (state3.retried) bits.push("\u91CD\u8BD5\u8FC7\u4E00\u6B21");
9008
+ if (state3.truncated) bits.push("\u7BC7\u5E45\u95F8\u95E8\u52A8\u8FC7\u624B\uFF08\u7701\u7565\u4E86\u53EF\u9009\u7684\u8282\uFF09");
9009
+ if (state3.edited) bits.push("\u4F60\u624B\u6539\u8FC7");
8652
9010
  return bits.join(" \xB7 ");
8653
9011
  }
8654
- function dockPhaseText(state2) {
8655
- switch (state2.phase) {
9012
+ function dockPhaseText(state3) {
9013
+ switch (state3.phase) {
8656
9014
  case "running":
8657
9015
  return "\u6B63\u5728\u4F18\u5316\u2026\uFF08\u7B49\u5F85\u6A21\u578B\u54CD\u5E94\uFF09";
8658
9016
  case "done":
@@ -8766,14 +9124,14 @@ async function copyText(text) {
8766
9124
  return false;
8767
9125
  }
8768
9126
  }
8769
- function OptimizeDock({ state: state2, seconds, actions }) {
8770
- const [copied, setCopied] = (0, import_react18.useState)(false);
8771
- const [discardArmed, setDiscardArmed] = (0, import_react18.useState)(false);
8772
- const running = state2.phase === "running";
8773
- const hasText = state2.text.trim() !== "";
8774
- const canInsert = state2.phase === "done" && hasText;
9127
+ function OptimizeDock({ state: state3, seconds, actions }) {
9128
+ const [copied, setCopied] = (0, import_react20.useState)(false);
9129
+ const [discardArmed, setDiscardArmed] = (0, import_react20.useState)(false);
9130
+ const running = state3.phase === "running";
9131
+ const hasText = state3.text.trim() !== "";
9132
+ const canInsert = state3.phase === "done" && hasText;
8775
9133
  const onCopy = () => {
8776
- void copyText(state2.text).then((ok) => {
9134
+ void copyText(state3.text).then((ok) => {
8777
9135
  if (!ok) return;
8778
9136
  setCopied(true);
8779
9137
  setTimeout(() => {
@@ -8783,8 +9141,8 @@ function OptimizeDock({ state: state2, seconds, actions }) {
8783
9141
  };
8784
9142
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { style: dockBox, role: "group", "aria-label": "\u4F18\u5316\u7ED3\u679C", children: [
8785
9143
  /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { style: dockHead, children: [
8786
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { style: dockPhase, role: "status", children: dockPhaseText(state2) }),
8787
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { style: dockMeta, children: running ? `\u5DF2\u7B49\u5F85 ${String(seconds)}s` : state2.elapsedMs > 0 ? `\u7528\u65F6 ${(state2.elapsedMs / 1e3).toFixed(1)} \u79D2` : "" }),
9144
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { style: dockPhase, role: "status", children: dockPhaseText(state3) }),
9145
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { style: dockMeta, children: running ? `\u5DF2\u7B49\u5F85 ${String(seconds)}s` : state3.elapsedMs > 0 ? `\u7528\u65F6 ${(state3.elapsedMs / 1e3).toFixed(1)} \u79D2` : "" }),
8788
9146
  !running && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
8789
9147
  "button",
8790
9148
  {
@@ -8836,27 +9194,27 @@ function OptimizeDock({ state: state2, seconds, actions }) {
8836
9194
  )
8837
9195
  ] }),
8838
9196
  /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { style: dockBody, children: [
8839
- state2.items.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("ol", { style: dockList, children: state2.items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("li", { style: dockItemRow, children: [
9197
+ state3.items.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("ol", { style: dockList, children: state3.items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("li", { style: dockItemRow, children: [
8840
9198
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { style: dockKind, children: KIND_LABEL[item.kind] ?? item.kind }),
8841
9199
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { style: dockItemText, children: item.text }),
8842
9200
  item.quote !== "" && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { style: dockMeta, children: item.quoteSource === "none" ? `\uFF08\u6A21\u578B\u81EA\u5DF1\u8865\u7684\uFF0C\u4F9D\u636E\u4E0D\u662F\u4F60\u539F\u8BDD\uFF1A\u300C${item.quote}\u300D\uFF09` : `\uFF08\u4F9D\u636E\uFF1A"${item.quote}"\uFF09` })
8843
9201
  ] }, item.id)) }),
8844
- state2.dropped.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { style: dockDropped, children: `\u4E22\u5F03 ${String(state2.dropped.length)} \u6761\uFF1A${state2.dropped.map((row2) => row2.reason).join("\uFF1B")}` }),
8845
- state2.phase === "error" && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { style: dockError, role: "alert", children: state2.error === "" ? "\u4F18\u5316\u5931\u8D25" : state2.error }),
8846
- (state2.phase === "done" || state2.phase === "cancelled") && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
9202
+ state3.dropped.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { style: dockDropped, children: `\u4E22\u5F03 ${String(state3.dropped.length)} \u6761\uFF1A${state3.dropped.map((row2) => row2.reason).join("\uFF1B")}` }),
9203
+ state3.phase === "error" && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { style: dockError, role: "alert", children: state3.error === "" ? "\u4F18\u5316\u5931\u8D25" : state3.error }),
9204
+ (state3.phase === "done" || state3.phase === "cancelled") && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
8847
9205
  "textarea",
8848
9206
  {
8849
- value: state2.text,
9207
+ value: state3.text,
8850
9208
  onChange: (event) => {
8851
9209
  actions.edit(event.target.value);
8852
9210
  },
8853
9211
  spellCheck: false,
8854
9212
  "aria-label": "\u4F18\u5316\u540E\u7684\u63D0\u793A\u8BCD\uFF08\u53EF\u7F16\u8F91\uFF09",
8855
- placeholder: state2.phase === "cancelled" ? "\u53D6\u6D88\u65F6\u8FD8\u6CA1\u6709\u6210\u54C1\uFF1A\u4E0A\u9762\u662F\u5DF2\u751F\u6210\u7684\u90E8\u5206\u3002\u70B9\u300C\u91CD\u65B0\u4F18\u5316\u300D\u8DD1\u5B8C\u4E00\u8F6E\u5C31\u80FD\u62FF\u5230\u6210\u54C1\u3002" : "\uFF08\u6210\u54C1\u4E3A\u7A7A\uFF09",
9213
+ placeholder: state3.phase === "cancelled" ? "\u53D6\u6D88\u65F6\u8FD8\u6CA1\u6709\u6210\u54C1\uFF1A\u4E0A\u9762\u662F\u5DF2\u751F\u6210\u7684\u90E8\u5206\u3002\u70B9\u300C\u91CD\u65B0\u4F18\u5316\u300D\u8DD1\u5B8C\u4E00\u8F6E\u5C31\u80FD\u62FF\u5230\u6210\u54C1\u3002" : "\uFF08\u6210\u54C1\u4E3A\u7A7A\uFF09",
8856
9214
  style: dockEditor
8857
9215
  }
8858
9216
  ),
8859
- state2.phase === "done" && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { style: dockSummaryLine, children: state2.route === "" ? dockSummary(state2) : `${dockSummary(state2)} \xB7 ${state2.route}` })
9217
+ state3.phase === "done" && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { style: dockSummaryLine, children: state3.route === "" ? dockSummary(state3) : `${dockSummary(state3)} \xB7 ${state3.route}` })
8860
9218
  ] }),
8861
9219
  /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { style: { ...dockButtons, ...dockButtonsPinned }, children: [
8862
9220
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
@@ -8879,7 +9237,7 @@ function OptimizeDock({ state: state2, seconds, actions }) {
8879
9237
  type: "button",
8880
9238
  disabled: running,
8881
9239
  style: running ? dockButtonDisabled : dockButton,
8882
- title: state2.edited ? "\u518D\u8DD1\u4E00\u8F6E\uFF08\u4F1A\u8986\u76D6\u4F60\u5728\u6846\u91CC\u624B\u6539\u7684\u5185\u5BB9\uFF09" : "\u7528\u540C\u4E00\u6BB5\u539F\u6587\u518D\u8DD1\u4E00\u8F6E",
9240
+ title: state3.edited ? "\u518D\u8DD1\u4E00\u8F6E\uFF08\u4F1A\u8986\u76D6\u4F60\u5728\u6846\u91CC\u624B\u6539\u7684\u5185\u5BB9\uFF09" : "\u7528\u540C\u4E00\u6BB5\u539F\u6587\u518D\u8DD1\u4E00\u8F6E",
8883
9241
  onMouseDown: (event) => {
8884
9242
  event.preventDefault();
8885
9243
  },
@@ -8930,11 +9288,11 @@ function QuickCommandsPanel({
8930
9288
  const status = useBookStatus((item) => item);
8931
9289
  const dock = useDock((item) => item);
8932
9290
  const dockHidden = useDockHidden((item) => item);
8933
- const ref = (0, import_react19.useRef)(null);
8934
- const [position, setPosition] = (0, import_react19.useState)(null);
8935
- const [activeId, setActiveId] = (0, import_react19.useState)("");
8936
- const [section, setSection] = (0, import_react19.useState)(DEFAULT_PANEL_SECTION);
8937
- const [optionsOpen, setOptionsOpen] = (0, import_react19.useState)(OPTIONS_FOLD_DEFAULT_OPEN);
9291
+ const ref = (0, import_react21.useRef)(null);
9292
+ const [position, setPosition] = (0, import_react21.useState)(null);
9293
+ const [activeId, setActiveId] = (0, import_react21.useState)("");
9294
+ const [section, setSection] = (0, import_react21.useState)(DEFAULT_PANEL_SECTION);
9295
+ const [optionsOpen, setOptionsOpen] = (0, import_react21.useState)(OPTIONS_FOLD_DEFAULT_OPEN);
8938
9296
  const dockPresent = dock !== null;
8939
9297
  const tierOff = settings.optimizerTier === "off";
8940
9298
  const seconds = useOptimizeElapsed(busy ? startedAt : 0);
@@ -8943,7 +9301,7 @@ function QuickCommandsPanel({
8943
9301
  const counts = bookCounts(book);
8944
9302
  const categories = book.categories;
8945
9303
  const active2 = categories.find((category) => category.id === activeId) ?? categories[0];
8946
- (0, import_react19.useLayoutEffect)(() => {
9304
+ (0, import_react21.useLayoutEffect)(() => {
8947
9305
  if (anchor === null) {
8948
9306
  setPosition(null);
8949
9307
  return;
@@ -8956,7 +9314,7 @@ function QuickCommandsPanel({
8956
9314
  const top = above >= MARGIN ? above : Math.min(anchor.bottom + GAP, window.innerHeight - height - MARGIN);
8957
9315
  setPosition({ left, top: Math.max(MARGIN, top) });
8958
9316
  }, [anchor?.left, anchor?.bottom, counts.prompts, categories.length, busy, section, dock !== null]);
8959
- (0, import_react19.useEffect)(() => {
9317
+ (0, import_react21.useEffect)(() => {
8960
9318
  if (anchor === null) return;
8961
9319
  const onPointerDown = (event) => {
8962
9320
  if (ref.current !== null && event.target instanceof Node && ref.current.contains(event.target)) return;
@@ -8984,8 +9342,8 @@ function QuickCommandsPanel({
8984
9342
  }, [anchor === null, actions, dockRunning]);
8985
9343
  const panelOpen = anchor !== null;
8986
9344
  const dockVisible = dockPresent && !dockHidden;
8987
- const prevOpen = (0, import_react19.useRef)(false);
8988
- const prevDockVisible = (0, import_react19.useRef)(false);
9345
+ const prevOpen = (0, import_react21.useRef)(false);
9346
+ const prevDockVisible = (0, import_react21.useRef)(false);
8989
9347
  if (prevOpen.current !== panelOpen) {
8990
9348
  prevOpen.current = panelOpen;
8991
9349
  if (panelOpen) {
@@ -9255,6 +9613,7 @@ function QuickCommandsPanel({
9255
9613
  }
9256
9614
 
9257
9615
  // src/client/optimize-state.ts
9616
+ init_settings_contract();
9258
9617
  var textOf2 = (value) => typeof value === "string" && value !== "" ? value : void 0;
9259
9618
  async function request(method, body) {
9260
9619
  try {
@@ -9288,8 +9647,8 @@ async function request(method, body) {
9288
9647
  function loadDockState() {
9289
9648
  return request("GET");
9290
9649
  }
9291
- function saveDockState(state2, hidden = false) {
9292
- return request("POST", { state: state2, hidden: hidden === true });
9650
+ function saveDockState(state3, hidden = false) {
9651
+ return request("POST", { state: state3, hidden: hidden === true });
9293
9652
  }
9294
9653
  function clearDockStateOnHost() {
9295
9654
  return saveDockState(null);
@@ -9368,26 +9727,26 @@ function createDirectoryFlowController(options) {
9368
9727
  }
9369
9728
 
9370
9729
  // src/client/DirectoryFlowEntry.tsx
9371
- var import_react20 = require("react");
9730
+ var import_react22 = require("react");
9372
9731
  function DirectoryFlowEntry(props) {
9373
9732
  const { open, pick } = props;
9374
- const alive = (0, import_react20.useRef)(true);
9375
- const latest = (0, import_react20.useRef)(props);
9733
+ const alive = (0, import_react22.useRef)(true);
9734
+ const latest = (0, import_react22.useRef)(props);
9376
9735
  latest.current = props;
9377
- const flow = (0, import_react20.useMemo)(() => createPickFlow({
9736
+ const flow = (0, import_react22.useMemo)(() => createPickFlow({
9378
9737
  pick,
9379
9738
  report: (outcome) => {
9380
9739
  applyOutcome(latest.current, outcome);
9381
9740
  },
9382
9741
  isAlive: () => alive.current
9383
9742
  }), [pick]);
9384
- (0, import_react20.useEffect)(() => {
9743
+ (0, import_react22.useEffect)(() => {
9385
9744
  alive.current = true;
9386
9745
  return () => {
9387
9746
  alive.current = false;
9388
9747
  };
9389
9748
  }, []);
9390
- (0, import_react20.useEffect)(() => {
9749
+ (0, import_react22.useEffect)(() => {
9391
9750
  flow.setOpen(open);
9392
9751
  }, [flow, open]);
9393
9752
  return null;
@@ -9494,30 +9853,43 @@ function apply(ctx) {
9494
9853
  adoptSettings(peekService("configForms"), "get");
9495
9854
  adoptSettings(peekService("settingsScope"), "bind");
9496
9855
  const WRITE_READBACK_MS = 1200;
9856
+ const WRITE_RETRY_MS = 120;
9497
9857
  const setField = (field, value) => {
9498
9858
  writeNotice.set("");
9499
9859
  const verify = typeof value === "boolean";
9500
- void scope.set(field, value).then((accepted) => {
9501
- if (accepted === false) {
9502
- console.warn("[composer-ux] settings write refused", field);
9503
- writeNotice.set(
9504
- `\u5199\u5165\u300C${field}\u300D\u88AB\u5BBF\u4E3B\u62D2\u7EDD\u3002\u5E38\u89C1\u539F\u56E0\uFF1Aprofile \u7684\u5199\u5165\u9501\u88AB\u5360\u7528\uFF0C\u6216\u662F\u4E00\u628A\u5B64\u513F\u9501\uFF08\u786C\u6740\u91CD\u542F\u7559\u4E0B\u7684\uFF09\u2014\u2014\u89C1 README\u300C\u8BBE\u7F6E\u5199\u4E0D\u8FDB\u53BB\u300D\u4E00\u8282\uFF1B\u91CD\u542F DSH \u540E\u4ECD\u65E0\u6548\uFF0C\u5C31\u624B\u5DE5\u5220\u6389 profiles/<\u4F60\u7684 profile>/package.json.lock\u3002`
9505
- );
9506
- return;
9507
- }
9508
- if (!verify) return;
9509
- setTimeout(() => {
9510
- const now = live.getSnapshot()[field];
9511
- if (now === value) return;
9512
- console.warn("[composer-ux] settings write had no visible effect", field, now, value);
9513
- writeNotice.set(
9514
- `\u5199\u5165\u300C${field}\u300D\u5DF2\u88AB\u5BBF\u4E3B\u63A5\u53D7\uFF0C\u4F46\u8FD0\u884C\u65F6\u7684\u503C\u6CA1\u6709\u53D8\u5316\uFF08\u4ECD\u662F ${String(now)}\uFF09\u3002\u914D\u7F6E\u53EF\u80FD\u5DF2\u7ECF\u843D\u76D8\uFF0C\u53EA\u662F\u8FD9\u4E2A\u8FDB\u7A0B\u6CA1\u63A5\u4F4F\u2014\u2014\u91CD\u542F DSH \u5373\u53EF\u751F\u6548\u3002`
9515
- );
9516
- }, WRITE_READBACK_MS);
9517
- }, (error) => {
9518
- console.error("[composer-ux] settings write failed", error);
9519
- writeNotice.set(`\u5199\u5165\u300C${field}\u300D\u5931\u8D25\uFF1A${error instanceof Error ? error.message : String(error)}`);
9520
- });
9860
+ const attempt = (remaining) => {
9861
+ void scope.set(field, value).then((accepted) => {
9862
+ if (accepted === false) {
9863
+ if (remaining > 0) {
9864
+ setTimeout(() => {
9865
+ attempt(remaining - 1);
9866
+ }, WRITE_RETRY_MS);
9867
+ return;
9868
+ }
9869
+ console.warn("[composer-ux] settings write refused", field);
9870
+ writeNotice.set(
9871
+ `\u5199\u5165\u300C${field}\u300D\u88AB\u5BBF\u4E3B\u62D2\u7EDD\u3002\u5E38\u89C1\u539F\u56E0\uFF1A\u8BBE\u7F6E\u7248\u672C\u521A\u88AB\u6539\u8FC7\uFF08\u542F\u52A8\u65F6\u5BBF\u4E3B\u534A\u4F1A\u81EA\u5DF1\u5199\u4E00\u6B21\uFF09\u3001profile \u7684\u5199\u5165\u9501\u88AB\u5360\u7528\uFF0C\u6216\u662F\u4E00\u628A\u5B64\u513F\u9501\uFF08\u786C\u6740\u91CD\u542F\u7559\u4E0B\u7684\uFF09\u2014\u2014\u89C1 README\u300C\u8BBE\u7F6E\u5199\u4E0D\u8FDB\u53BB\u300D\u4E00\u8282\uFF1B\u91CD\u542F DSH \u540E\u4ECD\u65E0\u6548\uFF0C\u5C31\u624B\u5DE5\u5220\u6389 profiles/<\u4F60\u7684 profile>/package.json.lock\u3002`
9872
+ );
9873
+ return;
9874
+ }
9875
+ if (!verify) return;
9876
+ setTimeout(() => {
9877
+ const now = live.getSnapshot()[field];
9878
+ if (now === value) return;
9879
+ console.warn("[composer-ux] settings write had no visible effect", field, now, value);
9880
+ writeNotice.set(
9881
+ `\u5199\u5165\u300C${field}\u300D\u5DF2\u88AB\u5BBF\u4E3B\u63A5\u53D7\uFF0C\u4F46\u8FD0\u884C\u65F6\u7684\u503C\u6CA1\u6709\u53D8\u5316\uFF08\u4ECD\u662F ${String(now)}\uFF09\u3002\u914D\u7F6E\u53EF\u80FD\u5DF2\u7ECF\u843D\u76D8\uFF0C\u53EA\u662F\u8FD9\u4E2A\u8FDB\u7A0B\u6CA1\u63A5\u4F4F\u2014\u2014\u91CD\u542F DSH \u5373\u53EF\u751F\u6548\u3002`
9882
+ );
9883
+ }, WRITE_READBACK_MS);
9884
+ }, (error) => {
9885
+ console.error("[composer-ux] settings write failed", error);
9886
+ writeNotice.set(`\u5199\u5165\u300C${field}\u300D\u5931\u8D25\uFF1A${error instanceof Error ? error.message : String(error)}`);
9887
+ }).catch((error) => {
9888
+ console.warn("[composer-ux] settings write threw", field, error);
9889
+ writeNotice.set("\u5199\u5165\u300C" + field + "\u300D\u5931\u8D25\uFF1A" + (error instanceof Error ? error.message : String(error)));
9890
+ });
9891
+ };
9892
+ attempt(1);
9521
9893
  };
9522
9894
  const clearField = (field) => {
9523
9895
  void scope.unset(field).then((accepted) => {
@@ -9763,9 +10135,9 @@ function apply(ctx) {
9763
10135
  * `confirm`(那会打断输入、在桌面壳里还可能被拦)。
9764
10136
  */
9765
10137
  dockInsert: () => {
9766
- const state2 = dock.getSnapshot();
9767
- const decision = insertDecision(state2, currentDraft(), insertConfirmed);
9768
- if (decision === "empty" || state2 === null) {
10138
+ const state3 = dock.getSnapshot();
10139
+ const decision = insertDecision(state3, currentDraft(), insertConfirmed);
10140
+ if (decision === "empty" || state3 === null) {
9769
10141
  note2("\u7ED3\u679C\u6846\u91CC\u8FD8\u6CA1\u6709\u6210\u54C1\u53EF\u63D2\u5165\uFF08\u7B49\u8FD9\u4E00\u8F6E\u8DD1\u5B8C\uFF09");
9770
10142
  return;
9771
10143
  }
@@ -9775,33 +10147,33 @@ function apply(ctx) {
9775
10147
  return;
9776
10148
  }
9777
10149
  insertConfirmed = false;
9778
- if (!replaceDraft(composeOptimizedDraft(state2.slashPrefix, state2.text))) {
10150
+ if (!replaceDraft(composeOptimizedDraft(state3.slashPrefix, state3.text))) {
9779
10151
  note2("\u5199\u56DE\u8F93\u5165\u6846\u5931\u8D25\uFF1A\u6CA1\u62FF\u5230\u8F93\u5165\u6846\u7684\u63A7\u5236\u6743\uFF08\u5237\u65B0\u9875\u9762\u518D\u8BD5\uFF09");
9780
10152
  return;
9781
10153
  }
9782
10154
  focusComposer();
9783
- note2(state2.slashPrefix === "" ? "\u5DF2\u63D2\u5165\u8F93\u5165\u6846 \xB7 Ctrl+Z \u53EF\u8FD8\u539F" : `\u5DF2\u63D2\u5165\u8F93\u5165\u6846\uFF08\u4FDD\u7559\u547D\u4EE4 ${state2.slashPrefix}\uFF09\xB7 Ctrl+Z \u53EF\u8FD8\u539F`);
10155
+ note2(state3.slashPrefix === "" ? "\u5DF2\u63D2\u5165\u8F93\u5165\u6846 \xB7 Ctrl+Z \u53EF\u8FD8\u539F" : `\u5DF2\u63D2\u5165\u8F93\u5165\u6846\uFF08\u4FDD\u7559\u547D\u4EE4 ${state3.slashPrefix}\uFF09\xB7 Ctrl+Z \u53EF\u8FD8\u539F`);
9784
10156
  },
9785
10157
  /** 用**框里那一轮的原文**再跑一轮(不是拿输入框现在的内文 —— 那时你多半已经插进去了)。 */
9786
10158
  dockRetry: () => {
9787
- const state2 = dock.getSnapshot();
9788
- if (state2 === null) return;
9789
- if (state2.edited) note2("\u91CD\u65B0\u4F18\u5316\u4F1A\u8986\u76D6\u4F60\u5728\u7ED3\u679C\u6846\u91CC\u624B\u6539\u7684\u5185\u5BB9");
10159
+ const state3 = dock.getSnapshot();
10160
+ if (state3 === null) return;
10161
+ if (state3.edited) note2("\u91CD\u65B0\u4F18\u5316\u4F1A\u8986\u76D6\u4F60\u5728\u7ED3\u679C\u6846\u91CC\u624B\u6539\u7684\u5185\u5BB9");
9790
10162
  startOptimize({
9791
- source: state2.source,
10163
+ source: state3.source,
9792
10164
  draftAtStart: currentDraft(),
9793
- prefix: state2.slashPrefix
10165
+ prefix: state3.slashPrefix
9794
10166
  });
9795
10167
  },
9796
10168
  /** 中止这一轮并保留已生成的部分(条目流水留着,成品本来就不存在)。 */
9797
10169
  dockCancel: () => {
9798
- const state2 = dock.getSnapshot();
9799
- if (state2 === null || state2.phase !== "running") return;
10170
+ const state3 = dock.getSnapshot();
10171
+ if (state3 === null || state3.phase !== "running") return;
9800
10172
  optimizeAbort?.abort();
9801
10173
  optimizeAbort = void 0;
9802
10174
  optimizing.set(false);
9803
10175
  optimizeStartedAt.set(0);
9804
- dock.set(dockReducer(state2, { type: "cancel", at: Date.now() }));
10176
+ dock.set(dockReducer(state3, { type: "cancel", at: Date.now() }));
9805
10177
  note2("\u5DF2\u53D6\u6D88\u8FD9\u4E00\u8F6E\uFF1A\u4E0A\u9762\u662F\u5DF2\u7ECF\u751F\u6210\u7684\u90E8\u5206");
9806
10178
  },
9807
10179
  /**
@@ -9896,6 +10268,11 @@ function apply(ctx) {
9896
10268
  id: "composer-ux-panel-resize",
9897
10269
  inject: () => ({ hooks: { live }, actions: { setField } })
9898
10270
  }, PanelResizeHandles));
10271
+ void loadNavFold();
10272
+ slots.inject("shell.overlay", () => slots.register({
10273
+ name: "shell.overlay",
10274
+ id: "composer-ux-nav-fold"
10275
+ }, NavFoldHost));
9899
10276
  slots.inject("conversation.input.right", () => slots.register({
9900
10277
  name: "conversation.input.right",
9901
10278
  id: "composer-ux-quick",
@@ -9974,8 +10351,8 @@ function apply(ctx) {
9974
10351
  // 「快捷指令」栏关掉时这里直接给空批次 —— 这是唯一一处"关掉就不附加"的闸,
9975
10352
  // 键位发送与官方按钮两条路都从这里取批次,不需要各写一遍。
9976
10353
  promptsForSend: () => activeSections(live.getSnapshot()).quick ? appendBatchForSend(book.getSnapshot(), currentBlankSession()) : [],
9977
- setMenu: (state2) => {
9978
- menu2.set(state2);
10354
+ setMenu: (state3) => {
10355
+ menu2.set(state3);
9979
10356
  },
9980
10357
  menuOpen: () => menu2.getSnapshot() !== null
9981
10358
  });