dsh-context-compression-improved 0.8.0-beta.7 → 0.9.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/.gitattributes +2 -2
- package/.githooks/pre-push +37 -37
- package/.github/workflows/ci.yml +39 -39
- package/CHANGELOG.de.md +41 -0
- package/CHANGELOG.es.md +41 -0
- package/CHANGELOG.fr.md +42 -0
- package/CHANGELOG.it.md +41 -0
- package/CHANGELOG.ja.md +35 -0
- package/CHANGELOG.ko.md +34 -0
- package/CHANGELOG.md +47 -0
- package/CHANGELOG.ru.md +37 -0
- package/CHANGELOG.zh.md +32 -0
- package/CONTRIBUTING.md +22 -22
- package/LICENSE +21 -21
- package/README.de.md +7 -9
- package/README.es.md +7 -9
- package/README.fr.md +7 -9
- package/README.it.md +7 -9
- package/README.ja.md +6 -2
- package/README.ko.md +6 -2
- package/README.md +96 -98
- package/README.ru.md +7 -9
- package/README.zh.md +89 -85
- package/SECURITY.md +18 -18
- package/THIRD_PARTY_NOTICES.md +14 -14
- package/docs/compat-0.1.5-report.md +77 -77
- package/docs/installation.de.md +5 -5
- package/docs/installation.es.md +5 -5
- package/docs/installation.fr.md +5 -5
- package/docs/installation.it.md +5 -5
- package/docs/installation.ja.md +5 -5
- package/docs/installation.ko.md +5 -5
- package/docs/installation.md +5 -5
- package/docs/installation.ru.md +5 -5
- package/docs/installation.zh.md +5 -5
- package/docs/repair-log.md +657 -657
- package/package.json +163 -163
- package/packages/selector/LICENSE +21 -21
- package/packages/selector/README.md +26 -26
- package/packages/selector/README.zh.md +24 -24
- package/packages/selector/THIRD_PARTY_NOTICES.md +32 -32
- package/packages/selector/cordis.patch.yml +27 -27
- package/packages/selector/docs/history-tool-call-working-set-spec.md +112 -112
- package/packages/selector/docs/native-tool-result-selector-spec.md +34 -34
- package/packages/selector/docs/subagent-cache-reuse-spec.md +46 -46
- package/packages/selector/dsh.plugin.json +16 -16
- package/packages/selector/lib/client.js +178 -21
- package/packages/selector/lib/host-generation.js +62 -0
- package/packages/selector/lib/index.js +208 -1
- package/packages/selector/lib/invariant.js +1 -1
- package/packages/selector/lib/pruner.js +41 -43
- package/packages/selector/lib/style.css +53 -53
- package/packages/selector/lib/tail-trim.js +73 -4
- package/packages/selector/package.json +80 -21
- package/packages/selector/screenshots.json +3 -3
- package/packages/selector/src/client/CustomPolicyEditor.tsx +216 -216
- package/packages/selector/src/client/EstimatorControls.tsx +277 -277
- package/packages/selector/src/client/bridge-scope.ts +125 -0
- package/packages/selector/src/client/index.ts +109 -31
- package/packages/selector/src/client/monitor-fab.ts +0 -2
- package/packages/selector/src/client/preset-options.ts +88 -88
- package/packages/selector/src/client/scope-face.ts +24 -24
- package/packages/selector/src/compat/host-generation.ts +96 -0
- package/packages/selector/src/compat/settings-lease.ts +108 -0
- package/packages/selector/src/compat/tool-result.ts +91 -0
- package/packages/selector/src/css-modules.d.ts +6 -6
- package/packages/selector/src/deepseek-v4-tokenizer.ts +205 -205
- package/packages/selector/src/estimator-catalog.ts +104 -104
- package/packages/selector/src/index.ts +8 -0
- package/packages/selector/src/invariant.ts +113 -113
- package/packages/selector/src/preset-overlay.ts +626 -626
- package/packages/selector/src/pruner/content.ts +198 -198
- package/packages/selector/src/pruner/session.ts +97 -96
- package/packages/selector/src/pruner/tuning.ts +23 -23
- package/packages/selector/src/pruner/types.ts +78 -78
- package/packages/selector/src/pruner.ts +45 -40
- package/packages/selector/src/runtime/adaptive-cost.ts +205 -205
- package/packages/selector/src/runtime/custom-policy.ts +278 -278
- package/packages/selector/src/runtime/deepseek-official-pricing.ts +298 -298
- package/packages/selector/src/runtime/deepseek-v4-vision-tokens.ts +254 -254
- package/packages/selector/src/runtime/measurement.ts +431 -431
- package/packages/selector/src/runtime/reducers.ts +1674 -1674
- package/packages/selector/src/runtime/retrieve.ts +7 -3
- package/packages/selector/src/runtime/session-events.ts +30 -30
- package/packages/selector/src/runtime/tail-trim.ts +175 -165
- package/packages/selector/src/runtime/token-count.ts +72 -72
- package/packages/selector/src/runtime/tokenpilot/advisor.ts +419 -419
- package/packages/selector/src/runtime/tokenpilot/benefit.ts +200 -200
- package/packages/selector/src/runtime/tokenpilot/dedup.ts +81 -81
- package/packages/selector/src/runtime/tokenpilot/estimator.ts +151 -151
- package/packages/selector/src/runtime/tokenpilot/locator.ts +128 -128
- package/packages/selector/src/runtime/tokenpilot/read-state.ts +98 -98
- package/packages/selector/src/runtime/tokenpilot/sidechannel.ts +303 -303
- package/packages/selector/src/runtime/toolclass.ts +103 -103
- package/packages/selector/src/runtime/value.ts +48 -48
- package/packages/selector/src/settings-bridge.ts +175 -0
- package/packages/selector/tests/advisor-report.host.spec.ts +223 -223
- package/packages/selector/tests/built/client-artifact.spec.ts +6 -9
- package/packages/selector/tests/cache-prefix-audit.spec.ts +123 -123
- package/packages/selector/tests/code-skeleton.client.spec.ts +98 -94
- package/packages/selector/tests/compat/compat-narrow-waist.spec.ts +150 -0
- package/packages/selector/tests/custom-contract.client.spec.ts +226 -223
- package/packages/selector/tests/estimator-catalog.spec.ts +70 -70
- package/packages/selector/tests/estimator-route-registration.host.spec.ts +199 -194
- package/packages/selector/tests/helpers/legacy-namespace.ts +35 -35
- package/packages/selector/tests/helpers/legacy-settings/index.ts +15 -15
- package/packages/selector/tests/helpers/legacy-settings/legacy/provider.d.ts +41 -41
- package/packages/selector/tests/helpers/legacy-settings/legacy/provider.js +647 -647
- package/packages/selector/tests/helpers/legacy-settings/legacy/redact.js +78 -78
- package/packages/selector/tests/helpers/legacy-settings/legacy/util-values.js +234 -234
- package/packages/selector/tests/host-preset-overlay.host.spec.ts +204 -204
- package/packages/selector/tests/preset-options-write.client.spec.ts +192 -188
- package/packages/selector/tests/preset-overlay-loader.e2e.host.spec.ts +200 -200
- package/packages/selector/tests/preset-overlay.host.spec.ts +246 -246
- package/packages/selector/tests/public/package-contract.client.spec.ts +11 -3
- package/packages/selector/tests/runtime/adaptive-cost.spec.ts +167 -167
- package/packages/selector/tests/runtime/advice-never-withholds.host.spec.ts +230 -230
- package/packages/selector/tests/runtime/advisor-invariant.spec.ts +272 -272
- package/packages/selector/tests/runtime/advisor.spec.ts +226 -226
- package/packages/selector/tests/runtime/auto-compact-config.spec.ts +523 -523
- package/packages/selector/tests/runtime/char-basis.spec.ts +30 -30
- package/packages/selector/tests/runtime/code-skeleton.spec.ts +152 -152
- package/packages/selector/tests/runtime/deepseek-official-pricing.spec.ts +186 -186
- package/packages/selector/tests/runtime/deepseek-v4-tokenizer.spec.ts +122 -122
- package/packages/selector/tests/runtime/deepseek-v4-vision-tokens.spec.ts +122 -122
- package/packages/selector/tests/runtime/deprecated-preset-options.spec.ts +96 -96
- package/packages/selector/tests/runtime/fixtures/profile-baseline.json +273 -273
- package/packages/selector/tests/runtime/fixtures/tokenizer-golden.json +106 -106
- package/packages/selector/tests/runtime/fixtures/vision-golden.json +459 -459
- package/packages/selector/tests/runtime/frequency-longstrings.spec.ts +74 -74
- package/packages/selector/tests/runtime/html-reducer.spec.ts +212 -212
- package/packages/selector/tests/runtime/line-mapping.spec.ts +153 -153
- package/packages/selector/tests/runtime/prose-reducers.spec.ts +133 -133
- package/packages/selector/tests/runtime/public/public-runtime.spec.ts +3 -3
- package/packages/selector/tests/runtime/read-input-cap.spec.ts +33 -33
- package/packages/selector/tests/runtime/search-reducer.spec.ts +110 -110
- package/packages/selector/tests/runtime/session-events.spec.ts +27 -27
- package/packages/selector/tests/runtime/sidechannel.spec.ts +241 -241
- package/packages/selector/tests/runtime/toc-and-bundled.spec.ts +159 -159
- package/packages/selector/tests/runtime/tokenizer-golden.spec.ts +53 -53
- package/packages/selector/tests/runtime/tokenpilot/benefit.spec.ts +217 -217
- package/packages/selector/tests/runtime/tokenpilot/dedup.spec.ts +52 -52
- package/packages/selector/tests/runtime/tokenpilot/estimator.spec.ts +79 -79
- package/packages/selector/tests/runtime/tokenpilot/locator.spec.ts +76 -76
- package/packages/selector/tests/runtime/tokenpilot/profile-baseline.spec.ts +116 -116
- package/packages/selector/tests/runtime/tokenpilot/read-state.spec.ts +82 -82
- package/packages/selector/tests/runtime/toolclass.spec.ts +156 -156
- package/packages/selector/tests/runtime/value.spec.ts +23 -23
- package/packages/selector/tests/settings-seat.client.spec.ts +45 -7
- package/packages/selector/tests/standing-generation.host.spec.ts +724 -724
- package/packages/selector/tests/subagent-cache-reuse.host.spec.ts +269 -269
- package/packages/selector/tests/support/cache-prefix-audit.ts +105 -105
- package/packages/selector/tests/support/mock-adapter.ts +37 -37
- package/packages/selector/tests/support/ui-primitives.tsx +34 -34
- package/packages/selector/tsconfig.json +11 -11
- package/packages/selector/tsdown.client.config.ts +102 -102
- package/packages/selector/tsdown.config.ts +20 -20
- package/scripts/capture-profile-baseline.mjs +42 -42
- package/scripts/generate-tokenizer-fixtures.py +81 -81
- package/scripts/generate-vision-fixtures.py +208 -208
- package/scripts/hosts.mjs +74 -0
- package/scripts/packed-components-smoke.mjs +763 -732
- package/scripts/packed-install-e2e.mjs +1330 -1273
- package/scripts/sync-hosts.mjs +174 -0
- package/scripts/toolclass-corpus-replay.mjs +281 -281
- package/scripts/verify-release.mjs +335 -318
- package/tsconfig.base.json +18 -18
- package/tsconfig.json +7 -7
- package/tsconfig.tests.json +15 -15
- package/vitest.built.config.ts +9 -9
- package/vitest.config.ts +46 -43
|
@@ -1,194 +1,199 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Host-side guard for the estimator catalog route.
|
|
3
|
-
*
|
|
4
|
-
* The defect this pins is a registration that never happens: the injection gate
|
|
5
|
-
* asked for more services than the handler needs, and an unsatisfied
|
|
6
|
-
* `ctx.inject` callback fails silently, so the plugin simply had no HTTP API
|
|
7
|
-
* and every request fell through to the host 404. These cases assert the two
|
|
8
|
-
* properties that failure violated — the route appears whenever `webServer` is
|
|
9
|
-
* usable, in either arrival order, and its absence is never silent.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import { Context } from '@deepseek-ai/cordis'
|
|
13
|
-
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
14
|
-
import { apply } from '../src/index.ts'
|
|
15
|
-
|
|
16
|
-
const CATALOG_ROUTE = '/api/dsh-context-compression-improved/estimator-catalog'
|
|
17
|
-
const LEGACY_ROUTE = '/endpoint/dsh-context-compression-improved/estimator-catalog'
|
|
18
|
-
const SAVINGS_ROUTE = '/api/dsh-context-compression-improved/savings'
|
|
19
|
-
const SAVINGS_LEGACY_ROUTE = '/endpoint/dsh-context-compression-improved/savings'
|
|
20
|
-
const MONITOR_ROUTE = '/api/dsh-context-compression-improved/monitor'
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
expect(routes
|
|
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
|
-
})
|
|
1
|
+
/**
|
|
2
|
+
* Host-side guard for the estimator catalog route.
|
|
3
|
+
*
|
|
4
|
+
* The defect this pins is a registration that never happens: the injection gate
|
|
5
|
+
* asked for more services than the handler needs, and an unsatisfied
|
|
6
|
+
* `ctx.inject` callback fails silently, so the plugin simply had no HTTP API
|
|
7
|
+
* and every request fell through to the host 404. These cases assert the two
|
|
8
|
+
* properties that failure violated — the route appears whenever `webServer` is
|
|
9
|
+
* usable, in either arrival order, and its absence is never silent.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { Context } from '@deepseek-ai/cordis'
|
|
13
|
+
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
14
|
+
import { apply } from '../src/index.ts'
|
|
15
|
+
|
|
16
|
+
const CATALOG_ROUTE = '/api/dsh-context-compression-improved/estimator-catalog'
|
|
17
|
+
const LEGACY_ROUTE = '/endpoint/dsh-context-compression-improved/estimator-catalog'
|
|
18
|
+
const SAVINGS_ROUTE = '/api/dsh-context-compression-improved/savings'
|
|
19
|
+
const SAVINGS_LEGACY_ROUTE = '/endpoint/dsh-context-compression-improved/savings'
|
|
20
|
+
const MONITOR_ROUTE = '/api/dsh-context-compression-improved/monitor'
|
|
21
|
+
|
|
22
|
+
// compat-legacy: the settings bridge rides the same always-on plane — its
|
|
23
|
+
// two routes (both prefixes) register wherever savings/monitor do.
|
|
24
|
+
const SETTINGS_LEGACY_ROUTE = '/endpoint/dsh-context-compression-improved/settings'
|
|
25
|
+
const SETTINGS_ROUTE = '/api/dsh-context-compression-improved/settings'
|
|
26
|
+
const MONITOR_LEGACY_ROUTE = '/endpoint/dsh-context-compression-improved/monitor'
|
|
27
|
+
|
|
28
|
+
interface RegisteredRoute {
|
|
29
|
+
kind: string
|
|
30
|
+
path: string
|
|
31
|
+
handler: (req: unknown, res: unknown) => void
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface FakeResponse {
|
|
35
|
+
status?: number
|
|
36
|
+
body?: string
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** The state `register` reads off its own `this`, mirroring the host service. */
|
|
40
|
+
interface WebServerStub {
|
|
41
|
+
tables: { exact: Map<string, RegisteredRoute> }
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let ctx: Context | undefined
|
|
45
|
+
|
|
46
|
+
afterEach(async () => {
|
|
47
|
+
await ctx?.fiber.dispose()
|
|
48
|
+
ctx = undefined
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
/** Settle one macrotask so a deferred activation callback can run. */
|
|
52
|
+
const settle = (): Promise<void> => new Promise(resolve => setTimeout(resolve, 20))
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Mount a host web server stand-in that records routes and reproduces the real
|
|
56
|
+
* host's duplicate-`(kind, path)` contract, so a double registration is a
|
|
57
|
+
* failure rather than a silent overwrite.
|
|
58
|
+
*/
|
|
59
|
+
async function mountWebServer(runtime: Context, routes: RegisteredRoute[]): Promise<void> {
|
|
60
|
+
await runtime.plugin({
|
|
61
|
+
name: 'fake-webserver',
|
|
62
|
+
apply(webCtx) {
|
|
63
|
+
webCtx.provide('webServer', {
|
|
64
|
+
// Mirrors dsh-host-webserver: `register` reads its route table off
|
|
65
|
+
// `this`. A caller that detaches the method and invokes it standalone
|
|
66
|
+
// makes `this` the wrapper and fails here, exactly as the host does --
|
|
67
|
+
// which is the defect this spec exists to catch.
|
|
68
|
+
tables: { exact: new Map<string, RegisteredRoute>() },
|
|
69
|
+
register(this: WebServerStub, route: RegisteredRoute) {
|
|
70
|
+
const table = this.tables.exact
|
|
71
|
+
if (table.has(route.path)) {
|
|
72
|
+
throw new Error(`webserver: duplicate ${route.kind} route "${route.path}"`)
|
|
73
|
+
}
|
|
74
|
+
table.set(route.path, route)
|
|
75
|
+
routes.push(route)
|
|
76
|
+
return () => {}
|
|
77
|
+
},
|
|
78
|
+
})
|
|
79
|
+
},
|
|
80
|
+
})
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Mount the estimator-side services the handler only enriches its payload with. */
|
|
84
|
+
async function mountEstimatorServices(runtime: Context): Promise<void> {
|
|
85
|
+
await runtime.plugin({
|
|
86
|
+
name: 'fake-estimator-services',
|
|
87
|
+
apply(estimatorCtx) {
|
|
88
|
+
estimatorCtx.provide('llm', { listProviders: () => [] })
|
|
89
|
+
estimatorCtx.provide('agentDefaultModel', { currentSelection: () => undefined })
|
|
90
|
+
},
|
|
91
|
+
})
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Drive one registered route through a stand-in response. */
|
|
95
|
+
async function invoke(route: RegisteredRoute): Promise<FakeResponse> {
|
|
96
|
+
const captured: FakeResponse = {}
|
|
97
|
+
const res = {
|
|
98
|
+
writeHead(code: number) { captured.status = code },
|
|
99
|
+
end(body?: string) { if (body !== undefined) captured.body = body },
|
|
100
|
+
}
|
|
101
|
+
route.handler({ method: 'GET' }, res)
|
|
102
|
+
await settle()
|
|
103
|
+
return captured
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
describe('estimator catalog route registration', () => {
|
|
107
|
+
it('registers both route prefixes with only webServer present', async () => {
|
|
108
|
+
const routes: RegisteredRoute[] = []
|
|
109
|
+
const runtime = new Context()
|
|
110
|
+
ctx = runtime
|
|
111
|
+
await mountWebServer(runtime, routes)
|
|
112
|
+
|
|
113
|
+
apply(runtime, { estimatorCatalogRoute: true })
|
|
114
|
+
await settle()
|
|
115
|
+
|
|
116
|
+
expect(routes.map(route => route.path)).toEqual([LEGACY_ROUTE, CATALOG_ROUTE, SAVINGS_LEGACY_ROUTE, SAVINGS_ROUTE, MONITOR_LEGACY_ROUTE, MONITOR_ROUTE, SETTINGS_LEGACY_ROUTE, SETTINGS_ROUTE])
|
|
117
|
+
expect(routes.every(route => route.kind === 'exact')).toBe(true)
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
it('registers the route when webServer activates after the plugin applied', async () => {
|
|
121
|
+
const routes: RegisteredRoute[] = []
|
|
122
|
+
const runtime = new Context()
|
|
123
|
+
ctx = runtime
|
|
124
|
+
|
|
125
|
+
apply(runtime, { estimatorCatalogRoute: true })
|
|
126
|
+
await settle()
|
|
127
|
+
expect(routes).toHaveLength(0)
|
|
128
|
+
|
|
129
|
+
await mountWebServer(runtime, routes)
|
|
130
|
+
await settle()
|
|
131
|
+
|
|
132
|
+
expect(routes.map(route => route.path)).toEqual([LEGACY_ROUTE, CATALOG_ROUTE, SAVINGS_LEGACY_ROUTE, SAVINGS_ROUTE, MONITOR_LEGACY_ROUTE, MONITOR_ROUTE, SETTINGS_LEGACY_ROUTE, SETTINGS_ROUTE])
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
it('registers nothing twice when the estimator services arrive later', async () => {
|
|
136
|
+
const routes: RegisteredRoute[] = []
|
|
137
|
+
const runtime = new Context()
|
|
138
|
+
ctx = runtime
|
|
139
|
+
await mountWebServer(runtime, routes)
|
|
140
|
+
|
|
141
|
+
apply(runtime, { estimatorCatalogRoute: true })
|
|
142
|
+
await settle()
|
|
143
|
+
const afterRegistration = routes.length
|
|
144
|
+
|
|
145
|
+
await mountEstimatorServices(runtime)
|
|
146
|
+
await settle()
|
|
147
|
+
|
|
148
|
+
expect(routes).toHaveLength(afterRegistration)
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
it('keeps the rest of the plugin alive and warns when webServer never arrives', async () => {
|
|
152
|
+
const runtime = new Context()
|
|
153
|
+
ctx = runtime
|
|
154
|
+
// The diagnostic goes to `console`: the host's cordis logger surfaces no
|
|
155
|
+
// plugin output at all, so a lifecycle line published there is invisible.
|
|
156
|
+
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})
|
|
157
|
+
|
|
158
|
+
try {
|
|
159
|
+
expect(() => apply(runtime, { estimatorCatalogRoute: true })).not.toThrow()
|
|
160
|
+
await settle()
|
|
161
|
+
|
|
162
|
+
const messages = warn.mock.calls.map(([message]) => String(message))
|
|
163
|
+
expect(messages.some(message => message.includes('estimator catalog route pending'))).toBe(true)
|
|
164
|
+
} finally {
|
|
165
|
+
warn.mockRestore()
|
|
166
|
+
}
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
it('answers 200 without the estimator services, which only enrich the payload', async () => {
|
|
170
|
+
const routes: RegisteredRoute[] = []
|
|
171
|
+
const runtime = new Context()
|
|
172
|
+
ctx = runtime
|
|
173
|
+
await mountWebServer(runtime, routes)
|
|
174
|
+
|
|
175
|
+
apply(runtime, { estimatorCatalogRoute: true })
|
|
176
|
+
await settle()
|
|
177
|
+
|
|
178
|
+
const route = routes.find(candidate => candidate.path === CATALOG_ROUTE)
|
|
179
|
+
expect(route).toBeDefined()
|
|
180
|
+
const response = await invoke(route as RegisteredRoute)
|
|
181
|
+
|
|
182
|
+
expect(response.status).toBe(200)
|
|
183
|
+
expect(JSON.parse(String(response.body))).toMatchObject({ ok: true, providers: [] })
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
it('without the estimator opt-in only the always-on read routes register (savings + monitor)', async () => {
|
|
187
|
+
// savings 与 monitor 路由是有意常开的只读面(纯 token 聚合与折叠状态,无会话内容);estimator
|
|
188
|
+
// catalog 才是 opt-in 行。默认面 = 恰好两条 savings 前缀 + 两条 monitor 前缀。
|
|
189
|
+
const routes: RegisteredRoute[] = []
|
|
190
|
+
const runtime = new Context()
|
|
191
|
+
ctx = runtime
|
|
192
|
+
await mountWebServer(runtime, routes)
|
|
193
|
+
|
|
194
|
+
apply(runtime, { presetOverlay: false })
|
|
195
|
+
await settle()
|
|
196
|
+
|
|
197
|
+
expect(routes.map(route => route.path)).toEqual([SAVINGS_LEGACY_ROUTE, SAVINGS_ROUTE, MONITOR_LEGACY_ROUTE, MONITOR_ROUTE, SETTINGS_LEGACY_ROUTE, SETTINGS_ROUTE])
|
|
198
|
+
})
|
|
199
|
+
})
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Test-host helper: registers the legacy `context-compression` settings
|
|
3
|
-
* namespace on a 0.1.5-shaped test settings service, so specs can drive the
|
|
4
|
-
* plugin through `settings.update(...)` exactly as they did before the 0.1.7
|
|
5
|
-
* declarative migration. Production code reads the volatile entry field first
|
|
6
|
-
* and falls back to this namespace; on a real 0.1.7 host neither the
|
|
7
|
-
* registration nor this helper exists.
|
|
8
|
-
*/
|
|
9
|
-
import type { Context } from '@deepseek-ai/cordis'
|
|
10
|
-
import {
|
|
11
|
-
CONTEXT_COMPRESSION_SETTINGS_NAMESPACE,
|
|
12
|
-
ContextCompressionSettingsSchema,
|
|
13
|
-
} from '../../src/runtime/config.ts'
|
|
14
|
-
|
|
15
|
-
export const LegacyNamespaceRegistrar = {
|
|
16
|
-
name: 'context-compression:test/legacy-namespace-registrar',
|
|
17
|
-
async apply(ctx: Context): Promise<void> {
|
|
18
|
-
await new Promise<void>((resolve) => {
|
|
19
|
-
ctx.inject(['settings'], (s) => {
|
|
20
|
-
try {
|
|
21
|
-
// The test host mounts a vendored 0.1.5-shaped provider whose
|
|
22
|
-
// static type is the 0.1.7 Context augmentation (`SettingsForms`);
|
|
23
|
-
// narrow to the legacy registry surface at the seam.
|
|
24
|
-
;(s.settings as unknown as {
|
|
25
|
-
register(ns: never, schema: unknown): unknown
|
|
26
|
-
}).register(
|
|
27
|
-
CONTEXT_COMPRESSION_SETTINGS_NAMESPACE as never,
|
|
28
|
-
ContextCompressionSettingsSchema,
|
|
29
|
-
)
|
|
30
|
-
} catch { /* already registered by an earlier row */ }
|
|
31
|
-
resolve()
|
|
32
|
-
})
|
|
33
|
-
})
|
|
34
|
-
},
|
|
35
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Test-host helper: registers the legacy `context-compression` settings
|
|
3
|
+
* namespace on a 0.1.5-shaped test settings service, so specs can drive the
|
|
4
|
+
* plugin through `settings.update(...)` exactly as they did before the 0.1.7
|
|
5
|
+
* declarative migration. Production code reads the volatile entry field first
|
|
6
|
+
* and falls back to this namespace; on a real 0.1.7 host neither the
|
|
7
|
+
* registration nor this helper exists.
|
|
8
|
+
*/
|
|
9
|
+
import type { Context } from '@deepseek-ai/cordis'
|
|
10
|
+
import {
|
|
11
|
+
CONTEXT_COMPRESSION_SETTINGS_NAMESPACE,
|
|
12
|
+
ContextCompressionSettingsSchema,
|
|
13
|
+
} from '../../src/runtime/config.ts'
|
|
14
|
+
|
|
15
|
+
export const LegacyNamespaceRegistrar = {
|
|
16
|
+
name: 'context-compression:test/legacy-namespace-registrar',
|
|
17
|
+
async apply(ctx: Context): Promise<void> {
|
|
18
|
+
await new Promise<void>((resolve) => {
|
|
19
|
+
ctx.inject(['settings'], (s) => {
|
|
20
|
+
try {
|
|
21
|
+
// The test host mounts a vendored 0.1.5-shaped provider whose
|
|
22
|
+
// static type is the 0.1.7 Context augmentation (`SettingsForms`);
|
|
23
|
+
// narrow to the legacy registry surface at the seam.
|
|
24
|
+
;(s.settings as unknown as {
|
|
25
|
+
register(ns: never, schema: unknown): unknown
|
|
26
|
+
}).register(
|
|
27
|
+
CONTEXT_COMPRESSION_SETTINGS_NAMESPACE as never,
|
|
28
|
+
ContextCompressionSettingsSchema,
|
|
29
|
+
)
|
|
30
|
+
} catch { /* already registered by an earlier row */ }
|
|
31
|
+
resolve()
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
},
|
|
35
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Legacy test-host settings seam.
|
|
3
|
-
*
|
|
4
|
-
* Vendored verbatim from `@deepseek-ai/dsh-settings@0.1.5-rc.2`
|
|
5
|
-
* (`lib/types/index.js` + `lib/types/redact.js`, with the
|
|
6
|
-
* `@deepseek-ai/dsh-util-values@0.1.5-rc.2` helpers inlined as
|
|
7
|
-
* `./legacy/util-values.js`): the 0.1.7 host replaced the
|
|
8
|
-
* namespace-registry provider with declarative `SettingsForms`, while the
|
|
9
|
-
* plugin keeps the legacy `ctx.settings.get(ns)` read as a host-shape
|
|
10
|
-
* fallback (see src/index.ts). The host specs mount a provider subclassing
|
|
11
|
-
* this base to exercise exactly that fallback against the real 0.1.7
|
|
12
|
-
* baseline. Type declarations: `./legacy/provider.d.ts`.
|
|
13
|
-
*/
|
|
14
|
-
export { SettingsProvider as LegacySettingsProvider } from './legacy/provider.js'
|
|
15
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Legacy test-host settings seam.
|
|
3
|
+
*
|
|
4
|
+
* Vendored verbatim from `@deepseek-ai/dsh-settings@0.1.5-rc.2`
|
|
5
|
+
* (`lib/types/index.js` + `lib/types/redact.js`, with the
|
|
6
|
+
* `@deepseek-ai/dsh-util-values@0.1.5-rc.2` helpers inlined as
|
|
7
|
+
* `./legacy/util-values.js`): the 0.1.7 host replaced the
|
|
8
|
+
* namespace-registry provider with declarative `SettingsForms`, while the
|
|
9
|
+
* plugin keeps the legacy `ctx.settings.get(ns)` read as a host-shape
|
|
10
|
+
* fallback (see src/index.ts). The host specs mount a provider subclassing
|
|
11
|
+
* this base to exercise exactly that fallback against the real 0.1.7
|
|
12
|
+
* baseline. Type declarations: `./legacy/provider.d.ts`.
|
|
13
|
+
*/
|
|
14
|
+
export { SettingsProvider as LegacySettingsProvider } from './legacy/provider.js'
|
|
15
|
+
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Narrow type surface for the vendored 0.1.5 `SettingsProvider` (legacy test-host seam).
|
|
3
|
-
*
|
|
4
|
-
* The 0.1.7 `@deepseek-ai/dsh-settings` host replaced the namespace-registry
|
|
5
|
-
* provider with the declarative `SettingsForms` projector, but the plugin
|
|
6
|
-
* deliberately keeps the legacy `ctx.settings.get(ns)` read as a fallback
|
|
7
|
-
* "so a host that still serves the old service shape keeps working (test
|
|
8
|
-
* hosts do exactly that)" (src/index.ts). The host specs drive that fallback
|
|
9
|
-
* through this vendored base class — the verbatim 0.1.5-rc.2 implementation,
|
|
10
|
-
* not a behavioral re-implementation.
|
|
11
|
-
*
|
|
12
|
-
* Only the members the specs and the production fallback actually touch are
|
|
13
|
-
* declared; the full 0.1.5 surface exists at runtime in provider.js.
|
|
14
|
-
*/
|
|
15
|
-
import { Service } from '@deepseek-ai/cordis'
|
|
16
|
-
|
|
17
|
-
export declare abstract class SettingsProvider extends Service {
|
|
18
|
-
/** Register as the `settings` service of `ctx` (implementation: `super(ctx, 'settings')`). */
|
|
19
|
-
constructor(ctx: Context)
|
|
20
|
-
/** Whether {@linkcode LegacySettingsProvider.update} may persist through this provider. */
|
|
21
|
-
abstract readonly writable: boolean
|
|
22
|
-
/** Load the provider's raw document (namespace → raw section) once at init. */
|
|
23
|
-
protected abstract load(): Promise<Record<string, unknown>>
|
|
24
|
-
/** Durably store one namespace's merged user section. */
|
|
25
|
-
protected abstract persist(ns: string, section: Record<string, unknown>): Promise<void>
|
|
26
|
-
/** Register a namespace schema; duplicate registration fails loud. */
|
|
27
|
-
register(ns: string, schema: unknown, options?: unknown): unknown
|
|
28
|
-
/** Read one registered namespace's resolved value (undefined while unregistered). */
|
|
29
|
-
get(ns: string): unknown
|
|
30
|
-
/** Merge a patch into one registered namespace's user layer, validate, persist. */
|
|
31
|
-
update(ns: string, patch: object, expectedRevision?: number): Promise<void>
|
|
32
|
-
/** Replace one registered namespace's user section wholesale, validate, persist. */
|
|
33
|
-
replace(ns: string, section: object, expectedRevision?: number): Promise<void>
|
|
34
|
-
/** Apply path-addressed edits to one registered namespace's user section. */
|
|
35
|
-
mutate(ns: string, ops: readonly unknown[], expectedRevision?: number): Promise<void>
|
|
36
|
-
/** Describe every registered namespace for configuration surfaces. */
|
|
37
|
-
describe(options?: { redactSecrets?: boolean }): unknown[]
|
|
38
|
-
/** Non-file providers expose no open-document affordance. */
|
|
39
|
-
get documentPath(): string | undefined
|
|
40
|
-
prepareDocument(): Promise<string | undefined>
|
|
41
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Narrow type surface for the vendored 0.1.5 `SettingsProvider` (legacy test-host seam).
|
|
3
|
+
*
|
|
4
|
+
* The 0.1.7 `@deepseek-ai/dsh-settings` host replaced the namespace-registry
|
|
5
|
+
* provider with the declarative `SettingsForms` projector, but the plugin
|
|
6
|
+
* deliberately keeps the legacy `ctx.settings.get(ns)` read as a fallback
|
|
7
|
+
* "so a host that still serves the old service shape keeps working (test
|
|
8
|
+
* hosts do exactly that)" (src/index.ts). The host specs drive that fallback
|
|
9
|
+
* through this vendored base class — the verbatim 0.1.5-rc.2 implementation,
|
|
10
|
+
* not a behavioral re-implementation.
|
|
11
|
+
*
|
|
12
|
+
* Only the members the specs and the production fallback actually touch are
|
|
13
|
+
* declared; the full 0.1.5 surface exists at runtime in provider.js.
|
|
14
|
+
*/
|
|
15
|
+
import { Service } from '@deepseek-ai/cordis'
|
|
16
|
+
|
|
17
|
+
export declare abstract class SettingsProvider extends Service {
|
|
18
|
+
/** Register as the `settings` service of `ctx` (implementation: `super(ctx, 'settings')`). */
|
|
19
|
+
constructor(ctx: Context)
|
|
20
|
+
/** Whether {@linkcode LegacySettingsProvider.update} may persist through this provider. */
|
|
21
|
+
abstract readonly writable: boolean
|
|
22
|
+
/** Load the provider's raw document (namespace → raw section) once at init. */
|
|
23
|
+
protected abstract load(): Promise<Record<string, unknown>>
|
|
24
|
+
/** Durably store one namespace's merged user section. */
|
|
25
|
+
protected abstract persist(ns: string, section: Record<string, unknown>): Promise<void>
|
|
26
|
+
/** Register a namespace schema; duplicate registration fails loud. */
|
|
27
|
+
register(ns: string, schema: unknown, options?: unknown): unknown
|
|
28
|
+
/** Read one registered namespace's resolved value (undefined while unregistered). */
|
|
29
|
+
get(ns: string): unknown
|
|
30
|
+
/** Merge a patch into one registered namespace's user layer, validate, persist. */
|
|
31
|
+
update(ns: string, patch: object, expectedRevision?: number): Promise<void>
|
|
32
|
+
/** Replace one registered namespace's user section wholesale, validate, persist. */
|
|
33
|
+
replace(ns: string, section: object, expectedRevision?: number): Promise<void>
|
|
34
|
+
/** Apply path-addressed edits to one registered namespace's user section. */
|
|
35
|
+
mutate(ns: string, ops: readonly unknown[], expectedRevision?: number): Promise<void>
|
|
36
|
+
/** Describe every registered namespace for configuration surfaces. */
|
|
37
|
+
describe(options?: { redactSecrets?: boolean }): unknown[]
|
|
38
|
+
/** Non-file providers expose no open-document affordance. */
|
|
39
|
+
get documentPath(): string | undefined
|
|
40
|
+
prepareDocument(): Promise<string | undefined>
|
|
41
|
+
}
|