@joekytc/dsh-swarm 0.3.6 → 0.3.7
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/config.d.ts +6 -0
- package/lib/config.js +1 -0
- package/lib/dispatcher/dispatcher.js +7 -3
- package/lib/roles/toolsets.d.ts +16 -4
- package/lib/roles/toolsets.js +22 -5
- package/package.json +1 -1
package/lib/config.d.ts
CHANGED
|
@@ -80,5 +80,11 @@ export interface KanbanConfig {
|
|
|
80
80
|
model: string;
|
|
81
81
|
};
|
|
82
82
|
};
|
|
83
|
+
/** wiki_write 会话级放行的 preset id 白名单(buildStandaloneDtGuard 非独立分支热读)。
|
|
84
|
+
* 默认:插件自有 'swarm'(蜂群 preset)/'kanban-w'(W preset)+ 宿主内置 'ptc'
|
|
85
|
+
* (2026-09-16 实测:dsh web「蜂群模式」标签会话的 header.agentPreset 实际为宿主
|
|
86
|
+
* PTC 模式 id)。宿主 preset 体系演化/部署自定义模式 id 时改配置即可,无需改代码。
|
|
87
|
+
* 写面仍由 wiki_write 工具内 assertAllowedWikiPagePath 五类命名空间白名单硬约束。 */
|
|
88
|
+
wikiWritePresets: string[];
|
|
83
89
|
}
|
|
84
90
|
export declare const Config: Schema<KanbanConfig>;
|
package/lib/config.js
CHANGED
|
@@ -467,9 +467,13 @@ function startDispatcherInner(ctx, configProvider, storageDir, logFile, provider
|
|
|
467
467
|
}
|
|
468
468
|
// 独立评审硬闸:header.agentPreset==='kanban-dt' 且未经角色组合(session id 非 kbn-
|
|
469
469
|
// 前缀)时收紧(看板写工具拒、bash/run_code 仅只读 git+clone/fetch、wiki_write 仅
|
|
470
|
-
// reviews 命名空间);wiki_write
|
|
471
|
-
// 时注销(与 subagent/swarm guard 同款)。
|
|
472
|
-
const unguardStandalone = toolsSvc?.guard?.(buildStandaloneDtGuard(
|
|
470
|
+
// reviews 命名空间);wiki_write 对非评审会话全局收紧(链上组合会话/swarm 主会话/
|
|
471
|
+
// W preset 会话放行)。dispose 时注销(与 subagent/swarm guard 同款)。
|
|
472
|
+
const unguardStandalone = toolsSvc?.guard?.(buildStandaloneDtGuard({
|
|
473
|
+
// wiki_write 放行白名单热读配置(applyOverride 后下次工具调用即生效);
|
|
474
|
+
// config 缺字段回 [] fail-closed(默认值由 config.ts schema 保证存在)。
|
|
475
|
+
getWikiWritePresets: () => configProvider.getEffective().wikiWritePresets ?? [],
|
|
476
|
+
}));
|
|
473
477
|
if (unguardStandalone) {
|
|
474
478
|
ctx.on('dispose', unguardStandalone);
|
|
475
479
|
}
|
package/lib/roles/toolsets.d.ts
CHANGED
|
@@ -96,10 +96,21 @@ export declare function buildSwarmSessionGuard(): (execution: {
|
|
|
96
96
|
* 落盘是 git 自身行为,BASH_WRITE_RE 无此二动词天然放行,无需特判);
|
|
97
97
|
* 3. wiki_write(独立模式)→ 仅放行 projects/<repo>/reviews/<主题>-<日期>/ 命名空间;
|
|
98
98
|
* 4. wiki_write(非独立会话)→ 链上组合会话(isRoleComposed)放行(自有 agent-scope
|
|
99
|
-
* guard 管,链命名空间写入绝不被本 guard
|
|
100
|
-
*
|
|
99
|
+
* guard 管,链命名空间写入绝不被本 guard 误拦);swarm 主会话与 W preset 会话放行
|
|
100
|
+
* (2026-09-16 放宽,写面由工具内路径白名单约束);其余(main/未知 GUI)拒绝
|
|
101
|
+
* ——评审工具全局注册后 wiki_write 收紧到评审/知识会话;
|
|
101
102
|
* 5. 其余工具(read/glob/grep/ocr_review/wiki_read/wiki_search 等)→ 放行。 */
|
|
102
|
-
|
|
103
|
+
/** wiki_write 会话级放行 preset 默认白名单:与 config.ts wikiWritePresets 默认值同源,
|
|
104
|
+
* 仅供 guard deps 未接线(测试/裸调用)时兜底;生产经 dispatcher 注入热读配置。
|
|
105
|
+
* 'ptc'(2026-09-16 实测):dsh web「蜂群模式」标签会话的 header.agentPreset 实际为
|
|
106
|
+
* 宿主内置 PTC 模式 id 'ptc'(presets/ptc,非插件 'swarm')——UI 标签与 header id 不同源。 */
|
|
107
|
+
export declare const DEFAULT_WIKI_WRITE_PRESETS: ReadonlyArray<string>;
|
|
108
|
+
export interface StandaloneDtGuardDeps {
|
|
109
|
+
/** wiki_write 放行 preset 白名单热读(dispatcher 注入 () => getEffective().wikiWritePresets;
|
|
110
|
+
* 缺省回落 DEFAULT_WIKI_WRITE_PRESETS——测试与未接线场景保持默认行为)。 */
|
|
111
|
+
getWikiWritePresets?: () => ReadonlyArray<string>;
|
|
112
|
+
}
|
|
113
|
+
export declare function buildStandaloneDtGuard(deps?: StandaloneDtGuardDeps): (execution: {
|
|
103
114
|
name?: string;
|
|
104
115
|
arguments?: unknown;
|
|
105
116
|
agent?: unknown;
|
|
@@ -107,7 +118,8 @@ export declare function buildStandaloneDtGuard(): (execution: {
|
|
|
107
118
|
/** 独立评审工具全局注册:ocr_review + wiki 三原语(wiki_read/wiki_search/wiki_write)。
|
|
108
119
|
* 独立评审不经 agent-runner 角色组合,角色工具面不存在,故在插件全局 ctx 注册;
|
|
109
120
|
* caller 固定 actor='dt'(can('wiki-write','dt')=true),wiki_write 的会话级收紧由
|
|
110
|
-
* buildStandaloneDtGuard
|
|
121
|
+
* buildStandaloneDtGuard 完成(链上组合会话/swarm 主会话/W preset 会话放行,
|
|
122
|
+
* main/未知 GUI 拒绝)。
|
|
111
123
|
* wiki 客户端按 kbMode 构造(与 registerMainSessionTools 同源:remote 优先 ctx.get('wiki')
|
|
112
124
|
* 注入(测试 mock),生产热读取 getEffective().wikiVault;local 走 LocalWikiClient)。
|
|
113
125
|
* local 模式不注册 wiki_write:LocalWikiClient.abs 只接受 wiki/** 形态,而 wiki_write
|
package/lib/roles/toolsets.js
CHANGED
|
@@ -581,10 +581,16 @@ function dualVerbGitDenyReason(verb, rest, deny) {
|
|
|
581
581
|
* 落盘是 git 自身行为,BASH_WRITE_RE 无此二动词天然放行,无需特判);
|
|
582
582
|
* 3. wiki_write(独立模式)→ 仅放行 projects/<repo>/reviews/<主题>-<日期>/ 命名空间;
|
|
583
583
|
* 4. wiki_write(非独立会话)→ 链上组合会话(isRoleComposed)放行(自有 agent-scope
|
|
584
|
-
* guard 管,链命名空间写入绝不被本 guard
|
|
585
|
-
*
|
|
584
|
+
* guard 管,链命名空间写入绝不被本 guard 误拦);swarm 主会话与 W preset 会话放行
|
|
585
|
+
* (2026-09-16 放宽,写面由工具内路径白名单约束);其余(main/未知 GUI)拒绝
|
|
586
|
+
* ——评审工具全局注册后 wiki_write 收紧到评审/知识会话;
|
|
586
587
|
* 5. 其余工具(read/glob/grep/ocr_review/wiki_read/wiki_search 等)→ 放行。 */
|
|
587
|
-
|
|
588
|
+
/** wiki_write 会话级放行 preset 默认白名单:与 config.ts wikiWritePresets 默认值同源,
|
|
589
|
+
* 仅供 guard deps 未接线(测试/裸调用)时兜底;生产经 dispatcher 注入热读配置。
|
|
590
|
+
* 'ptc'(2026-09-16 实测):dsh web「蜂群模式」标签会话的 header.agentPreset 实际为
|
|
591
|
+
* 宿主内置 PTC 模式 id 'ptc'(presets/ptc,非插件 'swarm')——UI 标签与 header id 不同源。 */
|
|
592
|
+
export const DEFAULT_WIKI_WRITE_PRESETS = ['swarm', 'kanban-w', 'ptc'];
|
|
593
|
+
export function buildStandaloneDtGuard(deps = {}) {
|
|
588
594
|
return (execution) => {
|
|
589
595
|
const header = extractSessionHeader(execution?.agent);
|
|
590
596
|
const name = String(execution?.name ?? '');
|
|
@@ -648,7 +654,17 @@ export function buildStandaloneDtGuard() {
|
|
|
648
654
|
if (name === 'wiki_write') {
|
|
649
655
|
if (isRoleComposed(execution?.agent) || isDtChainSubagent)
|
|
650
656
|
return undefined;
|
|
651
|
-
|
|
657
|
+
// 放宽(2026-09-16):swarm 主会话与 W preset 会话可写 wiki——can('wiki-write') 本就含 w
|
|
658
|
+
// (permissions.ts),写面由 wiki_write 工具内 assertAllowedWikiPagePath 五类命名空间
|
|
659
|
+
// 白名单硬约束;local 模式 wiki_write 未全局注册,无工具面即无暴露面。
|
|
660
|
+
// 放行面配置化(硬规则 6):白名单经 deps 热读 config.wikiWritePresets,宿主 preset
|
|
661
|
+
// 体系演化/部署自定义模式 id 时改配置即可;config 缺字段回 [](fail-closed,仅内置默认兜底测试)。
|
|
662
|
+
const preset = header?.agentPreset;
|
|
663
|
+
const allowed = deps.getWikiWritePresets?.() ?? DEFAULT_WIKI_WRITE_PRESETS;
|
|
664
|
+
if (preset !== undefined && allowed.includes(preset))
|
|
665
|
+
return undefined;
|
|
666
|
+
// 诊断尾巴:报错带实际 preset(或"无"),用户重试一次即可定位会话模式判定缺口
|
|
667
|
+
return 'wiki-write-restricted-to-reviewer-sessions: wiki_write 仅限 DT 评审会话 / W 角色 / swarm 主会话使用(当前会话 preset=' + (preset ?? '无') + ')';
|
|
652
668
|
}
|
|
653
669
|
return undefined;
|
|
654
670
|
};
|
|
@@ -656,7 +672,8 @@ export function buildStandaloneDtGuard() {
|
|
|
656
672
|
/** 独立评审工具全局注册:ocr_review + wiki 三原语(wiki_read/wiki_search/wiki_write)。
|
|
657
673
|
* 独立评审不经 agent-runner 角色组合,角色工具面不存在,故在插件全局 ctx 注册;
|
|
658
674
|
* caller 固定 actor='dt'(can('wiki-write','dt')=true),wiki_write 的会话级收紧由
|
|
659
|
-
* buildStandaloneDtGuard
|
|
675
|
+
* buildStandaloneDtGuard 完成(链上组合会话/swarm 主会话/W preset 会话放行,
|
|
676
|
+
* main/未知 GUI 拒绝)。
|
|
660
677
|
* wiki 客户端按 kbMode 构造(与 registerMainSessionTools 同源:remote 优先 ctx.get('wiki')
|
|
661
678
|
* 注入(测试 mock),生产热读取 getEffective().wikiVault;local 走 LocalWikiClient)。
|
|
662
679
|
* local 模式不注册 wiki_write:LocalWikiClient.abs 只接受 wiki/** 形态,而 wiki_write
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@joekytc/dsh-swarm",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.7",
|
|
4
4
|
"description": "A governed swarm of six specialist DSH agents (orchestrator, planner, knowledge-base bridge, developer and two reviewers) that turns a requirement into a strict phase pipeline with machine-verified delivery evidence, review-gated merges, a full audit-log event stream and a live kanban tab; design inspired by the Hermes Agent kanban",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "joekytc",
|