dsh-context-compression-improved 0.11.2 → 0.11.3
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/dsh.plugin.json +1 -1
- package/lib/client.js +27 -10
- package/package.json +1 -1
package/dsh.plugin.json
CHANGED
package/lib/client.js
CHANGED
|
@@ -3857,6 +3857,17 @@ window.__ModuleLoader__.load({
|
|
|
3857
3857
|
if (left.version !== 3 || right.version !== 3) return false;
|
|
3858
3858
|
return left.version === right.version && left.unit === right.unit && left.prefixPolicy === right.prefixPolicy && left.fresh.enabled === right.fresh.enabled && left.fresh.trigger === right.fresh.trigger && left.fresh.target === right.fresh.target && left.aggregate.enabled === right.aggregate.enabled && left.aggregate.trigger === right.aggregate.trigger && left.aggregate.target === right.aggregate.target && left.history.enabled === right.history.enabled && left.history.trigger === right.history.trigger && left.history.keepRecentToolCalls === right.history.keepRecentToolCalls && left.history.keepRecentTokens === right.history.keepRecentTokens && left.history.minReclaim === right.history.minReclaim && left.tailTrim.enabled === right.tailTrim.enabled && left.tailTrim.trigger === right.tailTrim.trigger;
|
|
3859
3859
|
}
|
|
3860
|
+
/**
|
|
3861
|
+
* Host locale APIs throw on duplicate writes: `addLanguage` when the global
|
|
3862
|
+
* catalog already has the id (`... is already registered`), and `register` when
|
|
3863
|
+
* the namespace already carries that locale (`... already has locale "..."`).
|
|
3864
|
+
* This plugin is mounted twice by name (bundle row + estimator-catalog row) and
|
|
3865
|
+
* re-runs apply on `_reload`, so both throws are expected benign skips — the
|
|
3866
|
+
* entry is already present and usable — and must never surface as warning noise.
|
|
3867
|
+
*/
|
|
3868
|
+
function isBenignLocaleDuplicate(error) {
|
|
3869
|
+
return error instanceof Error && /already (?:registered|has locale)/.test(error.message);
|
|
3870
|
+
}
|
|
3860
3871
|
function apply(ctx) {
|
|
3861
3872
|
try {
|
|
3862
3873
|
ctx.locale.register(NS, {
|
|
@@ -3864,7 +3875,7 @@ window.__ModuleLoader__.load({
|
|
|
3864
3875
|
en
|
|
3865
3876
|
});
|
|
3866
3877
|
} catch (error) {
|
|
3867
|
-
console.warn("[dsh-context-compression-improved] locale
|
|
3878
|
+
if (!isBenignLocaleDuplicate(error)) console.warn("[dsh-context-compression-improved] locale zh/en register failed:", error);
|
|
3868
3879
|
}
|
|
3869
3880
|
const languages = [
|
|
3870
3881
|
{
|
|
@@ -3903,15 +3914,21 @@ window.__ModuleLoader__.load({
|
|
|
3903
3914
|
dict: ru
|
|
3904
3915
|
}
|
|
3905
3916
|
];
|
|
3906
|
-
for (const language of languages)
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3917
|
+
for (const language of languages) {
|
|
3918
|
+
try {
|
|
3919
|
+
ctx.locale.register(NS, language.id, language.dict);
|
|
3920
|
+
} catch (error) {
|
|
3921
|
+
if (!isBenignLocaleDuplicate(error)) console.warn(`[dsh-context-compression-improved] locale "${language.id}" dictionary registration failed:`, error);
|
|
3922
|
+
}
|
|
3923
|
+
try {
|
|
3924
|
+
ctx.locale.addLanguage({
|
|
3925
|
+
id: language.id,
|
|
3926
|
+
label: language.label,
|
|
3927
|
+
fallback: "en"
|
|
3928
|
+
});
|
|
3929
|
+
} catch (error) {
|
|
3930
|
+
if (!isBenignLocaleDuplicate(error)) console.warn(`[dsh-context-compression-improved] locale "${language.id}" language registration failed:`, error);
|
|
3931
|
+
}
|
|
3915
3932
|
}
|
|
3916
3933
|
const tNav = ctx.locale?.bind?.(NS) ?? ((key) => key);
|
|
3917
3934
|
let configFormsHandle;
|