@dsh-plus/subagent-model 0.1.8 → 0.1.9
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 +423 -300
- package/package.json +4 -2
- package/src/client/card.tsx +86 -102
- package/src/client/client.ts +5 -84
- package/src/client/i18n.ts +7 -22
- package/src/client/styles.ts +12 -48
- package/src/client/fields.tsx +0 -75
- package/src/client/scope.ts +0 -59
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dsh-plus/subagent-model",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "dsh-plus service+ui plugin: 为 subagent/subagent_fork 等子代理按提供商配置模型与思考程度(或继承主代理)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -31,7 +31,9 @@
|
|
|
31
31
|
"platform": "web"
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
|
-
"dependencies": {
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@dsh-plus/shared": "0.1.3"
|
|
36
|
+
},
|
|
35
37
|
"peerDependencies": {
|
|
36
38
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
37
39
|
"@deepseek-ai/dsh-settings": "^0.1.0-rc.8",
|
package/src/client/card.tsx
CHANGED
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 「子代理模型配置」配置卡片:注册进 settings.plugin.item 插槽(官方插件配置页)。
|
|
3
|
-
*
|
|
4
|
-
* 配置读写走官方 settingsScope
|
|
5
|
-
*
|
|
3
|
+
* 外壳与基础控件走 @dsh-plus/shared/client 套件(CardChrome/CheckRow/SelectField)。
|
|
4
|
+
* 配置读写走官方 settingsScope 传输:value 为 schema 解析后的命名空间值
|
|
5
|
+
* (enabled + entries),行集合 = 目录返回的已注册子代理 provider
|
|
6
6
|
* ∪ 已配置条目,保存时全量写回 entries(未配置的新 provider 行以默认空值
|
|
7
7
|
* 落盘,自文档化);「模型目录」为唯一保留的自定义端点。
|
|
8
8
|
* @module subagent-model/client/card
|
|
9
9
|
*/
|
|
10
|
-
import { type ReactElement, useEffect, useMemo, useState, useSyncExternalStore } from 'react'
|
|
11
10
|
|
|
11
|
+
import {
|
|
12
|
+
CardChrome,
|
|
13
|
+
type CardStatusState,
|
|
14
|
+
CheckRow,
|
|
15
|
+
IDLE_STATUS,
|
|
16
|
+
type Scope,
|
|
17
|
+
SelectField,
|
|
18
|
+
type SelectOption,
|
|
19
|
+
type SettingsApi,
|
|
20
|
+
} from '@dsh-plus/shared/client'
|
|
21
|
+
import { type ReactElement, useEffect, useMemo, useState, useSyncExternalStore } from 'react'
|
|
12
22
|
import { SETTINGS_NS } from '../ns.ts'
|
|
13
23
|
import { type CatalogProvider, fetchCatalog, type ModelCatalog } from './api.ts'
|
|
14
24
|
import {
|
|
@@ -19,8 +29,6 @@ import {
|
|
|
19
29
|
EMPTY_ROW,
|
|
20
30
|
toPatch,
|
|
21
31
|
} from './draft.ts'
|
|
22
|
-
import { CheckRow, SelectField, type SelectOption } from './fields.tsx'
|
|
23
|
-
import type { Scope, SettingsApi } from './scope.ts'
|
|
24
32
|
|
|
25
33
|
export interface CardProps {
|
|
26
34
|
t(key: string): string
|
|
@@ -28,12 +36,6 @@ export interface CardProps {
|
|
|
28
36
|
api: SettingsApi
|
|
29
37
|
}
|
|
30
38
|
|
|
31
|
-
interface Status {
|
|
32
|
-
kind: 'idle' | 'ok' | 'error'
|
|
33
|
-
text: string
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const IDLE_STATUS: Status = { kind: 'idle', text: '' }
|
|
37
39
|
const EFFORT_INHERIT = 'inherit'
|
|
38
40
|
const EFFORT_DEFAULT = 'default'
|
|
39
41
|
|
|
@@ -105,6 +107,7 @@ function RowBlock(props: RowBlockProps): ReactElement {
|
|
|
105
107
|
<div className="dsm-rowHead">
|
|
106
108
|
<span className="dsm-rowName">{name}</span>
|
|
107
109
|
<CheckRow
|
|
110
|
+
prefix="dsm"
|
|
108
111
|
id={`dsm-row-${name}`}
|
|
109
112
|
label={t('rowEnabled')}
|
|
110
113
|
checked={row.enabled}
|
|
@@ -114,6 +117,7 @@ function RowBlock(props: RowBlockProps): ReactElement {
|
|
|
114
117
|
</div>
|
|
115
118
|
<p className="dsm-rowHint">{t('rowHint')}</p>
|
|
116
119
|
<SelectField
|
|
120
|
+
prefix="dsm"
|
|
117
121
|
id={`dsm-provider-${name}`}
|
|
118
122
|
label={t('provider')}
|
|
119
123
|
hint={t('providerHint')}
|
|
@@ -123,6 +127,7 @@ function RowBlock(props: RowBlockProps): ReactElement {
|
|
|
123
127
|
onEdit={(v) => onEdit({ ...row, provider: v })}
|
|
124
128
|
/>
|
|
125
129
|
<SelectField
|
|
130
|
+
prefix="dsm"
|
|
126
131
|
id={`dsm-model-${name}`}
|
|
127
132
|
label={t('model')}
|
|
128
133
|
hint={t('modelHint')}
|
|
@@ -134,6 +139,7 @@ function RowBlock(props: RowBlockProps): ReactElement {
|
|
|
134
139
|
onEdit={(v) => onEdit({ ...row, model: v })}
|
|
135
140
|
/>
|
|
136
141
|
<SelectField
|
|
142
|
+
prefix="dsm"
|
|
137
143
|
id={`dsm-effort-${name}`}
|
|
138
144
|
label={t('effort')}
|
|
139
145
|
hint={t('effortHint')}
|
|
@@ -158,7 +164,7 @@ export function SubagentModelCard(props: CardProps): ReactElement | null {
|
|
|
158
164
|
const [catalog, setCatalog] = useState<ModelCatalog | null>(null)
|
|
159
165
|
const [catalogFailed, setCatalogFailed] = useState(false)
|
|
160
166
|
const [saving, setSaving] = useState(false)
|
|
161
|
-
const [status, setStatus] = useState<
|
|
167
|
+
const [status, setStatus] = useState<CardStatusState>(IDLE_STATUS)
|
|
162
168
|
|
|
163
169
|
// 播种草稿(行集 = 已配置条目);catalog 到达后只补缺失的 provider 空行,
|
|
164
170
|
// 不覆盖在途编辑;后续 Host 更新同样不覆盖。
|
|
@@ -259,97 +265,75 @@ export function SubagentModelCard(props: CardProps): ReactElement | null {
|
|
|
259
265
|
const rowNames = Object.keys(draft.rows).sort()
|
|
260
266
|
const providerCount = (catalog?.providers ?? []).length
|
|
261
267
|
return (
|
|
262
|
-
<
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
{
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
{t('noRows')}
|
|
307
|
-
</p>
|
|
308
|
-
) : null}
|
|
309
|
-
{rowNames.map((name) => (
|
|
310
|
-
<RowBlock
|
|
311
|
-
key={name}
|
|
312
|
-
name={name}
|
|
313
|
-
row={draft.rows[name] ?? { ...EMPTY_ROW }}
|
|
314
|
-
catalog={catalog}
|
|
315
|
-
disabled={disabled}
|
|
316
|
-
t={t}
|
|
317
|
-
onEdit={(row) => editRow(name, row)}
|
|
318
|
-
/>
|
|
319
|
-
))}
|
|
320
|
-
<p className="dsm-hint dsm-rowHint">{providerCount > 0 ? t('rowDesc') : ''}</p>
|
|
321
|
-
<div className="dsm-footer">
|
|
322
|
-
{status.kind !== 'idle' ? (
|
|
323
|
-
<p
|
|
324
|
-
className={`dsm-status${status.kind === 'error' ? ' dsm-statusError' : ''}`}
|
|
325
|
-
role="status"
|
|
326
|
-
>
|
|
327
|
-
{status.text}
|
|
328
|
-
</p>
|
|
329
|
-
) : null}
|
|
330
|
-
<button
|
|
331
|
-
type="button"
|
|
332
|
-
className="dsm-btn dsm-btnGhost"
|
|
333
|
-
disabled={!dirty || saving}
|
|
334
|
-
onClick={() => {
|
|
335
|
-
setDraft(draftFrom(value, catalog))
|
|
336
|
-
setStatus(IDLE_STATUS)
|
|
337
|
-
}}
|
|
338
|
-
>
|
|
339
|
-
{t('discard')}
|
|
340
|
-
</button>
|
|
341
|
-
<button
|
|
342
|
-
type="button"
|
|
343
|
-
className="dsm-btn dsm-btnPrimary"
|
|
344
|
-
disabled={!dirty || invalid || saving || disabled}
|
|
345
|
-
onClick={onSave}
|
|
346
|
-
>
|
|
347
|
-
{t(saving ? 'saving' : 'save')}
|
|
348
|
-
</button>
|
|
349
|
-
</div>
|
|
268
|
+
<CardChrome
|
|
269
|
+
prefix="dsm"
|
|
270
|
+
title={t('title')}
|
|
271
|
+
description={t('description')}
|
|
272
|
+
open={open}
|
|
273
|
+
onToggle={setOpen}
|
|
274
|
+
statusBadge={{ text: t(draft.enabled ? 'enabledOn' : 'enabledOff'), on: draft.enabled }}
|
|
275
|
+
dirty={dirty}
|
|
276
|
+
dirtyLabel={t('unsaved')}
|
|
277
|
+
readOnlyNotice={disabled ? t('readOnly') : undefined}
|
|
278
|
+
status={status}
|
|
279
|
+
actions={[
|
|
280
|
+
{
|
|
281
|
+
key: 'discard',
|
|
282
|
+
label: t('discard'),
|
|
283
|
+
disabled: !dirty || saving,
|
|
284
|
+
onClick: () => {
|
|
285
|
+
setDraft(draftFrom(value, catalog))
|
|
286
|
+
setStatus(IDLE_STATUS)
|
|
287
|
+
},
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
key: 'save',
|
|
291
|
+
label: t(saving ? 'saving' : 'save'),
|
|
292
|
+
variant: 'primary',
|
|
293
|
+
disabled: !dirty || invalid || saving || disabled,
|
|
294
|
+
onClick: onSave,
|
|
295
|
+
},
|
|
296
|
+
]}
|
|
297
|
+
>
|
|
298
|
+
<CheckRow
|
|
299
|
+
prefix="dsm"
|
|
300
|
+
id="dsm-enabled"
|
|
301
|
+
label={t('enabled')}
|
|
302
|
+
checked={draft.enabled}
|
|
303
|
+
disabled={disabled}
|
|
304
|
+
onEdit={(v) => edit('enabled', v)}
|
|
305
|
+
/>
|
|
306
|
+
{catalogFailed ? (
|
|
307
|
+
<div className="dsm-banner" role="status">
|
|
308
|
+
<span>{t('catalogError')}</span>
|
|
309
|
+
<button type="button" className="dsm-bannerRetry" onClick={onRetryCatalog}>
|
|
310
|
+
{t('catalogRetry')}
|
|
311
|
+
</button>
|
|
350
312
|
</div>
|
|
351
313
|
) : null}
|
|
352
|
-
|
|
314
|
+
{catalog === null && !catalogFailed ? (
|
|
315
|
+
<p className="dsm-empty" role="status">
|
|
316
|
+
{t('catalogLoading')}
|
|
317
|
+
</p>
|
|
318
|
+
) : null}
|
|
319
|
+
{rowNames.length === 0 ? (
|
|
320
|
+
<p className="dsm-empty" role="status">
|
|
321
|
+
{t('noRows')}
|
|
322
|
+
</p>
|
|
323
|
+
) : null}
|
|
324
|
+
{rowNames.map((name) => (
|
|
325
|
+
<RowBlock
|
|
326
|
+
key={name}
|
|
327
|
+
name={name}
|
|
328
|
+
row={draft.rows[name] ?? { ...EMPTY_ROW }}
|
|
329
|
+
catalog={catalog}
|
|
330
|
+
disabled={disabled}
|
|
331
|
+
t={t}
|
|
332
|
+
onEdit={(row) => editRow(name, row)}
|
|
333
|
+
/>
|
|
334
|
+
))}
|
|
335
|
+
<p className="dsm-hint dsm-rowHint">{providerCount > 0 ? t('rowDesc') : ''}</p>
|
|
336
|
+
</CardChrome>
|
|
353
337
|
)
|
|
354
338
|
}
|
|
355
339
|
|
package/src/client/client.ts
CHANGED
|
@@ -4,23 +4,20 @@
|
|
|
4
4
|
* (包装见 tsdown.config.ts);样式沿用官方 data-plugin-css 约定,HMR 据此卸载。
|
|
5
5
|
*
|
|
6
6
|
* 类型说明:浏览器半只用到 slots/locale/connection/remote 的很窄一面,
|
|
7
|
-
*
|
|
8
|
-
* client 依赖树;运行时契约以官方 dsh-client-ui-settings-plugins 的
|
|
9
|
-
* settings.plugin.item 插槽与 dsh-client-connection 的 settings RPC 面为准。
|
|
7
|
+
* scope 与基础控件走 @dsh-plus/shared/client 套件(收编自本插件原实现)。
|
|
10
8
|
* rc7 起该插槽为 keyed 槽位:key 必须是卡片编辑的 settings 命名空间
|
|
11
9
|
* (即服务端 settingsNamespace() 注册的同一字面量,见 ../ns.ts),
|
|
12
10
|
* 官方配置页按此 key 与 Host 已注册命名空间配对分发。
|
|
13
11
|
* 配置读写经官方 settings RPC 直连(rc7 起第三方命名空间全量开放;
|
|
14
|
-
* 不复用 settingsScope 服务——非 loopback
|
|
12
|
+
* 不复用 settingsScope 服务——非 loopback 页面下它无数据);
|
|
15
13
|
* 自定义端点仅剩「模型目录」(api.ts)。
|
|
16
14
|
* @module @dsh-plus/subagent-model/client
|
|
17
15
|
*/
|
|
18
16
|
import type { Context } from '@deepseek-ai/cordis'
|
|
19
|
-
|
|
17
|
+
import { createApiScope } from '@dsh-plus/shared/client'
|
|
20
18
|
import { SETTINGS_NS } from '../ns.ts'
|
|
21
19
|
import { SubagentModelCard } from './card.tsx'
|
|
22
20
|
import { en, NS, zh } from './i18n.ts'
|
|
23
|
-
import type { Scope, ScopeSnapshot, SettingsApi } from './scope.ts'
|
|
24
21
|
import { injectStyle } from './styles.ts'
|
|
25
22
|
|
|
26
23
|
export const name = 'dsh-plus-subagent-model'
|
|
@@ -43,7 +40,7 @@ interface RemoteLike {
|
|
|
43
40
|
}
|
|
44
41
|
|
|
45
42
|
interface ConnectionLike {
|
|
46
|
-
api: { settings:
|
|
43
|
+
api: { settings: Parameters<typeof createApiScope>[0] }
|
|
47
44
|
}
|
|
48
45
|
|
|
49
46
|
interface ClientContext {
|
|
@@ -55,82 +52,6 @@ interface ClientContext {
|
|
|
55
52
|
effect(execute: () => () => void, label?: string): unknown
|
|
56
53
|
}
|
|
57
54
|
|
|
58
|
-
/**
|
|
59
|
-
* api 直连实现的命名空间 scope(官方配置页 tab 同款模式)。
|
|
60
|
-
* 读:describe 取命名空间视图(脱敏 value/revision + 顶层 writable);
|
|
61
|
-
* 刷新:remote `settings/document-updated`(按命名空间过滤)与
|
|
62
|
-
* `connection/reset`;generation 防旧读覆盖新发布。任何页面 origin
|
|
63
|
-
* (loopback 或 tailnet 信任域名)下行为一致。
|
|
64
|
-
*/
|
|
65
|
-
function createApiScope(api: SettingsApi, ns: string, c: ClientContext): Scope {
|
|
66
|
-
let state: ScopeSnapshot = {
|
|
67
|
-
status: 'loading',
|
|
68
|
-
value: undefined,
|
|
69
|
-
revision: undefined,
|
|
70
|
-
writable: false,
|
|
71
|
-
}
|
|
72
|
-
const listeners = new Set<() => void>()
|
|
73
|
-
let generation = 0
|
|
74
|
-
const publish = (next: ScopeSnapshot): void => {
|
|
75
|
-
state = next
|
|
76
|
-
for (const listener of [...listeners]) listener()
|
|
77
|
-
}
|
|
78
|
-
const load = async (): Promise<void> => {
|
|
79
|
-
const gen = ++generation
|
|
80
|
-
let response: Awaited<ReturnType<SettingsApi['describe']>>
|
|
81
|
-
try {
|
|
82
|
-
response = await api.describe({})
|
|
83
|
-
} catch {
|
|
84
|
-
return
|
|
85
|
-
}
|
|
86
|
-
if (gen !== generation || !response.result.ok) return
|
|
87
|
-
const writable = response.result.value?.writable ?? false
|
|
88
|
-
const view = response.result.value?.namespaces.find((candidate) => candidate.ns === ns)
|
|
89
|
-
if (view === undefined) {
|
|
90
|
-
publish({
|
|
91
|
-
status: 'unavailable',
|
|
92
|
-
value: undefined,
|
|
93
|
-
revision: undefined,
|
|
94
|
-
writable,
|
|
95
|
-
})
|
|
96
|
-
return
|
|
97
|
-
}
|
|
98
|
-
publish({
|
|
99
|
-
status: 'ready',
|
|
100
|
-
value: view.value,
|
|
101
|
-
revision: view.revision,
|
|
102
|
-
writable,
|
|
103
|
-
})
|
|
104
|
-
}
|
|
105
|
-
const refresh = (namespace?: unknown): void => {
|
|
106
|
-
if (namespace !== undefined && namespace !== ns) return
|
|
107
|
-
void load()
|
|
108
|
-
}
|
|
109
|
-
const disposers = [
|
|
110
|
-
c.get('remote').$on('settings/document-updated', refresh),
|
|
111
|
-
c.on('connection/reset', () => {
|
|
112
|
-
void load()
|
|
113
|
-
}),
|
|
114
|
-
]
|
|
115
|
-
c.effect(
|
|
116
|
-
() => () => {
|
|
117
|
-
for (const dispose of disposers) dispose()
|
|
118
|
-
},
|
|
119
|
-
'subagent-model: settings scope',
|
|
120
|
-
)
|
|
121
|
-
void load()
|
|
122
|
-
return {
|
|
123
|
-
getSnapshot: () => state,
|
|
124
|
-
subscribe: (listener: () => void) => {
|
|
125
|
-
listeners.add(listener)
|
|
126
|
-
return () => {
|
|
127
|
-
listeners.delete(listener)
|
|
128
|
-
}
|
|
129
|
-
},
|
|
130
|
-
load,
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
55
|
export function apply(ctx: Context): void {
|
|
135
56
|
const c = ctx as unknown as ClientContext
|
|
136
57
|
const tag = injectStyle()
|
|
@@ -142,7 +63,7 @@ export function apply(ctx: Context): void {
|
|
|
142
63
|
)
|
|
143
64
|
c.effect(() => c.locale.register(NS, { zh, en }), 'subagent-model: locale')
|
|
144
65
|
const api = c.get('connection').api.settings
|
|
145
|
-
const scope = createApiScope(api, SETTINGS_NS, c)
|
|
66
|
+
const scope = createApiScope(api, SETTINGS_NS, c, 'subagent-model: settings scope')
|
|
146
67
|
c.slots.inject('settings.plugin.item', () =>
|
|
147
68
|
c.slots.register(
|
|
148
69
|
{
|
package/src/client/i18n.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 配置卡片文案(zh/en)。经 ctx.locale.register 注册、bind 取用,与官方卡片同机制。
|
|
3
|
+
* 公共键(save/discard/unsaved 等)来自 shared 的 common 字典,本文件只维护业务键。
|
|
3
4
|
* @module subagent-model/client/i18n
|
|
4
5
|
*/
|
|
6
|
+
import { commonEn, commonZh, mergeDict } from '@dsh-plus/shared/client'
|
|
5
7
|
|
|
6
8
|
export const NS = 'dsh-plus-subagent-model'
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
const ownZh = {
|
|
9
11
|
title: '子代理模型配置',
|
|
10
12
|
description: '为 subagent / subagent_fork 等子代理单独指定提供商、模型与思考程度,或继承主代理。',
|
|
11
13
|
enabled: '启用插件',
|
|
@@ -28,20 +30,10 @@ export const zh: Record<string, string> = {
|
|
|
28
30
|
catalogRetry: '重试',
|
|
29
31
|
catalogLoading: '目录加载中…',
|
|
30
32
|
unknownValue: '目录外',
|
|
31
|
-
save: '保存',
|
|
32
|
-
saving: '保存中…',
|
|
33
|
-
discard: '放弃',
|
|
34
|
-
unsaved: '未保存',
|
|
35
|
-
saveFailed: '保存失败:',
|
|
36
|
-
loading: '加载中…',
|
|
37
|
-
unavailable: '配置服务不可用。',
|
|
38
|
-
readOnly: '当前部署无 settings provider,配置为只读;请编辑 settings.yaml。',
|
|
39
|
-
expand: '展开',
|
|
40
|
-
collapse: '收起',
|
|
41
33
|
invalidModel: '模型不能脱离提供商单独配置。',
|
|
42
34
|
}
|
|
43
35
|
|
|
44
|
-
|
|
36
|
+
const ownEn = {
|
|
45
37
|
title: 'Subagent model config',
|
|
46
38
|
description:
|
|
47
39
|
'Pick a provider, model, and thinking effort for subagent / subagent_fork children, or inherit from the main agent.',
|
|
@@ -66,15 +58,8 @@ export const en: Record<string, string> = {
|
|
|
66
58
|
catalogRetry: 'Retry',
|
|
67
59
|
catalogLoading: 'Loading catalog\u2026',
|
|
68
60
|
unknownValue: 'outside catalog',
|
|
69
|
-
save: 'Save',
|
|
70
|
-
saving: 'Saving\u2026',
|
|
71
|
-
discard: 'Discard',
|
|
72
|
-
unsaved: 'Unsaved',
|
|
73
|
-
saveFailed: 'Save failed: ',
|
|
74
|
-
loading: 'Loading\u2026',
|
|
75
|
-
unavailable: 'Configuration service unavailable.',
|
|
76
|
-
readOnly: 'No settings provider in this deployment; edit settings.yaml instead.',
|
|
77
|
-
expand: 'Expand',
|
|
78
|
-
collapse: 'Collapse',
|
|
79
61
|
invalidModel: 'Model cannot be set without a provider.',
|
|
80
62
|
}
|
|
63
|
+
|
|
64
|
+
export const zh: Record<string, string> = mergeDict(commonZh, ownZh)
|
|
65
|
+
export const en: Record<string, string> = mergeDict(commonEn, ownEn)
|
package/src/client/styles.ts
CHANGED
|
@@ -1,66 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* 配置卡片样式:基础规则走 @dsh-plus/shared/client 的 cardCss('dsm'),
|
|
3
|
+
* 本文件只补插件特有规则(provider 行块 / banner / 目录空态)。
|
|
4
|
+
* 沿用官方 data-plugin / data-plugin-css 约定(HMR 据此卸载)。
|
|
4
5
|
* @module subagent-model/client/styles
|
|
5
6
|
*/
|
|
7
|
+
import { cardCss, injectCardStyle } from '@dsh-plus/shared/client'
|
|
6
8
|
|
|
7
9
|
export const PLUGIN_ID = '@dsh-plus/subagent-model'
|
|
8
|
-
export const STYLE_TAG_ID = `${PLUGIN_ID}/card.css`
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
.dsm-card{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);border-radius:12px;list-style:none;transition:border-color .16s,background .16s}
|
|
12
|
-
.dsm-card:hover{border-color:var(--dsw-alias-label-dimmed)}
|
|
13
|
-
.dsm-cardOpen{background:var(--dsw-alias-bg-layer-2);border-color:var(--dsw-alias-label-dimmed)}
|
|
14
|
-
.dsm-header{appearance:none;width:100%;font:inherit;color:inherit;text-align:left;cursor:pointer;background:0 0;border:0;border-radius:12px;align-items:center;gap:12px;padding:14px 16px;display:flex}
|
|
15
|
-
.dsm-header:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:-2px}
|
|
16
|
-
.dsm-headText{flex-direction:column;flex:1;gap:4px;min-width:0;display:flex}
|
|
17
|
-
.dsm-name{color:var(--dsw-alias-label-primary);font-size:15px;font-weight:600;line-height:1.4}
|
|
18
|
-
.dsm-description{color:var(--dsw-alias-label-tertiary);font-size:13px;line-height:1.5}
|
|
19
|
-
.dsm-chevron{color:var(--dsw-alias-label-tertiary);flex:none;transition:transform .16s;font-size:12px}
|
|
20
|
-
.dsm-chevronOpen{transform:rotate(180deg)}
|
|
21
|
-
.dsm-pending{white-space:nowrap;background:var(--dsw-alias-bg-module-platform);color:var(--dsw-alias-label-secondary);border-radius:999px;flex:none;padding:1px 8px;font-size:11px;font-weight:500;line-height:17px}
|
|
22
|
-
.dsm-body{border-top:1px solid var(--dsw-alias-border-l2);margin:0 16px;padding-bottom:8px}
|
|
23
|
-
.dsm-field{flex-direction:column;gap:6px;padding:12px 0;display:flex}
|
|
24
|
-
.dsm-field+.dsm-field{border-top:1px solid var(--dsw-alias-border-l2)}
|
|
25
|
-
.dsm-head{align-items:center;gap:8px;display:flex}
|
|
26
|
-
.dsm-label{min-width:0;color:var(--dsw-alias-label-primary);flex:1;font-size:13px;font-weight:500;line-height:1.5}
|
|
27
|
-
.dsm-select{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);height:34px;min-width:0;font:inherit;color:var(--dsw-alias-label-primary);border-radius:8px;padding:0 8px;font-size:13px}
|
|
28
|
-
.dsm-select:focus-visible{border-color:var(--dsw-alias-brand-primary);outline:none}
|
|
29
|
-
.dsm-select:disabled{color:var(--dsw-alias-label-tertiary);cursor:default}
|
|
30
|
-
.dsm-hint{color:var(--dsw-alias-label-tertiary);margin:0;font-size:12px;line-height:1.5}
|
|
31
|
-
.dsm-invalid{color:var(--dsw-alias-label-error);margin:0;font-size:12px;line-height:1.5}
|
|
32
|
-
.dsm-checkRow{align-items:center;gap:8px;display:flex;padding:6px 0}
|
|
33
|
-
.dsm-checkRow input{accent-color:var(--dsw-alias-brand-primary)}
|
|
34
|
-
.dsm-checkRow label{color:var(--dsw-alias-label-primary);font-size:13px;line-height:1.5;cursor:pointer}
|
|
11
|
+
const extraCss = `
|
|
35
12
|
.dsm-row{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-2);border-radius:10px;margin:12px 0 0;padding:4px 12px 10px}
|
|
36
13
|
.dsm-rowHead{align-items:center;gap:8px;padding:8px 0 2px;display:flex}
|
|
37
14
|
.dsm-rowName{min-width:0;color:var(--dsw-alias-label-primary);flex:1;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:13px;font-weight:600;line-height:1.5}
|
|
38
15
|
.dsm-rowHint{color:var(--dsw-alias-label-tertiary);margin:0 0 4px;font-size:12px;line-height:1.5}
|
|
39
|
-
.dsm-groupLabel{color:var(--dsw-alias-label-secondary);font-size:12px;font-weight:600;padding:12px 0 2px;margin:0}
|
|
40
|
-
.dsm-status{min-width:0;color:var(--dsw-alias-label-secondary);flex:1;margin:0;font-size:12px;line-height:1.5}
|
|
41
|
-
.dsm-statusError{color:var(--dsw-alias-label-error)}
|
|
42
16
|
.dsm-banner{background:var(--dsw-alias-interactive-bg-hover-danger);color:var(--dsw-alias-state-error-primary);justify-content:space-between;align-items:center;gap:8px;border-radius:8px;margin-top:12px;padding:7px 8px;font-size:12px;line-height:18px;display:flex}
|
|
43
17
|
.dsm-bannerRetry{color:inherit;font:inherit;cursor:pointer;background:0 0;border:none;flex:none;padding:0;font-weight:600}
|
|
44
18
|
.dsm-empty{color:var(--dsw-alias-label-tertiary);margin:12px 0 0;font-size:12px;line-height:1.5}
|
|
45
|
-
|
|
46
|
-
.dsm-
|
|
47
|
-
.dsm-
|
|
48
|
-
|
|
49
|
-
.dsm-btnPrimary{background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-3)}
|
|
50
|
-
.dsm-btn:disabled{opacity:.4;cursor:default}
|
|
51
|
-
.dsm-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}
|
|
19
|
+
@media (max-width:767px){
|
|
20
|
+
.dsm-row{padding:2px 8px 8px}
|
|
21
|
+
.dsm-rowHead{flex-wrap:wrap}
|
|
22
|
+
}
|
|
52
23
|
`
|
|
53
24
|
|
|
25
|
+
export const cardCssAll = cardCss('dsm', extraCss)
|
|
26
|
+
|
|
54
27
|
/** 幂等注入样式标签;返回标签(已存在或环境无 document 时为 null)。 */
|
|
55
28
|
export function injectStyle(): HTMLStyleElement | null {
|
|
56
|
-
|
|
57
|
-
if (document.querySelector(`style[data-plugin-css=${JSON.stringify(STYLE_TAG_ID)}]`) !== null) {
|
|
58
|
-
return null
|
|
59
|
-
}
|
|
60
|
-
const tag = document.createElement('style')
|
|
61
|
-
tag.dataset.plugin = PLUGIN_ID
|
|
62
|
-
tag.dataset.pluginCss = STYLE_TAG_ID
|
|
63
|
-
tag.textContent = cardCss
|
|
64
|
-
document.head.appendChild(tag)
|
|
65
|
-
return tag
|
|
29
|
+
return injectCardStyle(PLUGIN_ID, cardCssAll)
|
|
66
30
|
}
|
package/src/client/fields.tsx
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 配置卡片的基础控件:勾选行与下拉选择行(视觉对齐官方卡片字段)。
|
|
3
|
-
* @module subagent-model/client/fields
|
|
4
|
-
*/
|
|
5
|
-
import type { ReactElement } from 'react'
|
|
6
|
-
|
|
7
|
-
export interface CheckRowProps {
|
|
8
|
-
id: string
|
|
9
|
-
label: string
|
|
10
|
-
checked: boolean
|
|
11
|
-
disabled?: boolean
|
|
12
|
-
onEdit(checked: boolean): void
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function CheckRow(props: CheckRowProps): ReactElement {
|
|
16
|
-
return (
|
|
17
|
-
<div className="dsm-checkRow">
|
|
18
|
-
<input
|
|
19
|
-
id={props.id}
|
|
20
|
-
type="checkbox"
|
|
21
|
-
checked={props.checked}
|
|
22
|
-
disabled={props.disabled === true}
|
|
23
|
-
onChange={(event) => props.onEdit(event.target.checked)}
|
|
24
|
-
/>
|
|
25
|
-
<label htmlFor={props.id}>{props.label}</label>
|
|
26
|
-
</div>
|
|
27
|
-
)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface SelectOption {
|
|
31
|
-
value: string
|
|
32
|
-
label: string
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface SelectFieldProps {
|
|
36
|
-
id: string
|
|
37
|
-
label: string
|
|
38
|
-
hint?: string
|
|
39
|
-
value: string
|
|
40
|
-
options: SelectOption[]
|
|
41
|
-
disabled?: boolean
|
|
42
|
-
invalid?: boolean
|
|
43
|
-
invalidLabel?: string
|
|
44
|
-
onEdit(value: string): void
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function SelectField(props: SelectFieldProps): ReactElement {
|
|
48
|
-
const invalid = props.invalid === true
|
|
49
|
-
return (
|
|
50
|
-
<div className="dsm-field">
|
|
51
|
-
<div className="dsm-head">
|
|
52
|
-
<label className="dsm-label" htmlFor={props.id}>
|
|
53
|
-
{props.label}
|
|
54
|
-
</label>
|
|
55
|
-
</div>
|
|
56
|
-
<select
|
|
57
|
-
id={props.id}
|
|
58
|
-
className="dsm-select"
|
|
59
|
-
aria-invalid={invalid || undefined}
|
|
60
|
-
value={props.value}
|
|
61
|
-
disabled={props.disabled === true}
|
|
62
|
-
onChange={(event) => props.onEdit(event.target.value)}
|
|
63
|
-
>
|
|
64
|
-
{props.options.map((option) => (
|
|
65
|
-
<option key={option.value} value={option.value}>
|
|
66
|
-
{option.label}
|
|
67
|
-
</option>
|
|
68
|
-
))}
|
|
69
|
-
</select>
|
|
70
|
-
<p className={invalid ? 'dsm-invalid' : 'dsm-hint'}>
|
|
71
|
-
{invalid ? (props.invalidLabel ?? '') : (props.hint ?? '')}
|
|
72
|
-
</p>
|
|
73
|
-
</div>
|
|
74
|
-
)
|
|
75
|
-
}
|
package/src/client/scope.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 浏览器半 settingsScope/connection 的最小本地接口声明。
|
|
3
|
-
* 只声明本插件用到的窄面,避免为构建期类型引入整条官方 client 依赖树;
|
|
4
|
-
* 运行时契约以官方 dsh-client-connection 的 settings RPC 面为准
|
|
5
|
-
* (rc7:白名单已移除,任何已注册命名空间均可 describe/update/replace)。
|
|
6
|
-
*
|
|
7
|
-
* 实现说明:本插件不复用 settingsScope 服务的 bind()——它在非 loopback
|
|
8
|
-
* 页面(如经 tailnet 域名访问)下走 memory 模式、永远无数据;这里按官方
|
|
9
|
-
* 配置页 tab 的同款模式用 `api.settings` 直连实现 Scope(describe 读 +
|
|
10
|
-
* remote `settings/document-updated` / `connection/reset` 刷新,见 client.ts)。
|
|
11
|
-
* @module {pkg}/client/scope
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/** settings 命名空间 scope 的快照(官方 SettingsScopeSnapshot 的最小投影)。 */
|
|
15
|
-
export interface ScopeSnapshot {
|
|
16
|
-
status: 'loading' | 'ready' | 'unavailable'
|
|
17
|
-
/** schema 解析后的配置值(secret 字段已脱敏剥除)。 */
|
|
18
|
-
value: unknown
|
|
19
|
-
/** 命名空间 revision,写操作 fencing 用;首次 Host 应答前为 undefined。 */
|
|
20
|
-
revision: number | undefined
|
|
21
|
-
/** Host 文档是否可写。 */
|
|
22
|
-
writable: boolean
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/** settingsScope.bind({namespace}) 返回的控制器面。 */
|
|
26
|
-
export interface Scope {
|
|
27
|
-
getSnapshot(): ScopeSnapshot
|
|
28
|
-
subscribe(listener: () => void): () => void
|
|
29
|
-
load(): Promise<void>
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/** connection api.settings 的 RPC 面(本插件用到的三个方法)。 */
|
|
33
|
-
export interface SettingsApi {
|
|
34
|
-
describe(payload?: Record<string, never>): Promise<{
|
|
35
|
-
result: {
|
|
36
|
-
ok: boolean
|
|
37
|
-
value?: {
|
|
38
|
-
writable: boolean
|
|
39
|
-
namespaces: Array<{
|
|
40
|
-
ns: string
|
|
41
|
-
value: unknown
|
|
42
|
-
revision: number
|
|
43
|
-
secrets: Array<{ path: string[]; set: boolean }>
|
|
44
|
-
}>
|
|
45
|
-
}
|
|
46
|
-
error?: { message?: string }
|
|
47
|
-
}
|
|
48
|
-
}>
|
|
49
|
-
update(request: {
|
|
50
|
-
ns: string
|
|
51
|
-
patch: Record<string, unknown>
|
|
52
|
-
expectedRevision?: number
|
|
53
|
-
}): Promise<{ result: { ok: boolean; error?: { message?: string } } }>
|
|
54
|
-
replace(request: {
|
|
55
|
-
ns: string
|
|
56
|
-
section: Record<string, unknown>
|
|
57
|
-
expectedRevision?: number
|
|
58
|
-
}): Promise<{ result: { ok: boolean; error?: { message?: string } } }>
|
|
59
|
-
}
|