@linxin666/dsh-liangshen 0.4.15 → 0.4.17

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
@@ -398,6 +398,18 @@ function readPresetDefinition(id, dir) {
398
398
  };
399
399
  }
400
400
  /**
401
+ * Parse the on-demand tool family text: comma separated, each entry a prefix
402
+ * ending in exactly one trailing `*`.
403
+ * @param text - the settings text.
404
+ * @returns the pattern list, or undefined when the text is blank or any entry is malformed.
405
+ */
406
+ function parsePagedToolPatterns(text) {
407
+ if (text === void 0) return void 0;
408
+ const entries = text.split(",").map((entry) => entry.trim()).filter((entry) => entry !== "");
409
+ if (entries.length === 0) return void 0;
410
+ return entries.every((entry) => /^[^*]+\*$/.test(entry)) ? entries : void 0;
411
+ }
412
+ /**
401
413
  * The overlay table: settings field to composition row and config key.
402
414
  *
403
415
  * `presentation` also selects the executor: the catalog declares the wire and
@@ -405,7 +417,17 @@ function readPresetDefinition(id, dir) {
405
417
  * the assembled native roster remains the only surface.
406
418
  */
407
419
  function overrideTargets(overrides) {
408
- return [["tool-catalog", { ...overrides.presentation === void 0 ? {} : { presentation: overrides.presentation } }], ["minimal-prompt", { ...overrides.dispatcher === void 0 ? {} : { dispatcher: overrides.dispatcher } }]];
420
+ const paged = parsePagedToolPatterns(overrides.pagedToolPatterns);
421
+ const pagedPatch = () => paged === void 0 ? {} : { pagedToolPatterns: [...paged] };
422
+ return [
423
+ ["tool-catalog", {
424
+ ...overrides.presentation === void 0 ? {} : { presentation: overrides.presentation },
425
+ ...pagedPatch()
426
+ }],
427
+ ["tool-activate", pagedPatch()],
428
+ ["working-context", pagedPatch()],
429
+ ["minimal-prompt", { ...overrides.dispatcher === void 0 ? {} : { dispatcher: overrides.dispatcher } }]
430
+ ];
409
431
  }
410
432
  /**
411
433
  * Apply the settings overlay to one parsed row list.
@@ -601,7 +623,7 @@ function mountOnce(packageName, fn) {
601
623
  * transport and every other tool is reached from inside the program through
602
624
  * the generated SDK ('native' keeps the assembled roster alone), declared once
603
625
  * per session instead of staged across a turn boundary. High-fan-out tool families
604
- * (default `mcp__*`) stay paged out of the executed surface through the
626
+ * (default `mcp__*`, `browser_*`, `task_board_*`, `team_*`, `squad*`, `ui_*`, `ssh_*`) stay paged out of the executed surface through the
605
627
  * host's scoped tool restriction until the preset's own `tool_activate` tool
606
628
  * loads their namespace (LRU cap three), with the activation state replayed
607
629
  * from the durable session event stream. The tool catalog — listing exactly
@@ -627,14 +649,16 @@ const Config = z.object({
627
649
  enabled: z.boolean().default(true).volatile(),
628
650
  announceToAgent: z.boolean().default(false).volatile(),
629
651
  presentation: z.union([...PRESENTATION_OPTIONS, z.transform("both", () => "ptc").deprecated().hidden()]).default("ptc").volatile(),
630
- dispatcher: z.boolean().default(true).volatile()
652
+ dispatcher: z.boolean().default(true).volatile(),
653
+ pagedToolPatterns: z.string().default("").volatile()
631
654
  });
632
655
  /** Schema defaults, re-read for hand-built test contexts. */
633
656
  const DEFAULT_CONFIG = {
634
657
  enabled: true,
635
658
  announceToAgent: false,
636
659
  presentation: "ptc",
637
- dispatcher: true
660
+ dispatcher: true,
661
+ pagedToolPatterns: ""
638
662
  };
639
663
  /**
640
664
  * Read one activation field. The Host validates the raw profile config and
@@ -659,11 +683,12 @@ function resolveConfig(config) {
659
683
  enabled: readField(config?.enabled, DEFAULT_CONFIG.enabled),
660
684
  announceToAgent: readField(config?.announceToAgent, DEFAULT_CONFIG.announceToAgent),
661
685
  presentation: rawPresentation === "both" ? "ptc" : rawPresentation,
662
- dispatcher: readField(config?.dispatcher, DEFAULT_CONFIG.dispatcher)
686
+ dispatcher: readField(config?.dispatcher, DEFAULT_CONFIG.dispatcher),
687
+ pagedToolPatterns: readField(config?.pagedToolPatterns, DEFAULT_CONFIG.pagedToolPatterns)
663
688
  };
664
689
  }
665
690
  /** Model-facing announcement: plugin presence, principle, and limits. */
666
- 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 按会话一次声明,取值 'ptc'(默认:wire 收拢为唯一的 run_code,其余工具经生成的 SDK 调用)或 'native'(组装出的原生清单,无程序化传输),并可在插件设置界面切换(写入所声明预设的 tool-catalog 行);未挂载 code runtime 时不做声明,会话运行原生工具面。温和工具分页出厂开启(pagedToolPatterns 默认 ['mcp__*']):匹配工具在激活前被作用域级工具限制移出可见面(既不在 wire,也不在生成的 SDK 声明中),目录消息列出常驻工具签名与未激活命名空间摘要,调用 tool_activate({ namespace }) 按需激活(LRU 上限 3 个活跃命名空间,驱逐最久未用);激活状态从持久会话事件流重建,resume/压缩后自然恢复。关键事实登记簿(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」时即指本插件,请据此协作。";
691
+ 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 按会话一次声明,取值 'ptc'(默认:wire 收拢为唯一的 run_code,其余工具经生成的 SDK 调用)或 'native'(组装出的原生清单,无程序化传输),并可在插件设置界面切换(写入所声明预设的 tool-catalog 行);未挂载 code runtime 时不做声明,会话运行原生工具面。按需工具族出厂开启(pagedToolPatterns 默认 ['mcp__*', 'browser_*', 'task_board_*', 'team_*', 'squad*', 'ui_*', 'ssh_*'],可在插件设置的「按需工具族」中用逗号分隔的前缀改写):匹配工具在激活前被作用域级工具限制移出可见面(既不在 wire,也不在生成的 SDK 声明中),目录消息列出常驻工具签名与未激活命名空间摘要,调用 tool_activate({ namespace }) 按需激活(LRU 上限 3 个活跃命名空间,驱逐最久未用);激活状态从持久会话事件流重建,resume/压缩后自然恢复。关键事实登记簿(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」时即指本插件,请据此协作。";
667
692
  /** Order of the announcement section within the tool-guidance band. */
668
693
  const SECTION_ORDER = 150;
669
694
  /**
@@ -12,7 +12,13 @@
12
12
  import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
13
13
  import type { SnapshotStore } from '@deepseek-ai/dsh-client-store';
14
14
  import type { ConfigForm } from '@deepseek-ai/dsh-client-ui-settings/client';
15
- import { type CardActions, type CardShell, type FieldState as CardFieldState } from './settings-form.ts';
15
+ import { type CardActions, type CardShell, type FieldSpec, type FieldState as CardFieldState } from './settings-form.ts';
16
+ /**
17
+ * The on-demand tool family list: comma separated entries, each a prefix with
18
+ * one trailing star. Blank clears the field; any malformed entry holds the
19
+ * draft unwritten.
20
+ */
21
+ export declare function pagedToolPatternsField(field: string): FieldSpec;
16
22
  /** Wire presentations the tool catalog accepts (mirrors the Host schema). */
17
23
  export declare const PRESENTATION_CHOICES: readonly ["ptc", "native"];
18
24
  /** The LiangShen fields this card edits (the namespace's full schema). */
@@ -25,6 +31,8 @@ export interface LiangShenSettings {
25
31
  presentation?: string;
26
32
  /** Whether the preset appends the dispatcher rules section after the persona. */
27
33
  dispatcher?: boolean;
34
+ /** Comma-separated on-demand tool families the Host writes to the tool-catalog row. */
35
+ pagedToolPatterns?: string;
28
36
  }
29
37
  /** What the LiangShen card renders. */
30
38
  export interface LiangShenSettingsCardState extends CardShell {
@@ -32,6 +40,7 @@ export interface LiangShenSettingsCardState extends CardShell {
32
40
  announceToAgent: CardFieldState;
33
41
  presentation: CardFieldState;
34
42
  dispatcher: CardFieldState;
43
+ pagedToolPatterns: CardFieldState;
35
44
  }
36
45
  /** The registration-side face the card's slot entry injects. */
37
46
  export interface LiangShenSettingsCardFace extends CardActions {
@@ -30,6 +30,9 @@ export declare const zh: {
30
30
  'settings.presentationHint': string;
31
31
  'settings.dispatcher': string;
32
32
  'settings.dispatcherHint': string;
33
+ 'settings.pagedToolPatterns': string;
34
+ 'settings.pagedToolPatternsHint': string;
35
+ 'settings.pagedToolPatternsInvalid': string;
33
36
  'settings.on': string;
34
37
  'settings.off': string;
35
38
  'settings.inherit': string;
@@ -92,7 +92,20 @@ export interface PresetOverrides {
92
92
  presentation?: string;
93
93
  /** The `minimal-prompt` row's `dispatcher` switch. */
94
94
  dispatcher?: boolean;
95
+ /**
96
+ * Comma-separated on-demand tool families; written as an array to every row
97
+ * that pages from it (tool-catalog, tool-activate, working-context), skipped
98
+ * when blank or malformed.
99
+ */
100
+ pagedToolPatterns?: string;
95
101
  }
102
+ /**
103
+ * Parse the on-demand tool family text: comma separated, each entry a prefix
104
+ * ending in exactly one trailing `*`.
105
+ * @param text - the settings text.
106
+ * @returns the pattern list, or undefined when the text is blank or any entry is malformed.
107
+ */
108
+ export declare function parsePagedToolPatterns(text: string | undefined): string[] | undefined;
96
109
  /**
97
110
  * Apply the settings overlay to one parsed row list.
98
111
  *
@@ -23,7 +23,7 @@
23
23
  * transport and every other tool is reached from inside the program through
24
24
  * the generated SDK ('native' keeps the assembled roster alone), declared once
25
25
  * per session instead of staged across a turn boundary. High-fan-out tool families
26
- * (default `mcp__*`) stay paged out of the executed surface through the
26
+ * (default `mcp__*`, `browser_*`, `task_board_*`, `team_*`, `squad*`, `ui_*`, `ssh_*`) stay paged out of the executed surface through the
27
27
  * host's scoped tool restriction until the preset's own `tool_activate` tool
28
28
  * loads their namespace (LRU cap three), with the activation state replayed
29
29
  * from the durable session event stream. The tool catalog — listing exactly
@@ -87,17 +87,27 @@ export interface Config {
87
87
  * and the switch is what returns a session to the bare persona.
88
88
  */
89
89
  dispatcher?: ConfigField<boolean>;
90
+ /**
91
+ * On-demand tool families, comma separated (each entry a prefix ending in one
92
+ * `*`), written to every row that pages from the list — the catalog, the
93
+ * activation tool and the working context all replay the session log with it,
94
+ * so the three must never disagree. Empty keeps the preset's shipped list; a
95
+ * malformed text is ignored.
96
+ */
97
+ pagedToolPatterns?: ConfigField<string>;
90
98
  }
91
99
  export declare const Config: z<Schemastery.ObjectS<NoInfer<{
92
100
  enabled: z<boolean, boolean, "volatile-defined">;
93
101
  announceToAgent: z<boolean, boolean, "volatile-defined">;
94
102
  presentation: z<string, "ptc" | "native", "volatile-defined">;
95
103
  dispatcher: z<boolean, boolean, "volatile-defined">;
104
+ pagedToolPatterns: z<string, string, "volatile-defined">;
96
105
  }>>, Schemastery.ObjectT<NoInfer<{
97
106
  enabled: z<boolean, boolean, "volatile-defined">;
98
107
  announceToAgent: z<boolean, boolean, "volatile-defined">;
99
108
  presentation: z<string, "ptc" | "native", "volatile-defined">;
100
109
  dispatcher: z<boolean, boolean, "volatile-defined">;
110
+ pagedToolPatterns: z<string, string, "volatile-defined">;
101
111
  }>>, "plain">;
102
112
  /** The settings the runtime acts on, every field read at its use site. */
103
113
  export interface ResolvedConfig {
@@ -109,6 +119,8 @@ export interface ResolvedConfig {
109
119
  presentation: Presentation;
110
120
  /** Whether the declared preset's minimal-prompt row appends the dispatcher rule block. */
111
121
  dispatcher: boolean;
122
+ /** On-demand tool family text; empty inherits the preset's shipped list. */
123
+ pagedToolPatterns: string;
112
124
  }
113
125
  /** Schema defaults, re-read for hand-built test contexts. */
114
126
  export declare const DEFAULT_CONFIG: ResolvedConfig;
@@ -119,7 +131,7 @@ export declare const DEFAULT_CONFIG: ResolvedConfig;
119
131
  */
120
132
  export declare function resolveConfig(config?: Config): ResolvedConfig;
121
133
  /** Model-facing announcement: plugin presence, principle, and limits. */
122
- 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 'ptc'\uFF08\u9ED8\u8BA4\uFF1Awire \u6536\u62E2\u4E3A\u552F\u4E00\u7684 run_code\uFF0C\u5176\u4F59\u5DE5\u5177\u7ECF\u751F\u6210\u7684 SDK \u8C03\u7528\uFF09\u6216 'native'\uFF08\u7EC4\u88C5\u51FA\u7684\u539F\u751F\u6E05\u5355\uFF0C\u65E0\u7A0B\u5E8F\u5316\u4F20\u8F93\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\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";
134
+ 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 'ptc'\uFF08\u9ED8\u8BA4\uFF1Awire \u6536\u62E2\u4E3A\u552F\u4E00\u7684 run_code\uFF0C\u5176\u4F59\u5DE5\u5177\u7ECF\u751F\u6210\u7684 SDK \u8C03\u7528\uFF09\u6216 'native'\uFF08\u7EC4\u88C5\u51FA\u7684\u539F\u751F\u6E05\u5355\uFF0C\u65E0\u7A0B\u5E8F\u5316\u4F20\u8F93\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\u6309\u9700\u5DE5\u5177\u65CF\u51FA\u5382\u5F00\u542F\uFF08pagedToolPatterns \u9ED8\u8BA4 ['mcp__*', 'browser_*', 'task_board_*', 'team_*', 'squad*', 'ui_*', 'ssh_*']\uFF0C\u53EF\u5728\u63D2\u4EF6\u8BBE\u7F6E\u7684\u300C\u6309\u9700\u5DE5\u5177\u65CF\u300D\u4E2D\u7528\u9017\u53F7\u5206\u9694\u7684\u524D\u7F00\u6539\u5199\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\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";
123
135
  /**
124
136
  * Absolute path of the bundled LiangShen preset directory: the composition,
125
137
  * 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
- "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: `ptc` by default (the wire collapses to `run_code` and every other tool is reached through the generated SDK), with `native` as the explicit assembled-roster option. 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 reachable 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.15",
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: `ptc` by default (the wire collapses to `run_code` and every other tool is reached through the generated SDK), with `native` as the explicit assembled-roster option. High-fan-out tool families (default `['mcp__*', 'browser_*', 'task_board_*', 'team_*', 'squad*', 'ui_*', 'ssh_*']`, while every host builtin stays resident; customizable via `pagedToolPatterns`) stay paged out of the wire and generated SDK 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 reachable 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.17",
5
5
  "icon": "icon.svg",
6
6
  "type": "module",
7
7
  "engines": {
@@ -25,7 +25,7 @@
25
25
  },
26
26
  "dsh": {
27
27
  "engines": {
28
- "dsh": ">=0.2.2-rc.1"
28
+ "dsh": ">=0.2.2-rc.2"
29
29
  },
30
30
  "bundle": {
31
31
  "patch": "./cordis.patch.yml"
@@ -42,25 +42,25 @@
42
42
  }
43
43
  },
44
44
  "peerDependencies": {
45
- "@deepseek-ai/dsh": ">=0.2.2-rc.1"
45
+ "@deepseek-ai/dsh": ">=0.2.2-rc.2"
46
46
  },
47
47
  "dependencies": {
48
48
  "@deepseek-ai/schemastery": "^3.19.0"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@deepseek-ai/cordis": "^4.1.0",
52
- "@deepseek-ai/dsh-agent-preset-registry": "^0.2.2-rc.1",
53
- "@deepseek-ai/dsh-api-remotes": "^0.2.2-rc.1",
54
- "@deepseek-ai/dsh-api-session-controller": "^0.2.2-rc.1",
55
- "@deepseek-ai/dsh-client-connection": "^0.2.2-rc.1",
56
- "@deepseek-ai/dsh-client-locale": "^0.2.2-rc.1",
57
- "@deepseek-ai/dsh-client-store": "^0.2.2-rc.1",
58
- "@deepseek-ai/dsh-client-ui-conversation": "^0.2.2-rc.1",
59
- "@deepseek-ai/dsh-client-ui-renderer": "^0.2.2-rc.1",
60
- "@deepseek-ai/dsh-client-ui-settings": "^0.2.2-rc.1",
61
- "@deepseek-ai/dsh-client-ui-slots": "^0.2.2-rc.1",
62
- "@deepseek-ai/dsh-settings": "^0.2.2-rc.1",
63
- "@deepseek-ai/dsh-system-prompt": "^0.2.2-rc.1",
52
+ "@deepseek-ai/dsh-agent-preset-registry": "^0.2.2-rc.2",
53
+ "@deepseek-ai/dsh-api-remotes": "^0.2.2-rc.2",
54
+ "@deepseek-ai/dsh-api-session-controller": "^0.2.2-rc.2",
55
+ "@deepseek-ai/dsh-client-connection": "^0.2.2-rc.2",
56
+ "@deepseek-ai/dsh-client-locale": "^0.2.2-rc.2",
57
+ "@deepseek-ai/dsh-client-store": "^0.2.2-rc.2",
58
+ "@deepseek-ai/dsh-client-ui-conversation": "^0.2.2-rc.2",
59
+ "@deepseek-ai/dsh-client-ui-renderer": "^0.2.2-rc.2",
60
+ "@deepseek-ai/dsh-client-ui-settings": "^0.2.2-rc.2",
61
+ "@deepseek-ai/dsh-client-ui-slots": "^0.2.2-rc.2",
62
+ "@deepseek-ai/dsh-settings": "^0.2.2-rc.2",
63
+ "@deepseek-ai/dsh-system-prompt": "^0.2.2-rc.2",
64
64
  "@testing-library/react": "^16.1.0",
65
65
  "@types/node": "^22.20.0",
66
66
  "@types/react": "~18.3.1",
@@ -5,24 +5,40 @@
5
5
  # presentation declared for the session's whole lifetime instead of a staged
6
6
  # turn boundary.
7
7
  #
8
- # The presentation is the SDK's ToolPresentationMode, picked by the
8
+ # The presentation is the SDK's tool presentation mode, picked by the
9
9
  # tool-catalog row's `presentation` key (default `'ptc'`): `'native'` keeps
10
- # the assembled roster on the wire, and `'ptc'` collapses the wire to the
11
- # single `run_code` transport with every other tool reached from inside the
12
- # program through the generated SDK. The declaration lands once per agent
13
- # scope through agent.ctx.tools.presentAs as early as the scope exists, and
14
- # degrades to the native surface with a one-time warning when the deployment
15
- # has no code runtime or the host declines. The retired anchor-turn staging is
16
- # gone: the legacy `anchorTools` and boolean `ptcPresentation` keys are still
17
- # accepted (the latter mapping true -> 'ptc' and false -> 'native') but only
18
- # warn once.
10
+ # the roster on the wire, and `'ptc'` collapses the wire to the single
11
+ # `run_code` transport with every other tool reached from inside the program
12
+ # through the generated SDK. The settings overlay turns that key into the
13
+ # `tool-executor-ptc` row below, which is what actually decides the wire:
14
+ # 0.2.2 retired `agent.ctx.tools.presentAs`, so no plugin declares it per
15
+ # scope any more, and a deployment with no code runtime keeps the native
16
+ # surface. The retired anchor-turn staging is gone: the legacy `anchorTools`
17
+ # and boolean `ptcPresentation` keys are still accepted (the latter mapping
18
+ # true -> 'ptc' and false -> 'native') but only warn once.
19
19
  #
20
20
  # Gentle tool paging keeps high-fan-out families out of reach until needed:
21
- # tools matching `pagedToolPatterns` (default `mcp__*`) stay paged out, the
22
- # durable tool-catalog message summarizes their namespaces with an activation
23
- # pointer, and the preset's own `tool_activate` tool (the tool-activate row)
24
- # loads one namespace back — at most three stay active, LRU eviction pages the
25
- # oldest back out. The activation state replays from the durable session event
21
+ # tools matching `pagedToolPatterns` — by default the MCP bridge plus the plugin
22
+ # families `browser_*`, `task_board_*`, `team_*`, `squad*`, `ui_*` and
23
+ # `ssh_*` — stay paged out, the durable tool-catalog message summarizes their
24
+ # namespaces with an activation pointer, and the preset's own `tool_activate`
25
+ # tool (the tool-activate row) loads one namespace back — at most three stay
26
+ # active, LRU eviction pages the oldest back out. The pattern's own head decides
27
+ # the family: a head ending in `__` is an MCP bridge and takes the first `__`
28
+ # segment of the tool name (`mcp__codegraph__x` -> `codegraph`), any other head
29
+ # names the family literally with one trailing `_` dropped (`task_board_*` ->
30
+ # `task_board`), so `squad*` covers `squads_*` and `squad_member_*` alike.
31
+ # Every host builtin the rows below mount stays resident: no shipped pattern
32
+ # names one, so the shell, filesystem, job, skill, delegation, plan, goal and web
33
+ # tools never page.
34
+ # The pattern list is ONE fact shared by THREE rows: `tool-catalog` installs the
35
+ # registry restriction, `tool-activate` replays the log to answer it, and
36
+ # `working-context` renders the resulting active set. All three therefore carry
37
+ # the same shipped list and the settings overlay rewrites all three together: a
38
+ # row left on its own default would disagree about what is active, and the
39
+ # activation tool would refuse to re-activate a namespace the registry had
40
+ # already withheld.
41
+ # The activation state replays from the durable session event
26
42
  # stream on every assembly, so resume and compaction rebuild it without process
27
43
  # memory. Paging is enforced twice, because the wire is not the only surface a
28
44
  # tool can be reached through: the assembled tool list loses the paged families,
@@ -140,8 +156,11 @@
140
156
  # the assembled roster alone. The shipped default is a static-context choice,
141
157
  # not a measured win: the official scaffold comparison ranks this presentation
142
158
  # below the native surface on both code-agent benchmarks, and the bundled
143
- # benchmark matrix is how that trade would be settled locally. `pagedToolPatterns` (default `['mcp__*']`) names the
144
- # high-fan-out families that stay paged out of the wire until activated; the
159
+ # benchmark matrix is how that trade would be settled locally.
160
+ # `pagedToolPatterns` names the high-fan-out families that stay paged out of the
161
+ # wire until activated: the MCP bridge plus the plugin families `browser_*`,
162
+ # `task_board_*`, `team_*`, `squad*`, `ui_*` and `ssh_*`. Every host builtin
163
+ # the rows below mount stays resident, because no shipped pattern names one; the
145
164
  # active set replays from the session event stream, so resume and compaction
146
165
  # rebuild it. `maxResidentTokens` (default 6000, calibrated above the shipped
147
166
  # roster so the guard flags real growth rather than the factory configuration)
@@ -182,18 +201,19 @@
182
201
  config:
183
202
  descriptionMaxLength: 200
184
203
  presentation: 'ptc'
185
- pagedToolPatterns: ['mcp__*']
204
+ pagedToolPatterns: ['mcp__*', 'browser_*', 'task_board_*', 'team_*', 'squad*', 'ui_*', 'ssh_*']
186
205
  maxResidentTokens: 8000
187
206
 
188
207
  # ── the wire ────────────────────────────────────────────────────────────────
189
208
  #
190
- # `presentation` on the `tool-catalog` row above IS the wire. The plugin
191
- # declares it on each agent scope through `agent.ctx.tools.presentAs` as soon
192
- # as the scope exists, then re-assembles so the declaration reaches the
193
- # request the model actually receives; `native` keeps the assembled roster,
194
- # `ptc` collapses it to the single `run_code` transport. A deployment with no
195
- # PTC runtime, a host that declines the declaration, or a wire that offers no
196
- # schema projection keeps the native surface and warns once.
209
+ # `presentation` on the `tool-catalog` row above IS the wire, because the
210
+ # settings overlay turns it into the `tool-executor-ptc` row below: a mounted
211
+ # ptc executor collapses the wire to the single `run_code` transport, and the
212
+ # `native` value disables that row so the roster is what the request carries.
213
+ # The catalog reads the same fact back (a `ptc` setting plus a mounted
214
+ # runtime) because no reader can observe the collapse itself: the ptc
215
+ # executor keeps `run_code` outside the registry, so a schema read returns the
216
+ # same list under both modes.
197
217
  #
198
218
  # This cohort splits execution into an agent-scoped executor row. The row below
199
219
  # selects the same official PTC executor as the builtin ptc preset; the settings
@@ -203,14 +223,26 @@
203
223
  # the settings overlay rewrites the SAME key, so the settings switch and the
204
224
  # composition never disagree.
205
225
 
226
+ # The working-context line folds the SAME active set the catalog pages from, so
227
+ # this row carries the same `pagedToolPatterns` list as the tool-catalog row:
228
+ # two pattern sources would let the rendered line name a namespace active that
229
+ # the registry has already withheld.
206
230
  - id: working-context
207
231
  name: ./working-context.mjs
232
+ config:
233
+ pagedToolPatterns: ['mcp__*', 'browser_*', 'task_board_*', 'team_*', 'squad*', 'ui_*', 'ssh_*']
208
234
 
209
235
  # The paging activation handle the catalog points at: with `pagedToolPatterns`
210
236
  # non-empty this row is what lets `tool_activate({ namespace })` bring one
211
237
  # paged namespace back onto the wire (and the generated SDK) for the session.
238
+ # It carries the SAME list as the tool-catalog and working-context rows, because
239
+ # it replays the log with its own copy: a different list would let it answer
240
+ # "already active" for a namespace the catalog's restriction had withheld,
241
+ # leaving that namespace unreachable for the rest of the session.
212
242
  - id: tool-activate
213
243
  name: ./tool-activate.mjs
244
+ config:
245
+ pagedToolPatterns: ['mcp__*', 'browser_*', 'task_board_*', 'team_*', 'squad*', 'ui_*', 'ssh_*']
214
246
 
215
247
  # The key-fact register: the model pins a hard constraint / confirmed decision /
216
248
  # failed path with `fact_register`, the fold rebuilds the register from the
@@ -530,8 +562,8 @@
530
562
  fetch: false
531
563
  searchTimeoutMs: 60000
532
564
 
533
- # PTC execution is an agent-scoped plugin in this cohort. The declaration
534
- # overlay disables this row for the native presentation; without it, `presentAs`
535
- # can select the wire but no executor can carry a run_code program.
565
+ # PTC execution is an agent-scoped plugin in this cohort, and this row IS the
566
+ # presentation: the settings overlay disables it for the native presentation.
567
+ # Without that executor the wire has no `run_code` to carry a program.
536
568
  - id: tool-executor-ptc
537
569
  name: '@deepseek-ai/dsh-tool-executor-ptc'
@@ -177,9 +177,6 @@ export function isDelegatedCaller(agent, ctx) {
177
177
  if (header?.['origin'] === 'subagent') return true
178
178
 
179
179
  const agents = readService(ctx, 'agents')
180
- if (asRecord(agents) === undefined) return false
181
- const roots = rootsOf(agents)
182
- if (roots === undefined) return false
183
180
  const id = idOf(caller)
184
181
  const get = asRecord(agents)?.['get']
185
182
  if (id !== undefined && typeof get === 'function') {
@@ -191,7 +188,22 @@ export function isDelegatedCaller(agent, ctx) {
191
188
  }
192
189
  if (live !== agent) return false
193
190
  }
194
- return !roots.includes(agent)
191
+
192
+ const roots = asRecord(agents) === undefined ? undefined : rootsOf(agents)
193
+ if (roots !== undefined) return !roots.includes(agent)
194
+
195
+ // Starting in 0.2.2-rc.2 `agents.roots()` was replaced by `subagents.rootOf(caller)`.
196
+ const subagents = readService(ctx, 'subagents')
197
+ const rootOf = asRecord(subagents)?.['rootOf']
198
+ if (typeof rootOf === 'function') {
199
+ try {
200
+ const root = rootOf.call(subagents, agent)
201
+ if (asRecord(root) !== undefined) return root !== agent
202
+ } catch {
203
+ return false
204
+ }
205
+ }
206
+ return false
195
207
  }
196
208
 
197
209
  /**
@@ -356,10 +368,14 @@ export function hasRunningChildSubagent(agent, ctx) {
356
368
  if (ownId !== undefined) parentIds.add(ownId)
357
369
  const headerId = sessionIdOf(caller)
358
370
  if (headerId !== undefined) parentIds.add(headerId)
359
- const running = entriesOf(listed).some(entry =>
360
- entry['status'] === 'running'
361
- && typeof entry['parent'] === 'string'
362
- && parentIds.has(entry['parent']))
371
+ const running = entriesOf(listed).some((entry) => {
372
+ const active = entry['status'] === 'running' || entry['running'] === true
373
+ if (!active) return false
374
+ const directParent = typeof entry['parent'] === 'string'
375
+ ? entry['parent']
376
+ : asRecord(asRecord(entry['session'])?.['header'])?.['parentSession']
377
+ return typeof directParent === 'string' && parentIds.has(directParent)
378
+ })
363
379
  if (running) return true
364
380
  }
365
381
 
@@ -13,12 +13,13 @@
13
13
  * renders the current facts as one of its fields, republished only on change.
14
14
  *
15
15
  * The register itself is a list of single-line facts, newest last, rebuilt by
16
- * replaying `tool/call` events for this tool from the session log — exactly
17
- * the way the paging activation state replays. A fact is a string the model
18
- * writes; registering a new fact APPENDS, and registering one already present
19
- * is a no-op report. REVOCATION is append-only too: a `revoke` entry removes
20
- * every earlier fact carrying the same tag, so the fold stays deterministic
21
- * after resume and compaction without any process memory.
16
+ * replaying this tool's calls out of the session log — exactly the way the
17
+ * paging activation state replays, and from both wire shapes a session records
18
+ * them in ({@link factRegisterCall}). A fact is a string the model writes;
19
+ * registering a new fact APPENDS, and registering one already present is a
20
+ * no-op report. REVOCATION is append-only too: a `revoke` entry removes every
21
+ * earlier fact carrying the same tag, so the fold stays deterministic after
22
+ * resume and compaction without any process memory.
22
23
  *
23
24
  * The tool is deliberately small: it validates and reports, it does not edit
24
25
  * the context itself. The projection the model sees next step is the fold of
@@ -53,17 +54,52 @@ export const MAX_FACT_CHARS = 160
53
54
  /** Cap the register so the ledger cannot itself flood the local window. */
54
55
  export const MAX_FACTS = 12
55
56
 
57
+ /**
58
+ * The call one event contributes to the fold, or undefined when the event is
59
+ * not a `fact_register` call that took effect.
60
+ *
61
+ * The session records the call in one of two shapes, and which one depends on
62
+ * the presentation the session runs. `native` records a top-level `tool/call`
63
+ * whose `arguments` is the JSON string the model emitted. `ptc` — the shipped
64
+ * default — collapses the wire to `run_code` and reaches every other tool from
65
+ * inside a program, which the runtime records as `tool/ptc-dispatch`: its
66
+ * `arguments` is already an object, and a dispatch that failed carries its own
67
+ * `isError` on the dispatch record (`event.data.isError`), not on the event
68
+ * envelope. Reading only `tool/call` therefore folded an empty register in
69
+ * every factory-default session — pin and revoke both reported success while no
70
+ * `key facts` field ever rendered — which is the same gap `paging.mjs` replays
71
+ * both shapes to avoid.
72
+ *
73
+ * A dispatch that reported an error never took effect, so it contributes
74
+ * nothing: a failed pin must not pin, and a failed revoke must not drop a fact
75
+ * that still stands. `tool/ptc-dispatch-start` only announces a dispatch that
76
+ * has not settled yet, so the event-type check below leaves it out. The
77
+ * `native` half keeps its existing semantics untouched: a `tool/call` is read
78
+ * whatever its `tool/result` later reported, exactly as before this change.
79
+ */
80
+ function factRegisterCall(event) {
81
+ if (event?.type === 'tool/ptc-dispatch') {
82
+ const dispatch = event.data
83
+ if (dispatch?.name !== FACT_LEDGER_TOOL || dispatch?.isError === true) return undefined
84
+ return dispatch
85
+ }
86
+ if (event?.type !== 'tool/call' || event.data?.name !== FACT_LEDGER_TOOL) return undefined
87
+ return event.data
88
+ }
89
+
56
90
  /**
57
91
  * Fold the current fact register from the event stream: every successful
58
- * `fact_register` call appends its fact (or revokes by tag). Facts carry no
59
- * ids — revocation matches on the optional `tag`, and an untagged fact can
60
- * only be revoked by revoking its exact text as the tag of last resort.
92
+ * `fact_register` call appends its fact (or revokes by tag), whichever wire
93
+ * shape recorded it. Facts carry no ids — revocation matches on the optional
94
+ * `tag`, and an untagged fact can only be revoked by revoking its exact text as
95
+ * the tag of last resort.
61
96
  */
62
97
  export function foldFactLedger(events) {
63
98
  const facts = []
64
99
  for (const event of Array.isArray(events) ? events : []) {
65
- if (event?.type !== 'tool/call' || event.data?.name !== FACT_LEDGER_TOOL) continue
66
- let args = event.data?.arguments
100
+ const data = factRegisterCall(event)
101
+ if (data === undefined) continue
102
+ let args = data.arguments
67
103
  if (typeof args === 'string') {
68
104
  try { args = JSON.parse(args) } catch { args = undefined }
69
105
  }