dsh-context-compression-improved 0.6.4 → 0.7.0-beta.1
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/CHANGELOG.ja.md +51 -0
- package/CHANGELOG.ko.md +47 -0
- package/CHANGELOG.md +72 -0
- package/CHANGELOG.zh.md +47 -0
- package/README.ja.md +2 -2
- package/README.ko.md +2 -2
- package/README.md +6 -3
- package/README.zh.md +3 -2
- package/eslint.config.js +76 -30
- package/package.json +164 -162
- package/packages/selector/dsh.plugin.json +16 -16
- package/packages/selector/lib/client.js +16 -4
- package/packages/selector/lib/index.js +92 -1
- package/packages/selector/lib/{advisor-state.js → intent-gate.js} +91 -3
- package/packages/selector/lib/profiles.d.ts +9 -0
- package/packages/selector/lib/pruner.d.ts +59 -0
- package/packages/selector/lib/pruner.js +410 -8
- package/packages/selector/package.json +114 -114
- package/packages/selector/src/client/decode.ts +6 -2
- package/packages/selector/src/client/index.ts +213 -232
- package/packages/selector/src/client/scope-face.ts +24 -24
- package/packages/selector/src/deepseek-v4-tokenizer.ts +1 -1
- package/packages/selector/src/index.ts +418 -412
- package/packages/selector/src/preset-overlay.ts +3 -0
- package/packages/selector/src/profiles.ts +30 -10
- package/packages/selector/src/pruner/content.ts +1 -1
- package/packages/selector/src/pruner/state.ts +7 -0
- package/packages/selector/src/pruner.ts +253 -10
- package/packages/selector/src/runtime/audit.ts +17 -0
- package/packages/selector/src/runtime/config.ts +36 -11
- package/packages/selector/src/runtime/reducers.ts +1 -1
- package/packages/selector/src/runtime/summary-command.ts +133 -0
- package/packages/selector/src/runtime/tokenpilot/advisor-prompt.ts +46 -1
- package/packages/selector/src/runtime/tokenpilot/advisor-state.ts +55 -0
- package/packages/selector/src/runtime/tokenpilot/intent-fold.ts +53 -0
- package/packages/selector/src/runtime/tokenpilot/intent-gate.ts +65 -0
- package/packages/selector/src/runtime/tokenpilot/intent-input-mask.ts +125 -0
- package/packages/selector/src/runtime/tokenpilot/intent-range.ts +37 -0
- package/packages/selector/src/runtime/tokenpilot/locator.ts +2 -2
- package/packages/selector/src/runtime/tokenpilot/sidechannel.ts +4 -1
- package/packages/selector/src/runtime/types.ts +12 -0
- package/packages/selector/tests/auto-compact.client.spec.tsx +214 -213
- package/packages/selector/tests/built/client-artifact.spec.ts +2 -0
- package/packages/selector/tests/code-skeleton.client.spec.ts +94 -93
- package/packages/selector/tests/custom-contract.client.spec.ts +3 -2
- package/packages/selector/tests/estimator-channel.client.spec.tsx +252 -252
- package/packages/selector/tests/helpers/legacy-namespace.ts +8 -4
- package/packages/selector/tests/helpers/legacy-settings/index.ts +15 -0
- package/packages/selector/tests/helpers/legacy-settings/legacy/provider.d.ts +41 -0
- package/packages/selector/tests/helpers/legacy-settings/legacy/provider.js +647 -0
- package/packages/selector/tests/helpers/legacy-settings/legacy/redact.js +78 -0
- package/packages/selector/tests/helpers/legacy-settings/legacy/util-values.js +234 -0
- package/packages/selector/tests/host-preset-overlay.host.spec.ts +204 -206
- package/packages/selector/tests/preset-options-write.client.spec.ts +188 -187
- package/packages/selector/tests/preset-overlay-loader.e2e.host.spec.ts +200 -206
- package/packages/selector/tests/profiles.client.spec.tsx +436 -434
- package/packages/selector/tests/public/package-contract.client.spec.ts +78 -78
- package/packages/selector/tests/runtime/advice-never-withholds.host.spec.ts +230 -233
- package/packages/selector/tests/runtime/audit.spec.ts +275 -274
- package/packages/selector/tests/runtime/auto-compact-config.spec.ts +3 -3
- package/packages/selector/tests/runtime/deepseek-v4-tokenizer.spec.ts +4 -4
- package/packages/selector/tests/runtime/intent-gate.spec.ts +62 -0
- package/packages/selector/tests/runtime/intent-summary.spec.ts +156 -0
- package/packages/selector/tests/runtime/public/public-runtime.spec.ts +2736 -2727
- package/packages/selector/tests/runtime/summary-command.spec.ts +154 -0
- package/packages/selector/tests/settings-seat.client.spec.ts +165 -165
- package/packages/selector/tests/standing-generation.host.spec.ts +704 -704
- package/packages/selector/tests/subagent-cache-reuse.host.spec.ts +18 -2
- package/packages/selector/tests/support/ui-primitives.tsx +34 -34
- package/pnpm-workspace.yaml +1 -1
- package/scripts/packed-components-smoke.mjs +2 -0
- package/scripts/packed-install-e2e.mjs +1275 -1273
- package/scripts/verify-release.mjs +318 -317
- package/tsconfig.tests.json +3 -1
- package/vitest.config.ts +14 -0
|
@@ -1,232 +1,213 @@
|
|
|
1
|
-
import type {} from '@deepseek-ai/dsh-client-locale/client'
|
|
2
|
-
import type { Context as ClientContext } from '@deepseek-ai/cordis'
|
|
3
|
-
import type {} from '@deepseek-ai/dsh-client-ui-session/client'
|
|
4
|
-
import type {} from '@deepseek-ai/dsh-client-ui-settings/client'
|
|
5
|
-
import type {} from '@deepseek-ai/dsh-client-ui-workspace/client'
|
|
6
|
-
import {
|
|
7
|
-
isCustomCompressionPolicy,
|
|
8
|
-
ContextCompressionSettingsSection,
|
|
9
|
-
type CompressionSelectorInjected, type ContextCompressionSettings,
|
|
10
|
-
} from './CompressionProfileSelector.tsx'
|
|
11
|
-
import { DEFAULT_CUSTOM_COMPRESSION_POLICY } from '../profiles.ts'
|
|
12
|
-
import { decodeSettings } from './decode.ts'
|
|
13
|
-
import { en, zh } from './locales.ts'
|
|
14
|
-
import { planPresetOptionsOps, presetOptionsOpsAccepted } from './preset-options.ts'
|
|
15
|
-
import type { ScopeSnapshot, SettingsScope } from './scope-face.ts'
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Harness 0.1.5 mounts the web core's `slots` service on the client context
|
|
19
|
-
* but no longer ships a public type for it; declare the face this plugin
|
|
20
|
-
* consumes (same shape dsh-thinking-levels and dsh-prime-memory rely on).
|
|
21
|
-
* `inject` factories may be sync (return a disposer) or generator (yield the
|
|
22
|
-
* registration); slot options are validated at runtime per slot kind, which
|
|
23
|
-
* lets one entry supply both `id` (Desktop, list) and `key` (CLI, keyed).
|
|
24
|
-
*/
|
|
25
|
-
interface SlotsService {
|
|
26
|
-
inject(slot: string, register: () => (() => void) | Generator<() => void>): () => void
|
|
27
|
-
register(options: Record<string, unknown>, component: unknown): () => void
|
|
28
|
-
}
|
|
29
|
-
declare module '@deepseek-ai/cordis' {
|
|
30
|
-
interface Context {
|
|
31
|
-
slots: SlotsService
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Declare all consumed services (the official client-plugin pattern, and the
|
|
36
|
-
// shape dsh-thinking-levels proves on this same 0.1.5 host line): cordis holds
|
|
37
|
-
// apply until `locale` / `configForms` are provided, so registration can use
|
|
38
|
-
// them directly. Resolving them lazily via ctx.get() instead races the settings
|
|
39
|
-
// client's activation — on a loss the apply early-returned and EVERY settings
|
|
40
|
-
// entry silently vanished.
|
|
41
|
-
export const inject = ['slots', 'locale', 'configForms']
|
|
42
|
-
const NS = 'context-compression'
|
|
43
|
-
|
|
44
|
-
/** 0.1.7: the profile entry whose config carries the compression settings doc. */
|
|
45
|
-
const ENTRY_ID = 'context-compression-improved-bundle'
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
},
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
)
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
// 设置里同时出现独立分节和插件卡片,重复展示同一张面板。
|
|
215
|
-
try {
|
|
216
|
-
ctx.slots.inject('settings.section', () => ctx.slots.register({
|
|
217
|
-
name: 'settings.section',
|
|
218
|
-
id: 'context-compression',
|
|
219
|
-
order: 17,
|
|
220
|
-
label: () => tNav('nav'),
|
|
221
|
-
locale: NS,
|
|
222
|
-
inject: injected,
|
|
223
|
-
}, ContextCompressionSettingsSection))
|
|
224
|
-
} catch (error) {
|
|
225
|
-
console.warn('[dsh-context-compression-improved] settings.section 注册失败(新宿主已收编):', error)
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
export type {
|
|
230
|
-
CompressionProfile, CompressionProfileSelectorProps, CompressionSelectorInjected,
|
|
231
|
-
ContextCompressionSettings,
|
|
232
|
-
} from './CompressionProfileSelector.tsx'
|
|
1
|
+
import type {} from '@deepseek-ai/dsh-client-locale/client'
|
|
2
|
+
import type { Context as ClientContext } from '@deepseek-ai/cordis'
|
|
3
|
+
import type {} from '@deepseek-ai/dsh-client-ui-session/client'
|
|
4
|
+
import type {} from '@deepseek-ai/dsh-client-ui-settings/client'
|
|
5
|
+
import type {} from '@deepseek-ai/dsh-client-ui-workspace/client'
|
|
6
|
+
import {
|
|
7
|
+
isCustomCompressionPolicy,
|
|
8
|
+
ContextCompressionSettingsSection,
|
|
9
|
+
type CompressionSelectorInjected, type ContextCompressionSettings,
|
|
10
|
+
} from './CompressionProfileSelector.tsx'
|
|
11
|
+
import { DEFAULT_CUSTOM_COMPRESSION_POLICY } from '../profiles.ts'
|
|
12
|
+
import { decodeSettings } from './decode.ts'
|
|
13
|
+
import { en, zh } from './locales.ts'
|
|
14
|
+
import { planPresetOptionsOps, presetOptionsOpsAccepted } from './preset-options.ts'
|
|
15
|
+
import type { ScopeSnapshot, SettingsScope } from './scope-face.ts'
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Harness 0.1.5 mounts the web core's `slots` service on the client context
|
|
19
|
+
* but no longer ships a public type for it; declare the face this plugin
|
|
20
|
+
* consumes (same shape dsh-thinking-levels and dsh-prime-memory rely on).
|
|
21
|
+
* `inject` factories may be sync (return a disposer) or generator (yield the
|
|
22
|
+
* registration); slot options are validated at runtime per slot kind, which
|
|
23
|
+
* lets one entry supply both `id` (Desktop, list) and `key` (CLI, keyed).
|
|
24
|
+
*/
|
|
25
|
+
interface SlotsService {
|
|
26
|
+
inject(slot: string, register: () => (() => void) | Generator<() => void>): () => void
|
|
27
|
+
register(options: Record<string, unknown>, component: unknown): () => void
|
|
28
|
+
}
|
|
29
|
+
declare module '@deepseek-ai/cordis' {
|
|
30
|
+
interface Context {
|
|
31
|
+
slots: SlotsService
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Declare all consumed services (the official client-plugin pattern, and the
|
|
36
|
+
// shape dsh-thinking-levels proves on this same 0.1.5 host line): cordis holds
|
|
37
|
+
// apply until `locale` / `configForms` are provided, so registration can use
|
|
38
|
+
// them directly. Resolving them lazily via ctx.get() instead races the settings
|
|
39
|
+
// client's activation — on a loss the apply early-returned and EVERY settings
|
|
40
|
+
// entry silently vanished.
|
|
41
|
+
export const inject = ['slots', 'locale', 'configForms']
|
|
42
|
+
const NS = 'context-compression'
|
|
43
|
+
|
|
44
|
+
/** 0.1.7: the profile entry whose config carries the compression settings doc. */
|
|
45
|
+
const ENTRY_ID = 'context-compression-improved-bundle'
|
|
46
|
+
|
|
47
|
+
function sameCustomPolicy(
|
|
48
|
+
left: ContextCompressionSettings['custom'],
|
|
49
|
+
right: ContextCompressionSettings['custom'],
|
|
50
|
+
): boolean {
|
|
51
|
+
if (left.version !== 3 || right.version !== 3) return false
|
|
52
|
+
return left.version === right.version
|
|
53
|
+
&& left.unit === right.unit
|
|
54
|
+
&& left.prefixPolicy === right.prefixPolicy
|
|
55
|
+
&& left.fresh.enabled === right.fresh.enabled
|
|
56
|
+
&& left.fresh.trigger === right.fresh.trigger
|
|
57
|
+
&& left.fresh.target === right.fresh.target
|
|
58
|
+
&& left.aggregate.enabled === right.aggregate.enabled
|
|
59
|
+
&& left.aggregate.trigger === right.aggregate.trigger
|
|
60
|
+
&& left.aggregate.target === right.aggregate.target
|
|
61
|
+
&& left.history.enabled === right.history.enabled
|
|
62
|
+
&& left.history.trigger === right.history.trigger
|
|
63
|
+
&& left.history.keepRecentToolCalls === right.history.keepRecentToolCalls
|
|
64
|
+
&& left.history.keepRecentTokens === right.history.keepRecentTokens
|
|
65
|
+
&& left.history.minReclaim === right.history.minReclaim
|
|
66
|
+
&& left.tailTrim.enabled === right.tailTrim.enabled
|
|
67
|
+
&& left.tailTrim.trigger === right.tailTrim.trigger
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function apply(ctx: ClientContext): void {
|
|
71
|
+
ctx.locale.register(NS, { zh, en })
|
|
72
|
+
// Section label translator, captured EAGERLY: the settings shell evaluates
|
|
73
|
+
// `label()` during its own render; a lazy ctx.locale accessor inside the
|
|
74
|
+
// thunk would throw there if `locale` ever left this module's inject list
|
|
75
|
+
// (the search-index 0.5.3 family-tab incident). bind() returns a live
|
|
76
|
+
// binder, so locale switches are still followed.
|
|
77
|
+
const localeSvc = ctx.locale as { bind?: (n: string) => (key: string) => string } | undefined
|
|
78
|
+
const tNav = localeSvc?.bind?.(NS) ?? ((key: string) => key)
|
|
79
|
+
const injected = (): CompressionSelectorInjected => {
|
|
80
|
+
// 0.1.7: the compression document rides the selector row's entry config as
|
|
81
|
+
// the volatile `settings` field. The form handle is fetched per factory
|
|
82
|
+
// call on the caller's fiber (same activation rule as the old bind); the
|
|
83
|
+
// wrapper below decodes the stored doc and converts per-field writes into
|
|
84
|
+
// whole-doc commits (a volatile object replaces as one snapshot).
|
|
85
|
+
const form = ctx.configForms.get<Record<string, unknown>>(ENTRY_ID)
|
|
86
|
+
const readDoc = (): ContextCompressionSettings | undefined =>
|
|
87
|
+
decodeSettings(form.getSnapshot().value?.settings)
|
|
88
|
+
// useSyncExternalStore requires a getSnapshot that returns a STABLE
|
|
89
|
+
// reference between changes — a fresh object per call is React error #185
|
|
90
|
+
// (maximum update depth exceeded). Cache the projection keyed on the form
|
|
91
|
+
// snapshot's identity: ConfigFormSnapshot is documented stable until the
|
|
92
|
+
// next accepted change.
|
|
93
|
+
let projectedSource: object | undefined
|
|
94
|
+
let projected: ScopeSnapshot<ContextCompressionSettings> = {
|
|
95
|
+
status: 'loading', value: undefined, revision: undefined,
|
|
96
|
+
writable: false, base: undefined, user: undefined, mode: 'host',
|
|
97
|
+
}
|
|
98
|
+
const scope: SettingsScope<ContextCompressionSettings> = {
|
|
99
|
+
getSnapshot() {
|
|
100
|
+
const snap = form.getSnapshot()
|
|
101
|
+
if (snap !== projectedSource) {
|
|
102
|
+
projectedSource = snap
|
|
103
|
+
projected = {
|
|
104
|
+
status: snap.status,
|
|
105
|
+
value: decodeSettings(snap.value?.settings),
|
|
106
|
+
revision: snap.revision,
|
|
107
|
+
writable: snap.writable,
|
|
108
|
+
base: snap.base,
|
|
109
|
+
user: snap.user,
|
|
110
|
+
mode: snap.mode,
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return projected
|
|
114
|
+
},
|
|
115
|
+
subscribe: (listener) => form.subscribe(listener),
|
|
116
|
+
set: async (field, value) => {
|
|
117
|
+
const next = { ...(readDoc() ?? {}) } as Record<string, unknown>
|
|
118
|
+
next[field] = value
|
|
119
|
+
return form.set('settings', next)
|
|
120
|
+
},
|
|
121
|
+
unset: async (field) => {
|
|
122
|
+
const next = { ...(readDoc() ?? {}) } as Record<string, unknown>
|
|
123
|
+
delete next[field]
|
|
124
|
+
return form.set('settings', next)
|
|
125
|
+
},
|
|
126
|
+
mutate: async (ops) => {
|
|
127
|
+
const doc = { ...(readDoc() ?? {}) } as Record<string, unknown>
|
|
128
|
+
for (const op of ops) {
|
|
129
|
+
const [head, key] = op.path as [string, string]
|
|
130
|
+
if (head !== 'presetOptions') return false
|
|
131
|
+
const section = { ...((doc.presetOptions ?? {}) as Record<string, unknown>) }
|
|
132
|
+
if (op.op === 'unset') delete section[key]
|
|
133
|
+
else section[key] = (op as { value?: unknown }).value
|
|
134
|
+
doc.presetOptions = section
|
|
135
|
+
}
|
|
136
|
+
return form.set('settings', doc)
|
|
137
|
+
},
|
|
138
|
+
}
|
|
139
|
+
const writeAndConfirm = async (
|
|
140
|
+
write: () => Promise<unknown>,
|
|
141
|
+
accepts: (settings: ContextCompressionSettings) => boolean,
|
|
142
|
+
): Promise<void> => {
|
|
143
|
+
const beforeRevision = scope.getSnapshot().revision
|
|
144
|
+
await write()
|
|
145
|
+
const after = scope.getSnapshot()
|
|
146
|
+
if (
|
|
147
|
+
after.status !== 'ready'
|
|
148
|
+
|| after.value === undefined
|
|
149
|
+
|| after.revision === beforeRevision
|
|
150
|
+
|| !accepts(after.value)
|
|
151
|
+
) {
|
|
152
|
+
throw new Error('Context compression settings were not saved.')
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
hooks: { compression: scope },
|
|
157
|
+
select: profile => writeAndConfirm(
|
|
158
|
+
() => scope.set('profile', profile),
|
|
159
|
+
settings => settings.profile === profile,
|
|
160
|
+
),
|
|
161
|
+
saveCustom: custom => writeAndConfirm(
|
|
162
|
+
() => scope.set('custom', custom),
|
|
163
|
+
settings => isCustomCompressionPolicy(settings.custom)
|
|
164
|
+
&& sameCustomPolicy(settings.custom, custom),
|
|
165
|
+
),
|
|
166
|
+
resetCustom: () => writeAndConfirm(
|
|
167
|
+
() => scope.set('custom', structuredClone(DEFAULT_CUSTOM_COMPRESSION_POLICY)),
|
|
168
|
+
settings => isCustomCompressionPolicy(settings.custom)
|
|
169
|
+
&& sameCustomPolicy(settings.custom, DEFAULT_CUSTOM_COMPRESSION_POLICY),
|
|
170
|
+
),
|
|
171
|
+
saveAutoCompact: thresholdPercent => writeAndConfirm(
|
|
172
|
+
() => scope.set('autoCompact', { thresholdPercent }),
|
|
173
|
+
settings => settings.autoCompact.thresholdPercent === thresholdPercent,
|
|
174
|
+
),
|
|
175
|
+
saveCodeSkeleton: enabled => writeAndConfirm(
|
|
176
|
+
() => scope.set('codeSkeleton', { enabled }),
|
|
177
|
+
settings => settings.codeSkeleton.enabled === enabled,
|
|
178
|
+
),
|
|
179
|
+
savePresetOptions: options => {
|
|
180
|
+
// Path-addressed so one field write cannot delete its siblings: the
|
|
181
|
+
// previous whole-section set erased estimatorMode (and every other
|
|
182
|
+
// override) whenever the user touched a second field.
|
|
183
|
+
const ops = planPresetOptionsOps(scope.getSnapshot().value?.presetOptions, options)
|
|
184
|
+
if (ops.length === 0) return Promise.resolve()
|
|
185
|
+
return writeAndConfirm(
|
|
186
|
+
() => scope.mutate?.(ops) ?? Promise.resolve(false),
|
|
187
|
+
settings => presetOptionsOpsAccepted(settings.presetOptions, ops),
|
|
188
|
+
)
|
|
189
|
+
},
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
// 设置 → 上下文压缩 直挂分节(0.1.1 契约;0.1.5 官方分节也注册在此,未声明槽
|
|
193
|
+
// 的注册会在激活期抛错,故 try/catch 守卫 —— 同 dsh-prime-memory 的双槽冗余)。
|
|
194
|
+
// 只挂这一处:再注册 `settings.plugins.tab` / `settings.plugin.item` 会在
|
|
195
|
+
// 设置里同时出现独立分节和插件卡片,重复展示同一张面板。
|
|
196
|
+
try {
|
|
197
|
+
ctx.slots.inject('settings.section', () => ctx.slots.register({
|
|
198
|
+
name: 'settings.section',
|
|
199
|
+
id: 'context-compression',
|
|
200
|
+
order: 17,
|
|
201
|
+
label: () => tNav('nav'),
|
|
202
|
+
locale: NS,
|
|
203
|
+
inject: injected,
|
|
204
|
+
}, ContextCompressionSettingsSection))
|
|
205
|
+
} catch (error) {
|
|
206
|
+
console.warn('[dsh-context-compression-improved] settings.section 注册失败(新宿主已收编):', error)
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export type {
|
|
211
|
+
CompressionProfile, CompressionProfileSelectorProps, CompressionSelectorInjected,
|
|
212
|
+
ContextCompressionSettings,
|
|
213
|
+
} from './CompressionProfileSelector.tsx'
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 0.1.7-rc.2 stopped exporting `SettingsScope` from
|
|
3
|
-
* `@deepseek-ai/dsh-client-ui-settings/client`; the structural face the
|
|
4
|
-
* selector consumes lives here instead (getSnapshot shape mirrors the 0.1.7
|
|
5
|
-
* `ConfigFormSnapshot` minus the parts the components never read).
|
|
6
|
-
*/
|
|
7
|
-
/** The projected snapshot shape (identity-stable between changes — React #185). */
|
|
8
|
-
export interface ScopeSnapshot<T> {
|
|
9
|
-
status: 'loading' | 'ready' | 'unavailable'
|
|
10
|
-
value: T | undefined
|
|
11
|
-
revision: number | undefined
|
|
12
|
-
writable: boolean
|
|
13
|
-
base: unknown
|
|
14
|
-
user: unknown
|
|
15
|
-
mode: 'host' | 'memory'
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface SettingsScope<T> {
|
|
19
|
-
getSnapshot(): ScopeSnapshot<T>
|
|
20
|
-
subscribe(listener: () => void): () => void
|
|
21
|
-
set(field: string, value: unknown): Promise<boolean>
|
|
22
|
-
unset(field: string): Promise<boolean>
|
|
23
|
-
mutate?(ops: readonly { path: readonly string[]; op: string; value?: unknown }[]): Promise<boolean>
|
|
24
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* 0.1.7-rc.2 stopped exporting `SettingsScope` from
|
|
3
|
+
* `@deepseek-ai/dsh-client-ui-settings/client`; the structural face the
|
|
4
|
+
* selector consumes lives here instead (getSnapshot shape mirrors the 0.1.7
|
|
5
|
+
* `ConfigFormSnapshot` minus the parts the components never read).
|
|
6
|
+
*/
|
|
7
|
+
/** The projected snapshot shape (identity-stable between changes — React #185). */
|
|
8
|
+
export interface ScopeSnapshot<T> {
|
|
9
|
+
status: 'loading' | 'ready' | 'unavailable'
|
|
10
|
+
value: T | undefined
|
|
11
|
+
revision: number | undefined
|
|
12
|
+
writable: boolean
|
|
13
|
+
base: unknown
|
|
14
|
+
user: unknown
|
|
15
|
+
mode: 'host' | 'memory'
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface SettingsScope<T> {
|
|
19
|
+
getSnapshot(): ScopeSnapshot<T>
|
|
20
|
+
subscribe(listener: () => void): () => void
|
|
21
|
+
set(field: string, value: unknown): Promise<boolean>
|
|
22
|
+
unset(field: string): Promise<boolean>
|
|
23
|
+
mutate?(ops: readonly { path: readonly string[]; op: string; value?: unknown }[]): Promise<boolean>
|
|
24
|
+
}
|
|
@@ -109,7 +109,7 @@ interface ArtifactCacheEntry {
|
|
|
109
109
|
const registryCache = new Map<DeepSeekTokenizerArtifactOrigin, ArtifactCacheEntry>()
|
|
110
110
|
|
|
111
111
|
function artifactForModel(modelId: string): TokenizerArtifact | undefined {
|
|
112
|
-
return ARTIFACTS.find(artifact => (artifact.origin.modelIds
|
|
112
|
+
return ARTIFACTS.find(artifact => (artifact.origin.modelIds).includes(modelId))
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
/**
|