@dsh-plus/subagent-model 0.1.10 → 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/src/service.ts CHANGED
@@ -1,19 +1,16 @@
1
1
  /**
2
- * SubagentModelService:子代理模型配置中枢。
3
- * - 配置:installSettingsSection 接入 settings 用户层($DSH_HOME/settings.yaml,热生效),
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
- import { installSettingsSection } from '@deepseek-ai/dsh-settings'
11
+
14
12
  import { Config, SETTINGS_NS, type SubagentModelConfig, validateEntries } from './config.ts'
15
- import { registerCatalogApi } from './config-api.ts'
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', 'llm']
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
- installSettingsSection(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) => {
38
- this.current = source
39
- },
40
- onChange: () => {},
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
  }