@linxin666/dsh-liangshen 0.3.24 → 0.4.1
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 +24 -17
- package/README.zh.md +25 -18
- package/cordis.patch.yml +3 -2
- package/icon.svg +3 -0
- package/lib/client.js +381 -77
- package/lib/client.js.map +1 -1
- package/lib/index.js +594 -428
- package/lib/types/announce.test.d.ts +10 -0
- package/lib/types/client/LiangShenSettingsCard.d.ts +27 -10
- package/lib/types/client/PluginSettingsCard.d.ts +4 -0
- package/lib/types/client/index.d.ts +32 -13
- package/lib/types/client/lever-controller.d.ts +16 -2
- package/lib/types/client/locales.d.ts +13 -0
- package/lib/types/client/main-session.d.ts +32 -0
- package/lib/types/client/plugin-card-seat.d.ts +23 -16
- package/lib/types/client/settings-form.d.ts +17 -17
- package/lib/types/composition.d.ts +116 -0
- package/lib/types/composition.test.d.ts +7 -0
- package/lib/types/index.d.ts +146 -31
- package/lib/types/index.test.d.ts +5 -0
- package/package.json +25 -20
- package/presets/liangshen/agent.cordis.yml +44 -10
- package/presets/liangshen/fact-ledger.mjs +141 -0
- package/presets/liangshen/guard.mjs +426 -0
- package/presets/liangshen/minimal-prompt.mjs +2 -2
- package/presets/liangshen/tool-catalog.mjs +24 -20
- package/presets/liangshen/working-context.mjs +10 -2
- package/src/announce.test.ts +248 -55
- package/src/client/LiangShenLever.module.css +2 -0
- package/src/client/LiangShenLever.tsx +37 -9
- package/src/client/LiangShenSettingsCard.tsx +96 -12
- package/src/client/PluginSettingsCard.tsx +7 -2
- package/src/client/index.ts +61 -23
- package/src/client/lever-controller.ts +76 -9
- package/src/client/locales.ts +30 -4
- package/src/client/main-session.ts +43 -0
- package/src/client/plugin-card-seat.ts +24 -17
- package/src/client/settings-form.ts +34 -31
- package/src/composition.test.ts +294 -0
- package/src/composition.ts +554 -0
- package/src/index.test.ts +68 -1
- package/src/index.ts +278 -107
- package/tools/benchmark-live-run.mjs +171 -32
- package/lib/types/schema.d.ts +0 -18
- package/lib/types/schema.test.d.ts +0 -1
- package/lib/types/sync.d.ts +0 -74
- package/lib/types/sync.test.d.ts +0 -1
- package/src/schema.test.ts +0 -64
- package/src/schema.ts +0 -110
- package/src/sync.test.ts +0 -303
- package/src/sync.ts +0 -324
package/src/client/index.ts
CHANGED
|
@@ -24,8 +24,8 @@ import type {} from '@deepseek-ai/dsh-client-locale/client'
|
|
|
24
24
|
// Type-only: pulls the ui-conversation SlotMap merge (the composer tool row).
|
|
25
25
|
import type {} from '@deepseek-ai/dsh-client-ui-conversation/client'
|
|
26
26
|
import type {} from '@deepseek-ai/dsh-client-ui-slots'
|
|
27
|
-
import type {
|
|
28
|
-
// Type-only: pulls the settings-surface Context merge (ctx.
|
|
27
|
+
import type { ConfigForm, ConfigForms } from '@deepseek-ai/dsh-client-ui-settings/client'
|
|
28
|
+
// Type-only: pulls the settings-surface Context merge (ctx.configForms).
|
|
29
29
|
import type {} from '@deepseek-ai/dsh-client-ui-settings/client'
|
|
30
30
|
import { LiangShenLever } from './LiangShenLever.tsx'
|
|
31
31
|
import { LeverController } from './lever-controller.ts'
|
|
@@ -36,8 +36,27 @@ import { installPluginCard } from './plugin-card-seat.ts'
|
|
|
36
36
|
/** Locale namespace this half owns. */
|
|
37
37
|
export const NS = 'liangshen'
|
|
38
38
|
|
|
39
|
-
/**
|
|
40
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Settings namespace the settings card edits. Under the 0.1.7 settings
|
|
41
|
+
* contract the namespace IS the Host profile entry id, so this names the
|
|
42
|
+
* standalone row; the aggregate install mounts the generated
|
|
43
|
+
* `web-ui-liangshen` row instead and the family binder resolves between the
|
|
44
|
+
* two. Without that binder the card binds the entry id directly.
|
|
45
|
+
*/
|
|
46
|
+
export const SETTINGS_NAMESPACE = 'liangshen'
|
|
47
|
+
const AGGREGATE_ENTRY_ID = 'web-ui-liangshen'
|
|
48
|
+
const LIANGSHEN_ENTRY_IDS: readonly string[] = [AGGREGATE_ENTRY_ID, 'ui-liangshen', SETTINGS_NAMESPACE]
|
|
49
|
+
|
|
50
|
+
function servedEntryId(forms: ConfigForms): string {
|
|
51
|
+
let served: readonly string[] | undefined
|
|
52
|
+
try {
|
|
53
|
+
served = forms.describe().getSnapshot().view?.namespaces.map(view => view.ns)
|
|
54
|
+
} catch {
|
|
55
|
+
served = undefined
|
|
56
|
+
}
|
|
57
|
+
if (!served || served.length === 0) return SETTINGS_NAMESPACE
|
|
58
|
+
return LIANGSHEN_ENTRY_IDS.find(id => served.includes(id)) ?? SETTINGS_NAMESPACE
|
|
59
|
+
}
|
|
41
60
|
|
|
42
61
|
/** Owner share of a plugin card (the section supplies nothing). */
|
|
43
62
|
export interface SettingsPluginItemOwnerProps {
|
|
@@ -49,8 +68,9 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
|
49
68
|
interface SlotMap {
|
|
50
69
|
/**
|
|
51
70
|
* The child slot the Web UI plugin group declares; this card registers into
|
|
52
|
-
* the group
|
|
53
|
-
* here so this package needs no dependency on the sibling UI
|
|
71
|
+
* the group's list seat rather than the official bundle-configuration
|
|
72
|
+
* seat. Declared here so this package needs no dependency on the sibling UI
|
|
73
|
+
* package.
|
|
54
74
|
*/
|
|
55
75
|
'web-ui.plugin.item': { kind: 'list'; scope: 'root'; owner: SettingsPluginItemOwnerProps }
|
|
56
76
|
}
|
|
@@ -59,21 +79,34 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
|
59
79
|
declare module '@deepseek-ai/cordis' {
|
|
60
80
|
interface Context {
|
|
61
81
|
/**
|
|
62
|
-
* Optional
|
|
63
|
-
* that group plugin is not installed, so callers
|
|
64
|
-
*
|
|
82
|
+
* Optional family settings binder provided by dsh-web-settings; absent when
|
|
83
|
+
* that group plugin is not installed, so callers bind the shared forms
|
|
84
|
+
* service (`ctx.configForms`) by profile entry id directly.
|
|
65
85
|
*/
|
|
66
|
-
webUiSettings?: { bind<S>(spec:
|
|
86
|
+
webUiSettings?: { bind<S>(spec: LiangShenFormSpec<S>): ConfigForm<S> }
|
|
67
87
|
}
|
|
68
88
|
}
|
|
69
89
|
|
|
70
90
|
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
|
|
91
|
+
* One settings namespace a family card binds. The 0.1.7 client exports no spec
|
|
92
|
+
* type (the form controller takes it privately), so the binder's input shape is
|
|
93
|
+
* restated here.
|
|
94
|
+
*/
|
|
95
|
+
export interface LiangShenFormSpec<T> {
|
|
96
|
+
/** Settings namespace registered by the owning host plugin. */
|
|
97
|
+
namespace: string
|
|
98
|
+
/** Narrow one wire section; undefined keeps the last accepted value. */
|
|
99
|
+
decode?: (section: unknown) => T | undefined
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Required client services: the slot registry, locale, sessions, the shared
|
|
104
|
+
* configuration forms, and the roster Remote. Both `remote` and
|
|
105
|
+
* `remote.agentPresets` are declared: the context proxy refuses an uninjected
|
|
106
|
+
* service, and a nested service name does not imply its parent, so reading
|
|
107
|
+
* `ctx.remote.agentPresets` needs `remote` as well.
|
|
75
108
|
*/
|
|
76
|
-
export const inject = ['slots', 'locale', 'sessions', '
|
|
109
|
+
export const inject = ['slots', 'locale', 'sessions', 'configForms', 'remote', 'remote.agentPresets']
|
|
77
110
|
|
|
78
111
|
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
79
112
|
interface LocaleNamespaceMap {
|
|
@@ -109,17 +142,22 @@ export function apply(ctx: ClientContext): void {
|
|
|
109
142
|
// view still renders and reports what it knows.
|
|
110
143
|
}
|
|
111
144
|
|
|
112
|
-
// Plugin configuration card: one staged form over the `
|
|
113
|
-
//
|
|
145
|
+
// Plugin configuration card: one staged form over the `liangshen` settings
|
|
146
|
+
// namespace, contributed to the Web UI plugin group beside the
|
|
114
147
|
// remote-access and task-board cards.
|
|
115
148
|
try {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
149
|
+
// The family binder resolves the family namespace onto this row's profile
|
|
150
|
+
// entry id and binds the native shared form; a deployment without the group
|
|
151
|
+
// plugin addresses the entry id directly (the standalone bundle row id).
|
|
152
|
+
const binder = ctx.get('webUiSettings')
|
|
153
|
+
const settingsForm = binder !== undefined && typeof binder.bind === 'function'
|
|
154
|
+
? binder.bind<LiangShenSettings>({ namespace: SETTINGS_NAMESPACE })
|
|
155
|
+
: ctx.configForms.get<LiangShenSettings>(servedEntryId(ctx.configForms))
|
|
156
|
+
const settingsCard = new LiangShenSettingsCardController(settingsForm)
|
|
157
|
+
// Card seat: the family group's list seat, or the official
|
|
158
|
+
// bundle-configuration seat when the group is not installed.
|
|
121
159
|
installPluginCard(ctx, {
|
|
122
|
-
|
|
160
|
+
bundle: '@linxin666/dsh-liangshen',
|
|
123
161
|
id: 'liangshen',
|
|
124
162
|
order: 120,
|
|
125
163
|
locale: NS,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* The view stays pure; every fact and verb comes from here. The roster arrives
|
|
5
5
|
* over the agent-preset Remote namespace (the same one the official surfaces
|
|
6
|
-
* read), the
|
|
6
|
+
* read), the main-view session comes from the catalog's ownership marker, and the
|
|
7
7
|
* switch goes through `agentPresets.select`, which the host accepts only while
|
|
8
8
|
* the session is still blank.
|
|
9
9
|
*
|
|
@@ -15,8 +15,9 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import type { Context as ClientContext } from '@deepseek-ai/cordis'
|
|
18
|
-
import type { AgentPresetRoster } from '@deepseek-ai/dsh-agent-
|
|
18
|
+
import type { AgentPresetRoster } from '@deepseek-ai/dsh-agent-preset-registry/types'
|
|
19
19
|
import type { ISessions } from '@deepseek-ai/dsh-api-session-controller/client'
|
|
20
|
+
import { mainViewSessionId } from './main-session.ts'
|
|
20
21
|
import type { RemoteResult } from '@deepseek-ai/dsh-api-remotes/client'
|
|
21
22
|
import { createSnapshotStore, type SnapshotStore } from '@deepseek-ai/dsh-client-store'
|
|
22
23
|
import { LIANGSHEN_PRESET_ID, isActionable, leverState, restoreTarget, type LeverFacts, type LeverState } from '../core/lever.ts'
|
|
@@ -43,6 +44,15 @@ export type LeverError =
|
|
|
43
44
|
/** How long one preset switch may stay in flight before it is reported as timed out. */
|
|
44
45
|
export const SELECT_TIMEOUT_MS = 10_000
|
|
45
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Settings entry ids whose writes can move the roster this lever reads: the
|
|
49
|
+
* agent-preset registry's own entry (its default and selection policy) and this
|
|
50
|
+
* plugin's row under either install shape — the aggregate's generated row id
|
|
51
|
+
* and the standalone row id — because disabling the plugin unregisters the
|
|
52
|
+
* preset it declares.
|
|
53
|
+
*/
|
|
54
|
+
export const ROSTER_SETTINGS_ENTRY_IDS: readonly string[] = ['agent-preset-registry', 'web-ui-liangshen', 'liangshen']
|
|
55
|
+
|
|
46
56
|
/** What the lever view renders. */
|
|
47
57
|
export interface LeverSnapshot {
|
|
48
58
|
/** Resolved lever state. */
|
|
@@ -142,7 +152,7 @@ export class LeverController {
|
|
|
142
152
|
)
|
|
143
153
|
if (typeof remote?.$on === 'function') {
|
|
144
154
|
this.disposers.push(remote.$on('settings/document-updated', (ns: string) => {
|
|
145
|
-
if (ns
|
|
155
|
+
if (ROSTER_SETTINGS_ENTRY_IDS.includes(ns)) void this.load()
|
|
146
156
|
}))
|
|
147
157
|
}
|
|
148
158
|
this.refresh()
|
|
@@ -239,34 +249,91 @@ export class LeverController {
|
|
|
239
249
|
}
|
|
240
250
|
// The switch landed: remember where to return, then celebrate only the
|
|
241
251
|
// pull that turned the mode on.
|
|
242
|
-
|
|
252
|
+
if (direction === 'down') {
|
|
253
|
+
const prev = facts.agentPreset ?? this.detectPreset()
|
|
254
|
+
if (prev !== undefined && prev !== LIANGSHEN_PRESET_ID) {
|
|
255
|
+
this.rememberPrevious(prev)
|
|
256
|
+
}
|
|
257
|
+
}
|
|
243
258
|
const next = this.store.getSnapshot()
|
|
244
259
|
this.store.set({ ...next, busy: false, error: undefined, burst: direction === 'down' ? next.burst + 1 : next.burst })
|
|
245
260
|
this.refresh()
|
|
246
261
|
}
|
|
247
262
|
|
|
263
|
+
/**
|
|
264
|
+
* Try to detect the active preset from the DOM hero chip or storage
|
|
265
|
+
* when session.projectionValues.agentPreset is absent.
|
|
266
|
+
*/
|
|
267
|
+
private detectPreset(): string | undefined {
|
|
268
|
+
try {
|
|
269
|
+
if (typeof document !== 'undefined') {
|
|
270
|
+
const chip = document.querySelector<HTMLElement>('button[aria-haspopup="menu"] span[class*="seatLabel"]')
|
|
271
|
+
?? Array.from(document.querySelectorAll<HTMLElement>('button[aria-haspopup="menu"] span')).find(s => s.className.includes('seatLabel'))
|
|
272
|
+
const text = chip?.textContent?.trim()
|
|
273
|
+
if (text) {
|
|
274
|
+
const matched = this.rows.find(row => (row.name === text || row.id === text) && row.id !== LIANGSHEN_PRESET_ID)
|
|
275
|
+
if (matched) return matched.id
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
} catch {
|
|
279
|
+
// Defensive
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
try {
|
|
283
|
+
if (typeof sessionStorage !== 'undefined') {
|
|
284
|
+
const stored = sessionStorage.getItem('dsh-liangshen:previous-preset')
|
|
285
|
+
if (stored && stored !== LIANGSHEN_PRESET_ID && this.rows.some(r => r.id === stored)) {
|
|
286
|
+
return stored
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
} catch {
|
|
290
|
+
// Defensive
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
return undefined
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
private rememberPrevious(presetId: string | undefined): void {
|
|
297
|
+
if (presetId === undefined || presetId === LIANGSHEN_PRESET_ID) return
|
|
298
|
+
this.previous = presetId
|
|
299
|
+
try {
|
|
300
|
+
if (typeof sessionStorage !== 'undefined') {
|
|
301
|
+
sessionStorage.setItem('dsh-liangshen:previous-preset', presetId)
|
|
302
|
+
}
|
|
303
|
+
} catch {
|
|
304
|
+
// Defensive
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
248
308
|
/** The facts one decision reads, from the live session and the roster. */
|
|
249
309
|
private facts(): LeverFacts {
|
|
250
310
|
const summary = this.currentSession()
|
|
251
311
|
const available = this.rows.filter(row => row.broken === undefined).map(row => row.id)
|
|
252
312
|
const fallback = this.rows.find(row => row.isDefault)?.id
|
|
313
|
+
const currentPreset = presetOf(summary)
|
|
314
|
+
|
|
315
|
+
if (currentPreset !== undefined && currentPreset !== LIANGSHEN_PRESET_ID) {
|
|
316
|
+
this.rememberPrevious(currentPreset)
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
const previous = this.previous ?? this.detectPreset()
|
|
320
|
+
|
|
253
321
|
return {
|
|
254
322
|
blank: summary?.blank === true,
|
|
255
|
-
agentPreset:
|
|
323
|
+
agentPreset: currentPreset,
|
|
256
324
|
available,
|
|
257
325
|
fallback,
|
|
258
|
-
previous
|
|
326
|
+
previous,
|
|
259
327
|
}
|
|
260
328
|
}
|
|
261
329
|
|
|
262
330
|
private currentSessionId(): string | undefined {
|
|
263
|
-
|
|
264
|
-
return current === undefined ? undefined : String(current)
|
|
331
|
+
return mainViewSessionId(this.sessions?.list.getSnapshot().byId)
|
|
265
332
|
}
|
|
266
333
|
|
|
267
334
|
private currentSession(): { blank?: boolean, projectionValues?: Record<string, unknown> } | undefined {
|
|
268
335
|
const state = this.sessions?.list.getSnapshot()
|
|
269
|
-
const current = state?.
|
|
336
|
+
const current = mainViewSessionId(state?.byId)
|
|
270
337
|
if (state === undefined || current === undefined) return undefined
|
|
271
338
|
return state.byId[current] as unknown as { blank?: boolean, projectionValues?: Record<string, unknown> } | undefined
|
|
272
339
|
}
|
package/src/client/locales.ts
CHANGED
|
@@ -24,11 +24,11 @@ export const zh = {
|
|
|
24
24
|
'settings.title': '梁神模式',
|
|
25
25
|
'settings.description': '控制本插件与工具面呈现方式。',
|
|
26
26
|
'settings.enabled': '启用梁神模式',
|
|
27
|
-
'settings.enabledHint': '
|
|
27
|
+
'settings.enabledHint': '关闭后不声明预设、也不发 agent 公告。',
|
|
28
28
|
'settings.announceToAgent': '向 agent 公告本插件',
|
|
29
29
|
'settings.announceToAgentHint': '开启后向每一轮 agent 系统提示注入本插件公告;默认关闭以保持提示词干净。',
|
|
30
30
|
'settings.presentation': '工具面呈现方式',
|
|
31
|
-
'settings.presentationHint': '
|
|
31
|
+
'settings.presentationHint': '写入本插件声明的预设的 tool-catalog 行:both(出厂默认)让原生清单与 run_code 同驻(原生直调优先);native 保持原生工具清单;ptc 把 wire 收拢为 run_code。改动立即生效,但已开始的会话保持其已声明的组合。',
|
|
32
32
|
'settings.on': '开',
|
|
33
33
|
'settings.off': '关',
|
|
34
34
|
'settings.inherit': '继承(跟随部署默认)',
|
|
@@ -47,6 +47,19 @@ export const zh = {
|
|
|
47
47
|
'presentation.ptc': 'ptc(仅 run_code)',
|
|
48
48
|
'presentation.native': 'native(原生工具清单)',
|
|
49
49
|
'presentation.both': 'both(两者同驻)',
|
|
50
|
+
'settings.guardEnabled': '启用退化熔断器',
|
|
51
|
+
'settings.guardEnabledHint': '运行时检测思考退化(连续零产出长思考 / 同参重复失败),触发时注入熔断提示并临时下调推理档位。关闭后不干预任何请求。',
|
|
52
|
+
'settings.guardStallChars': '单步暴走字符阈值',
|
|
53
|
+
'settings.guardStallCharsHint': '单条推理达到该字符数且零产出即触发熔断(按 V4.1 官方 384K 最大输出校准;默认 8000,约 2-4K 思考 token)。',
|
|
54
|
+
'settings.guardGlobalCap': '慢烧连续步数',
|
|
55
|
+
'settings.guardGlobalCapHint': '连续多少步有真实推理但零产出触发慢烧熔断(默认 4;步数越小越敏感,真实长调查建议调大)。',
|
|
56
|
+
'settings.guardSensitivity': '熔断灵敏度',
|
|
57
|
+
'settings.guardSensitivityHint': '整体缩放熔断阈值:保守(更少打断,阈值×1.5)、均衡(出厂校准值)、激进(更早触发,阈值×0.5)。阈值随推理档位自适应:max 档 8000 / high 档 12000 / low 档 20000 字符。',
|
|
58
|
+
'sensitivity.conservative': '保守(少打断)',
|
|
59
|
+
'sensitivity.balanced': '均衡(默认)',
|
|
60
|
+
'sensitivity.aggressive': '激进(早触发)',
|
|
61
|
+
'settings.guardEchoFailures': '同参连续失败次数',
|
|
62
|
+
'settings.guardEchoFailuresHint': '同一工具以相同参数连续失败多少次触发空转熔断(默认 3)。',
|
|
50
63
|
}
|
|
51
64
|
|
|
52
65
|
/** English counterpart; the key set mirrors {@link zh} exactly. */
|
|
@@ -69,11 +82,11 @@ export const en: Record<keyof typeof zh, string> = {
|
|
|
69
82
|
'settings.title': 'LiangShen mode',
|
|
70
83
|
'settings.description': 'Controls this plugin and the wire presentation.',
|
|
71
84
|
'settings.enabled': 'Enable LiangShen mode',
|
|
72
|
-
'settings.enabledHint': 'When off,
|
|
85
|
+
'settings.enabledHint': 'When off, the preset is not declared and the agent announcement does not run.',
|
|
73
86
|
'settings.announceToAgent': 'Announce this plugin to agents',
|
|
74
87
|
'settings.announceToAgentHint': 'Adds this plugin announcement to every agent system prompt; off by default so prompts stay clean.',
|
|
75
88
|
'settings.presentation': 'Wire presentation',
|
|
76
|
-
'settings.presentationHint': 'Written into the
|
|
89
|
+
'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.',
|
|
77
90
|
'settings.on': 'On',
|
|
78
91
|
'settings.off': 'Off',
|
|
79
92
|
'settings.inherit': 'Inherit (deployment default)',
|
|
@@ -92,6 +105,19 @@ export const en: Record<keyof typeof zh, string> = {
|
|
|
92
105
|
'presentation.ptc': 'ptc (run_code only)',
|
|
93
106
|
'presentation.native': 'native (native tool roster)',
|
|
94
107
|
'presentation.both': 'both (both co-resident)',
|
|
108
|
+
'settings.guardEnabled': 'Degeneration circuit breaker',
|
|
109
|
+
'settings.guardEnabledHint': 'Detects reasoning degeneration at runtime (consecutive zero-output long reasoning / repeated identical-argument failures), injecting a breaker message and stepping the reasoning effort down when it fires. Disabled means requests are never touched.',
|
|
110
|
+
'settings.guardStallChars': 'Runaway reasoning character floor',
|
|
111
|
+
'settings.guardStallCharsHint': 'One reasoning block reaching this many characters with no output fires the breaker (calibrated against V4.1\'s official 384K max output; default 8000, roughly 2-4K thinking tokens).',
|
|
112
|
+
'settings.guardGlobalCap': 'Slow-burn step count',
|
|
113
|
+
'settings.guardGlobalCapHint': 'Consecutive output-free steps of real reasoning that fire the slow-burn ladder (default 4; lower is more sensitive — raise it for genuinely long investigations).',
|
|
114
|
+
'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). Thresholds adapt to the reasoning effort: 8000 at max / 12000 at high / 20000 at low.',
|
|
116
|
+
'sensitivity.conservative': 'Conservative (fewer interruptions)',
|
|
117
|
+
'sensitivity.balanced': 'Balanced (default)',
|
|
118
|
+
'sensitivity.aggressive': 'Aggressive (fires earlier)',
|
|
119
|
+
'settings.guardEchoFailures': 'Identical-argument failures',
|
|
120
|
+
'settings.guardEchoFailuresHint': 'Identical-argument failures of the same tool in a row that fire the echo ladder (default 3).',
|
|
95
121
|
}
|
|
96
122
|
|
|
97
123
|
/** Every key in the locale catalog. */
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Generated by scripts/sync-shared.mjs from shared/client/main-session.ts. Do not edit this copy; edit the shared source and run "node scripts/sync-shared.mjs".
|
|
2
|
+
/**
|
|
3
|
+
* Main-view Session derivation for the multi-instance Client Session model.
|
|
4
|
+
*
|
|
5
|
+
* The Client Session Controller carries no global "current" selection: view
|
|
6
|
+
* selection belongs to the workspace UI, which owns the main-area reference and
|
|
7
|
+
* publishes it through the catalog's per-source ownership counts
|
|
8
|
+
* (`SessionSummary.retainedBy.mainView`). A plugin that needs the Session the
|
|
9
|
+
* main view shows derives it from that marker instead of the removed
|
|
10
|
+
* `SessionListState.current` field.
|
|
11
|
+
*
|
|
12
|
+
* The marker describes view ownership, not authority. It is the right input for
|
|
13
|
+
* presentation and for deciding which view a navigation targets; it is not a
|
|
14
|
+
* business fallback, because source counts never imply visibility or success.
|
|
15
|
+
* @module dsh-web/shared/main-session
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/** The catalog row subset this helper reads (a `SessionSummary` projection). */
|
|
19
|
+
export interface MainViewOwnedRow<Id extends string = string> {
|
|
20
|
+
/** Catalog row identity. */
|
|
21
|
+
readonly id: Id
|
|
22
|
+
/** Per-source local ownership counts; absent rows are never owned. */
|
|
23
|
+
readonly retainedBy?: Readonly<Partial<Record<string, number>>> | undefined
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Resolve the Session the main view currently shows.
|
|
28
|
+
*
|
|
29
|
+
* Reads the catalog's rows rather than a per-id retain-info source: ownership
|
|
30
|
+
* counts ride the list snapshot, so this neither allocates observers nor opens
|
|
31
|
+
* history, and a subscription to the list still fires when the selection moves.
|
|
32
|
+
* @param byId - the session catalog's rows (`SessionListState.byId`), when available.
|
|
33
|
+
* @returns the main-view session id, or undefined when the main view shows none.
|
|
34
|
+
*/
|
|
35
|
+
export function mainViewSessionId<Id extends string>(
|
|
36
|
+
byId: Readonly<Record<Id, MainViewOwnedRow<Id> | undefined>> | undefined | null,
|
|
37
|
+
): Id | undefined {
|
|
38
|
+
if (byId === undefined || byId === null) return undefined
|
|
39
|
+
for (const row of Object.values<MainViewOwnedRow<Id> | undefined>(byId)) {
|
|
40
|
+
if (row !== undefined && (row.retainedBy?.mainView ?? 0) > 0) return row.id
|
|
41
|
+
}
|
|
42
|
+
return undefined
|
|
43
|
+
}
|
|
@@ -7,22 +7,24 @@
|
|
|
7
7
|
*
|
|
8
8
|
* - `web-ui.plugin.item` — the list seat declared by the dsh-web-settings
|
|
9
9
|
* group section (this family's own first-level "Web UI plugins" section);
|
|
10
|
-
* - `
|
|
11
|
-
*
|
|
10
|
+
* - `plugins.bundle.config` — the official keyed seat of the harness's plugin
|
|
11
|
+
* manager page, keyed by the bundle's package name and rendered on that
|
|
12
|
+
* bundle's page. alpha.2 removed the `settings.plugin.item` keyed seat of the
|
|
13
|
+
* `ui-settings-plugins` tab that this helper used before, so a card keyed by
|
|
14
|
+
* its settings namespace has no seat to land in any more.
|
|
12
15
|
*
|
|
13
|
-
* SEAT SELECTION IS NOT A DECLARATION PROBE. The official
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* heading and zero cards.
|
|
16
|
+
* SEAT SELECTION IS NOT A DECLARATION PROBE. The official plugin surface
|
|
17
|
+
* belongs to the harness bundle and declares its seats before any external
|
|
18
|
+
* plugin's `apply()` runs, so "is the official seat declared?" answers yes even
|
|
19
|
+
* in the deployment whose whole point is the family group. Choosing on that
|
|
20
|
+
* probe sends every family card to the official page and leaves the group's own
|
|
21
|
+
* section permanently empty — the family of reports where the section renders
|
|
22
|
+
* its heading and zero cards.
|
|
21
23
|
*
|
|
22
24
|
* The signal that actually distinguishes the two deployments is whether
|
|
23
25
|
* dsh-web-settings is loaded: it is the package that owns the group section and
|
|
24
26
|
* it publishes the `webUiSettings` service during `apply()`, which every
|
|
25
|
-
* family plugin already reads for its settings
|
|
27
|
+
* family plugin already reads for its settings form. Group loaded -> the family
|
|
26
28
|
* seat; group absent -> the official seat.
|
|
27
29
|
*
|
|
28
30
|
* The decision is re-evaluated on every `slots/changed` because the group may
|
|
@@ -40,8 +42,8 @@
|
|
|
40
42
|
/** The family list seat key. */
|
|
41
43
|
export const FAMILY_PLUGIN_CARD_SEAT = 'web-ui.plugin.item'
|
|
42
44
|
|
|
43
|
-
/** The official keyed plugin-card seat key. */
|
|
44
|
-
export const OFFICIAL_PLUGIN_CARD_SEAT = '
|
|
45
|
+
/** The official keyed plugin-card seat key (the alpha.2 bundle-configuration seat). */
|
|
46
|
+
export const OFFICIAL_PLUGIN_CARD_SEAT = 'plugins.bundle.config'
|
|
45
47
|
|
|
46
48
|
/** The service dsh-web-settings publishes while it is loaded. */
|
|
47
49
|
export const FAMILY_GROUP_SERVICE = 'webUiSettings'
|
|
@@ -61,7 +63,7 @@ export interface PluginCardContext {
|
|
|
61
63
|
on?(event: string, listener: (...args: never[]) => void): unknown
|
|
62
64
|
}
|
|
63
65
|
|
|
64
|
-
/** Owner share of a
|
|
66
|
+
/** Owner share of a family list-seat card (that seat supplies nothing). */
|
|
65
67
|
export interface SettingsPluginItemOwnerProps {
|
|
66
68
|
/** Marker field: card owner props are intentionally empty. */
|
|
67
69
|
children?: never
|
|
@@ -69,8 +71,13 @@ export interface SettingsPluginItemOwnerProps {
|
|
|
69
71
|
|
|
70
72
|
/** One family plugin's card contribution. */
|
|
71
73
|
export interface PluginCardSeat {
|
|
72
|
-
/**
|
|
73
|
-
|
|
74
|
+
/**
|
|
75
|
+
* Npm package name of the bundle this card configures; the official keyed
|
|
76
|
+
* seat dispatches on it. Every family package ships its own bundle patch, so
|
|
77
|
+
* a standalone install lists that package as the bundle whose page renders
|
|
78
|
+
* this card.
|
|
79
|
+
*/
|
|
80
|
+
bundle: string
|
|
74
81
|
/** Family list-seat entry id. */
|
|
75
82
|
id: string
|
|
76
83
|
/** Family list-seat sort order. */
|
|
@@ -159,7 +166,7 @@ export function installPluginCard(ctx: PluginCardContext, seat: PluginCardSeat):
|
|
|
159
166
|
}
|
|
160
167
|
: {
|
|
161
168
|
name: OFFICIAL_PLUGIN_CARD_SEAT,
|
|
162
|
-
key: seat.
|
|
169
|
+
key: seat.bundle,
|
|
163
170
|
locale: seat.locale,
|
|
164
171
|
...(seat.inject === undefined ? {} : { inject }),
|
|
165
172
|
}) as never, component) as () => void
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* card-store pattern.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import type {
|
|
11
|
+
import type { ConfigForm, ConfigFormSnapshot } from '@deepseek-ai/dsh-client-ui-settings/client'
|
|
12
12
|
import type { SnapshotStore } from '@deepseek-ai/dsh-client-store'
|
|
13
13
|
import { createSnapshotStore } from '@deepseek-ai/dsh-client-store'
|
|
14
14
|
|
|
@@ -114,7 +114,7 @@ interface PlannedWrite {
|
|
|
114
114
|
judge: (() => boolean) | undefined
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
/** One durable write inside the save's atomic
|
|
117
|
+
/** One durable write inside the save's atomic form mutation. */
|
|
118
118
|
export interface BatchedWrite {
|
|
119
119
|
/** Field this entry writes. */
|
|
120
120
|
field: string
|
|
@@ -211,34 +211,34 @@ export class CardForm<T> {
|
|
|
211
211
|
private readonly specs: Map<string, FieldSpec>
|
|
212
212
|
private readonly staged = new Map<string, StagedEdit>()
|
|
213
213
|
private readonly listeners = new Set<() => void>()
|
|
214
|
-
/** The
|
|
215
|
-
private readonly
|
|
214
|
+
/** The form subscription installed in the constructor; released by dispose(). */
|
|
215
|
+
private readonly disposeForm: () => void
|
|
216
216
|
private disposed = false
|
|
217
217
|
private saving = false
|
|
218
218
|
private failed = false
|
|
219
219
|
private failedReason: string | undefined
|
|
220
220
|
|
|
221
|
-
/** @param scope - the bound
|
|
221
|
+
/** @param scope - the bound configuration form for this card's namespace. */
|
|
222
222
|
constructor(
|
|
223
|
-
private readonly scope:
|
|
223
|
+
private readonly scope: ConfigForm<T>,
|
|
224
224
|
specs: FieldSpec[],
|
|
225
225
|
) {
|
|
226
226
|
this.specs = new Map(specs.map(spec => [spec.field, spec]))
|
|
227
|
-
this.
|
|
227
|
+
this.disposeForm = scope.subscribe(() => { this.publish() })
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
/**
|
|
231
|
-
* Release the
|
|
231
|
+
* Release the form subscription and every bound store listener. The card
|
|
232
232
|
* must call this on teardown; later calls are no-ops.
|
|
233
233
|
*/
|
|
234
234
|
dispose(): void {
|
|
235
235
|
if (this.disposed) return
|
|
236
236
|
this.disposed = true
|
|
237
|
-
this.
|
|
237
|
+
this.disposeForm()
|
|
238
238
|
this.listeners.clear()
|
|
239
239
|
}
|
|
240
240
|
|
|
241
|
-
/** Publish a projection of this form, rebuilt whenever the
|
|
241
|
+
/** Publish a projection of this form, rebuilt whenever the form or a draft changes. */
|
|
242
242
|
bind<S>(project: () => S): SnapshotStore<S> {
|
|
243
243
|
const store = createSnapshotStore(project())
|
|
244
244
|
this.listeners.add(() => { store.set(project()) })
|
|
@@ -295,19 +295,19 @@ export class CardForm<T> {
|
|
|
295
295
|
}
|
|
296
296
|
|
|
297
297
|
/**
|
|
298
|
-
* Write every staged edit in one atomic
|
|
298
|
+
* Write every staged edit in one atomic form mutation, then re-seed from
|
|
299
299
|
* what the Host accepted.
|
|
300
300
|
*
|
|
301
301
|
* The whole batch rides one mutate, so cross-field validate hooks
|
|
302
302
|
* (baseURL+model) judge it as a unit: the Host either applies every write
|
|
303
|
-
* or refuses the batch. The
|
|
304
|
-
*
|
|
305
|
-
*
|
|
306
|
-
* settled snapshot back
|
|
307
|
-
* fails the whole save. A
|
|
308
|
-
*
|
|
309
|
-
* message. A save that did not land keeps its drafts, so
|
|
310
|
-
* correct them instead of retyping.
|
|
303
|
+
* or refuses the batch. The form contract answers a refusal or a skipped
|
|
304
|
+
* write with `false` (it recovers with a fresh Host view instead of
|
|
305
|
+
* throwing), so the outcome is judged twice: the answer itself, and then the
|
|
306
|
+
* settled snapshot read back one planned write at a time. One missed write
|
|
307
|
+
* fails the whole save. A transport that rejects instead (the dsh-web bridge
|
|
308
|
+
* controller on a dead connection) reports through the same failure path
|
|
309
|
+
* with its rejection message. A save that did not land keeps its drafts, so
|
|
310
|
+
* the user can correct them instead of retyping.
|
|
311
311
|
* @returns settlement after the mutation and the read-back.
|
|
312
312
|
*/
|
|
313
313
|
async save(): Promise<void> {
|
|
@@ -323,30 +323,33 @@ export class CardForm<T> {
|
|
|
323
323
|
this.failed = false
|
|
324
324
|
this.failedReason = undefined
|
|
325
325
|
this.publish()
|
|
326
|
-
// One atomic namespace mutation: the
|
|
327
|
-
//
|
|
326
|
+
// One atomic namespace mutation: the form contract takes ordered path
|
|
327
|
+
// operations, so the whole staged batch is validated, persisted, and
|
|
328
328
|
// recovered together — either every write lands or none does.
|
|
329
329
|
const ops: Array<{ op: 'set'; path: string[]; value: string | number | boolean } | { op: 'unset'; path: string[] }> = valid.map(item => item.op.op === 'set'
|
|
330
330
|
? { op: 'set', path: [item.field], value: (item.op as { value: string | number | boolean }).value }
|
|
331
331
|
: { op: 'unset', path: [item.field] })
|
|
332
332
|
let failedReason: string | undefined
|
|
333
|
+
let accepted = false
|
|
333
334
|
try {
|
|
334
|
-
await this.scope.mutate(ops)
|
|
335
|
+
accepted = await this.scope.mutate(ops)
|
|
335
336
|
} catch (error) {
|
|
336
337
|
failedReason = error instanceof Error ? error.message : String(error)
|
|
337
338
|
}
|
|
338
|
-
//
|
|
339
|
-
//
|
|
340
|
-
// judge every planned write against the settled
|
|
341
|
-
// atomic, so one missed write fails the
|
|
342
|
-
|
|
339
|
+
// `false` is the contract's refusal/skip answer, and the form still
|
|
340
|
+
// resolves after a refusal (it recovers with a fresh view), so the answer
|
|
341
|
+
// alone is not enough: judge every planned write against the settled
|
|
342
|
+
// snapshot as well. The mutation is atomic, so one missed write fails the
|
|
343
|
+
// whole save and keeps the drafts.
|
|
344
|
+
const landed = accepted && failedReason === undefined && valid.every(item => item.judge())
|
|
343
345
|
for (const [field, before] of pending) {
|
|
344
346
|
if (landed && this.staged.get(field) === before) this.staged.delete(field)
|
|
345
347
|
}
|
|
346
348
|
this.saving = false
|
|
347
349
|
this.failed = !landed
|
|
348
|
-
// A
|
|
349
|
-
// generic failure copy; a rejecting
|
|
350
|
+
// A refused or unlanded batch carries no server reason: the card surfaces
|
|
351
|
+
// its generic failure copy; a rejecting transport (the bridge) adds its
|
|
352
|
+
// message.
|
|
350
353
|
this.failedReason = failedReason
|
|
351
354
|
this.publish()
|
|
352
355
|
}
|
|
@@ -381,7 +384,7 @@ export class CardForm<T> {
|
|
|
381
384
|
*/
|
|
382
385
|
private landedSet(field: string, value: unknown): boolean {
|
|
383
386
|
// A redacted secret never appears in any wire view layer: the Host strips
|
|
384
|
-
// role('secret') fields and reports them through a sidecar the
|
|
387
|
+
// role('secret') fields and reports them through a sidecar the form
|
|
385
388
|
// snapshot does not expose, so there is nothing to compare the draft
|
|
386
389
|
// against. Settling is the only signal the form has; the rest of the
|
|
387
390
|
// batch, when one exists, still carries the atomic verdict by read-back.
|
|
@@ -412,7 +415,7 @@ export class CardForm<T> {
|
|
|
412
415
|
return spec
|
|
413
416
|
}
|
|
414
417
|
|
|
415
|
-
private snapshotOf():
|
|
418
|
+
private snapshotOf(): ConfigFormSnapshot<T> {
|
|
416
419
|
return this.scope.getSnapshot()
|
|
417
420
|
}
|
|
418
421
|
|