dsh-context-compression-improved 0.8.0-beta.3 → 0.8.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/eslint.config.js +30 -30
- package/package.json +163 -163
- package/packages/selector/dsh.plugin.json +16 -16
- package/packages/selector/lib/client.d.ts +6 -0
- package/packages/selector/lib/client.js +106 -7
- package/packages/selector/lib/index.js +92 -1
- package/packages/selector/lib/{advisor-state.js → intent-gate.js} +91 -3
- package/packages/selector/lib/profiles.d.ts +9 -0
- package/packages/selector/lib/pruner.d.ts +59 -0
- package/packages/selector/lib/pruner.js +408 -5
- package/packages/selector/src/client/CompressionProfileControls.tsx +34 -0
- package/packages/selector/src/client/CompressionProfileSelector.tsx +1 -0
- package/packages/selector/src/client/decode.ts +53 -49
- package/packages/selector/src/client/index.ts +4 -0
- package/packages/selector/src/client/locales/de.ts +5 -0
- package/packages/selector/src/client/locales/es.ts +5 -0
- package/packages/selector/src/client/locales/fr.ts +5 -0
- package/packages/selector/src/client/locales/it.ts +5 -0
- package/packages/selector/src/client/locales/ja.ts +5 -0
- package/packages/selector/src/client/locales/ko.ts +5 -0
- package/packages/selector/src/client/locales/ru.ts +5 -0
- package/packages/selector/src/client/locales.ts +10 -0
- package/packages/selector/src/client/settings-section.tsx +9 -2
- package/packages/selector/src/index.ts +7 -0
- package/packages/selector/src/profiles.ts +414 -394
- package/packages/selector/src/pruner/state.ts +57 -50
- package/packages/selector/src/pruner.ts +241 -1
- package/packages/selector/src/runtime/audit.ts +303 -286
- package/packages/selector/src/runtime/config.ts +731 -706
- package/packages/selector/src/runtime/summary-command.ts +127 -0
- package/packages/selector/src/runtime/tokenpilot/advisor-prompt.ts +233 -188
- package/packages/selector/src/runtime/tokenpilot/advisor-state.ts +204 -149
- 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/types.ts +358 -346
- package/packages/selector/tests/auto-compact.client.spec.tsx +214 -213
- package/packages/selector/tests/code-skeleton.client.spec.ts +94 -93
- package/packages/selector/tests/custom-contract.client.spec.ts +223 -222
- package/packages/selector/tests/estimator-channel.client.spec.tsx +253 -252
- package/packages/selector/tests/preset-options-write.client.spec.ts +188 -187
- package/packages/selector/tests/profiles.client.spec.tsx +436 -434
- package/packages/selector/tests/runtime/audit.spec.ts +275 -274
- package/packages/selector/tests/runtime/intent-gate.spec.ts +62 -0
- package/packages/selector/tests/runtime/intent-summary.spec.ts +156 -0
- package/packages/selector/tests/runtime/public/public-runtime.spec.ts +2734 -2731
- package/packages/selector/tests/runtime/summary-command.spec.ts +154 -0
- package/packages/selector/tests/settings-seat.client.spec.ts +1 -1
- package/scripts/packed-install-e2e.mjs +1 -1
- package/scripts/verify-release.mjs +2 -1
|
@@ -60,6 +60,15 @@ window.__ModuleLoader__.load({
|
|
|
60
60
|
const enabled = value.enabled;
|
|
61
61
|
return typeof enabled === "boolean" ? { enabled } : void 0;
|
|
62
62
|
}
|
|
63
|
+
/** Browser-safe mirror of the runtime intentSummary section (absent inherits off). */
|
|
64
|
+
function decodeIntentSummarySettings(value) {
|
|
65
|
+
if (value === void 0) return { enabled: false };
|
|
66
|
+
if (!isPlainRecord(value)) return void 0;
|
|
67
|
+
const keys = Object.keys(value);
|
|
68
|
+
if (keys.length !== 1 || keys[0] !== "enabled") return void 0;
|
|
69
|
+
const enabled = value.enabled;
|
|
70
|
+
return typeof enabled === "boolean" ? { enabled } : void 0;
|
|
71
|
+
}
|
|
63
72
|
/**
|
|
64
73
|
* Browser mirror of the runtime presetOptions section: absent inherits the
|
|
65
74
|
* preset defaults (decodes to `undefined`); present values must be a plain
|
|
@@ -715,10 +724,45 @@ window.__ModuleLoader__.load({
|
|
|
715
724
|
});
|
|
716
725
|
}
|
|
717
726
|
/**
|
|
718
|
-
* The
|
|
719
|
-
*
|
|
720
|
-
*
|
|
727
|
+
* The turn-tail intent summary fold gate. Same deliberately minimal shape as
|
|
728
|
+
* the code-skeleton gate: an on/off select with its own save path; the fold
|
|
729
|
+
* itself is gated by the growth constants and the per-session /ctx-summary
|
|
730
|
+
* override, none of which belong in this card.
|
|
721
731
|
*/
|
|
732
|
+
function IntentSummaryControls({ value, disabled, save, settle, t }) {
|
|
733
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
734
|
+
className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.autoCompact,
|
|
735
|
+
"aria-labelledby": "context-compression-intentsummary-title",
|
|
736
|
+
children: [
|
|
737
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
|
|
738
|
+
id: "context-compression-intentsummary-title",
|
|
739
|
+
className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.autoCompactTitle,
|
|
740
|
+
children: t("intentSummary.title")
|
|
741
|
+
}),
|
|
742
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
743
|
+
className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.customNote,
|
|
744
|
+
children: t("intentSummary.description")
|
|
745
|
+
}),
|
|
746
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
747
|
+
className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.field,
|
|
748
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("intentSummary.enabled") }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
749
|
+
value: value ? "on" : "off",
|
|
750
|
+
disabled,
|
|
751
|
+
onChange: (event) => {
|
|
752
|
+
settle(() => save(event.currentTarget.value === "on"));
|
|
753
|
+
},
|
|
754
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
755
|
+
value: "on",
|
|
756
|
+
children: t("intentSummary.enabled.on")
|
|
757
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
758
|
+
value: "off",
|
|
759
|
+
children: t("intentSummary.enabled.off")
|
|
760
|
+
})]
|
|
761
|
+
})]
|
|
762
|
+
})
|
|
763
|
+
]
|
|
764
|
+
});
|
|
765
|
+
}
|
|
722
766
|
function CodeSkeletonControls({ value, disabled, save, settle, t }) {
|
|
723
767
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
724
768
|
className: _dsh_context_compression_css_466eb745356d_CompressionProfileSelector_module_css_default.autoCompact,
|
|
@@ -1226,7 +1270,7 @@ window.__ModuleLoader__.load({
|
|
|
1226
1270
|
function ContextCompressionSettingsSection(props) {
|
|
1227
1271
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingsCompressionProfileControls, { ...props });
|
|
1228
1272
|
}
|
|
1229
|
-
function SettingsCompressionProfileControls({ useCompression, select, saveCustom, resetCustom, saveAutoCompact, saveCodeSkeleton, savePresetOptions, t }) {
|
|
1273
|
+
function SettingsCompressionProfileControls({ useCompression, select, saveCustom, resetCustom, saveAutoCompact, saveCodeSkeleton, saveIntentSummary, savePresetOptions, t }) {
|
|
1230
1274
|
const state = useCompression((snapshot) => snapshot);
|
|
1231
1275
|
const [saving, setSaving] = (0, react.useState)(false);
|
|
1232
1276
|
const [saveError, setSaveError] = (0, react.useState)(null);
|
|
@@ -1313,6 +1357,13 @@ window.__ModuleLoader__.load({
|
|
|
1313
1357
|
settle,
|
|
1314
1358
|
t
|
|
1315
1359
|
}),
|
|
1360
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(IntentSummaryControls, {
|
|
1361
|
+
value: state.value?.intentSummary?.enabled ?? false,
|
|
1362
|
+
disabled: busy || !state.writable || false,
|
|
1363
|
+
save: saveIntentSummary,
|
|
1364
|
+
settle,
|
|
1365
|
+
t
|
|
1366
|
+
}),
|
|
1316
1367
|
current !== "tokenpilot-inspired" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EstimatorInactiveNotice, {
|
|
1317
1368
|
profile: t(`profile.${current}`),
|
|
1318
1369
|
t
|
|
@@ -1351,7 +1402,7 @@ window.__ModuleLoader__.load({
|
|
|
1351
1402
|
/**
|
|
1352
1403
|
* Decode one stored context-compression settings document with exactly the
|
|
1353
1404
|
* runtime schema's strictness: a plain object with only `profile`, `custom`,
|
|
1354
|
-
* `autoCompact`, and `
|
|
1405
|
+
* `autoCompact`, `codeSkeleton`, and `intentSummary` keys, a supported profile, a valid Custom
|
|
1355
1406
|
* document canonicalized to v3 exactly as the runtime resolver would, a
|
|
1356
1407
|
* strictly-shaped autoCompact section (absent inherits the 80% default), and
|
|
1357
1408
|
* a strictly-shaped codeSkeleton gate (absent inherits off). Anything else
|
|
@@ -1360,17 +1411,19 @@ window.__ModuleLoader__.load({
|
|
|
1360
1411
|
*/
|
|
1361
1412
|
function decodeSettings(value) {
|
|
1362
1413
|
if (!isPlainRecord(value)) return void 0;
|
|
1363
|
-
if (Object.keys(value).some((key) => key !== "profile" && key !== "custom" && key !== "autoCompact" && key !== "codeSkeleton" && key !== "presetOptions")) return;
|
|
1414
|
+
if (Object.keys(value).some((key) => key !== "profile" && key !== "custom" && key !== "autoCompact" && key !== "codeSkeleton" && key !== "intentSummary" && key !== "presetOptions")) return;
|
|
1364
1415
|
const profile = value.profile;
|
|
1365
1416
|
const custom = value.custom;
|
|
1366
1417
|
const autoCompact = decodeAutoCompactSettings(value.autoCompact);
|
|
1367
1418
|
const codeSkeleton = decodeCodeSkeletonSettings(value.codeSkeleton);
|
|
1419
|
+
const intentSummary = decodeIntentSummarySettings(value.intentSummary);
|
|
1368
1420
|
const presetOptions = decodePresetOptionsSettings(value.presetOptions);
|
|
1369
|
-
return typeof profile === "string" && COMPRESSION_PROFILES.includes(profile) && isCustomCompressionPolicy(custom) && autoCompact !== void 0 && codeSkeleton !== void 0 ? {
|
|
1421
|
+
return typeof profile === "string" && COMPRESSION_PROFILES.includes(profile) && isCustomCompressionPolicy(custom) && autoCompact !== void 0 && codeSkeleton !== void 0 && intentSummary !== void 0 ? {
|
|
1370
1422
|
profile,
|
|
1371
1423
|
custom: canonicalizeCustomPolicy(custom),
|
|
1372
1424
|
autoCompact,
|
|
1373
1425
|
codeSkeleton,
|
|
1426
|
+
intentSummary,
|
|
1374
1427
|
...presetOptions === void 0 ? {} : { presetOptions }
|
|
1375
1428
|
} : void 0;
|
|
1376
1429
|
}
|
|
@@ -1440,6 +1493,11 @@ window.__ModuleLoader__.load({
|
|
|
1440
1493
|
"codeSkeleton.enabled": "代码骨架压缩",
|
|
1441
1494
|
"codeSkeleton.enabled.on": "开",
|
|
1442
1495
|
"codeSkeleton.enabled.off": "关(默认)",
|
|
1496
|
+
"intentSummary.title": "回合末意图摘要(转向尾部压缩)",
|
|
1497
|
+
"intentSummary.description": "开启后,回合收尾阶段把本次消费的增量按语义角色折叠为意图摘要块:读类工具结果压成单行目标/规模记录,写类保留骨架头与逐字错误行,于下一次压力回合经既有折叠管线落地;仅当增长门控通过(活跃表面 >45% 且距上次折叠增长 >50K token)才触发。修改只影响新会话;当前会话可用 /ctx-summary off|on|status 临时覆盖。",
|
|
1498
|
+
"intentSummary.enabled": "回合末意图摘要",
|
|
1499
|
+
"intentSummary.enabled.on": "开",
|
|
1500
|
+
"intentSummary.enabled.off": "关(默认)",
|
|
1443
1501
|
"custom.title": "Custom 策略",
|
|
1444
1502
|
"custom.settingsHint": "具体参数请前往“设置 > 上下文压缩选择器”中编辑。",
|
|
1445
1503
|
"custom.sessionScope": "保存后的修改会在当前压缩运行时随后首次观察某个 Session 时生效;已被该运行时观察的 Session 继续使用其冻结策略。",
|
|
@@ -1550,6 +1608,11 @@ window.__ModuleLoader__.load({
|
|
|
1550
1608
|
"codeSkeleton.enabled": "Code skeleton compression",
|
|
1551
1609
|
"codeSkeleton.enabled.on": "On",
|
|
1552
1610
|
"codeSkeleton.enabled.off": "Off (default)",
|
|
1611
|
+
"intentSummary.title": "Turn-tail intent summary",
|
|
1612
|
+
"intentSummary.description": "When on, the turn-boundary postflight folds the consumed increment into intent-summary blocks by semantic role: read-class tool results become one-line target/scale records and write-class keep skeleton heads plus verbatim error lines, landing on the next pressure round through the ordinary fold pipeline. Only fires when the growth gate passes (live surface >45% and >50K tokens grown since the last fold). Applies to new sessions; override the current one with /ctx-summary off|on|status.",
|
|
1613
|
+
"intentSummary.enabled": "Turn-tail intent summary",
|
|
1614
|
+
"intentSummary.enabled.on": "On",
|
|
1615
|
+
"intentSummary.enabled.off": "Off (default)",
|
|
1553
1616
|
"custom.title": "Custom policy",
|
|
1554
1617
|
"custom.settingsHint": "Edit detailed parameters in Settings > Context compression selector.",
|
|
1555
1618
|
"custom.sessionScope": "Saved changes apply when the current compression runtime next observes a Session for the first time. A Session already observed by that runtime keeps its frozen policy.",
|
|
@@ -1662,6 +1725,11 @@ window.__ModuleLoader__.load({
|
|
|
1662
1725
|
"codeSkeleton.enabled": "Code-Skelettkomprimierung",
|
|
1663
1726
|
"codeSkeleton.enabled.on": "Ein",
|
|
1664
1727
|
"codeSkeleton.enabled.off": "Aus (Standard)",
|
|
1728
|
+
"intentSummary.title": "Abschluss-Zusammenfassung (Turn-Tail)",
|
|
1729
|
+
"intentSummary.description": "Aktiviert faltet der Turn-Abschluss den verbrauchten Zuwachs nach semantischen Rollen zu Intent-Zusammenfassungsblöcken: Lese-Tool-Ergebnisse werden zu Einzeilern mit Ziel/Umfang, die Schreibklasse behält Skelettköpfe plus wörtliche Fehlerzeilen; die Landung erfolgt in der nächsten Druckrunde über die gewöhnliche Falt-Pipeline. Zündet nur, wenn die Wachstumsschwelle passiert ist (live Oberfläche >45 % und >50K Token seit der letzten Faltung). Gilt für neue Sitzungen; die aktuelle lässt sich mit /ctx-summary off|on|status übersteuern.",
|
|
1730
|
+
"intentSummary.enabled": "Abschluss-Zusammenfassung",
|
|
1731
|
+
"intentSummary.enabled.on": "Ein",
|
|
1732
|
+
"intentSummary.enabled.off": "Aus (Standard)",
|
|
1665
1733
|
"custom.title": "Eigene Strategie",
|
|
1666
1734
|
"custom.settingsHint": "Detaillierte Parameter unter Einstellungen > Kontextkomprimierung wählen bearbeiten.",
|
|
1667
1735
|
"custom.sessionScope": "Gespeicherte Änderungen greifen, wenn die aktuelle Compression-Runtime eine Sitzung zum ersten Mal beobachtet. Eine von dieser Runtime bereits beobachtete Sitzung behält ihre eingefrorene Strategie.",
|
|
@@ -1774,6 +1842,11 @@ window.__ModuleLoader__.load({
|
|
|
1774
1842
|
"codeSkeleton.enabled": "Compresión de esqueleto del código",
|
|
1775
1843
|
"codeSkeleton.enabled.on": "Activado",
|
|
1776
1844
|
"codeSkeleton.enabled.off": "Desactivado (predeterminado)",
|
|
1845
|
+
"intentSummary.title": "Resumen de intención al cierre del turno",
|
|
1846
|
+
"intentSummary.description": "Al activarlo, el postflight de cierre de turno pliega el incremento consumido en bloques de resumen de intención por rol semántico: los resultados de herramientas de lectura se convierten en registros de una línea con objetivo/escala y los de escritura conservan la cabecera de esqueleto más las líneas de error textuales; aterriza en la siguiente ronda de presión por el conducto de plegado normal. Solo se dispara si se supera la puerta de crecimiento (superficie activa >45 % y >50K tokens desde el último plegado). Aplica a sesiones nuevas; la actual se gobierna con /ctx-summary off|on|status.",
|
|
1847
|
+
"intentSummary.enabled": "Resumen de intención al cierre",
|
|
1848
|
+
"intentSummary.enabled.on": "Sí",
|
|
1849
|
+
"intentSummary.enabled.off": "No (predeterminado)",
|
|
1777
1850
|
"custom.title": "Política personalizada",
|
|
1778
1851
|
"custom.settingsHint": "Edita los parámetros detallados en Ajustes > Selector de compresión de contexto.",
|
|
1779
1852
|
"custom.sessionScope": "Los cambios guardados se aplican cuando el runtime de compresión actual observa una Session por primera vez. Una Session ya observada por ese runtime conserva su política congelada.",
|
|
@@ -1886,6 +1959,11 @@ window.__ModuleLoader__.load({
|
|
|
1886
1959
|
"codeSkeleton.enabled": "Compression du code en squelette",
|
|
1887
1960
|
"codeSkeleton.enabled.on": "Activé",
|
|
1888
1961
|
"codeSkeleton.enabled.off": "Désactivé (par défaut)",
|
|
1962
|
+
"intentSummary.title": "Résumé d'intention en fin de tour",
|
|
1963
|
+
"intentSummary.description": "Activé, le postflight de fin de tour plie l'incrément consommé en blocs de résumé d'intention par rôle sémantique : les résultats d'outils de lecture deviennent des enregistrements une-ligne objectif/échelle, les écrits gardent la tête de squelette plus les lignes d'erreur verbatim ; l'atterrissage se fait au prochain tour de pression via le pipeline de pliage habituel. Ne se déclenche que si la porte de croissance passe (surface active >45 % et >50K tokens depuis le dernier pliage). S'applique aux nouvelles sessions ; la session courante se pilote avec /ctx-summary off|on|status.",
|
|
1964
|
+
"intentSummary.enabled": "Résumé d'intention en fin de tour",
|
|
1965
|
+
"intentSummary.enabled.on": "Activé",
|
|
1966
|
+
"intentSummary.enabled.off": "Désactivé (par défaut)",
|
|
1889
1967
|
"custom.title": "Stratégie personnalisée",
|
|
1890
1968
|
"custom.settingsHint": "Modifiez les paramètres détaillés dans Réglages > Sélecteur de compression du contexte.",
|
|
1891
1969
|
"custom.sessionScope": "Les changements enregistrés s’appliquent quand le runtime de compression actuel observe une Session pour la première fois. Une Session déjà observée par ce runtime garde sa stratégie figée.",
|
|
@@ -1998,6 +2076,11 @@ window.__ModuleLoader__.load({
|
|
|
1998
2076
|
"codeSkeleton.enabled": "Compressione a scheletro del codice",
|
|
1999
2077
|
"codeSkeleton.enabled.on": "Attivato",
|
|
2000
2078
|
"codeSkeleton.enabled.off": "Disattivato (predefinito)",
|
|
2079
|
+
"intentSummary.title": "Riepilogo di intento a fine turno",
|
|
2080
|
+
"intentSummary.description": "Quando attivo, il postflight di fine turno piega l'incremento consumato in blocchi di riepilogo di intento per ruolo semantico: i risultati degli strumenti di lettura diventano record a riga singola obiettivo/scala, quelli di scrittura mantengono la testa dello scheletro più le righe di errore testuali; atterra al prossimo round di pressione tramite la pipeline di piegatura ordinaria. Si attiva solo se la soglia di crescita passa (superficie attiva >45% e >50K token dall'ultima piegatura). Vale per le nuove sessioni; quella corrente si governa con /ctx-summary off|on|status.",
|
|
2081
|
+
"intentSummary.enabled": "Riepilogo di intento a fine turno",
|
|
2082
|
+
"intentSummary.enabled.on": "On",
|
|
2083
|
+
"intentSummary.enabled.off": "Off (predefinito)",
|
|
2001
2084
|
"custom.title": "Politica personalizzata",
|
|
2002
2085
|
"custom.settingsHint": "Modifica i parametri dettagliati in Impostazioni > Selettore di compressione del contesto.",
|
|
2003
2086
|
"custom.sessionScope": "Le modifiche salvate si applicano quando l’attuale runtime di compressione osserva una Sessione per la prima volta. Una Sessione già osservata da quel runtime mantiene la sua politica congelata.",
|
|
@@ -2110,6 +2193,11 @@ window.__ModuleLoader__.load({
|
|
|
2110
2193
|
"codeSkeleton.enabled": "コードスケルトン圧縮",
|
|
2111
2194
|
"codeSkeleton.enabled.on": "オン",
|
|
2112
2195
|
"codeSkeleton.enabled.off": "オフ(既定)",
|
|
2196
|
+
"intentSummary.title": "ターン末尾インテント要約",
|
|
2197
|
+
"intentSummary.description": "有効にすると、ターン境界のポストフライトが消費済み増分を意味役割ごとにインテント要約ブロックへ折り畳みます。読み系ツール結果は目標/規模の 1 行レコードに、書き系は骨格ヘッダーと逐語エラー行を保持し、次の圧力ラウンドで通常の折り畳みパイプラインを通じて着地します。成長ゲート(ライブ表面 >45%、前回の折り畳みから >50K トークン増)を通過したときだけ発火します。変更は新セッションに適用され、現セッションは /ctx-summary off|on|status で上書きできます。",
|
|
2198
|
+
"intentSummary.enabled": "ターン末尾インテント要約",
|
|
2199
|
+
"intentSummary.enabled.on": "オン",
|
|
2200
|
+
"intentSummary.enabled.off": "オフ(既定)",
|
|
2113
2201
|
"custom.title": "カスタムポリシー",
|
|
2114
2202
|
"custom.settingsHint": "詳細パラメーターは「設定 > コンテキスト圧縮セレクター」で編集してください。",
|
|
2115
2203
|
"custom.sessionScope": "保存した変更は、現在の圧縮ランタイムが次に Session を初めて観測したときに適用されます。そのランタイムに既に観測された Session は凍結済みポリシーを使い続けます。",
|
|
@@ -2222,6 +2310,11 @@ window.__ModuleLoader__.load({
|
|
|
2222
2310
|
"codeSkeleton.enabled": "코드 스켈레톤 압축",
|
|
2223
2311
|
"codeSkeleton.enabled.on": "켬",
|
|
2224
2312
|
"codeSkeleton.enabled.off": "끔(기본값)",
|
|
2313
|
+
"intentSummary.title": "턴 말머리 인텐트 요약",
|
|
2314
|
+
"intentSummary.description": "켜면 턴 경계 포스트플라이트가 소비된 증분을 의미 역할별 인텐트 요약 블록으로 접습니다. 읽기 도구 결과는 목표/규모 한 줄 레코드가 되고 쓰기는 골격 헤더와 원문 오류 줄을 유지하며, 다음 압력 라운드에서 기존 접기 파이프라인을 통해 착지합니다. 성장 게이트(라이브 표면 >45%, 마지막 접기 이후 >50K 토큰 증가)를 통과할 때만 발동합니다. 새 세션에 적용되며, 현재 세션은 /ctx-summary off|on|status 로 임시 전환할 수 있습니다.",
|
|
2315
|
+
"intentSummary.enabled": "턴 말머리 인텐트 요약",
|
|
2316
|
+
"intentSummary.enabled.on": "켜기",
|
|
2317
|
+
"intentSummary.enabled.off": "끄기(기본)",
|
|
2225
2318
|
"custom.title": "커스텀 정책",
|
|
2226
2319
|
"custom.settingsHint": "세부 파라미터는 「설정 > 컨텍스트 압축 셀렉터」에서 편집하세요.",
|
|
2227
2320
|
"custom.sessionScope": "저장된 변경 사항은 현재 압축 런타임이 Session을 처음 관측하는 시점에 적용됩니다. 해당 런타임이 이미 관측한 Session은 동결된 정책을 계속 사용합니다.",
|
|
@@ -2334,6 +2427,11 @@ window.__ModuleLoader__.load({
|
|
|
2334
2427
|
"codeSkeleton.enabled": "Скелетное сжатие кода",
|
|
2335
2428
|
"codeSkeleton.enabled.on": "Вкл",
|
|
2336
2429
|
"codeSkeleton.enabled.off": "Выкл (по умолчанию)",
|
|
2430
|
+
"intentSummary.title": "Итог намерения в конце хода",
|
|
2431
|
+
"intentSummary.description": "При включении постфлайт на границе хода сворачивает потреблённый прирост в блоки итогов намерения по семантическим ролям: результаты читающих инструментов становятся однострочными записями цель/масштаб, пишущие сохраняют заголовок скелета и дословные строки ошибок; приземляется в следующем раунде давления через обычный конвейер свёртки. Срабатывает только при прохождении шлюза роста (активная поверхность >45% и >50K токенов с последней свёртки). Действует на новые сессии; текущую можно переключить командой /ctx-summary off|on|status.",
|
|
2432
|
+
"intentSummary.enabled": "Итог намерения в конце хода",
|
|
2433
|
+
"intentSummary.enabled.on": "Вкл",
|
|
2434
|
+
"intentSummary.enabled.off": "Выкл (по умолчанию)",
|
|
2337
2435
|
"custom.title": "Пользовательская стратегия",
|
|
2338
2436
|
"custom.settingsHint": "Подробные параметры — в «Настройки > Выбор сжатия контекста».",
|
|
2339
2437
|
"custom.sessionScope": "Сохранённые изменения применяются, когда текущий runtime сжатия впервые наблюдает Session. Session, уже наблюдаемая этим runtime, сохраняет свою замороженную стратегию.",
|
|
@@ -2590,6 +2688,7 @@ window.__ModuleLoader__.load({
|
|
|
2590
2688
|
resetCustom: () => writeAndConfirm(() => scope.set("custom", structuredClone(DEFAULT_CUSTOM_COMPRESSION_POLICY)), (settings) => isCustomCompressionPolicy(settings.custom) && sameCustomPolicy(settings.custom, DEFAULT_CUSTOM_COMPRESSION_POLICY)),
|
|
2591
2689
|
saveAutoCompact: (thresholdPercent) => writeAndConfirm(() => scope.set("autoCompact", { thresholdPercent }), (settings) => settings.autoCompact.thresholdPercent === thresholdPercent),
|
|
2592
2690
|
saveCodeSkeleton: (enabled) => writeAndConfirm(() => scope.set("codeSkeleton", { enabled }), (settings) => settings.codeSkeleton.enabled === enabled),
|
|
2691
|
+
saveIntentSummary: (enabled) => writeAndConfirm(() => scope.set("intentSummary", { enabled }), (settings) => settings.intentSummary.enabled === enabled),
|
|
2593
2692
|
savePresetOptions: (options) => {
|
|
2594
2693
|
const ops = planPresetOptionsOps(scope.getSnapshot().value?.presetOptions, options);
|
|
2595
2694
|
if (ops.length === 0) return Promise.resolve();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { I as priceOfficialDeepSeekUsage, R as getSavingsLedger, a as getLastIntentFold, i as getAdvisorState, n as INTENT_GATE_GROWTH_TOKENS, o as getObservedIntentEnabled, p as setSummaryOverride, s as getSummaryOverride, t as INTENT_GATE_FLOOR_FRACTION, v as DEFAULT_CONTEXT_COMPRESSION_SETTINGS } from "./intent-gate.js";
|
|
2
2
|
import z from "@deepseek-ai/schemastery";
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
4
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
@@ -75,6 +75,96 @@ async function buildEstimatorCatalog(deps) {
|
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
77
|
//#endregion
|
|
78
|
+
//#region src/runtime/summary-command.ts
|
|
79
|
+
const SUMMARY_COMMAND_NAME = "ctx-summary";
|
|
80
|
+
const USAGE = "Usage: /ctx-summary off|on|status";
|
|
81
|
+
/** Parse the raw argument string; `undefined` = unrecognized (usage error). */
|
|
82
|
+
function parseSummaryCommandArgs(rawInput) {
|
|
83
|
+
const token = rawInput.trim().toLowerCase();
|
|
84
|
+
if (token === "off" || token === "on" || token === "status") return token;
|
|
85
|
+
}
|
|
86
|
+
function describeFold(sessionId) {
|
|
87
|
+
const fold = getLastIntentFold(sessionId);
|
|
88
|
+
if (fold === void 0) return "none";
|
|
89
|
+
return `turn ${fold.turn}, seq ${fold.startSeq}..${fold.endSeq}`;
|
|
90
|
+
}
|
|
91
|
+
/** Human-facing status line; observability only, never a decision input. */
|
|
92
|
+
function formatSummaryStatus(sessionId) {
|
|
93
|
+
const override = getSummaryOverride(sessionId);
|
|
94
|
+
const enabled = getObservedIntentEnabled(sessionId);
|
|
95
|
+
const enabledText = enabled === void 0 ? "unknown (gate not evaluated yet)" : enabled ? "yes" : "no";
|
|
96
|
+
return [
|
|
97
|
+
`ctx-summary status:`,
|
|
98
|
+
` override: ${override ?? "default (settings-driven)"}`,
|
|
99
|
+
` intentSummary enabled (settings): ${enabledText}`,
|
|
100
|
+
` gate: floor >${Math.round(INTENT_GATE_FLOOR_FRACTION * 100)}% of window AND growth >${INTENT_GATE_GROWTH_TOKENS} tokens since last fold`,
|
|
101
|
+
` last fold: ${describeFold(sessionId)}`
|
|
102
|
+
].join("\n");
|
|
103
|
+
}
|
|
104
|
+
/** Resolve the invoking agent's session id (`''` when the host exposes none). */
|
|
105
|
+
function sessionIdOf(agent) {
|
|
106
|
+
const session = agent?.session;
|
|
107
|
+
if (session === void 0 || session.id === void 0 || session.id === null) return "";
|
|
108
|
+
return String(session.id);
|
|
109
|
+
}
|
|
110
|
+
/** Best-effort `CommandDefinitionId` brand; `undefined` on stripped hosts (registered without it). */
|
|
111
|
+
async function loadCommandDefinitionId() {
|
|
112
|
+
try {
|
|
113
|
+
return (await import("@deepseek-ai/dsh-commands")).CommandDefinitionId;
|
|
114
|
+
} catch {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Mount `/ctx-summary` for every composed human-command adapter. Never
|
|
120
|
+
* throws: the command is a convenience surface, and a host without the
|
|
121
|
+
* commands service (or with an incompatible registry shape) simply runs
|
|
122
|
+
* without it.
|
|
123
|
+
*/
|
|
124
|
+
function registerSummaryCommand(ctx) {
|
|
125
|
+
ctx.inject(["commands"], (injected) => {
|
|
126
|
+
const commands = injected.commands;
|
|
127
|
+
if (commands === void 0 || typeof commands.register !== "function") return;
|
|
128
|
+
(async () => {
|
|
129
|
+
try {
|
|
130
|
+
const definitionId = await loadCommandDefinitionId();
|
|
131
|
+
await commands.register({
|
|
132
|
+
name: SUMMARY_COMMAND_NAME,
|
|
133
|
+
description: "Turn-tail intent summary: temporarily disable/resume or inspect status",
|
|
134
|
+
...definitionId === void 0 ? {} : { definitionId: definitionId("dsh-context-compression-improved/ctx-summary") },
|
|
135
|
+
handler: async (invocation) => {
|
|
136
|
+
const args = parseSummaryCommandArgs(typeof invocation.rawInput === "string" ? invocation.rawInput : "");
|
|
137
|
+
if (args === void 0) return {
|
|
138
|
+
kind: "error",
|
|
139
|
+
text: USAGE
|
|
140
|
+
};
|
|
141
|
+
const sessionId = sessionIdOf(invocation.agent);
|
|
142
|
+
if (args === "status") {
|
|
143
|
+
if (sessionId === "") return {
|
|
144
|
+
kind: "error",
|
|
145
|
+
text: "ctx-summary: no session is attached to this invocation"
|
|
146
|
+
};
|
|
147
|
+
return {
|
|
148
|
+
kind: "success",
|
|
149
|
+
text: formatSummaryStatus(sessionId)
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
if (sessionId === "") return {
|
|
153
|
+
kind: "error",
|
|
154
|
+
text: "ctx-summary: no session is attached to this invocation"
|
|
155
|
+
};
|
|
156
|
+
setSummaryOverride(sessionId, args);
|
|
157
|
+
return {
|
|
158
|
+
kind: "success",
|
|
159
|
+
text: args === "off" ? "ctx-summary: turn-tail intent summary paused for this session (until process restart or `/ctx-summary on`)" : "ctx-summary: turn-tail intent summary resumed for this session (numeric gates still apply)"
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
} catch {}
|
|
164
|
+
})();
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
//#endregion
|
|
78
168
|
//#region src/preset-overlay.ts
|
|
79
169
|
/** Plugin-owned, reversible compression overlays for native agent presets. */
|
|
80
170
|
/**
|
|
@@ -862,6 +952,7 @@ function apply(ctx, config = {}) {
|
|
|
862
952
|
if (config.estimatorCatalogRoute === true) registerEstimatorCatalogRoute(ctx);
|
|
863
953
|
registerSavingsRoute(ctx);
|
|
864
954
|
if (config.advisorReportRoute === true) registerAdvisorReportRoute(ctx);
|
|
955
|
+
registerSummaryCommand(ctx);
|
|
865
956
|
if (config.presetOverlay !== true) return;
|
|
866
957
|
ctx.inject(["agentPresets"], (presetsCtx) => {
|
|
867
958
|
const installation = decorateAgentPresets(presetsCtx.agentPresets, {
|
|
@@ -875,6 +875,20 @@ function parseCodeSkeletonSettings(value) {
|
|
|
875
875
|
return { enabled };
|
|
876
876
|
}
|
|
877
877
|
/**
|
|
878
|
+
* Strictly parse the persisted intentSummary section. Mirrors the codeSkeleton
|
|
879
|
+
* section semantics: absent inherits the lossless `false` default, while a
|
|
880
|
+
* present-but-invalid section is an explicitly invalid document.
|
|
881
|
+
*/
|
|
882
|
+
function parseIntentSummarySettings(value) {
|
|
883
|
+
if (value === void 0) return { enabled: false };
|
|
884
|
+
if (!isPlainRecord(value)) throw new TypeError("Context-compression intentSummary must be a plain object");
|
|
885
|
+
const keys = Object.keys(value);
|
|
886
|
+
if (keys.length !== 1 || keys[0] !== "enabled") throw new TypeError(`Context-compression intentSummary: expected exactly "enabled", got "${keys.join("\", \"")}"`);
|
|
887
|
+
const enabled = value.enabled;
|
|
888
|
+
if (typeof enabled !== "boolean") throw new TypeError("Context-compression intentSummary.enabled must be a boolean");
|
|
889
|
+
return { enabled };
|
|
890
|
+
}
|
|
891
|
+
/**
|
|
878
892
|
* Parse the optional tokenpilot-inspired preset sub-capability section. Absent
|
|
879
893
|
* inherits the preset defaults; present-but-invalid is rejected, mirroring the
|
|
880
894
|
* codeSkeleton section semantics.
|
|
@@ -981,7 +995,8 @@ const DEFAULT_CONTEXT_COMPRESSION_SETTINGS = {
|
|
|
981
995
|
profile: "balanced",
|
|
982
996
|
custom: structuredClone(DEFAULT_CUSTOM_COMPRESSION_POLICY),
|
|
983
997
|
autoCompact: { thresholdPercent: AUTO_COMPACT_THRESHOLD_LIMITS.default },
|
|
984
|
-
codeSkeleton: { enabled: false }
|
|
998
|
+
codeSkeleton: { enabled: false },
|
|
999
|
+
intentSummary: { enabled: false }
|
|
985
1000
|
};
|
|
986
1001
|
/**
|
|
987
1002
|
* Parse one settings document with the persisted-section semantics: `undefined`
|
|
@@ -999,17 +1014,19 @@ const ContextCompressionSettingsSchema = z.transform(z.any().required(), (value)
|
|
|
999
1014
|
if (!isPlainRecord(value)) throw new TypeError("Context-compression settings must be a plain object");
|
|
1000
1015
|
assertPlainDataTree(value);
|
|
1001
1016
|
const candidate = structuredClone(value);
|
|
1002
|
-
const unknown = Object.keys(candidate).find((key) => key !== "profile" && key !== "custom" && key !== "autoCompact" && key !== "codeSkeleton" && key !== "presetOptions");
|
|
1017
|
+
const unknown = Object.keys(candidate).find((key) => key !== "profile" && key !== "custom" && key !== "autoCompact" && key !== "codeSkeleton" && key !== "intentSummary" && key !== "presetOptions");
|
|
1003
1018
|
if (unknown !== void 0) throw new TypeError(`Context-compression settings: unknown key "${unknown}"`);
|
|
1004
1019
|
assertPresentSection(candidate, "profile", isSupportedProfile);
|
|
1005
1020
|
assertPresentSection(candidate, "custom", isUsableCustomDocument);
|
|
1006
1021
|
const autoCompact = parseAutoCompactSettings(candidate.autoCompact);
|
|
1007
1022
|
const codeSkeleton = parseCodeSkeletonSettings(candidate.codeSkeleton);
|
|
1023
|
+
const intentSummary = parseIntentSummarySettings(candidate.intentSummary);
|
|
1008
1024
|
const presetOptions = parsePresetOptionsSettings(candidate.presetOptions);
|
|
1009
1025
|
return {
|
|
1010
1026
|
...contextCompressionSettingsInputSchema(candidate),
|
|
1011
1027
|
autoCompact,
|
|
1012
1028
|
codeSkeleton,
|
|
1029
|
+
intentSummary,
|
|
1013
1030
|
...presetOptions === void 0 ? {} : { presetOptions }
|
|
1014
1031
|
};
|
|
1015
1032
|
}).default(DEFAULT_CONTEXT_COMPRESSION_SETTINGS);
|
|
@@ -1460,5 +1477,76 @@ function invalidateOnTaskChange(state, todoVersion) {
|
|
|
1460
1477
|
state.lastSummaryTurn = -1;
|
|
1461
1478
|
return true;
|
|
1462
1479
|
}
|
|
1480
|
+
/**
|
|
1481
|
+
* `/ctx-summary off|on` overrides, keyed by session id (string). The command
|
|
1482
|
+
* handler only sees `invocation.agent.session.id`, not the pruner's Session
|
|
1483
|
+
* object, so these are id-keyed rather than WeakMap'd. Entries are two-char
|
|
1484
|
+
* strings per session and cleared whenever the override is lifted.
|
|
1485
|
+
*/
|
|
1486
|
+
const summaryOverrides = /* @__PURE__ */ new Map();
|
|
1487
|
+
/** Read the session's `/ctx-summary` override; `undefined` = default (settings-driven). */
|
|
1488
|
+
function getSummaryOverride(sessionId) {
|
|
1489
|
+
return summaryOverrides.get(sessionId);
|
|
1490
|
+
}
|
|
1491
|
+
/** Set or clear (`undefined`) the session's `/ctx-summary` override. */
|
|
1492
|
+
function setSummaryOverride(sessionId, value) {
|
|
1493
|
+
if (value === void 0) summaryOverrides.delete(sessionId);
|
|
1494
|
+
else summaryOverrides.set(sessionId, value);
|
|
1495
|
+
}
|
|
1496
|
+
/** Last observed `intentSummary.enabled` for a session, for `/ctx-summary status`. */
|
|
1497
|
+
const lastObservedIntentEnabled = /* @__PURE__ */ new Map();
|
|
1498
|
+
/** Record the gate input the pass last evaluated for this session. */
|
|
1499
|
+
function observeIntentEnabled(sessionId, enabled) {
|
|
1500
|
+
lastObservedIntentEnabled.set(sessionId, enabled);
|
|
1501
|
+
}
|
|
1502
|
+
/** The settings-side enabled flag last observed for the session, if any. */
|
|
1503
|
+
function getObservedIntentEnabled(sessionId) {
|
|
1504
|
+
return lastObservedIntentEnabled.get(sessionId);
|
|
1505
|
+
}
|
|
1506
|
+
const lastIntentFolds = /* @__PURE__ */ new Map();
|
|
1507
|
+
/** Record a landed intent fold for the session (newest wins). */
|
|
1508
|
+
function recordIntentFold(sessionId, record) {
|
|
1509
|
+
lastIntentFolds.set(sessionId, record);
|
|
1510
|
+
}
|
|
1511
|
+
/** The most recent landed intent fold for the session, if any. */
|
|
1512
|
+
function getLastIntentFold(sessionId) {
|
|
1513
|
+
return lastIntentFolds.get(sessionId);
|
|
1514
|
+
}
|
|
1515
|
+
//#endregion
|
|
1516
|
+
//#region src/runtime/tokenpilot/intent-gate.ts
|
|
1517
|
+
/**
|
|
1518
|
+
* Turn-tail intent-summary growth gate (TokenPilot-inspired E2).
|
|
1519
|
+
*
|
|
1520
|
+
* Pure decision helper evaluated at the turn-boundary postflight: it decides
|
|
1521
|
+
* whether this turn may spend a summary-writer LLM call and stage a fold for
|
|
1522
|
+
* the next pressure round. The gate is deliberately conservative — every
|
|
1523
|
+
* unresolved input (unknown context window, non-finite counters) fails closed
|
|
1524
|
+
* toward "do not run", because a skipped fold is free while a wasted summary
|
|
1525
|
+
* call is not. Content safety is unaffected either way: fail-open semantics
|
|
1526
|
+
* live in the fold landing path, not here.
|
|
1527
|
+
*/
|
|
1528
|
+
/** Floor: the live surface must exceed this fraction of the context window. */
|
|
1529
|
+
const INTENT_GATE_FLOOR_FRACTION = .45;
|
|
1530
|
+
/** Growth: the live surface must have grown by more than this since the last landed fold. */
|
|
1531
|
+
const INTENT_GATE_GROWTH_TOKENS = 5e4;
|
|
1532
|
+
function isUsableNumber(value) {
|
|
1533
|
+
return Number.isFinite(value) && value >= 0;
|
|
1534
|
+
}
|
|
1535
|
+
/** Same evaluation with the reason attached, for audits and `/ctx-summary status`. */
|
|
1536
|
+
function evaluateIntentGate(input) {
|
|
1537
|
+
const snapshot = (decision, reason) => ({
|
|
1538
|
+
...input,
|
|
1539
|
+
decision,
|
|
1540
|
+
reason
|
|
1541
|
+
});
|
|
1542
|
+
if (!input.enabled) return snapshot(false, "disabled");
|
|
1543
|
+
if (input.override === "off") return snapshot(false, "override-off");
|
|
1544
|
+
if (!isUsableNumber(input.liveTokens)) return snapshot(false, "below-floor");
|
|
1545
|
+
if (input.contextWindow === void 0 || !isUsableNumber(input.contextWindow)) return snapshot(false, "no-window");
|
|
1546
|
+
if (!(input.liveTokens > input.contextWindow * .45)) return snapshot(false, "below-floor");
|
|
1547
|
+
if (!isUsableNumber(input.baselineTokens)) return snapshot(false, "below-growth");
|
|
1548
|
+
if (!(input.liveTokens - input.baselineTokens > 5e4)) return snapshot(false, "below-growth");
|
|
1549
|
+
return snapshot(true, "passed");
|
|
1550
|
+
}
|
|
1463
1551
|
//#endregion
|
|
1464
|
-
export {
|
|
1552
|
+
export { resolveCustomPolicy as A, isCompressionProfile as C, resolvePolicy as D, resolveConfig as E, decimalRateNanoUnits as F, priceOfficialDeepSeekUsage as I, resolveOfficialDeepSeekPrice as L, deepFreeze as M, COMPRESSION_PROFILES as N, CustomCompressionPolicySchema as O, DEEPSEEK_OFFICIAL_PRICE_CATALOG_VERSION as P, getSavingsLedger as R, codePointLength as S, parseContextCompressionSettings as T, DEFAULTS as _, getLastIntentFold as a, charsForTokens as b, invalidateOnTaskChange as c, recordRecertified as d, recordScore as f, ContextCompressionSettingsSchema as g, CONTEXT_COMPRESSION_SETTINGS_NAMESPACE as h, getAdvisorState as i, assertNever as j, DEFAULT_CUSTOM_COMPRESSION_POLICY as k, observeIntentEnabled as l, AUTO_COMPACT_THRESHOLD_LIMITS as m, INTENT_GATE_GROWTH_TOKENS as n, getObservedIntentEnabled as o, setSummaryOverride as p, evaluateIntentGate as r, getSummaryOverride as s, INTENT_GATE_FLOOR_FRACTION as t, recordIntentFold as u, DEFAULT_CONTEXT_COMPRESSION_SETTINGS as v, isValidAutoCompactThresholdPercent as w, charsToTokens as x, PRUNE_MARKER as y };
|
|
@@ -68,6 +68,13 @@ interface AutoCompactSettings {
|
|
|
68
68
|
interface CodeSkeletonSettings {
|
|
69
69
|
enabled: boolean;
|
|
70
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Orthogonal turn-tail intent-summary gate, mirrored browser-safe from the
|
|
73
|
+
* runtime: independent of every profile, default off.
|
|
74
|
+
*/
|
|
75
|
+
interface IntentSummarySettings {
|
|
76
|
+
enabled: boolean;
|
|
77
|
+
}
|
|
71
78
|
/** Browser-safe mirror of the runtime presetOptions section. */
|
|
72
79
|
interface PresetOptionsSettings {
|
|
73
80
|
readonly dedupeToolResults?: boolean;
|
|
@@ -98,6 +105,8 @@ interface ContextCompressionSettings {
|
|
|
98
105
|
autoCompact: AutoCompactSettings;
|
|
99
106
|
/** Code-skeleton reducer gate captured independently of `profile`. */
|
|
100
107
|
codeSkeleton: CodeSkeletonSettings;
|
|
108
|
+
/** Turn-tail intent-summary gate captured independently of `profile`. */
|
|
109
|
+
intentSummary: IntentSummarySettings;
|
|
101
110
|
/** Optional tokenpilot-inspired sub-capability overrides (presence-validated only). */
|
|
102
111
|
presetOptions?: PresetOptionsSettings;
|
|
103
112
|
}
|
|
@@ -134,6 +134,15 @@ interface AutoCompactSettings {
|
|
|
134
134
|
interface CodeSkeletonSettings {
|
|
135
135
|
enabled: boolean;
|
|
136
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* Orthogonal turn-tail intent-summary gate. Independent of every profile:
|
|
139
|
+
* when enabled, the turn-boundary growth gate may fold consumed-increment
|
|
140
|
+
* tool results into an LLM-written intent block (skeleton + verbatim error
|
|
141
|
+
* lines are kept; the model only ever writes the summary segment).
|
|
142
|
+
*/
|
|
143
|
+
interface IntentSummarySettings {
|
|
144
|
+
enabled: boolean;
|
|
145
|
+
}
|
|
137
146
|
/**
|
|
138
147
|
* Persisted sub-capability overrides for the `tokenpilot-inspired` preset.
|
|
139
148
|
* Absent fields inherit the preset defaults; the section is only meaningful
|
|
@@ -173,6 +182,8 @@ interface ContextCompressionSettings {
|
|
|
173
182
|
autoCompact: AutoCompactSettings;
|
|
174
183
|
/** Code-skeleton reducer gate snapped independently of `profile`. */
|
|
175
184
|
codeSkeleton: CodeSkeletonSettings;
|
|
185
|
+
/** Turn-tail intent-summary gate snapped independently of `profile`. */
|
|
186
|
+
intentSummary: IntentSummarySettings;
|
|
176
187
|
/** Optional tokenpilot-inspired sub-capability overrides; absent inherits preset defaults. */
|
|
177
188
|
presetOptions?: PresetOptionsSettings;
|
|
178
189
|
}
|
|
@@ -397,6 +408,32 @@ interface EstimatorFailures {
|
|
|
397
408
|
cooldownUntil: number;
|
|
398
409
|
}
|
|
399
410
|
//#endregion
|
|
411
|
+
//#region src/runtime/tokenpilot/intent-input-mask.d.ts
|
|
412
|
+
type IntentRole = 'read-mask' | 'write-keep' | 'conservative';
|
|
413
|
+
//#endregion
|
|
414
|
+
//#region src/runtime/tokenpilot/intent-fold.d.ts
|
|
415
|
+
/** One staged fold awaiting the next pressure round. */
|
|
416
|
+
interface PendingIntentFold {
|
|
417
|
+
readonly createdAt: number;
|
|
418
|
+
readonly turn: number;
|
|
419
|
+
/** Inclusive seq span of the folded candidates. */
|
|
420
|
+
readonly startSeq: number;
|
|
421
|
+
readonly endSeq: number;
|
|
422
|
+
/** LLM-written summary segment (fail-open parsed, char-capped). */
|
|
423
|
+
readonly summary: string;
|
|
424
|
+
/** Verbatim error lines collected across the batch (never LLM-revoiced). */
|
|
425
|
+
readonly errorLines: readonly string[];
|
|
426
|
+
/** Per-candidate faces: read-mask single lines ride the block, keep-class lines prompt-only. */
|
|
427
|
+
readonly records: ReadonlyArray<{
|
|
428
|
+
readonly seq: number;
|
|
429
|
+
readonly role: IntentRole;
|
|
430
|
+
readonly toolName: string;
|
|
431
|
+
readonly line: string;
|
|
432
|
+
}>;
|
|
433
|
+
/** Characters consumed by the summary-writer call (credit accounting). */
|
|
434
|
+
readonly summaryCallChars: number;
|
|
435
|
+
}
|
|
436
|
+
//#endregion
|
|
400
437
|
//#region src/pruner/state.d.ts
|
|
401
438
|
/** Mutable per-session state bag used inside {@link ToolResultPruner}. */
|
|
402
439
|
interface PrunerState {
|
|
@@ -430,6 +467,12 @@ interface PrunerState {
|
|
|
430
467
|
readonly estimatorRemainingTurns: WeakMap<Session, number>;
|
|
431
468
|
/** Per-session advisor side channel, constructed once with the advisor overrides. */
|
|
432
469
|
readonly advisorChannels: WeakMap<Session, SideChannel>;
|
|
470
|
+
/** Staged intent fold awaiting the next pressure round (at most one per session). */
|
|
471
|
+
readonly pendingIntentFolds: WeakMap<Session, PendingIntentFold>;
|
|
472
|
+
/** Landed intent-fold seqs: fold-once, never reconsidered by any later stage. */
|
|
473
|
+
readonly intentFoldedSeqs: WeakMap<Session, Set<number>>;
|
|
474
|
+
/** Live-surface tokens when the last intent fold landed (growth-gate baseline). */
|
|
475
|
+
readonly intentBaselines: WeakMap<Session, number>;
|
|
433
476
|
}
|
|
434
477
|
//#endregion
|
|
435
478
|
//#region src/runtime/custom-policy.d.ts
|
|
@@ -759,6 +802,22 @@ declare class ToolResultPruner extends Service {
|
|
|
759
802
|
* reads, so the default configuration adds exactly zero behavior.
|
|
760
803
|
*/
|
|
761
804
|
private postflightAdvisorPass;
|
|
805
|
+
/**
|
|
806
|
+
* Fire-and-forget postflight: evaluate the growth gate, and only when it
|
|
807
|
+
* passes, select the consumed increment OUTSIDE the protected working set,
|
|
808
|
+
* mask it to semantic-role records, and spend ONE summary-writer call. The
|
|
809
|
+
* verdict stages as a pending fold that the NEXT pressure round lands via
|
|
810
|
+
* the ordinary plan/apply machinery — the synchronous decision path never
|
|
811
|
+
* waits on an LLM.
|
|
812
|
+
*/
|
|
813
|
+
private postflightIntentFoldPass;
|
|
814
|
+
/**
|
|
815
|
+
* Convert a staged pending fold into per-candidate planned replacements
|
|
816
|
+
* (reducer `intent-summary`). Fail-open: a candidate that would grow, is
|
|
817
|
+
* rich-content, or no longer exists keeps its original text. Returns
|
|
818
|
+
* `undefined` when there is nothing (or no longer anything) to fold.
|
|
819
|
+
*/
|
|
820
|
+
private applyPendingIntentFold;
|
|
762
821
|
/**
|
|
763
822
|
* Monotonic per-session turn clock for advisory records. Bumped by the agent
|
|
764
823
|
* loop payloads (`pre-step`); passes without a turn coordinate reuse the last
|