@dsh-plus/subagent-model 0.1.9 → 0.2.0
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/index.d.ts +1 -4
- package/lib/index.js +51 -193
- package/package.json +8 -31
- package/src/config.ts +33 -42
- package/src/delegation.ts +23 -54
- package/src/index.ts +5 -4
- package/src/ns.ts +3 -6
- package/src/service.ts +20 -29
- package/lib/client.js +0 -820
- package/src/catalog.ts +0 -127
- package/src/client/api.ts +0 -45
- package/src/client/card.tsx +0 -340
- package/src/client/client.ts +0 -78
- package/src/client/draft.ts +0 -69
- package/src/client/i18n.ts +0 -65
- package/src/client/styles.ts +0 -30
- package/src/config-api.ts +0 -53
package/src/service.ts
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* SubagentModelService
|
|
3
|
-
* - 配置:
|
|
2
|
+
* SubagentModelService:子代理模型配置中枢(host 半)。
|
|
3
|
+
* - 配置:installSection 接入 settings 用户层($DSH_HOME/settings.yaml,热生效),
|
|
4
4
|
* 无 settings provider 时退化为 cordis 行级 config;写入经 validate 钩子
|
|
5
5
|
* 走 validateEntries 规则(model 不能脱离 provider 等),非法即拒。
|
|
6
|
-
* - 委托挂钩:包装 ctx.subagents.start/startContinuable,按 provider
|
|
7
|
-
* agentOptions(provider/model/effort
|
|
8
|
-
* - 子代理路由:根 ctx 的 agent/request 瀑布监听,把条目 effort 应用到子代理请求。
|
|
9
|
-
* - 自定义端点:ctx.webServer 仅注册模型目录路由(配置读写已走官方 settings RPC)。
|
|
6
|
+
* - 委托挂钩:包装 ctx.subagents.start/startContinuable,按 provider 名
|
|
7
|
+
* (未命中回落 default 条目)注入 agentOptions(provider/model/effort)。
|
|
10
8
|
* @module @dsh-plus/subagent-model
|
|
11
9
|
*/
|
|
12
10
|
import { Context, Service } from '@deepseek-ai/cordis'
|
|
13
|
-
|
|
11
|
+
|
|
14
12
|
import { Config, SETTINGS_NS, type SubagentModelConfig, validateEntries } from './config.ts'
|
|
15
|
-
import {
|
|
16
|
-
import { installChildRoute, installDelegationHook } from './delegation.ts'
|
|
13
|
+
import { installDelegationHook } from './delegation.ts'
|
|
17
14
|
|
|
18
15
|
declare module '@deepseek-ai/cordis' {
|
|
19
16
|
interface Context {
|
|
@@ -22,38 +19,32 @@ declare module '@deepseek-ai/cordis' {
|
|
|
22
19
|
}
|
|
23
20
|
|
|
24
21
|
export class SubagentModelService extends Service {
|
|
25
|
-
static [Context.inject] = ['subagents'
|
|
22
|
+
static [Context.inject] = ['subagents']
|
|
26
23
|
|
|
27
24
|
private current: () => SubagentModelConfig
|
|
28
25
|
|
|
29
26
|
constructor(ctx: Context, config: SubagentModelConfig) {
|
|
30
27
|
super(ctx, 'subagentModel')
|
|
31
28
|
this.current = () => config
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
29
|
+
// 官方 installSection 范式(同 secret-env/usage-panel):setSource 收到的是
|
|
30
|
+
// () => scope.get() 活视图——委托挂钩永远现取最新配置,热生效无竞态。
|
|
31
|
+
ctx.inject(['settings'], (settingsCtx) => {
|
|
32
|
+
settingsCtx.settings.installSection(ctx, SETTINGS_NS, Config, config, {
|
|
33
|
+
validate: (cfg: SubagentModelConfig) => {
|
|
34
|
+
const error = validateEntries(cfg.entries)
|
|
35
|
+
if (error !== null) throw new Error(`subagent-model: ${error}`)
|
|
36
|
+
},
|
|
37
|
+
setSource: (source: () => SubagentModelConfig) => {
|
|
38
|
+
this.current = source
|
|
39
|
+
},
|
|
40
|
+
onChange: () => {},
|
|
41
|
+
})
|
|
41
42
|
})
|
|
42
43
|
installDelegationHook(ctx, () => this.current())
|
|
43
|
-
installChildRoute(ctx)
|
|
44
|
-
ctx.inject(['webServer'], (webCtx) => {
|
|
45
|
-
registerCatalogApi(webCtx)
|
|
46
|
-
})
|
|
47
44
|
}
|
|
48
45
|
|
|
49
46
|
/** 当前生效配置(settings 用户层解析结果或 cordis 行级 config)。 */
|
|
50
47
|
currentConfig(): SubagentModelConfig {
|
|
51
48
|
return this.current()
|
|
52
49
|
}
|
|
53
|
-
|
|
54
|
-
/** 已注册的子代理 provider 名(配置卡片据此合成行)。 */
|
|
55
|
-
subagentProviders(): string[] {
|
|
56
|
-
const subagents = this.ctx.get('subagents')
|
|
57
|
-
return subagents === undefined ? [] : [...subagents.list()]
|
|
58
|
-
}
|
|
59
50
|
}
|