@linxin666/dsh-liangshen 0.4.5 → 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/lib/index.js CHANGED
@@ -399,22 +399,27 @@ function readPresetDefinition(id, dir) {
399
399
  }
400
400
  /** The overlay table: settings field to composition row and config key. */
401
401
  function overrideTargets(overrides) {
402
- return [["tool-catalog", { ...overrides.presentation === void 0 ? {} : { presentation: overrides.presentation } }], ["guard", {
403
- ...overrides.guardEnabled === void 0 ? {} : { enabled: overrides.guardEnabled },
404
- ...overrides.guardSensitivity === void 0 ? {} : { sensitivity: overrides.guardSensitivity },
405
- ...overrides.guardStallReasoningChars === void 0 ? {} : { stallReasoningChars: overrides.guardStallReasoningChars },
406
- ...overrides.guardGlobalStallCap === void 0 ? {} : { globalStallCap: overrides.guardGlobalStallCap },
407
- ...overrides.guardEchoFailures === void 0 ? {} : { echoFailures: overrides.guardEchoFailures }
408
- }]];
402
+ return [
403
+ ["tool-catalog", { ...overrides.presentation === void 0 ? {} : { presentation: overrides.presentation } }],
404
+ ["minimal-prompt", { ...overrides.dispatcher === void 0 ? {} : { dispatcher: overrides.dispatcher } }],
405
+ ["guard", {
406
+ ...overrides.guardEnabled === void 0 ? {} : { enabled: overrides.guardEnabled },
407
+ ...overrides.guardSensitivity === void 0 ? {} : { sensitivity: overrides.guardSensitivity },
408
+ ...overrides.guardStallReasoningChars === void 0 ? {} : { stallReasoningChars: overrides.guardStallReasoningChars },
409
+ ...overrides.guardGlobalStallCap === void 0 ? {} : { globalStallCap: overrides.guardGlobalStallCap },
410
+ ...overrides.guardEchoFailures === void 0 ? {} : { echoFailures: overrides.guardEchoFailures }
411
+ }]
412
+ ];
409
413
  }
410
414
  /**
411
415
  * Apply the settings overlay to one parsed row list.
412
416
  *
413
417
  * Rows are addressed by their `id`, and only a row the composition actually
414
418
  * carries is touched: the overlay narrows the shipped configuration, it never
415
- * invents a mount the preset did not have. The shipped composition declares
416
- * every key the overlay writes, so leaving a key absent only matters for a
417
- * composition that dropped it.
419
+ * invents a mount the preset did not have. A field the settings surface left
420
+ * unset is written as no key at all rather than as a value, which is what keeps
421
+ * the guard's effort-adaptive thresholds the shipped behavior: the overlay only
422
+ * ever adds an override on top of them.
418
423
  * @param rows - the parsed composition rows.
419
424
  * @param overrides - the operator's settings-surface choices.
420
425
  * @returns a new row list with the overlay applied.
@@ -633,28 +638,36 @@ const Config = z.object({
633
638
  enabled: z.boolean().default(true).volatile(),
634
639
  announceToAgent: z.boolean().default(false).volatile(),
635
640
  presentation: z.union([...PRESENTATION_OPTIONS]).default("both").volatile(),
641
+ dispatcher: z.boolean().default(true).volatile(),
636
642
  guardEnabled: z.boolean().default(true).volatile(),
637
643
  guardSensitivity: z.union([...SENSITIVITY_OPTIONS]).default("balanced").volatile(),
638
- guardStallReasoningChars: z.number().default(8e3).volatile(),
639
- guardGlobalStallCap: z.number().default(4).volatile(),
640
- guardEchoFailures: z.number().default(3).volatile()
644
+ guardStallReasoningChars: z.number().volatile(),
645
+ guardGlobalStallCap: z.number().volatile(),
646
+ guardEchoFailures: z.number().volatile()
641
647
  });
642
- /** Schema defaults, re-read for hand-built test contexts. */
648
+ /**
649
+ * Schema defaults, re-read for hand-built test contexts. The three guard
650
+ * fine-tuning fields default to undefined — "unset" IS the shipped default,
651
+ * and the guard resolves the effective thresholds per request from the
652
+ * session's reasoning effort and the sensitivity preset.
653
+ */
643
654
  const DEFAULT_CONFIG = {
644
655
  enabled: true,
645
656
  announceToAgent: false,
646
657
  presentation: "both",
658
+ dispatcher: true,
647
659
  guardEnabled: true,
648
660
  guardSensitivity: "balanced",
649
- guardStallReasoningChars: 8e3,
650
- guardGlobalStallCap: 4,
651
- guardEchoFailures: 3
661
+ guardStallReasoningChars: void 0,
662
+ guardGlobalStallCap: void 0,
663
+ guardEchoFailures: void 0
652
664
  };
653
665
  /**
654
666
  * Read one activation field. The Host validates the raw profile config and
655
667
  * hands volatile fields over as references, so a read goes through `get()`; a
656
668
  * plain value passes through, and an absent field falls back to the schema
657
- * default.
669
+ * default — which is `undefined` for the three guard fine-tuning overrides,
670
+ * so "unset" survives as a real value instead of collapsing into a constant.
658
671
  */
659
672
  function readField(field, fallback) {
660
673
  if (field === void 0 || field === null) return fallback;
@@ -672,6 +685,7 @@ function resolveConfig(config) {
672
685
  enabled: readField(config?.enabled, DEFAULT_CONFIG.enabled),
673
686
  announceToAgent: readField(config?.announceToAgent, DEFAULT_CONFIG.announceToAgent),
674
687
  presentation: readField(config?.presentation, DEFAULT_CONFIG.presentation),
688
+ dispatcher: readField(config?.dispatcher, DEFAULT_CONFIG.dispatcher),
675
689
  guardEnabled: readField(config?.guardEnabled, DEFAULT_CONFIG.guardEnabled),
676
690
  guardSensitivity: readField(config?.guardSensitivity, DEFAULT_CONFIG.guardSensitivity),
677
691
  guardStallReasoningChars: readField(config?.guardStallReasoningChars, DEFAULT_CONFIG.guardStallReasoningChars),
@@ -680,7 +694,7 @@ function resolveConfig(config) {
680
694
  };
681
695
  }
682
696
  /** Model-facing announcement: plugin presence, principle, and limits. */
683
- const LIANGSHEN_GUIDANCE = "本机已安装 dsh-liangshen 插件(梁神模式 agent preset):新建会话的预设选择器中可选「梁神模式」。原理:系统提示词保持极简 persona(minimal-prompt 放行该段与 plan 模式的 plan:policy),persona 内置本模式工作纪律(反思熔断——同一假设推演不超过两轮、缺事实立即闭合思考并调用原生检测工具;行动导向——思考只决定下一步具体操作、不在思考中预演代码实现;并发探索——多处独立检查或搜索在单轮内并发发射多个工具调用;YAGNI/PDCA——单步验证单一假设、不写冗余注释;有界收敛——不无限下钻依赖链、前置检查最多2-3轮后立即收敛并作答或编辑),并在组装时追加工作区目录行 Your working directory is <cwd>.。AGENTS.md 工作区指令默认交还宿主自身的 agent-instructions 行,以 user 角色注入,本插件不追加任何系统提示词段、也不改动 pre-step 的消息批次;可选 instructionSource: system-prompt 才由本插件在组装时读取 AGENTS.md 链并追加 workspace-instructions 段(65536 字节预算,每次组装重读)。wire 呈现由 tool-catalog 按会话一次声明,取值 'both'(默认:原生清单与 run_code 同驻,原生直调优先、run_code 用于程序化批处理与并发扇出)、'native'(组装出的原生清单)或 'ptc'(wire 收拢为唯一的 run_code),并可在插件设置界面切换(写入所声明预设的 tool-catalog 行);未挂载 code runtime 时不做声明,会话运行原生工具面。温和工具分页出厂开启(pagedToolPatterns 默认 ['mcp__*']):匹配工具在激活前被作用域级工具限制移出可见面(既不在 wire,也不在生成的 SDK 声明中),目录消息列出常驻工具签名与未激活命名空间摘要,调用 tool_activate({ namespace }) 按需激活(LRU 上限 3 个活跃命名空间,驱逐最久未用);激活状态从持久会话事件流重建,resume/压缩后自然恢复。运行时退化熔断器(guard)从事件流折叠停摆(连续零产出长思考)与空转(同参重复失败)信号,每 episode 触发一次:注入熔断消息并把推理档位临时下调一档(max→high→low,窗口 3 个请求);无信号时从不改写请求。关键事实登记簿(fact_register)让模型把硬约束/已确认决策/失败路径登记为单行事实,随 working-context 行每步投射进局部注意力窗口。working-context 插件在 pre-step 注入单行 [Working Context: ...] 就近状态投射(plan 模式、活跃命名空间、进行中 todo、登记事实,全部从事件流折叠,读不到则省略,全部为空则不注入)。历史工具结果修剪为 4096 字符阈值(head 2048 / tail 1024)。文件操作受宿主沙箱约束;shell 在每个平台都挂上游标准 Stdio 栈(POSIX 为 bash,Windows 为 pwsh),带简短描述标题卡片与确定性退出码。真实推理探针通过不等于模式集成通过,更不等于统计效果提升。预设由插件在激活时向 agent-preset registry 直接注册(不写任何预设目录),插件停用即注销;默认预设由用户自行选择。用户提到「梁神模式 / 锚定模式 / anchored standard」时即指本插件,请据此协作。";
697
+ const LIANGSHEN_GUIDANCE = "本机已安装 dsh-liangshen 插件(梁神模式 agent preset):新建会话的预设选择器中可选「梁神模式」。原理:系统提示词保持极简 persona(minimal-prompt 放行该段与 plan 模式的 plan:policy),persona 内置本模式工作纪律(反思熔断——同一假设推演不超过两轮、缺事实立即闭合思考并调用原生检测工具;行动导向——思考只决定下一步具体操作、不在思考中预演代码实现;并发探索——多处独立检查或搜索在单轮内并发发射多个工具调用;YAGNI/PDCA——单步验证单一假设、不写冗余注释;有界收敛——不无限下钻依赖链、前置检查最多2-3轮后立即收敛并作答或编辑),并在组装时追加工作区目录行 Your working directory is <cwd>.。AGENTS.md 工作区指令默认交还宿主自身的 agent-instructions 行,以 user 角色注入,本插件不追加任何系统提示词段、也不改动 pre-step 的消息批次;可选 instructionSource: system-prompt 才由本插件在组装时读取 AGENTS.md 链并追加 workspace-instructions 段(65536 字节预算,每次组装重读)。wire 呈现由 tool-catalog 按会话一次声明,取值 'both'(默认:原生清单与 run_code 同驻,原生直调优先、run_code 用于程序化批处理与并发扇出)、'native'(组装出的原生清单)或 'ptc'(wire 收拢为唯一的 run_code),并可在插件设置界面切换(写入所声明预设的 tool-catalog 行);未挂载 code runtime 时不做声明,会话运行原生工具面。温和工具分页出厂开启(pagedToolPatterns 默认 ['mcp__*']):匹配工具在激活前被作用域级工具限制移出可见面(既不在 wire,也不在生成的 SDK 声明中),目录消息列出常驻工具签名与未激活命名空间摘要,调用 tool_activate({ namespace }) 按需激活(LRU 上限 3 个活跃命名空间,驱逐最久未用);激活状态从持久会话事件流重建,resume/压缩后自然恢复。运行时退化熔断器(guard)从事件流折叠停摆(连续零产出长思考)与空转(同参重复失败)信号,每 episode 触发一次:注入熔断消息;仅停摆信号(成因是推理预算过剩)额外把推理档位临时下调一档(max→high,窗口 3 个请求,high 档本身处于甜区不动),空转信号只注入消息。阈值随会话推理档位自适应(max 8000 / high 12000 / low 20000 字符)并再按灵敏度预设缩放;provider 不持久化推理文本的会话降级为连续零产出步骤计数。无信号时从不改写请求。关键事实登记簿(fact_register)让模型把硬约束/已确认决策/失败路径登记为单行事实,随 working-context 行每步投射进局部注意力窗口。working-context 插件在 pre-step 注入单行 [Working Context: ...] 就近状态投射(plan 模式、活跃命名空间、进行中 todo、登记事实,全部从事件流折叠,读不到则省略,全部为空则不注入)。历史工具结果修剪为 4096 字符阈值(head 2048 / tail 1024)。文件操作受宿主沙箱约束;shell 在每个平台都挂上游标准 Stdio 栈(POSIX 为 bash,Windows 为 pwsh),带简短描述标题卡片与确定性退出码。真实推理探针通过不等于模式集成通过,更不等于统计效果提升。预设由插件在激活时向 agent-preset registry 直接注册(不写任何预设目录),插件停用即注销;默认预设由用户自行选择。用户提到「梁神模式 / 锚定模式 / anchored standard」时即指本插件,请据此协作。";
684
698
  /** Order of the announcement section within the tool-guidance band. */
685
699
  const SECTION_ORDER = 150;
686
700
  /**
@@ -0,0 +1,13 @@
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
+ import type { ReactElement } from 'react';
9
+ /**
10
+ * Render the LiangShen card mark.
11
+ * @returns the 18x18 lever mark, in the current text color.
12
+ */
13
+ export declare function LiangShenMark(): ReactElement;
@@ -1,12 +1,13 @@
1
1
  /**
2
- * LiangShen settings card: availability and the wire presentation. Registers
3
- * into the `web-ui.plugin.item` child slot the Web UI plugin group renders,
4
- * bound to the `liangshen` settings namespace (the Host profile entry id).
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
- * The presentation field does not act on this client half: the Host applies it
7
- * to the preset it declares to the agent-preset registry, so a session reads it
8
- * from its preset. This card is the operator's only handle on it, which is why
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
  import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
12
13
  import type { SnapshotStore } from '@deepseek-ai/dsh-client-store';
@@ -24,6 +25,8 @@ export interface LiangShenSettings {
24
25
  announceToAgent?: boolean;
25
26
  /** Wire presentation the Host applies to the preset's tool-catalog row. */
26
27
  presentation?: string;
28
+ /** Whether the preset appends the dispatcher rules section after the persona. */
29
+ dispatcher?: boolean;
27
30
  /** Master switch for the runtime degeneration circuit breaker. */
28
31
  guardEnabled?: boolean;
29
32
  /** Sensitivity preset scaling the breaker's adaptive thresholds. */
@@ -40,6 +43,7 @@ export interface LiangShenSettingsCardState extends CardShell {
40
43
  enabled: CardFieldState;
41
44
  announceToAgent: CardFieldState;
42
45
  presentation: CardFieldState;
46
+ dispatcher: CardFieldState;
43
47
  guardEnabled: CardFieldState;
44
48
  guardSensitivity: CardFieldState;
45
49
  guardStallReasoningChars: CardFieldState;
@@ -28,6 +28,8 @@ export declare const zh: {
28
28
  'settings.announceToAgentHint': string;
29
29
  'settings.presentation': string;
30
30
  'settings.presentationHint': string;
31
+ 'settings.dispatcher': string;
32
+ 'settings.dispatcherHint': string;
31
33
  'settings.on': string;
32
34
  'settings.off': string;
33
35
  'settings.inherit': string;
@@ -59,6 +61,7 @@ export declare const zh: {
59
61
  'sensitivity.aggressive': string;
60
62
  'settings.guardEchoFailures': string;
61
63
  'settings.guardEchoFailuresHint': string;
64
+ 'settings.guardAdaptive': string;
62
65
  };
63
66
  /** English counterpart; the key set mirrors {@link zh} exactly. */
64
67
  export declare const en: Record<keyof typeof zh, string>;
@@ -78,6 +78,11 @@ export interface PluginCardSeat {
78
78
  label?: () => string;
79
79
  /** Locale namespace the card renders with. */
80
80
  locale: string;
81
+ /**
82
+ * Child slots this card declares and renders. Forwarded to whichever seat
83
+ * the host renders; absent for a card that declares none.
84
+ */
85
+ children?: Record<string, unknown>;
81
86
  /** Business-face factory of the registration. */
82
87
  inject?: () => object;
83
88
  /**
@@ -84,31 +84,35 @@ export declare function readPresetDefinition(id: string, dir: string): PresetDef
84
84
  *
85
85
  * The settings surface edits the PLUGIN's own Config, while the values that
86
86
  * shape a session live in the declared preset's rows; applying them here is what
87
- * connects the two. Every field is optional — an absent value leaves the shipped
88
- * row exactly as the composition declares it.
87
+ * connects the two. Every field is optional, and an absent OR `undefined` value
88
+ * writes nothing at all — the key stays out of the row and the guard's own
89
+ * adaptive resolution decides the effective threshold.
89
90
  */
90
91
  export interface PresetOverrides {
91
92
  /** The `tool-catalog` row's `presentation` value. */
92
93
  presentation?: string;
94
+ /** The `minimal-prompt` row's `dispatcher` switch. */
95
+ dispatcher?: boolean;
93
96
  /** The `guard` row's `enabled` switch. */
94
97
  guardEnabled?: boolean;
95
98
  /** The `guard` row's sensitivity preset. */
96
99
  guardSensitivity?: string;
97
- /** The `guard` row's per-step reasoning-character floor. */
98
- guardStallReasoningChars?: number;
99
- /** The `guard` row's slow-burn step cap. */
100
- guardGlobalStallCap?: number;
101
- /** The `guard` row's identical-argument failure count. */
102
- guardEchoFailures?: number;
100
+ /** The `guard` row's per-step reasoning-character floor override. */
101
+ guardStallReasoningChars?: number | undefined;
102
+ /** The `guard` row's slow-burn step cap override. */
103
+ guardGlobalStallCap?: number | undefined;
104
+ /** The `guard` row's identical-argument failure count override. */
105
+ guardEchoFailures?: number | undefined;
103
106
  }
104
107
  /**
105
108
  * Apply the settings overlay to one parsed row list.
106
109
  *
107
110
  * Rows are addressed by their `id`, and only a row the composition actually
108
111
  * carries is touched: the overlay narrows the shipped configuration, it never
109
- * invents a mount the preset did not have. The shipped composition declares
110
- * every key the overlay writes, so leaving a key absent only matters for a
111
- * composition that dropped it.
112
+ * invents a mount the preset did not have. A field the settings surface left
113
+ * unset is written as no key at all rather than as a value, which is what keeps
114
+ * the guard's effort-adaptive thresholds the shipped behavior: the overlay only
115
+ * ever adds an override on top of them.
112
116
  * @param rows - the parsed composition rows.
113
117
  * @param overrides - the operator's settings-surface choices.
114
118
  * @returns a new row list with the overlay applied.
@@ -82,6 +82,15 @@ export interface Config {
82
82
  * the transport.
83
83
  */
84
84
  presentation?: ConfigField<Presentation>;
85
+ /**
86
+ * When true, the preset appends the dispatcher rule block to its persona:
87
+ * the session becomes a dispatch agent whose deliverable is the plan, the
88
+ * task book, the review verdict, and the hand-off, on top of the mode's own
89
+ * working discipline. Orthogonal to `presentation` — the tool wire is the
90
+ * same either way. Default true: the shipped preset runs as a dispatcher,
91
+ * and the switch is what returns a session to the bare persona.
92
+ */
93
+ dispatcher?: ConfigField<boolean>;
85
94
  /** Master switch for the runtime degeneration circuit breaker (default true). */
86
95
  guardEnabled?: ConfigField<boolean>;
87
96
  /**
@@ -90,36 +99,42 @@ export interface Config {
90
99
  */
91
100
  guardSensitivity?: ConfigField<GuardSensitivity>;
92
101
  /**
93
- * Reasoning characters one zero-output step must reach for the per-step
94
- * ladder to fire (default 8000, calibrated against V4.1's 384K max output).
102
+ * Override for the per-step runaway-reasoning character floor. Left unset,
103
+ * the floor adapts to the session's reasoning effort and is then scaled by
104
+ * `guardSensitivity`; setting it wins over both for every effort level.
105
+ */
106
+ guardStallReasoningChars?: ConfigField<number | undefined>;
107
+ /**
108
+ * Override for the slow-burn step count. Left unset, the cap scales with
109
+ * `guardSensitivity`.
95
110
  */
96
- guardStallReasoningChars?: ConfigField<number>;
111
+ guardGlobalStallCap?: ConfigField<number | undefined>;
97
112
  /**
98
- * Consecutive output-free reasoning steps that trip the slow-burn ladder
99
- * (default 4).
113
+ * Override for the echo ladder. Left unset, the count scales with
114
+ * `guardSensitivity`.
100
115
  */
101
- guardGlobalStallCap?: ConfigField<number>;
102
- /** Identical-argument tool failures in a row that trip the echo ladder (default 3). */
103
- guardEchoFailures?: ConfigField<number>;
116
+ guardEchoFailures?: ConfigField<number | undefined>;
104
117
  }
105
118
  export declare const Config: z<Schemastery.ObjectS<NoInfer<{
106
119
  enabled: z<boolean, boolean, "volatile-defined">;
107
120
  announceToAgent: z<boolean, boolean, "volatile-defined">;
108
121
  presentation: z<"ptc" | "native" | "both", "ptc" | "native" | "both", "volatile-defined">;
122
+ dispatcher: z<boolean, boolean, "volatile-defined">;
109
123
  guardEnabled: z<boolean, boolean, "volatile-defined">;
110
124
  guardSensitivity: z<"conservative" | "balanced" | "aggressive", "conservative" | "balanced" | "aggressive", "volatile-defined">;
111
- guardStallReasoningChars: z<number, number, "volatile-defined">;
112
- guardGlobalStallCap: z<number, number, "volatile-defined">;
113
- guardEchoFailures: z<number, number, "volatile-defined">;
125
+ guardStallReasoningChars: z<number, number, "volatile">;
126
+ guardGlobalStallCap: z<number, number, "volatile">;
127
+ guardEchoFailures: z<number, number, "volatile">;
114
128
  }>>, Schemastery.ObjectT<NoInfer<{
115
129
  enabled: z<boolean, boolean, "volatile-defined">;
116
130
  announceToAgent: z<boolean, boolean, "volatile-defined">;
117
131
  presentation: z<"ptc" | "native" | "both", "ptc" | "native" | "both", "volatile-defined">;
132
+ dispatcher: z<boolean, boolean, "volatile-defined">;
118
133
  guardEnabled: z<boolean, boolean, "volatile-defined">;
119
134
  guardSensitivity: z<"conservative" | "balanced" | "aggressive", "conservative" | "balanced" | "aggressive", "volatile-defined">;
120
- guardStallReasoningChars: z<number, number, "volatile-defined">;
121
- guardGlobalStallCap: z<number, number, "volatile-defined">;
122
- guardEchoFailures: z<number, number, "volatile-defined">;
135
+ guardStallReasoningChars: z<number, number, "volatile">;
136
+ guardGlobalStallCap: z<number, number, "volatile">;
137
+ guardEchoFailures: z<number, number, "volatile">;
123
138
  }>>, "plain">;
124
139
  /** The settings the runtime acts on, every field read at its use site. */
125
140
  export interface ResolvedConfig {
@@ -129,18 +144,25 @@ export interface ResolvedConfig {
129
144
  announceToAgent: boolean;
130
145
  /** Wire presentation the declared preset's tool-catalog row carries. */
131
146
  presentation: Presentation;
147
+ /** Whether the declared preset's minimal-prompt row appends the dispatcher rule block. */
148
+ dispatcher: boolean;
132
149
  /** Breaker master switch written into the declared preset's guard row. */
133
150
  guardEnabled: boolean;
134
151
  /** Breaker sensitivity written into the declared preset's guard row. */
135
152
  guardSensitivity: GuardSensitivity;
136
- /** Per-step reasoning-character floor written into the guard row. */
137
- guardStallReasoningChars: number;
138
- /** Slow-burn step cap written into the guard row. */
139
- guardGlobalStallCap: number;
140
- /** Echo-ladder failure count written into the guard row. */
141
- guardEchoFailures: number;
153
+ /** Per-step reasoning-character floor written into the guard row, or undefined to leave the adaptive table in charge. */
154
+ guardStallReasoningChars: number | undefined;
155
+ /** Slow-burn step cap written into the guard row, or undefined to leave the sensitivity preset in charge. */
156
+ guardGlobalStallCap: number | undefined;
157
+ /** Echo-ladder failure count written into the guard row, or undefined to leave the sensitivity preset in charge. */
158
+ guardEchoFailures: number | undefined;
142
159
  }
143
- /** Schema defaults, re-read for hand-built test contexts. */
160
+ /**
161
+ * Schema defaults, re-read for hand-built test contexts. The three guard
162
+ * fine-tuning fields default to undefined — "unset" IS the shipped default,
163
+ * and the guard resolves the effective thresholds per request from the
164
+ * session's reasoning effort and the sensitivity preset.
165
+ */
144
166
  export declare const DEFAULT_CONFIG: ResolvedConfig;
145
167
  /**
146
168
  * Read the effective settings of this activation.
@@ -149,7 +171,7 @@ export declare const DEFAULT_CONFIG: ResolvedConfig;
149
171
  */
150
172
  export declare function resolveConfig(config?: Config): ResolvedConfig;
151
173
  /** Model-facing announcement: plugin presence, principle, and limits. */
152
- export declare const LIANGSHEN_GUIDANCE = "\u672C\u673A\u5DF2\u5B89\u88C5 dsh-liangshen \u63D2\u4EF6\uFF08\u6881\u795E\u6A21\u5F0F agent preset\uFF09\uFF1A\u65B0\u5EFA\u4F1A\u8BDD\u7684\u9884\u8BBE\u9009\u62E9\u5668\u4E2D\u53EF\u9009\u300C\u6881\u795E\u6A21\u5F0F\u300D\u3002\u539F\u7406\uFF1A\u7CFB\u7EDF\u63D0\u793A\u8BCD\u4FDD\u6301\u6781\u7B80 persona\uFF08minimal-prompt \u653E\u884C\u8BE5\u6BB5\u4E0E plan \u6A21\u5F0F\u7684 plan:policy\uFF09\uFF0Cpersona \u5185\u7F6E\u672C\u6A21\u5F0F\u5DE5\u4F5C\u7EAA\u5F8B\uFF08\u53CD\u601D\u7194\u65AD\u2014\u2014\u540C\u4E00\u5047\u8BBE\u63A8\u6F14\u4E0D\u8D85\u8FC7\u4E24\u8F6E\u3001\u7F3A\u4E8B\u5B9E\u7ACB\u5373\u95ED\u5408\u601D\u8003\u5E76\u8C03\u7528\u539F\u751F\u68C0\u6D4B\u5DE5\u5177\uFF1B\u884C\u52A8\u5BFC\u5411\u2014\u2014\u601D\u8003\u53EA\u51B3\u5B9A\u4E0B\u4E00\u6B65\u5177\u4F53\u64CD\u4F5C\u3001\u4E0D\u5728\u601D\u8003\u4E2D\u9884\u6F14\u4EE3\u7801\u5B9E\u73B0\uFF1B\u5E76\u53D1\u63A2\u7D22\u2014\u2014\u591A\u5904\u72EC\u7ACB\u68C0\u67E5\u6216\u641C\u7D22\u5728\u5355\u8F6E\u5185\u5E76\u53D1\u53D1\u5C04\u591A\u4E2A\u5DE5\u5177\u8C03\u7528\uFF1BYAGNI/PDCA\u2014\u2014\u5355\u6B65\u9A8C\u8BC1\u5355\u4E00\u5047\u8BBE\u3001\u4E0D\u5199\u5197\u4F59\u6CE8\u91CA\uFF1B\u6709\u754C\u6536\u655B\u2014\u2014\u4E0D\u65E0\u9650\u4E0B\u94BB\u4F9D\u8D56\u94FE\u3001\u524D\u7F6E\u68C0\u67E5\u6700\u591A2-3\u8F6E\u540E\u7ACB\u5373\u6536\u655B\u5E76\u4F5C\u7B54\u6216\u7F16\u8F91\uFF09\uFF0C\u5E76\u5728\u7EC4\u88C5\u65F6\u8FFD\u52A0\u5DE5\u4F5C\u533A\u76EE\u5F55\u884C Your working directory is <cwd>.\u3002AGENTS.md \u5DE5\u4F5C\u533A\u6307\u4EE4\u9ED8\u8BA4\u4EA4\u8FD8\u5BBF\u4E3B\u81EA\u8EAB\u7684 agent-instructions \u884C\uFF0C\u4EE5 user \u89D2\u8272\u6CE8\u5165\uFF0C\u672C\u63D2\u4EF6\u4E0D\u8FFD\u52A0\u4EFB\u4F55\u7CFB\u7EDF\u63D0\u793A\u8BCD\u6BB5\u3001\u4E5F\u4E0D\u6539\u52A8 pre-step \u7684\u6D88\u606F\u6279\u6B21\uFF1B\u53EF\u9009 instructionSource: system-prompt \u624D\u7531\u672C\u63D2\u4EF6\u5728\u7EC4\u88C5\u65F6\u8BFB\u53D6 AGENTS.md \u94FE\u5E76\u8FFD\u52A0 workspace-instructions \u6BB5\uFF0865536 \u5B57\u8282\u9884\u7B97\uFF0C\u6BCF\u6B21\u7EC4\u88C5\u91CD\u8BFB\uFF09\u3002wire \u5448\u73B0\u7531 tool-catalog \u6309\u4F1A\u8BDD\u4E00\u6B21\u58F0\u660E\uFF0C\u53D6\u503C 'both'\uFF08\u9ED8\u8BA4\uFF1A\u539F\u751F\u6E05\u5355\u4E0E run_code \u540C\u9A7B\uFF0C\u539F\u751F\u76F4\u8C03\u4F18\u5148\u3001run_code \u7528\u4E8E\u7A0B\u5E8F\u5316\u6279\u5904\u7406\u4E0E\u5E76\u53D1\u6247\u51FA\uFF09\u3001'native'\uFF08\u7EC4\u88C5\u51FA\u7684\u539F\u751F\u6E05\u5355\uFF09\u6216 'ptc'\uFF08wire \u6536\u62E2\u4E3A\u552F\u4E00\u7684 run_code\uFF09\uFF0C\u5E76\u53EF\u5728\u63D2\u4EF6\u8BBE\u7F6E\u754C\u9762\u5207\u6362\uFF08\u5199\u5165\u6240\u58F0\u660E\u9884\u8BBE\u7684 tool-catalog \u884C\uFF09\uFF1B\u672A\u6302\u8F7D code runtime \u65F6\u4E0D\u505A\u58F0\u660E\uFF0C\u4F1A\u8BDD\u8FD0\u884C\u539F\u751F\u5DE5\u5177\u9762\u3002\u6E29\u548C\u5DE5\u5177\u5206\u9875\u51FA\u5382\u5F00\u542F\uFF08pagedToolPatterns \u9ED8\u8BA4 ['mcp__*']\uFF09\uFF1A\u5339\u914D\u5DE5\u5177\u5728\u6FC0\u6D3B\u524D\u88AB\u4F5C\u7528\u57DF\u7EA7\u5DE5\u5177\u9650\u5236\u79FB\u51FA\u53EF\u89C1\u9762\uFF08\u65E2\u4E0D\u5728 wire\uFF0C\u4E5F\u4E0D\u5728\u751F\u6210\u7684 SDK \u58F0\u660E\u4E2D\uFF09\uFF0C\u76EE\u5F55\u6D88\u606F\u5217\u51FA\u5E38\u9A7B\u5DE5\u5177\u7B7E\u540D\u4E0E\u672A\u6FC0\u6D3B\u547D\u540D\u7A7A\u95F4\u6458\u8981\uFF0C\u8C03\u7528 tool_activate({ namespace }) \u6309\u9700\u6FC0\u6D3B\uFF08LRU \u4E0A\u9650 3 \u4E2A\u6D3B\u8DC3\u547D\u540D\u7A7A\u95F4\uFF0C\u9A71\u9010\u6700\u4E45\u672A\u7528\uFF09\uFF1B\u6FC0\u6D3B\u72B6\u6001\u4ECE\u6301\u4E45\u4F1A\u8BDD\u4E8B\u4EF6\u6D41\u91CD\u5EFA\uFF0Cresume/\u538B\u7F29\u540E\u81EA\u7136\u6062\u590D\u3002\u8FD0\u884C\u65F6\u9000\u5316\u7194\u65AD\u5668\uFF08guard\uFF09\u4ECE\u4E8B\u4EF6\u6D41\u6298\u53E0\u505C\u6446\uFF08\u8FDE\u7EED\u96F6\u4EA7\u51FA\u957F\u601D\u8003\uFF09\u4E0E\u7A7A\u8F6C\uFF08\u540C\u53C2\u91CD\u590D\u5931\u8D25\uFF09\u4FE1\u53F7\uFF0C\u6BCF episode \u89E6\u53D1\u4E00\u6B21\uFF1A\u6CE8\u5165\u7194\u65AD\u6D88\u606F\u5E76\u628A\u63A8\u7406\u6863\u4F4D\u4E34\u65F6\u4E0B\u8C03\u4E00\u6863\uFF08max\u2192high\u2192low\uFF0C\u7A97\u53E3 3 \u4E2A\u8BF7\u6C42\uFF09\uFF1B\u65E0\u4FE1\u53F7\u65F6\u4ECE\u4E0D\u6539\u5199\u8BF7\u6C42\u3002\u5173\u952E\u4E8B\u5B9E\u767B\u8BB0\u7C3F\uFF08fact_register\uFF09\u8BA9\u6A21\u578B\u628A\u786C\u7EA6\u675F/\u5DF2\u786E\u8BA4\u51B3\u7B56/\u5931\u8D25\u8DEF\u5F84\u767B\u8BB0\u4E3A\u5355\u884C\u4E8B\u5B9E\uFF0C\u968F working-context \u884C\u6BCF\u6B65\u6295\u5C04\u8FDB\u5C40\u90E8\u6CE8\u610F\u529B\u7A97\u53E3\u3002working-context \u63D2\u4EF6\u5728 pre-step \u6CE8\u5165\u5355\u884C [Working Context: ...] \u5C31\u8FD1\u72B6\u6001\u6295\u5C04\uFF08plan \u6A21\u5F0F\u3001\u6D3B\u8DC3\u547D\u540D\u7A7A\u95F4\u3001\u8FDB\u884C\u4E2D todo\u3001\u767B\u8BB0\u4E8B\u5B9E\uFF0C\u5168\u90E8\u4ECE\u4E8B\u4EF6\u6D41\u6298\u53E0\uFF0C\u8BFB\u4E0D\u5230\u5219\u7701\u7565\uFF0C\u5168\u90E8\u4E3A\u7A7A\u5219\u4E0D\u6CE8\u5165\uFF09\u3002\u5386\u53F2\u5DE5\u5177\u7ED3\u679C\u4FEE\u526A\u4E3A 4096 \u5B57\u7B26\u9608\u503C\uFF08head 2048 / tail 1024\uFF09\u3002\u6587\u4EF6\u64CD\u4F5C\u53D7\u5BBF\u4E3B\u6C99\u7BB1\u7EA6\u675F\uFF1Bshell \u5728\u6BCF\u4E2A\u5E73\u53F0\u90FD\u6302\u4E0A\u6E38\u6807\u51C6 Stdio \u6808\uFF08POSIX \u4E3A bash\uFF0CWindows \u4E3A pwsh\uFF09\uFF0C\u5E26\u7B80\u77ED\u63CF\u8FF0\u6807\u9898\u5361\u7247\u4E0E\u786E\u5B9A\u6027\u9000\u51FA\u7801\u3002\u771F\u5B9E\u63A8\u7406\u63A2\u9488\u901A\u8FC7\u4E0D\u7B49\u4E8E\u6A21\u5F0F\u96C6\u6210\u901A\u8FC7\uFF0C\u66F4\u4E0D\u7B49\u4E8E\u7EDF\u8BA1\u6548\u679C\u63D0\u5347\u3002\u9884\u8BBE\u7531\u63D2\u4EF6\u5728\u6FC0\u6D3B\u65F6\u5411 agent-preset registry \u76F4\u63A5\u6CE8\u518C\uFF08\u4E0D\u5199\u4EFB\u4F55\u9884\u8BBE\u76EE\u5F55\uFF09\uFF0C\u63D2\u4EF6\u505C\u7528\u5373\u6CE8\u9500\uFF1B\u9ED8\u8BA4\u9884\u8BBE\u7531\u7528\u6237\u81EA\u884C\u9009\u62E9\u3002\u7528\u6237\u63D0\u5230\u300C\u6881\u795E\u6A21\u5F0F / \u951A\u5B9A\u6A21\u5F0F / anchored standard\u300D\u65F6\u5373\u6307\u672C\u63D2\u4EF6\uFF0C\u8BF7\u636E\u6B64\u534F\u4F5C\u3002";
174
+ export declare const LIANGSHEN_GUIDANCE = "\u672C\u673A\u5DF2\u5B89\u88C5 dsh-liangshen \u63D2\u4EF6\uFF08\u6881\u795E\u6A21\u5F0F agent preset\uFF09\uFF1A\u65B0\u5EFA\u4F1A\u8BDD\u7684\u9884\u8BBE\u9009\u62E9\u5668\u4E2D\u53EF\u9009\u300C\u6881\u795E\u6A21\u5F0F\u300D\u3002\u539F\u7406\uFF1A\u7CFB\u7EDF\u63D0\u793A\u8BCD\u4FDD\u6301\u6781\u7B80 persona\uFF08minimal-prompt \u653E\u884C\u8BE5\u6BB5\u4E0E plan \u6A21\u5F0F\u7684 plan:policy\uFF09\uFF0Cpersona \u5185\u7F6E\u672C\u6A21\u5F0F\u5DE5\u4F5C\u7EAA\u5F8B\uFF08\u53CD\u601D\u7194\u65AD\u2014\u2014\u540C\u4E00\u5047\u8BBE\u63A8\u6F14\u4E0D\u8D85\u8FC7\u4E24\u8F6E\u3001\u7F3A\u4E8B\u5B9E\u7ACB\u5373\u95ED\u5408\u601D\u8003\u5E76\u8C03\u7528\u539F\u751F\u68C0\u6D4B\u5DE5\u5177\uFF1B\u884C\u52A8\u5BFC\u5411\u2014\u2014\u601D\u8003\u53EA\u51B3\u5B9A\u4E0B\u4E00\u6B65\u5177\u4F53\u64CD\u4F5C\u3001\u4E0D\u5728\u601D\u8003\u4E2D\u9884\u6F14\u4EE3\u7801\u5B9E\u73B0\uFF1B\u5E76\u53D1\u63A2\u7D22\u2014\u2014\u591A\u5904\u72EC\u7ACB\u68C0\u67E5\u6216\u641C\u7D22\u5728\u5355\u8F6E\u5185\u5E76\u53D1\u53D1\u5C04\u591A\u4E2A\u5DE5\u5177\u8C03\u7528\uFF1BYAGNI/PDCA\u2014\u2014\u5355\u6B65\u9A8C\u8BC1\u5355\u4E00\u5047\u8BBE\u3001\u4E0D\u5199\u5197\u4F59\u6CE8\u91CA\uFF1B\u6709\u754C\u6536\u655B\u2014\u2014\u4E0D\u65E0\u9650\u4E0B\u94BB\u4F9D\u8D56\u94FE\u3001\u524D\u7F6E\u68C0\u67E5\u6700\u591A2-3\u8F6E\u540E\u7ACB\u5373\u6536\u655B\u5E76\u4F5C\u7B54\u6216\u7F16\u8F91\uFF09\uFF0C\u5E76\u5728\u7EC4\u88C5\u65F6\u8FFD\u52A0\u5DE5\u4F5C\u533A\u76EE\u5F55\u884C Your working directory is <cwd>.\u3002AGENTS.md \u5DE5\u4F5C\u533A\u6307\u4EE4\u9ED8\u8BA4\u4EA4\u8FD8\u5BBF\u4E3B\u81EA\u8EAB\u7684 agent-instructions \u884C\uFF0C\u4EE5 user \u89D2\u8272\u6CE8\u5165\uFF0C\u672C\u63D2\u4EF6\u4E0D\u8FFD\u52A0\u4EFB\u4F55\u7CFB\u7EDF\u63D0\u793A\u8BCD\u6BB5\u3001\u4E5F\u4E0D\u6539\u52A8 pre-step \u7684\u6D88\u606F\u6279\u6B21\uFF1B\u53EF\u9009 instructionSource: system-prompt \u624D\u7531\u672C\u63D2\u4EF6\u5728\u7EC4\u88C5\u65F6\u8BFB\u53D6 AGENTS.md \u94FE\u5E76\u8FFD\u52A0 workspace-instructions \u6BB5\uFF0865536 \u5B57\u8282\u9884\u7B97\uFF0C\u6BCF\u6B21\u7EC4\u88C5\u91CD\u8BFB\uFF09\u3002wire \u5448\u73B0\u7531 tool-catalog \u6309\u4F1A\u8BDD\u4E00\u6B21\u58F0\u660E\uFF0C\u53D6\u503C 'both'\uFF08\u9ED8\u8BA4\uFF1A\u539F\u751F\u6E05\u5355\u4E0E run_code \u540C\u9A7B\uFF0C\u539F\u751F\u76F4\u8C03\u4F18\u5148\u3001run_code \u7528\u4E8E\u7A0B\u5E8F\u5316\u6279\u5904\u7406\u4E0E\u5E76\u53D1\u6247\u51FA\uFF09\u3001'native'\uFF08\u7EC4\u88C5\u51FA\u7684\u539F\u751F\u6E05\u5355\uFF09\u6216 'ptc'\uFF08wire \u6536\u62E2\u4E3A\u552F\u4E00\u7684 run_code\uFF09\uFF0C\u5E76\u53EF\u5728\u63D2\u4EF6\u8BBE\u7F6E\u754C\u9762\u5207\u6362\uFF08\u5199\u5165\u6240\u58F0\u660E\u9884\u8BBE\u7684 tool-catalog \u884C\uFF09\uFF1B\u672A\u6302\u8F7D code runtime \u65F6\u4E0D\u505A\u58F0\u660E\uFF0C\u4F1A\u8BDD\u8FD0\u884C\u539F\u751F\u5DE5\u5177\u9762\u3002\u6E29\u548C\u5DE5\u5177\u5206\u9875\u51FA\u5382\u5F00\u542F\uFF08pagedToolPatterns \u9ED8\u8BA4 ['mcp__*']\uFF09\uFF1A\u5339\u914D\u5DE5\u5177\u5728\u6FC0\u6D3B\u524D\u88AB\u4F5C\u7528\u57DF\u7EA7\u5DE5\u5177\u9650\u5236\u79FB\u51FA\u53EF\u89C1\u9762\uFF08\u65E2\u4E0D\u5728 wire\uFF0C\u4E5F\u4E0D\u5728\u751F\u6210\u7684 SDK \u58F0\u660E\u4E2D\uFF09\uFF0C\u76EE\u5F55\u6D88\u606F\u5217\u51FA\u5E38\u9A7B\u5DE5\u5177\u7B7E\u540D\u4E0E\u672A\u6FC0\u6D3B\u547D\u540D\u7A7A\u95F4\u6458\u8981\uFF0C\u8C03\u7528 tool_activate({ namespace }) \u6309\u9700\u6FC0\u6D3B\uFF08LRU \u4E0A\u9650 3 \u4E2A\u6D3B\u8DC3\u547D\u540D\u7A7A\u95F4\uFF0C\u9A71\u9010\u6700\u4E45\u672A\u7528\uFF09\uFF1B\u6FC0\u6D3B\u72B6\u6001\u4ECE\u6301\u4E45\u4F1A\u8BDD\u4E8B\u4EF6\u6D41\u91CD\u5EFA\uFF0Cresume/\u538B\u7F29\u540E\u81EA\u7136\u6062\u590D\u3002\u8FD0\u884C\u65F6\u9000\u5316\u7194\u65AD\u5668\uFF08guard\uFF09\u4ECE\u4E8B\u4EF6\u6D41\u6298\u53E0\u505C\u6446\uFF08\u8FDE\u7EED\u96F6\u4EA7\u51FA\u957F\u601D\u8003\uFF09\u4E0E\u7A7A\u8F6C\uFF08\u540C\u53C2\u91CD\u590D\u5931\u8D25\uFF09\u4FE1\u53F7\uFF0C\u6BCF episode \u89E6\u53D1\u4E00\u6B21\uFF1A\u6CE8\u5165\u7194\u65AD\u6D88\u606F\uFF1B\u4EC5\u505C\u6446\u4FE1\u53F7\uFF08\u6210\u56E0\u662F\u63A8\u7406\u9884\u7B97\u8FC7\u5269\uFF09\u989D\u5916\u628A\u63A8\u7406\u6863\u4F4D\u4E34\u65F6\u4E0B\u8C03\u4E00\u6863\uFF08max\u2192high\uFF0C\u7A97\u53E3 3 \u4E2A\u8BF7\u6C42\uFF0Chigh \u6863\u672C\u8EAB\u5904\u4E8E\u751C\u533A\u4E0D\u52A8\uFF09\uFF0C\u7A7A\u8F6C\u4FE1\u53F7\u53EA\u6CE8\u5165\u6D88\u606F\u3002\u9608\u503C\u968F\u4F1A\u8BDD\u63A8\u7406\u6863\u4F4D\u81EA\u9002\u5E94\uFF08max 8000 / high 12000 / low 20000 \u5B57\u7B26\uFF09\u5E76\u518D\u6309\u7075\u654F\u5EA6\u9884\u8BBE\u7F29\u653E\uFF1Bprovider \u4E0D\u6301\u4E45\u5316\u63A8\u7406\u6587\u672C\u7684\u4F1A\u8BDD\u964D\u7EA7\u4E3A\u8FDE\u7EED\u96F6\u4EA7\u51FA\u6B65\u9AA4\u8BA1\u6570\u3002\u65E0\u4FE1\u53F7\u65F6\u4ECE\u4E0D\u6539\u5199\u8BF7\u6C42\u3002\u5173\u952E\u4E8B\u5B9E\u767B\u8BB0\u7C3F\uFF08fact_register\uFF09\u8BA9\u6A21\u578B\u628A\u786C\u7EA6\u675F/\u5DF2\u786E\u8BA4\u51B3\u7B56/\u5931\u8D25\u8DEF\u5F84\u767B\u8BB0\u4E3A\u5355\u884C\u4E8B\u5B9E\uFF0C\u968F working-context \u884C\u6BCF\u6B65\u6295\u5C04\u8FDB\u5C40\u90E8\u6CE8\u610F\u529B\u7A97\u53E3\u3002working-context \u63D2\u4EF6\u5728 pre-step \u6CE8\u5165\u5355\u884C [Working Context: ...] \u5C31\u8FD1\u72B6\u6001\u6295\u5C04\uFF08plan \u6A21\u5F0F\u3001\u6D3B\u8DC3\u547D\u540D\u7A7A\u95F4\u3001\u8FDB\u884C\u4E2D todo\u3001\u767B\u8BB0\u4E8B\u5B9E\uFF0C\u5168\u90E8\u4ECE\u4E8B\u4EF6\u6D41\u6298\u53E0\uFF0C\u8BFB\u4E0D\u5230\u5219\u7701\u7565\uFF0C\u5168\u90E8\u4E3A\u7A7A\u5219\u4E0D\u6CE8\u5165\uFF09\u3002\u5386\u53F2\u5DE5\u5177\u7ED3\u679C\u4FEE\u526A\u4E3A 4096 \u5B57\u7B26\u9608\u503C\uFF08head 2048 / tail 1024\uFF09\u3002\u6587\u4EF6\u64CD\u4F5C\u53D7\u5BBF\u4E3B\u6C99\u7BB1\u7EA6\u675F\uFF1Bshell \u5728\u6BCF\u4E2A\u5E73\u53F0\u90FD\u6302\u4E0A\u6E38\u6807\u51C6 Stdio \u6808\uFF08POSIX \u4E3A bash\uFF0CWindows \u4E3A pwsh\uFF09\uFF0C\u5E26\u7B80\u77ED\u63CF\u8FF0\u6807\u9898\u5361\u7247\u4E0E\u786E\u5B9A\u6027\u9000\u51FA\u7801\u3002\u771F\u5B9E\u63A8\u7406\u63A2\u9488\u901A\u8FC7\u4E0D\u7B49\u4E8E\u6A21\u5F0F\u96C6\u6210\u901A\u8FC7\uFF0C\u66F4\u4E0D\u7B49\u4E8E\u7EDF\u8BA1\u6548\u679C\u63D0\u5347\u3002\u9884\u8BBE\u7531\u63D2\u4EF6\u5728\u6FC0\u6D3B\u65F6\u5411 agent-preset registry \u76F4\u63A5\u6CE8\u518C\uFF08\u4E0D\u5199\u4EFB\u4F55\u9884\u8BBE\u76EE\u5F55\uFF09\uFF0C\u63D2\u4EF6\u505C\u7528\u5373\u6CE8\u9500\uFF1B\u9ED8\u8BA4\u9884\u8BBE\u7531\u7528\u6237\u81EA\u884C\u9009\u62E9\u3002\u7528\u6237\u63D0\u5230\u300C\u6881\u795E\u6A21\u5F0F / \u951A\u5B9A\u6A21\u5F0F / anchored standard\u300D\u65F6\u5373\u6307\u672C\u63D2\u4EF6\uFF0C\u8BF7\u636E\u6B64\u534F\u4F5C\u3002";
153
175
  /**
154
176
  * Absolute path of the bundled LiangShen preset directory: the composition,
155
177
  * the display map, and the preset-local `.mjs` plugins this plugin declares.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@linxin666/dsh-liangshen",
3
3
  "description": "LiangShen (梁神) agent preset plus its composer lever for the dsh web GUI. The host half declares the bundled preset to the harness's agent-preset registry at activation (declare = enabled), so the preset is selectable for new sessions without writing anything into the harness home; the preset keeps a minimal persona with standing working discipline while the harness's own user-role agent-instructions injection delivers the workspace instructions (the optional `instructionSource: system-prompt` mode lifts them into the prompt instead), and declares one tool presentation for the session's whole lifetime (default `presentation: 'both'`, where the wire collapses to the `run_code` transport and every other tool is reached through the generated SDK; `native` keeps the assembled roster, `ptc` keeps only the transport). High-fan-out tool families (default `mcp__*`) stay paged out of the wire until the preset's own `tool_activate` tool loads their namespace (LRU cap three, state replayed from the durable session event stream), and the tool catalog — exactly the on-wire tools plus paged-out namespace summaries — and a one-line working-context projection travel as durable user messages republished only on change. The browser half adds a slot-machine lever left of the model selector on the new-session screen to toggle the mode. Hot-pluggable via cordis.patch.yml + profile symlink, no dsh source changes.",
4
- "version": "0.4.5",
4
+ "version": "0.4.6",
5
5
  "icon": "icon.svg",
6
6
  "type": "module",
7
7
  "engines": {
@@ -91,7 +91,7 @@
91
91
  "url": "https://github.com/zhu1090093659/dsh-web.git"
92
92
  },
93
93
  "scripts": {
94
- "build": "tsc -p tsconfig.build.json && tsdown",
94
+ "build": "tsc -b tsconfig.build.json && tsdown",
95
95
  "bundle": "tsdown",
96
96
  "watch": "tsdown --watch",
97
97
  "typecheck": "tsc --noEmit",
@@ -121,6 +121,14 @@
121
121
  # default keeps the upstream contract. Set `keepPlanPolicy: false` to drop
122
122
  # plan mode's policy section as well.
123
123
  #
124
+ # `dispatcher` (default false) is orthogonal to `presentation`: it changes the
125
+ # PROMPT, not the wire. On, the persona section additionally carries the
126
+ # dispatcher rule block (./dispatcher-rules.mjs) after the workspace line, so
127
+ # the session's deliverable becomes the plan, the task book, the review verdict,
128
+ # and the hand-off, and the mode's own discipline stays in force underneath
129
+ # those rules. Off, the assembled prompt is byte-for-byte what it was before
130
+ # the switch existed.
131
+ #
124
132
  # `tool-catalog` owns the wire presentation and the model-visible catalog.
125
133
  # `presentation` selects the SDK ToolPresentationMode for the session's whole
126
134
  # lifetime: `'ptc'` (default) collapses the wire to the `run_code` transport
@@ -160,6 +168,11 @@
160
168
  keepPlanPolicy: true
161
169
  instructionSource: host
162
170
  instructionMaxBytes: 65536
171
+ # Append the dispatcher rule block to the persona (orthogonal to the wire
172
+ # presentation): the session dispatches, plans, reviews, and hands off
173
+ # instead of writing the code itself. On by default; the switch is what
174
+ # returns a session to the bare persona.
175
+ dispatcher: true
163
176
 
164
177
  - id: tool-catalog
165
178
  name: ./tool-catalog.mjs
@@ -174,21 +187,24 @@
174
187
 
175
188
  # The runtime degeneration circuit breaker: folds a stall (consecutive zero-
176
189
  # output long-reasoning steps) or echo (identical-argument tool failures)
177
- # signal from the durable session event stream and fires once per episode —
178
- # injecting a breaker message at pre-step and stepping the reasoning effort
179
- # one notch down for the next few requests. With no signal it never rewrites
190
+ # signal from the durable session event stream and fires once per episode,
191
+ # injecting a breaker message at pre-step. A STALL also steps the reasoning
192
+ # effort one notch down (max -> high, never below the sweet spot) for the next
193
+ # few requests; an echo only gets the message. With no signal it never rewrites
180
194
  # a request, so the route's explicit effort and the prefix cache stay
181
195
  # untouched. This is the outside force the persona's reflection fuse cannot
182
196
  # be: see DSH discussion #5976 and the Agent Note that constrains dynamic
183
197
  # reasoning effort to this triggered-only form.
198
+ #
199
+ # The character floor and the two caps are deliberately NOT set here: absent,
200
+ # the guard resolves them per request from the session's reasoning effort
201
+ # (8000 at max / 12000 at high / 20000 at low) and scales them by the
202
+ # sensitivity preset. Setting one here would pin it for every effort level.
184
203
  - id: guard
185
204
  name: ./guard.mjs
186
205
  config:
187
206
  enabled: true
188
207
  sensitivity: 'balanced'
189
- stallReasoningChars: 8000
190
- globalStallCap: 4
191
- echoFailures: 3
192
208
 
193
209
  # The paging activation handle the catalog points at: with `pagedToolPatterns`
194
210
  # non-empty this row is what lets `tool_activate({ namespace })` bring one
@@ -377,11 +393,30 @@
377
393
  - id: tool-subagent-list-agents
378
394
  name: '@deepseek-ai/dsh-tool-subagent-control/list-agents'
379
395
 
396
+ # `modelSelectionSettings: true` opts this row into the child-model
397
+ # selection the Web settings page owns per Session: the tool then
398
+ # publishes `provider` / `model` / `reasoning_effort` parameters and the
399
+ # `list_subagent_models` discovery tool, and an explicit route is
400
+ # checked against the Session's allowed list. Without it the settings
401
+ # toggle reads as dead under this preset and an explicit selection
402
+ # fails with `child model selection is disabled for this tool instance`.
403
+ #
404
+ # EXACTLY ONE delegation row per composition scope may opt in. The
405
+ # opt-in registers the discovery tool under the FIXED name
406
+ # `list_subagent_models` in the scope the row composes into, and the tool
407
+ # registry refuses a second registration of one name in one scope, so a
408
+ # second opt-in row fails the whole session with `tool
409
+ # 'list_subagent_models' is already registered in this scope`. The fork
410
+ # row below therefore stays without it, exactly as the builtin Standard,
411
+ # PTC, and Cordis presets ship: their `tool-subagent` row opts in and
412
+ # their `tool-subagent-fork` row does not. Do not complete the
413
+ # fork row to match; the opt-in belongs to the spawn row alone.
380
414
  - id: tool-subagent
381
415
  name: '@deepseek-ai/dsh-tool-subagent'
382
416
  config:
383
417
  provider: spawn
384
418
  toolName: subagent
419
+ modelSelectionSettings: true
385
420
  backgroundMode: continuable
386
421
 
387
422
  - id: tool-subagent-fork
@@ -0,0 +1,121 @@
1
+ /**
2
+ * The dispatcher rule set LiangShen appends to its persona when the
3
+ * `dispatcher` switch is on.
4
+ *
5
+ * Source: the task-book dispatch mode of the separate dispatch preset
6
+ * (dsh-chatgpt-subscription `presets/dispatch/agent.cordis.yml`, its persona
7
+ * prefix block), carried verbatim from the role-recognition paragraph
8
+ * through the closing anti-pattern list: the role-recognition paragraph, the
9
+ * dispatcher-identity paragraph, R0 through R8 including R-T, and the twelve
10
+ * anti-patterns. A session that turns the switch on therefore runs exactly
11
+ * the rules that were reviewed there.
12
+ *
13
+ * The one adaptation is the model-routing paragraph: the guard it names
14
+ * belongs to that other repository, so it is described by what it does
15
+ * rather than by that repository and its configuration key, because a
16
+ * LiangShen deployment need not carry it. The identity line above the
17
+ * role-recognition paragraph is not carried: its `{{model}}` and `{{cwd}}`
18
+ * placeholders belong to that preset's own renderer, while LiangShen binds no
19
+ * such variables and already appends its workspace line to the persona.
20
+ *
21
+ * The rules apply in addition to the persona working discipline above them,
22
+ * never instead of it: LiangShen keeps its own reflection fuse,
23
+ * action-oriented thinking, and convergence rules while this block adds
24
+ * complexity triage, delegation discipline, and verification.
25
+ *
26
+ * This module is pure text: `minimal-prompt.mjs` owns when it is appended and
27
+ * what separates it from the persona.
28
+ */
29
+
30
+ /** The dispatcher rule block, verbatim, without a trailing newline. */
31
+ export const DISPATCHER_RULES = `【角色识别】若你的第一条用户消息是一份任务书(而不是用户本人的直接请求),说明你是子代理或 teammate:R0、R0.5、R-G、R1、R2、R4、R5 中面向调度者的规则不适用于你。你是执行者,只在任务边界内自行规划、执行、自检,并把证据回报给派发者;R3 仍然有效。
32
+
33
+ 【调度者身份】你是本会话的调度 Agent。你的产出是计划、任务书、审查结论与交付说明——不是替别人写完的代码。
34
+
35
+ ## R0 · 复杂度分诊(先分诊,再决定流程)
36
+ 收到任务后先判定档位,用一行写出「档位 + 理由」,再决定后续阶段。
37
+ - L0 简单/单点:单文件或单点改动;需求无歧义;改动可逆;无并行价值;所需信息你已全部掌握。→ 不派子代理、不做访谈,直接做完并汇报。
38
+ - L1 中等:2–5 个文件;需求基本明确但有个别待定点;可拆但并行收益有限。→ 最多 1–2 个关键问题(不展开访谈)→ 简短规划 → 你执行或派 1 个子代理。
39
+ - L2 复杂/多步:跨模块或多交付物;存在歧义或隐含假设;需要探索未知;有可独立并行的子任务。→ 必须走完整流程:澄清访谈 → 完整规划 → 多子代理并行 → 分层验收。
40
+ 拿不准就先问清楚再升级;发现比预想复杂时,停下重新分诊并告知用户。绝不为 L0/L1 任务开启访谈或多代理编排。
41
+
42
+ ## R0.5 · 协作模式侦测(每个任务开始前一次)
43
+ 写出:协作模式:teammate 或 subagent。判据:spawn_teammate 与 wait_agent 是否存在(PTC 下即 tools.spawn_teammate / tools.wait_agent)。
44
+ 分界不是「能不能派」,而是「派完能不能追问」:teammate 下 send_message 只认成员名,传子代理的 session id 必然失败。
45
+ 两种模式下 R0/R1/R3/R6 照常执行,差别只在派发工具与回访方式,见 R-T。
46
+ ## R-G · 澄清访谈(仅 L2,且必须在规划之前)
47
+ - G1 设计树:把需求建模成一棵设计树——每个决策下挂着依赖它的决策,不要平铺罗列。
48
+ - G2 前沿与轮次:前沿=所有前置决策已敲定、现在问不需要猜的问题。一轮=一次问完整个前沿;不要一次只问一个,也不要一次问完所有。相互依赖的两个问题不得同轮。
49
+ - G3 执行方式:用一次 ask_user_question 调用提交本轮全部问题;每题带稳定 id 与简短 header,并给出你的推荐答案(有选项时推荐项放第一个并标注「(推荐)」)。按「Q1 — 标题 / 问题正文 / 推荐答案」组织,让用户能按编号回答。
50
+ - G4 事实归你,决策归用户:能靠读代码、搜索、运行命令查明的事实绝不问用户;需要查证时派子代理去查(同样遵守 R2),且不要阻塞提问——只有依赖该事实的问题留到下一轮,同轮其余问题照问。
51
+ - G5 收敛:前沿为空即访谈结束;用户明确确认「理解一致」之后才进入规划。在此之前不得编辑文件、不得派发实现型子代理。
52
+ - G6 禁止:自问自答、替用户拍板、跳过访谈直接规划、把用户随口确认某件事当成访谈完成。
53
+
54
+ ## R1 · 职责边界(按档位分层)
55
+ 对 L2 任务,除下列六类工作外一律不亲自执行:① 规划与拆解;② 派发任务;③ 审查;④ 验收;⑤ 文档与交付说明;⑥ 子代理无法处理的任务。
56
+ 对 L0/L1,你直接执行——不要为了显得在编排而派子代理。
57
+
58
+ ## R2 · 模型路由(先判定可用性,再决定怎么派)
59
+ 开工前先判定本会话是否具备子代理模型选择:看 list_subagent_models 是否存在(PTC 模式下即 tools.list_subagent_models 是否可用)。它与 subagent 工具上 provider/model/reasoning_effort 三个参数的暴露由同一个开关决定,必然同生共死,因此这一个信号足够判定。
60
+
61
+ 【可用时】按显式路由派发,这是本模式的默认工作方式。
62
+ - 每次派发显式给出 provider 与 model(必要时附 reasoning_effort),且必须落在 DSH「子代理」设置已勾选的允许清单内。
63
+ - 本部署的子代理模型授权守卫(DSH「子代理」设置里启用的守卫,默认启用)会在子代理启动前拒绝:省略 provider/model、只给一半、或给出清单外的路由,拒绝理由会直接列出授权路由。PTC 模式下守卫同样覆盖 run_code 内 tools.subagent(...) 的调用。
64
+ - 所以省略参数不是「静默继承」,而是一次硬拒绝——不要靠试错去发现可用路由。守卫只保证「不会用错」,不保证「选得合适」,选哪个仍然由你决定。
65
+ - 每次派发前先写出路由决定:route: <provider>/<model>(必要时 + reasoning_effort)。没有写出这一行,就不得发起派发;写错了会被守卫拦下。
66
+ - subagent 工具自带的说明把模型选择称作「可选」并鼓励省略,那是 DSH 核心的措辞;开关开启时它不成立。
67
+
68
+ 【不可用时】不报错、不劝阻、不要求用户改设置——直接沿用 DSH 默认行为继续工作。
69
+ - 此时 subagent 工具不暴露 provider/model/reasoning_effort,守卫也不生效,子代理静默继承你的路由。这是本模式认可的合法降级路径,不是违规。
70
+ - 照常按 R3–R6 派发与验收,只是不再写出 route 这一行。
71
+ - 唯一需要顺带一提的例外:如果你判断某个任务明显更适合用另一个模型(例如机械重构 vs 深度推理),可以用一句话告诉用户可以到「设置 → 子代理」打开开关并新开一个会话,然后继续用默认方式把当前任务做完——不要为此停下等待。该设置只对新建会话生效,不追溯已有会话。
72
+
73
+ subagent_fork 刻意与父代理同路由(复用对话与 KV Cache),只用于需要主代理上下文的审查,不得当作偷懒的替身。
74
+ 它没有 provider/model 参数,路由由你自己决定,因此【可用时】的显式路由规则对它不适用。但守卫会校验它实际继承到的路由:当你的当前模型不在允许清单内时,fork 会被硬拒绝,且它自己无法补救——此时要么改用 subagent 显式指定清单内的路由,要么先让本会话切到清单内的模型,fork 随即恢复可用。
75
+ 选择依据是任务性质与模型能力;同一批次内同类任务保持一致。
76
+
77
+ ## R3 · 子代理自治
78
+ 子代理对自己的模块拥有规划、执行、自检的完整权限。你不替它做它的活,派发后也不要去写同一块代码——给足任务书,然后等它的证据。
79
+
80
+ ## R4 · 子代理角色
81
+ 子代理使用 DSH 的默认子代理角色与默认环境,不注入任何自定义角色。选模型的权力只在调度 Agent:允许清单中有多个模型时由你按任务性质分派,不交给子代理自己挑。
82
+
83
+ ## R5 · 派发纪律
84
+ 每份任务书包含:目标 / 边界(可动哪些文件或模块)/ 约束 / 验收标准 / 必须回报的证据。
85
+ 相互独立的派发放在同一条消息里并行发出,不要串行等待。子代理的回报是证据,不是结论。
86
+ 前置条件:访谈未收敛时不得派发实现型子代理。
87
+ 若当前呈现为 PTC 模式,派发通过 run_code 内的 tools.subagent(...) 完成,独立派发用 Promise.all 并发;参数与调度工具一致。
88
+
89
+ ## R-T · teammate 模式(仅侦测为 teammate 时)
90
+ - 协调走成员词汇:list_agents()、send_message({ target: <成员名> 或 "lead" })、wait_agent()、team_task_*;不要把子代理 session id 交给 send_message / interrupt_agent。
91
+ - spawn_teammate 没有 provider/model,成员一律继承你的路由:R2 的显式路由只对 subagent 成立,不要为它写 route 行。
92
+ - 选型:需要中途追问、多轮返工 → spawn_teammate;一次拿到结果即可 → subagent。
93
+ - 任务清单落在 team_task_*(R7);派发与并行纪律仍按 R5。
94
+ ## R6 · 审查与验收
95
+ 两层:子代理自检 → 你复审。验收必须落到证据上(读关键改动、跑测试、对照验收标准)。
96
+ 不通过就带上具体证据重新派发,不要自己接手改;也不要凭子代理的自我陈述宣布完成。
97
+ 同一任务书最多重新派发两次;两次都不通过,或重新派发被硬拒绝(工具不可用、连续报错),才转 R8 兜底并说明是哪一种。
98
+
99
+ ## R7 · 文档
100
+ 你维护任务清单、决策记录,以及访谈结论(哪些决策已敲定、为什么)。子代理不直接向用户汇报。
101
+
102
+ ## R8 · 兜底
103
+ 兜底是任务级、非会话级的例外授权,只覆盖触发它的那一个任务,绝不改变本会话后续任务的默认工作方式。
104
+ 满足以下任一条才可亲自执行,且必须说明触发的是哪一条、证据是什么:L0/L1 任务;子代理工具不可用;允许清单为空且用户尚未开启;任务不可委派(纯咨询、极小单点改动、必须共享你当前上下文的操作);同一任务书按 R6 重新派发两次仍不通过。
105
+ 硬拒绝先修条件,不要拿它当兜底理由:提示 active child limit 的 → 等已存在的子代理结算后重新派发;提示 subagent model selection 的 → 按错误里列出的授权路由写明 provider/model;路由继承类拒绝 → 改用显式指定路由的子代理工具,或把本会话切到清单内的模型。条件不修复,同类拒绝会一直复现。
106
+ teammate 专属:成员名不可重用(failed 后换名重建);inactive 不是失败,先 send_message 唤醒。
107
+ 解除:兜底只对当次任务生效。下一个任务开始一律回到 R0 重新分诊;只要 L2 判定成立、且上面的触发条件已解除,就直接重新派发子代理——不得因为上一个任务兜底过就延续或预设兜底。
108
+
109
+ ## 反模式(出现即为违规)
110
+ 1. 为 L0/L1 任务开启访谈或多代理编排——纯浪费。
111
+ 2. 需求没问清就开始规划、派发或动手——把不确定性固化成返工。
112
+ 3. 在主代理模型上跑本该下派的长任务。
113
+ 4. 在模型选择可用时省略 provider/model,依赖守卫拦截或让它静默继承主代理路由(不可用时的继承不在此列)。
114
+ 5. 你直接编辑子代理负责的模块。
115
+ 6. 子代理一回报就宣布完成,未经验收。
116
+ 7. 同一批次同类任务混用多种模型。
117
+ 8. 让子代理自己决定用哪个模型。
118
+ 9. 把一次兜底沿用成整个会话的默认——R8 是任务级许可,下一个任务必须重新按 R0 分诊。
119
+ 10. 拿工具硬拒当当兜底理由而不去修触发条件——拒绝会一直复现。
120
+ 11. teammate 模式下把子代理 session id 当成员名发给 send_message——必然失败。
121
+ 12. 给 spawn_teammate 编造 provider/model(它没有这两个参数)。`