@dsh-plus/subagent-model 0.1.5 → 0.1.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 +625 -649
- package/lib/index.d.ts +0 -3
- package/lib/index.js +43 -36
- package/package.json +7 -7
- package/src/catalog.ts +46 -33
- package/src/client/card.tsx +139 -56
- package/src/client/client.ts +20 -9
- package/src/client/i18n.ts +8 -4
- package/src/client/scope.ts +22 -3
- package/src/config.ts +16 -9
- package/src/delegation.ts +8 -2
- package/src/index.ts +6 -3
- package/src/service.ts +1 -2
package/src/client/client.ts
CHANGED
|
@@ -63,7 +63,12 @@ interface ClientContext {
|
|
|
63
63
|
* (loopback 或 tailnet 信任域名)下行为一致。
|
|
64
64
|
*/
|
|
65
65
|
function createApiScope(api: SettingsApi, ns: string, c: ClientContext): Scope {
|
|
66
|
-
let state: ScopeSnapshot = {
|
|
66
|
+
let state: ScopeSnapshot = {
|
|
67
|
+
status: 'loading',
|
|
68
|
+
value: undefined,
|
|
69
|
+
revision: undefined,
|
|
70
|
+
writable: false,
|
|
71
|
+
}
|
|
67
72
|
const listeners = new Set<() => void>()
|
|
68
73
|
let generation = 0
|
|
69
74
|
const publish = (next: ScopeSnapshot): void => {
|
|
@@ -72,7 +77,7 @@ function createApiScope(api: SettingsApi, ns: string, c: ClientContext): Scope {
|
|
|
72
77
|
}
|
|
73
78
|
const load = async (): Promise<void> => {
|
|
74
79
|
const gen = ++generation
|
|
75
|
-
let response
|
|
80
|
+
let response: Awaited<ReturnType<SettingsApi['describe']>>
|
|
76
81
|
try {
|
|
77
82
|
response = await api.describe({})
|
|
78
83
|
} catch {
|
|
@@ -82,10 +87,20 @@ function createApiScope(api: SettingsApi, ns: string, c: ClientContext): Scope {
|
|
|
82
87
|
const writable = response.result.value?.writable ?? false
|
|
83
88
|
const view = response.result.value?.namespaces.find((candidate) => candidate.ns === ns)
|
|
84
89
|
if (view === undefined) {
|
|
85
|
-
publish({
|
|
90
|
+
publish({
|
|
91
|
+
status: 'unavailable',
|
|
92
|
+
value: undefined,
|
|
93
|
+
revision: undefined,
|
|
94
|
+
writable,
|
|
95
|
+
})
|
|
86
96
|
return
|
|
87
97
|
}
|
|
88
|
-
publish({
|
|
98
|
+
publish({
|
|
99
|
+
status: 'ready',
|
|
100
|
+
value: view.value,
|
|
101
|
+
revision: view.revision,
|
|
102
|
+
writable,
|
|
103
|
+
})
|
|
89
104
|
}
|
|
90
105
|
const refresh = (namespace?: unknown): void => {
|
|
91
106
|
if (namespace !== undefined && namespace !== ns) return
|
|
@@ -117,7 +132,6 @@ function createApiScope(api: SettingsApi, ns: string, c: ClientContext): Scope {
|
|
|
117
132
|
}
|
|
118
133
|
|
|
119
134
|
export function apply(ctx: Context): void {
|
|
120
|
-
|
|
121
135
|
const c = ctx as unknown as ClientContext
|
|
122
136
|
const tag = injectStyle()
|
|
123
137
|
c.effect(
|
|
@@ -126,10 +140,7 @@ export function apply(ctx: Context): void {
|
|
|
126
140
|
},
|
|
127
141
|
'subagent-model: style',
|
|
128
142
|
)
|
|
129
|
-
c.effect(
|
|
130
|
-
() => c.locale.register(NS, { zh, en }),
|
|
131
|
-
'subagent-model: locale',
|
|
132
|
-
)
|
|
143
|
+
c.effect(() => c.locale.register(NS, { zh, en }), 'subagent-model: locale')
|
|
133
144
|
const api = c.get('connection').api.settings
|
|
134
145
|
const scope = createApiScope(api, SETTINGS_NS, c)
|
|
135
146
|
c.slots.inject('settings.plugin.item', () =>
|
package/src/client/i18n.ts
CHANGED
|
@@ -20,7 +20,8 @@ export const zh: Record<string, string> = {
|
|
|
20
20
|
providerHint: '留空 = 子代理沿用主代理的提供商与模型。',
|
|
21
21
|
modelHint: '留空 = 沿用主代理的模型(需与所选提供商匹配)。',
|
|
22
22
|
effortHint: 'inherit = 不干预(fork 会随会话继承);default = 显式使用模型默认档位。',
|
|
23
|
-
rowHint:
|
|
23
|
+
rowHint:
|
|
24
|
+
'按子代理 provider 名匹配;standard preset 中 spawn ↔ subagent 工具、fork ↔ subagent_fork 工具。',
|
|
24
25
|
rowDesc: '未注册的 provider 行不生效,可保留待用。',
|
|
25
26
|
noRows: '当前未发现子代理 provider;配置将在 provider 注册后生效。',
|
|
26
27
|
catalogError: '提供商目录加载失败:',
|
|
@@ -42,7 +43,8 @@ export const zh: Record<string, string> = {
|
|
|
42
43
|
|
|
43
44
|
export const en: Record<string, string> = {
|
|
44
45
|
title: 'Subagent model config',
|
|
45
|
-
description:
|
|
46
|
+
description:
|
|
47
|
+
'Pick a provider, model, and thinking effort for subagent / subagent_fork children, or inherit from the main agent.',
|
|
46
48
|
enabled: 'Enable plugin',
|
|
47
49
|
rowEnabled: 'Enable row',
|
|
48
50
|
provider: 'Provider',
|
|
@@ -54,8 +56,10 @@ export const en: Record<string, string> = {
|
|
|
54
56
|
effortDefault: 'Follow model default',
|
|
55
57
|
providerHint: 'Empty = the child follows the main agent\u2019s provider and model.',
|
|
56
58
|
modelHint: 'Empty = follow the main agent\u2019s model (must match the chosen provider).',
|
|
57
|
-
effortHint:
|
|
58
|
-
|
|
59
|
+
effortHint:
|
|
60
|
+
'inherit = do not touch (forks inherit via session seed); default = explicitly use the model\u2019s default level.',
|
|
61
|
+
rowHint:
|
|
62
|
+
'Matched by subagent provider name; in the standard preset spawn \u2194 subagent tool, fork \u2194 subagent_fork tool.',
|
|
59
63
|
rowDesc: 'Rows for unregistered providers are inert; keep them for later.',
|
|
60
64
|
noRows: 'No subagent provider registered yet; config takes effect once one appears.',
|
|
61
65
|
catalogError: 'Failed to load provider catalog: ',
|
package/src/client/scope.ts
CHANGED
|
@@ -31,7 +31,26 @@ export interface Scope {
|
|
|
31
31
|
|
|
32
32
|
/** connection api.settings 的 RPC 面(本插件用到的三个方法)。 */
|
|
33
33
|
export interface SettingsApi {
|
|
34
|
-
describe(payload?: Record<string, never>): Promise<{
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
describe(payload?: Record<string, never>): Promise<{
|
|
35
|
+
result: {
|
|
36
|
+
ok: boolean
|
|
37
|
+
value?: {
|
|
38
|
+
namespaces: Array<{
|
|
39
|
+
ns: string
|
|
40
|
+
secrets: Array<{ path: string[]; set: boolean }>
|
|
41
|
+
}>
|
|
42
|
+
}
|
|
43
|
+
error?: { message?: string }
|
|
44
|
+
}
|
|
45
|
+
}>
|
|
46
|
+
update(request: {
|
|
47
|
+
ns: string
|
|
48
|
+
patch: Record<string, unknown>
|
|
49
|
+
expectedRevision?: number
|
|
50
|
+
}): Promise<{ result: { ok: boolean; error?: { message?: string } } }>
|
|
51
|
+
replace(request: {
|
|
52
|
+
ns: string
|
|
53
|
+
section: Record<string, unknown>
|
|
54
|
+
expectedRevision?: number
|
|
55
|
+
}): Promise<{ result: { ok: boolean; error?: { message?: string } } }>
|
|
37
56
|
}
|
package/src/config.ts
CHANGED
|
@@ -14,8 +14,9 @@
|
|
|
14
14
|
* 显式声明输入/输出接口并注解 schema(输出为规范型,输入为可空宽松型)。
|
|
15
15
|
* @module subagent-model/config
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
import { settingsNamespace } from '@deepseek-ai/dsh-settings'
|
|
19
|
+
import z from '@deepseek-ai/schemastery'
|
|
19
20
|
|
|
20
21
|
import { SETTINGS_NS as NS_LITERAL } from './ns.ts'
|
|
21
22
|
|
|
@@ -44,20 +45,26 @@ export interface SubagentModelConfig {
|
|
|
44
45
|
/** 配置的宽松输入形态(schema 校验前的用户数据)。 */
|
|
45
46
|
export interface SubagentModelConfigInput {
|
|
46
47
|
enabled?: boolean | null
|
|
47
|
-
entries?: Record<
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
entries?: Record<
|
|
49
|
+
string,
|
|
50
|
+
{
|
|
51
|
+
enabled?: boolean | null
|
|
52
|
+
provider?: string | null
|
|
53
|
+
model?: string | null
|
|
54
|
+
reasoningEffort?: string | null
|
|
55
|
+
}
|
|
56
|
+
> | null
|
|
53
57
|
}
|
|
54
58
|
|
|
55
59
|
const EntrySchema = z.object({
|
|
56
60
|
enabled: z.boolean().description('该子代理 provider 行的开关').default(false),
|
|
57
61
|
provider: z.string().description('LLM 提供商 id;留空 = 继承主代理').default(''),
|
|
58
62
|
model: z.string().description('模型 id;留空 = 继承主代理').default(''),
|
|
59
|
-
reasoningEffort: z
|
|
60
|
-
.
|
|
63
|
+
reasoningEffort: z
|
|
64
|
+
.string()
|
|
65
|
+
.description(
|
|
66
|
+
`思考程度:${EFFORT_INHERIT}(继承主代理)/ ${EFFORT_DEFAULT}(跟随模型默认)/ 提供商目录档位 id`,
|
|
67
|
+
)
|
|
61
68
|
.default(EFFORT_INHERIT),
|
|
62
69
|
})
|
|
63
70
|
|
package/src/delegation.ts
CHANGED
|
@@ -19,11 +19,17 @@
|
|
|
19
19
|
* @module subagent-model/delegation
|
|
20
20
|
*/
|
|
21
21
|
import type { Context } from '@deepseek-ai/cordis'
|
|
22
|
-
import type {
|
|
22
|
+
import type { AgentOptions } from '@deepseek-ai/dsh-agent'
|
|
23
23
|
import type { LlmCallConfig } from '@deepseek-ai/dsh-llm'
|
|
24
24
|
import type { ContinuableStartSpec, SubagentStartRequest } from '@deepseek-ai/dsh-subagent'
|
|
25
25
|
|
|
26
|
-
import {
|
|
26
|
+
import {
|
|
27
|
+
applyEffort,
|
|
28
|
+
mergeAgentOptions,
|
|
29
|
+
type RequestConfig,
|
|
30
|
+
resolveEntry,
|
|
31
|
+
type SubagentModelConfig,
|
|
32
|
+
} from './config.ts'
|
|
27
33
|
|
|
28
34
|
const WRAPPED = Symbol('dsh-plus-subagent-model.wrapped')
|
|
29
35
|
|
package/src/index.ts
CHANGED
|
@@ -15,10 +15,13 @@ export const name = 'dsh-plus-subagent-model'
|
|
|
15
15
|
|
|
16
16
|
export const inject = ['subagents', 'llm'] as const
|
|
17
17
|
|
|
18
|
-
export {
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
export type {
|
|
19
|
+
EntryConfig,
|
|
20
|
+
InjectedOptions,
|
|
21
|
+
SubagentModelConfig,
|
|
22
|
+
} from './config.ts'
|
|
21
23
|
export { SubagentModelService } from './service.ts'
|
|
24
|
+
export { Config }
|
|
22
25
|
|
|
23
26
|
export function apply(ctx: Context, config: SubagentModelConfig): void {
|
|
24
27
|
ctx.plugin(SubagentModelService, config)
|
package/src/service.ts
CHANGED
|
@@ -11,9 +11,8 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { Context, Service } from '@deepseek-ai/cordis'
|
|
13
13
|
import { installSettingsSection } from '@deepseek-ai/dsh-settings'
|
|
14
|
-
|
|
14
|
+
import { Config, SETTINGS_NS, type SubagentModelConfig, validateEntries } from './config.ts'
|
|
15
15
|
import { registerCatalogApi } from './config-api.ts'
|
|
16
|
-
import { Config, SETTINGS_NS, validateEntries, type SubagentModelConfig } from './config.ts'
|
|
17
16
|
import { installChildRoute, installDelegationHook } from './delegation.ts'
|
|
18
17
|
|
|
19
18
|
declare module '@deepseek-ai/cordis' {
|