@dsh-plus/subagent-model 0.3.8 → 0.3.10
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/lib/client.js +41 -7
- package/package.json +10 -10
- package/src/client/card.tsx +10 -4
- package/src/client/client.ts +12 -15
- package/src/client/i18n.ts +2 -0
- package/src/index.ts +3 -2
- package/src/service.ts +1 -1
package/lib/client.js
CHANGED
|
@@ -72,6 +72,35 @@ window.__ModuleLoader__.load({
|
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
74
|
//#endregion
|
|
75
|
+
//#region ../shared/src/client/config-slots.ts
|
|
76
|
+
/** dsh-plus 聚合 bundle 的包名(各插件 row 均经其补丁层插入 profile)。 */
|
|
77
|
+
const DSH_PLUS_BUNDLE = "@dsh-plus/bundle-main";
|
|
78
|
+
/**
|
|
79
|
+
* 把一张配置卡片同时注册进 legacy 与新版三个槽位。
|
|
80
|
+
* 任一槽位在当前 dsh 版本未声明时对应 inject 挂起等待,版本不命中即 no-op。
|
|
81
|
+
*/
|
|
82
|
+
function injectPluginConfigCard(slots, reg) {
|
|
83
|
+
const base = {
|
|
84
|
+
locale: reg.ns,
|
|
85
|
+
inject: reg.inject
|
|
86
|
+
};
|
|
87
|
+
slots.inject("settings.plugin.item", () => slots.register({
|
|
88
|
+
name: "settings.plugin.item",
|
|
89
|
+
key: reg.ns,
|
|
90
|
+
...base
|
|
91
|
+
}, reg.component));
|
|
92
|
+
slots.inject("plugins.row.config", () => slots.register({
|
|
93
|
+
name: "plugins.row.config",
|
|
94
|
+
key: `${DSH_PLUS_BUNDLE}#${reg.rowId}`,
|
|
95
|
+
...base
|
|
96
|
+
}, reg.component));
|
|
97
|
+
slots.inject("plugins.bundle.config", () => slots.register({
|
|
98
|
+
name: "plugins.bundle.config",
|
|
99
|
+
key: reg.pkg,
|
|
100
|
+
...base
|
|
101
|
+
}, reg.component));
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
75
104
|
//#region ../shared/src/client/fields.tsx
|
|
76
105
|
/**
|
|
77
106
|
* 勾选行:自绘圆角扁平开关(switch),对齐官方 WebUI 无原生 checkbox 的
|
|
@@ -426,7 +455,8 @@ ${extra}
|
|
|
426
455
|
//#endregion
|
|
427
456
|
//#region src/client/card.tsx
|
|
428
457
|
/**
|
|
429
|
-
*
|
|
458
|
+
* 「子代理模型配置」配置卡片:经 injectPluginConfigCard 注册(legacy settings.plugin.item
|
|
459
|
+
* 与 0.1.6-alpha.2 插件页 plugins.row.config / plugins.bundle.config,view 分发 summary/page)。
|
|
430
460
|
* 外壳与基础控件走 @dsh-plus/shared/client 套件(CardChrome/CheckRow/SelectField)。
|
|
431
461
|
* 配置读写走官方 settingsScope 传输:value 为 schema 解析后的命名空间值
|
|
432
462
|
* (enabled + entries),行集合 = 目录返回的已注册子代理 provider
|
|
@@ -558,7 +588,7 @@ ${extra}
|
|
|
558
588
|
const { t, scope, api } = props;
|
|
559
589
|
const snapshot = (0, react.useSyncExternalStore)((listener) => scope.subscribe(listener), () => scope.getSnapshot());
|
|
560
590
|
const value = snapshot.value;
|
|
561
|
-
const [open, setOpen] = (0, react.useState)(
|
|
591
|
+
const [open, setOpen] = (0, react.useState)(props.view === "page");
|
|
562
592
|
const [draft, setDraft] = (0, react.useState)(null);
|
|
563
593
|
const [catalog, setCatalog] = (0, react.useState)(null);
|
|
564
594
|
const [catalogFailed, setCatalogFailed] = (0, react.useState)(false);
|
|
@@ -602,6 +632,7 @@ ${extra}
|
|
|
602
632
|
catalog
|
|
603
633
|
]);
|
|
604
634
|
const invalid = (0, react.useMemo)(() => draft !== null && Object.values(draft.rows).some((row) => row.model.length > 0 && row.provider.length === 0), [draft]);
|
|
635
|
+
if (props.view === "summary") return t("summaryLine");
|
|
605
636
|
if (value === void 0 || draft === null) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
|
|
606
637
|
className: "dsm-card",
|
|
607
638
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
@@ -732,6 +763,7 @@ ${extra}
|
|
|
732
763
|
const ownZh = {
|
|
733
764
|
title: "子代理模型配置",
|
|
734
765
|
description: "为 subagent / subagent_fork 等子代理单独指定提供商、模型与思考程度,或继承主代理。",
|
|
766
|
+
summaryLine: "为子代理单独指定提供商、模型与思考程度,或继承主代理。",
|
|
735
767
|
enabled: "启用插件",
|
|
736
768
|
rowEnabled: "启用该行",
|
|
737
769
|
provider: "提供商",
|
|
@@ -756,6 +788,7 @@ ${extra}
|
|
|
756
788
|
const ownEn = {
|
|
757
789
|
title: "Subagent model config",
|
|
758
790
|
description: "Pick a provider, model, and thinking effort for subagent / subagent_fork children, or inherit from the main agent.",
|
|
791
|
+
summaryLine: "Pick a provider, model, and thinking effort for subagent children, or inherit.",
|
|
759
792
|
enabled: "Enable plugin",
|
|
760
793
|
rowEnabled: "Enable row",
|
|
761
794
|
provider: "Provider",
|
|
@@ -827,16 +860,17 @@ ${extra}
|
|
|
827
860
|
}), "subagent-model: locale");
|
|
828
861
|
const scope = createSettingsScope(c, SETTINGS_NS, "subagent-model: settings scope");
|
|
829
862
|
const api = createNamespaceApi(c.get("remote").settings, SETTINGS_NS);
|
|
830
|
-
c.slots
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
863
|
+
injectPluginConfigCard(c.slots, {
|
|
864
|
+
ns: SETTINGS_NS,
|
|
865
|
+
rowId: "dsh-plus-subagent-model",
|
|
866
|
+
pkg: "@dsh-plus/subagent-model",
|
|
867
|
+
component: SubagentModelCard,
|
|
834
868
|
inject: () => ({
|
|
835
869
|
t: c.locale.bind(NS),
|
|
836
870
|
scope,
|
|
837
871
|
api
|
|
838
872
|
})
|
|
839
|
-
}
|
|
873
|
+
});
|
|
840
874
|
}
|
|
841
875
|
//#endregion
|
|
842
876
|
exports.apply = apply;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dsh-plus/subagent-model",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.10",
|
|
4
4
|
"description": "dsh-plus service+ui plugin: 为 subagent/subagent_fork 等子代理按提供商配置模型与思考程度(或继承主代理)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -19,22 +19,22 @@
|
|
|
19
19
|
"src"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@dsh-plus/shared": "0.1.
|
|
22
|
+
"@dsh-plus/shared": "0.1.19"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"@deepseek-ai/cordis": "^4.0.2",
|
|
26
|
-
"@deepseek-ai/dsh-host-webserver": "^0.1.
|
|
27
|
-
"@deepseek-ai/dsh-llm": "^0.1.
|
|
28
|
-
"@deepseek-ai/dsh-settings": "^0.1.
|
|
29
|
-
"@deepseek-ai/dsh-subagent": "^0.1.
|
|
26
|
+
"@deepseek-ai/dsh-host-webserver": "^0.1.6-alpha.2",
|
|
27
|
+
"@deepseek-ai/dsh-llm": "^0.1.6-alpha.2",
|
|
28
|
+
"@deepseek-ai/dsh-settings": "^0.1.6-alpha.2",
|
|
29
|
+
"@deepseek-ai/dsh-subagent": "^0.1.6-alpha.2",
|
|
30
30
|
"@deepseek-ai/schemastery": "^3.18.2"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@deepseek-ai/cordis": "4.0.2",
|
|
34
|
-
"@deepseek-ai/dsh-host-webserver": "0.1.
|
|
35
|
-
"@deepseek-ai/dsh-llm": "0.1.
|
|
36
|
-
"@deepseek-ai/dsh-settings": "0.1.
|
|
37
|
-
"@deepseek-ai/dsh-subagent": "0.1.
|
|
34
|
+
"@deepseek-ai/dsh-host-webserver": "0.1.6-alpha.2",
|
|
35
|
+
"@deepseek-ai/dsh-llm": "0.1.6-alpha.2",
|
|
36
|
+
"@deepseek-ai/dsh-settings": "0.1.6-alpha.2",
|
|
37
|
+
"@deepseek-ai/dsh-subagent": "0.1.6-alpha.2",
|
|
38
38
|
"@deepseek-ai/schemastery": "3.18.2",
|
|
39
39
|
"@types/node": "26.4.0",
|
|
40
40
|
"@types/react": "~18.3.31",
|
package/src/client/card.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 「子代理模型配置」配置卡片:经 injectPluginConfigCard 注册(legacy settings.plugin.item
|
|
3
|
+
* 与 0.1.6-alpha.2 插件页 plugins.row.config / plugins.bundle.config,view 分发 summary/page)。
|
|
3
4
|
* 外壳与基础控件走 @dsh-plus/shared/client 套件(CardChrome/CheckRow/SelectField)。
|
|
4
5
|
* 配置读写走官方 settingsScope 传输:value 为 schema 解析后的命名空间值
|
|
5
6
|
* (enabled + entries),行集合 = 目录返回的已注册子代理 provider
|
|
@@ -14,6 +15,7 @@ import {
|
|
|
14
15
|
CheckRow,
|
|
15
16
|
IDLE_STATUS,
|
|
16
17
|
type NamespaceSettingsApi,
|
|
18
|
+
type PluginConfigViewProps,
|
|
17
19
|
type Scope,
|
|
18
20
|
SelectField,
|
|
19
21
|
type SelectOption,
|
|
@@ -30,7 +32,7 @@ import {
|
|
|
30
32
|
} from './draft.ts'
|
|
31
33
|
import type { Translate } from './i18n.ts'
|
|
32
34
|
|
|
33
|
-
export interface CardProps {
|
|
35
|
+
export interface CardProps extends PluginConfigViewProps {
|
|
34
36
|
t: Translate
|
|
35
37
|
scope: Scope
|
|
36
38
|
api: NamespaceSettingsApi
|
|
@@ -144,14 +146,15 @@ function RowBlock(props: RowBlockProps): ReactElement {
|
|
|
144
146
|
)
|
|
145
147
|
}
|
|
146
148
|
|
|
147
|
-
export function SubagentModelCard(props: CardProps): ReactElement | null {
|
|
149
|
+
export function SubagentModelCard(props: CardProps): ReactElement | string | null {
|
|
148
150
|
const { t, scope, api } = props
|
|
149
151
|
const snapshot = useSyncExternalStore(
|
|
150
152
|
(listener: () => void) => scope.subscribe(listener),
|
|
151
153
|
() => scope.getSnapshot(),
|
|
152
154
|
)
|
|
153
155
|
const value = snapshot.value as ConfigValue | undefined
|
|
154
|
-
|
|
156
|
+
// 0.1.6-alpha.2 插件页 page 视图为表单落地页,默认展开;旧槽位无 view,保持折叠。
|
|
157
|
+
const [open, setOpen] = useState(props.view === 'page')
|
|
155
158
|
const [draft, setDraft] = useState<Draft | null>(null)
|
|
156
159
|
const [catalog, setCatalog] = useState<ModelCatalog | null>(null)
|
|
157
160
|
const [catalogFailed, setCatalogFailed] = useState(false)
|
|
@@ -207,6 +210,9 @@ export function SubagentModelCard(props: CardProps): ReactElement | null {
|
|
|
207
210
|
[draft],
|
|
208
211
|
)
|
|
209
212
|
|
|
213
|
+
// 插件页 summary 视图只出一行简介(hooks 已全部落定,可安全提前返回)。
|
|
214
|
+
if (props.view === 'summary') return t('summaryLine')
|
|
215
|
+
|
|
210
216
|
if (value === undefined || draft === null) {
|
|
211
217
|
return (
|
|
212
218
|
<li className="dsm-card">
|
package/src/client/client.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 浏览器半入口:注册 locale 字典 +
|
|
2
|
+
* 浏览器半入口:注册 locale 字典 + 注册「子代理模型配置」卡片
|
|
3
|
+
* (injectPluginConfigCard 三槽位:legacy settings.plugin.item 与 0.1.6-alpha.2
|
|
4
|
+
* 独立插件页的 plugins.row.config / plugins.bundle.config)。
|
|
3
5
|
* 构建产物为 window.__ModuleLoader__.load({id, factory}) 形式的 CJS factory
|
|
4
6
|
* (包装见 tsdown.config.ts);样式沿用官方 data-plugin-css 约定,HMR 据此卸载。
|
|
5
7
|
*
|
|
@@ -8,9 +10,7 @@
|
|
|
8
10
|
* 0.1.2-alpha.1 起配置读写统一走 ctx.remote.settings 直连
|
|
9
11
|
* (connection.api.settings RPC 面已移除;不复用 settingsScope 服务——
|
|
10
12
|
* 非 loopback 页面下它固定 memory 模式无数据);自定义端点仅剩「模型目录」(api.ts)。
|
|
11
|
-
*
|
|
12
|
-
* (即服务端 SETTINGS_NS 注册的同一字面量,见 ../ns.ts),
|
|
13
|
-
* 官方配置页按此 key 与 Host 已注册命名空间配对分发。
|
|
13
|
+
* 卡片 key/rowId 约定见 @dsh-plus/shared/client/config-slots。
|
|
14
14
|
* @module @dsh-plus/subagent-model/client
|
|
15
15
|
*/
|
|
16
16
|
import type { Context } from '@deepseek-ai/cordis'
|
|
@@ -18,6 +18,7 @@ import type { Context } from '@deepseek-ai/cordis'
|
|
|
18
18
|
import {
|
|
19
19
|
createNamespaceApi,
|
|
20
20
|
createSettingsScope,
|
|
21
|
+
injectPluginConfigCard,
|
|
21
22
|
type PluginClientContext,
|
|
22
23
|
} from '@dsh-plus/shared/client'
|
|
23
24
|
import { SETTINGS_NS } from '../ns.ts'
|
|
@@ -45,15 +46,11 @@ export function apply(ctx: Context): void {
|
|
|
45
46
|
c.effect(() => c.locale.register(NS, { zh, en }), 'subagent-model: locale')
|
|
46
47
|
const scope = createSettingsScope(c, SETTINGS_NS, 'subagent-model: settings scope')
|
|
47
48
|
const api = createNamespaceApi(c.get('remote').settings, SETTINGS_NS)
|
|
48
|
-
c.slots
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
},
|
|
56
|
-
SubagentModelCard,
|
|
57
|
-
),
|
|
58
|
-
)
|
|
49
|
+
injectPluginConfigCard(c.slots, {
|
|
50
|
+
ns: SETTINGS_NS,
|
|
51
|
+
rowId: 'dsh-plus-subagent-model',
|
|
52
|
+
pkg: '@dsh-plus/subagent-model',
|
|
53
|
+
component: SubagentModelCard,
|
|
54
|
+
inject: () => ({ t: c.locale.bind(NS), scope, api }),
|
|
55
|
+
})
|
|
59
56
|
}
|
package/src/client/i18n.ts
CHANGED
|
@@ -10,6 +10,7 @@ export const NS = 'dsh-plus-subagent-model'
|
|
|
10
10
|
const ownZh = {
|
|
11
11
|
title: '子代理模型配置',
|
|
12
12
|
description: '为 subagent / subagent_fork 等子代理单独指定提供商、模型与思考程度,或继承主代理。',
|
|
13
|
+
summaryLine: '为子代理单独指定提供商、模型与思考程度,或继承主代理。',
|
|
13
14
|
enabled: '启用插件',
|
|
14
15
|
rowEnabled: '启用该行',
|
|
15
16
|
provider: '提供商',
|
|
@@ -37,6 +38,7 @@ const ownEn = {
|
|
|
37
38
|
title: 'Subagent model config',
|
|
38
39
|
description:
|
|
39
40
|
'Pick a provider, model, and thinking effort for subagent / subagent_fork children, or inherit from the main agent.',
|
|
41
|
+
summaryLine: 'Pick a provider, model, and thinking effort for subagent children, or inherit.',
|
|
40
42
|
enabled: 'Enable plugin',
|
|
41
43
|
rowEnabled: 'Enable row',
|
|
42
44
|
provider: 'Provider',
|
package/src/index.ts
CHANGED
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
* 主代理显式选择的路由(官方 subagent-model-selection 的 model 字段)优先,
|
|
6
6
|
* 本插件只补"未选择时的强制默认"。
|
|
7
7
|
* 配置经 settings 用户层($DSH_HOME/settings.yaml)持久化并热生效;
|
|
8
|
-
* 配置 UI 位于 webui
|
|
9
|
-
*
|
|
8
|
+
* 配置 UI 位于 webui 插件页(0.1.6-alpha.2 起为侧边栏「插件」页 bundle 行配置;
|
|
9
|
+
* 旧版为 设置-插件-插件配置 的 settings.plugin.item 卡片,经三槽位注册兼容,
|
|
10
|
+
* 见 @dsh-plus/shared/client/config-slots),模型目录经 host webServer 同源端点下发。
|
|
10
11
|
* @module @dsh-plus/subagent-model
|
|
11
12
|
*/
|
|
12
13
|
import type { Context } from '@deepseek-ai/cordis'
|
package/src/service.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* - 委托挂钩:包装 ctx.subagents.start/startContinuable,按 provider 名
|
|
7
7
|
* (未命中回落 default 条目)注入 agentOptions(provider/model/effort)。
|
|
8
8
|
* - 自定义端点:ctx.webServer 仅注册模型目录路由(配置读写已走官方
|
|
9
|
-
* remote.settings
|
|
9
|
+
* remote.settings 直连,配置卡片(三槽位注册)见 client 半)。
|
|
10
10
|
* @module @dsh-plus/subagent-model
|
|
11
11
|
*/
|
|
12
12
|
import type { Context } from '@deepseek-ai/cordis'
|