dsh-thinking-levels 4.4.18 → 4.4.20
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 +14 -0
- package/README.md +10 -2
- package/dsh.plugin.json +1 -1
- package/lib/auto-schedule-projection.d.ts +15 -0
- package/lib/auto-schedule-projection.js +24 -2
- package/lib/client.js +46 -3
- package/lib/client.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.4.20
|
|
4
|
+
|
|
5
|
+
- **connect 类插件兼容矩阵(issue #10 后续收口,无 src/ 变更)。** 普查四家 connect/聚合插件当日版本的 adapter 形态——`@dmh2002/dsh-connect-qoder` 1.27.1 / `dsh-connect-trae` 4.18.5 / `dsh-connect-workbuddy` 5.30.0(dingminhua,ES class + 自有默认档广告)、`dsh-our-free-model`(Ebony-Vinyl,plain class + prepareCall 内部直调 this.resolveModel)——全部为普通对象形态、无 Proxy/freeze、不回读 `llm.adapters`,4.4.18 的 registry-entry facade 方案零返工成立。
|
|
6
|
+
- 新增 `tests/adapter-matrix.spec.ts`(28 例):六形态(hub write-through Proxy / vision-router 只读 Proxy / connect class / 内调 class / frozen / getter-only)× 四行为(不写第三方对象 / 不递归 / 八成员透传 + this 绑定 / 幂等不套娃)表驱动全绿;handle.replace 拓扑瞬态用例锁死收敛(重挂裸 adapter → `adapters-updated` 重包,`Object.is` 同一 facade);混合流用例锁死 our-free-model 式「重注册新实例 + 连续 emit」不套娃。全量回归 285/285。
|
|
7
|
+
- README 新增「Third-party adapter compatibility」契约段,面向 connect 插件作者写明三承诺:永不写入第三方对象 / 只替换注册表条目 / 每 inner adapter 单一 facade 幂等标记。
|
|
8
|
+
|
|
9
|
+
## 4.4.19
|
|
10
|
+
|
|
11
|
+
- **修复 issue #11:选中 auto 时界面看不到实际生效档位。** 报告人观察到「选 Auto 后请求仍以 high 发出,`lastUsed` 一直是 high、`pending` 一直是 auto」。核实结论:auto 不上送**是设计**(它是 scheduler sentinel,请求期由 `decideEffort` 按工具采样窗口解析成具体档位,有降档行为),`lastUsed`/`pending` 是宿主 `modelSelection` 投影的固有语义(`lastUsed` 每次 `request/header` 被重写、`pending` 匹配 header 提交后清空,二者都不承载用户意图 —— 见 `auto-schedule-projection.ts` 模块注释)。**真正的缺陷是显示**:`tlAutoSchedule` 投影新增 `lastEffective` 字段,折叠已提交的 `request/header` 中的 effective effort(宿主在 `dsh-llm` 里把解析结果写进该事件),选择器 chip 据此显示 `Auto → high`。
|
|
12
|
+
- 为什么不能复用 `directory.current.reasoningEffort`:宿主从 `modelSelection.next`(**下一步**要用的选择,即用户意图)派生它(`dsh-client-ui-model-selection/src/client/directory.ts:178`),选中 auto 时它永远是 `'auto'`,所以旧的 `→ level` 提示永远不显示。
|
|
13
|
+
- 投影 `stateVersion` 1 → 2(形状变更);历史会话不受影响 —— 投影是日志的折叠视图,冷读会重新折叠出 `samples`/`userEffort`/`lastEffective`。
|
|
14
|
+
- 降级:投影通道缺失(旧宿主、冷会话)时 `lastEffectiveEffort` 为 `undefined`,chip 退回只显示意图标签,不报错(抛错的 inject 会让整个座位让回官方选择器)。
|
|
15
|
+
- 新增 7 个用例:`request/header` 折叠(正常/缺失/非字符串)、引用稳定性(`Object.is` 门控)、冷读重建、注入面降级。
|
|
16
|
+
|
|
3
17
|
## 4.4.18
|
|
4
18
|
|
|
5
19
|
- **修复 issue #10(同时覆盖 #9 的形态):与第三方 adapter 包装器同开时 `resolveModel` 互递归爆栈 / 改写报错。**
|
package/README.md
CHANGED
|
@@ -163,9 +163,17 @@ The scheduling policy is the same source as [dsh-tool-turbo](https://github.com/
|
|
|
163
163
|
|
|
164
164
|
**Where the samples come from (4.4.7+).** The scheduler folds `tool/call` events into a Session projection (`tlAutoSchedule`), so it sees real tool history on every host from 0.1.2-rc.1 on; the pre-4.4.7 `session.events` read only ever produced samples on 0.1.0-rc.8. The session's explicit pick is folded from `model/selection` events, so a level the host echoes back can never be mistaken for a manual choice. Known limitation: host `0.1.0-rc.8` exposes no `stateOf` on its projection registry (legacy plane contract), so that one line keeps the old array read — scheduling works there, the echo correction does not.
|
|
165
165
|
|
|
166
|
-
##
|
|
166
|
+
## Third-party adapter compatibility (contract for connect-plugin authors)
|
|
167
|
+
|
|
168
|
+
TL reads the `llm.adapters` registry to advertise `auto` in the model directory, and makes three promises to every plugin that registers adapters there (providers-hub, the connect-* family, our-free-model, vision-router, …):
|
|
169
|
+
|
|
170
|
+
1. **TL never writes to your adapter object.** Since 4.4.18 the advertisement replaces the *registry entry* with a plain-object forwarding facade instead of assigning `adapter.resolveModel` (the old in-place write recursed against providers-hub's write-through Proxy — issue #10 — and threw against vision-router's read-only Proxy — issue #9).
|
|
171
|
+
2. **TL only swaps the registry entry.** The host re-reads `adapters.get(provider)` on every call, so the swap is transparent to you; your adapter stays byte-for-byte untouched, frozen and getter-only shapes included.
|
|
172
|
+
3. **One facade per inner adapter, idempotent.** Re-runs (every `llm/adapters-updated`) never stack a second layer, and one adapter serving several provider routes keeps a single facade identity (the host compares adapter identity to preserve replay state).
|
|
167
173
|
|
|
168
|
-
|
|
174
|
+
What you may rely on: your own `resolveModel` post-processing (default efforts, badges) runs first; TL appends `auto` (and gated `low`) *after* it. Calls made internally on `this` (e.g. `prepareCall` → `this.resolveModel`) bypass the facade by design — only directory/selector flows through the registry. The full shape × behaviour matrix lives in `tests/adapter-matrix.spec.ts`.
|
|
175
|
+
|
|
176
|
+
## Install
|
|
169
177
|
|
|
170
178
|
```bash
|
|
171
179
|
# 1. install the plugin into a profile from npm (web shown; any profile works)
|
package/dsh.plugin.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "dsh-external/dsh-thinking-levels",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.20",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"description": "thinking-level (reasoning_effort) control — auto-adjust per tool round, with optional manual lock and per-tool timing telemetry.",
|
|
6
6
|
"engines": {
|
|
@@ -44,6 +44,20 @@ export interface AutoScheduleState {
|
|
|
44
44
|
samples: readonly ToolCallSample[];
|
|
45
45
|
/** Effort explicitly picked in this session, or null when never picked. */
|
|
46
46
|
userEffort: string | null;
|
|
47
|
+
/**
|
|
48
|
+
* The effort the last request ACTUALLY carried, folded from the committed
|
|
49
|
+
* `request/header` (the host writes the effective value there —
|
|
50
|
+
* `dsh-llm/lib/index.js:2298-2308`).
|
|
51
|
+
*
|
|
52
|
+
* Issue #11: with `auto` selected the UI showed "Auto" while every request
|
|
53
|
+
* went out as a concrete level, so the user could not tell what was really
|
|
54
|
+
* sent. The host's `modelSelection.lastUsed` cannot answer that either (it is
|
|
55
|
+
* rewritten on every header, i.e. it holds our own output — see the module
|
|
56
|
+
* doc), so the answer has to come from this projection.
|
|
57
|
+
*
|
|
58
|
+
* `null` until the session's first committed request.
|
|
59
|
+
*/
|
|
60
|
+
lastEffective: string | null;
|
|
47
61
|
}
|
|
48
62
|
/**
|
|
49
63
|
* Fold one committed Session event into the auto-schedule state.
|
|
@@ -72,6 +86,7 @@ export declare function buildAutoScheduleDefinition(): {
|
|
|
72
86
|
argsSize: z.ZodNumber;
|
|
73
87
|
}, z.core.$strip>>;
|
|
74
88
|
userEffort: z.ZodNullable<z.ZodString>;
|
|
89
|
+
lastEffective: z.ZodNullable<z.ZodString>;
|
|
75
90
|
}, z.core.$strip>;
|
|
76
91
|
init: () => AutoScheduleState;
|
|
77
92
|
apply: typeof applyAutoSchedule;
|
|
@@ -42,9 +42,10 @@ export const AUTO_SCHEDULE_KEY = 'tlAutoSchedule';
|
|
|
42
42
|
const stateSchema = z.object({
|
|
43
43
|
samples: z.array(z.object({ name: z.string(), argsSize: z.number() })),
|
|
44
44
|
userEffort: z.string().nullable(),
|
|
45
|
+
lastEffective: z.string().nullable(),
|
|
45
46
|
});
|
|
46
47
|
/** Initial folded state (also the shape every cold read starts from). */
|
|
47
|
-
const initAutoSchedule = () => ({ samples: [], userEffort: null });
|
|
48
|
+
const initAutoSchedule = () => ({ samples: [], userEffort: null, lastEffective: null });
|
|
48
49
|
/**
|
|
49
50
|
* Fold one committed Session event into the auto-schedule state.
|
|
50
51
|
*
|
|
@@ -78,6 +79,23 @@ export function applyAutoSchedule(state, event) {
|
|
|
78
79
|
const userEffort = typeof raw === 'string' && raw.length > 0 ? raw : null;
|
|
79
80
|
return userEffort === state.userEffort ? state : { ...state, userEffort };
|
|
80
81
|
}
|
|
82
|
+
if (type === 'request/header') {
|
|
83
|
+
// Issue #11: the header carries the effort this request actually went out
|
|
84
|
+
// with — the host resolves and commits the effective value here, so it is
|
|
85
|
+
// the only durable record of what `auto` turned into.
|
|
86
|
+
const data = event.data;
|
|
87
|
+
const header = typeof data === 'object' && data !== null
|
|
88
|
+
? data.header
|
|
89
|
+
: undefined;
|
|
90
|
+
const config = typeof header === 'object' && header !== null
|
|
91
|
+
? header.config
|
|
92
|
+
: undefined;
|
|
93
|
+
const raw = typeof config === 'object' && config !== null
|
|
94
|
+
? config.reasoningEffort
|
|
95
|
+
: undefined;
|
|
96
|
+
const lastEffective = typeof raw === 'string' && raw.length > 0 ? raw : null;
|
|
97
|
+
return lastEffective === state.lastEffective ? state : { ...state, lastEffective };
|
|
98
|
+
}
|
|
81
99
|
return state;
|
|
82
100
|
}
|
|
83
101
|
/**
|
|
@@ -89,7 +107,11 @@ export function applyAutoSchedule(state, event) {
|
|
|
89
107
|
export function buildAutoScheduleDefinition() {
|
|
90
108
|
return {
|
|
91
109
|
key: AUTO_SCHEDULE_KEY,
|
|
92
|
-
|
|
110
|
+
// Bumped 1 → 2 when `lastEffective` joined the state (issue #11): the host
|
|
111
|
+
// validates against `stateSchema` per version, so a shape change must raise
|
|
112
|
+
// it. Historical sessions are not lost — the state is a fold over the log,
|
|
113
|
+
// so a cold read rebuilds samples/userEffort/lastEffective from the events.
|
|
114
|
+
stateVersion: 2,
|
|
93
115
|
stateSchema,
|
|
94
116
|
init: initAutoSchedule,
|
|
95
117
|
apply: applyAutoSchedule,
|
package/lib/client.js
CHANGED
|
@@ -2770,7 +2770,7 @@ body:not([data-ds-dark-theme]) .${ZONE_CLASS}[data-top="1"] .${TRACK_CLASS} { an
|
|
|
2770
2770
|
* (the "max context window" editor moved into each line).
|
|
2771
2771
|
* @param props - injected directory + config forms, session seat, copy.
|
|
2772
2772
|
*/
|
|
2773
|
-
function ModelPanel({ directory, piAiScope, deepseekScope, tlScope, sessionId, t }) {
|
|
2773
|
+
function ModelPanel({ directory, piAiScope, deepseekScope, tlScope, sessionId, lastEffectiveEffort, t }) {
|
|
2774
2774
|
const state = (0, react.useSyncExternalStore)((listener) => directory?.store.subscribe(listener) ?? (() => {}), () => directory?.store.getSnapshot() ?? UNAVAILABLE_STATE);
|
|
2775
2775
|
const piSnapshot = (0, react.useSyncExternalStore)((listener) => piAiScope.subscribe(listener), () => piAiScope.getSnapshot());
|
|
2776
2776
|
const dsSnapshot = (0, react.useSyncExternalStore)((listener) => deepseekScope.subscribe(listener), () => deepseekScope.getSnapshot());
|
|
@@ -2977,11 +2977,21 @@ body:not([data-ds-dark-theme]) .${ZONE_CLASS}[data-top="1"] .${TRACK_CLASS} { an
|
|
|
2977
2977
|
const triggerLabel = current?.name ?? state.current?.model ?? t("model.panel.choose");
|
|
2978
2978
|
const currentReasoning = current?.model.reasoning;
|
|
2979
2979
|
const resolvedEffort = state.current?.reasoningEffort;
|
|
2980
|
+
/**
|
|
2981
|
+
* Issue #11: what the last request ACTUALLY carried.
|
|
2982
|
+
*
|
|
2983
|
+
* `resolvedEffort` above is the host's `modelSelection.next` — the user's
|
|
2984
|
+
* intent — so with `auto` picked it stays `'auto'` and the `→ level` hint
|
|
2985
|
+
* could never appear. The projection's `lastEffective` is the committed
|
|
2986
|
+
* header's resolved level. Fall back to `resolvedEffort` for hosts without the
|
|
2987
|
+
* projection so a non-auto pick keeps its previous hint behaviour.
|
|
2988
|
+
*/
|
|
2989
|
+
const actualEffort = lastEffectiveEffort ?? resolvedEffort;
|
|
2980
2990
|
const autoAdvertised = currentReasoning?.efforts.some((effort) => effort.id === "auto") === true;
|
|
2981
2991
|
const intentEffort = selectedEffortRef.current ?? (resolvedEffort === "auto" || autoAdvertised && configLevel === "auto" ? "auto" : resolvedEffort ?? currentReasoning?.defaultEffort);
|
|
2982
2992
|
const effortName = (id) => currentReasoning?.efforts.find((level) => level.id === id)?.name ?? id;
|
|
2983
2993
|
const effortLabel = currentReasoning === void 0 ? void 0 : intentEffort === void 0 ? t("input.effort.default") : effortName(intentEffort);
|
|
2984
|
-
const resolvedHint = currentReasoning !== void 0 && intentEffort === "auto" &&
|
|
2994
|
+
const resolvedHint = currentReasoning !== void 0 && intentEffort === "auto" && actualEffort !== void 0 && actualEffort !== "auto" ? `→ ${effortName(actualEffort)}` : void 0;
|
|
2985
2995
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2986
2996
|
ref: rootRef,
|
|
2987
2997
|
style: rootStyle,
|
|
@@ -5458,6 +5468,8 @@ body:not([data-ds-dark-theme]) .${ZONE_CLASS}[data-top="1"] .${TRACK_CLASS} { an
|
|
|
5458
5468
|
* the switch and the panel seats (or abdicates) immediately, no reload.
|
|
5459
5469
|
*/
|
|
5460
5470
|
let seatDirectories;
|
|
5471
|
+
/** The `sessions` face, kept for the chip's projection read (issue #11). */
|
|
5472
|
+
let sessionsRef;
|
|
5461
5473
|
let seatDeclared = false;
|
|
5462
5474
|
let seatWatched = false;
|
|
5463
5475
|
let seatClaimed;
|
|
@@ -5467,6 +5479,35 @@ body:not([data-ds-dark-theme]) .${ZONE_CLASS}[data-top="1"] .${TRACK_CLASS} { an
|
|
|
5467
5479
|
if (seatHandleMemo === void 0 && scopeOf !== void 0) seatHandleMemo = tlSettingsScopeOf(scopeOf);
|
|
5468
5480
|
return seatHandleMemo;
|
|
5469
5481
|
};
|
|
5482
|
+
/**
|
|
5483
|
+
* The level the session's last committed request actually carried, read from
|
|
5484
|
+
* this plugin's own `tlAutoSchedule` projection (issue #11).
|
|
5485
|
+
*
|
|
5486
|
+
* Why not the directory's `current.reasoningEffort`: the host derives it from
|
|
5487
|
+
* `modelSelection.next` — the selection the NEXT step uses, i.e. the user's
|
|
5488
|
+
* intent (`dsh-client-ui-model-selection/src/client/directory.ts:178`). With
|
|
5489
|
+
* `auto` picked, `next.reasoningEffort` stays `'auto'` for the whole session,
|
|
5490
|
+
* so the chip had no way to show what was really sent. The projection folds
|
|
5491
|
+
* the committed `request/header`, which carries the resolved level.
|
|
5492
|
+
*
|
|
5493
|
+
* Returns `undefined` — never throws — when the projection channel or the
|
|
5494
|
+
* projection itself is absent (older hosts, cold sessions). The chip then
|
|
5495
|
+
* degrades to the plain intent label.
|
|
5496
|
+
* @param sessions - the sessions face captured from the scope inject.
|
|
5497
|
+
* @param sessionId - the owning session.
|
|
5498
|
+
* @returns the last effective effort id, or undefined.
|
|
5499
|
+
*/
|
|
5500
|
+
const lastEffectiveOf = (sessions, sessionId) => {
|
|
5501
|
+
try {
|
|
5502
|
+
const face = sessions?.binding(sessionId)?.session?.projections?.faceOf?.("tlAutoSchedule");
|
|
5503
|
+
const snapshot = typeof face?.getSnapshot === "function" ? face.getSnapshot() : void 0;
|
|
5504
|
+
const value = typeof snapshot === "object" && snapshot !== null ? snapshot.value : void 0;
|
|
5505
|
+
const raw = typeof value === "object" && value !== null ? value.lastEffective : void 0;
|
|
5506
|
+
return typeof raw === "string" && raw.length > 0 ? raw : void 0;
|
|
5507
|
+
} catch {
|
|
5508
|
+
return;
|
|
5509
|
+
}
|
|
5510
|
+
};
|
|
5470
5511
|
const takeoverUiOn = () => {
|
|
5471
5512
|
const snap = typeof seatHandle()?.getSnapshot === "function" ? seatHandle().getSnapshot() : void 0;
|
|
5472
5513
|
return snap?.status === "ready" && snap.value?.takeoverUi === true;
|
|
@@ -5487,7 +5528,8 @@ body:not([data-ds-dark-theme]) .${ZONE_CLASS}[data-top="1"] .${TRACK_CLASS} { an
|
|
|
5487
5528
|
directory,
|
|
5488
5529
|
piAiScope: scopeOf?.("llm-pi-ai"),
|
|
5489
5530
|
deepseekScope: scopeOf?.("llm-deepseek"),
|
|
5490
|
-
tlScope: scopeOf === void 0 ? void 0 : tlSettingsScopeOf(scopeOf)
|
|
5531
|
+
tlScope: scopeOf === void 0 ? void 0 : tlSettingsScopeOf(scopeOf),
|
|
5532
|
+
lastEffectiveEffort: lastEffectiveOf(sessionsRef, sessionId)
|
|
5491
5533
|
};
|
|
5492
5534
|
}
|
|
5493
5535
|
});
|
|
@@ -5525,6 +5567,7 @@ body:not([data-ds-dark-theme]) .${ZONE_CLASS}[data-top="1"] .${TRACK_CLASS} { an
|
|
|
5525
5567
|
const directories = scope.modelDirectories;
|
|
5526
5568
|
if (directories === void 0) return;
|
|
5527
5569
|
seatDirectories = directories;
|
|
5570
|
+
sessionsRef = scope.sessions;
|
|
5528
5571
|
ctx.slots.inject("conversation.input.model", function* () {
|
|
5529
5572
|
seatDeclared = true;
|
|
5530
5573
|
startSeatWatch();
|