@dsh-plus/subagent-model 0.3.6 → 0.3.7

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 CHANGED
@@ -166,7 +166,10 @@ window.__ModuleLoader__.load({
166
166
  confirm: "Confirm",
167
167
  cancel: "Cancel"
168
168
  };
169
- /** own 覆盖同键合并(返回新对象,入参不可变)。 */
169
+ /**
170
+ * own 覆盖同键合并(返回新对象,入参不可变)。
171
+ * 返回类型保留两侧键集合,调用方据此派生 DictKey。
172
+ */
170
173
  function mergeDict(base, own) {
171
174
  return {
172
175
  ...base,
package/lib/index.d.ts CHANGED
@@ -47,7 +47,7 @@ declare class SubagentModelService extends Service {
47
47
  //#endregion
48
48
  //#region src/index.d.ts
49
49
  declare const name = "dsh-plus-subagent-model";
50
- declare const inject: readonly ["subagents", "llm"];
50
+ declare const inject: readonly ['subagents', 'llm'];
51
51
  declare function apply(ctx: Context, config: SubagentModelConfig): void;
52
52
  //#endregion
53
53
  export { Config, type EntryConfig, type InjectedOptions, type SubagentModelConfig, SubagentModelService, apply, inject, name };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dsh-plus/subagent-model",
3
- "version": "0.3.6",
3
+ "version": "0.3.7",
4
4
  "description": "dsh-plus service+ui plugin: 为 subagent/subagent_fork 等子代理按提供商配置模型与思考程度(或继承主代理)",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -19,7 +19,7 @@
19
19
  "src"
20
20
  ],
21
21
  "dependencies": {
22
- "@dsh-plus/shared": "0.1.15"
22
+ "@dsh-plus/shared": "0.1.16"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "@deepseek-ai/cordis": "^4.0.2",
@@ -28,9 +28,10 @@ import {
28
28
  EMPTY_ROW,
29
29
  toPatch,
30
30
  } from './draft.ts'
31
+ import type { Translate } from './i18n.ts'
31
32
 
32
33
  export interface CardProps {
33
- t(key: string): string
34
+ t: Translate
34
35
  scope: Scope
35
36
  api: NamespaceSettingsApi
36
37
  }
@@ -45,7 +46,7 @@ function unknownOption(value: string, label: string): SelectOption {
45
46
  function providerOptions(
46
47
  catalog: ModelCatalog | null,
47
48
  row: DraftRow,
48
- t: (k: string) => string,
49
+ t: Translate,
49
50
  ): SelectOption[] {
50
51
  const options: SelectOption[] = [{ value: '', label: t('inheritProvider') }]
51
52
  for (const provider of catalog?.providers ?? [])
@@ -56,11 +57,7 @@ function providerOptions(
56
57
  return options
57
58
  }
58
59
 
59
- function modelOptions(
60
- catalog: ModelCatalog | null,
61
- row: DraftRow,
62
- t: (k: string) => string,
63
- ): SelectOption[] {
60
+ function modelOptions(catalog: ModelCatalog | null, row: DraftRow, t: Translate): SelectOption[] {
64
61
  const options: SelectOption[] = [{ value: '', label: t('inheritModel') }]
65
62
  const provider = catalog?.providers.find((p) => p.id === row.provider)
66
63
  for (const model of provider?.models ?? []) options.push({ value: model.id, label: model.name })
@@ -70,11 +67,7 @@ function modelOptions(
70
67
  return options
71
68
  }
72
69
 
73
- function effortOptions(
74
- catalog: ModelCatalog | null,
75
- row: DraftRow,
76
- t: (k: string) => string,
77
- ): SelectOption[] {
70
+ function effortOptions(catalog: ModelCatalog | null, row: DraftRow, t: Translate): SelectOption[] {
78
71
  const options: SelectOption[] = [
79
72
  { value: EFFORT_INHERIT, label: t('effortInherit') },
80
73
  { value: EFFORT_DEFAULT, label: t('effortDefault') },
@@ -94,7 +87,7 @@ interface RowBlockProps {
94
87
  row: DraftRow
95
88
  catalog: ModelCatalog | null
96
89
  disabled: boolean
97
- t(key: string): string
90
+ t: Translate
98
91
  onEdit(row: DraftRow): void
99
92
  }
100
93
 
@@ -18,11 +18,11 @@ import type { Context } from '@deepseek-ai/cordis'
18
18
  import {
19
19
  createNamespaceApi,
20
20
  createSettingsScope,
21
- type SettingsRemoteFace,
21
+ type PluginClientContext,
22
22
  } from '@dsh-plus/shared/client'
23
23
  import { SETTINGS_NS } from '../ns.ts'
24
24
  import { SubagentModelCard } from './card.tsx'
25
- import { en, NS, zh } from './i18n.ts'
25
+ import { type DictKey, en, NS, zh } from './i18n.ts'
26
26
  import { injectStyle } from './styles.ts'
27
27
 
28
28
  export const name = 'dsh-plus-subagent-model'
@@ -30,28 +30,8 @@ export const name = 'dsh-plus-subagent-model'
30
30
  /** 浏览器半需要的 cordis 服务 key(loader 据此注入;package.json 的 dsh.client.inject 管包加载顺序)。 */
31
31
  export const inject = ['slots', 'locale', 'remote', 'remote.settings'] as const
32
32
 
33
- interface SlotsLike {
34
- inject(key: string, callback: () => unknown): unknown
35
- register(options: Record<string, unknown>, component: unknown): () => void
36
- }
37
-
38
- interface LocaleLike {
39
- register(ns: string, dict: { zh: Record<string, string>; en: Record<string, string> }): () => void
40
- bind(ns: string): (key: string) => string
41
- }
42
-
43
- interface RemoteLike {
44
- settings: SettingsRemoteFace
45
- $on(event: string, listener: (payload?: unknown) => void): () => void
46
- }
47
-
48
- interface ClientContext {
49
- slots: SlotsLike
50
- locale: LocaleLike
51
- get(key: 'remote'): RemoteLike
52
- on(event: string, listener: () => void): () => void
53
- effect(execute: () => () => void, label?: string): unknown
54
- }
33
+ /** 宿主窄面收编在 @dsh-plus/shared/client;TKey 传入本包 DictKey 使键名受检。 */
34
+ type ClientContext = PluginClientContext<DictKey>
55
35
 
56
36
  export function apply(ctx: Context): void {
57
37
  const c = ctx as unknown as ClientContext
@@ -31,7 +31,7 @@ const ownZh = {
31
31
  catalogLoading: '目录加载中…',
32
32
  unknownValue: '目录外',
33
33
  invalidModel: '模型不能脱离提供商单独配置。',
34
- }
34
+ } as const
35
35
 
36
36
  const ownEn = {
37
37
  title: 'Subagent model config',
@@ -59,7 +59,13 @@ const ownEn = {
59
59
  catalogLoading: 'Loading catalog\u2026',
60
60
  unknownValue: 'outside catalog',
61
61
  invalidModel: 'Model cannot be set without a provider.',
62
- }
62
+ } as const
63
63
 
64
- export const zh: Record<string, string> = mergeDict(commonZh, ownZh)
65
- export const en: Record<string, string> = mergeDict(commonEn, ownEn)
64
+ export type DictKey = keyof typeof commonZh | keyof typeof ownZh
65
+
66
+ /** 卡片/面板共用的翻译函数类型(slot 注入的 bind 结果按此消费)。 */
67
+ export type Translate = (key: DictKey) => string
68
+
69
+ // 标注为 Record<DictKey, string>:en 缺任一键即编译期报错(中英强制对齐)。
70
+ export const zh: Record<DictKey, string> = mergeDict(commonZh, ownZh)
71
+ export const en: Record<DictKey, string> = mergeDict(commonEn, ownEn)