@linxin666/dsh-liangshen 0.4.4 → 0.4.6
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/README.i18n.yaml +2 -2
- package/README.md +27 -9
- package/README.zh.md +26 -8
- package/lib/client.js +134 -31
- package/lib/client.js.map +1 -1
- package/lib/index.js +33 -19
- package/lib/types/client/LiangShenMark.d.ts +13 -0
- package/lib/types/client/LiangShenSettingsCard.d.ts +11 -7
- package/lib/types/client/PluginSettingsCard.d.ts +7 -0
- package/lib/types/client/locales.d.ts +3 -0
- package/lib/types/client/plugin-card-seat.d.ts +5 -0
- package/lib/types/client/settings-form.d.ts +16 -0
- package/lib/types/composition.d.ts +15 -11
- package/lib/types/index.d.ts +44 -22
- package/package.json +16 -16
- package/presets/liangshen/agent.cordis.yml +41 -6
- package/presets/liangshen/dispatcher-rules.mjs +121 -0
- package/presets/liangshen/guard.mjs +134 -34
- package/presets/liangshen/minimal-prompt.mjs +65 -9
- package/presets/liangshen/tool-catalog.mjs +45 -12
- package/src/announce.test.ts +3 -2
- package/src/client/LiangShenMark.tsx +25 -0
- package/src/client/LiangShenSettingsCard.tsx +29 -10
- package/src/client/PluginSettingsCard.tsx +9 -0
- package/src/client/locales.ts +16 -10
- package/src/client/plugin-card-seat.ts +7 -0
- package/src/client/settings-card.module.css +31 -5
- package/src/client/settings-form.ts +27 -1
- package/src/composition.test.ts +56 -0
- package/src/composition.ts +16 -11
- package/src/index.test.ts +56 -0
- package/src/index.ts +51 -23
|
@@ -43,6 +43,18 @@
|
|
|
43
43
|
* (`withheldToolNames`) and is lifted before a new one is applied, so repeated
|
|
44
44
|
* collections do not accumulate filters.
|
|
45
45
|
*
|
|
46
|
+
* WHICH PRESENTATION PAGES WHAT: the registry restriction is installed for
|
|
47
|
+
* `ptc` alone, because a collapsed wire is the one presentation where the
|
|
48
|
+
* scope's registry IS the whole reachable surface. `both` deliberately leaves
|
|
49
|
+
* the registry unrestricted: its wire carries the full native roster beside
|
|
50
|
+
* `run_code`, so a paged namespace is off the direct-call surface while the
|
|
51
|
+
* SDK inside a program still reaches it. That reachability is the native wire's
|
|
52
|
+
* own — the wire carries every registered tool and nothing removes the paged
|
|
53
|
+
* ones from the scope's registry — rather than an exemption paging grants, and
|
|
54
|
+
* it is why the paged-out summary states each presentation's reachability
|
|
55
|
+
* instead of describing both with one sentence. `native` carries no program at
|
|
56
|
+
* all, so the wire partition is the whole of paging there.
|
|
57
|
+
*
|
|
46
58
|
* TIMING: that restriction is installed from OUTSIDE the assembly waterfall.
|
|
47
59
|
* `SystemPrompt.assemble()` collects the tool providers and calls every
|
|
48
60
|
* section's `text(context)` BEFORE it runs the `system-prompt/assemble`
|
|
@@ -62,10 +74,12 @@
|
|
|
62
74
|
* The catalog republishes only when its content changes or the published copy
|
|
63
75
|
* left the visible surface (compaction, resume).
|
|
64
76
|
*
|
|
65
|
-
* RESIDENT BUDGET: `maxResidentTokens`
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
77
|
+
* RESIDENT BUDGET: `maxResidentTokens` estimates the always-on-wire surface
|
|
78
|
+
* and warns once when it is crossed; the shipped ceiling is the
|
|
79
|
+
* `DEFAULT_MAX_RESIDENT_TOKENS` constant below, and a deployment may raise or
|
|
80
|
+
* lower it through the config. The guard is a diagnostic, never a truncation:
|
|
81
|
+
* silently dropping a tool the session needs would trade a measurable context
|
|
82
|
+
* cost for an unmeasurable capability loss.
|
|
69
83
|
*/
|
|
70
84
|
|
|
71
85
|
import {
|
|
@@ -322,21 +336,29 @@ const PTC_PROGRAM_LINES = [
|
|
|
322
336
|
/**
|
|
323
337
|
* The short note the catalog carries when `run_code` sits on the wire beside
|
|
324
338
|
* the native roster ('both'): native calls are the primary surface, and the
|
|
325
|
-
* transport covers programmatic batch work.
|
|
326
|
-
*
|
|
339
|
+
* transport covers programmatic batch work. The trigger is countable, because a
|
|
340
|
+
* shape rule alone leaves the boundary to the model's judgement. Paged-out
|
|
341
|
+
* namespaces stay reachable through the SDK inside a program even before
|
|
342
|
+
* activation — the native wire carries every registered tool and 'both' leaves
|
|
343
|
+
* the scope's registry unrestricted, so nothing removed them from the program's
|
|
344
|
+
* own surface.
|
|
327
345
|
*/
|
|
328
346
|
const BOTH_PROGRAM_LINES = [
|
|
329
|
-
'Prefer calling the tools above directly by name: ordinary single-step work (read, edit, bash, one search) goes through the native call, never through `run_code`. Reserve `run_code` for what a direct call cannot do — an async TypeScript body (`code`, with a short `description`) that reaches tools as `await tools.<name>({ ... })`, overlaps independent read-only calls under `Promise.all`, and catches `ToolCallError` to continue: programmatic batch computation, wide fan-out, or multi-step data shaping.
|
|
330
|
-
'
|
|
347
|
+
'Prefer calling the tools above directly by name: ordinary single-step work (read, edit, bash, one search) goes through the native call, never through `run_code`. Reserve `run_code` for what a direct call cannot do — an async TypeScript body (`code`, with a short `description`) that reaches tools as `await tools.<name>({ ... })`, overlaps independent read-only calls under `Promise.all`, and catches `ToolCallError` to continue: programmatic batch computation, wide fan-out, or multi-step data shaping.',
|
|
348
|
+
'',
|
|
349
|
+
'The trigger is countable: one intent with three or more independent targets, or intermediate results that do not belong in the conversation. Below that, call the tools directly. Every call inside a program must handle its own failure with `try/catch`, so the error chain a program produces is longer than a direct call — wrapping one-step work in a program to save a call pays that cost for nothing.',
|
|
350
|
+
'',
|
|
351
|
+
'Paged-out namespaces stay off the NATIVE direct-call surface but stay reachable through the SDK inside a program even before activation — the native wire carries every registered tool and nothing removes the paged ones from the scope registry, so this is the reachability the wire itself carries rather than an exemption paging grants — and activating one also puts its tools back on the direct surface.',
|
|
331
352
|
]
|
|
332
353
|
|
|
333
354
|
/**
|
|
334
355
|
* Model-facing catalog text.
|
|
335
356
|
* - Native presentation: the on-wire tool list plus the paged-out namespace summary.
|
|
336
|
-
* - 'both': the on-wire list INCLUDING `run_code`, the namespace summary
|
|
337
|
-
* the short programmatic-escape note.
|
|
357
|
+
* - 'both': the on-wire list INCLUDING `run_code`, the namespace summary with
|
|
358
|
+
* its direct-call-only reachability, and the short programmatic-escape note.
|
|
338
359
|
* - 'ptc' (wire collapsed to `run_code`): the SDK-reachable list plus the full
|
|
339
|
-
* program contract naming `run_code` the one direct transport
|
|
360
|
+
* program contract naming `run_code` the one direct transport, and a
|
|
361
|
+
* namespace summary whose page covers the whole surface.
|
|
340
362
|
*/
|
|
341
363
|
export function renderCatalogText(entries, presentation = 'native', inactive = []) {
|
|
342
364
|
// Activated paged families are listed under their namespace heading; every
|
|
@@ -364,11 +386,22 @@ export function renderCatalogText(entries, presentation = 'native', inactive = [
|
|
|
364
386
|
const footer = inactive.length === 0
|
|
365
387
|
? 'This is the complete current list and replaces any earlier available-tools list in this session.'
|
|
366
388
|
: 'This is the current on-wire list and replaces any earlier available-tools list in this session.'
|
|
389
|
+
// The paged-out summary states its own reachability per presentation, because
|
|
390
|
+
// the presentations differ on exactly the fact a reader would otherwise have
|
|
391
|
+
// to infer from the program contract further down: 'ptc' pages the whole
|
|
392
|
+
// surface, 'both' pages the direct-call surface only while a program still
|
|
393
|
+
// reaches what it withholds, and 'native' carries no program at all.
|
|
394
|
+
const inactiveReachability = presentation === 'ptc'
|
|
395
|
+
? 'The page covers the whole surface here, not the wire alone: these namespaces are unreachable from inside a program too until they are activated.'
|
|
396
|
+
: presentation === 'both'
|
|
397
|
+
? 'Only the direct-call surface is paged here: a program still reaches these namespaces before activation, and activating one returns its tools to the direct-call surface as well.'
|
|
398
|
+
: 'This presentation carries no program transport, so the wire is the only surface these namespaces can be reached through.'
|
|
367
399
|
const inactiveBlock = inactive.length === 0 ? [] : [
|
|
368
400
|
'',
|
|
369
401
|
'These tool namespaces are registered but currently paged out of the wire:',
|
|
402
|
+
inactiveReachability,
|
|
370
403
|
'<inactive_namespaces>',
|
|
371
|
-
...inactive.map(ns => `- \`${ns.namespace}\` (${ns.count} tool${ns.count === 1 ? '' : 's'}${ns.sample === '' ? '' : `, e.g. \`${ns.sample}\``}): ${ns.description} Call \`tool_activate({ namespace: "${ns.namespace}" })\` to
|
|
404
|
+
...inactive.map(ns => `- \`${ns.namespace}\` (${ns.count} tool${ns.count === 1 ? '' : 's'}${ns.sample === '' ? '' : `, e.g. \`${ns.sample}\``}): ${ns.description} Call \`tool_activate({ namespace: "${ns.namespace}" })\` to activate it.`),
|
|
372
405
|
'</inactive_namespaces>',
|
|
373
406
|
]
|
|
374
407
|
const presentationLines = presentation === 'ptc'
|
package/src/announce.test.ts
CHANGED
|
@@ -200,11 +200,12 @@ describe('dsh-liangshen preset declaration', () => {
|
|
|
200
200
|
const { host } = await mount({ presentation: 'ptc', guardEnabled: false, guardEchoFailures: 5 })
|
|
201
201
|
const rows = host.declarations[0]!.definition.plugins as readonly { id?: string, config?: Record<string, unknown> }[]
|
|
202
202
|
expect(rows.find(row => row.id === 'tool-catalog')?.config?.['presentation']).toBe('ptc')
|
|
203
|
+
// The echo override the operator committed is written; the two overrides
|
|
204
|
+
// nobody set stay out of the row entirely, so the guard resolves them from
|
|
205
|
+
// the session's reasoning effort and the sensitivity preset.
|
|
203
206
|
expect(rows.find(row => row.id === 'guard')?.config).toEqual({
|
|
204
207
|
enabled: false,
|
|
205
208
|
sensitivity: 'balanced',
|
|
206
|
-
stallReasoningChars: 8000,
|
|
207
|
-
globalStallCap: 4,
|
|
208
209
|
echoFailures: 5,
|
|
209
210
|
})
|
|
210
211
|
})
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Card mark for the LiangShen settings entry: the mode's machine is a
|
|
3
|
+
* slot-machine lever, so the mark is that lever reduced to one knob, one arm
|
|
4
|
+
* and one pivot foot. Three rounded shapes with no interior detail stay
|
|
5
|
+
* legible at 18px, and every shape is painted with `currentColor` so the mark
|
|
6
|
+
* follows the surrounding theme like the lever itself does.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { ReactElement } from 'react'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Render the LiangShen card mark.
|
|
13
|
+
* @returns the 18x18 lever mark, in the current text color.
|
|
14
|
+
*/
|
|
15
|
+
export function LiangShenMark(): ReactElement {
|
|
16
|
+
return (
|
|
17
|
+
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" aria-hidden="true">
|
|
18
|
+
<rect x="3.6" y="13.2" width="8.8" height="2.8" rx="1.4" fill="currentColor" />
|
|
19
|
+
<g transform="rotate(20 8 14.4)">
|
|
20
|
+
<rect x="6.5" y="4.6" width="3" height="9.8" rx="1.5" fill="currentColor" />
|
|
21
|
+
<circle cx="8" cy="4.4" r="2.9" fill="currentColor" />
|
|
22
|
+
</g>
|
|
23
|
+
</svg>
|
|
24
|
+
)
|
|
25
|
+
}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* LiangShen settings card: availability
|
|
3
|
-
* into the `web-ui.plugin.item` child slot the
|
|
4
|
-
* bound to the `liangshen` settings namespace
|
|
2
|
+
* LiangShen settings card: availability, the wire presentation, and the
|
|
3
|
+
* dispatcher identity. Registers into the `web-ui.plugin.item` child slot the
|
|
4
|
+
* Web UI plugin group renders, bound to the `liangshen` settings namespace
|
|
5
|
+
* (the Host profile entry id).
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
* to the preset it declares to the agent-preset registry, so
|
|
8
|
-
* from its preset.
|
|
9
|
-
* every field the Host schema carries appears here.
|
|
7
|
+
* No field acts on this client half: the Host applies the presentation and the
|
|
8
|
+
* dispatcher switch to the preset it declares to the agent-preset registry, so
|
|
9
|
+
* a session reads both from its preset. The card is the operator's only handle
|
|
10
|
+
* on them, which is why every field the Host schema carries appears here.
|
|
10
11
|
*/
|
|
11
12
|
|
|
12
13
|
import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'
|
|
13
14
|
import type { SnapshotStore } from '@deepseek-ai/dsh-client-store'
|
|
14
15
|
import type { ConfigForm } from '@deepseek-ai/dsh-client-ui-settings/client'
|
|
16
|
+
import { LiangShenMark } from './LiangShenMark.tsx'
|
|
15
17
|
import { BooleanField, ChoiceField, PluginSettingsCard, ValueField } from './PluginSettingsCard.tsx'
|
|
16
18
|
import { CardForm, booleanField, choiceField, numberField, type CardActions, type CardShell, type FieldState as CardFieldState } from './settings-form.ts'
|
|
17
19
|
|
|
@@ -29,6 +31,8 @@ export interface LiangShenSettings {
|
|
|
29
31
|
announceToAgent?: boolean
|
|
30
32
|
/** Wire presentation the Host applies to the preset's tool-catalog row. */
|
|
31
33
|
presentation?: string
|
|
34
|
+
/** Whether the preset appends the dispatcher rules section after the persona. */
|
|
35
|
+
dispatcher?: boolean
|
|
32
36
|
/** Master switch for the runtime degeneration circuit breaker. */
|
|
33
37
|
guardEnabled?: boolean
|
|
34
38
|
/** Sensitivity preset scaling the breaker's adaptive thresholds. */
|
|
@@ -46,6 +50,7 @@ export interface LiangShenSettingsCardState extends CardShell {
|
|
|
46
50
|
enabled: CardFieldState
|
|
47
51
|
announceToAgent: CardFieldState
|
|
48
52
|
presentation: CardFieldState
|
|
53
|
+
dispatcher: CardFieldState
|
|
49
54
|
guardEnabled: CardFieldState
|
|
50
55
|
guardSensitivity: CardFieldState
|
|
51
56
|
guardStallReasoningChars: CardFieldState
|
|
@@ -72,6 +77,7 @@ export class LiangShenSettingsCardController {
|
|
|
72
77
|
booleanField('enabled'),
|
|
73
78
|
booleanField('announceToAgent'),
|
|
74
79
|
choiceField('presentation', PRESENTATION_CHOICES),
|
|
80
|
+
booleanField('dispatcher'),
|
|
75
81
|
booleanField('guardEnabled'),
|
|
76
82
|
choiceField('guardSensitivity', SENSITIVITY_CHOICES),
|
|
77
83
|
numberField('guardStallReasoningChars', { integer: true, min: 200 }),
|
|
@@ -87,6 +93,7 @@ export class LiangShenSettingsCardController {
|
|
|
87
93
|
enabled: this.form.field('enabled'),
|
|
88
94
|
announceToAgent: this.form.field('announceToAgent'),
|
|
89
95
|
presentation: this.form.field('presentation'),
|
|
96
|
+
dispatcher: this.form.field('dispatcher'),
|
|
90
97
|
guardEnabled: this.form.field('guardEnabled'),
|
|
91
98
|
guardSensitivity: this.form.field('guardSensitivity'),
|
|
92
99
|
guardStallReasoningChars: this.form.field('guardStallReasoningChars'),
|
|
@@ -135,6 +142,7 @@ export function LiangShenSettingsCard(props: LiangShenSettingsCardProps) {
|
|
|
135
142
|
t={t}
|
|
136
143
|
titleKey="settings.title"
|
|
137
144
|
descriptionKey="settings.description"
|
|
145
|
+
icon={<LiangShenMark />}
|
|
138
146
|
defaultOpen={false}
|
|
139
147
|
state={state}
|
|
140
148
|
renderChildrenWhenNotExposed
|
|
@@ -174,6 +182,17 @@ export function LiangShenSettingsCard(props: LiangShenSettingsCardProps) {
|
|
|
174
182
|
onEdit={(text) => { props.edit('presentation', text) }}
|
|
175
183
|
onReset={() => { props.resetField('presentation') }}
|
|
176
184
|
/>
|
|
185
|
+
<BooleanField
|
|
186
|
+
id="settings-liangshen-dispatcher"
|
|
187
|
+
label={t('settings.dispatcher')}
|
|
188
|
+
hint={t('settings.dispatcherHint')}
|
|
189
|
+
onLabel={t('settings.on')}
|
|
190
|
+
offLabel={t('settings.off')}
|
|
191
|
+
{...fieldProps}
|
|
192
|
+
{...state.dispatcher}
|
|
193
|
+
onEdit={(text) => { props.edit('dispatcher', text) }}
|
|
194
|
+
onReset={() => { props.resetField('dispatcher') }}
|
|
195
|
+
/>
|
|
177
196
|
<BooleanField
|
|
178
197
|
id="settings-liangshen-guard-enabled"
|
|
179
198
|
label={t('settings.guardEnabled')}
|
|
@@ -200,7 +219,7 @@ export function LiangShenSettingsCard(props: LiangShenSettingsCardProps) {
|
|
|
200
219
|
numeric
|
|
201
220
|
label={t('settings.guardStallChars')}
|
|
202
221
|
hint={t('settings.guardStallCharsHint')}
|
|
203
|
-
placeholder=
|
|
222
|
+
placeholder={t('settings.guardAdaptive')}
|
|
204
223
|
{...fieldProps}
|
|
205
224
|
{...state.guardStallReasoningChars}
|
|
206
225
|
onEdit={(text) => { props.edit('guardStallReasoningChars', text) }}
|
|
@@ -211,7 +230,7 @@ export function LiangShenSettingsCard(props: LiangShenSettingsCardProps) {
|
|
|
211
230
|
numeric
|
|
212
231
|
label={t('settings.guardGlobalCap')}
|
|
213
232
|
hint={t('settings.guardGlobalCapHint')}
|
|
214
|
-
placeholder=
|
|
233
|
+
placeholder={t('settings.guardAdaptive')}
|
|
215
234
|
{...fieldProps}
|
|
216
235
|
{...state.guardGlobalStallCap}
|
|
217
236
|
onEdit={(text) => { props.edit('guardGlobalStallCap', text) }}
|
|
@@ -222,7 +241,7 @@ export function LiangShenSettingsCard(props: LiangShenSettingsCardProps) {
|
|
|
222
241
|
numeric
|
|
223
242
|
label={t('settings.guardEchoFailures')}
|
|
224
243
|
hint={t('settings.guardEchoFailuresHint')}
|
|
225
|
-
placeholder=
|
|
244
|
+
placeholder={t('settings.guardAdaptive')}
|
|
226
245
|
{...fieldProps}
|
|
227
246
|
{...state.guardEchoFailures}
|
|
228
247
|
onEdit={(text) => { props.edit('guardEchoFailures', text) }}
|
|
@@ -41,6 +41,13 @@ export interface PluginSettingsCardProps<TKey extends string = string> {
|
|
|
41
41
|
descriptionKey: TKey
|
|
42
42
|
/** Optional rich header description rendered instead of the plain t(descriptionKey) text (the plain text stays as the tooltip). */
|
|
43
43
|
descriptionNode?: ReactNode
|
|
44
|
+
/**
|
|
45
|
+
* Optional leading mark identifying the plugin. A card without one keeps the
|
|
46
|
+
* plain official header shape, so the chrome stays a readable sibling of the
|
|
47
|
+
* built-in PluginCard wherever a family plugin lands in the official bundle
|
|
48
|
+
* seat.
|
|
49
|
+
*/
|
|
50
|
+
icon?: ReactNode
|
|
44
51
|
/** The card's form state: availability, writability, and what a save would do. */
|
|
45
52
|
state: CardShell
|
|
46
53
|
/** Write every staged edit. */
|
|
@@ -91,6 +98,7 @@ export function PluginSettingsCard<TKey extends string = string>(props: PluginSe
|
|
|
91
98
|
const header = alwaysOpen === true
|
|
92
99
|
? (
|
|
93
100
|
<div className={css.headerStatic}>
|
|
101
|
+
{props.icon !== undefined ? <span className={css.mark} aria-hidden="true">{props.icon}</span> : null}
|
|
94
102
|
<span className={css.headText}>
|
|
95
103
|
<span className={css.name} title={title}>{title}</span>
|
|
96
104
|
<span className={css.description} title={description}>{props.descriptionNode ?? description}</span>
|
|
@@ -106,6 +114,7 @@ export function PluginSettingsCard<TKey extends string = string>(props: PluginSe
|
|
|
106
114
|
aria-label={`${props.t(open ? 'settings.collapse' : 'settings.expand')}: ${title}`}
|
|
107
115
|
onClick={() => { setOpen(!open) }}
|
|
108
116
|
>
|
|
117
|
+
{props.icon !== undefined ? <span className={css.mark} aria-hidden="true">{props.icon}</span> : null}
|
|
109
118
|
<span className={css.headText}>
|
|
110
119
|
<span className={css.name} title={title}>{title}</span>
|
|
111
120
|
<span className={css.description} title={description}>{props.descriptionNode ?? description}</span>
|
package/src/client/locales.ts
CHANGED
|
@@ -29,6 +29,8 @@ export const zh = {
|
|
|
29
29
|
'settings.announceToAgentHint': '开启后向每一轮 agent 系统提示注入本插件公告;默认关闭以保持提示词干净。',
|
|
30
30
|
'settings.presentation': '工具面呈现方式',
|
|
31
31
|
'settings.presentationHint': '写入本插件声明的预设的 tool-catalog 行:both(出厂默认)让原生清单与 run_code 同驻(原生直调优先);native 保持原生工具清单;ptc 把 wire 收拢为 run_code。改动立即生效,但已开始的会话保持其已声明的组合。',
|
|
32
|
+
'settings.dispatcher': '调度者身份',
|
|
33
|
+
'settings.dispatcherHint': '开启后本模式按调度 Agent 工作:先分诊复杂度(L0/L1 直接执行,L2 走完整流程),L2 任务先澄清访谈再规划,由主代理派发子代理并逐层审查与验收。与工具面呈现方式无关,只决定身份与流程纪律。出厂默认开启;关闭后回到仅含工作纪律的极简 persona。',
|
|
32
34
|
'settings.on': '开',
|
|
33
35
|
'settings.off': '关',
|
|
34
36
|
'settings.inherit': '继承(跟随部署默认)',
|
|
@@ -48,18 +50,19 @@ export const zh = {
|
|
|
48
50
|
'presentation.native': 'native(原生工具清单)',
|
|
49
51
|
'presentation.both': 'both(两者同驻)',
|
|
50
52
|
'settings.guardEnabled': '启用退化熔断器',
|
|
51
|
-
'settings.guardEnabledHint': '运行时检测思考退化(连续零产出长思考 /
|
|
53
|
+
'settings.guardEnabledHint': '运行时检测思考退化(连续零产出长思考 / 同参重复失败),触发时注入熔断提示;仅停摆信号额外临时下调推理档位(max→high,不下探到甜区以下)。关闭后不干预任何请求。',
|
|
52
54
|
'settings.guardStallChars': '单步暴走字符阈值',
|
|
53
|
-
'settings.guardStallCharsHint': '
|
|
55
|
+
'settings.guardStallCharsHint': '留空即按推理档位自适应:max 档 8000 / high 档 12000 / low 档 20000 字符(按 V4.1 官方 384K 最大输出校准,约 2-4K 思考 token),再按灵敏度预设缩放。填写本字段则以该固定值覆盖所有档位。',
|
|
54
56
|
'settings.guardGlobalCap': '慢烧连续步数',
|
|
55
|
-
'settings.guardGlobalCapHint': '
|
|
57
|
+
'settings.guardGlobalCapHint': '留空即按灵敏度预设缩放(均衡档为 4);provider 不持久化推理文本的会话也以此为兜底步骤计数。填写本字段则以该固定值覆盖。步数越小越敏感,真实长调查建议调大。',
|
|
56
58
|
'settings.guardSensitivity': '熔断灵敏度',
|
|
57
|
-
'settings.guardSensitivityHint': '整体缩放熔断阈值:保守(更少打断,阈值×1.5)、均衡(出厂校准值)、激进(更早触发,阈值×0.5
|
|
59
|
+
'settings.guardSensitivityHint': '整体缩放熔断阈值:保守(更少打断,阈值×1.5)、均衡(出厂校准值)、激进(更早触发,阈值×0.5)。仅在对应细调字段留空时生效——阈值随推理档位自适应:max 档 8000 / high 档 12000 / low 档 20000 字符。',
|
|
58
60
|
'sensitivity.conservative': '保守(少打断)',
|
|
59
61
|
'sensitivity.balanced': '均衡(默认)',
|
|
60
62
|
'sensitivity.aggressive': '激进(早触发)',
|
|
61
63
|
'settings.guardEchoFailures': '同参连续失败次数',
|
|
62
|
-
'settings.guardEchoFailuresHint': '
|
|
64
|
+
'settings.guardEchoFailuresHint': '留空即按灵敏度预设缩放(均衡档为 3);填写本字段则以该固定值覆盖。空转信号只注入熔断消息,不下调推理档位。',
|
|
65
|
+
'settings.guardAdaptive': '自适应',
|
|
63
66
|
}
|
|
64
67
|
|
|
65
68
|
/** English counterpart; the key set mirrors {@link zh} exactly. */
|
|
@@ -87,6 +90,8 @@ export const en: Record<keyof typeof zh, string> = {
|
|
|
87
90
|
'settings.announceToAgentHint': 'Adds this plugin announcement to every agent system prompt; off by default so prompts stay clean.',
|
|
88
91
|
'settings.presentation': 'Wire presentation',
|
|
89
92
|
'settings.presentationHint': 'Written into the tool-catalog row of the preset this plugin declares: both (the shipped default) keeps the roster and run_code co-resident (direct native calls first); native keeps the native roster; ptc collapses the wire to run_code. A change re-declares the preset immediately; sessions that already started keep the composition they declared.',
|
|
93
|
+
'settings.dispatcher': 'Dispatcher identity',
|
|
94
|
+
'settings.dispatcherHint': 'When on, the mode works as a dispatcher agent: it triages complexity first (L0/L1 work is done directly, an L2 task runs the full flow), clarifies an L2 task through an interview before planning, and the lead agent dispatches subagents and reviews and accepts them layer by layer. It is unrelated to the wire presentation and decides identity and process discipline only. On by default; switching it off returns the prompt to the bare persona with its working discipline.',
|
|
90
95
|
'settings.on': 'On',
|
|
91
96
|
'settings.off': 'Off',
|
|
92
97
|
'settings.inherit': 'Inherit (deployment default)',
|
|
@@ -106,18 +111,19 @@ export const en: Record<keyof typeof zh, string> = {
|
|
|
106
111
|
'presentation.native': 'native (native tool roster)',
|
|
107
112
|
'presentation.both': 'both (both co-resident)',
|
|
108
113
|
'settings.guardEnabled': 'Degeneration circuit breaker',
|
|
109
|
-
'settings.guardEnabledHint': 'Detects reasoning degeneration at runtime (consecutive zero-output long reasoning / repeated identical-argument failures)
|
|
114
|
+
'settings.guardEnabledHint': 'Detects reasoning degeneration at runtime (consecutive zero-output long reasoning / repeated identical-argument failures) and injects a breaker message; only a stall also steps the reasoning effort down (max to high, never below the sweet spot). Disabled means requests are never touched.',
|
|
110
115
|
'settings.guardStallChars': 'Runaway reasoning character floor',
|
|
111
|
-
'settings.guardStallCharsHint': '
|
|
116
|
+
'settings.guardStallCharsHint': 'Leave empty to adapt to the reasoning effort: 8000 at max / 12000 at high / 20000 at low characters (calibrated against V4.1\'s official 384K max output, roughly 2-4K thinking tokens), then scaled by the sensitivity preset. Setting a value pins it for every effort level.',
|
|
112
117
|
'settings.guardGlobalCap': 'Slow-burn step count',
|
|
113
|
-
'settings.guardGlobalCapHint': '
|
|
118
|
+
'settings.guardGlobalCapHint': 'Leave empty to scale with the sensitivity preset (4 at balanced); it is also the fallback step count for a session whose provider persists no reasoning text. Setting a value pins it. Lower is more sensitive — raise it for genuinely long investigations.',
|
|
114
119
|
'settings.guardSensitivity': 'Breaker sensitivity',
|
|
115
|
-
'settings.guardSensitivityHint': 'Scales every breaker threshold: conservative (fewer interruptions, x1.5), balanced (the calibrated defaults), aggressive (fires earlier, x0.5).
|
|
120
|
+
'settings.guardSensitivityHint': 'Scales every breaker threshold: conservative (fewer interruptions, x1.5), balanced (the calibrated defaults), aggressive (fires earlier, x0.5). It applies only where the matching fine-tuning field is left empty — thresholds adapt to the reasoning effort: 8000 at max / 12000 at high / 20000 at low.',
|
|
116
121
|
'sensitivity.conservative': 'Conservative (fewer interruptions)',
|
|
117
122
|
'sensitivity.balanced': 'Balanced (default)',
|
|
118
123
|
'sensitivity.aggressive': 'Aggressive (fires earlier)',
|
|
119
124
|
'settings.guardEchoFailures': 'Identical-argument failures',
|
|
120
|
-
'settings.guardEchoFailuresHint': '
|
|
125
|
+
'settings.guardEchoFailuresHint': 'Leave empty to scale with the sensitivity preset (3 at balanced); setting a value pins it. An echo only injects the breaker message — it never steps the reasoning effort down.',
|
|
126
|
+
'settings.guardAdaptive': 'Adaptive',
|
|
121
127
|
}
|
|
122
128
|
|
|
123
129
|
/** Every key in the locale catalog. */
|
|
@@ -86,6 +86,11 @@ export interface PluginCardSeat {
|
|
|
86
86
|
label?: () => string
|
|
87
87
|
/** Locale namespace the card renders with. */
|
|
88
88
|
locale: string
|
|
89
|
+
/**
|
|
90
|
+
* Child slots this card declares and renders. Forwarded to whichever seat
|
|
91
|
+
* the host renders; absent for a card that declares none.
|
|
92
|
+
*/
|
|
93
|
+
children?: Record<string, unknown>
|
|
89
94
|
/** Business-face factory of the registration. */
|
|
90
95
|
inject?: () => object
|
|
91
96
|
/**
|
|
@@ -162,12 +167,14 @@ export function installPluginCard(ctx: PluginCardContext, seat: PluginCardSeat):
|
|
|
162
167
|
...(seat.order === undefined ? {} : { order: seat.order }),
|
|
163
168
|
...(seat.label === undefined ? {} : { label: seat.label }),
|
|
164
169
|
locale: seat.locale,
|
|
170
|
+
...(seat.children === undefined ? {} : { children: seat.children }),
|
|
165
171
|
...(seat.inject === undefined ? {} : { inject }),
|
|
166
172
|
}
|
|
167
173
|
: {
|
|
168
174
|
name: OFFICIAL_PLUGIN_CARD_SEAT,
|
|
169
175
|
key: seat.bundle,
|
|
170
176
|
locale: seat.locale,
|
|
177
|
+
...(seat.children === undefined ? {} : { children: seat.children }),
|
|
171
178
|
...(seat.inject === undefined ? {} : { inject }),
|
|
172
179
|
}) as never, component) as () => void
|
|
173
180
|
current = target
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
border: 0;
|
|
37
37
|
border-radius: 12px;
|
|
38
38
|
align-items: center;
|
|
39
|
-
gap:
|
|
40
|
-
padding:
|
|
39
|
+
gap: 13px;
|
|
40
|
+
padding: 16px;
|
|
41
41
|
display: flex;
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
box-sizing: border-box;
|
|
52
52
|
border-radius: 12px;
|
|
53
53
|
align-items: center;
|
|
54
|
-
gap:
|
|
55
|
-
padding:
|
|
54
|
+
gap: 13px;
|
|
55
|
+
padding: 16px;
|
|
56
56
|
display: flex;
|
|
57
57
|
}
|
|
58
58
|
|
|
@@ -64,6 +64,25 @@
|
|
|
64
64
|
display: flex;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
/* Optional leading plugin mark: a quiet tile that takes the ink color on
|
|
68
|
+
hover and while the card is open, so the whole row reads as one control. */
|
|
69
|
+
.mark {
|
|
70
|
+
flex: none;
|
|
71
|
+
display: grid;
|
|
72
|
+
place-items: center;
|
|
73
|
+
width: 34px;
|
|
74
|
+
height: 34px;
|
|
75
|
+
border-radius: 10px;
|
|
76
|
+
background: var(--dsw-alias-bg-module-platform);
|
|
77
|
+
color: var(--dsw-alias-label-secondary);
|
|
78
|
+
transition: color 0.16s;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.header:hover .mark,
|
|
82
|
+
.cardOpen .mark {
|
|
83
|
+
color: var(--dsw-alias-label-primary);
|
|
84
|
+
}
|
|
85
|
+
|
|
67
86
|
.name {
|
|
68
87
|
color: var(--dsw-alias-label-primary);
|
|
69
88
|
font-size: 15px;
|
|
@@ -95,7 +114,13 @@
|
|
|
95
114
|
.chevron {
|
|
96
115
|
color: var(--dsw-alias-label-tertiary);
|
|
97
116
|
flex: none;
|
|
98
|
-
|
|
117
|
+
width: 16px;
|
|
118
|
+
height: 16px;
|
|
119
|
+
transition: transform 0.16s, color 0.16s;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.header:hover .chevron {
|
|
123
|
+
color: var(--dsw-alias-label-secondary);
|
|
99
124
|
}
|
|
100
125
|
|
|
101
126
|
.chevronOpen {
|
|
@@ -406,6 +431,7 @@
|
|
|
406
431
|
@media (prefers-reduced-motion: reduce) {
|
|
407
432
|
.card,
|
|
408
433
|
.header,
|
|
434
|
+
.mark,
|
|
409
435
|
.chevron,
|
|
410
436
|
.chevronOpen,
|
|
411
437
|
.discard,
|
|
@@ -215,6 +215,8 @@ export class CardForm<T> {
|
|
|
215
215
|
private readonly disposeForm: () => void
|
|
216
216
|
private disposed = false
|
|
217
217
|
private saving = false
|
|
218
|
+
/** A save asked for while one was in flight; it runs once the first settles (#1754). */
|
|
219
|
+
private saveQueued = false
|
|
218
220
|
private failed = false
|
|
219
221
|
private failedReason: string | undefined
|
|
220
222
|
|
|
@@ -283,7 +285,7 @@ export class CardForm<T> {
|
|
|
283
285
|
resetField: (field) => {
|
|
284
286
|
this.stage(field, { text: this.specOf(field).format(this.baseValue(field)), clear: true })
|
|
285
287
|
},
|
|
286
|
-
save: () => { void this.
|
|
288
|
+
save: () => { void this.requestSave() },
|
|
287
289
|
discard: () => {
|
|
288
290
|
if (this.staged.size === 0 && !this.failed) return
|
|
289
291
|
this.staged.clear()
|
|
@@ -310,6 +312,30 @@ export class CardForm<T> {
|
|
|
310
312
|
* the user can correct them instead of retyping.
|
|
311
313
|
* @returns settlement after the mutation and the read-back.
|
|
312
314
|
*/
|
|
315
|
+
/**
|
|
316
|
+
* Run one save, and re-run it once if another was asked for while this one
|
|
317
|
+
* was still in flight.
|
|
318
|
+
*
|
|
319
|
+
* A save is a Host round trip that also drives the profile reconcile, and
|
|
320
|
+
* the Host runs that write inside one exclusive transaction. Answering a
|
|
321
|
+
* press that arrives mid-flight by returning immediately dropped the edit
|
|
322
|
+
* with no explanation, which is the "the save button stops working after a
|
|
323
|
+
* few rounds" report (#1754). Serializing instead means a save pressed while
|
|
324
|
+
* another is still settling runs against the settled state - which is what
|
|
325
|
+
* the operator meant by pressing it again.
|
|
326
|
+
* @returns settlement after the mutation and the read-back.
|
|
327
|
+
*/
|
|
328
|
+
async requestSave(): Promise<void> {
|
|
329
|
+
if (this.saving) {
|
|
330
|
+
this.saveQueued = true
|
|
331
|
+
return
|
|
332
|
+
}
|
|
333
|
+
await this.save()
|
|
334
|
+
if (!this.saveQueued) return
|
|
335
|
+
this.saveQueued = false
|
|
336
|
+
await this.requestSave()
|
|
337
|
+
}
|
|
338
|
+
|
|
313
339
|
async save(): Promise<void> {
|
|
314
340
|
const plan = this.plan()
|
|
315
341
|
const valid = plan.filter((item): item is PlannedWrite & { judge: () => boolean } => item.judge !== undefined)
|
package/src/composition.test.ts
CHANGED
|
@@ -77,6 +77,14 @@ describe('readCompositionRows', () => {
|
|
|
77
77
|
expect(catalog['pagedToolPatterns']).toEqual(['mcp__*'])
|
|
78
78
|
})
|
|
79
79
|
|
|
80
|
+
it('operator reads the shipped dispatcher switch ON on the minimal-prompt row', () => {
|
|
81
|
+
// Given the factory composition, When the operator reads the minimal-prompt
|
|
82
|
+
// row, Then it declares `dispatcher: true`: the shipped default appends the
|
|
83
|
+
// dispatcher block, and the key is present so the overlay writes a value
|
|
84
|
+
// rather than inventing a key the row never carried.
|
|
85
|
+
expect(configOf(rowOf(rows(), 'minimal-prompt'))['dispatcher']).toBe(true)
|
|
86
|
+
})
|
|
87
|
+
|
|
80
88
|
it('operator keeps a literal block scalar verbatim', () => {
|
|
81
89
|
// Given the persona row's `prefix: |-` scalar, When the operator reads it,
|
|
82
90
|
// Then the prose is content and the next composition row ends it.
|
|
@@ -235,6 +243,22 @@ describe('applyPresetOverrides', () => {
|
|
|
235
243
|
expect(applyPresetOverrides(parsed, {})).toEqual(parsed)
|
|
236
244
|
})
|
|
237
245
|
|
|
246
|
+
it('operator leaves every guard key out of the row while the settings are unset', () => {
|
|
247
|
+
// Given the shipped rows and settings whose guard overrides are unset (the
|
|
248
|
+
// factory state), When the operator applies the overlay, Then the guard row
|
|
249
|
+
// carries no fine-tuning key at all, so the guard's own effort-adaptive
|
|
250
|
+
// thresholds and sensitivity preset are what a session actually runs.
|
|
251
|
+
const applied = applyPresetOverrides(rows(), {
|
|
252
|
+
presentation: 'both',
|
|
253
|
+
guardEnabled: true,
|
|
254
|
+
guardSensitivity: 'balanced',
|
|
255
|
+
guardStallReasoningChars: undefined,
|
|
256
|
+
guardGlobalStallCap: undefined,
|
|
257
|
+
guardEchoFailures: undefined,
|
|
258
|
+
})
|
|
259
|
+
expect(configOf(rowOf(applied, 'guard'))).toEqual({ enabled: true, sensitivity: 'balanced' })
|
|
260
|
+
})
|
|
261
|
+
|
|
238
262
|
it('operator writes the settings into the rows that carry them', () => {
|
|
239
263
|
// Given committed settings, When the operator applies the overlay, Then
|
|
240
264
|
// the tool-catalog and guard rows carry them and nothing else moves.
|
|
@@ -258,6 +282,38 @@ describe('applyPresetOverrides', () => {
|
|
|
258
282
|
expect(rowOf(applied, 'minimal-prompt')).toEqual(rowOf(rows(), 'minimal-prompt'))
|
|
259
283
|
})
|
|
260
284
|
|
|
285
|
+
it('operator leaves the dispatcher key out of the row while the setting is unset', () => {
|
|
286
|
+
// Given the shipped rows and no dispatcher choice, When the operator
|
|
287
|
+
// applies the overlay, Then the minimal-prompt row keeps exactly the keys
|
|
288
|
+
// the composition declares: the switch is only ever written when a caller
|
|
289
|
+
// committed a value for it, never invented as a factory default.
|
|
290
|
+
const applied = applyPresetOverrides(rows(), { presentation: 'both' })
|
|
291
|
+
expect(rowOf(applied, 'minimal-prompt')).toEqual(rowOf(rows(), 'minimal-prompt'))
|
|
292
|
+
expect(configOf(rowOf(applied, 'minimal-prompt'))['dispatcher']).toBe(true)
|
|
293
|
+
})
|
|
294
|
+
|
|
295
|
+
it('operator writes the dispatcher switch into the minimal-prompt row', () => {
|
|
296
|
+
// Given a committed dispatcher choice, When the operator applies the
|
|
297
|
+
// overlay, Then the minimal-prompt row carries it and the presentation key
|
|
298
|
+
// in the tool-catalog row is untouched: the two settings are orthogonal,
|
|
299
|
+
// and the row's other config keys survive.
|
|
300
|
+
const applied = applyPresetOverrides(rows(), { presentation: 'both', dispatcher: true })
|
|
301
|
+
const prompt = configOf(rowOf(applied, 'minimal-prompt'))
|
|
302
|
+
expect(prompt['dispatcher']).toBe(true)
|
|
303
|
+
expect(prompt['keepPlanPolicy']).toBe(true)
|
|
304
|
+
expect(prompt['instructionSource']).toBe('host')
|
|
305
|
+
expect(configOf(rowOf(applied, 'tool-catalog'))['presentation']).toBe('both')
|
|
306
|
+
expect(rowOf(applied, 'guard')).toEqual(rowOf(rows(), 'guard'))
|
|
307
|
+
})
|
|
308
|
+
|
|
309
|
+
it('operator turns the dispatcher switch back off through the same key', () => {
|
|
310
|
+
// Given a committed `false` for the dispatcher switch, When the operator
|
|
311
|
+
// applies the overlay, Then the row carries that value: the key is written
|
|
312
|
+
// for both directions, so a session can return to the bare persona.
|
|
313
|
+
const applied = applyPresetOverrides(rows(), { dispatcher: false })
|
|
314
|
+
expect(configOf(rowOf(applied, 'minimal-prompt'))['dispatcher']).toBe(false)
|
|
315
|
+
})
|
|
316
|
+
|
|
261
317
|
it('operator is never given a row the composition does not carry', () => {
|
|
262
318
|
// Given a composition with no tool-catalog row, When the operator applies
|
|
263
319
|
// a presentation choice, Then no row is invented for it.
|
package/src/composition.ts
CHANGED
|
@@ -490,22 +490,25 @@ export function readPresetDefinition(id: string, dir: string): PresetDefinition
|
|
|
490
490
|
*
|
|
491
491
|
* The settings surface edits the PLUGIN's own Config, while the values that
|
|
492
492
|
* shape a session live in the declared preset's rows; applying them here is what
|
|
493
|
-
* connects the two. Every field is optional
|
|
494
|
-
*
|
|
493
|
+
* connects the two. Every field is optional, and an absent OR `undefined` value
|
|
494
|
+
* writes nothing at all — the key stays out of the row and the guard's own
|
|
495
|
+
* adaptive resolution decides the effective threshold.
|
|
495
496
|
*/
|
|
496
497
|
export interface PresetOverrides {
|
|
497
498
|
/** The `tool-catalog` row's `presentation` value. */
|
|
498
499
|
presentation?: string
|
|
500
|
+
/** The `minimal-prompt` row's `dispatcher` switch. */
|
|
501
|
+
dispatcher?: boolean
|
|
499
502
|
/** The `guard` row's `enabled` switch. */
|
|
500
503
|
guardEnabled?: boolean
|
|
501
504
|
/** The `guard` row's sensitivity preset. */
|
|
502
505
|
guardSensitivity?: string
|
|
503
|
-
/** The `guard` row's per-step reasoning-character floor. */
|
|
504
|
-
guardStallReasoningChars?: number
|
|
505
|
-
/** The `guard` row's slow-burn step cap. */
|
|
506
|
-
guardGlobalStallCap?: number
|
|
507
|
-
/** The `guard` row's identical-argument failure count. */
|
|
508
|
-
guardEchoFailures?: number
|
|
506
|
+
/** The `guard` row's per-step reasoning-character floor override. */
|
|
507
|
+
guardStallReasoningChars?: number | undefined
|
|
508
|
+
/** The `guard` row's slow-burn step cap override. */
|
|
509
|
+
guardGlobalStallCap?: number | undefined
|
|
510
|
+
/** The `guard` row's identical-argument failure count override. */
|
|
511
|
+
guardEchoFailures?: number | undefined
|
|
509
512
|
}
|
|
510
513
|
|
|
511
514
|
/** One settings overlay entry: the row it targets and the keys it writes. */
|
|
@@ -515,6 +518,7 @@ type OverrideTarget = readonly [string, Readonly<Record<string, unknown>>]
|
|
|
515
518
|
function overrideTargets(overrides: PresetOverrides): OverrideTarget[] {
|
|
516
519
|
return [
|
|
517
520
|
['tool-catalog', { ...overrides.presentation === undefined ? {} : { presentation: overrides.presentation } }],
|
|
521
|
+
['minimal-prompt', { ...overrides.dispatcher === undefined ? {} : { dispatcher: overrides.dispatcher } }],
|
|
518
522
|
['guard', {
|
|
519
523
|
...overrides.guardEnabled === undefined ? {} : { enabled: overrides.guardEnabled },
|
|
520
524
|
...overrides.guardSensitivity === undefined ? {} : { sensitivity: overrides.guardSensitivity },
|
|
@@ -530,9 +534,10 @@ function overrideTargets(overrides: PresetOverrides): OverrideTarget[] {
|
|
|
530
534
|
*
|
|
531
535
|
* Rows are addressed by their `id`, and only a row the composition actually
|
|
532
536
|
* carries is touched: the overlay narrows the shipped configuration, it never
|
|
533
|
-
* invents a mount the preset did not have.
|
|
534
|
-
*
|
|
535
|
-
*
|
|
537
|
+
* invents a mount the preset did not have. A field the settings surface left
|
|
538
|
+
* unset is written as no key at all rather than as a value, which is what keeps
|
|
539
|
+
* the guard's effort-adaptive thresholds the shipped behavior: the overlay only
|
|
540
|
+
* ever adds an override on top of them.
|
|
536
541
|
* @param rows - the parsed composition rows.
|
|
537
542
|
* @param overrides - the operator's settings-surface choices.
|
|
538
543
|
* @returns a new row list with the overlay applied.
|