@suifei/dsh-ai-team 0.4.15 → 0.4.19
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/index.js +89 -1
- package/lib/skillopt/review-runner.js +1 -1
- package/lib/skillopt/reviewer.js +10 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -52,7 +52,7 @@ export const name = 'ai-team';
|
|
|
52
52
|
// 实际使用的服务(含可选服务:缺失时 serviceOf 回退 ctx.get 并返回 undefined)。
|
|
53
53
|
export const inject = ['webServer', 'permissionPresets', 'sandboxPolicy', 'tools', 'shell', 'agents', 'subagents', 'sessions'];
|
|
54
54
|
|
|
55
|
-
const VERSION = '0.4.
|
|
55
|
+
const VERSION = '0.4.19';
|
|
56
56
|
const HUMAN_ID = 'mem_human';
|
|
57
57
|
|
|
58
58
|
const SKILLOPT_BACKENDS = ['mock', 'claude', 'codex', 'copilot', 'cursor', 'pi', 'opencode', 'handoff', 'azure_openai'];
|
|
@@ -546,8 +546,24 @@ export function apply(ctx, config = {}) {
|
|
|
546
546
|
// 注意:member 是 try 块内变量,catch 里必须从 state 取成员。
|
|
547
547
|
const targetMember = projectRuntime.service.state.members?.[plan.memberId];
|
|
548
548
|
const failureText = `${error?.code ?? ''} ${error?.message ?? String(error)}`;
|
|
549
|
+
// 探针(.fail 后缀以便 errors 级可见):自愈为什么没触发。
|
|
550
|
+
diag.append({
|
|
551
|
+
ev: 'wake.catch.probe.fail',
|
|
552
|
+
memberId: plan.memberId,
|
|
553
|
+
reason: plan.reason,
|
|
554
|
+
hasTarget: targetMember !== undefined && targetMember !== null,
|
|
555
|
+
sessionIdType: typeof targetMember?.sessionId,
|
|
556
|
+
failureText: failureText.slice(0, 160),
|
|
557
|
+
});
|
|
549
558
|
const legacySession = /subagent|not-found|not found|E_SESSION_MISSING|NOT_RESUMABLE|unavailable/i.test(failureText)
|
|
550
559
|
&& typeof targetMember?.sessionId === 'string' && targetMember.sessionId !== '';
|
|
560
|
+
diag.append({
|
|
561
|
+
ev: 'wake.catch.probe.fail',
|
|
562
|
+
stage: 'decision',
|
|
563
|
+
memberId: plan.memberId,
|
|
564
|
+
legacySession,
|
|
565
|
+
hasActivateMember: typeof activateMember === 'function',
|
|
566
|
+
});
|
|
551
567
|
if (legacySession) {
|
|
552
568
|
try {
|
|
553
569
|
const reseated = await activateMember({
|
|
@@ -564,6 +580,7 @@ export function apply(ctx, config = {}) {
|
|
|
564
580
|
oldSessionId: targetMember.sessionId,
|
|
565
581
|
newSessionId: reseated?.sessionId ?? null,
|
|
566
582
|
ok: reseated?.error === undefined,
|
|
583
|
+
error: reseated?.error ?? null,
|
|
567
584
|
});
|
|
568
585
|
} catch (reseatError) {
|
|
569
586
|
diag.append({
|
|
@@ -966,6 +983,25 @@ export function apply(ctx, config = {}) {
|
|
|
966
983
|
if (runtime === null) return '[skillopt optimize] no active project runtime';
|
|
967
984
|
const jobId = 'job_' + Date.now().toString(36) + Math.random().toString(36).slice(2, 8);
|
|
968
985
|
const actor = { kind: 'human', memberId: HUMAN_ID };
|
|
986
|
+
// 评审前先刷新评审官会话:subagent provider 不提供 continuable
|
|
987
|
+
// 会话,旧会话在重启/回合结束后即不可投递(NOT_RESUMABLE)。
|
|
988
|
+
// 这一步让评审投递落在**新鲜会话**上,闭环才成立。
|
|
989
|
+
try {
|
|
990
|
+
const reviewer = Object.values(runtime.service.state.members ?? {})
|
|
991
|
+
.find((member) => member.kind === 'agent' && (member.role === '评审' || member.name === '评审官'));
|
|
992
|
+
if (reviewer !== undefined) {
|
|
993
|
+
const refreshed = await activateMember({
|
|
994
|
+
payload: {
|
|
995
|
+
memberId: reviewer.id,
|
|
996
|
+
force: true,
|
|
997
|
+
prompt: '会话已刷新(评审官)。职责不变:只做 A/B 盲评,把一行 JSON 结论用 team 工具发到评审卡。',
|
|
998
|
+
},
|
|
999
|
+
}, runtime);
|
|
1000
|
+
diag.append({ ev: refreshed.error === undefined ? 'skillopt.reviewer.refreshed' : 'skillopt.reviewer.refresh.fail', projectId: runtime.id, memberId: reviewer.id, sessionId: refreshed.sessionId ?? null, message: refreshed.error?.message ?? null });
|
|
1001
|
+
}
|
|
1002
|
+
} catch (error) {
|
|
1003
|
+
diag.append({ ev: 'skillopt.reviewer.refresh.fail', projectId: runtime.id, message: error?.message ?? String(error) });
|
|
1004
|
+
}
|
|
969
1005
|
const started = await startReview({
|
|
970
1006
|
service: runtime.service,
|
|
971
1007
|
projectRuntime: runtime,
|
|
@@ -1795,6 +1831,58 @@ export function apply(ctx, config = {}) {
|
|
|
1795
1831
|
broadcast(undefined);
|
|
1796
1832
|
return send(res, activated);
|
|
1797
1833
|
}
|
|
1834
|
+
// 成员恢复巡检(不依赖 boot/tick):subagent provider 不提供
|
|
1835
|
+
// continuable 会话,唤醒失败后必须重建会话——单成员或全量。
|
|
1836
|
+
if (body.type === 'member.reseat') {
|
|
1837
|
+
const payload = body.payload ?? {};
|
|
1838
|
+
const state = runtime.service.state;
|
|
1839
|
+
const targets = Array.isArray(payload.memberIds) && payload.memberIds.length > 0
|
|
1840
|
+
? payload.memberIds
|
|
1841
|
+
: typeof payload.memberId === 'string' && payload.memberId !== ''
|
|
1842
|
+
? [payload.memberId]
|
|
1843
|
+
: payload.all === true
|
|
1844
|
+
? Object.values(state.members ?? {}).filter((member) => member.kind === 'agent' && member.status !== 'retired').map((member) => member.id)
|
|
1845
|
+
: [];
|
|
1846
|
+
if (targets.length === 0) {
|
|
1847
|
+
return send(res, { error: { code: 'E_INVALID_ARGUMENT', message: 'memberIds, memberId or all:true is required' } }, 400);
|
|
1848
|
+
}
|
|
1849
|
+
const results = [];
|
|
1850
|
+
for (const memberId of targets) {
|
|
1851
|
+
const before = state.members?.[memberId]?.sessionId ?? null;
|
|
1852
|
+
try {
|
|
1853
|
+
const activated = await activateMember({
|
|
1854
|
+
payload: {
|
|
1855
|
+
memberId,
|
|
1856
|
+
force: true,
|
|
1857
|
+
prompt: typeof payload.prompt === 'string' && payload.prompt !== ''
|
|
1858
|
+
? payload.prompt
|
|
1859
|
+
: '会话已重建(成员恢复)。先读 tasks/thread 当前状态,继续推进;不要重复已完成的工作。',
|
|
1860
|
+
},
|
|
1861
|
+
}, runtime);
|
|
1862
|
+
results.push({
|
|
1863
|
+
memberId,
|
|
1864
|
+
ok: activated.error === undefined,
|
|
1865
|
+
oldSessionId: before,
|
|
1866
|
+
newSessionId: activated.sessionId ?? null,
|
|
1867
|
+
error: activated.error ?? null,
|
|
1868
|
+
});
|
|
1869
|
+
} catch (error) {
|
|
1870
|
+
results.push({ memberId, ok: false, oldSessionId: before, newSessionId: null, error: { code: 'E_RUNTIME', message: error?.message ?? String(error) } });
|
|
1871
|
+
}
|
|
1872
|
+
if (typeof diag?.append === 'function') {
|
|
1873
|
+
diag.append({
|
|
1874
|
+
ev: results.at(-1)?.ok === true ? 'member.reseat' : 'member.reseat.fail',
|
|
1875
|
+
projectId: projectId,
|
|
1876
|
+
memberId,
|
|
1877
|
+
oldSessionId: before,
|
|
1878
|
+
newSessionId: results.at(-1)?.newSessionId ?? null,
|
|
1879
|
+
message: results.at(-1)?.error?.message ?? null,
|
|
1880
|
+
});
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
broadcast(undefined);
|
|
1884
|
+
return send(res, { ok: results.every((row) => row.ok), results });
|
|
1885
|
+
}
|
|
1798
1886
|
try {
|
|
1799
1887
|
const result = await runtime.service.dispatch({
|
|
1800
1888
|
type: body.type,
|
|
@@ -52,7 +52,7 @@ export async function startReview({ service, projectRuntime, job, actor, votes }
|
|
|
52
52
|
const orders = [];
|
|
53
53
|
for (let index = 0; index < count; index++) {
|
|
54
54
|
const order = Math.random() < 0.5 ? 'ab' : 'ba';
|
|
55
|
-
const body = buildReviewRequest({ before: job.before, after: job.candidate, order, jobId: job.id });
|
|
55
|
+
const body = buildReviewRequest({ before: job.before, after: job.candidate, order, jobId: job.id, taskId: reviewTaskId, baseSeq: 0 });
|
|
56
56
|
await service.dispatch({
|
|
57
57
|
type: 'member.message',
|
|
58
58
|
payload: { memberId: reviewer.id, body },
|
package/lib/skillopt/reviewer.js
CHANGED
|
@@ -13,10 +13,12 @@ export const REVIEWER_ROLE = '评审';
|
|
|
13
13
|
export const REVIEWER_NAME = '评审官';
|
|
14
14
|
|
|
15
15
|
/** 评审 prompt(盲评两版,输出一行 JSON)。 */
|
|
16
|
-
export function buildReviewRequest({ before, after, order, jobId }) {
|
|
16
|
+
export function buildReviewRequest({ before, after, order, jobId, taskId, baseSeq = 0 }) {
|
|
17
17
|
const aIsAfter = order === 'ba';
|
|
18
18
|
const versionA = aIsAfter ? after : before;
|
|
19
19
|
const versionB = aIsAfter ? before : after;
|
|
20
|
+
const card = typeof taskId === 'string' && taskId !== '' ? taskId : '<taskId>';
|
|
21
|
+
const verdict = '{"better":"A","margin":"clear","reason":"一句话理由"}';
|
|
20
22
|
return [
|
|
21
23
|
`【技能盲评 ${jobId}】你是独立评审。只做比较,不要修改任何文件。`,
|
|
22
24
|
'',
|
|
@@ -30,9 +32,13 @@ export function buildReviewRequest({ before, after, order, jobId }) {
|
|
|
30
32
|
'## 版本 B',
|
|
31
33
|
versionB,
|
|
32
34
|
'',
|
|
33
|
-
'
|
|
34
|
-
'
|
|
35
|
-
|
|
35
|
+
'## 如何提交结论(必须用 team 工具,两步)',
|
|
36
|
+
'1) 读取评审卡当前 headSeq:调用 team 工具',
|
|
37
|
+
` {"action":"thread","taskId":"${card}"}`,
|
|
38
|
+
'2) 用拿到的 headSeq 回帖(body 里只放一行 JSON):',
|
|
39
|
+
` {"action":"reply","taskId":"${card}","baseSeq":${baseSeq},"body":"${verdict.replace(/"/g, '\\"')}"}`,
|
|
40
|
+
`注意:action 必须是 "reply"(不是 thread.post),参数名是 taskId / baseSeq / body;初始 baseSeq 通常为 ${baseSeq},若第 1 步返回的 headSeq 不同,用返回的 headSeq。`,
|
|
41
|
+
'除这次 team 回帖外不要做其它动作。',
|
|
36
42
|
].join('\n');
|
|
37
43
|
}
|
|
38
44
|
|
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.19",
|
|
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",
|