dsh-bufeng 0.0.0-stage → 0.64.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +68 -2
- package/bufeng.patch.yml +3 -0
- package/client/build-client.mjs +159 -0
- package/client/client.js +4038 -0
- package/client/src/board.js +133 -0
- package/client/src/capabilities.js +787 -0
- package/client/src/cards.js +263 -0
- package/client/src/data.js +43 -0
- package/client/src/graph.js +558 -0
- package/client/src/icons.js +88 -0
- package/client/src/projects.js +467 -0
- package/client/src/prompt.js +55 -0
- package/client/src/react.js +7 -0
- package/client/src/settings.js +407 -0
- package/client/src/styles.js +611 -0
- package/client/src/taskboard.js +321 -0
- package/client/src/taskgraph.js +145 -0
- package/client/src/ui.js +72 -0
- package/lib/acceptance-subject.js +71 -0
- package/lib/board/server.js +546 -0
- package/lib/board/snapshot.js +133 -0
- package/lib/board/taskview.js +151 -0
- package/lib/bootstrap.js +77 -0
- package/lib/catalog.js +385 -0
- package/lib/core.js +478 -0
- package/lib/data/capability-alias-catalog.json +301 -0
- package/lib/data/capability-alias.json +25 -0
- package/lib/domain.js +1342 -0
- package/lib/host-probe.js +176 -0
- package/lib/identity-hook.js +490 -0
- package/lib/index.js +119 -0
- package/lib/lessons.js +134 -0
- package/lib/metering.js +109 -0
- package/lib/scope.js +389 -0
- package/lib/session/child-watch.js +86 -0
- package/lib/session/evidence.js +118 -0
- package/lib/session/node-session.js +335 -0
- package/lib/session/queue.js +307 -0
- package/lib/session/reconcile.js +500 -0
- package/lib/tools/capabilities.js +1461 -0
- package/lib/tools/governance.js +579 -0
- package/lib/tools/index.js +33 -0
- package/lib/tools/project.js +500 -0
- package/lib/tools/readonly.js +566 -0
- package/lib/tools/recover.js +402 -0
- package/lib/tools/run.js +1609 -0
- package/lib/tools/skills.js +162 -0
- package/lib/tools/trees.js +637 -0
- package/lib/workspace-rmw.js +365 -0
- package/package.json +42 -4
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* client/src/settings.js — ⚙ 设置页(v0.16.5):治理配置分区卡片 + 全字段可编辑。
|
|
3
|
+
* 分区:🧭 总管身份(autoAdopt 开关)/ ⚖️ 调度与预算(并发闸门/日预算/预警线)/ 📁 项目目录(projectsRoot/defaultWorkspaceDir)。
|
|
4
|
+
* v0.26.x 第三单 T2(面板工程):defaultWorkspace 卡片从只读展示改真配置输入框(同 projectsRoot 的 EditRow 样式),
|
|
5
|
+
* 配置字段 gate.defaultWorkspaceDir(子目录名语义,默认 bufeng-ws);快照字段仍用既有 defaultWorkspace(值来自配置带回退)。
|
|
6
|
+
* 非 ASCII 输入本地即时红字警告(warnOf 插槽,不等服务端往返);服务端 400 校验文案沿用 EditRow err 槽透出。
|
|
7
|
+
* 编辑交互:字段失焦或回车即保存(POST /bufeng/api/config,与 bufeng_config 工具同校验规则,越界自动钳制);
|
|
8
|
+
* draft 状态防 SSE 2s 刷新覆盖正在编辑的输入框。快照自带 gate 兜底默认值。
|
|
9
|
+
*/
|
|
10
|
+
import { h, useState } from './react.js';
|
|
11
|
+
import { LINE, DIM, LABEL } from './ui.js';
|
|
12
|
+
import { RoleIconMd } from './icons.js';
|
|
13
|
+
|
|
14
|
+
const inputStyle = {
|
|
15
|
+
background: 'var(--dsw-alias-bg-layer-1, rgba(255,255,255,.04))',
|
|
16
|
+
border: '1px solid ' + LINE, borderRadius: 6, color: 'inherit',
|
|
17
|
+
font: 'var(--ds-font-family-code, monospace)', fontSize: 12, padding: '5px 8px', outline: 'none'
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
async function postConfig(patch) {
|
|
21
|
+
const res = await fetch('/bufeng/api/config', {
|
|
22
|
+
method: 'POST',
|
|
23
|
+
headers: { 'content-type': 'application/json' },
|
|
24
|
+
body: JSON.stringify(patch)
|
|
25
|
+
});
|
|
26
|
+
const body = await res.json().catch(() => ({}));
|
|
27
|
+
if (!res.ok || body.ok === false) throw new Error(body.error || 'HTTP ' + res.status);
|
|
28
|
+
return body;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* v0.26.x defaultWorkspaceDir 专用:非 ASCII 本地即时警告(宿主对非 ASCII 路径存在会话归组 bug,掉组风险;建议不阻断) */
|
|
32
|
+
const wsDirWarnOf = (v) => /[^\x00-\x7F]/.test(String(v ?? ''))
|
|
33
|
+
? '⚠ 含非 ASCII 字符:宿主对非 ASCII 路径存在会话归组 bug(掉组),建议 ASCII'
|
|
34
|
+
: null;
|
|
35
|
+
|
|
36
|
+
/* v0.43.1 阶段1C(k-mvla504o12i):覆盖硬闸三态枚举(与 lib/core.js GATE.coverageGate 合法值一一对应,勿单方变更) */
|
|
37
|
+
const COV_STATES = [
|
|
38
|
+
{ id: 'off', label: 'off · 关停' },
|
|
39
|
+
{ id: 'shadow', label: 'shadow · 影子' },
|
|
40
|
+
{ id: 'enforce', label: 'enforce · 强制' }
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
/* v0.46.0 面板棒(k-mvnpelij0ha):能力面宣传三态枚举(与 lib/core.js GATE.capabilityPrompt 合法值一一对应,勿单方变更) */
|
|
44
|
+
const CAP_STATES = [
|
|
45
|
+
{ id: 'off', label: 'off · 关停' },
|
|
46
|
+
{ id: 'brief', label: 'brief · 摘要' },
|
|
47
|
+
{ id: 'full', label: 'full · 全量' }
|
|
48
|
+
];
|
|
49
|
+
/* W2-T4(k-mvsc8xhx0qv):派单中转闸三态枚举(与 lib/core.js GATE.relayGate 合法值一一对应,勿单方变更;ADR 字面锚 data-bf-relgate/data-bf-relcur,勿更名) */
|
|
50
|
+
const REL_STATES = [
|
|
51
|
+
{ id: 'off', label: 'off · 关停' },
|
|
52
|
+
{ id: 'shadow', label: 'shadow · 影子' },
|
|
53
|
+
{ id: 'enforce', label: 'enforce · 强制' }
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
function Toggle({ on, busy, onClick, buttonExtra }) {
|
|
57
|
+
return h('button', {
|
|
58
|
+
...buttonExtra, // k-mvi7fdym0jr:额外按钮属性(data-bf-* 锚供 sim 定位,仿 EditRow inputExtra 先例)
|
|
59
|
+
onClick,
|
|
60
|
+
disabled: busy,
|
|
61
|
+
title: on ? '点击关闭' : '点击开启',
|
|
62
|
+
style: {
|
|
63
|
+
border: 'none', cursor: busy ? 'wait' : 'pointer', width: 40, height: 22, borderRadius: 11,
|
|
64
|
+
padding: 0, position: 'relative', transition: 'background .15s', flexShrink: 0,
|
|
65
|
+
background: on ? 'var(--dsw-alias-state-success-primary, #2f9e44)' : 'var(--dsw-alias-state-idle-primary, #555)'
|
|
66
|
+
}
|
|
67
|
+
}, h('span', {
|
|
68
|
+
style: {
|
|
69
|
+
position: 'absolute', top: 2, left: on ? 20 : 2, width: 18, height: 18, borderRadius: '50%',
|
|
70
|
+
background: '#fff', transition: 'left .15s', boxShadow: '0 1px 3px rgba(0,0,0,.4)'
|
|
71
|
+
}
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* 分区卡片:图标+标题+副题,突出配置分类(v0.16.5) */
|
|
76
|
+
function Section({ icon, title, desc, children, id }) {
|
|
77
|
+
return h('div', { id, style: { border: '1px solid ' + LINE, borderRadius: 10, padding: '14px 16px', marginBottom: 14, background: 'var(--dsw-alias-bg-layer-1, transparent)' } },
|
|
78
|
+
h('div', { style: { display: 'flex', alignItems: 'baseline', gap: 8, marginBottom: desc ? 2 : 8 } },
|
|
79
|
+
h('span', { style: { fontSize: 14 } }, icon),
|
|
80
|
+
h('span', { style: { font: 'var(--dsw-font-xs-strong-13, 600 13px/1.5 sans-serif)', ...LABEL } }, title),
|
|
81
|
+
desc ? h('span', { style: { ...DIM, fontSize: 11 } }, desc) : null),
|
|
82
|
+
children);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* v0.24.0 星枢角色图例(设置页落位之一):三角色 24 档展示,与看板卡/任务行同款图标 */
|
|
86
|
+
function legendItem(kind, uid, name, desc) {
|
|
87
|
+
return h('div', { style: { display: 'flex', alignItems: 'center', gap: 8 } },
|
|
88
|
+
h(RoleIconMd, { kind, uid }),
|
|
89
|
+
h('div', null,
|
|
90
|
+
h('div', { style: { font: 'var(--dsw-font-xs-strong-13, 600 13px/1.5 sans-serif)', ...LABEL } }, name),
|
|
91
|
+
h('div', { style: { ...DIM, fontSize: 11 } }, desc)));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/* 可编辑配置行:右侧紧凑输入框,失焦/回车保存,Esc 取消。
|
|
95
|
+
warnOf=(val)=>string|null 本地即时警告(红字,随输入变化,不依赖服务端往返);inputExtra=额外挂到 input 的属性(data-bf-* 锚供 sim 定位);
|
|
96
|
+
服务端 400 错误文案经 err 槽红字透出(沿用既有展示模式)。 */
|
|
97
|
+
function EditRow({ label, hint, value, width, onSave, parse, suffix, warnOf, inputExtra }) {
|
|
98
|
+
const [draft, setDraft] = useState(null); // null=显示快照值;非 null=正在编辑(防 SSE 刷新覆盖)
|
|
99
|
+
const [busy, setBusy] = useState(false);
|
|
100
|
+
const [err, setErr] = useState(null);
|
|
101
|
+
const shown = draft ?? String(value ?? '');
|
|
102
|
+
const warn = warnOf ? warnOf(shown) : null; // 本地即时警告:随草稿值即时显隐
|
|
103
|
+
const commit = async () => {
|
|
104
|
+
if (draft === null || busy) return;
|
|
105
|
+
const raw = draft.trim();
|
|
106
|
+
if (raw === String(value ?? '')) { setDraft(null); setErr(null); return; } // 没改
|
|
107
|
+
setBusy(true); setErr(null);
|
|
108
|
+
try {
|
|
109
|
+
await onSave(parse ? parse(raw) : raw);
|
|
110
|
+
setDraft(null);
|
|
111
|
+
} catch (e) {
|
|
112
|
+
setErr(e.message);
|
|
113
|
+
} finally { setBusy(false); }
|
|
114
|
+
};
|
|
115
|
+
return h('div', { style: { display: 'flex', alignItems: 'center', gap: 12, padding: '10px 0', borderBottom: '1px solid ' + LINE } },
|
|
116
|
+
h('div', { style: { flex: 1, minWidth: 0 } },
|
|
117
|
+
h('div', { style: { font: 'var(--dsw-font-xs-strong-13, 600 13px/1.5 sans-serif)', ...LABEL } }, label),
|
|
118
|
+
h('div', { style: { ...DIM, fontSize: 11, marginTop: 2 } }, hint)),
|
|
119
|
+
h('div', { style: { display: 'flex', flexDirection: 'column', alignItems: 'flex-end', gap: 2 } },
|
|
120
|
+
h('div', { style: { display: 'flex', alignItems: 'center', gap: 4 } },
|
|
121
|
+
h('input', {
|
|
122
|
+
...inputExtra,
|
|
123
|
+
value: shown,
|
|
124
|
+
disabled: busy,
|
|
125
|
+
onChange: (e) => setDraft(e.target.value),
|
|
126
|
+
onBlur: commit,
|
|
127
|
+
onKeyDown: (e) => { if (e.key === 'Enter') commit(); if (e.key === 'Escape') { setDraft(null); setErr(null); } },
|
|
128
|
+
style: { ...inputStyle, width: width ?? 110, textAlign: 'right', opacity: busy ? .6 : 1, borderColor: err ? 'var(--dsw-alias-state-error-primary, #e5484d)' : LINE }
|
|
129
|
+
}),
|
|
130
|
+
suffix ? h('span', { style: { ...DIM, fontSize: 11, width: 30 } }, suffix) : null),
|
|
131
|
+
warn ? h('span', { 'data-bf-editwarn': '1', style: { fontSize: 11, color: 'var(--dsw-alias-state-error-label, #e5484d)' } }, warn) : null,
|
|
132
|
+
err ? h('span', { 'data-bf-editerr': '1', style: { fontSize: 11, color: 'var(--dsw-alias-state-error-label, #e5484d)' } }, err) : null));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export function SettingsPane({ snap }) {
|
|
136
|
+
const gate = snap.gate || {};
|
|
137
|
+
// v0.23.0 项目根 hint:优先快照 projectsRootDefaultNote(有值=未改配,展示 note);空串/字段缺失=当前值+回退语义说明
|
|
138
|
+
const rootNote = snap.projectsRootDefaultNote;
|
|
139
|
+
const projectsRootHint = rootNote ? rootNote + ';必须是绝对路径;改后新建项目落新根,已有项目路径不变' : '当前 ' + (gate.projectsRoot ?? '~/.dsh/bufeng/projects') + ';未改配时新建项目落 DSH 工作区根下同名目录(发现失败回退 ~/.dsh/bufeng/projects);必须是绝对路径;改后新建项目落新根,已有项目路径不变';
|
|
140
|
+
const [busy, setBusy] = useState(false); // autoAdopt 开关 busy
|
|
141
|
+
const [busyHook, setBusyHook] = useState(false); // identityHook 开关 busy
|
|
142
|
+
const [busyArch, setBusyArch] = useState(false); // autoArchiveSessions 开关 busy
|
|
143
|
+
const [busyKeep, setBusyKeep] = useState(false); // k-mvi7fdym0jr:keepDefault 开关 busy(同上)
|
|
144
|
+
const [setTab, setSetTab] = useState('set-id');
|
|
145
|
+
// v0.40.7:未知分区 id 自愈回退首分区(防陈旧/异常状态值把左侧导航打成零 active——导航恒有一格在位)
|
|
146
|
+
const navItems = [
|
|
147
|
+
{ id: 'set-id', icon: '🧭', label: '总管与入口' },
|
|
148
|
+
{ id: 'set-sess', icon: '🗂', label: '会话策略' },
|
|
149
|
+
{ id: 'set-model', icon: '🧠', label: '模型治理' },
|
|
150
|
+
{ id: 'set-budget', icon: '⚖️', label: '调度与预算' },
|
|
151
|
+
{ id: 'set-dir', icon: '📁', label: '项目目录' },
|
|
152
|
+
{ id: 'set-legend', icon: '🧩', label: '角色图例' }
|
|
153
|
+
];
|
|
154
|
+
const activeTab = navItems.some((it) => it.id === setTab) ? setTab : navItems[0].id;
|
|
155
|
+
const jump = (id) => { setSetTab(id); try { document.getElementById(id)?.scrollIntoView({ behavior: 'smooth', block: 'start' }); } catch (e) { /* noop */ } };
|
|
156
|
+
const [msg, setMsg] = useState(null);
|
|
157
|
+
const autoAdopt = gate.autoAdopt === true;
|
|
158
|
+
const identityHook = gate.identityHook !== false; // 默认开
|
|
159
|
+
const keepDefault = gate.keepDefault !== false; // 同上:默认模型跟随总管(v0.35.0 GATE 键,此前 client 零引用=真缺口)
|
|
160
|
+
const fmtTokens = (n) => n >= 1e8 ? (n / 1e8) + ' 亿' : n >= 1e4 ? (n / 1e4) + ' 万' : String(n ?? '—');
|
|
161
|
+
|
|
162
|
+
const flip = async () => {
|
|
163
|
+
setBusy(true); setMsg(null);
|
|
164
|
+
try {
|
|
165
|
+
const out = await postConfig({ autoAdopt: !autoAdopt });
|
|
166
|
+
setMsg({ ok: true, text: '已' + (out.changed && out.changed.autoAdopt !== undefined ? (out.changed.autoAdopt ? '开启' : '关闭') : (autoAdopt ? '关闭' : '开启')) + '总管自动入名单' });
|
|
167
|
+
} catch (e) {
|
|
168
|
+
setMsg({ ok: false, text: '设置失败:' + e.message });
|
|
169
|
+
} finally { setBusy(false); }
|
|
170
|
+
};
|
|
171
|
+
const flipHook = async () => {
|
|
172
|
+
setBusyHook(true); setMsg(null);
|
|
173
|
+
try {
|
|
174
|
+
const out = await postConfig({ identityHook: !identityHook });
|
|
175
|
+
setMsg({ ok: true, text: '已' + (out.changed && out.changed.identityHook !== undefined ? (out.changed.identityHook ? '开启' : '关闭') : (identityHook ? '关闭' : '开启')) + '入口注入钩子' });
|
|
176
|
+
} catch (e) {
|
|
177
|
+
setMsg({ ok: false, text: '设置失败:' + e.message });
|
|
178
|
+
} finally { setBusyHook(false); }
|
|
179
|
+
};
|
|
180
|
+
const flipArch = async () => {
|
|
181
|
+
setBusyArch(true); setMsg(null);
|
|
182
|
+
try {
|
|
183
|
+
const out = await postConfig({ autoArchiveSessions: gate.autoArchiveSessions !== true });
|
|
184
|
+
setMsg({ ok: true, text: '已' + (out.changed && out.changed.autoArchiveSessions !== undefined ? (out.changed.autoArchiveSessions ? '开启' : '关闭') : (gate.autoArchiveSessions === true ? '关闭' : '开启')) + '自动归档会话' });
|
|
185
|
+
} catch (e) {
|
|
186
|
+
setMsg({ ok: false, text: '设置失败:' + e.message });
|
|
187
|
+
} finally { setBusyArch(false); }
|
|
188
|
+
};
|
|
189
|
+
const flipKeep = async () => {
|
|
190
|
+
setBusyKeep(true); setMsg(null);
|
|
191
|
+
try {
|
|
192
|
+
const out = await postConfig({ keepDefault: !keepDefault });
|
|
193
|
+
setMsg({ ok: true, text: '已' + (out.changed && out.changed.keepDefault !== undefined ? (out.changed.keepDefault ? '开启' : '关闭') : (keepDefault ? '关闭' : '开启')) + '默认模型跟随总管' });
|
|
194
|
+
} catch (e) {
|
|
195
|
+
setMsg({ ok: false, text: '设置失败:' + e.message });
|
|
196
|
+
} finally { setBusyKeep(false); }
|
|
197
|
+
};
|
|
198
|
+
/* v0.43.1 阶段1C(k-mvla504o12i):覆盖硬闸三态卡(coverageGate)——三值选中即提交(POST /bufeng/api/config
|
|
199
|
+
走 applyGatePatch 同一权威,与 bufeng_config 工具双通道等价);成功回执+失败错误直显(无草稿提交语义,
|
|
200
|
+
当前值只在快照回显后翻转=失败自动保持现值不漂移)。 */
|
|
201
|
+
const covGate = ['off', 'shadow', 'enforce'].includes(gate.coverageGate) ? gate.coverageGate : 'shadow'; // 缺省/非法存量值读取侧按 shadow(与 core.js GATE 口径一致)
|
|
202
|
+
const [busyCov, setBusyCov] = useState(false);
|
|
203
|
+
const flipCov = async (v) => {
|
|
204
|
+
setBusyCov(true); setMsg(null);
|
|
205
|
+
try {
|
|
206
|
+
const out = await postConfig({ coverageGate: v });
|
|
207
|
+
setMsg({ ok: true, text: '已设置覆盖硬闸 coverageGate=' + (out.changed && out.changed.coverageGate !== undefined ? out.changed.coverageGate : v) });
|
|
208
|
+
} catch (e) {
|
|
209
|
+
setMsg({ ok: false, text: '设置失败:' + e.message });
|
|
210
|
+
} finally { setBusyCov(false); }
|
|
211
|
+
};
|
|
212
|
+
/* v0.46.0 面板棒(k-mvnpelij0ha):能力面宣传三态卡(capabilityPrompt)——coverageGate 三态卡同法:三值选中即提交
|
|
213
|
+
(POST /bufeng/api/config 走 applyGatePatch 同一权威,与 bufeng_config 工具双通道等价);成功回执+失败错误直显;
|
|
214
|
+
缺省/非法存量值读取侧按 off 显示(与 lib/core.js GATE 口径一致——off=零注入零 token)。 */
|
|
215
|
+
const capGate = ['off', 'brief', 'full'].includes(gate.capabilityPrompt) ? gate.capabilityPrompt : 'off';
|
|
216
|
+
const [busyCap, setBusyCap] = useState(false);
|
|
217
|
+
const flipCap = async (v) => {
|
|
218
|
+
setBusyCap(true); setMsg(null);
|
|
219
|
+
try {
|
|
220
|
+
const out = await postConfig({ capabilityPrompt: v });
|
|
221
|
+
setMsg({ ok: true, text: '已设置能力面宣传 capabilityPrompt=' + (out.changed && out.changed.capabilityPrompt !== undefined ? out.changed.capabilityPrompt : v) });
|
|
222
|
+
} catch (e) {
|
|
223
|
+
setMsg({ ok: false, text: '设置失败:' + e.message });
|
|
224
|
+
} finally { setBusyCap(false); }
|
|
225
|
+
};
|
|
226
|
+
/* W2-T4(k-mvsc8xhx0qv):派单中转闸三态卡(relayGate)——coverageGate/capabilityPrompt 三态卡同法:三值选中即提交
|
|
227
|
+
(POST /bufeng/api/config 走 applyGatePatch 同一权威,与 bufeng_config 工具双通道等价);成功回执+失败错误直显
|
|
228
|
+
(无草稿提交语义,当前值只在快照回显后翻转=失败自动保持现值不漂移);缺省/非法存量值读取侧按 shadow 显示。 */
|
|
229
|
+
const relayGate = ['off', 'shadow', 'enforce'].includes(gate.relayGate) ? gate.relayGate : 'shadow';
|
|
230
|
+
const [busyRelay, setBusyRelay] = useState(false);
|
|
231
|
+
const flipRelay = async (v) => {
|
|
232
|
+
setBusyRelay(true); setMsg(null);
|
|
233
|
+
try {
|
|
234
|
+
const out = await postConfig({ relayGate: v });
|
|
235
|
+
setMsg({ ok: true, text: '已设置中转闸 relayGate=' + (out.changed && out.changed.relayGate !== undefined ? out.changed.relayGate : v) });
|
|
236
|
+
} catch (e) {
|
|
237
|
+
setMsg({ ok: false, text: '设置失败:' + e.message });
|
|
238
|
+
} finally { setBusyRelay(false); }
|
|
239
|
+
};
|
|
240
|
+
const saveField = (key, fmt) => async (v) => {
|
|
241
|
+
const out = await postConfig({ [key]: v });
|
|
242
|
+
const applied = out.changed?.[key];
|
|
243
|
+
setMsg({ ok: true, text: applied === undefined ? '未变化' : '已保存 ' + key + ' = ' + (fmt ? fmt(applied) : applied) });
|
|
244
|
+
};
|
|
245
|
+
return h('div', { className: 'bf-set-wrap' },
|
|
246
|
+
h('aside', { className: 'bf-set-nav' },
|
|
247
|
+
h('div', { className: 'bf-set-nav-h' }, '⚙ 设置'),
|
|
248
|
+
navItems.map((it) => h('div', {
|
|
249
|
+
key: it.id,
|
|
250
|
+
className: 'bf-set-link' + (activeTab === it.id ? ' bf-on' : ''),
|
|
251
|
+
onClick: () => jump(it.id)
|
|
252
|
+
}, h('span', null, it.icon), it.label)),
|
|
253
|
+
h('div', { className: 'bf-set-nav-note' }, '改动即时生效;只影响后续派单与新会话。')),
|
|
254
|
+
h('div', { className: 'bf-set-main' },
|
|
255
|
+
h('div', { style: { ...DIM, fontSize: 12, margin: '2px 0 12px' } },
|
|
256
|
+
'改动即时生效并留痕事件史(bufeng.config.updated);数字越界自动钳制到合法区间;输入框失焦或回车保存,Esc 取消。'),
|
|
257
|
+
|
|
258
|
+
h(Section, { id: 'set-id', icon: '🧭', title: '总管身份', desc: '名单制 · v0.27' },
|
|
259
|
+
h('div', { style: { display: 'flex', alignItems: 'flex-start', gap: 14 } },
|
|
260
|
+
h('div', { style: { flex: 1, minWidth: 0 } },
|
|
261
|
+
h('div', { style: { font: 'var(--dsw-font-xs-strong-13, 600 13px/1.5 sans-serif)', ...LABEL } },
|
|
262
|
+
'总管自动入名单(autoAdopt)' + (autoAdopt ? ' ✅ 开启中' : '')),
|
|
263
|
+
h('div', { style: { ...DIM, fontSize: 12, marginTop: 3, lineHeight: 1.6 } },
|
|
264
|
+
'开启后:新客户会话命中工坊关键词即自动加入总管名单(无需客户逐次确认),与名单内总管同权。' +
|
|
265
|
+
'关闭后:提示确认后加入——该会话调 bufeng_adopt(confirm:true)经你在对话中确认后入名单。' +
|
|
266
|
+
'名单制无失位:原会话原地入名单、职责不动——多窗口多位总管同权并存(v0.27 去根化)。')),
|
|
267
|
+
h(Toggle, { on: autoAdopt, busy, onClick: flip }))),
|
|
268
|
+
|
|
269
|
+
h(Section, { id: 'set-hook', icon: '🪝', title: '入口注入', desc: '司南身份觉醒 · v0.18.0' },
|
|
270
|
+
h('div', { style: { display: 'flex', alignItems: 'flex-start', gap: 14 } },
|
|
271
|
+
h('div', { style: { flex: 1, minWidth: 0 } },
|
|
272
|
+
h('div', { style: { font: 'var(--dsw-font-xs-strong-13, 600 13px/1.5 sans-serif)', ...LABEL } },
|
|
273
|
+
'总管身份提示注入(identityHook)' + (identityHook ? ' ✅ 开启中' : '')),
|
|
274
|
+
h('div', { style: { ...DIM, fontSize: 12, marginTop: 3, lineHeight: 1.6 } },
|
|
275
|
+
'开启后:会话消息命中工坊关键词(司南/派单/建树/项目+仓库…)时,自动向该会话注入一条身份提示' +
|
|
276
|
+
'(总管→钦定身份提示+承接流程;无身份→候选工坊与入名单指引),无需智能体自觉调用 bufeng_whoami。' +
|
|
277
|
+
'节点会话不受打扰;纯编码会话有关键词门防噪。')),
|
|
278
|
+
h(Toggle, { on: identityHook, busy: busyHook, onClick: flipHook }))),
|
|
279
|
+
|
|
280
|
+
h(Section, { id: 'set-sess', icon: '🗂', title: '会话策略', desc: '任务会话 · v0.20.0' },
|
|
281
|
+
h('div', { style: { display: 'flex', alignItems: 'flex-start', gap: 14 } },
|
|
282
|
+
h('div', { style: { flex: 1, minWidth: 0 } },
|
|
283
|
+
h('div', { style: { font: 'var(--dsw-font-xs-strong-13, 600 13px/1.5 sans-serif)', ...LABEL } },
|
|
284
|
+
'自动归档任务会话(autoArchiveSessions)' + (gate.autoArchiveSessions === true ? ' ✅ 开启中' : '')),
|
|
285
|
+
h('div', { style: { ...DIM, fontSize: 12, marginTop: 3, lineHeight: 1.6 } },
|
|
286
|
+
'任务会话按「【成员名称】【月-日 时:分:秒】任务主题」命名、每任务必新建(避免上下文污染)——这两项是固定行为。' +
|
|
287
|
+
'本开关控制任务结束后是否自动归档该任务会话(GUI 会话列表不堆积;归档会话可从工作区归档视图找回)。' +
|
|
288
|
+
'默认关闭:测试验证阶段保留全部会话,便于查看处理过程。')),
|
|
289
|
+
h(Toggle, { on: gate.autoArchiveSessions === true, busy: busyArch, onClick: flipArch }))),
|
|
290
|
+
h(Section, { id: 'set-model', icon: '🧠', title: '模型治理', desc: '默认模型跟随总管 · v0.35.0' },
|
|
291
|
+
h('div', { style: { display: 'flex', alignItems: 'flex-start', gap: 14 } },
|
|
292
|
+
h('div', { style: { flex: 1, minWidth: 0 } },
|
|
293
|
+
h('div', { style: { font: 'var(--dsw-font-xs-strong-13, 600 13px/1.5 sans-serif)', ...LABEL } },
|
|
294
|
+
'默认模型跟随总管(keepDefault)' + (keepDefault ? ' ✅ 开启中' : '')),
|
|
295
|
+
h('div', { style: { ...DIM, fontSize: 12, marginTop: 3, lineHeight: 1.6 } },
|
|
296
|
+
'开启后:未配置模型的节点开任务会话时沿用总管会话当前模型(capture→spawn→restore,会话结束自动恢复)。' +
|
|
297
|
+
'关闭后:回到不跟随现状(未配模型节点=宿主默认模型)。本开关真实写 gate(POST /api/config,与 bufeng_config 工具双通道等价)。')),
|
|
298
|
+
h(Toggle, { on: keepDefault, busy: busyKeep, onClick: flipKeep, buttonExtra: { 'data-bf-keep': keepDefault ? 'on' : 'off' } }))),
|
|
299
|
+
|
|
300
|
+
h(Section, { id: 'set-cov', icon: '🛡', title: '覆盖硬闸(coverageGate)', desc: 'v0.43.1 · 覆盖矩阵守门' },
|
|
301
|
+
h('div', { style: { display: 'flex', alignItems: 'flex-start', gap: 14 } },
|
|
302
|
+
h('div', { style: { flex: 1, minWidth: 0 } },
|
|
303
|
+
h('div', { style: { font: 'var(--dsw-font-xs-strong-13, 600 13px/1.5 sans-serif)', ...LABEL } },
|
|
304
|
+
'覆盖硬闸三态',
|
|
305
|
+
h('span', { 'data-bf-covcur': covGate, style: { marginLeft: 8, font: 'var(--ds-font-family-code, monospace)' } }, '当前:' + covGate)),
|
|
306
|
+
h('div', { style: { ...DIM, fontSize: 12, marginTop: 3, lineHeight: 1.6 } },
|
|
307
|
+
'off=覆盖判定整段跳过(零事件零告警);shadow=观察期:派单照常+影子告警(出厂默认);enforce=矩阵缺口在派单前拒派。' +
|
|
308
|
+
'出厂 shadow=影子观察期,切 enforce 建议看观测数据拍板。选中即提交,与 bufeng_config 工具双通道等价(同一 applyGatePatch 权威)。'),
|
|
309
|
+
snap.coverage ? h('div', { style: { ...DIM, fontSize: 11, marginTop: 6 } },
|
|
310
|
+
'📊 观测计数:影子告警 ',
|
|
311
|
+
h('span', { 'data-bf-covshadow': String(snap.coverage.coverageShadow ?? 0), style: { font: 'var(--ds-font-family-code, monospace)', color: 'var(--dsw-alias-state-warning-label, #f5a623)' } }, String(snap.coverage.coverageShadow ?? 0)),
|
|
312
|
+
' 条 · 拒派 ',
|
|
313
|
+
h('span', { 'data-bf-covgap': String(snap.coverage.coverageGap ?? 0), style: { font: 'var(--ds-font-family-code, monospace)', color: 'var(--dsw-alias-state-error-label, #e5484d)' } }, String(snap.coverage.coverageGap ?? 0)),
|
|
314
|
+
' 条(账本事件全量趋势)') : null),
|
|
315
|
+
h('div', { style: { display: 'flex', flexDirection: 'column', gap: 4, flexShrink: 0 } },
|
|
316
|
+
COV_STATES.map((st) => h('button', {
|
|
317
|
+
key: st.id,
|
|
318
|
+
'data-bf-covgate': st.id,
|
|
319
|
+
disabled: busyCov,
|
|
320
|
+
title: '切换覆盖硬闸为 ' + st.id,
|
|
321
|
+
onClick: () => flipCov(st.id),
|
|
322
|
+
style: {
|
|
323
|
+
cursor: busyCov ? 'wait' : 'pointer', fontSize: 11, padding: '4px 10px', borderRadius: 6,
|
|
324
|
+
font: 'var(--ds-font-family-code, monospace)',
|
|
325
|
+
border: '1px solid ' + (st.id === covGate ? 'var(--dsw-alias-state-success-primary, #2f9e44)' : LINE),
|
|
326
|
+
background: st.id === covGate ? 'rgba(47,158,68,.16)' : 'transparent',
|
|
327
|
+
color: 'inherit', opacity: busyCov ? .6 : 1
|
|
328
|
+
}
|
|
329
|
+
}, st.label))))),
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
h(Section, { id: 'set-relay', icon: '🔁', title: '派单中转闸(relayGate)', desc: 'v0.54.0 · 派单中转链守门' },
|
|
333
|
+
h('div', { style: { display: 'flex', alignItems: 'flex-start', gap: 14 } },
|
|
334
|
+
h('div', { style: { flex: 1, minWidth: 0 } },
|
|
335
|
+
h('div', { style: { font: 'var(--dsw-font-xs-strong-13, 600 13px/1.5 sans-serif)', ...LABEL } },
|
|
336
|
+
'派单中转闸三态',
|
|
337
|
+
h('span', { 'data-bf-relcur': relayGate, style: { marginLeft: 8, font: 'var(--ds-font-family-code, monospace)' } }, '当前:' + relayGate)),
|
|
338
|
+
h('div', { style: { ...DIM, fontSize: 12, marginTop: 3, lineHeight: 1.6 } },
|
|
339
|
+
'任务卡「↻ 续跑」(bufeng_task_recover action=resume)等中转写通道的守门三态:off=整段关停(零投递);shadow=只记录不拦截(出厂默认);enforce=越界即拒。' +
|
|
340
|
+
'缺省/非法存量值读取侧按 shadow 处理(fail-safe 不误拦)。选中即提交,与 bufeng_config 工具双通道等价(同一 applyGatePatch 权威)。')),
|
|
341
|
+
h('div', { style: { display: 'flex', flexDirection: 'column', gap: 4, flexShrink: 0 } },
|
|
342
|
+
REL_STATES.map((st) => h('button', {
|
|
343
|
+
key: st.id,
|
|
344
|
+
'data-bf-relgate': st.id,
|
|
345
|
+
disabled: busyRelay,
|
|
346
|
+
title: '切换派单中转闸为 ' + st.id,
|
|
347
|
+
onClick: () => flipRelay(st.id),
|
|
348
|
+
style: {
|
|
349
|
+
cursor: busyRelay ? 'wait' : 'pointer', fontSize: 11, padding: '4px 10px', borderRadius: 6,
|
|
350
|
+
font: 'var(--ds-font-family-code, monospace)',
|
|
351
|
+
border: '1px solid ' + (st.id === relayGate ? 'var(--dsw-alias-state-success-primary, #2f9e44)' : LINE),
|
|
352
|
+
background: st.id === relayGate ? 'rgba(47,158,68,.16)' : 'transparent',
|
|
353
|
+
color: 'inherit', opacity: busyRelay ? .6 : 1
|
|
354
|
+
}
|
|
355
|
+
}, st.label))))),
|
|
356
|
+
h(Section, { id: 'set-capprompt', icon: '📣', title: '能力面宣传(capabilityPrompt)', desc: 'v0.46.0 · 派单提示词能力段' },
|
|
357
|
+
h('div', { style: { display: 'flex', alignItems: 'flex-start', gap: 14 } },
|
|
358
|
+
h('div', { style: { flex: 1, minWidth: 0 } },
|
|
359
|
+
h('div', { style: { font: 'var(--dsw-font-xs-strong-13, 600 13px/1.5 sans-serif)', ...LABEL } },
|
|
360
|
+
'能力面宣传三态',
|
|
361
|
+
h('span', { 'data-bf-capcur': capGate, style: { marginLeft: 8, font: 'var(--ds-font-family-code, monospace)' } }, '当前:' + capGate)),
|
|
362
|
+
h('div', { style: { ...DIM, fontSize: 12, marginTop: 3, lineHeight: 1.6 } },
|
|
363
|
+
'派单提示词「可用能力提示」段开关:off=不注入(零 token,出厂默认,存量任务提示词字节全等);brief=装备名摘要;full=工具白名单投影+推荐命中词(无装备无命中节点整段缺席)。' +
|
|
364
|
+
'缺省/非法存量值读取侧按 off 处理(fail-safe 零注入)。选中即提交,与 bufeng_config 工具双通道等价(同一 applyGatePatch 权威)。')),
|
|
365
|
+
h('div', { style: { display: 'flex', flexDirection: 'column', gap: 4, flexShrink: 0 } },
|
|
366
|
+
CAP_STATES.map((st) => h('button', {
|
|
367
|
+
key: st.id,
|
|
368
|
+
'data-bf-capgate': st.id,
|
|
369
|
+
disabled: busyCap,
|
|
370
|
+
title: '切换能力面宣传为 ' + st.id,
|
|
371
|
+
onClick: () => flipCap(st.id),
|
|
372
|
+
style: {
|
|
373
|
+
cursor: busyCap ? 'wait' : 'pointer', fontSize: 11, padding: '4px 10px', borderRadius: 6,
|
|
374
|
+
font: 'var(--ds-font-family-code, monospace)',
|
|
375
|
+
border: '1px solid ' + (st.id === capGate ? 'var(--dsw-alias-state-success-primary, #2f9e44)' : LINE),
|
|
376
|
+
background: st.id === capGate ? 'rgba(47,158,68,.16)' : 'transparent',
|
|
377
|
+
color: 'inherit', opacity: busyCap ? .6 : 1
|
|
378
|
+
}
|
|
379
|
+
}, st.label))))),
|
|
380
|
+
h(Section, { id: 'set-budget', icon: '⚖️', title: '调度与预算', desc: '派单闸门' },
|
|
381
|
+
h(EditRow, { label: '并发闸门(maxConcurrentNodes)', hint: '全林同时执行任务的节点上限,1-64', value: gate.maxConcurrentNodes, width: 64, suffix: '个', onSave: saveField('maxConcurrentNodes'), parse: (s) => Number(s) }),
|
|
382
|
+
h(EditRow, { label: '日预算(dailyBudgetTokens)', hint: '全林每日 token 估算上限,1 万-10 亿;100% 熔断拒派', value: gate.dailyBudgetTokens, width: 110, suffix: 'token', onSave: saveField('dailyBudgetTokens', fmtTokens), parse: (s) => Number(s) }),
|
|
383
|
+
h(EditRow, { label: '预警线(budgetWarnAt)', hint: '用量达到预算的百分比即预警,50-100', value: Math.round((gate.budgetWarnAt ?? 0.85) * 100), width: 64, suffix: '%', onSave: saveField('budgetWarnAt'), parse: (s) => Number(s) / 100 }),
|
|
384
|
+
h(EditRow, { label: '任务默认时限(taskTimeoutDefaultMin)', hint: '派单未显式给 timeoutMin 时的默认时限,分钟;0=不限时(默认,进度靠等待屏障每 5 分钟分段反馈);>0 超时只标不杀(看板⏰徽章)', value: gate.taskTimeoutDefaultMin ?? 0, width: 64, suffix: '分', onSave: saveField('taskTimeoutDefaultMin'), parse: (s) => Number(s) }),
|
|
385
|
+
h(EditRow, { label: '总管名单容量(maxRoots)', hint: '总管名单席位上限,2-16(默认 4);满员拒绝新总管入名单(等待 TTL 清理或调大容量)', value: gate.maxRoots ?? 4, width: 64, suffix: '席', onSave: saveField('maxRoots'), parse: (s) => Number(s) }),
|
|
386
|
+
h(EditRow, { label: '总管名单 TTL(rootTtlMin)', hint: '名单条目超 lastActiveAt 未活跃即按死席摘除(惰性扫描),分钟,60-1000000;默认 1440=24h', value: gate.rootTtlMin ?? 1440, width: 64, suffix: '分', onSave: saveField('rootTtlMin'), parse: (s) => Number(s) })),
|
|
387
|
+
|
|
388
|
+
h(Section, { id: 'set-dir', icon: '📁', title: '项目目录', desc: '总管代建项目的统一存放地' },
|
|
389
|
+
h(EditRow, { label: '项目根(projectsRoot)', hint: projectsRootHint, value: gate.projectsRoot, width: 330, onSave: saveField('projectsRoot') }),
|
|
390
|
+
h(EditRow, {
|
|
391
|
+
label: '默认工作区目录名(defaultWorkspaceDir)',
|
|
392
|
+
hint: '无项目/无显式目录的派单会话统一落这里(GUI 分区「捕风·默认工作区」)。DSH 工作区根下的子目录名(非绝对路径),默认 bufeng-ws;' +
|
|
393
|
+
'改后新建树/派单兜底/自建登记生效,已有树与项目路径不动。当前生效:' + (snap.defaultWorkspace ?? '~/.dsh/bufeng/workspace'),
|
|
394
|
+
value: gate.defaultWorkspaceDir ?? 'bufeng-ws',
|
|
395
|
+
width: 200, inputExtra: { 'data-bf-wsdir': '1' }, warnOf: wsDirWarnOf,
|
|
396
|
+
onSave: saveField('defaultWorkspaceDir')
|
|
397
|
+
})),
|
|
398
|
+
|
|
399
|
+
h(Section, { id: 'set-legend', icon: '🧩', title: '角色图例', desc: '星枢 · v0.24.0(看板卡/任务行同款)' },
|
|
400
|
+
h('div', { style: { display: 'flex', alignItems: 'center', gap: 20, flexWrap: 'wrap' } },
|
|
401
|
+
legendItem('orchestrator', 'legend-zg', '总管', '中枢枢纽 · 紫罗盘'),
|
|
402
|
+
legendItem('leader', 'legend-dg', '都管', '带队把关 · 青盾'),
|
|
403
|
+
legendItem('member', 'legend-cy', '成员', '动手执行 · 琥珀齿轮'))),
|
|
404
|
+
|
|
405
|
+
msg ? h('div', { style: { fontSize: 12, marginTop: 10, color: msg.ok ? 'var(--dsw-alias-state-success-label, #4cc38a)' : 'var(--dsw-alias-state-error-label, #e5484d)' } }, msg.text) : null
|
|
406
|
+
));
|
|
407
|
+
}
|