@suifei/dsh-ai-team 0.4.81 → 0.4.83
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/client.js +7 -4
- package/index.js +67 -1
- package/lib/runtime/wake-failure.js +42 -22
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -270,7 +270,7 @@ window.__ModuleLoader__.load({
|
|
|
270
270
|
memberModel: '模型',
|
|
271
271
|
memberReasoning: '推理等级',
|
|
272
272
|
memberReasoningDefault: '跟随模型默认',
|
|
273
|
-
memberReasoningNone: '
|
|
273
|
+
memberReasoningNone: '该模型没有声明推理档位;在 DSH 提供商设置里为它配置 reasoningEfforts 后,这里才会出现可选档位',
|
|
274
274
|
memberReasoningError: '推理等级读取失败:{message}',
|
|
275
275
|
memberReasoningAsk: '为 {model} 选择推理等级',
|
|
276
276
|
memberProviderDefault: '跟随系统默认',
|
|
@@ -687,7 +687,7 @@ window.__ModuleLoader__.load({
|
|
|
687
687
|
memberModel: 'Model',
|
|
688
688
|
memberReasoning: 'Reasoning',
|
|
689
689
|
memberReasoningDefault: 'Model default',
|
|
690
|
-
memberReasoningNone: 'This model
|
|
690
|
+
memberReasoningNone: 'This model declares no reasoning levels; add reasoningEfforts for it in the DSH provider settings to enable this selector',
|
|
691
691
|
memberReasoningError: 'Could not read reasoning levels: {message}',
|
|
692
692
|
memberReasoningAsk: 'Pick a reasoning level for {model}',
|
|
693
693
|
memberProviderDefault: 'Follow system default',
|
|
@@ -2529,6 +2529,11 @@ window.__ModuleLoader__.load({
|
|
|
2529
2529
|
})
|
|
2530
2530
|
.then((body) => {
|
|
2531
2531
|
if (!alive) return;
|
|
2532
|
+
// 端点用 ok:false 表达「查不到」:不能当成「该模型没有档位」,否则用户
|
|
2533
|
+
// 会以为模型不支持推理,而实际是适配器没回答。
|
|
2534
|
+
if (body !== null && typeof body === 'object' && body.ok === false) {
|
|
2535
|
+
throw new Error(body?.error?.message ?? t('memberReasoningError'));
|
|
2536
|
+
}
|
|
2532
2537
|
setEfforts({ efforts: Array.isArray(body?.efforts) ? body.efforts : [], defaultEffort: body?.defaultEffort ?? null });
|
|
2533
2538
|
setEffortsError('');
|
|
2534
2539
|
})
|
|
@@ -2551,8 +2556,6 @@ window.__ModuleLoader__.load({
|
|
|
2551
2556
|
: efforts !== null && availableEfforts.length === 0 && effortsLoading === false
|
|
2552
2557
|
? t('memberReasoningNone')
|
|
2553
2558
|
: '';
|
|
2554
|
-
const providers2 = providers;
|
|
2555
|
-
const providersAll = providers2;
|
|
2556
2559
|
if (provider !== '' && !providers.some((entry) => entry.id === provider)) {
|
|
2557
2560
|
providers.unshift({ id: provider, name: provider, models: model === '' ? [] : [{ id: model, name: model }], modelCount: model === '' ? 0 : 1 });
|
|
2558
2561
|
}
|
package/index.js
CHANGED
|
@@ -49,7 +49,7 @@ import { buildModelCatalog, buildModelEfforts } from './lib/host/model-catalog.j
|
|
|
49
49
|
import { createTeamTool } from './lib/host/member-tools.js';
|
|
50
50
|
import { describeTaskContext, describeWake, planWakes } from './lib/host/waker.js';
|
|
51
51
|
import { describeCauseChain } from './lib/runtime/error-chain.js';
|
|
52
|
-
import { classifyWakeFailure } from './lib/runtime/wake-failure.js';
|
|
52
|
+
import { classifyWakeFailure, isMalformedTurnError } from './lib/runtime/wake-failure.js';
|
|
53
53
|
import { registerShellGuard } from './lib/runtime/shell-guard.js';
|
|
54
54
|
import { createActivationBudget } from './lib/runtime/activation-budget.js';
|
|
55
55
|
import { blocksActivation, probeProviderRegistration } from './lib/runtime/subagent-probe.js';
|
|
@@ -672,6 +672,11 @@ export function apply(ctx, config = {}) {
|
|
|
672
672
|
});
|
|
673
673
|
// blocked 最常见的原因是归档 gate:立刻复核一次血缘归档状态。
|
|
674
674
|
if (endKind === 'blocked') void repairArchivedHosts();
|
|
675
|
+
// 工具参数在传输中截断(MALFORMED_RESPONSE):那次调用没有执行,成员
|
|
676
|
+
// 停在半路。重发一次通常就好,交给带预算的续跑(见 retryMalformedTurn)。
|
|
677
|
+
if (endKind === 'error' && isMalformedTurnError(event?.data?.reason)) {
|
|
678
|
+
void retryMalformedTurn(eventRuntime, member);
|
|
679
|
+
}
|
|
675
680
|
return;
|
|
676
681
|
}
|
|
677
682
|
if (member.lastFailure === undefined || member.lastFailure === null) return;
|
|
@@ -733,6 +738,67 @@ export function apply(ctx, config = {}) {
|
|
|
733
738
|
const projectWorkspace = (projectRuntime, member) => member?.workspace
|
|
734
739
|
|| projectRuntime?.service?.state?.projects?.[projectRuntime.id]?.workspacePath
|
|
735
740
|
|| null;
|
|
741
|
+
// 工具参数截断的续跑预算:与「会话重建」分开计数——重建会丢上下文,
|
|
742
|
+
// 续跑只是重发一条消息,成本低但也不能无限。
|
|
743
|
+
const malformedRetries = createActivationBudget({ limit: 3, windowMs: 10 * 60 * 1000 });
|
|
744
|
+
const retryMalformedTurn = async (projectRuntime, member) => {
|
|
745
|
+
try {
|
|
746
|
+
const project = projectRuntime?.service?.state?.projects?.[projectRuntime.id];
|
|
747
|
+
if (project !== undefined && project.runState === 'stopped') return;
|
|
748
|
+
const budget = malformedRetries.take(member.id);
|
|
749
|
+
if (budget.allowed !== true) {
|
|
750
|
+
diag.append({
|
|
751
|
+
ev: 'member.malformed.retry.suppressed.fail',
|
|
752
|
+
projectId: projectRuntime?.id ?? null,
|
|
753
|
+
memberId: member.id,
|
|
754
|
+
count: budget.count,
|
|
755
|
+
limit: budget.limit,
|
|
756
|
+
windowMs: budget.windowMs,
|
|
757
|
+
});
|
|
758
|
+
return;
|
|
759
|
+
}
|
|
760
|
+
const cwd = projectWorkspace(projectRuntime, member);
|
|
761
|
+
if (typeof cwd !== 'string' || cwd === '') return;
|
|
762
|
+
const parentInfo = await ensureParent();
|
|
763
|
+
if (parentInfo?.agent === undefined) return;
|
|
764
|
+
const subagents = serviceOf(ctx, 'subagents');
|
|
765
|
+
const sessionRuntime = new MemberRuntime({
|
|
766
|
+
subagents,
|
|
767
|
+
sessions: serviceOf(ctx, 'sessions'),
|
|
768
|
+
permissionPresets: serviceOf(ctx, 'permissionPresets'),
|
|
769
|
+
sandboxPolicy: serviceOf(ctx, 'sandboxPolicy'),
|
|
770
|
+
agents: serviceOf(ctx, 'agents'),
|
|
771
|
+
agentPresets: serviceOf(ctx, 'agentPresets'),
|
|
772
|
+
direct: false,
|
|
773
|
+
parent: parentInfo.agent,
|
|
774
|
+
provider: (typeof subagents?.list === 'function' ? subagents.list() : [])[0],
|
|
775
|
+
preset: 'standard',
|
|
776
|
+
cwd,
|
|
777
|
+
trackHandle: (sessionId, handle) => resumedHandles.set(sessionId, handle),
|
|
778
|
+
});
|
|
779
|
+
const delivered = await sessionRuntime.wake(member, {
|
|
780
|
+
prompt: [
|
|
781
|
+
'上一轮你发起的工具调用在传输中被截断(Unexpected end of JSON input),那次调用没有执行。',
|
|
782
|
+
'请重新发起同一次调用:参数写成一行紧凑 JSON,不要在参数里展开大段文本;',
|
|
783
|
+
'需要写长内容时改用更短的措辞,或先落盘再引用路径。',
|
|
784
|
+
].join(''),
|
|
785
|
+
});
|
|
786
|
+
diag.append({
|
|
787
|
+
ev: 'member.malformed.retry',
|
|
788
|
+
projectId: projectRuntime?.id ?? null,
|
|
789
|
+
memberId: member.id,
|
|
790
|
+
attempt: budget.count,
|
|
791
|
+
messageId: delivered?.messageId ?? null,
|
|
792
|
+
});
|
|
793
|
+
} catch (error) {
|
|
794
|
+
diag.append({
|
|
795
|
+
ev: 'member.malformed.retry.fail',
|
|
796
|
+
projectId: projectRuntime?.id ?? null,
|
|
797
|
+
memberId: member?.id ?? null,
|
|
798
|
+
message: error?.message ?? String(error),
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
};
|
|
736
802
|
const wakeFromResult = async (projectRuntime, result, actor = {}) => {
|
|
737
803
|
if (projectRuntime === null || projectRuntime === undefined) return;
|
|
738
804
|
// P6 停止门(事件 hook 侧):stopped 项目停止**自动派发**;Human
|
|
@@ -1,22 +1,42 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 唤醒失败的归类。
|
|
3
|
-
*
|
|
4
|
-
* 实机根因(2026-11-12 确诊):成员回合结束后会话仍被一个活跃写句柄占用,
|
|
5
|
-
* `sessionQuery.observeSession` 拒绝发放读租约,冷恢复必然失败:
|
|
6
|
-
*
|
|
7
|
-
* subagent "X" is unavailable
|
|
8
|
-
* cause: session "X" is already owned by an active write handle
|
|
9
|
-
*
|
|
10
|
-
* 插件无法释放这个租约(属 Harness 侧的句柄泄漏),只能重建会话。这类失败是
|
|
11
|
-
* **可预期的**,不应按未知故障刷告警;其它原因仍然算真实失败。
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
const BUSY_HANDLE = /active write handle/i;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @param {string|null|undefined} causeChain `describeCauseChain()` 的输出
|
|
18
|
-
* @returns {'wake.session-busy'|'wake.fail'} busy 表示「写租约被占用,必然需要重建」
|
|
19
|
-
*/
|
|
20
|
-
export function classifyWakeFailure(causeChain) {
|
|
21
|
-
return typeof causeChain === 'string' && BUSY_HANDLE.test(causeChain) ? 'wake.session-busy' : 'wake.fail';
|
|
22
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* 唤醒失败的归类。
|
|
3
|
+
*
|
|
4
|
+
* 实机根因(2026-11-12 确诊):成员回合结束后会话仍被一个活跃写句柄占用,
|
|
5
|
+
* `sessionQuery.observeSession` 拒绝发放读租约,冷恢复必然失败:
|
|
6
|
+
*
|
|
7
|
+
* subagent "X" is unavailable
|
|
8
|
+
* cause: session "X" is already owned by an active write handle
|
|
9
|
+
*
|
|
10
|
+
* 插件无法释放这个租约(属 Harness 侧的句柄泄漏),只能重建会话。这类失败是
|
|
11
|
+
* **可预期的**,不应按未知故障刷告警;其它原因仍然算真实失败。
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const BUSY_HANDLE = /active write handle/i;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @param {string|null|undefined} causeChain `describeCauseChain()` 的输出
|
|
18
|
+
* @returns {'wake.session-busy'|'wake.fail'} busy 表示「写租约被占用,必然需要重建」
|
|
19
|
+
*/
|
|
20
|
+
export function classifyWakeFailure(causeChain) {
|
|
21
|
+
return typeof causeChain === 'string' && BUSY_HANDLE.test(causeChain) ? 'wake.session-busy' : 'wake.fail';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 回合是否因「工具参数在传输中截断」而失败。
|
|
26
|
+
*
|
|
27
|
+
* 实机(2026-11-13):成员在第 4 步发起的 `team` 调用只到
|
|
28
|
+
* `{"action": "tasks", "qaChecklist": ` 就断了,宿主解析不出 JSON,整轮以
|
|
29
|
+
* `MALFORMED_RESPONSE` 结束——工具没执行、成员也没被唤醒,任务停在半路。
|
|
30
|
+
* 这类失败是**传输/采样**造成的,与任务本身无关:重发一次通常就好,所以值得
|
|
31
|
+
* 自动续跑一次(预算见调用方),而不是让成员静默停摆。
|
|
32
|
+
*
|
|
33
|
+
* @param {{kind?: string, error?: {code?: string, message?: string}}|null|undefined} reason `turn/end` 的 reason
|
|
34
|
+
* @returns {boolean}
|
|
35
|
+
*/
|
|
36
|
+
export function isMalformedTurnError(reason) {
|
|
37
|
+
if (reason === null || typeof reason !== 'object' || reason.kind !== 'error') return false;
|
|
38
|
+
const error = reason.error;
|
|
39
|
+
if (error === null || typeof error !== 'object') return false;
|
|
40
|
+
if (String(error.code ?? '').toUpperCase() === 'MALFORMED_RESPONSE') return true;
|
|
41
|
+
return /unexpected end of json input/i.test(String(error.message ?? ''));
|
|
42
|
+
}
|
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.83",
|
|
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",
|