dsh-context-compression-improved 0.9.5 → 0.9.8
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/CHANGELOG.md +4 -0
- package/CONTRIBUTING.md +22 -22
- package/LICENSE +21 -21
- package/README.de.md +3 -3
- package/README.es.md +3 -3
- package/README.fr.md +3 -3
- package/README.it.md +3 -3
- package/README.ja.md +16 -3
- package/README.ko.md +16 -3
- package/README.md +16 -3
- package/README.ru.md +3 -3
- package/README.zh.md +16 -3
- package/SECURITY.md +18 -18
- package/THIRD_PARTY_NOTICES.md +14 -14
- package/assets/board.png +0 -0
- package/assets/context.png +0 -0
- package/docs/compat-0.1.5-report.md +77 -77
- package/docs/installation.de.md +2 -2
- package/docs/installation.es.md +2 -2
- package/docs/installation.fr.md +2 -2
- package/docs/installation.it.md +2 -2
- package/docs/installation.ja.md +2 -2
- package/docs/installation.ko.md +2 -2
- package/docs/installation.md +2 -2
- package/docs/installation.ru.md +2 -2
- package/docs/installation.zh.md +2 -2
- package/docs/repair-log.md +657 -657
- package/package.json +7 -6
- 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 +2 -2
- package/packages/selector/lib/index.js +25 -0
- package/packages/selector/lib/pruner.d.ts +1 -1
- package/packages/selector/lib/pruner.js +1 -2
- package/packages/selector/lib/style.css +53 -53
- package/packages/selector/lib/tail-trim.js +25 -2
- package/packages/selector/package.json +22 -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/preset-options.ts +88 -88
- package/packages/selector/src/client/scope-face.ts +24 -24
- package/packages/selector/src/compat/llm-messages.ts +50 -0
- package/packages/selector/src/css-modules.d.ts +6 -6
- package/packages/selector/src/estimator-catalog.ts +104 -104
- package/packages/selector/src/index.ts +27 -0
- package/packages/selector/src/invariant.ts +113 -113
- package/packages/selector/src/pruner/tuning.ts +23 -23
- package/packages/selector/src/pruner/types.ts +78 -78
- package/packages/selector/src/pruner.ts +5 -1
- package/packages/selector/src/runtime/adaptive-cost.ts +205 -205
- package/packages/selector/src/runtime/audit.ts +303 -303
- 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/session-events.ts +30 -30
- package/packages/selector/src/runtime/tail-trim.ts +2 -1
- package/packages/selector/src/runtime/token-count.ts +72 -72
- package/packages/selector/src/runtime/tokenpilot/advisor-prompt.ts +233 -233
- package/packages/selector/src/runtime/tokenpilot/advisor-state.ts +204 -204
- 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/intent-fold.ts +53 -53
- package/packages/selector/src/runtime/tokenpilot/intent-gate.ts +65 -65
- package/packages/selector/src/runtime/tokenpilot/intent-input-mask.ts +125 -125
- package/packages/selector/src/runtime/tokenpilot/intent-range.ts +37 -37
- package/packages/selector/src/runtime/tokenpilot/read-state.ts +98 -98
- package/packages/selector/src/runtime/toolclass.ts +103 -103
- package/packages/selector/src/runtime/value.ts +48 -48
- package/packages/selector/tests/advisor-report.host.spec.ts +223 -223
- package/packages/selector/tests/cache-prefix-audit.spec.ts +123 -123
- package/packages/selector/tests/estimator-catalog.spec.ts +70 -70
- 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/preset-overlay.host.spec.ts +246 -246
- package/packages/selector/tests/public/package-contract.client.spec.ts +4 -4
- package/packages/selector/tests/runtime/adaptive-cost.spec.ts +167 -167
- 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/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-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/intent-gate.spec.ts +62 -62
- package/packages/selector/tests/runtime/intent-summary.spec.ts +156 -156
- 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/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/summary-command.spec.ts +154 -154
- 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/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/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/pnpm-workspace.yaml +6 -0
- package/screenshots.json +6 -0
- 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 +6 -2
- package/scripts/packed-install-e2e.mjs +19 -3
- package/scripts/sync-hosts.mjs +2 -2
- package/scripts/toolclass-corpus-replay.mjs +281 -281
- package/scripts/verify-release.mjs +6 -6
- package/tsconfig.base.json +18 -18
- package/tsconfig.json +7 -7
- package/vitest.built.config.ts +9 -9
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
# Parent and child agent cache-prefix audit
|
|
2
|
-
|
|
3
|
-
## Scope
|
|
4
|
-
|
|
5
|
-
This reference characterizes when DeepSeek Harness parent and child requests can present an identical prompt prefix to DeepSeek's automatic context cache. It does not add an explicit cache key, cache breakpoint, cache identifier, or client-side KV cache.
|
|
6
|
-
|
|
7
|
-
The selector plugin owns settings registration and UI only. It has no hook into agent request construction, subagent session creation, or LLM serialization, so this work must not add runtime request behavior to the plugin or modify Harness core.
|
|
8
|
-
|
|
9
|
-
## Three separate questions
|
|
10
|
-
|
|
11
|
-
Context inheritance asks whether a child session receives parent session events. A fork copies the parent event prefix through the last completed turn; a spawn starts without parent messages. The child metadata records the parent session and, for a fork, the seed length.
|
|
12
|
-
|
|
13
|
-
Harness cache control asks whether Harness supplies a DeepSeek cache key or breakpoint across requests or sessions. The DeepSeek adapter serializes ordinary Chat Completions input and reads official usage fields; it supplies no explicit cache control.
|
|
14
|
-
|
|
15
|
-
Server cache reuse asks whether byte-identical request prefixes can hit DeepSeek's automatic context cache. This is best-effort server behavior and is confirmed only when official response usage reports a positive `prompt_cache_hit_tokens` value. Latency and price are not evidence.
|
|
16
|
-
|
|
17
|
-
## Reuse characterization
|
|
18
|
-
|
|
19
|
-
The test-only audit representation is versioned and canonical. Object keys are sorted recursively, while arrays retain their model-visible order. A SHA-256 fingerprint is computed over UTF-8 JSON containing the provider, model, system prompt, tool schemas, and inherited messages.
|
|
20
|
-
|
|
21
|
-
A child is reusable only when it is a fork, declares parent-context inheritance, and its provider, model, system prompt, tools, and inherited messages equal the parent's stable envelope. Spawn mode, a changed persona or system prompt, changed tool schema or order, changed provider or model route, and changed history are rejected. The audit never repairs or concatenates mismatched contexts.
|
|
22
|
-
|
|
23
|
-
The characterization does not guarantee that two independently assembled HTTP bodies have the same byte prefix: JSON property order and the child-only continuation still belong to the DeepSeek adapter. The live test captures the actual immutable agent-loop request options and compares the stable inherited envelope before allowing a cache-reuse claim.
|
|
24
|
-
|
|
25
|
-
## Safe evidence record
|
|
26
|
-
|
|
27
|
-
An evidence event may contain only the audit version, prefix fingerprint, estimated shared-prefix tokens, parent and child session identifiers, mode, eligibility or reason, cache-read tokens, cache-miss tokens, observed prompt tokens, and confirmation status. It must not contain prompts, messages, tool arguments or results, tool schemas, permissions, environment values, credentials, or secrets.
|
|
28
|
-
|
|
29
|
-
Usage is internally consistent only when `cacheReadTokens + cacheMissTokens` equals the observed prompt-token total. A positive cache-read count confirms a natural cache hit for that request. Missing or zero cache-read usage yields `unconfirmed`, never a claimed miss caused by Harness.
|
|
30
|
-
|
|
31
|
-
## TDD acceptance criteria
|
|
32
|
-
|
|
33
|
-
The RED test imports an absent test-support module and defines the required behavior before implementation. The GREEN implementation remains under `tests/support` and exports no product runtime API.
|
|
34
|
-
|
|
35
|
-
- Fork accepts an identical completed-turn prefix and produces the same fingerprint for parent and child views.
|
|
36
|
-
- Spawn is ineligible because it does not inherit parent messages.
|
|
37
|
-
- Persona, tool schema or order, provider, model, and history mismatches are ineligible.
|
|
38
|
-
- Safe evidence records contain only the allowlisted fields and never contain representative secret or tool-result content.
|
|
39
|
-
- Usage projection accepts hit plus miss equaling the prompt total and rejects inconsistent totals.
|
|
40
|
-
- The existing selector runtime source remains unchanged, so disabling or omitting the plugin cannot affect agent requests.
|
|
41
|
-
- A key-gated host-side live DeepSeek E2E test uses an isolated in-memory context and task-local `DSH_HOME`; it reports only sanitized usage evidence.
|
|
42
|
-
- Existing fork, spawn, request-reconstruction, DeepSeek usage-projection, selector-plugin tests, the full build, and `git diff --check` pass.
|
|
43
|
-
|
|
44
|
-
## Operational boundaries
|
|
45
|
-
|
|
46
|
-
Tests do not connect to the active web profile, start or restart a Harness service, deploy code, or write session logs outside the isolated test environment. The test-only implementation adds no product runtime API and does not alter active profile settings or service state.
|
|
1
|
+
# Parent and child agent cache-prefix audit
|
|
2
|
+
|
|
3
|
+
## Scope
|
|
4
|
+
|
|
5
|
+
This reference characterizes when DeepSeek Harness parent and child requests can present an identical prompt prefix to DeepSeek's automatic context cache. It does not add an explicit cache key, cache breakpoint, cache identifier, or client-side KV cache.
|
|
6
|
+
|
|
7
|
+
The selector plugin owns settings registration and UI only. It has no hook into agent request construction, subagent session creation, or LLM serialization, so this work must not add runtime request behavior to the plugin or modify Harness core.
|
|
8
|
+
|
|
9
|
+
## Three separate questions
|
|
10
|
+
|
|
11
|
+
Context inheritance asks whether a child session receives parent session events. A fork copies the parent event prefix through the last completed turn; a spawn starts without parent messages. The child metadata records the parent session and, for a fork, the seed length.
|
|
12
|
+
|
|
13
|
+
Harness cache control asks whether Harness supplies a DeepSeek cache key or breakpoint across requests or sessions. The DeepSeek adapter serializes ordinary Chat Completions input and reads official usage fields; it supplies no explicit cache control.
|
|
14
|
+
|
|
15
|
+
Server cache reuse asks whether byte-identical request prefixes can hit DeepSeek's automatic context cache. This is best-effort server behavior and is confirmed only when official response usage reports a positive `prompt_cache_hit_tokens` value. Latency and price are not evidence.
|
|
16
|
+
|
|
17
|
+
## Reuse characterization
|
|
18
|
+
|
|
19
|
+
The test-only audit representation is versioned and canonical. Object keys are sorted recursively, while arrays retain their model-visible order. A SHA-256 fingerprint is computed over UTF-8 JSON containing the provider, model, system prompt, tool schemas, and inherited messages.
|
|
20
|
+
|
|
21
|
+
A child is reusable only when it is a fork, declares parent-context inheritance, and its provider, model, system prompt, tools, and inherited messages equal the parent's stable envelope. Spawn mode, a changed persona or system prompt, changed tool schema or order, changed provider or model route, and changed history are rejected. The audit never repairs or concatenates mismatched contexts.
|
|
22
|
+
|
|
23
|
+
The characterization does not guarantee that two independently assembled HTTP bodies have the same byte prefix: JSON property order and the child-only continuation still belong to the DeepSeek adapter. The live test captures the actual immutable agent-loop request options and compares the stable inherited envelope before allowing a cache-reuse claim.
|
|
24
|
+
|
|
25
|
+
## Safe evidence record
|
|
26
|
+
|
|
27
|
+
An evidence event may contain only the audit version, prefix fingerprint, estimated shared-prefix tokens, parent and child session identifiers, mode, eligibility or reason, cache-read tokens, cache-miss tokens, observed prompt tokens, and confirmation status. It must not contain prompts, messages, tool arguments or results, tool schemas, permissions, environment values, credentials, or secrets.
|
|
28
|
+
|
|
29
|
+
Usage is internally consistent only when `cacheReadTokens + cacheMissTokens` equals the observed prompt-token total. A positive cache-read count confirms a natural cache hit for that request. Missing or zero cache-read usage yields `unconfirmed`, never a claimed miss caused by Harness.
|
|
30
|
+
|
|
31
|
+
## TDD acceptance criteria
|
|
32
|
+
|
|
33
|
+
The RED test imports an absent test-support module and defines the required behavior before implementation. The GREEN implementation remains under `tests/support` and exports no product runtime API.
|
|
34
|
+
|
|
35
|
+
- Fork accepts an identical completed-turn prefix and produces the same fingerprint for parent and child views.
|
|
36
|
+
- Spawn is ineligible because it does not inherit parent messages.
|
|
37
|
+
- Persona, tool schema or order, provider, model, and history mismatches are ineligible.
|
|
38
|
+
- Safe evidence records contain only the allowlisted fields and never contain representative secret or tool-result content.
|
|
39
|
+
- Usage projection accepts hit plus miss equaling the prompt total and rejects inconsistent totals.
|
|
40
|
+
- The existing selector runtime source remains unchanged, so disabling or omitting the plugin cannot affect agent requests.
|
|
41
|
+
- A key-gated host-side live DeepSeek E2E test uses an isolated in-memory context and task-local `DSH_HOME`; it reports only sanitized usage evidence.
|
|
42
|
+
- Existing fork, spawn, request-reconstruction, DeepSeek usage-projection, selector-plugin tests, the full build, and `git diff --check` pass.
|
|
43
|
+
|
|
44
|
+
## Operational boundaries
|
|
45
|
+
|
|
46
|
+
Tests do not connect to the active web profile, start or restart a Harness service, deploy code, or write session logs outside the isolated test environment. The test-only implementation adds no product runtime API and does not alter active profile settings or service state.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "dsh-external/dsh-context-compression-improved",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.8",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"description": "Auditable tool-result context-compression selector with code-skeleton gate for DeepSeek Harness",
|
|
6
6
|
"engines": {
|
|
7
|
-
"dsh": "0.1.0-rc.2 || 0.1.0-rc.3 || 0.1.0-rc.6 || 0.1.0-rc.7 || 0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2"
|
|
7
|
+
"dsh": "0.1.0-rc.2 || 0.1.0-rc.3 || 0.1.0-rc.6 || 0.1.0-rc.7 || 0.1.0-rc.8 || 0.1.1-rc.1 || 0.1.1-rc.2 || 0.1.2-rc.1 || 0.1.5-rc.1 || 0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.1 || 0.2.1-rc.2"
|
|
8
8
|
},
|
|
9
9
|
"contributes": {
|
|
10
10
|
"tools": [],
|
|
@@ -1030,6 +1030,16 @@ function asWebServer(value) {
|
|
|
1030
1030
|
return typeof value.register === "function" ? value : void 0;
|
|
1031
1031
|
}
|
|
1032
1032
|
/**
|
|
1033
|
+
* `webServer.register` throws `duplicate exact route` when the same lib is
|
|
1034
|
+
* mounted twice by the host (two plugin ids resolving to one module: the
|
|
1035
|
+
* package-root manifest and the nested selector manifest). The other mount
|
|
1036
|
+
* already owns every path in the batch, so the collision is a success from
|
|
1037
|
+
* the plugin's point of view — without this, the losing arm logs a stack-
|
|
1038
|
+
* heavy warn pair on every boot (observed 0.9.5 on 0.2.0-rc.2, savings and
|
|
1039
|
+
* monitor).
|
|
1040
|
+
*/
|
|
1041
|
+
const isDuplicateRouteError = (error) => String(error?.message ?? error).includes("duplicate exact route");
|
|
1042
|
+
/**
|
|
1033
1043
|
* Serve `GET /api/dsh-context-compression-improved/estimator-catalog` — the
|
|
1034
1044
|
* settings card's host-route dropdowns (live provider/model groups from the DSH
|
|
1035
1045
|
* `llm` service plus the effective selection). Best effort: without the
|
|
@@ -1099,6 +1109,11 @@ function registerEstimatorCatalogRoute(ctx) {
|
|
|
1099
1109
|
}, "contextCompressionSelector.estimator-catalog route");
|
|
1100
1110
|
log("info", "context-compression estimator catalog route registered (%s): %s", channel, ESTIMATOR_CATALOG_ROUTES.join(", "));
|
|
1101
1111
|
} catch (error) {
|
|
1112
|
+
if (isDuplicateRouteError(error)) {
|
|
1113
|
+
registered = true;
|
|
1114
|
+
log("info", "context-compression estimator catalog route already registered by another mount (%s)", channel);
|
|
1115
|
+
return;
|
|
1116
|
+
}
|
|
1102
1117
|
log("warn", "context-compression estimator catalog route registration failed (%s): %o", channel, error);
|
|
1103
1118
|
}
|
|
1104
1119
|
};
|
|
@@ -1170,6 +1185,11 @@ function registerSavingsRoute(ctx) {
|
|
|
1170
1185
|
}, "contextCompressionSelector.savings route");
|
|
1171
1186
|
log("info", "context-compression savings route registered (%s): %s", channel, SAVINGS_ROUTES.join(", "));
|
|
1172
1187
|
} catch (error) {
|
|
1188
|
+
if (isDuplicateRouteError(error)) {
|
|
1189
|
+
registered = true;
|
|
1190
|
+
log("info", "context-compression savings route already registered by another mount (%s)", channel);
|
|
1191
|
+
return;
|
|
1192
|
+
}
|
|
1173
1193
|
log("warn", "context-compression savings route registration failed (%s): %o", channel, error);
|
|
1174
1194
|
}
|
|
1175
1195
|
};
|
|
@@ -1296,6 +1316,11 @@ function registerMonitorRoute(ctx) {
|
|
|
1296
1316
|
}, "contextCompressionSelector.monitor route");
|
|
1297
1317
|
log("info", "context-compression monitor route registered (%s): %s", channel, MONITOR_ROUTES.join(", "));
|
|
1298
1318
|
} catch (error) {
|
|
1319
|
+
if (isDuplicateRouteError(error)) {
|
|
1320
|
+
registered = true;
|
|
1321
|
+
log("info", "context-compression monitor route already registered by another mount (%s)", channel);
|
|
1322
|
+
return;
|
|
1323
|
+
}
|
|
1299
1324
|
log("warn", "context-compression monitor route registration failed (%s): %o", channel, error);
|
|
1300
1325
|
}
|
|
1301
1326
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import z from "@deepseek-ai/schemastery";
|
|
2
2
|
import { Context, Service } from "@deepseek-ai/cordis";
|
|
3
|
-
import { ContentBlock, ToolCallId } from "@deepseek-ai/dsh-llm";
|
|
4
3
|
import { Session, SessionEvent } from "@deepseek-ai/dsh-session";
|
|
4
|
+
import { ContentBlock, ToolCallId } from "@deepseek-ai/dsh-llm";
|
|
5
5
|
import { TokenMeasurement } from "@deepseek-ai/dsh-token-meter";
|
|
6
6
|
//#region src/runtime/tokenpilot/dedup.d.ts
|
|
7
7
|
/** Entry stored per first-seen content hash. */
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { B as decimalRateNanoUnits, F as recordIntentFold, H as resolveOfficialDeepSeekPrice, I as recordRecertified, L as recordScore, M as getSummaryOverride, N as invalidateOnTaskChange, O as evaluateIntentGate, P as observeIntentEnabled, T as observeContextUsage, U as getSavingsLedger, V as priceOfficialDeepSeekUsage, W as savingsHash, _ as resolveCustomPolicy, b as COMPRESSION_PROFILES, c as charsToTokens, d as isValidAutoCompactThresholdPercent, f as parseContextCompressionSettings, g as DEFAULT_CUSTOM_COMPRESSION_POLICY, h as CustomCompressionPolicySchema, i as DEFAULTS, k as getAdvisorState, l as codePointLength, m as resolvePolicy, n as CONTEXT_COMPRESSION_SETTINGS_NAMESPACE, o as PRUNE_MARKER, p as resolveConfig, r as ContextCompressionSettingsSchema, s as charsForTokens, t as AUTO_COMPACT_THRESHOLD_LIMITS, u as isCompressionProfile, v as assertNever, y as deepFreeze, z as DEEPSEEK_OFFICIAL_PRICE_CATALOG_VERSION } from "./config.js";
|
|
2
|
-
import { a as validatePublishedTailTrim, c as eventBySeq, i as tailTrimStub, l as sessionEvents, n as tailTrimMessage, o as compressionMessageSource, r as tailTrimRef, s as viewToolResult, t as parseTailTrimRef } from "./tail-trim.js";
|
|
2
|
+
import { a as validatePublishedTailTrim, c as eventBySeq, d as freezeMessage, i as tailTrimStub, l as sessionEvents, n as tailTrimMessage, o as compressionMessageSource, r as tailTrimRef, s as viewToolResult, t as parseTailTrimRef, u as createUserMessage } from "./tail-trim.js";
|
|
3
3
|
import z from "@deepseek-ai/schemastery";
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
5
5
|
import { Service } from "@deepseek-ai/cordis";
|
|
6
|
-
import { createUserMessage, freezeMessage } from "@deepseek-ai/dsh-llm";
|
|
7
6
|
import * as dshSessionNamespace from "@deepseek-ai/dsh-session";
|
|
8
7
|
import { readFileSync } from "node:fs";
|
|
9
8
|
import { Tokenizer } from "@huggingface/tokenizers";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
.
|
|
1
|
+
.WcpPCW_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
|
+
.WcpPCW_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
|
+
.WcpPCW_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
|
+
.WcpPCW_root {
|
|
25
25
|
width: 100%;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
.
|
|
28
|
+
.WcpPCW_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
|
+
.WcpPCW_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
|
+
.WcpPCW_profileCard:hover:not(:disabled) {
|
|
49
49
|
background: var(--dsw-alias-interactive-bg-hover);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
.
|
|
52
|
+
.WcpPCW_profileCard[aria-pressed="true"] {
|
|
53
53
|
border-color: var(--dsw-alias-label-primary);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
.
|
|
56
|
+
.WcpPCW_profileCard:active:not(:disabled) {
|
|
57
57
|
transform: scale(.99);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
.
|
|
60
|
+
.WcpPCW_profileCard:disabled {
|
|
61
61
|
cursor: default;
|
|
62
62
|
opacity: .6;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
.
|
|
65
|
+
.WcpPCW_profileCard:focus-visible {
|
|
66
66
|
outline-offset: 2px;
|
|
67
67
|
outline: 2px solid;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
.
|
|
70
|
+
.WcpPCW_profileCardTop {
|
|
71
71
|
align-items: center;
|
|
72
72
|
gap: 8px;
|
|
73
73
|
display: flex;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
.
|
|
76
|
+
.WcpPCW_profileCardTitle {
|
|
77
77
|
font-size: 14px;
|
|
78
78
|
font-weight: 500;
|
|
79
79
|
line-height: 20px;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
.
|
|
82
|
+
.WcpPCW_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
|
+
.WcpPCW_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
|
+
.WcpPCW_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
|
+
.WcpPCW_button:hover {
|
|
113
113
|
background: var(--dsw-alias-interactive-bg-hover);
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
.
|
|
116
|
+
.WcpPCW_button:disabled {
|
|
117
117
|
cursor: default;
|
|
118
118
|
opacity: .6;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
.
|
|
121
|
+
.WcpPCW_copy {
|
|
122
122
|
flex: 1;
|
|
123
123
|
min-width: 0;
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
.
|
|
126
|
+
.WcpPCW_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
|
+
.WcpPCW_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
|
+
.WcpPCW_chevron {
|
|
141
141
|
color: var(--dsw-alias-label-secondary);
|
|
142
142
|
flex: none;
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
.
|
|
145
|
+
.WcpPCW_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
|
+
.WcpPCW_menuTitle {
|
|
153
153
|
font-size: 13px;
|
|
154
154
|
line-height: 17px;
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
.
|
|
157
|
+
.WcpPCW_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
|
+
.WcpPCW_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
|
+
.WcpPCW_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
|
+
.WcpPCW_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
|
+
.WcpPCW_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
|
+
.WcpPCW_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
|
+
.WcpPCW_customTitle {
|
|
200
200
|
margin: 0 0 6px;
|
|
201
201
|
font-size: 13px;
|
|
202
202
|
line-height: 17px;
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
-
.
|
|
205
|
+
.WcpPCW_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
|
+
.WcpPCW_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
|
+
.WcpPCW_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
|
+
.WcpPCW_fieldGrid {
|
|
228
228
|
grid-template-columns: 1fr;
|
|
229
229
|
gap: 8px;
|
|
230
230
|
display: grid;
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
-
.
|
|
233
|
+
.WcpPCW_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
|
+
.WcpPCW_field input, .WcpPCW_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
|
+
.WcpPCW_field input:focus-visible, .WcpPCW_field select:focus-visible, .WcpPCW_actions button:focus-visible {
|
|
257
257
|
outline-offset: 2px;
|
|
258
258
|
outline: 2px solid;
|
|
259
259
|
}
|
|
260
260
|
|
|
261
|
-
.
|
|
261
|
+
.WcpPCW_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
|
+
.WcpPCW_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,40 +274,40 @@
|
|
|
274
274
|
padding: 4px 8px;
|
|
275
275
|
}
|
|
276
276
|
|
|
277
|
-
.
|
|
277
|
+
.WcpPCW_actions button:active:not(:disabled) {
|
|
278
278
|
transform: scale(.98);
|
|
279
279
|
}
|
|
280
280
|
|
|
281
|
-
.
|
|
281
|
+
.WcpPCW_actions button:disabled {
|
|
282
282
|
opacity: .6;
|
|
283
283
|
}
|
|
284
284
|
|
|
285
285
|
@media (width <= 560px) {
|
|
286
|
-
.
|
|
286
|
+
.WcpPCW_profileGrid {
|
|
287
287
|
grid-template-columns: 1fr;
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
290
|
|
|
291
|
-
.
|
|
291
|
+
.WcpPCW_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
|
+
.WcpPCW_autoCompactTitle {
|
|
299
299
|
margin: 0 0 8px;
|
|
300
300
|
font-size: 15px;
|
|
301
301
|
font-weight: 600;
|
|
302
302
|
}
|
|
303
303
|
|
|
304
|
-
.
|
|
304
|
+
.WcpPCW_autoCompactRisk {
|
|
305
305
|
opacity: .9;
|
|
306
306
|
margin: 8px 0 0;
|
|
307
307
|
font-size: 12px;
|
|
308
308
|
}
|
|
309
309
|
|
|
310
|
-
.
|
|
310
|
+
.WcpPCW_savingsCard {
|
|
311
311
|
border: 1px solid #ffffff1a;
|
|
312
312
|
border-radius: 8px;
|
|
313
313
|
flex-direction: column;
|
|
@@ -317,33 +317,33 @@
|
|
|
317
317
|
display: flex;
|
|
318
318
|
}
|
|
319
319
|
|
|
320
|
-
.
|
|
320
|
+
.WcpPCW_savingsRow {
|
|
321
321
|
justify-content: space-between;
|
|
322
322
|
align-items: baseline;
|
|
323
323
|
gap: 12px;
|
|
324
324
|
display: flex;
|
|
325
325
|
}
|
|
326
326
|
|
|
327
|
-
.
|
|
327
|
+
.WcpPCW_savingsNetPositive strong {
|
|
328
328
|
color: #30d158;
|
|
329
329
|
}
|
|
330
330
|
|
|
331
|
-
.
|
|
331
|
+
.WcpPCW_savingsNetNegative strong {
|
|
332
332
|
color: #ff9f0a;
|
|
333
333
|
}
|
|
334
334
|
|
|
335
|
-
.
|
|
335
|
+
.WcpPCW_savingsMuted {
|
|
336
336
|
opacity: .66;
|
|
337
337
|
font-size: .92em;
|
|
338
338
|
}
|
|
339
339
|
|
|
340
|
-
.
|
|
340
|
+
.WcpPCW_savingsBreakdown {
|
|
341
341
|
border-top: 1px solid #ffffff14;
|
|
342
342
|
margin-top: 4px;
|
|
343
343
|
padding-top: 4px;
|
|
344
344
|
}
|
|
345
345
|
|
|
346
|
-
.
|
|
346
|
+
.WcpPCW_savingsNote {
|
|
347
347
|
opacity: .5;
|
|
348
348
|
margin-top: 4px;
|
|
349
349
|
font-size: .85em;
|
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
import { r as hostGenerationSnapshot } from "./host-generation.js";
|
|
2
|
-
|
|
2
|
+
//#region src/compat/llm-messages.ts
|
|
3
|
+
/** Recursive `Object.freeze` over own enumerable properties (arrays included). */
|
|
4
|
+
function deepFreeze(value) {
|
|
5
|
+
if (value !== null && typeof value === "object" && !Object.isFrozen(value)) {
|
|
6
|
+
Object.freeze(value);
|
|
7
|
+
for (const nested of Object.values(value)) deepFreeze(nested);
|
|
8
|
+
}
|
|
9
|
+
return value;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Detach and deep-freeze a message whose identity already exists — the host
|
|
13
|
+
* factory is `deepFreeze(structuredClone(message))`, byte-for-byte.
|
|
14
|
+
*/
|
|
15
|
+
function freezeMessage(message) {
|
|
16
|
+
return deepFreeze(structuredClone(message));
|
|
17
|
+
}
|
|
18
|
+
function createUserMessage(input) {
|
|
19
|
+
return deepFreeze(structuredClone({
|
|
20
|
+
...input,
|
|
21
|
+
role: "user",
|
|
22
|
+
id: crypto.randomUUID()
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
3
26
|
//#region src/runtime/session-events.ts
|
|
4
27
|
/**
|
|
5
28
|
* Read one immutable Session event snapshot.
|
|
@@ -208,4 +231,4 @@ function sameNumbers(left, right) {
|
|
|
208
231
|
return left !== void 0 && left.length === right.length && left.every((value, index) => value === right[index]);
|
|
209
232
|
}
|
|
210
233
|
//#endregion
|
|
211
|
-
export { validatePublishedTailTrim as a, eventBySeq as c, tailTrimStub as i, sessionEvents as l, tailTrimMessage as n, compressionMessageSource as o, tailTrimRef as r, viewToolResult as s, parseTailTrimRef as t };
|
|
234
|
+
export { validatePublishedTailTrim as a, eventBySeq as c, freezeMessage as d, tailTrimStub as i, sessionEvents as l, tailTrimMessage as n, compressionMessageSource as o, tailTrimRef as r, viewToolResult as s, parseTailTrimRef as t, createUserMessage as u };
|