dsh-model-switch 0.4.62 → 0.4.63
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 -1
- package/cordis.patch.yml +3 -6
- package/lib/client.js +120 -43
- package/lib/session-title.js +77 -27
- package/lib/subagent-runtime.js +181 -200
- package/lib/types/client/picker/popup-placement.d.ts +53 -0
- package/lib/types/client/picker/useComposerPickerSurface.d.ts +2 -3
- package/lib/types/subagent-runtime-legacy.d.ts +34 -0
- package/lib/types/subagent-runtime.d.ts +36 -101
- package/lib/types/title-settings-reader.d.ts +34 -0
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -16,8 +16,14 @@
|
|
|
16
16
|
- **验证(virtual / 零真实额度)**:DSH `0.2.1-rc.5` lab 的 headless profile(真实宿主 + 虚拟探针 4731,模型回放一次 `subagent` 工具调用)。发布版 **0.4.60** 复现:工具结果为 `Error: cannot get property "workingDirectory" without inject`(会话 `session-f783b457`);装本修复构建后同一回放得到 `started subagent 4b1d65b1-1b91-4b41-a144-41cc7617e039`(`isError:false`,会话 `session-8ea93988`,探针记录 `D:\dsh-artifacts\probe-subagent.jsonl`)。自动审查/命名/记忆等其它接管行未改动。
|
|
17
17
|
- **残余**:0.4.61 装到桌面 profile 后需实际点一次子代理/团队委派确认(桌面宿主无法在 lab 内复刻)。0.1.7 / 0.2.0 的 `start()` 线依赖列表照旧合并,语义不变。
|
|
18
18
|
|
|
19
|
-
##
|
|
19
|
+
## v0.4.63
|
|
20
|
+
|
|
21
|
+
- **子代理停止按钮(`subagents/interruptByParent` definition-unavailable)**:不再用子类替换官方 `@deepseek-ai/dsh-subagent` 运行时。`cordis.patch.yml` 保留官方 `subagent` 行启用(Typert 清单由其包拥有),`src/subagent-runtime.ts` 只在官方实例的 `start` / `startContinuable` / `startActivation` 三个入口上装可恢复包装:用 `symbols.original` 定位官方原对象、按 lease 幂等共享、乱序卸载只恢复自己仍拥有的属性,`prompt` / `interrupt` / `interruptByParent` / Typert 绑定一概不碰;旧的启动辅助与子类保留在 `src/subagent-runtime-legacy.ts` 供已有导入使用(标注 deprecated,不再挂载)。**运行时证据(virtual / 零真实额度)**:DSH `0.2.2-rc.1` lab(`D:/dsh-artifacts/rc1-diff/home-next`,端口 3084)+ 本构建 + `tools/route-probe.mjs`(4719)启动后,按 UI 停止按钮的调用原样发起 `POST /api/subagents/interruptByParent`,返回 `{"ok":true,"value":{"accepted":true}}`(此前为 `gateway/definition-unavailable … strict definition was withdrawn`);同一宿主里 `include:subagent` 仍 active。同一 lab 用探针回放一次 `subagent` 工具调用(子路由分组设为 `apigoto/mimo-v2.6-pro`,会话模型 `gpt-6.1-sol`),探针依次记录 `gpt-6.1-sol`(父)→ `mimo-v2.6-pro`(子代理实际请求)→ `gpt-6.1-sol`(父续跑),即子代理请求携带的正是 Model Switch 计算的 provider/model。把 lab 的 bundles 换成 `@deepseek-ai/dsh-experimental-agent-team-profile` 后,回放 `spawn_teammate`(`context: fresh` 与 `fork` 各一次)同样出现 `mimo-v2.6-pro` 的子请求,证明 Teams 创建成员走官方运行时且继承同一路由;`spawn_teammate` 工具本身返回成功(否则不会产生子请求)。证据:`D:/dsh-artifacts/subagent-route-stop/lab/report-*.json`、`delegation3.log`、`teams.log`、`teams-fork.log`。
|
|
22
|
+
- **计划审查卡模型菜单裁切/错位**:菜单改为独立 Portal(`document.body`,`data-dsh-plan-review-menu`),`popup-placement.ts` 纯函数产出 `--dsh-menu-top/right/max-height` 三个变量,样式表再组合 `env(safe-area-inset-*)` 与 56dvh 上限;`useComposerPickerSurface` 用 `useLayoutEffect` + `ResizeObserver(trigger+menu)` + `resize`/捕获 `scroll` 幂等重定位(相等守卫防自回写),Escape 分层(搜索→根→关闭并回焦)、外点消失、SSR 无 `document` 时不渲染弹层。`tests/picker` 21 文件 / **166 测试**全绿(含真实 DOM portal 几何与 320px 右移基线)。浏览器视觉复核已完成(无头 Edge + CDP,1300×626):composer 模型 chip 的菜单与 PlanReviewCard 共用同一 `ComposerPicker` 组件与 `useComposerPickerSurface` hook,实测 Portal 为 `document.body` 直接子节点、`position:fixed`、右缘与触发器对齐(差 0px)、上方放置、完全在视口内、CSS 变量 `--dsh-menu-top/right/max-height` 均正确写入。截图:`D:/dsh-artifacts/subagent-route-stop/lab/picker-menu.png`。
|
|
23
|
+
- **随对话更新的标题(all-prompts)路由**:`src/title-settings-reader.ts` 改为每次调用先读 `ctx.get('modelSwitch')`(active-only 严格读),再回落到 scoped `ctx.inject` 子作用域;读不到/抛错一律返回 undefined,回到官方回退且不阻塞行。**rc.1 实机定位到的两处真实缺陷**:①监听器把 `this`(发射上下文)当成事件负载,`loader/partial-dispose` 拿不到 entry,导致启动过程中无关条目的 teardown 释放槽位后不再重领——命名 provider 静默消失、标题退回截断文案;现改为优先取第一个参数并用 entry 形状判定。②无关条目的 `partial-dispose` 不再释放命名槽位,只有官方命名行消失才释放并重领。**运行时证据(virtual / 零真实额度)**:rc.1 lab 中一次会话发两条消息,探针记录 `gpt-6.1-sol`(会话模型)与 `mimo-v2.6-flash`(配置的标题模型)交替出现,即每轮对话都触发标题更新且走 Model Switch 标题路由。热切换用同一 `settings/update` 验证:只改扁平 `titleProvider/titleModel` 时第二条标题仍走旧模型——这是**有意优先级**(会话 provider `apigoto` 存有分组,分组 pin 优先于扁平对),不是缓存;把该分组的 `titleModel` 一并改到 `mimo-v2.6-pro` 后,下一次标题请求即使用 `mimo-v2.6-pro`,无需重启。**热切换已验收。**
|
|
24
|
+
- 说明:本轮所有改动均未提交、未打标签、未推送、未发 npm、未安装到桌面 profile(按用户指示,等“发布并推送”)。`pnpm run check` 全绿:69 文件 / 678 测试 + pack 闸门。
|
|
20
25
|
|
|
26
|
+
- **0.4.62 无头 lab 补验(2026-11-05,virtual / 零真实额度)**:DSH `0.2.1-rc.5` lab(`D:\dsh-lab`,3082)+ `dsh-model-switch@0.4.62` 本地构建产物 + `tools/route-probe.mjs`(4731),用 dsh-browser-cdp 全程无头运行。基线目录加载正常(供应商下拉 8 项、无 ⚠);页面级仅拦截 `POST /session/modelCatalog` 做确定性故障注入:前 2 次失败后第 3 次成功,自动恢复无点击(calls=3, faulted=2);连续 3 次失败时显示错误与「重试」,「保存」「删除该组」保持可用;清除故障后点「重试」一次即恢复完整目录(calls=5, faulted=4,0 ⚠)。另在新建会话经 UI 发起一次真实工具调用:1 轮 2 步、页面显示「已读取文件」与 `ok`,探针记录 `deepseek-flash tool=read` → `mimo-v2.6-flash`(会话命名)→ `deepseek-flash` 后续请求,无 inactive context / body-not-executed 报错。宿主报告的 `ModelCatalogFailure` 合并在 lab 不可复现(pi-ai 提供商目录为静态配置,停探针不会让 `listModels` 抛错),该路径由 `tests/client-controller.spec.ts` 覆盖。证据:`D:\dsh-artifacts\lab-0462-evidence.json`、`D:\dsh-artifacts\probe-lab-0462-tool.jsonl`;宿主与探针已停止,3082/4731 已释放,lab 恢复为 npm `0.4.62`,桌面 profile 未改动。**仅文档,不发版。**
|
|
21
27
|
- **兼容巡检(2026-11-02,仅文档)**:DSH `latest` 仍是 `0.2.1-rc.5`(未移动,10-30/31 的验收结论继续有效);`dsh-prime-memory` 从 **0.26.16 移到 0.26.24**,其 `engines.dsh` 含 rc.5,已在 rc.5 lab + 本插件 0.4.60 下跑完七项接入检查(行激活、适配推送落地、无 `llm:` 静态钉、`settings-set` 读回、`effectiveCfg` 单测 9/9、免重启改路由 `replays:1→2`、蒸馏走新路由)。`docs/compat-watch-state.json` 记录 0.26.24 为已验证版本。**无代码改动,不发版。**
|
|
22
28
|
|
|
23
29
|
## v0.4.60
|
package/cordis.patch.yml
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Existing rows are disabled with their original name; replacements use unique ids.
|
|
1
|
+
# Adapt public DSH rows only through profile patches and released runtime APIs.
|
|
3
2
|
# Do not replace agent-presets: a nested AgentPresets instance loads a second
|
|
4
3
|
# @deepseek-ai/dsh-scope identity, and session.create then fails as unscoped.
|
|
4
|
+
# Keep the official Subagent row enabled: its package-owned Typert manifest
|
|
5
|
+
# defines prompt/interruptByParent. The inserted adapter wraps only start methods.
|
|
5
6
|
# Web selection is a deployment opt-in: preserve the existing complete Web config.
|
|
6
7
|
# An id-targeted config patch replaces (not merges) it, including fetchProvider.
|
|
7
8
|
|
|
8
|
-
- id: subagent
|
|
9
|
-
name: '@deepseek-ai/dsh-subagent'
|
|
10
|
-
disabled: true
|
|
11
|
-
|
|
12
9
|
# The official Auto reviewer hardwires the session route; Model Switch replaces
|
|
13
10
|
# it with its own row so the reviewer model stays configurable (one registerAuto
|
|
14
11
|
# per context). A profile that never enabled the optional bundle has no such
|
package/lib/client.js
CHANGED
|
@@ -3970,16 +3970,65 @@ window.__ModuleLoader__.load({
|
|
|
3970
3970
|
};
|
|
3971
3971
|
}
|
|
3972
3972
|
//#endregion
|
|
3973
|
+
//#region src/client/picker/popup-placement.ts
|
|
3974
|
+
function samePlacement(left, right) {
|
|
3975
|
+
return left !== void 0 && left["--dsh-menu-top"] === right["--dsh-menu-top"] && left["--dsh-menu-right"] === right["--dsh-menu-right"] && left["--dsh-menu-max-height"] === right["--dsh-menu-max-height"] && left.visibility === right.visibility;
|
|
3976
|
+
}
|
|
3977
|
+
/**
|
|
3978
|
+
* Narrow-screen reservation: the right clamp keeps this much viewport width
|
|
3979
|
+
* clear to the menu's left even when right-aligning to the trigger would
|
|
3980
|
+
* push the left edge off-screen (the pre-portal behavior base).
|
|
3981
|
+
*/
|
|
3982
|
+
const PREFERRED_WIDTH = 320;
|
|
3983
|
+
const FALLBACK_WIDTH = 280;
|
|
3984
|
+
const FALLBACK_HEIGHT = 220;
|
|
3985
|
+
/**
|
|
3986
|
+
* Position the portaled picker menu in viewport coordinates, right-aligned to
|
|
3987
|
+
* its trigger and preferring the space above it, clamped to the viewport.
|
|
3988
|
+
*/
|
|
3989
|
+
/**
|
|
3990
|
+
* Position the portaled picker menu in viewport coordinates, right-aligned to
|
|
3991
|
+
* its trigger and preferring the space above it, clamped to the viewport.
|
|
3992
|
+
*
|
|
3993
|
+
* The height clamp is the viewport budget only (never a content measurement):
|
|
3994
|
+
* the stylesheet caps the box at that budget, so taller menu panes grow into
|
|
3995
|
+
* it naturally and a later ResizeObserver pass only re-reads the rendered box
|
|
3996
|
+
* to re-anchor the trigger edge. Capping from the measured box would instead
|
|
3997
|
+
* lock the menu at whatever height it first rendered with.
|
|
3998
|
+
*/
|
|
3999
|
+
function placeComposerPopup({ trigger, menu, viewport, gutter = 8 }) {
|
|
4000
|
+
const maxWidth = Math.max(0, viewport.width - gutter * 2);
|
|
4001
|
+
const width = Math.min(menu.width || FALLBACK_WIDTH, maxWidth);
|
|
4002
|
+
const reserve = Math.max(Math.min(PREFERRED_WIDTH, maxWidth), width);
|
|
4003
|
+
const right = Math.min(Math.max(gutter, viewport.width - trigger.right), Math.max(gutter, viewport.width - gutter - reserve));
|
|
4004
|
+
const spaceAbove = Math.max(0, trigger.top - gutter * 2);
|
|
4005
|
+
const spaceBelow = Math.max(0, viewport.height - trigger.bottom - gutter * 2);
|
|
4006
|
+
const placeAbove = spaceAbove >= Math.min(menu.height, 180) || spaceAbove >= spaceBelow;
|
|
4007
|
+
const availableHeight = Math.max(0, (placeAbove ? spaceAbove : spaceBelow) - gutter);
|
|
4008
|
+
return {
|
|
4009
|
+
"--dsh-menu-top": `${placeAbove ? Math.max(gutter, trigger.top - gutter - Math.min(menu.height || FALLBACK_HEIGHT, availableHeight)) : Math.min(Math.max(gutter, trigger.bottom + gutter), Math.max(gutter, viewport.height - gutter - Math.min(menu.height || FALLBACK_HEIGHT, availableHeight)))}px`,
|
|
4010
|
+
"--dsh-menu-right": `${right}px`,
|
|
4011
|
+
"--dsh-menu-max-height": `${availableHeight}px`,
|
|
4012
|
+
visibility: "visible"
|
|
4013
|
+
};
|
|
4014
|
+
}
|
|
4015
|
+
//#endregion
|
|
3973
4016
|
//#region src/client/picker/useComposerPickerSurface.ts
|
|
3974
|
-
/**
|
|
4017
|
+
/** camelCase React style keys to hyphenated CSS custom-value writes. */
|
|
4018
|
+
function applyPopupStyle(target, style) {
|
|
4019
|
+
if (target === void 0) return;
|
|
4020
|
+
for (const [property, value] of Object.entries(style)) {
|
|
4021
|
+
if (value === void 0) continue;
|
|
4022
|
+
const rendered = typeof value === "number" && property !== "zIndex" ? `${value}px` : String(value);
|
|
4023
|
+
target.setProperty(property.replace(/[A-Z]/gu, (char) => `-${char.toLowerCase()}`), rendered);
|
|
4024
|
+
}
|
|
4025
|
+
}
|
|
4026
|
+
/** Own popup activation, viewport placement, and dismissal behind one internal seam. */
|
|
3975
4027
|
function useComposerPickerSurface(options) {
|
|
3976
4028
|
const [open, setOpen] = (0, react.useState)(false);
|
|
3977
|
-
const [menuStyle, setMenuStyle] = (0, react.useState)({
|
|
3978
|
-
position: "fixed",
|
|
3979
|
-
zIndex: 4e3
|
|
3980
|
-
});
|
|
3981
4029
|
const triggerRef = (0, react.useRef)(null);
|
|
3982
4030
|
const menuRef = (0, react.useRef)(null);
|
|
4031
|
+
const placementRef = (0, react.useRef)();
|
|
3983
4032
|
const pointerOpenIntent = (0, react.useRef)(null);
|
|
3984
4033
|
const callbacks = (0, react.useRef)({
|
|
3985
4034
|
onOpen: options.onOpen,
|
|
@@ -3994,6 +4043,7 @@ window.__ModuleLoader__.load({
|
|
|
3994
4043
|
const id = (0, react.useId)();
|
|
3995
4044
|
const close = (0, react.useCallback)((restoreFocus = false) => {
|
|
3996
4045
|
setOpen(false);
|
|
4046
|
+
placementRef.current = void 0;
|
|
3997
4047
|
callbacks.current.onClose();
|
|
3998
4048
|
if (restoreFocus) queueMicrotask(() => {
|
|
3999
4049
|
triggerRef.current?.focus();
|
|
@@ -4008,29 +4058,54 @@ window.__ModuleLoader__.load({
|
|
|
4008
4058
|
(0, react.useEffect)(() => {
|
|
4009
4059
|
if (options.locked) close();
|
|
4010
4060
|
}, [close, options.locked]);
|
|
4061
|
+
/**
|
|
4062
|
+
* Keep the portaled menu glued to its trigger in viewport coordinates:
|
|
4063
|
+
* measure once per commit, then follow resizes, scrolls, and menu size
|
|
4064
|
+
* changes through listeners instead of re-rendering.
|
|
4065
|
+
*/
|
|
4011
4066
|
(0, react.useLayoutEffect)(() => {
|
|
4012
|
-
if (!open) return;
|
|
4067
|
+
if (!open || typeof window === "undefined") return;
|
|
4068
|
+
const place = () => {
|
|
4069
|
+
const trigger = triggerRef.current;
|
|
4070
|
+
const menu = menuRef.current;
|
|
4071
|
+
if (trigger === null || menu === null) return;
|
|
4072
|
+
const rect = trigger.getBoundingClientRect();
|
|
4073
|
+
const measured = menu.getBoundingClientRect();
|
|
4074
|
+
const bounds = {
|
|
4075
|
+
width: measured.width || Math.min(280, window.innerWidth - 16),
|
|
4076
|
+
height: measured.height || menu.scrollHeight || 220
|
|
4077
|
+
};
|
|
4078
|
+
const next = placeComposerPopup({
|
|
4079
|
+
trigger: rect,
|
|
4080
|
+
menu: {
|
|
4081
|
+
width: bounds.width,
|
|
4082
|
+
height: bounds.height
|
|
4083
|
+
},
|
|
4084
|
+
viewport: {
|
|
4085
|
+
width: window.innerWidth,
|
|
4086
|
+
height: window.innerHeight
|
|
4087
|
+
}
|
|
4088
|
+
});
|
|
4089
|
+
if (samePlacement(placementRef.current, next)) return;
|
|
4090
|
+
placementRef.current = next;
|
|
4091
|
+
applyPopupStyle(menu.style, next);
|
|
4092
|
+
};
|
|
4093
|
+
place();
|
|
4013
4094
|
const trigger = triggerRef.current;
|
|
4014
|
-
|
|
4015
|
-
const
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
});
|
|
4027
|
-
}, [
|
|
4028
|
-
open,
|
|
4029
|
-
options.embedded,
|
|
4030
|
-
options.pane
|
|
4031
|
-
]);
|
|
4095
|
+
const menu = menuRef.current;
|
|
4096
|
+
const observer = typeof ResizeObserver === "undefined" ? void 0 : new ResizeObserver(place);
|
|
4097
|
+
if (trigger !== null) observer?.observe(trigger);
|
|
4098
|
+
if (menu !== null) observer?.observe(menu);
|
|
4099
|
+
window.addEventListener("resize", place);
|
|
4100
|
+
window.addEventListener("scroll", place, true);
|
|
4101
|
+
return () => {
|
|
4102
|
+
observer?.disconnect();
|
|
4103
|
+
window.removeEventListener("resize", place);
|
|
4104
|
+
window.removeEventListener("scroll", place, true);
|
|
4105
|
+
};
|
|
4106
|
+
}, [open, options.pane]);
|
|
4032
4107
|
(0, react.useEffect)(() => {
|
|
4033
|
-
if (!open ||
|
|
4108
|
+
if (!open || typeof document === "undefined") return;
|
|
4034
4109
|
const interaction = options.resolveInteractionOperations?.();
|
|
4035
4110
|
return installPickerDismissal({
|
|
4036
4111
|
documentTarget: document,
|
|
@@ -4044,13 +4119,11 @@ window.__ModuleLoader__.load({
|
|
|
4044
4119
|
close,
|
|
4045
4120
|
id,
|
|
4046
4121
|
open,
|
|
4047
|
-
options.resolveInteractionOperations
|
|
4048
|
-
options.tone
|
|
4122
|
+
options.resolveInteractionOperations
|
|
4049
4123
|
]);
|
|
4050
4124
|
return {
|
|
4051
4125
|
id,
|
|
4052
4126
|
open,
|
|
4053
|
-
menuStyle,
|
|
4054
4127
|
triggerRef,
|
|
4055
4128
|
menuRef,
|
|
4056
4129
|
show,
|
|
@@ -4323,7 +4396,7 @@ window.__ModuleLoader__.load({
|
|
|
4323
4396
|
}
|
|
4324
4397
|
//#endregion
|
|
4325
4398
|
//#region \0dsh-css:src/client/picker/ComposerPicker.module.css.mjs
|
|
4326
|
-
const css$1 = ".GdQohq_root{min-width:0;position:relative}.GdQohq_trigger{width:fit-content;min-width:0;max-width:256px;min-height:28px;color:var(--dsw-alias-label-secondary);font:var(--dsw-font-xs-strong-13);cursor:pointer;background:0 0;border:none;border-radius:24px;outline:none;align-items:center;gap:4px;padding:4px 4px 4px 8px;display:flex}.GdQohq_trigger:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.GdQohq_trigger:focus-visible{box-shadow:0 0 0 2px var(--dsw-alias-border-l3)}.GdQohq_trigger:disabled{color:var(--dsw-alias-label-dimmed);cursor:default}.GdQohq_triggerLabel{overflow-wrap:normal;text-overflow:ellipsis;white-space:nowrap;align-items:center;gap:4px;min-width:0;display:inline-flex;overflow:hidden}.GdQohq_triggerEffort{color:var(--dsw-alias-label-caption);flex:none}.GdQohq_chevron{color:var(--dsw-alias-label-caption);transition:transform .12s var(--ds-ease-in-out);flex:none}.GdQohq_chevronOpen{transform:rotate(180deg)}.GdQohq_embedded{width:100%}.GdQohq_embedded .GdQohq_trigger{background:var(--dsw-alias-interactive-bg-hover);width:100%;max-width:none;min-height:36px;color:var(--dsw-alias-label-primary);border-radius:10px;justify-content:space-between;padding:4px 10px}.GdQohq_embedded .GdQohq_trigger:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.GdQohq_capsule{width:100%}.GdQohq_capsule .GdQohq_trigger{border:1px solid var(--dsw-alias-border-inverted);background:var(--dsw-specific-input-major);width:100%;max-width:none;min-height:32px;color:var(--dsw-alias-label-primary);border-radius:24px;justify-content:space-between;padding:4px 8px 4px 10px}.GdQohq_capsule .GdQohq_trigger:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.GdQohq_menu{box-sizing:border-box;width:min(280px, max(0px, calc(100vw - 32px - env(safe-area-inset-left) - env(safe-area-inset-right))));max-height:min(360px, calc(56dvh - env(safe-area-inset-bottom)));border:1px solid var(--dsw-alias-border-inverted);background:var(--dsw-specific-menu);backdrop-filter:var(--dsw-menu-backdrop-filter);box-shadow:var(--dsw-shadow-lv3);color:var(--dsw-alias-label-primary);--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2);--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2);border-radius:12px;flex-direction:column;padding:4px;display:flex;overflow:hidden}.GdQohq_paneHeader{flex:none;grid-template-columns:32px minmax(0,1fr) 32px;align-items:center;gap:8px;min-height:40px;padding:2px 4px;display:grid}.GdQohq_paneHeader .GdQohq_headerButton{width:32px;min-width:32px;height:32px;color:var(--dsw-alias-label-secondary);padding:0}.GdQohq_paneHeader .GdQohq_headerButton:last-child{justify-self:end}.GdQohq_paneTitle{min-width:0;color:var(--dsw-alias-label-primary);font:var(--dsw-font-s-strong-14);overflow-wrap:anywhere;text-align:center;padding:4px 8px}.GdQohq_searchSlot{min-width:0;overflow:hidden}.GdQohq_headerSearch{box-sizing:border-box;width:100%;min-width:0;max-width:100%;display:flex}.GdQohq_headerSearch input::-webkit-search-cancel-button{display:none}.GdQohq_list{min-height:0;overflow:hidden auto}.GdQohq_status,.GdQohq_empty{color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-xs-13);overflow-wrap:anywhere;padding:10px}.GdQohq_error,.GdQohq_warning{background:var(--dsw-alias-interactive-bg-hover-danger);color:var(--dsw-alias-state-error-primary);font:var(--dsw-font-xxs-12);overflow-wrap:anywhere;border-radius:8px;justify-content:space-between;align-items:flex-start;gap:8px;margin-bottom:4px;padding:7px 8px;display:flex}.GdQohq_warning{background:var(--dsw-alias-bg-module-platform);color:var(--dsw-alias-state-warn-label)}.GdQohq_retry{color:inherit;font:var(--dsw-font-xxs-strong-12);cursor:pointer;background:0 0;border:none;flex:none;padding:0}.GdQohq_groups{min-height:0}.GdQohq_group+.GdQohq_group{margin-top:4px}.GdQohq_groupTitle{z-index:1;background:var(--dsw-specific-menu);color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-xxs-strong-12);overflow-wrap:anywhere;align-items:center;gap:6px;padding:5px 8px 3px;display:flex;position:sticky;top:0}.GdQohq_runtimeMark{min-width:14px;color:var(--dsw-alias-label-primary);font:var(--dsw-font-xxs-strong-12);justify-content:center;align-items:center;display:inline-flex}.GdQohq_runtimeMark svg{width:14px;height:14px;display:block}.GdQohq_option{box-sizing:border-box;width:auto;min-width:100%;min-height:38px;color:inherit;text-align:left;cursor:pointer;background:0 0;border:none;border-radius:10px;outline:none;align-items:center;gap:8px;padding:6px 8px;display:flex}.GdQohq_option:hover:not(:disabled),.GdQohq_option:focus-visible{background:var(--dsw-alias-interactive-bg-hover)}.GdQohq_selected{background:0 0}.GdQohq_option:disabled{color:var(--dsw-alias-label-dimmed);cursor:default}.GdQohq_optionCopy{flex-direction:column;flex:1;min-width:0;display:flex}.GdQohq_modelName{color:inherit;font:var(--dsw-font-s-strong-14);overflow-wrap:anywhere}.GdQohq_description{color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-xxs-12);overflow-wrap:anywhere}.GdQohq_check{color:var(--dsw-alias-label-primary);flex:0 0 18px;place-items:center;display:grid}.GdQohq_cell{box-sizing:border-box;width:auto;min-width:100%;height:40px;min-height:40px;color:var(--dsw-alias-label-primary);font:var(--dsw-font-s-14);cursor:pointer;text-align:left;background:0 0;border:none;border-radius:10px;align-items:center;gap:8px;padding:0 10px;display:flex}.GdQohq_cell:hover{background:var(--dsw-alias-interactive-bg-hover)}.GdQohq_cellLabel{white-space:nowrap;flex:none}.GdQohq_cellValue{min-width:0;color:var(--dsw-alias-label-tertiary);text-align:right;text-overflow:ellipsis;white-space:nowrap;flex:auto;overflow:hidden}.GdQohq_cellChevron{color:var(--dsw-alias-label-tertiary);flex:none}";
|
|
4399
|
+
const css$1 = ".GdQohq_root{min-width:0;position:relative}.GdQohq_trigger{width:fit-content;min-width:0;max-width:256px;min-height:28px;color:var(--dsw-alias-label-secondary);font:var(--dsw-font-xs-strong-13);cursor:pointer;background:0 0;border:none;border-radius:24px;outline:none;align-items:center;gap:4px;padding:4px 4px 4px 8px;display:flex}.GdQohq_trigger:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.GdQohq_trigger:focus-visible{box-shadow:0 0 0 2px var(--dsw-alias-border-l3)}.GdQohq_trigger:disabled{color:var(--dsw-alias-label-dimmed);cursor:default}.GdQohq_triggerLabel{overflow-wrap:normal;text-overflow:ellipsis;white-space:nowrap;align-items:center;gap:4px;min-width:0;display:inline-flex;overflow:hidden}.GdQohq_triggerEffort{color:var(--dsw-alias-label-caption);flex:none}.GdQohq_chevron{color:var(--dsw-alias-label-caption);transition:transform .12s var(--ds-ease-in-out);flex:none}.GdQohq_chevronOpen{transform:rotate(180deg)}.GdQohq_embedded{width:100%}.GdQohq_embedded .GdQohq_trigger{background:var(--dsw-alias-interactive-bg-hover);width:100%;max-width:none;min-height:36px;color:var(--dsw-alias-label-primary);border-radius:10px;justify-content:space-between;padding:4px 10px}.GdQohq_embedded .GdQohq_trigger:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.GdQohq_capsule{width:100%}.GdQohq_capsule .GdQohq_trigger{border:1px solid var(--dsw-alias-border-inverted);background:var(--dsw-specific-input-major);width:100%;max-width:none;min-height:32px;color:var(--dsw-alias-label-primary);border-radius:24px;justify-content:space-between;padding:4px 8px 4px 10px}.GdQohq_capsule .GdQohq_trigger:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.GdQohq_menu{box-sizing:border-box;width:min(280px, max(0px, calc(100vw - 32px - env(safe-area-inset-left) - env(safe-area-inset-right))));top:max(var(--dsh-menu-top,8px), calc(env(safe-area-inset-top) + 8px));right:max(var(--dsh-menu-right,8px), calc(env(safe-area-inset-right) + 8px));max-height:min(var(--dsh-menu-max-height,360px), calc(56dvh - env(safe-area-inset-bottom) - env(safe-area-inset-top)));visibility:hidden;border:1px solid var(--dsw-alias-border-inverted);background:var(--dsw-specific-menu);backdrop-filter:var(--dsw-menu-backdrop-filter);box-shadow:var(--dsw-shadow-lv3);color:var(--dsw-alias-label-primary);--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2);--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2);border-radius:12px;flex-direction:column;padding:4px;display:flex;overflow:hidden}.GdQohq_paneHeader{flex:none;grid-template-columns:32px minmax(0,1fr) 32px;align-items:center;gap:8px;min-height:40px;padding:2px 4px;display:grid}.GdQohq_paneHeader .GdQohq_headerButton{width:32px;min-width:32px;height:32px;color:var(--dsw-alias-label-secondary);padding:0}.GdQohq_paneHeader .GdQohq_headerButton:last-child{justify-self:end}.GdQohq_paneTitle{min-width:0;color:var(--dsw-alias-label-primary);font:var(--dsw-font-s-strong-14);overflow-wrap:anywhere;text-align:center;padding:4px 8px}.GdQohq_searchSlot{min-width:0;overflow:hidden}.GdQohq_headerSearch{box-sizing:border-box;width:100%;min-width:0;max-width:100%;display:flex}.GdQohq_headerSearch input::-webkit-search-cancel-button{display:none}.GdQohq_list{min-height:0;overflow:hidden auto}.GdQohq_status,.GdQohq_empty{color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-xs-13);overflow-wrap:anywhere;padding:10px}.GdQohq_error,.GdQohq_warning{background:var(--dsw-alias-interactive-bg-hover-danger);color:var(--dsw-alias-state-error-primary);font:var(--dsw-font-xxs-12);overflow-wrap:anywhere;border-radius:8px;justify-content:space-between;align-items:flex-start;gap:8px;margin-bottom:4px;padding:7px 8px;display:flex}.GdQohq_warning{background:var(--dsw-alias-bg-module-platform);color:var(--dsw-alias-state-warn-label)}.GdQohq_retry{color:inherit;font:var(--dsw-font-xxs-strong-12);cursor:pointer;background:0 0;border:none;flex:none;padding:0}.GdQohq_groups{min-height:0}.GdQohq_group+.GdQohq_group{margin-top:4px}.GdQohq_groupTitle{z-index:1;background:var(--dsw-specific-menu);color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-xxs-strong-12);overflow-wrap:anywhere;align-items:center;gap:6px;padding:5px 8px 3px;display:flex;position:sticky;top:0}.GdQohq_runtimeMark{min-width:14px;color:var(--dsw-alias-label-primary);font:var(--dsw-font-xxs-strong-12);justify-content:center;align-items:center;display:inline-flex}.GdQohq_runtimeMark svg{width:14px;height:14px;display:block}.GdQohq_option{box-sizing:border-box;width:auto;min-width:100%;min-height:38px;color:inherit;text-align:left;cursor:pointer;background:0 0;border:none;border-radius:10px;outline:none;align-items:center;gap:8px;padding:6px 8px;display:flex}.GdQohq_option:hover:not(:disabled),.GdQohq_option:focus-visible{background:var(--dsw-alias-interactive-bg-hover)}.GdQohq_selected{background:0 0}.GdQohq_option:disabled{color:var(--dsw-alias-label-dimmed);cursor:default}.GdQohq_optionCopy{flex-direction:column;flex:1;min-width:0;display:flex}.GdQohq_modelName{color:inherit;font:var(--dsw-font-s-strong-14);overflow-wrap:anywhere}.GdQohq_description{color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-xxs-12);overflow-wrap:anywhere}.GdQohq_check{color:var(--dsw-alias-label-primary);flex:0 0 18px;place-items:center;display:grid}.GdQohq_cell{box-sizing:border-box;width:auto;min-width:100%;height:40px;min-height:40px;color:var(--dsw-alias-label-primary);font:var(--dsw-font-s-14);cursor:pointer;text-align:left;background:0 0;border:none;border-radius:10px;align-items:center;gap:8px;padding:0 10px;display:flex}.GdQohq_cell:hover{background:var(--dsw-alias-interactive-bg-hover)}.GdQohq_cellLabel{white-space:nowrap;flex:none}.GdQohq_cellValue{min-width:0;color:var(--dsw-alias-label-tertiary);text-align:right;text-overflow:ellipsis;white-space:nowrap;flex:auto;overflow:hidden}.GdQohq_cellChevron{color:var(--dsw-alias-label-tertiary);flex:none}";
|
|
4327
4400
|
const tagId$1 = "dsh-model-switch/ComposerPicker.module.css";
|
|
4328
4401
|
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$1) + "]") === null) {
|
|
4329
4402
|
const tag = document.createElement("style");
|
|
@@ -4457,7 +4530,7 @@ window.__ModuleLoader__.load({
|
|
|
4457
4530
|
lastActionRef.current = "load";
|
|
4458
4531
|
load();
|
|
4459
4532
|
};
|
|
4460
|
-
const { id, open,
|
|
4533
|
+
const { id, open, triggerRef, menuRef, close, onTriggerPointerDown, onTriggerClick } = useComposerPickerSurface({
|
|
4461
4534
|
locked,
|
|
4462
4535
|
embedded: embedded ?? false,
|
|
4463
4536
|
pane,
|
|
@@ -4563,16 +4636,15 @@ window.__ModuleLoader__.load({
|
|
|
4563
4636
|
const contextDisplay = (label) => label === "standard" ? t("context.standard") : label;
|
|
4564
4637
|
const triggerLabel = triggerBits.join(" · ");
|
|
4565
4638
|
const triggerAria = currentSelection === null ? t("trigger.selectAria") : t("trigger.aria", { model: triggerLabel });
|
|
4566
|
-
const
|
|
4567
|
-
if (lockedRef.current) return;
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
}
|
|
4639
|
+
const onPickerKeyDown = (event) => {
|
|
4640
|
+
if (lockedRef.current || event.key !== "Escape" || !open) return;
|
|
4641
|
+
event.preventDefault();
|
|
4642
|
+
event.stopPropagation();
|
|
4643
|
+
if (pane === "model" && searching) {
|
|
4644
|
+
setSearching(false);
|
|
4645
|
+
setQuery("");
|
|
4646
|
+
} else if (pane !== "root") returnToRoot();
|
|
4647
|
+
else close(true);
|
|
4576
4648
|
};
|
|
4577
4649
|
const paneHeader = pane === "root" ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModelPaneHeader, {
|
|
4578
4650
|
title: t({
|
|
@@ -4602,7 +4674,11 @@ window.__ModuleLoader__.load({
|
|
|
4602
4674
|
ref: menuRef,
|
|
4603
4675
|
id: `${id}-menu`,
|
|
4604
4676
|
className: ComposerPicker_module_css_default.menu,
|
|
4605
|
-
style:
|
|
4677
|
+
style: {
|
|
4678
|
+
position: "fixed",
|
|
4679
|
+
zIndex: 4e3
|
|
4680
|
+
},
|
|
4681
|
+
"data-dsh-plan-review-menu": "true",
|
|
4606
4682
|
role: "menu",
|
|
4607
4683
|
tabIndex: -1,
|
|
4608
4684
|
"aria-label": t("menu.aria"),
|
|
@@ -4610,6 +4686,7 @@ window.__ModuleLoader__.load({
|
|
|
4610
4686
|
onPointerDown: (event) => {
|
|
4611
4687
|
event.stopPropagation();
|
|
4612
4688
|
},
|
|
4689
|
+
onKeyDown: onPickerKeyDown,
|
|
4613
4690
|
children: [paneHeader, /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4614
4691
|
className: ComposerPicker_module_css_default.list,
|
|
4615
4692
|
children: [
|
|
@@ -4914,7 +4991,7 @@ window.__ModuleLoader__.load({
|
|
|
4914
4991
|
}) : null;
|
|
4915
4992
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4916
4993
|
className: classNames(ComposerPicker_module_css_default.root, tone === "capsule" ? ComposerPicker_module_css_default.capsule : embedded && ComposerPicker_module_css_default.embedded),
|
|
4917
|
-
onKeyDown:
|
|
4994
|
+
onKeyDown: onPickerKeyDown,
|
|
4918
4995
|
children: [
|
|
4919
4996
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
4920
4997
|
ref: triggerRef,
|
|
@@ -4939,7 +5016,7 @@ window.__ModuleLoader__.load({
|
|
|
4939
5016
|
className: classNames(ComposerPicker_module_css_default.chevron, open && ComposerPicker_module_css_default.chevronOpen)
|
|
4940
5017
|
})]
|
|
4941
5018
|
}),
|
|
4942
|
-
menu !== null &&
|
|
5019
|
+
menu !== null && typeof document !== "undefined" ? (0, react_dom.createPortal)(menu, document.body) : null,
|
|
4943
5020
|
toast !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Toast, {
|
|
4944
5021
|
text: toast.text,
|
|
4945
5022
|
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconWarningOutlineRegular, { size: 16 }),
|
package/lib/session-title.js
CHANGED
|
@@ -1,4 +1,69 @@
|
|
|
1
1
|
import { a as sessionProviderOf, n as groupRoute, t as deploymentRoute } from "./session-route-D8izd8Zd.js";
|
|
2
|
+
//#region lib/types/title-settings-reader.js
|
|
3
|
+
/**
|
|
4
|
+
* Safe reads of the optional Model Switch settings service for the naming row.
|
|
5
|
+
*
|
|
6
|
+
* The session-naming row must keep the official naming behavior when the
|
|
7
|
+
* `model-switch` row is absent, so `modelSwitch` can never join the row's own
|
|
8
|
+
* `inject` list: Cordis waits for every declared dependency before a fiber
|
|
9
|
+
* loads (there is no "optional" inject), and a never-provided service would
|
|
10
|
+
* leave the row pending forever.
|
|
11
|
+
*
|
|
12
|
+
* Two reads are tried per call, in this order:
|
|
13
|
+
*
|
|
14
|
+
* 1. `ctx.get('modelSwitch')` with Cordis' default strict mode — the active
|
|
15
|
+
* implementation only, or undefined. This is the read the shipped row used
|
|
16
|
+
* and it keeps working across a settings-row rebuild because the store
|
|
17
|
+
* entry is replaced, not cached here.
|
|
18
|
+
* 2. A scoped `ctx.inject(['modelSwitch'])` child fiber, which binds a
|
|
19
|
+
* dependent scope and resets it on dispose. This covers compositions where
|
|
20
|
+
* the strict store read is invisible from the row's own entry context.
|
|
21
|
+
*
|
|
22
|
+
* The returned function identity is stable for the row's lifetime and every
|
|
23
|
+
* call re-reads, so a settings save or a service rebuild needs no remount.
|
|
24
|
+
* Reads never throw: a missing face, a disposed scope, or a throwing read all
|
|
25
|
+
* answer undefined, which means "official behavior" to the caller.
|
|
26
|
+
*
|
|
27
|
+
* @module dsh-model-switch/title-settings-reader
|
|
28
|
+
*/
|
|
29
|
+
/** Accept only a settings object; anything else is the official "no settings" answer. */
|
|
30
|
+
function settingsOf(value) {
|
|
31
|
+
if (value === null || typeof value !== "object") return void 0;
|
|
32
|
+
const service = value;
|
|
33
|
+
if (typeof service.currentSettings !== "function") return void 0;
|
|
34
|
+
const settings = service.currentSettings();
|
|
35
|
+
return settings !== null && typeof settings === "object" ? settings : void 0;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Create the settings reader for one naming row context.
|
|
39
|
+
* @param ctx - this row's context (the row fiber's own scope).
|
|
40
|
+
* @returns The reader: per-request live settings, or undefined when unavailable.
|
|
41
|
+
*/
|
|
42
|
+
function titleSettingsReaderOf(ctx) {
|
|
43
|
+
let scoped;
|
|
44
|
+
ctx.inject(["modelSwitch"], (scope) => {
|
|
45
|
+
scope.effect(() => {
|
|
46
|
+
scoped = scope;
|
|
47
|
+
return () => {
|
|
48
|
+
if (scoped === scope) scoped = void 0;
|
|
49
|
+
};
|
|
50
|
+
}, "model-switch: session-title settings reader");
|
|
51
|
+
});
|
|
52
|
+
return () => {
|
|
53
|
+
try {
|
|
54
|
+
const direct = settingsOf(ctx.get("modelSwitch"));
|
|
55
|
+
if (direct !== void 0) return direct;
|
|
56
|
+
} catch {}
|
|
57
|
+
const scope = scoped;
|
|
58
|
+
if (scope === void 0) return void 0;
|
|
59
|
+
try {
|
|
60
|
+
return settingsOf(scope.modelSwitch);
|
|
61
|
+
} catch {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
//#endregion
|
|
2
67
|
//#region lib/types/session-title.js
|
|
3
68
|
/**
|
|
4
69
|
* Model Switch-owned session-naming row.
|
|
@@ -479,8 +544,8 @@ async function runTitleCall(ctx, module, plan, request, attempt) {
|
|
|
479
544
|
* @returns The official provider result.
|
|
480
545
|
* @throws The last candidate failure when every candidate fails.
|
|
481
546
|
*/
|
|
482
|
-
async function generateTitle(ctx, module, plan, request) {
|
|
483
|
-
const candidates = titleRouteCandidates(
|
|
547
|
+
async function generateTitle(ctx, module, plan, request, settingsReader) {
|
|
548
|
+
const candidates = titleRouteCandidates(settingsReader(), sessionProviderOf(ctx, request.session), plan.config, request.route);
|
|
484
549
|
const attempts = candidates.length === 0 ? [{
|
|
485
550
|
route: void 0,
|
|
486
551
|
config: plan.config
|
|
@@ -513,23 +578,6 @@ async function generateTitle(ctx, module, plan, request) {
|
|
|
513
578
|
if (!request.signal.aborted) ctx.logger.warn(`model-switch: session title generation failed on every candidate (${tried}): ${String(lastError)}`);
|
|
514
579
|
throw lastError;
|
|
515
580
|
}
|
|
516
|
-
/**
|
|
517
|
-
* Read live Model Switch settings without requiring the host row.
|
|
518
|
-
*
|
|
519
|
-
* The host is read structurally instead of injected so this row keeps mirroring
|
|
520
|
-
* the official naming behavior when the `model-switch` row is disabled: an
|
|
521
|
-
* unreachable host resolves to the row's own policy rather than to a pinned
|
|
522
|
-
* route.
|
|
523
|
-
* @param ctx - this row's context.
|
|
524
|
-
* @returns The settings, or undefined when the host is unavailable.
|
|
525
|
-
*/
|
|
526
|
-
function currentSettings(ctx) {
|
|
527
|
-
try {
|
|
528
|
-
return ctx.get("modelSwitch", false)?.currentSettings();
|
|
529
|
-
} catch {
|
|
530
|
-
return;
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
581
|
/** Resolve the naming plan for one official row, or the shipped defaults when no row exists. */
|
|
534
582
|
function planFor(ctx, module, entry) {
|
|
535
583
|
const cadence = titleCadence(entry === void 0 ? void 0 : officialTitlePackage(entry)) ?? TITLE_CADENCES[0];
|
|
@@ -550,11 +598,11 @@ function planFor(ctx, module, entry) {
|
|
|
550
598
|
};
|
|
551
599
|
}
|
|
552
600
|
/** One naming plan bound to a live route resolver. */
|
|
553
|
-
function providerOf(ctx, module, plan) {
|
|
601
|
+
function providerOf(ctx, module, plan, settingsReader) {
|
|
554
602
|
return {
|
|
555
603
|
id: plan.cadence.id,
|
|
556
604
|
automatic: plan.cadence.automatic,
|
|
557
|
-
generate: (request) => generateTitle(ctx, module, plan, request)
|
|
605
|
+
generate: (request) => generateTitle(ctx, module, plan, request, settingsReader)
|
|
558
606
|
};
|
|
559
607
|
}
|
|
560
608
|
/** Timing knobs for the takeover choreography (exported for tests). */
|
|
@@ -578,11 +626,13 @@ const TAKEOVER_MAX_ATTEMPTS = 20;
|
|
|
578
626
|
var NamingSeam = class {
|
|
579
627
|
ctx;
|
|
580
628
|
module;
|
|
629
|
+
settingsReader;
|
|
581
630
|
disposer;
|
|
582
631
|
plan;
|
|
583
|
-
constructor(ctx, module, plan) {
|
|
632
|
+
constructor(ctx, module, settingsReader, plan) {
|
|
584
633
|
this.ctx = ctx;
|
|
585
634
|
this.module = module;
|
|
635
|
+
this.settingsReader = settingsReader;
|
|
586
636
|
this.plan = plan;
|
|
587
637
|
}
|
|
588
638
|
/** The cadence currently registered. */
|
|
@@ -602,7 +652,7 @@ var NamingSeam = class {
|
|
|
602
652
|
this.plan = plan;
|
|
603
653
|
if (this.disposer !== void 0) return true;
|
|
604
654
|
try {
|
|
605
|
-
this.disposer = this.ctx.sessionTitle.register(providerOf(this.ctx, this.module, plan));
|
|
655
|
+
this.disposer = this.ctx.sessionTitle.register(providerOf(this.ctx, this.module, plan, this.settingsReader));
|
|
606
656
|
return true;
|
|
607
657
|
} catch {
|
|
608
658
|
return false;
|
|
@@ -725,8 +775,7 @@ function installTakeover(ctx, module, seam) {
|
|
|
725
775
|
* the real Host always provides one of them.
|
|
726
776
|
*/
|
|
727
777
|
const entryOfEvent = (self, first) => {
|
|
728
|
-
const candidate
|
|
729
|
-
return candidate !== null && typeof candidate === "object" && "options" in candidate ? candidate : void 0;
|
|
778
|
+
for (const candidate of [first, self]) if (candidate !== null && typeof candidate === "object" && "options" in candidate) return candidate;
|
|
730
779
|
};
|
|
731
780
|
const listeners = [];
|
|
732
781
|
const listen = (event, listener) => {
|
|
@@ -755,9 +804,9 @@ function installTakeover(ctx, module, seam) {
|
|
|
755
804
|
reclaim(entry, plan);
|
|
756
805
|
});
|
|
757
806
|
listen("loader/partial-dispose", function(first) {
|
|
758
|
-
seam.yieldSlot();
|
|
759
807
|
const entry = entryOfEvent(this, first);
|
|
760
808
|
if (entry === void 0 || !isOfficialTitleRow(entry)) return;
|
|
809
|
+
seam.yieldSlot();
|
|
761
810
|
handled.delete(entry);
|
|
762
811
|
if (seam.claimed) return;
|
|
763
812
|
const plan = planFor(ctx, module, officialTitleEntry(ctx.get("loader", false)));
|
|
@@ -797,6 +846,7 @@ function installTakeover(ctx, module, seam) {
|
|
|
797
846
|
* @param ctx - this row's context.
|
|
798
847
|
*/
|
|
799
848
|
async function apply(ctx) {
|
|
849
|
+
const settingsReader = titleSettingsReaderOf(ctx);
|
|
800
850
|
const entry = officialTitleEntry(ctx.get("loader", false));
|
|
801
851
|
if (entry === void 0) ctx.logger.info("model-switch: no instantiated official session-title row to mirror; naming uses the first-prompt cadence");
|
|
802
852
|
let module;
|
|
@@ -809,7 +859,7 @@ async function apply(ctx) {
|
|
|
809
859
|
}
|
|
810
860
|
const plan = planFor(ctx, module, entry);
|
|
811
861
|
if (plan === void 0) return;
|
|
812
|
-
const seam = new NamingSeam(ctx, module, plan);
|
|
862
|
+
const seam = new NamingSeam(ctx, module, settingsReader, plan);
|
|
813
863
|
if (!(enabledOfficialRows(ctx).length > 0) && !seam.claim()) ctx.logger.info("model-switch: another session-title provider already owns the seam; naming follows it while it is active");
|
|
814
864
|
installTakeover(ctx, module, seam);
|
|
815
865
|
}
|
package/lib/subagent-runtime.js
CHANGED
|
@@ -1,105 +1,22 @@
|
|
|
1
1
|
import { o as sessionSubagentRouteOf } from "./session-route-D8izd8Zd.js";
|
|
2
|
+
import { symbols } from "@deepseek-ai/cordis";
|
|
2
3
|
import { ReasoningEffortId } from "@deepseek-ai/dsh-llm";
|
|
3
4
|
import OfficialSubagentRuntime from "@deepseek-ai/dsh-subagent";
|
|
4
|
-
//#region lib/types/subagent-runtime.js
|
|
5
|
-
/**
|
|
5
|
+
//#region lib/types/subagent-runtime-legacy.js
|
|
6
|
+
/** Previously published startup error; retained for consumers of this module. */
|
|
6
7
|
var StartupIncompatibilityError = class extends Error {
|
|
7
8
|
name = "StartupIncompatibilityError";
|
|
8
9
|
surface;
|
|
9
|
-
/**
|
|
10
|
-
* @param surfaceOrMessage - the incompatible public surface, or the error message.
|
|
11
|
-
* @param message - the missing or incompatible requirement.
|
|
12
|
-
*/
|
|
13
10
|
constructor(surfaceOrMessage, message) {
|
|
14
11
|
super(message ?? surfaceOrMessage);
|
|
15
12
|
this.surface = message === void 0 ? "startup" : surfaceOrMessage;
|
|
16
13
|
}
|
|
17
14
|
};
|
|
18
|
-
|
|
19
|
-
return typeof value === "string" && value.trim() !== "";
|
|
20
|
-
}
|
|
21
|
-
function spawnHasAnyRouteField(options) {
|
|
22
|
-
return present(options?.provider) || present(options?.model) || options?.reasoningEffort !== void 0;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Inject one resolved route into a spawn that names none.
|
|
26
|
-
*
|
|
27
|
-
* A spawn that already names a provider, model, or effort keeps it: the caller's
|
|
28
|
-
* explicit selection outranks any profile policy. The route itself is derived
|
|
29
|
-
* from the DELEGATING session (its provider selects a saved group, else the flat
|
|
30
|
-
* Subagent card in `fixed` mode), so two sessions on different providers route
|
|
31
|
-
* their own spawns and neither can rewrite the other's policy.
|
|
32
|
-
* @param request - the caller's spawn request.
|
|
33
|
-
* @param route - the delegating session's resolved route, or undefined for official inherit.
|
|
34
|
-
* @returns The request to hand the official runtime.
|
|
35
|
-
*/
|
|
36
|
-
function routeSubagentRequest(request, route) {
|
|
37
|
-
if (spawnHasAnyRouteField(request.agentOptions)) return request;
|
|
38
|
-
if (route === void 0) return request;
|
|
39
|
-
return {
|
|
40
|
-
...request,
|
|
41
|
-
agentOptions: {
|
|
42
|
-
...request.agentOptions,
|
|
43
|
-
provider: route.provider,
|
|
44
|
-
model: route.model,
|
|
45
|
-
...route.reasoningEffort === void 0 ? {} : { reasoningEffort: ReasoningEffortId(route.reasoningEffort) }
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
function assertPublicMethod(value, surface, method) {
|
|
50
|
-
if (value === null || typeof value !== "object" && typeof value !== "function" || typeof Reflect.get(value, method) !== "function") throw new StartupIncompatibilityError(surface, surface + " must expose public " + method + "()");
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Classify the runtime surface this Host publishes.
|
|
54
|
-
*
|
|
55
|
-
* DSH 0.2.1 replaced `start()` / `startContinuable()` with the activation API
|
|
56
|
-
* (`startActivation`), so a version-agnostic adapter has to recognize both
|
|
57
|
-
* lines instead of hard-coding one.
|
|
58
|
-
*
|
|
59
|
-
* @param value - a runtime class's prototype or a mounted runtime instance.
|
|
60
|
-
* @returns `activation` (0.2.1+), `start` (0.1.7/0.2.0), or undefined when neither is published.
|
|
61
|
-
*/
|
|
15
|
+
/** Classify the two published start API generations without version guessing. */
|
|
62
16
|
function subagentSurfaceOf(value) {
|
|
63
17
|
if (value === null || typeof value !== "object" && typeof value !== "function") return void 0;
|
|
64
18
|
if (typeof Reflect.get(value, "startActivation") === "function") return "activation";
|
|
65
|
-
|
|
66
|
-
const hasContinuable = typeof Reflect.get(value, "startContinuable") === "function";
|
|
67
|
-
return hasStart && hasContinuable ? "start" : void 0;
|
|
68
|
-
}
|
|
69
|
-
/** Read one public method, failing with the typed startup error when it is absent. */
|
|
70
|
-
function publicMethod(prototype, surface, method) {
|
|
71
|
-
if (prototype === null || typeof prototype !== "object" && typeof prototype !== "function") throw new StartupIncompatibilityError(surface, surface + " must expose public " + method + "()");
|
|
72
|
-
const value = Reflect.get(prototype, method);
|
|
73
|
-
if (typeof value !== "function") throw new StartupIncompatibilityError(surface, surface + " must expose public " + method + "()");
|
|
74
|
-
return value;
|
|
75
|
-
}
|
|
76
|
-
function constructible(value) {
|
|
77
|
-
if (typeof value !== "function") return false;
|
|
78
|
-
try {
|
|
79
|
-
Reflect.construct(Object, [], value);
|
|
80
|
-
return true;
|
|
81
|
-
} catch (error) {
|
|
82
|
-
if (error instanceof TypeError) return false;
|
|
83
|
-
throw error;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
function assertOfficialRuntimeSurface() {
|
|
87
|
-
const runtime = OfficialSubagentRuntime;
|
|
88
|
-
if (!constructible(runtime)) throw new StartupIncompatibilityError("OfficialSubagentRuntime", "OfficialSubagentRuntime must be constructible");
|
|
89
|
-
const line = subagentSurfaceOf(Reflect.get(runtime, "prototype"));
|
|
90
|
-
if (line === void 0) throw new StartupIncompatibilityError("OfficialSubagentRuntime", "OfficialSubagentRuntime must expose public startActivation() (0.2.1+) or start()/startContinuable()");
|
|
91
|
-
return line;
|
|
92
|
-
}
|
|
93
|
-
function assertRoutingSurface(ctx) {
|
|
94
|
-
assertPublicMethod(ctx.get("modelSwitch", false), "Model Switch runtime", "currentSettings");
|
|
95
|
-
}
|
|
96
|
-
function routingSurface(ctx) {
|
|
97
|
-
return ctx.modelSwitch;
|
|
98
|
-
}
|
|
99
|
-
function assertMountedSurface(ctx) {
|
|
100
|
-
const service = ctx.subagents;
|
|
101
|
-
assertPublicMethod(service, "mounted Subagent runtime", "resolveMaxDepth");
|
|
102
|
-
if (subagentSurfaceOf(service) === void 0) throw new StartupIncompatibilityError("mounted Subagent runtime", "mounted Subagent runtime must expose public startActivation() (0.2.1+) or start()/startContinuable()");
|
|
19
|
+
return typeof Reflect.get(value, "start") === "function" && typeof Reflect.get(value, "startContinuable") === "function" ? "start" : void 0;
|
|
103
20
|
}
|
|
104
21
|
function once(dispose) {
|
|
105
22
|
let pending;
|
|
@@ -123,9 +40,9 @@ var CleanupLedger = class {
|
|
|
123
40
|
return failures;
|
|
124
41
|
}
|
|
125
42
|
};
|
|
126
|
-
function startupFailure(error,
|
|
127
|
-
if (
|
|
128
|
-
throw new AggregateError([error, ...
|
|
43
|
+
function startupFailure(error, failures) {
|
|
44
|
+
if (failures.length === 0) throw error;
|
|
45
|
+
throw new AggregateError([error, ...failures], "Subagent runtime startup and cleanup failed", { cause: error });
|
|
129
46
|
}
|
|
130
47
|
function cleanupDisposer(ledger) {
|
|
131
48
|
return async () => {
|
|
@@ -133,19 +50,7 @@ function cleanupDisposer(ledger) {
|
|
|
133
50
|
if (failures.length > 0) throw new AggregateError(failures, "Subagent runtime cleanup failed");
|
|
134
51
|
};
|
|
135
52
|
}
|
|
136
|
-
/**
|
|
137
|
-
* Mount a candidate and use the fallback only for typed startup incompatibility.
|
|
138
|
-
*
|
|
139
|
-
* Every resource registered by an attempt is disposed in reverse order before a
|
|
140
|
-
* fallback starts and again when the mounted result is disposed. Cleanup keeps
|
|
141
|
-
* running after failures, and a startup error stays first in any aggregate.
|
|
142
|
-
*
|
|
143
|
-
* @param candidate - startup callback for the routed candidate.
|
|
144
|
-
* @param fallback - startup callback for the untouched official runtime.
|
|
145
|
-
* @returns the selected value and an idempotent disposer.
|
|
146
|
-
* @throws the candidate error unless it is a StartupIncompatibilityError.
|
|
147
|
-
* @throws the fallback startup error when fallback startup fails.
|
|
148
|
-
*/
|
|
53
|
+
/** Retain the typed-only startup fallback and reverse, idempotent cleanup contract. */
|
|
149
54
|
async function mountWithStartupFallback(candidate, fallback) {
|
|
150
55
|
const ledger = new CleanupLedger();
|
|
151
56
|
try {
|
|
@@ -154,9 +59,8 @@ async function mountWithStartupFallback(candidate, fallback) {
|
|
|
154
59
|
dispose: cleanupDisposer(ledger)
|
|
155
60
|
};
|
|
156
61
|
} catch (error) {
|
|
157
|
-
const
|
|
158
|
-
if (!(error instanceof StartupIncompatibilityError)) startupFailure(error,
|
|
159
|
-
if (cleanupFailures.length > 0) startupFailure(error, cleanupFailures);
|
|
62
|
+
const failures = await ledger.disposeAll();
|
|
63
|
+
if (!(error instanceof StartupIncompatibilityError) || failures.length > 0) startupFailure(error, failures);
|
|
160
64
|
}
|
|
161
65
|
try {
|
|
162
66
|
return {
|
|
@@ -167,120 +71,197 @@ async function mountWithStartupFallback(candidate, fallback) {
|
|
|
167
71
|
startupFailure(error, await ledger.disposeAll());
|
|
168
72
|
}
|
|
169
73
|
}
|
|
170
|
-
/**
|
|
171
|
-
* Operator-facing notice for a Host whose Subagent runtime cannot be routed.
|
|
172
|
-
*
|
|
173
|
-
* DSH 0.2.1 replaced `start()`/`startContinuable()` with the activation API, so
|
|
174
|
-
* this adapter's override point is gone; the row then mounts the untouched
|
|
175
|
-
* official runtime instead of guessing a new seam.
|
|
176
|
-
* @param error - the typed startup incompatibility that rejected the candidate.
|
|
177
|
-
* @returns The notice logged once at startup.
|
|
178
|
-
*/
|
|
179
74
|
function routedRuntimeUnavailableNotice(error) {
|
|
180
75
|
return `model-switch: the routed Subagent runtime is unavailable on this DSH Host (${error.message}); delegation follows the official route instead`;
|
|
181
76
|
}
|
|
182
|
-
/**
|
|
183
|
-
function
|
|
184
|
-
|
|
185
|
-
ctx.logger.warn(message);
|
|
186
|
-
} catch {}
|
|
77
|
+
/** @deprecated Only the legacy subclass needs a mirrored dependency list. */
|
|
78
|
+
function subagentRuntimeInject(officialInject) {
|
|
79
|
+
return [.../* @__PURE__ */ new Set([...officialInject ?? [], "modelSwitch"])];
|
|
187
80
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
return async () => {
|
|
193
|
-
await official.dispose();
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
return (await mountWithStartupFallback(async (track) => {
|
|
197
|
-
try {
|
|
198
|
-
assertOfficialRuntimeSurface();
|
|
199
|
-
} catch (error) {
|
|
200
|
-
if (error instanceof StartupIncompatibilityError) reportNotice(ctx, routedRuntimeUnavailableNotice(error));
|
|
201
|
-
throw error;
|
|
202
|
-
}
|
|
203
|
-
assertRoutingSurface(ctx);
|
|
204
|
-
const candidate = ctx.plugin(ModelSwitchSubagentRuntime);
|
|
205
|
-
track(() => candidate.dispose());
|
|
206
|
-
await candidate;
|
|
207
|
-
const surface = ctx.inject(["subagents"], (surfaceCtx) => {
|
|
208
|
-
assertMountedSurface(surfaceCtx);
|
|
209
|
-
});
|
|
210
|
-
track(() => surface.dispose());
|
|
211
|
-
await surface;
|
|
212
|
-
return candidate;
|
|
213
|
-
}, async (track) => {
|
|
214
|
-
const official = ctx.plugin(OfficialSubagentRuntime);
|
|
215
|
-
track(() => official.dispose());
|
|
216
|
-
await official;
|
|
217
|
-
return official;
|
|
218
|
-
})).dispose;
|
|
81
|
+
function publicMethod(method) {
|
|
82
|
+
const value = Reflect.get(OfficialSubagentRuntime.prototype, method);
|
|
83
|
+
if (typeof value !== "function") throw new StartupIncompatibilityError("OfficialSubagentRuntime", `OfficialSubagentRuntime must expose public ${method}()`);
|
|
84
|
+
return value;
|
|
219
85
|
}
|
|
220
|
-
/** Profile replacement that selects the routed runtime or the untouched official runtime. */
|
|
221
|
-
const profileSubagentRuntime = Object.assign(async (ctx) => mountProfileRuntime(ctx), {});
|
|
222
86
|
/**
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
* `inject` from the class it mounts — a static list on this subclass *replaces*
|
|
227
|
-
* the base class's list instead of adding to it. DSH 0.2.1's runtime declares
|
|
228
|
-
* `workingDirectory` and reads it on every activation
|
|
229
|
-
* (`ctx.workingDirectory.ensure(...)`); declaring only `modelSwitch` hid that
|
|
230
|
-
* dependency, so every delegation failed with
|
|
231
|
-
* `cannot get property "workingDirectory" without inject`. The list is read from
|
|
232
|
-
* the installed runtime instead of hard-coded so a future Host dependency is
|
|
233
|
-
* mirrored too.
|
|
87
|
+
* @deprecated Kept importable for existing consumers, not mounted by the bundle.
|
|
88
|
+
* Install profileSubagentRuntime around the official service instead: the
|
|
89
|
+
* official Loader row must remain enabled to own its strict Typert definitions.
|
|
234
90
|
*/
|
|
235
|
-
const OFFICIAL_RUNTIME_INJECT = (() => {
|
|
236
|
-
const declared = OfficialSubagentRuntime.inject;
|
|
237
|
-
return Array.isArray(declared) ? [...declared] : [];
|
|
238
|
-
})();
|
|
239
|
-
/**
|
|
240
|
-
* The plugin dependency list for the mounted runtime.
|
|
241
|
-
*
|
|
242
|
-
* Static inheritance does not merge `inject`: cordis reads the static list off
|
|
243
|
-
* the class it mounts, so the subclass must repeat every service the official
|
|
244
|
-
* runtime's own code reads and add the route surface this adapter uses.
|
|
245
|
-
* @param officialInject - the installed runtime's declared dependencies (absent on 0.1.7/0.2.0).
|
|
246
|
-
* @returns The deduplicated list, official dependencies first.
|
|
247
|
-
*/
|
|
248
|
-
function subagentRuntimeInject(officialInject) {
|
|
249
|
-
return [.../* @__PURE__ */ new Set([...officialInject ?? [], "modelSwitch"])];
|
|
250
|
-
}
|
|
251
|
-
/** Official runtime with only a pre-descriptor route-selection adapter. */
|
|
252
91
|
var ModelSwitchSubagentRuntime = class extends OfficialSubagentRuntime {
|
|
253
|
-
static inject = subagentRuntimeInject(
|
|
92
|
+
static inject = subagentRuntimeInject(OfficialSubagentRuntime.inject);
|
|
254
93
|
routed(name, request) {
|
|
255
94
|
const provider = this.ctx.subagents.getProvider(name);
|
|
256
95
|
if (provider !== void 0 && provider.capabilities.agentOptions !== true) return request;
|
|
257
|
-
|
|
258
|
-
return routeSubagentRequest(request, sessionSubagentRouteOf(this.ctx, request.parent.session, modelSwitch.currentSettings()));
|
|
96
|
+
return routeSubagentRequest(request, sessionSubagentRouteOf(this.ctx, request.parent.session, this.ctx.modelSwitch.currentSettings()));
|
|
259
97
|
}
|
|
260
98
|
start(name, request) {
|
|
261
|
-
return publicMethod(
|
|
99
|
+
return Reflect.apply(publicMethod("start"), this, [name, this.routed(name, request)]);
|
|
262
100
|
}
|
|
263
101
|
startContinuable(spec) {
|
|
264
|
-
return publicMethod(
|
|
102
|
+
return Reflect.apply(publicMethod("startContinuable"), this, [{
|
|
265
103
|
...spec,
|
|
266
104
|
request: this.routed(spec.provider, spec.request)
|
|
267
|
-
});
|
|
105
|
+
}]);
|
|
268
106
|
}
|
|
269
|
-
/**
|
|
270
|
-
* 0.2.1+ activation entry: delegation tools call this instead of
|
|
271
|
-
* `start()`/`startContinuable()`, and its spec carries the same
|
|
272
|
-
* `request.agentOptions` this adapter already rewrites. Every other spec
|
|
273
|
-
* field (label, childId, signal, delivery) passes through untouched.
|
|
274
|
-
*
|
|
275
|
-
* @param spec - the activation spec published by the installed Host.
|
|
276
|
-
* @returns The official activation result.
|
|
277
|
-
*/
|
|
278
107
|
startActivation(spec) {
|
|
279
|
-
return publicMethod(
|
|
108
|
+
return Reflect.apply(publicMethod("startActivation"), this, [{
|
|
280
109
|
...spec,
|
|
281
110
|
request: this.routed(spec.provider, spec.request)
|
|
282
|
-
});
|
|
111
|
+
}]);
|
|
283
112
|
}
|
|
284
113
|
};
|
|
285
114
|
//#endregion
|
|
286
|
-
|
|
115
|
+
//#region lib/types/subagent-runtime.js
|
|
116
|
+
function present(value) {
|
|
117
|
+
return typeof value === "string" && value.trim() !== "";
|
|
118
|
+
}
|
|
119
|
+
function spawnHasAnyRouteField(options) {
|
|
120
|
+
return present(options?.provider) || present(options?.model) || options?.reasoningEffort !== void 0;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Inject a parent-session route only when the caller named no provider, model,
|
|
124
|
+
* or reasoning effort. All other request and Agent options pass through.
|
|
125
|
+
*/
|
|
126
|
+
function routeSubagentRequest(request, route) {
|
|
127
|
+
if (spawnHasAnyRouteField(request.agentOptions) || route === void 0) return request;
|
|
128
|
+
return {
|
|
129
|
+
...request,
|
|
130
|
+
agentOptions: {
|
|
131
|
+
...request.agentOptions,
|
|
132
|
+
provider: route.provider,
|
|
133
|
+
model: route.model,
|
|
134
|
+
...route.reasoningEffort === void 0 ? {} : { reasoningEffort: ReasoningEffortId(route.reasoningEffort) }
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
/** Resolve the current public route surface, never retaining a disposed service. */
|
|
139
|
+
function routedSubagentRequest(ctx, runtime, providerName, request) {
|
|
140
|
+
if (spawnHasAnyRouteField(request.agentOptions)) return request;
|
|
141
|
+
const provider = runtime.getProvider?.(providerName);
|
|
142
|
+
if (provider !== void 0 && provider.capabilities?.agentOptions !== true) return request;
|
|
143
|
+
let modelSwitch;
|
|
144
|
+
try {
|
|
145
|
+
modelSwitch = ctx.get("modelSwitch");
|
|
146
|
+
} catch {
|
|
147
|
+
return request;
|
|
148
|
+
}
|
|
149
|
+
if (typeof modelSwitch?.currentSettings !== "function") return request;
|
|
150
|
+
return routeSubagentRequest(request, sessionSubagentRouteOf(ctx, request.parent.session, modelSwitch.currentSettings()));
|
|
151
|
+
}
|
|
152
|
+
/** A tracing proxy is for calls, not method ownership or descriptor restoration. */
|
|
153
|
+
function originalService(value) {
|
|
154
|
+
const original = Reflect.get(value, symbols.original);
|
|
155
|
+
return original !== null && (typeof original === "object" || typeof original === "function") ? original : value;
|
|
156
|
+
}
|
|
157
|
+
function isRequest(value) {
|
|
158
|
+
if (typeof value !== "object" || value === null) return false;
|
|
159
|
+
const parent = Reflect.get(value, "parent");
|
|
160
|
+
return typeof parent === "object" && parent !== null && Reflect.get(parent, "session") !== void 0;
|
|
161
|
+
}
|
|
162
|
+
function warn(ctx, message) {
|
|
163
|
+
try {
|
|
164
|
+
ctx.logger.warn(message);
|
|
165
|
+
} catch {}
|
|
166
|
+
}
|
|
167
|
+
const wrappers = /* @__PURE__ */ new WeakMap();
|
|
168
|
+
function routeFor(state, provider, request) {
|
|
169
|
+
const ctx = [...state.leases].at(-1)?.ctx;
|
|
170
|
+
return ctx === void 0 ? request : routedSubagentRequest(ctx, state.runtime, provider, request);
|
|
171
|
+
}
|
|
172
|
+
function wrapMethod(target, key, factory) {
|
|
173
|
+
const original = Reflect.get(target, key);
|
|
174
|
+
if (typeof original !== "function") return void 0;
|
|
175
|
+
const previous = Object.getOwnPropertyDescriptor(target, key);
|
|
176
|
+
const wrapped = factory(original);
|
|
177
|
+
Object.defineProperty(target, key, {
|
|
178
|
+
configurable: true,
|
|
179
|
+
enumerable: previous?.enumerable ?? false,
|
|
180
|
+
writable: true,
|
|
181
|
+
value: wrapped
|
|
182
|
+
});
|
|
183
|
+
return () => {
|
|
184
|
+
if (Object.getOwnPropertyDescriptor(target, key)?.value !== wrapped) return;
|
|
185
|
+
if (previous === void 0) Reflect.deleteProperty(target, key);
|
|
186
|
+
else Object.defineProperty(target, key, previous);
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Wrap the official service's start entries only. Its identity, prototype,
|
|
191
|
+
* registry, manager, Typert binding and prompt/interrupt methods are untouched.
|
|
192
|
+
* Disposers are idempotent and safe when overlapping adapter fibers unload in
|
|
193
|
+
* either order. Unsupported or sealed surfaces leave the official route usable.
|
|
194
|
+
*/
|
|
195
|
+
function installSubagentRouteWrappers(ctx) {
|
|
196
|
+
const service = ctx.get("subagents");
|
|
197
|
+
if (service === void 0) {
|
|
198
|
+
warn(ctx, "model-switch: subagents service is unavailable; delegation keeps the official route");
|
|
199
|
+
return () => {};
|
|
200
|
+
}
|
|
201
|
+
const runtime = originalService(service);
|
|
202
|
+
let state = wrappers.get(runtime);
|
|
203
|
+
if (state === void 0) {
|
|
204
|
+
state = {
|
|
205
|
+
runtime,
|
|
206
|
+
leases: /* @__PURE__ */ new Set(),
|
|
207
|
+
restores: []
|
|
208
|
+
};
|
|
209
|
+
const current = state;
|
|
210
|
+
const wrap = (key, factory) => {
|
|
211
|
+
const restore = wrapMethod(runtime, key, factory);
|
|
212
|
+
if (restore !== void 0) current.restores.push(restore);
|
|
213
|
+
};
|
|
214
|
+
try {
|
|
215
|
+
for (const key of ["startActivation", "startContinuable"]) wrap(key, (original) => function(...args) {
|
|
216
|
+
const rawSpec = args[0];
|
|
217
|
+
if (typeof rawSpec !== "object" || rawSpec === null) return Reflect.apply(original, this, args);
|
|
218
|
+
const spec = rawSpec;
|
|
219
|
+
if (typeof spec.provider !== "string" || !isRequest(spec.request)) return Reflect.apply(original, this, args);
|
|
220
|
+
const request = routeFor(current, spec.provider, spec.request);
|
|
221
|
+
return Reflect.apply(original, this, [request === spec.request ? spec : {
|
|
222
|
+
...spec,
|
|
223
|
+
request
|
|
224
|
+
}, ...args.slice(1)]);
|
|
225
|
+
});
|
|
226
|
+
wrap("start", (original) => function(...args) {
|
|
227
|
+
const [provider, request] = args;
|
|
228
|
+
if (typeof provider !== "string" || !isRequest(request)) return Reflect.apply(original, this, args);
|
|
229
|
+
return Reflect.apply(original, this, [
|
|
230
|
+
provider,
|
|
231
|
+
routeFor(current, provider, request),
|
|
232
|
+
...args.slice(2)
|
|
233
|
+
]);
|
|
234
|
+
});
|
|
235
|
+
} catch (error) {
|
|
236
|
+
for (const restore of current.restores.reverse()) restore();
|
|
237
|
+
warn(ctx, `model-switch: Subagent starts cannot be wrapped (${String(error)}); delegation keeps the official route`);
|
|
238
|
+
return () => {};
|
|
239
|
+
}
|
|
240
|
+
if (current.restores.length === 0) {
|
|
241
|
+
warn(ctx, "model-switch: no supported public Subagent start entry; delegation keeps the official route");
|
|
242
|
+
return () => {};
|
|
243
|
+
}
|
|
244
|
+
wrappers.set(runtime, state);
|
|
245
|
+
}
|
|
246
|
+
const lease = { ctx };
|
|
247
|
+
state.leases.add(lease);
|
|
248
|
+
const owned = state;
|
|
249
|
+
return () => {
|
|
250
|
+
if (!owned.leases.delete(lease) || owned.leases.size > 0) return;
|
|
251
|
+
for (const restore of [...owned.restores].reverse()) restore();
|
|
252
|
+
wrappers.delete(runtime);
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Wait for the official service without replacing it or copying its dependency
|
|
257
|
+
* list. Model Switch is read optionally per call, so its absence cannot hold a
|
|
258
|
+
* startup fiber or retain a stale settings service. Cordis rebinds this effect
|
|
259
|
+
* when the official service is recreated.
|
|
260
|
+
*/
|
|
261
|
+
function profileSubagentRuntime(ctx) {
|
|
262
|
+
ctx.inject(["subagents"], (scope) => {
|
|
263
|
+
scope.effect(() => installSubagentRouteWrappers(scope), "Model Switch: route official Subagent starts");
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
//#endregion
|
|
267
|
+
export { ModelSwitchSubagentRuntime, StartupIncompatibilityError, profileSubagentRuntime as default, profileSubagentRuntime, installSubagentRouteWrappers, mountWithStartupFallback, routeSubagentRequest, routedRuntimeUnavailableNotice, routedSubagentRequest, subagentRuntimeInject, subagentSurfaceOf };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** Viewport placement result written imperatively onto the portaled menu. */
|
|
2
|
+
/**
|
|
3
|
+
* Viewport-edge clamps are emitted as CSS custom properties; the stylesheet
|
|
4
|
+
* composes them with the env(safe-area-inset-*) floors (see `.menu` in
|
|
5
|
+
* ComposerPicker.module.css):
|
|
6
|
+
*
|
|
7
|
+
* top: max(var(--dsh-menu-top), calc(env(safe-area-inset-top) + gutter));
|
|
8
|
+
* right: max(var(--dsh-menu-right), calc(env(safe-area-inset-right) + gutter));
|
|
9
|
+
* max-height: min(var(--dsh-menu-max-height), calc(100dvh - env(safe-area-inset-bottom) - env(safe-area-inset-top)));
|
|
10
|
+
*
|
|
11
|
+
* Numbers come from innerWidth/innerHeight, which exclude browser chrome but
|
|
12
|
+
* not display cutouts, so the stylesheet side of the max()/min() keeps the
|
|
13
|
+
* popup inside the safe area on notched phones.
|
|
14
|
+
*/
|
|
15
|
+
export interface PopupPlacementStyle {
|
|
16
|
+
readonly '--dsh-menu-top': string;
|
|
17
|
+
readonly '--dsh-menu-right': string;
|
|
18
|
+
readonly '--dsh-menu-max-height': string;
|
|
19
|
+
readonly visibility: 'visible';
|
|
20
|
+
}
|
|
21
|
+
export declare function samePlacement(left: PopupPlacementStyle | undefined, right: PopupPlacementStyle): boolean;
|
|
22
|
+
export interface PopupPlacementInput {
|
|
23
|
+
readonly trigger: {
|
|
24
|
+
readonly left: number;
|
|
25
|
+
readonly right: number;
|
|
26
|
+
readonly top: number;
|
|
27
|
+
readonly bottom: number;
|
|
28
|
+
};
|
|
29
|
+
readonly menu: {
|
|
30
|
+
readonly width: number;
|
|
31
|
+
readonly height: number;
|
|
32
|
+
};
|
|
33
|
+
readonly viewport: {
|
|
34
|
+
readonly width: number;
|
|
35
|
+
readonly height: number;
|
|
36
|
+
};
|
|
37
|
+
readonly gutter?: number;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Position the portaled picker menu in viewport coordinates, right-aligned to
|
|
41
|
+
* its trigger and preferring the space above it, clamped to the viewport.
|
|
42
|
+
*/
|
|
43
|
+
/**
|
|
44
|
+
* Position the portaled picker menu in viewport coordinates, right-aligned to
|
|
45
|
+
* its trigger and preferring the space above it, clamped to the viewport.
|
|
46
|
+
*
|
|
47
|
+
* The height clamp is the viewport budget only (never a content measurement):
|
|
48
|
+
* the stylesheet caps the box at that budget, so taller menu panes grow into
|
|
49
|
+
* it naturally and a later ResizeObserver pass only re-reads the rendered box
|
|
50
|
+
* to re-anchor the trigger edge. Capping from the measured box would instead
|
|
51
|
+
* lock the menu at whatever height it first rendered with.
|
|
52
|
+
*/
|
|
53
|
+
export declare function placeComposerPopup({ trigger, menu, viewport, gutter }: PopupPlacementInput): PopupPlacementStyle;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type MouseEvent as ReactMouseEvent, type PointerEvent as ReactPointerEvent, type RefObject } from 'react';
|
|
2
2
|
import { type PickerInteractionOperations } from './popup-dismissal.ts';
|
|
3
3
|
export interface ComposerPickerSurfaceOptions {
|
|
4
4
|
locked: boolean;
|
|
@@ -13,7 +13,6 @@ export interface ComposerPickerSurfaceOptions {
|
|
|
13
13
|
export interface ComposerPickerSurface {
|
|
14
14
|
id: string;
|
|
15
15
|
open: boolean;
|
|
16
|
-
menuStyle: CSSProperties;
|
|
17
16
|
triggerRef: RefObject<HTMLButtonElement>;
|
|
18
17
|
menuRef: RefObject<HTMLDivElement>;
|
|
19
18
|
show: () => void;
|
|
@@ -21,5 +20,5 @@ export interface ComposerPickerSurface {
|
|
|
21
20
|
onTriggerPointerDown: (event: ReactPointerEvent<HTMLButtonElement>) => void;
|
|
22
21
|
onTriggerClick: (event?: ReactMouseEvent<HTMLButtonElement>) => void;
|
|
23
22
|
}
|
|
24
|
-
/** Own popup activation,
|
|
23
|
+
/** Own popup activation, viewport placement, and dismissal behind one internal seam. */
|
|
25
24
|
export declare function useComposerPickerSurface(options: ComposerPickerSurfaceOptions): ComposerPickerSurface;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import OfficialSubagentRuntime, { type ContinuableStart, type ContinuableStartSpec, type SubagentRun, type SubagentStartRequest } from '@deepseek-ai/dsh-subagent';
|
|
2
|
+
import { type SubagentActivationSpecLike } from './subagent-runtime.js';
|
|
3
|
+
/** Previously published startup error; retained for consumers of this module. */
|
|
4
|
+
export declare class StartupIncompatibilityError extends Error {
|
|
5
|
+
readonly name = "StartupIncompatibilityError";
|
|
6
|
+
readonly surface: string;
|
|
7
|
+
constructor(surfaceOrMessage: string, message?: string);
|
|
8
|
+
}
|
|
9
|
+
export type StartupDisposer = () => void | PromiseLike<void>;
|
|
10
|
+
export type StartupCleanupTracker = (dispose: StartupDisposer) => void;
|
|
11
|
+
export interface MountedStartup<T> {
|
|
12
|
+
readonly value: T;
|
|
13
|
+
readonly dispose: () => Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
export type SubagentSurfaceLine = 'activation' | 'start';
|
|
16
|
+
/** Classify the two published start API generations without version guessing. */
|
|
17
|
+
export declare function subagentSurfaceOf(value: unknown): SubagentSurfaceLine | undefined;
|
|
18
|
+
/** Retain the typed-only startup fallback and reverse, idempotent cleanup contract. */
|
|
19
|
+
export declare function mountWithStartupFallback<T>(candidate: (track: StartupCleanupTracker) => Promise<T>, fallback: (track: StartupCleanupTracker) => Promise<T>): Promise<MountedStartup<T>>;
|
|
20
|
+
export declare function routedRuntimeUnavailableNotice(error: StartupIncompatibilityError): string;
|
|
21
|
+
/** @deprecated Only the legacy subclass needs a mirrored dependency list. */
|
|
22
|
+
export declare function subagentRuntimeInject(officialInject: readonly string[] | undefined): string[];
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated Kept importable for existing consumers, not mounted by the bundle.
|
|
25
|
+
* Install profileSubagentRuntime around the official service instead: the
|
|
26
|
+
* official Loader row must remain enabled to own its strict Typert definitions.
|
|
27
|
+
*/
|
|
28
|
+
export declare class ModelSwitchSubagentRuntime extends OfficialSubagentRuntime {
|
|
29
|
+
static inject: string[];
|
|
30
|
+
private routed;
|
|
31
|
+
start(name: string, request: SubagentStartRequest): Promise<SubagentRun>;
|
|
32
|
+
startContinuable(spec: ContinuableStartSpec): Promise<ContinuableStart>;
|
|
33
|
+
startActivation(spec: SubagentActivationSpecLike): Promise<unknown>;
|
|
34
|
+
}
|
|
@@ -1,116 +1,51 @@
|
|
|
1
|
-
import { Context } from '@deepseek-ai/cordis';
|
|
2
|
-
import
|
|
1
|
+
import { type Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import type { SubagentStartRequest } from '@deepseek-ai/dsh-subagent';
|
|
3
3
|
import { type SubagentRoute } from './session-route.js';
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*/
|
|
12
|
-
constructor(surfaceOrMessage: string, message?: string);
|
|
4
|
+
export { ModelSwitchSubagentRuntime, StartupIncompatibilityError, mountWithStartupFallback, routedRuntimeUnavailableNotice, subagentRuntimeInject, subagentSurfaceOf, } from './subagent-runtime-legacy.js';
|
|
5
|
+
export type { MountedStartup, StartupCleanupTracker, StartupDisposer, SubagentSurfaceLine, } from './subagent-runtime-legacy.js';
|
|
6
|
+
type RoutableSubagentRequest = Pick<SubagentStartRequest, 'parent' | 'agentOptions'>;
|
|
7
|
+
interface SubagentProviderSurface {
|
|
8
|
+
readonly capabilities?: {
|
|
9
|
+
readonly agentOptions?: boolean;
|
|
10
|
+
};
|
|
13
11
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export interface MountedStartup<T> {
|
|
20
|
-
readonly value: T;
|
|
21
|
-
readonly dispose: () => Promise<void>;
|
|
12
|
+
interface SubagentRuntimeSurface {
|
|
13
|
+
getProvider?(name: string): SubagentProviderSurface | undefined;
|
|
14
|
+
readonly startActivation?: unknown;
|
|
15
|
+
readonly start?: unknown;
|
|
16
|
+
readonly startContinuable?: unknown;
|
|
22
17
|
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* The 0.2.1+ activation spec, declared structurally.
|
|
26
|
-
*
|
|
27
|
-
* The pinned dependency typings predate the activation API, so the modern entry
|
|
28
|
-
* is described here and delegated through the base prototype. `request` carries
|
|
29
|
-
* the same `parent`/`agentOptions` pair the legacy start request does, which is
|
|
30
|
-
* why one route adapter serves both lines.
|
|
31
|
-
*/
|
|
18
|
+
/** The public 0.2.1+ activation shape used by tools and Agent Teams. */
|
|
32
19
|
export interface SubagentActivationSpecLike {
|
|
33
20
|
readonly provider: string;
|
|
34
|
-
readonly request:
|
|
21
|
+
readonly request: RoutableSubagentRequest & Record<string, unknown>;
|
|
22
|
+
readonly [field: string]: unknown;
|
|
23
|
+
}
|
|
24
|
+
/** Structural form of the pre-0.2.1 continuation start API. */
|
|
25
|
+
export interface ContinuableStartSpecLike {
|
|
26
|
+
readonly provider: string;
|
|
27
|
+
readonly request: RoutableSubagentRequest & Record<string, unknown>;
|
|
35
28
|
readonly [field: string]: unknown;
|
|
36
29
|
}
|
|
37
30
|
/**
|
|
38
|
-
* Inject
|
|
39
|
-
*
|
|
40
|
-
* A spawn that already names a provider, model, or effort keeps it: the caller's
|
|
41
|
-
* explicit selection outranks any profile policy. The route itself is derived
|
|
42
|
-
* from the DELEGATING session (its provider selects a saved group, else the flat
|
|
43
|
-
* Subagent card in `fixed` mode), so two sessions on different providers route
|
|
44
|
-
* their own spawns and neither can rewrite the other's policy.
|
|
45
|
-
* @param request - the caller's spawn request.
|
|
46
|
-
* @param route - the delegating session's resolved route, or undefined for official inherit.
|
|
47
|
-
* @returns The request to hand the official runtime.
|
|
31
|
+
* Inject a parent-session route only when the caller named no provider, model,
|
|
32
|
+
* or reasoning effort. All other request and Agent options pass through.
|
|
48
33
|
*/
|
|
49
34
|
export declare function routeSubagentRequest<T extends RoutableSubagentRequest>(request: T, route: SubagentRoute | undefined): T;
|
|
50
|
-
/**
|
|
51
|
-
export
|
|
52
|
-
/**
|
|
53
|
-
* Classify the runtime surface this Host publishes.
|
|
54
|
-
*
|
|
55
|
-
* DSH 0.2.1 replaced `start()` / `startContinuable()` with the activation API
|
|
56
|
-
* (`startActivation`), so a version-agnostic adapter has to recognize both
|
|
57
|
-
* lines instead of hard-coding one.
|
|
58
|
-
*
|
|
59
|
-
* @param value - a runtime class's prototype or a mounted runtime instance.
|
|
60
|
-
* @returns `activation` (0.2.1+), `start` (0.1.7/0.2.0), or undefined when neither is published.
|
|
61
|
-
*/
|
|
62
|
-
export declare function subagentSurfaceOf(value: unknown): SubagentSurfaceLine | undefined;
|
|
35
|
+
/** Resolve the current public route surface, never retaining a disposed service. */
|
|
36
|
+
export declare function routedSubagentRequest<T extends RoutableSubagentRequest>(ctx: Context, runtime: SubagentRuntimeSurface, providerName: string, request: T): T;
|
|
63
37
|
/**
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* running after failures, and a startup error stays first in any aggregate.
|
|
69
|
-
*
|
|
70
|
-
* @param candidate - startup callback for the routed candidate.
|
|
71
|
-
* @param fallback - startup callback for the untouched official runtime.
|
|
72
|
-
* @returns the selected value and an idempotent disposer.
|
|
73
|
-
* @throws the candidate error unless it is a StartupIncompatibilityError.
|
|
74
|
-
* @throws the fallback startup error when fallback startup fails.
|
|
38
|
+
* Wrap the official service's start entries only. Its identity, prototype,
|
|
39
|
+
* registry, manager, Typert binding and prompt/interrupt methods are untouched.
|
|
40
|
+
* Disposers are idempotent and safe when overlapping adapter fibers unload in
|
|
41
|
+
* either order. Unsupported or sealed surfaces leave the official route usable.
|
|
75
42
|
*/
|
|
76
|
-
export declare function
|
|
43
|
+
export declare function installSubagentRouteWrappers(ctx: Context): () => void;
|
|
77
44
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
* official runtime instead of guessing a new seam.
|
|
83
|
-
* @param error - the typed startup incompatibility that rejected the candidate.
|
|
84
|
-
* @returns The notice logged once at startup.
|
|
45
|
+
* Wait for the official service without replacing it or copying its dependency
|
|
46
|
+
* list. Model Switch is read optionally per call, so its absence cannot hold a
|
|
47
|
+
* startup fiber or retain a stale settings service. Cordis rebinds this effect
|
|
48
|
+
* when the official service is recreated.
|
|
85
49
|
*/
|
|
86
|
-
export declare function
|
|
87
|
-
/** Profile replacement that selects the routed runtime or the untouched official runtime. */
|
|
88
|
-
export declare const profileSubagentRuntime: (ctx: Context) => Promise<() => Promise<void>>;
|
|
89
|
-
/**
|
|
90
|
-
* The plugin dependency list for the mounted runtime.
|
|
91
|
-
*
|
|
92
|
-
* Static inheritance does not merge `inject`: cordis reads the static list off
|
|
93
|
-
* the class it mounts, so the subclass must repeat every service the official
|
|
94
|
-
* runtime's own code reads and add the route surface this adapter uses.
|
|
95
|
-
* @param officialInject - the installed runtime's declared dependencies (absent on 0.1.7/0.2.0).
|
|
96
|
-
* @returns The deduplicated list, official dependencies first.
|
|
97
|
-
*/
|
|
98
|
-
export declare function subagentRuntimeInject(officialInject: readonly string[] | undefined): string[];
|
|
99
|
-
/** Official runtime with only a pre-descriptor route-selection adapter. */
|
|
100
|
-
export declare class ModelSwitchSubagentRuntime extends OfficialSubagentRuntime {
|
|
101
|
-
static inject: string[];
|
|
102
|
-
private routed;
|
|
103
|
-
start(name: string, request: SubagentStartRequest): Promise<SubagentRun>;
|
|
104
|
-
startContinuable(spec: ContinuableStartSpec): Promise<ContinuableStart>;
|
|
105
|
-
/**
|
|
106
|
-
* 0.2.1+ activation entry: delegation tools call this instead of
|
|
107
|
-
* `start()`/`startContinuable()`, and its spec carries the same
|
|
108
|
-
* `request.agentOptions` this adapter already rewrites. Every other spec
|
|
109
|
-
* field (label, childId, signal, delivery) passes through untouched.
|
|
110
|
-
*
|
|
111
|
-
* @param spec - the activation spec published by the installed Host.
|
|
112
|
-
* @returns The official activation result.
|
|
113
|
-
*/
|
|
114
|
-
startActivation(spec: SubagentActivationSpecLike): Promise<unknown>;
|
|
115
|
-
}
|
|
50
|
+
export declare function profileSubagentRuntime(ctx: Context): void;
|
|
116
51
|
export default profileSubagentRuntime;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Safe reads of the optional Model Switch settings service for the naming row.
|
|
3
|
+
*
|
|
4
|
+
* The session-naming row must keep the official naming behavior when the
|
|
5
|
+
* `model-switch` row is absent, so `modelSwitch` can never join the row's own
|
|
6
|
+
* `inject` list: Cordis waits for every declared dependency before a fiber
|
|
7
|
+
* loads (there is no "optional" inject), and a never-provided service would
|
|
8
|
+
* leave the row pending forever.
|
|
9
|
+
*
|
|
10
|
+
* Two reads are tried per call, in this order:
|
|
11
|
+
*
|
|
12
|
+
* 1. `ctx.get('modelSwitch')` with Cordis' default strict mode — the active
|
|
13
|
+
* implementation only, or undefined. This is the read the shipped row used
|
|
14
|
+
* and it keeps working across a settings-row rebuild because the store
|
|
15
|
+
* entry is replaced, not cached here.
|
|
16
|
+
* 2. A scoped `ctx.inject(['modelSwitch'])` child fiber, which binds a
|
|
17
|
+
* dependent scope and resets it on dispose. This covers compositions where
|
|
18
|
+
* the strict store read is invisible from the row's own entry context.
|
|
19
|
+
*
|
|
20
|
+
* The returned function identity is stable for the row's lifetime and every
|
|
21
|
+
* call re-reads, so a settings save or a service rebuild needs no remount.
|
|
22
|
+
* Reads never throw: a missing face, a disposed scope, or a throwing read all
|
|
23
|
+
* answer undefined, which means "official behavior" to the caller.
|
|
24
|
+
*
|
|
25
|
+
* @module dsh-model-switch/title-settings-reader
|
|
26
|
+
*/
|
|
27
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
28
|
+
import type { ModelSwitchSettings } from './host-settings.js';
|
|
29
|
+
/**
|
|
30
|
+
* Create the settings reader for one naming row context.
|
|
31
|
+
* @param ctx - this row's context (the row fiber's own scope).
|
|
32
|
+
* @returns The reader: per-request live settings, or undefined when unavailable.
|
|
33
|
+
*/
|
|
34
|
+
export declare function titleSettingsReaderOf(ctx: Context): () => ModelSwitchSettings | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-model-switch",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.63",
|
|
4
4
|
"description": "Explicit model routing plus composer/Plan picker for DeepSeek Harness",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -122,7 +122,8 @@
|
|
|
122
122
|
"0.2.0-rc.2": "compatible",
|
|
123
123
|
"0.2.1-rc.2": "compatible",
|
|
124
124
|
"0.2.1-rc.3": "compatible",
|
|
125
|
-
"0.2.1-rc.5": "compatible"
|
|
125
|
+
"0.2.1-rc.5": "compatible",
|
|
126
|
+
"0.2.2-rc.1": "compatible"
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
129
|
},
|