@suifei/dsh-ai-team 0.4.30 → 0.4.32
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/CHANGELOG.md +18 -0
- package/client.js +50 -11
- package/index.js +14 -3
- package/lib/host/decision-report.js +14 -4
- package/lib/host/people-view.js +7 -2
- package/lib/host/pmo.js +29 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.32 - 2026-11-12
|
|
4
|
+
|
|
5
|
+
**中危批次 3:前端断流自愈、重复提交、同人绑定**
|
|
6
|
+
|
|
7
|
+
- **断流不再假装在重连**:`EventSource` 只在临时失败时自己重试;一旦被判死(`readyState === CLOSED`,例如服务端 4xx/5xx),浏览器不会再试,而界面还挂着「正在自动重连…」。现在由前端按 2s→30s 退避重建事件源,卸载时清掉定时器;收到帧后清掉断流提示并提示已恢复。
|
|
8
|
+
- **重复提交**:发送与回复共用同一个在途守卫——连按 Ctrl/⌘+Enter 或双击不会写出两条相同的消息/回复。
|
|
9
|
+
- **同人绑定真的会合并**:界面把「绑定到谁」的名字当 `personId` 提交,而聚合桶键是 `name:<名字>`,于是别名落到 `person:<名字>`,两行永远合不到一起、提示却是成功。现在服务端把别名的目标归一为 `person:<id>` / `name:<名字>`,聚合时裸名字也按 `name:` 处理,历史数据文件不回改也能生效。
|
|
10
|
+
- 测试:`node --test` **216/216**(新增 `client-contract` 结构契约 3 例、人员别名 2 例)。
|
|
11
|
+
|
|
12
|
+
## 0.4.31 - 2026-11-12
|
|
13
|
+
|
|
14
|
+
**中危批次 2:Host 会话落账、报告路径判别、PMO 决策遵从建议**
|
|
15
|
+
|
|
16
|
+
- **Host 会话现在真的会落账**:`bindHostSession` 一直存在却只在「首次创建」时被调用——从 `roots()` 选中既有根会话、或父级换成另一条根会话时都不会写,`state.hostSessionId` 永远为空,归档修复 sweep 看不见它,父级变化后 `sendMessage`/冷恢复直接 `UNAUTHORIZED` 且无自愈。现在每次解析出 Host 都按现状重绑(幂等),失败留诊断。
|
|
17
|
+
- **报告路径按存在性判别**:一份 Thread 里常先给示例、后给真实路径,文末还可能附模板。现在优先取**真实存在**的那条,都不存在时才退回「最后一次提到」,不再被文末模板或旧稿带走。
|
|
18
|
+
- **PMO 决策遵从问题里的建议**:显式 `recommendation` 现在先按选项字母(`建议 A` ↔ `A. …`)匹配,其次双向包含;只有匹配不上才退回关键词打分。此前关键词打分可以让「建议 A」被选成 B。
|
|
19
|
+
- 测试:`node --test` **211/211**。
|
|
20
|
+
|
|
3
21
|
## 0.4.30 - 2026-11-12
|
|
4
22
|
|
|
5
23
|
**中危批次:唤醒路径收敛与权限预设可配置**
|
package/client.js
CHANGED
|
@@ -85,6 +85,7 @@ window.__ModuleLoader__.load({
|
|
|
85
85
|
fromDiscussion: '由讨论升格',
|
|
86
86
|
loading: '加载中…',
|
|
87
87
|
streamDown: '实时更新已中断,界面可能滞后;正在自动重连…',
|
|
88
|
+
streamUp: '实时更新已恢复。',
|
|
88
89
|
loadFailedTitle: '工作台不可达',
|
|
89
90
|
loadFailedBody: 'bootstrap 接口(/ai-team)无法访问;请确认插件已启用后重试。',
|
|
90
91
|
spike: 'AI Team',
|
|
@@ -497,6 +498,7 @@ window.__ModuleLoader__.load({
|
|
|
497
498
|
loadFailedTitle: 'Workbench unreachable',
|
|
498
499
|
loadFailedBody: 'The bootstrap endpoint (/ai-team) cannot be reached; confirm the plugin is enabled and retry.',
|
|
499
500
|
streamDown: 'Live updates stopped; the view may lag while the stream reconnects…',
|
|
501
|
+
streamUp: 'Live updates are back.',
|
|
500
502
|
spike: 'AI Team',
|
|
501
503
|
spikeTitle: 'Wenyuan Pavilion AI Team workbench: compile, collate, edit; direction, acceptance and ledger.',
|
|
502
504
|
navAria: 'Page navigation',
|
|
@@ -2637,6 +2639,8 @@ window.__ModuleLoader__.load({
|
|
|
2637
2639
|
const scopeRef = React.useRef(scope);
|
|
2638
2640
|
// SSE 断流一次性提示:只提示一次,恢复后重置。
|
|
2639
2641
|
const streamDownRef = React.useRef(false);
|
|
2642
|
+
// 发送在途守卫:双击按钮或连按 Ctrl+Enter 会重复提交同一条消息/回复。
|
|
2643
|
+
const sendingRef = React.useRef(false);
|
|
2640
2644
|
scopeRef.current = scope;
|
|
2641
2645
|
const [nBusy, setNBusy] = React.useState(false);
|
|
2642
2646
|
const [nError, setNError] = React.useState('');
|
|
@@ -2731,15 +2735,25 @@ window.__ModuleLoader__.load({
|
|
|
2731
2735
|
}
|
|
2732
2736
|
load();
|
|
2733
2737
|
// Event-driven refresh only; the Host sends one frame per command and
|
|
2734
|
-
// no heartbeat/timer.
|
|
2735
|
-
//
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2738
|
+
// no heartbeat/timer. A project is required — no magic fallback id here.
|
|
2739
|
+
// EventSource 只在**临时**失败时自动重连;一旦被判死(readyState
|
|
2740
|
+
// CLOSED,例如服务端返回 4xx/5xx),它不会再试,界面会永远停在
|
|
2741
|
+
// 「正在自动重连…」的假承诺上。这里自己接管重建,并在恢复后清掉提示。
|
|
2742
|
+
let source = null;
|
|
2743
|
+
let retryTimer = null;
|
|
2744
|
+
let retryDelay = 2000;
|
|
2745
|
+
const openStream = () => {
|
|
2746
|
+
if (!alive || typeof EventSource !== 'function' || !projectId) return;
|
|
2747
|
+
source = new EventSource('/ai-team/api/projects/' + encodeURIComponent(projectId) + '/events');
|
|
2740
2748
|
source.addEventListener('change', (raw) => {
|
|
2741
2749
|
if (!alive) return;
|
|
2742
|
-
|
|
2750
|
+
retryDelay = 2000;
|
|
2751
|
+
if (streamDownRef.current) {
|
|
2752
|
+
streamDownRef.current = false;
|
|
2753
|
+
// 恢复后清掉断流提示;否则「正在自动重连」会一直挂着。
|
|
2754
|
+
say('');
|
|
2755
|
+
pushToast(t('streamUp'));
|
|
2756
|
+
}
|
|
2743
2757
|
try {
|
|
2744
2758
|
const frame = JSON.parse(raw.data);
|
|
2745
2759
|
pushToast(notificationText(frame?.event));
|
|
@@ -2752,19 +2766,30 @@ window.__ModuleLoader__.load({
|
|
|
2752
2766
|
load();
|
|
2753
2767
|
});
|
|
2754
2768
|
source.addEventListener('error', () => {
|
|
2755
|
-
// EventSource 自己会重连,但**必须让用户看见**:旧实现只在首屏
|
|
2756
|
-
// (dataRef===null)时打印,面板已有数据时断流完全静默。
|
|
2757
2769
|
if (!alive) return;
|
|
2758
|
-
console.error(PKG + ': event stream unavailable
|
|
2770
|
+
console.error(PKG + ': event stream unavailable');
|
|
2759
2771
|
if (!streamDownRef.current) {
|
|
2760
2772
|
streamDownRef.current = true;
|
|
2761
2773
|
say(t('streamDown'));
|
|
2762
2774
|
}
|
|
2775
|
+
// CONNECTING 时浏览器自己会重试,保持原样;CLOSED 表示已放弃,
|
|
2776
|
+
// 必须由我们按退避重建,否则永远不会恢复。
|
|
2777
|
+
if (source !== null && source.readyState === 2) {
|
|
2778
|
+
try { source.close(); } catch { /* already closed */ }
|
|
2779
|
+
source = null;
|
|
2780
|
+
if (retryTimer === null) {
|
|
2781
|
+
const delay = retryDelay;
|
|
2782
|
+
retryDelay = Math.min(retryDelay * 2, 30000);
|
|
2783
|
+
retryTimer = setTimeout(() => { retryTimer = null; openStream(); }, delay);
|
|
2784
|
+
}
|
|
2785
|
+
}
|
|
2763
2786
|
});
|
|
2764
|
-
}
|
|
2787
|
+
};
|
|
2788
|
+
openStream();
|
|
2765
2789
|
return () => {
|
|
2766
2790
|
alive = false;
|
|
2767
2791
|
if (controller) controller.abort();
|
|
2792
|
+
if (retryTimer !== null) clearTimeout(retryTimer);
|
|
2768
2793
|
if (source) source.close();
|
|
2769
2794
|
};
|
|
2770
2795
|
}, [projectId]);
|
|
@@ -3657,6 +3682,15 @@ window.__ModuleLoader__.load({
|
|
|
3657
3682
|
async function send() {
|
|
3658
3683
|
const text = draft.trim();
|
|
3659
3684
|
if (!text) return;
|
|
3685
|
+
if (sendingRef.current) return;
|
|
3686
|
+
sendingRef.current = true;
|
|
3687
|
+
try {
|
|
3688
|
+
await sendOnce(text);
|
|
3689
|
+
} finally {
|
|
3690
|
+
sendingRef.current = false;
|
|
3691
|
+
}
|
|
3692
|
+
}
|
|
3693
|
+
async function sendOnce(text) {
|
|
3660
3694
|
// 目录门槛只拦"要动手"的任务:讨论与建卡无需工作目录(11-管理视角
|
|
3661
3695
|
// §3);激活/认领由 Host fail-closed,并把用户引导到目录设置。
|
|
3662
3696
|
if (!project?.workspacePath && mode === 'task') {
|
|
@@ -3699,6 +3733,9 @@ window.__ModuleLoader__.load({
|
|
|
3699
3733
|
async function sendReply() {
|
|
3700
3734
|
const text = reply.trim();
|
|
3701
3735
|
if (!text || !selectedTask) return;
|
|
3736
|
+
// 与发送共用同一个在途守卫:连按 Ctrl+Enter 会写出两条相同回复。
|
|
3737
|
+
if (sendingRef.current) return;
|
|
3738
|
+
sendingRef.current = true;
|
|
3702
3739
|
try {
|
|
3703
3740
|
const result = await runCommand('thread.post', {
|
|
3704
3741
|
taskId: selectedTask.id,
|
|
@@ -3712,6 +3749,8 @@ window.__ModuleLoader__.load({
|
|
|
3712
3749
|
await reloadData();
|
|
3713
3750
|
} catch (error) {
|
|
3714
3751
|
sayRight(tf(t, 'replyFailed', { message: error?.message ?? String(error) }));
|
|
3752
|
+
} finally {
|
|
3753
|
+
sendingRef.current = false;
|
|
3715
3754
|
}
|
|
3716
3755
|
}
|
|
3717
3756
|
function openConvert() {
|
package/index.js
CHANGED
|
@@ -1400,9 +1400,16 @@ export function apply(ctx, config = {}) {
|
|
|
1400
1400
|
cwd: booted?.dataDir ?? process.cwd(),
|
|
1401
1401
|
resumeSessionId: existingHost,
|
|
1402
1402
|
}).then(async (value) => {
|
|
1403
|
-
|
|
1404
|
-
|
|
1403
|
+
// Host 会话必须落账:它决定冷恢复与 sendMessage 的 parent,也决定归档
|
|
1404
|
+
// 修复 sweep 能不能看见根会话。除了「首次创建」,从 roots() 里选中
|
|
1405
|
+
// 既有会话、以及父级发生变化(换成了另一条根会话)时同样要重绑——
|
|
1406
|
+
// 否则之后每次 sendMessage/coldResume 都以 UNAUTHORIZED 失败且无自愈。
|
|
1407
|
+
for (const runtime of booted?.runtimes?.values() ?? []) {
|
|
1408
|
+
if (runtime.service.state.hostSessionId === value.sessionId) continue;
|
|
1409
|
+
try {
|
|
1405
1410
|
await runtime.service.bindHostSession(value.sessionId, runtime.id);
|
|
1411
|
+
} catch (error) {
|
|
1412
|
+
diag.append({ ev: 'host.bind.fail', projectId: runtime.id, sessionId: value.sessionId, message: error?.message ?? String(error) });
|
|
1406
1413
|
}
|
|
1407
1414
|
}
|
|
1408
1415
|
host = value;
|
|
@@ -1716,7 +1723,11 @@ export function apply(ctx, config = {}) {
|
|
|
1716
1723
|
return send(res, { error: { code: 'E_INVALID_ARGUMENT', message: 'name and personId are required' } }, 400);
|
|
1717
1724
|
}
|
|
1718
1725
|
const aliases = readAliases() ?? {};
|
|
1719
|
-
|
|
1726
|
+
// 归一到视图层的桶键:接受 `person:<id>`、`name:<名字>` 或裸名字。
|
|
1727
|
+
// 归一后才能与 aggregatePeople 的桶键对齐(裸名字曾让两行永不合并,
|
|
1728
|
+
// 而界面还提示「已绑定」)。
|
|
1729
|
+
const normalized = personId.startsWith('person:') || personId.startsWith('name:') ? personId : `name:${personId}`;
|
|
1730
|
+
aliases[memberName] = normalized;
|
|
1720
1731
|
writeFileSync(aliasesPath, JSON.stringify(aliases, null, 2) + '\n', 'utf8');
|
|
1721
1732
|
diag?.append({ ev: 'people.alias', name: memberName, personId });
|
|
1722
1733
|
return send(res, { ok: true, aliases });
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Read the Human-decision table from a linked Markdown report.
|
|
3
5
|
*
|
|
4
6
|
* This is deliberately narrow: only a report containing a section titled
|
|
@@ -26,13 +28,21 @@ export function findReportPath(text) {
|
|
|
26
28
|
/`[A-Za-z]:[\\/][^`<>|\r\n]+?\.md`/g,
|
|
27
29
|
/[A-Za-z]:[\\/][^\s"'<>|`]+?\.md\b/g,
|
|
28
30
|
];
|
|
29
|
-
|
|
31
|
+
// 命中多个时先看**哪个真的存在**:模型常先给示例路径、再给真实产物路径,文末
|
|
32
|
+
// 也可能附一段模板示例——单靠「取第一个/取最后一个」都会错一边。存在的路径
|
|
33
|
+
// 优先;都不存在时退回「最后一次提到」,那是模型的最终答复约定。
|
|
34
|
+
const hits = [];
|
|
30
35
|
for (const pattern of patterns) {
|
|
31
36
|
for (const match of text.matchAll(pattern)) {
|
|
32
|
-
|
|
37
|
+
hits.push({ index: match.index ?? 0, path: match[0].replace(/^["'`]|["'`]$/g, '') });
|
|
33
38
|
}
|
|
34
39
|
}
|
|
35
|
-
|
|
40
|
+
if (hits.length === 0) return null;
|
|
41
|
+
hits.sort((a, b) => a.index - b.index);
|
|
42
|
+
const existing = hits.filter((hit) => {
|
|
43
|
+
try { return existsSync(hit.path); } catch { return false; }
|
|
44
|
+
});
|
|
45
|
+
return (existing.length > 0 ? existing[existing.length - 1] : hits[hits.length - 1]).path;
|
|
36
46
|
}
|
|
37
47
|
|
|
38
48
|
export function parseDecisionQuestions(markdown) {
|
package/lib/host/people-view.js
CHANGED
|
@@ -22,8 +22,13 @@ export function aggregatePeople(registryEntries, runtimes, options = {}) {
|
|
|
22
22
|
const aliases = options.aliases ?? null;
|
|
23
23
|
const people = new Map();
|
|
24
24
|
const bucketOf = (name) => {
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
// 别名的目标可以是 `person:<id>`(真正的 personId)、`name:<名字>`,或
|
|
26
|
+
// 历史数据里的裸名字。裸名字必须归一到 `name:<名字>`——否则「X → 白砚」
|
|
27
|
+
// 会让 X 落到 `person:白砚`,而白砚本人是 `name:白砚`,两行永远合不到一起。
|
|
28
|
+
const alias = aliases !== null && Object.prototype.hasOwnProperty.call(aliases, name) ? aliases[name] : null;
|
|
29
|
+
if (alias === null) return `name:${name}`;
|
|
30
|
+
if (alias.startsWith('person:') || alias.startsWith('name:')) return alias;
|
|
31
|
+
return `name:${alias}`;
|
|
27
32
|
};
|
|
28
33
|
for (const runtime of runtimes) {
|
|
29
34
|
const projectName = registryEntries.find((project) => project.id === runtime.id)?.name ?? runtime.id;
|
package/lib/host/pmo.js
CHANGED
|
@@ -14,6 +14,30 @@ function clean(value) {
|
|
|
14
14
|
return typeof value === 'string' ? value.trim() : '';
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
/** 选项开头的字母编号(`B.` / `B、` / `B)` / `B:`)。 */
|
|
18
|
+
function optionLetter(value) {
|
|
19
|
+
const match = /^\s*[((]?([A-Za-z])[))..、::]/.exec(value);
|
|
20
|
+
return match === null ? null : match[1].toUpperCase();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** 建议里点名的选项字母(`建议 B` / `推荐:C` / `选 A`)。 */
|
|
24
|
+
function recommendationLetter(recommendation) {
|
|
25
|
+
const match = /(?:建议|推荐|选择|选|option|choose)\s*[::]?\s*[((]?([A-Za-z])\b/i.exec(recommendation)
|
|
26
|
+
?? /^\s*[((]?([A-Za-z])[))..、::]/.exec(recommendation);
|
|
27
|
+
return match === null ? null : match[1].toUpperCase();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** 显式建议命中哪个选项:字母编号优先,其次双向包含。 */
|
|
31
|
+
function explicitPick(options, recommendation) {
|
|
32
|
+
if (recommendation === '') return null;
|
|
33
|
+
const letter = recommendationLetter(recommendation);
|
|
34
|
+
if (letter !== null) {
|
|
35
|
+
const byLetter = options.find((option) => optionLetter(option) === letter);
|
|
36
|
+
if (byLetter !== undefined) return byLetter;
|
|
37
|
+
}
|
|
38
|
+
return options.find((option) => recommendation.includes(option) || option.includes(recommendation)) ?? null;
|
|
39
|
+
}
|
|
40
|
+
|
|
17
41
|
function scoreOption(option, question) {
|
|
18
42
|
const value = clean(option);
|
|
19
43
|
if (value === '') return -100;
|
|
@@ -36,6 +60,11 @@ export function chooseDecisionAnswers(questions) {
|
|
|
36
60
|
const options = Array.isArray(question?.options) ? question.options.map(clean).filter(Boolean) : [];
|
|
37
61
|
const recommendation = clean(question?.recommendation);
|
|
38
62
|
if (options.length > 0) {
|
|
63
|
+
// 问题里给了明确建议就按建议选——只有没有建议、或建议对不上任何选项时,
|
|
64
|
+
// 才退回关键字打分。否则「建议 A」可能被关键词打分选成 B,PMO 自动决策
|
|
65
|
+
// 就与问题给出的建议相反。
|
|
66
|
+
const explicit = explicitPick(options, recommendation);
|
|
67
|
+
if (explicit !== null) return { id, value: explicit };
|
|
39
68
|
const picked = options
|
|
40
69
|
.map((option) => ({ option, score: scoreOption(option, question) }))
|
|
41
70
|
.sort((left, right) => right.score - left.score)[0];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@suifei/dsh-ai-team",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.32",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "文渊阁 (Wenyuan Pavilion) — AI Team mode for DeepSeek Harness: concurrent projects, owned tasks, threads, inbox and an append-only team ledger",
|
|
6
6
|
"license": "MIT",
|