@dsh-plus/subagent-model 0.1.7 → 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 +414 -286
- package/package.json +4 -2
- package/src/client/card.tsx +94 -157
- package/src/client/client.ts +5 -84
- package/src/client/draft.ts +69 -0
- 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 -56
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,56 +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
|
-
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 } } }>
|
|
56
|
-
}
|