@suifei/dsh-ai-team 0.4.14 → 0.4.18
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 +96 -7
- 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.18';
|
|
56
56
|
const HUMAN_ID = 'mem_human';
|
|
57
57
|
|
|
58
58
|
const SKILLOPT_BACKENDS = ['mock', 'claude', 'codex', 'copilot', 'cursor', 'pi', 'opencode', 'handoff', 'azure_openai'];
|
|
@@ -540,13 +540,30 @@ export function apply(ctx, config = {}) {
|
|
|
540
540
|
});
|
|
541
541
|
console.warn('[ai-team] wake failed:', plan.memberId, error?.code ?? error?.message ?? error);
|
|
542
542
|
// 一次性迁移自愈:旧形态成员会话(历史上由 agents.create 创建、
|
|
543
|
-
// 不在 subagent catalog
|
|
544
|
-
// subagent
|
|
543
|
+
// 不在 subagent catalog)或重启后不可恢复的会话(NOT_RESUMABLE /
|
|
544
|
+
// is unavailable)无法经父→子通道投递。识别该失败后自动以 subagent
|
|
545
|
+
// 形态重建一次(重置会话),避免成员静默不再被唤醒。
|
|
546
|
+
// 注意:member 是 try 块内变量,catch 里必须从 state 取成员。
|
|
547
|
+
const targetMember = projectRuntime.service.state.members?.[plan.memberId];
|
|
545
548
|
const failureText = `${error?.code ?? ''} ${error?.message ?? String(error)}`;
|
|
546
|
-
//
|
|
547
|
-
|
|
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
|
+
});
|
|
548
558
|
const legacySession = /subagent|not-found|not found|E_SESSION_MISSING|NOT_RESUMABLE|unavailable/i.test(failureText)
|
|
549
|
-
&& typeof
|
|
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
|
+
});
|
|
550
567
|
if (legacySession) {
|
|
551
568
|
try {
|
|
552
569
|
const reseated = await activateMember({
|
|
@@ -560,9 +577,10 @@ export function apply(ctx, config = {}) {
|
|
|
560
577
|
ev: 'member.autoreseat',
|
|
561
578
|
projectId: projectRuntime.id,
|
|
562
579
|
memberId: plan.memberId,
|
|
563
|
-
oldSessionId:
|
|
580
|
+
oldSessionId: targetMember.sessionId,
|
|
564
581
|
newSessionId: reseated?.sessionId ?? null,
|
|
565
582
|
ok: reseated?.error === undefined,
|
|
583
|
+
error: reseated?.error ?? null,
|
|
566
584
|
});
|
|
567
585
|
} catch (reseatError) {
|
|
568
586
|
diag.append({
|
|
@@ -965,6 +983,25 @@ export function apply(ctx, config = {}) {
|
|
|
965
983
|
if (runtime === null) return '[skillopt optimize] no active project runtime';
|
|
966
984
|
const jobId = 'job_' + Date.now().toString(36) + Math.random().toString(36).slice(2, 8);
|
|
967
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
|
+
}
|
|
968
1005
|
const started = await startReview({
|
|
969
1006
|
service: runtime.service,
|
|
970
1007
|
projectRuntime: runtime,
|
|
@@ -1794,6 +1831,58 @@ export function apply(ctx, config = {}) {
|
|
|
1794
1831
|
broadcast(undefined);
|
|
1795
1832
|
return send(res, activated);
|
|
1796
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
|
+
}
|
|
1797
1886
|
try {
|
|
1798
1887
|
const result = await runtime.service.dispatch({
|
|
1799
1888
|
type: body.type,
|
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.18",
|
|
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",
|