dsh-context-compression-improved 0.2.3 → 0.2.5
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 -1
- package/.githooks/pre-push +37 -0
- package/.github/workflows/ci.yml +39 -39
- package/CHANGELOG.ja.md +169 -39
- package/CHANGELOG.ko.md +167 -39
- package/CHANGELOG.md +333 -135
- package/CHANGELOG.zh.md +152 -39
- package/CONTRIBUTING.md +22 -22
- package/README.ja.md +85 -104
- package/README.ko.md +85 -103
- package/README.md +94 -112
- package/README.zh.md +85 -101
- package/THIRD_PARTY_NOTICES.md +14 -14
- package/docs/compat-0.1.5-report.md +77 -0
- package/docs/installation.ja.md +78 -76
- package/docs/installation.ko.md +78 -76
- package/docs/installation.md +103 -76
- package/docs/installation.zh.md +100 -76
- package/docs/repair-log.md +657 -582
- package/eslint.config.js +30 -30
- package/package.json +163 -142
- package/packages/selector/README.md +26 -31
- package/packages/selector/README.zh.md +24 -31
- package/packages/selector/THIRD_PARTY_NOTICES.md +32 -38
- package/packages/selector/cordis.patch.yml +27 -19
- package/packages/selector/dsh.plugin.json +2 -2
- package/packages/selector/lib/client.d.ts +320 -228
- package/packages/selector/lib/client.js +3254 -1462
- package/packages/selector/lib/config.js +1713 -842
- package/packages/selector/lib/index.d.ts +46 -38
- package/packages/selector/lib/index.js +1099 -645
- package/packages/selector/lib/invariant.js +70 -70
- package/packages/selector/lib/pruner.d.ts +904 -684
- package/packages/selector/lib/pruner.js +5800 -3807
- package/packages/selector/lib/style.css +88 -46
- package/packages/selector/lib/tail-trim.js +145 -136
- package/packages/selector/package.json +18 -19
- package/packages/selector/screenshots.json +3 -6
- package/packages/selector/src/client/CompressionProfileControls.tsx +293 -229
- package/packages/selector/src/client/CompressionProfileSelector.module.css +199 -170
- package/packages/selector/src/client/CompressionProfileSelector.tsx +85 -79
- package/packages/selector/src/client/EstimatorControls.tsx +277 -281
- package/packages/selector/src/client/decode.ts +57 -49
- package/packages/selector/src/client/index.ts +249 -111
- package/packages/selector/src/client/locales/de.ts +141 -0
- package/packages/selector/src/client/locales/es.ts +141 -0
- package/packages/selector/src/client/locales/fr.ts +141 -0
- package/packages/selector/src/client/locales/it.ts +141 -0
- package/packages/selector/src/client/locales/ja.ts +141 -0
- package/packages/selector/src/client/locales/ko.ts +141 -0
- package/packages/selector/src/client/locales/ru.ts +141 -0
- package/packages/selector/src/client/locales.ts +282 -198
- package/packages/selector/src/client/monitor-fab.ts +336 -0
- package/packages/selector/src/client/preset-options.ts +88 -70
- package/packages/selector/src/client/savings-card.tsx +150 -0
- package/packages/selector/src/client/settings-section.tsx +140 -126
- package/packages/selector/src/deepseek-v4-tokenizer.ts +205 -210
- package/packages/selector/src/index.ts +671 -327
- package/packages/selector/src/invariant.ts +113 -113
- package/packages/selector/src/preset-overlay.ts +60 -1
- package/packages/selector/src/profiles.ts +431 -342
- package/packages/selector/src/pruner/content.ts +18 -5
- package/packages/selector/src/pruner/state.ts +57 -43
- package/packages/selector/src/pruner/types.ts +23 -5
- package/packages/selector/src/pruner.ts +2736 -2144
- package/packages/selector/src/runtime/adaptive-cost.ts +23 -12
- package/packages/selector/src/runtime/audit.ts +303 -215
- package/packages/selector/src/runtime/config.ts +756 -613
- package/packages/selector/src/runtime/measurement.ts +436 -403
- package/packages/selector/src/runtime/monitor.ts +235 -0
- package/packages/selector/src/runtime/reducers.ts +1115 -97
- package/packages/selector/src/runtime/retrieve.ts +479 -457
- package/packages/selector/src/runtime/savings.ts +337 -0
- package/packages/selector/src/runtime/session-events.ts +30 -17
- package/packages/selector/src/runtime/summary-command.ts +127 -0
- package/packages/selector/src/runtime/tail-trim.ts +166 -166
- package/packages/selector/src/runtime/tokenpilot/advisor-prompt.ts +233 -0
- package/packages/selector/src/runtime/tokenpilot/advisor-state.ts +204 -0
- package/packages/selector/src/runtime/tokenpilot/advisor.ts +419 -0
- package/packages/selector/src/runtime/tokenpilot/benefit.ts +200 -0
- package/packages/selector/src/runtime/tokenpilot/dedup.ts +1 -1
- package/packages/selector/src/runtime/tokenpilot/estimator.ts +151 -183
- 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 +1 -1
- package/packages/selector/src/runtime/tokenpilot/read-state.ts +23 -2
- package/packages/selector/src/runtime/tokenpilot/sidechannel.ts +303 -0
- package/packages/selector/src/runtime/toolclass.ts +103 -0
- package/packages/selector/src/runtime/types.ts +365 -309
- package/packages/selector/tests/advisor-report.host.spec.ts +223 -0
- package/packages/selector/tests/auto-compact.client.spec.tsx +214 -226
- package/packages/selector/tests/built/client-artifact.spec.ts +59 -51
- package/packages/selector/tests/code-skeleton.client.spec.ts +91 -88
- package/packages/selector/tests/custom-contract.client.spec.ts +205 -202
- package/packages/selector/tests/estimator-channel.client.spec.tsx +253 -247
- package/packages/selector/tests/estimator-route-registration.host.spec.ts +194 -176
- package/packages/selector/tests/host-preset-overlay.host.spec.ts +206 -204
- package/packages/selector/tests/monitor-fab.client.spec.ts +138 -0
- package/packages/selector/tests/preset-options-write.client.spec.ts +207 -181
- package/packages/selector/tests/preset-overlay-loader.e2e.host.spec.ts +201 -196
- package/packages/selector/tests/preset-overlay.host.spec.ts +246 -243
- package/packages/selector/tests/profiles.client.spec.tsx +436 -434
- package/packages/selector/tests/public/package-contract.client.spec.ts +78 -33
- package/packages/selector/tests/runtime/adaptive-cost.spec.ts +7 -7
- package/packages/selector/tests/runtime/advice-never-withholds.host.spec.ts +232 -0
- package/packages/selector/tests/runtime/advisor-invariant.spec.ts +272 -0
- package/packages/selector/tests/runtime/advisor.spec.ts +226 -0
- package/packages/selector/tests/runtime/audit.spec.ts +275 -129
- package/packages/selector/tests/runtime/char-basis.spec.ts +30 -0
- package/packages/selector/tests/runtime/code-skeleton.spec.ts +14 -3
- package/packages/selector/tests/runtime/deprecated-preset-options.spec.ts +96 -0
- package/packages/selector/tests/runtime/frequency-longstrings.spec.ts +74 -0
- package/packages/selector/tests/runtime/html-reducer.spec.ts +212 -0
- 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/line-mapping.spec.ts +153 -0
- package/packages/selector/tests/runtime/monitor.spec.ts +301 -0
- package/packages/selector/tests/runtime/prose-reducers.spec.ts +133 -0
- package/packages/selector/tests/runtime/public/public-runtime.spec.ts +2724 -2531
- package/packages/selector/tests/runtime/read-input-cap.spec.ts +33 -0
- package/packages/selector/tests/runtime/savings.spec.ts +120 -0
- package/packages/selector/tests/runtime/search-reducer.spec.ts +110 -0
- package/packages/selector/tests/runtime/session-events.spec.ts +27 -27
- package/packages/selector/tests/runtime/sidechannel.spec.ts +241 -0
- package/packages/selector/tests/runtime/summary-command.spec.ts +154 -0
- package/packages/selector/tests/runtime/toc-and-bundled.spec.ts +159 -0
- package/packages/selector/tests/runtime/tokenpilot/benefit.spec.ts +217 -0
- package/packages/selector/tests/runtime/tokenpilot/estimator.spec.ts +79 -56
- package/packages/selector/tests/runtime/tokenpilot/profile-baseline.spec.ts +116 -100
- package/packages/selector/tests/runtime/tokenpilot/read-state.spec.ts +24 -0
- package/packages/selector/tests/runtime/toolclass.spec.ts +156 -0
- package/packages/selector/tests/settings-seat.client.spec.ts +130 -0
- package/packages/selector/tests/standing-generation.host.spec.ts +697 -631
- package/packages/selector/tests/subagent-cache-reuse.host.spec.ts +253 -250
- package/pnpm-workspace.yaml +66 -19
- package/scripts/capture-profile-baseline.mjs +42 -0
- package/scripts/generate-tokenizer-fixtures.py +81 -81
- package/scripts/generate-vision-fixtures.py +208 -208
- package/scripts/{packed-components-smoke.ts → packed-components-smoke.mjs} +732 -713
- package/scripts/{packed-install-e2e.ts → packed-install-e2e.mjs} +1273 -1072
- package/scripts/toolclass-corpus-replay.mjs +281 -0
- package/scripts/{verify-release.ts → verify-release.mjs} +318 -300
- package/tests/TEST_INVENTORY.md +41 -42
- package/scripts/capture-profile-baseline.ts +0 -80
- package/tsconfig.scripts.json +0 -13
- /package/{packages/selector/assets/screenshots → docs/assets}/context-compression-selector-profiles.jpg +0 -0
- /package/{packages/selector/assets/screenshots → docs/assets}/context-compression-selector-settings.png +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
.
|
|
1
|
+
.xdHrtq_settingsSection {
|
|
2
2
|
max-width: 720px;
|
|
3
3
|
color: var(--dsw-alias-label-primary);
|
|
4
4
|
flex-direction: column;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
display: flex;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
.
|
|
9
|
+
.xdHrtq_settingsTitle {
|
|
10
10
|
color: var(--dsw-alias-label-primary);
|
|
11
11
|
margin: 0;
|
|
12
12
|
font-size: 16px;
|
|
@@ -14,24 +14,24 @@
|
|
|
14
14
|
line-height: 24px;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
.
|
|
17
|
+
.xdHrtq_settingsDescription {
|
|
18
18
|
color: var(--dsw-alias-label-tertiary);
|
|
19
19
|
margin: 0;
|
|
20
20
|
font-size: 14px;
|
|
21
21
|
line-height: 22px;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
.
|
|
24
|
+
.xdHrtq_root {
|
|
25
25
|
width: 100%;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
.
|
|
28
|
+
.xdHrtq_profileGrid {
|
|
29
29
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
30
30
|
gap: 10px;
|
|
31
31
|
display: grid;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
.
|
|
34
|
+
.xdHrtq_profileCard {
|
|
35
35
|
border: 1px solid var(--dsw-alias-border-l2);
|
|
36
36
|
min-height: 112px;
|
|
37
37
|
color: var(--dsw-alias-label-primary);
|
|
@@ -45,41 +45,41 @@
|
|
|
45
45
|
display: flex;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
.
|
|
48
|
+
.xdHrtq_profileCard:hover:not(:disabled) {
|
|
49
49
|
background: var(--dsw-alias-interactive-bg-hover);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
.
|
|
52
|
+
.xdHrtq_profileCard[aria-pressed="true"] {
|
|
53
53
|
border-color: var(--dsw-alias-label-primary);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
.
|
|
56
|
+
.xdHrtq_profileCard:active:not(:disabled) {
|
|
57
57
|
transform: scale(.99);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
.
|
|
60
|
+
.xdHrtq_profileCard:disabled {
|
|
61
61
|
cursor: default;
|
|
62
62
|
opacity: .6;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
.
|
|
65
|
+
.xdHrtq_profileCard:focus-visible {
|
|
66
66
|
outline-offset: 2px;
|
|
67
67
|
outline: 2px solid;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
.
|
|
70
|
+
.xdHrtq_profileCardTop {
|
|
71
71
|
align-items: center;
|
|
72
72
|
gap: 8px;
|
|
73
73
|
display: flex;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
.
|
|
76
|
+
.xdHrtq_profileCardTitle {
|
|
77
77
|
font-size: 14px;
|
|
78
78
|
font-weight: 500;
|
|
79
79
|
line-height: 20px;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
.
|
|
82
|
+
.xdHrtq_profileCurrent {
|
|
83
83
|
background: var(--dsw-alias-label-primary);
|
|
84
84
|
color: var(--dsw-alias-bg-base);
|
|
85
85
|
border-radius: 999px;
|
|
@@ -88,13 +88,13 @@
|
|
|
88
88
|
line-height: 14px;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
.
|
|
91
|
+
.xdHrtq_profileCardDetail {
|
|
92
92
|
color: var(--dsw-alias-label-secondary);
|
|
93
93
|
font-size: 12px;
|
|
94
94
|
line-height: 18px;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
.
|
|
97
|
+
.xdHrtq_button {
|
|
98
98
|
border: 1px solid var(--dsw-alias-border-l2);
|
|
99
99
|
width: 100%;
|
|
100
100
|
min-height: 34px;
|
|
@@ -109,27 +109,27 @@
|
|
|
109
109
|
display: flex;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
.
|
|
112
|
+
.xdHrtq_button:hover {
|
|
113
113
|
background: var(--dsw-alias-interactive-bg-hover);
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
.
|
|
116
|
+
.xdHrtq_button:disabled {
|
|
117
117
|
cursor: default;
|
|
118
118
|
opacity: .6;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
.
|
|
121
|
+
.xdHrtq_copy {
|
|
122
122
|
flex: 1;
|
|
123
123
|
min-width: 0;
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
.
|
|
126
|
+
.xdHrtq_label {
|
|
127
127
|
color: var(--dsw-alias-label-tertiary);
|
|
128
128
|
font-size: 11px;
|
|
129
129
|
line-height: 14px;
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
.
|
|
132
|
+
.xdHrtq_value {
|
|
133
133
|
text-overflow: ellipsis;
|
|
134
134
|
white-space: nowrap;
|
|
135
135
|
font-size: 13px;
|
|
@@ -137,24 +137,24 @@
|
|
|
137
137
|
overflow: hidden;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
.
|
|
140
|
+
.xdHrtq_chevron {
|
|
141
141
|
color: var(--dsw-alias-label-secondary);
|
|
142
142
|
flex: none;
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
.
|
|
145
|
+
.xdHrtq_menuCopy {
|
|
146
146
|
flex-direction: column;
|
|
147
147
|
gap: 2px;
|
|
148
148
|
min-width: 220px;
|
|
149
149
|
display: flex;
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
.
|
|
152
|
+
.xdHrtq_menuTitle {
|
|
153
153
|
font-size: 13px;
|
|
154
154
|
line-height: 17px;
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
.
|
|
157
|
+
.xdHrtq_menuDetail {
|
|
158
158
|
white-space: normal;
|
|
159
159
|
max-width: 290px;
|
|
160
160
|
color: var(--dsw-alias-label-tertiary);
|
|
@@ -162,61 +162,61 @@
|
|
|
162
162
|
line-height: 15px;
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
.
|
|
165
|
+
.xdHrtq_error {
|
|
166
166
|
color: var(--dsw-alias-state-error-primary);
|
|
167
167
|
padding: 4px 8px 0;
|
|
168
168
|
font-size: 11px;
|
|
169
169
|
line-height: 15px;
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
.
|
|
172
|
+
.xdHrtq_unavailable {
|
|
173
173
|
color: var(--dsw-alias-label-tertiary);
|
|
174
174
|
padding: 4px 8px 0;
|
|
175
175
|
font-size: 11px;
|
|
176
176
|
line-height: 15px;
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
-
.
|
|
179
|
+
.xdHrtq_settingsHint {
|
|
180
180
|
color: var(--dsw-alias-label-secondary);
|
|
181
181
|
padding: 4px 8px 0;
|
|
182
182
|
font-size: 11px;
|
|
183
183
|
line-height: 15px;
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
.
|
|
186
|
+
.xdHrtq_pricing {
|
|
187
187
|
color: var(--dsw-alias-label-tertiary);
|
|
188
188
|
padding: 4px 8px 0;
|
|
189
189
|
font-size: 11px;
|
|
190
190
|
line-height: 15px;
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
-
.
|
|
193
|
+
.xdHrtq_custom {
|
|
194
194
|
border-top: 1px solid var(--dsw-alias-border-l2);
|
|
195
195
|
margin-top: 16px;
|
|
196
196
|
padding: 16px 0 0;
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
-
.
|
|
199
|
+
.xdHrtq_customTitle {
|
|
200
200
|
margin: 0 0 6px;
|
|
201
201
|
font-size: 13px;
|
|
202
202
|
line-height: 17px;
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
-
.
|
|
205
|
+
.xdHrtq_customNote {
|
|
206
206
|
color: var(--dsw-alias-label-tertiary);
|
|
207
207
|
margin: 4px 0;
|
|
208
208
|
font-size: 11px;
|
|
209
209
|
line-height: 15px;
|
|
210
210
|
}
|
|
211
211
|
|
|
212
|
-
.
|
|
212
|
+
.xdHrtq_stage {
|
|
213
213
|
border: 0;
|
|
214
214
|
border-top: 1px solid var(--dsw-alias-border-l2);
|
|
215
215
|
margin: 12px 0 0;
|
|
216
216
|
padding: 12px 0 0;
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
-
.
|
|
219
|
+
.xdHrtq_stageToggle {
|
|
220
220
|
align-items: center;
|
|
221
221
|
gap: 6px;
|
|
222
222
|
font-size: 12px;
|
|
@@ -224,13 +224,13 @@
|
|
|
224
224
|
display: inline-flex;
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
-
.
|
|
227
|
+
.xdHrtq_fieldGrid {
|
|
228
228
|
grid-template-columns: 1fr;
|
|
229
229
|
gap: 8px;
|
|
230
230
|
display: grid;
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
-
.
|
|
233
|
+
.xdHrtq_field {
|
|
234
234
|
min-width: 0;
|
|
235
235
|
color: var(--dsw-alias-label-secondary);
|
|
236
236
|
flex-direction: column;
|
|
@@ -241,7 +241,7 @@
|
|
|
241
241
|
display: flex;
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
-
.
|
|
244
|
+
.xdHrtq_field input, .xdHrtq_field select {
|
|
245
245
|
box-sizing: border-box;
|
|
246
246
|
border: 1px solid var(--dsw-alias-border-l2);
|
|
247
247
|
background: var(--dsw-alias-bg-base);
|
|
@@ -253,19 +253,19 @@
|
|
|
253
253
|
padding: 4px 6px;
|
|
254
254
|
}
|
|
255
255
|
|
|
256
|
-
.
|
|
256
|
+
.xdHrtq_field input:focus-visible, .xdHrtq_field select:focus-visible, .xdHrtq_actions button:focus-visible {
|
|
257
257
|
outline-offset: 2px;
|
|
258
258
|
outline: 2px solid;
|
|
259
259
|
}
|
|
260
260
|
|
|
261
|
-
.
|
|
261
|
+
.xdHrtq_actions {
|
|
262
262
|
flex-wrap: wrap;
|
|
263
263
|
gap: 8px;
|
|
264
264
|
margin-top: 10px;
|
|
265
265
|
display: flex;
|
|
266
266
|
}
|
|
267
267
|
|
|
268
|
-
.
|
|
268
|
+
.xdHrtq_actions button {
|
|
269
269
|
border: 1px solid var(--dsw-alias-border-l2);
|
|
270
270
|
min-height: 30px;
|
|
271
271
|
color: var(--dsw-alias-label-primary);
|
|
@@ -274,35 +274,77 @@
|
|
|
274
274
|
padding: 4px 8px;
|
|
275
275
|
}
|
|
276
276
|
|
|
277
|
-
.
|
|
277
|
+
.xdHrtq_actions button:active:not(:disabled) {
|
|
278
278
|
transform: scale(.98);
|
|
279
279
|
}
|
|
280
280
|
|
|
281
|
-
.
|
|
281
|
+
.xdHrtq_actions button:disabled {
|
|
282
282
|
opacity: .6;
|
|
283
283
|
}
|
|
284
284
|
|
|
285
285
|
@media (width <= 560px) {
|
|
286
|
-
.
|
|
286
|
+
.xdHrtq_profileGrid {
|
|
287
287
|
grid-template-columns: 1fr;
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
290
|
|
|
291
|
-
.
|
|
291
|
+
.xdHrtq_autoCompact {
|
|
292
292
|
border: 1px solid #80808059;
|
|
293
293
|
border-radius: 8px;
|
|
294
294
|
margin-top: 24px;
|
|
295
295
|
padding: 16px;
|
|
296
296
|
}
|
|
297
297
|
|
|
298
|
-
.
|
|
298
|
+
.xdHrtq_autoCompactTitle {
|
|
299
299
|
margin: 0 0 8px;
|
|
300
300
|
font-size: 15px;
|
|
301
301
|
font-weight: 600;
|
|
302
302
|
}
|
|
303
303
|
|
|
304
|
-
.
|
|
304
|
+
.xdHrtq_autoCompactRisk {
|
|
305
305
|
opacity: .9;
|
|
306
306
|
margin: 8px 0 0;
|
|
307
307
|
font-size: 12px;
|
|
308
308
|
}
|
|
309
|
+
|
|
310
|
+
.xdHrtq_savingsCard {
|
|
311
|
+
border: 1px solid #ffffff1a;
|
|
312
|
+
border-radius: 8px;
|
|
313
|
+
flex-direction: column;
|
|
314
|
+
gap: 4px;
|
|
315
|
+
margin-top: 14px;
|
|
316
|
+
padding: 10px 12px;
|
|
317
|
+
display: flex;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
.xdHrtq_savingsRow {
|
|
321
|
+
justify-content: space-between;
|
|
322
|
+
align-items: baseline;
|
|
323
|
+
gap: 12px;
|
|
324
|
+
display: flex;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
.xdHrtq_savingsNetPositive strong {
|
|
328
|
+
color: #30d158;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
.xdHrtq_savingsNetNegative strong {
|
|
332
|
+
color: #ff9f0a;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
.xdHrtq_savingsMuted {
|
|
336
|
+
opacity: .66;
|
|
337
|
+
font-size: .92em;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
.xdHrtq_savingsBreakdown {
|
|
341
|
+
border-top: 1px solid #ffffff14;
|
|
342
|
+
margin-top: 4px;
|
|
343
|
+
padding-top: 4px;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
.xdHrtq_savingsNote {
|
|
347
|
+
opacity: .5;
|
|
348
|
+
margin-top: 4px;
|
|
349
|
+
font-size: .85em;
|
|
350
|
+
}
|
|
@@ -1,136 +1,145 @@
|
|
|
1
|
-
import { createUserMessage } from "@deepseek-ai/dsh-llm";
|
|
2
|
-
//#region src/runtime/session-events.ts
|
|
3
|
-
/**
|
|
4
|
-
* Read one immutable Session event snapshot.
|
|
5
|
-
*
|
|
6
|
-
* Harness rc.2 exposed `events`; Alpha 5 replaced it with the public
|
|
7
|
-
* `snapshotEvents()` method. Prefer the new API when present and retain the
|
|
8
|
-
* old accessor as the compatibility fallback for already-supported hosts.
|
|
9
|
-
*/
|
|
10
|
-
function sessionEvents(session) {
|
|
11
|
-
const snapshot = session.snapshotEvents;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
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
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
if (
|
|
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
|
-
if (
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
1
|
+
import { createUserMessage } from "@deepseek-ai/dsh-llm";
|
|
2
|
+
//#region src/runtime/session-events.ts
|
|
3
|
+
/**
|
|
4
|
+
* Read one immutable Session event snapshot.
|
|
5
|
+
*
|
|
6
|
+
* Harness rc.2 exposed `events`; Alpha 5 replaced it with the public
|
|
7
|
+
* `snapshotEvents()` method. Prefer the new API when present and retain the
|
|
8
|
+
* old accessor as the compatibility fallback for already-supported hosts.
|
|
9
|
+
*/
|
|
10
|
+
function sessionEvents(session) {
|
|
11
|
+
const snapshot = session.snapshotEvents;
|
|
12
|
+
if (typeof snapshot === "function") return snapshot.call(session);
|
|
13
|
+
return session.events ?? [];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Resolve one surface-node seq to its event. 0.1.5 surface nodes are
|
|
17
|
+
* positional and may replace earlier ranges, so a node's seq is not
|
|
18
|
+
* guaranteed to equal the snapshot array index: always resolve by seq.
|
|
19
|
+
*/
|
|
20
|
+
function eventBySeq(events, seq) {
|
|
21
|
+
return events[Number(seq)];
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/runtime/tail-trim.ts
|
|
25
|
+
/** Plugin-owned TailTrim publication protocol over official Session events. */
|
|
26
|
+
const TAIL_TRIM_REF_PATTERN = /^session:\/\/([^/]+)\/tailtrim\/(\d+)$/;
|
|
27
|
+
const MAX_ROOTS = 64;
|
|
28
|
+
const MAX_STUB_CODE_POINTS = 1024;
|
|
29
|
+
/** Build a same-session reference keyed by the standard prune event. */
|
|
30
|
+
function tailTrimRef(sessionId, manifestSeq) {
|
|
31
|
+
return `session://${sessionId}/tailtrim/${String(manifestSeq)}`;
|
|
32
|
+
}
|
|
33
|
+
/** Parse one exact TailTrim reference. */
|
|
34
|
+
function parseTailTrimRef(ref) {
|
|
35
|
+
const match = TAIL_TRIM_REF_PATTERN.exec(ref);
|
|
36
|
+
if (match === null) return null;
|
|
37
|
+
const manifestSeq = Number(match[2]);
|
|
38
|
+
if (!Number.isSafeInteger(manifestSeq) || manifestSeq < 0) return null;
|
|
39
|
+
return {
|
|
40
|
+
sessionId: match[1] ?? "",
|
|
41
|
+
manifestSeq
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/** Build the fixed bounded model-visible TailTrim stub. */
|
|
45
|
+
function tailTrimStub(ref, toolNames, sourceEventSeqs) {
|
|
46
|
+
const stub = [
|
|
47
|
+
"[TailTrim: completed tool-call group]",
|
|
48
|
+
`ref: ${ref}`,
|
|
49
|
+
`tools: ${toolNames.join(", ")}`,
|
|
50
|
+
`source_event_seqs: ${sourceEventSeqs.join(", ")}`,
|
|
51
|
+
"use context_compression_retrieve with this TailTrim ref if needed"
|
|
52
|
+
].join("\n");
|
|
53
|
+
return Array.from(stub).length <= MAX_STUB_CODE_POINTS ? stub : null;
|
|
54
|
+
}
|
|
55
|
+
/** Wrap a TailTrim stub in the one user message used for range replacement. */
|
|
56
|
+
function tailTrimMessage(stub) {
|
|
57
|
+
return createUserMessage({
|
|
58
|
+
content: [{
|
|
59
|
+
type: "text",
|
|
60
|
+
text: stub
|
|
61
|
+
}],
|
|
62
|
+
source: {
|
|
63
|
+
kind: "plugin",
|
|
64
|
+
plugin: "dsh-context-compression-improved-runtime"
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/** Validate the standard prune, adjacent replacement, append roots and stub. */
|
|
69
|
+
function validatePublishedTailTrim(session, manifestSeq) {
|
|
70
|
+
const events = sessionEvents(session);
|
|
71
|
+
const manifest = events[manifestSeq];
|
|
72
|
+
if (manifest?.type !== "compaction/prune" || manifest.data.shadowedSeqs.length < 2 || manifest.data.shadowedSeqs.length > MAX_ROOTS || manifest.data.shadowedSeqs[0] !== Number(manifest.data.shadowedRange.start) || manifest.data.shadowedSeqs.at(-1) !== Number(manifest.data.shadowedRange.end) || new Set(manifest.data.shadowedSeqs).size !== manifest.data.shadowedSeqs.length) return null;
|
|
73
|
+
const replacement = events[manifestSeq + 1];
|
|
74
|
+
if (replacement?.type !== "user/message" || replacement.seq !== manifest.seq + 1 || replacement.data.source.kind !== "plugin" || replacement.data.source.plugin !== "dsh-context-compression-improved-runtime" || replacement.surfaceOp === void 0 || replacement.surfaceOp === "append" || replacement.surfaceOp.startSeq !== manifest.data.shadowedRange.start || replacement.surfaceOp.endSeq !== manifest.data.shadowedRange.end || !sameNumbers(replacement.sourceEventSeqs, [manifest.seq, ...manifest.data.shadowedSeqs]) || replacement.data.content.length !== 1 || replacement.data.content[0]?.type !== "text") return null;
|
|
75
|
+
const tracedRoots = manifest.data.shadowedSeqs.map((seq) => uniqueAppendRoot(session, seq, manifestSeq));
|
|
76
|
+
if (tracedRoots.some((root) => root === null)) return null;
|
|
77
|
+
const sourceEventSeqs = tracedRoots;
|
|
78
|
+
if (new Set(sourceEventSeqs).size !== sourceEventSeqs.length) return null;
|
|
79
|
+
const roots = sourceEventSeqs.map((seq) => events[seq]);
|
|
80
|
+
if (roots.some((event) => event === void 0)) return null;
|
|
81
|
+
const typedRoots = roots;
|
|
82
|
+
if (!validRootGroup(typedRoots, manifestSeq)) return null;
|
|
83
|
+
const assistant = typedRoots[0];
|
|
84
|
+
if (assistant?.type !== "assistant/message") return null;
|
|
85
|
+
const toolNames = assistant.data.message.content.map((block) => {
|
|
86
|
+
if (block.type !== "tool-call") throw new Error("unreachable");
|
|
87
|
+
return block.name;
|
|
88
|
+
});
|
|
89
|
+
const ref = tailTrimRef(String(session.id), manifestSeq);
|
|
90
|
+
const stub = tailTrimStub(ref, toolNames, sourceEventSeqs);
|
|
91
|
+
if (stub === null || replacement.data.content[0].text !== stub) return null;
|
|
92
|
+
return {
|
|
93
|
+
manifest,
|
|
94
|
+
replacement,
|
|
95
|
+
roots: typedRoots,
|
|
96
|
+
toolNames,
|
|
97
|
+
ref,
|
|
98
|
+
stub
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function uniqueAppendRoot(session, seq, beforeSeq) {
|
|
102
|
+
const events = sessionEvents(session);
|
|
103
|
+
const pending = [{
|
|
104
|
+
seq,
|
|
105
|
+
depth: 0
|
|
106
|
+
}];
|
|
107
|
+
const visited = /* @__PURE__ */ new Set();
|
|
108
|
+
const roots = /* @__PURE__ */ new Set();
|
|
109
|
+
while (pending.length > 0) {
|
|
110
|
+
const next = pending.pop();
|
|
111
|
+
if (next === void 0 || next.depth > MAX_ROOTS || visited.has(next.seq)) continue;
|
|
112
|
+
if (!Number.isSafeInteger(next.seq) || next.seq < 0 || next.seq >= beforeSeq) return null;
|
|
113
|
+
visited.add(next.seq);
|
|
114
|
+
if (visited.size > MAX_ROOTS) return null;
|
|
115
|
+
const event = events[next.seq];
|
|
116
|
+
if (event === void 0 || event.type !== "assistant/message" && event.type !== "tool/result") return null;
|
|
117
|
+
if (event.surfaceOp === "append") roots.add(event.seq);
|
|
118
|
+
else if (typeof event.surfaceOp === "object") {
|
|
119
|
+
const sources = event.sourceEventSeqs;
|
|
120
|
+
if (sources === void 0 || sources.length === 0) return null;
|
|
121
|
+
for (const source of sources) pending.push({
|
|
122
|
+
seq: source,
|
|
123
|
+
depth: next.depth + 1
|
|
124
|
+
});
|
|
125
|
+
} else return null;
|
|
126
|
+
if (roots.size > 1) return null;
|
|
127
|
+
}
|
|
128
|
+
return roots.size === 1 ? [...roots][0] ?? null : null;
|
|
129
|
+
}
|
|
130
|
+
function validRootGroup(roots, manifestSeq) {
|
|
131
|
+
const assistant = roots[0];
|
|
132
|
+
if (assistant?.type !== "assistant/message" || assistant.seq >= manifestSeq || assistant.surfaceOp !== "append" || assistant.data.interrupted === true || assistant.data.message.content.length === 0 || assistant.data.message.content.some((block) => block.type !== "tool-call")) return false;
|
|
133
|
+
const callIds = assistant.data.message.content.map((call) => call.id);
|
|
134
|
+
if (new Set(callIds).size !== callIds.length || roots.length !== callIds.length + 1) return false;
|
|
135
|
+
for (const [index, root] of roots.slice(1).entries()) {
|
|
136
|
+
if (root.type !== "tool/result" || root.seq >= manifestSeq || root.surfaceOp !== "append") return false;
|
|
137
|
+
if (root.data.message.content[0].isError === true || root.data.error !== void 0 || root.data.turn !== assistant.data.turn || root.data.step !== assistant.data.step || String(root.data.message.source.callId) !== String(callIds[index])) return false;
|
|
138
|
+
}
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
function sameNumbers(left, right) {
|
|
142
|
+
return left !== void 0 && left.length === right.length && left.every((value, index) => value === right[index]);
|
|
143
|
+
}
|
|
144
|
+
//#endregion
|
|
145
|
+
export { validatePublishedTailTrim as a, tailTrimStub as i, tailTrimMessage as n, eventBySeq as o, tailTrimRef as r, sessionEvents as s, parseTailTrimRef as t };
|