dsh-cohub 0.13.8 → 0.13.9
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/README.md +1 -1
- package/lib/client.js +12 -211
- package/lib/index.js +45 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# dsh-cohub
|
|
2
2
|
|
|
3
|
-
> 本文对应 **v0.13.
|
|
3
|
+
> 本文对应 **v0.13.9**;完整变更历史见 [CHANGELOG.md](./CHANGELOG.md)。
|
|
4
4
|
|
|
5
5
|
DeepSeek Harness 版(对照 [OpenCode 版](../oh-my-opencode-cohub/)):中文智能体编排插件。
|
|
6
6
|
把「纯调度模式 + 内置技能(代理编排体系 + co-cordis 组合创作 + 写作组)+ 多模型共识 + 运行期调度韧性」移植到 DSH 原生能力之上。
|
package/lib/client.js
CHANGED
|
@@ -450,7 +450,7 @@ window.__ModuleLoader__.load({
|
|
|
450
450
|
var React = require("react");
|
|
451
451
|
|
|
452
452
|
/* ────────────────────────────────────────────────────────────────
|
|
453
|
-
* CoHub
|
|
453
|
+
* CoHub 代理设置页(DSH 0.2.1)
|
|
454
454
|
*
|
|
455
455
|
* 历史纠正(旧注释是错的,别再抄回去):
|
|
456
456
|
* ❌「0.2 官方设置页会自动按 volatile 字段生成表单,无需客户端」
|
|
@@ -533,14 +533,8 @@ window.__ModuleLoader__.load({
|
|
|
533
533
|
|
|
534
534
|
var zh = {
|
|
535
535
|
nav: "CoHub 代理",
|
|
536
|
-
title: "CoHub
|
|
537
|
-
description: "
|
|
538
|
-
provider: "供应商",
|
|
539
|
-
model: "模型",
|
|
540
|
-
configured: "显式配置",
|
|
541
|
-
inherited: "继承父模型",
|
|
542
|
-
providerInherit: "(不配置,继承父模型)",
|
|
543
|
-
modelInherit: "(继承父模型)",
|
|
536
|
+
title: "CoHub 代理",
|
|
537
|
+
description: "团队 → 角色库。每个角色的提示词、绑定工具与运行模型(供应商 / 模型 / 推理强度 / 最大输出)统一在「角色库」里配置。",
|
|
544
538
|
loading: "加载中…",
|
|
545
539
|
unavailable: "当前设置不可用(宿主未提供 cohub 配置命名空间)。",
|
|
546
540
|
readOnly: "当前连接只读,无法修改设置。",
|
|
@@ -552,17 +546,8 @@ window.__ModuleLoader__.load({
|
|
|
552
546
|
saving: "保存中…",
|
|
553
547
|
saved: "已保存。",
|
|
554
548
|
discard: "放弃修改",
|
|
555
|
-
reset: "重置",
|
|
556
|
-
customModel: "输入模型 ID",
|
|
557
|
-
selectProviderFirst: "请先选择供应商",
|
|
558
549
|
loadProvidersFailed: "模型供应商列表加载失败",
|
|
559
550
|
emptyModel: "该供应商未提供模型目录",
|
|
560
|
-
unavailableOption: "{value}(不可用)",
|
|
561
|
-
reasoningEffort: "推理强度",
|
|
562
|
-
effortInherit: "(继承父会话)",
|
|
563
|
-
effortSelectModelFirst: "请先选择模型",
|
|
564
|
-
effortUnsupported: "该模型不支持",
|
|
565
|
-
effortUnsupportedOption: "{value}(当前模型不支持)",
|
|
566
551
|
"skill.co-orchestrator": "调度编排",
|
|
567
552
|
"skill.co-planner": "方案制定",
|
|
568
553
|
"skill.co-oracle": "架构/代码审查",
|
|
@@ -730,14 +715,8 @@ window.__ModuleLoader__.load({
|
|
|
730
715
|
|
|
731
716
|
var en = {
|
|
732
717
|
nav: "CoHub agents",
|
|
733
|
-
title: "CoHub
|
|
734
|
-
description: "
|
|
735
|
-
provider: "Provider",
|
|
736
|
-
model: "Model",
|
|
737
|
-
configured: "Explicit",
|
|
738
|
-
inherited: "Inherited",
|
|
739
|
-
providerInherit: "(not set — inherit parent model)",
|
|
740
|
-
modelInherit: "(inherit parent model)",
|
|
718
|
+
title: "CoHub agents",
|
|
719
|
+
description: "Teams → Roles. Each role's prompt, bound tools and runtime model (provider / model / reasoning effort / max output) are configured in the role library.",
|
|
741
720
|
loading: "Loading…",
|
|
742
721
|
unavailable: "This setting is unavailable (the Host does not serve the cohub configuration namespace).",
|
|
743
722
|
readOnly: "This connection is read-only; settings cannot be changed.",
|
|
@@ -749,17 +728,8 @@ window.__ModuleLoader__.load({
|
|
|
749
728
|
saving: "Saving…",
|
|
750
729
|
saved: "Saved.",
|
|
751
730
|
discard: "Discard",
|
|
752
|
-
reset: "Reset",
|
|
753
|
-
customModel: "Enter model ID",
|
|
754
|
-
selectProviderFirst: "Select a provider first",
|
|
755
731
|
loadProvidersFailed: "Failed to load the provider catalog",
|
|
756
732
|
emptyModel: "This provider publishes no model catalog",
|
|
757
|
-
unavailableOption: "{value} (unavailable)",
|
|
758
|
-
reasoningEffort: "Reasoning effort",
|
|
759
|
-
effortInherit: "(inherit from parent session)",
|
|
760
|
-
effortSelectModelFirst: "Select a model first",
|
|
761
|
-
effortUnsupported: "Not supported by this model",
|
|
762
|
-
effortUnsupportedOption: "{value} (unsupported by this model)",
|
|
763
733
|
"skill.co-orchestrator": "Orchestrator",
|
|
764
734
|
"skill.co-planner": "Planner",
|
|
765
735
|
"skill.co-oracle": "Architecture/code review",
|
|
@@ -2952,10 +2922,6 @@ window.__ModuleLoader__.load({
|
|
|
2952
2922
|
".cohub-row-id{color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px;}",
|
|
2953
2923
|
".cohub-badge{margin-left:auto;border-radius:999px;padding:1px 8px;font-size:11px;line-height:17px;white-space:nowrap;border:1px solid var(--dsw-alias-border-l2);color:var(--dsw-alias-label-tertiary);}",
|
|
2954
2924
|
".cohub-badge-explicit{color:var(--dsw-alias-state-success-primary);border-color:var(--dsw-alias-state-success-primary);}",
|
|
2955
|
-
// 四列:供应商 / 模型 / 推理强度 / 重置。三列下拉都等分剩余宽度,重置按钮自适应。
|
|
2956
|
-
".cohub-fields{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr) minmax(0,1fr) auto;gap:8px;margin-top:8px;align-items:end;}",
|
|
2957
|
-
// 窄容器下 4 列会把下拉压到不可读:退成两列(前三个字段各占一行两列,按钮贴右下)。
|
|
2958
|
-
"@media (max-width:560px){.cohub-fields{grid-template-columns:minmax(0,1fr) minmax(0,1fr);}}",
|
|
2959
2925
|
".cohub-field{display:flex;flex-direction:column;gap:4px;min-width:0;}",
|
|
2960
2926
|
".cohub-label{color:var(--dsw-alias-label-secondary);font-size:12px;line-height:18px;}",
|
|
2961
2927
|
".cohub-select,.cohub-input{box-sizing:border-box;width:100%;height:32px;font:inherit;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-3);border:1px solid var(--dsw-alias-border-l2);border-radius:8px;padding:0 10px;font-size:13px;line-height:20px;}",
|
|
@@ -2975,7 +2941,7 @@ window.__ModuleLoader__.load({
|
|
|
2975
2941
|
".cohub-button-ghost{color:var(--dsw-alias-label-secondary);background:transparent;border:1px solid var(--dsw-alias-border-l2);}",
|
|
2976
2942
|
".cohub-button-ghost:hover:not(:disabled){color:var(--dsw-alias-label-primary);}",
|
|
2977
2943
|
".cohub-button:disabled{opacity:.45;cursor:default;}",
|
|
2978
|
-
// ──
|
|
2944
|
+
// ── 自定义团队区块(各自独立的草稿与保存按钮) ──
|
|
2979
2945
|
".cohub-roles{display:flex;flex-direction:column;gap:12px;margin-top:8px;padding-top:16px;border-top:1px solid var(--dsw-alias-border-l2);}",
|
|
2980
2946
|
".cohub-subtitle{margin:0;font-size:14px;font-weight:600;line-height:22px;}",
|
|
2981
2947
|
".cohub-role-summary{flex:1 1 140px;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px;}",
|
|
@@ -3046,7 +3012,7 @@ window.__ModuleLoader__.load({
|
|
|
3046
3012
|
/**
|
|
3047
3013
|
* settings.section 页面。
|
|
3048
3014
|
* @param props - 注入面:hooks.cohubSkills→useCohubSkills、动作、locale 提供的 t。
|
|
3049
|
-
* @returns
|
|
3015
|
+
* @returns 页面结构:团队 → 角色库(角色的提示词 / 绑定工具 / 运行模型),底部是 Config.skills 的保存动作条。
|
|
3050
3016
|
*/
|
|
3051
3017
|
function CohubSection(props) {
|
|
3052
3018
|
var t = typeof props.t === "function" ? props.t : fallbackTranslate;
|
|
@@ -3068,171 +3034,8 @@ window.__ModuleLoader__.load({
|
|
|
3068
3034
|
|
|
3069
3035
|
var locked = !state.writable || state.saving || state.conflicted;
|
|
3070
3036
|
var providers = state.providers || [];
|
|
3071
|
-
var modelsByProvider = state.modelsByProvider || {};
|
|
3072
3037
|
var rows = state.rows || [];
|
|
3073
3038
|
|
|
3074
|
-
function renderRow(row) {
|
|
3075
|
-
var known = SKILL_NAMES.indexOf(row.name) >= 0;
|
|
3076
|
-
var label = known ? t("skill." + row.name) : row.name;
|
|
3077
|
-
var providerIds = [];
|
|
3078
|
-
var providerOptions = [
|
|
3079
|
-
React.createElement("option", { key: "__inherit", value: "" }, t("providerInherit"))
|
|
3080
|
-
];
|
|
3081
|
-
for (var i = 0; i < providers.length; i += 1) {
|
|
3082
|
-
providerIds.push(providers[i].id);
|
|
3083
|
-
providerOptions.push(React.createElement("option", { key: providers[i].id, value: providers[i].id }, providers[i].label));
|
|
3084
|
-
}
|
|
3085
|
-
if (row.provider !== "" && providerIds.indexOf(row.provider) < 0) {
|
|
3086
|
-
// 已存但当前目录里没有:给一个不可选回显项,避免下拉显示成第一项造成误读。
|
|
3087
|
-
providerOptions.push(React.createElement("option", {
|
|
3088
|
-
key: "__missing-provider",
|
|
3089
|
-
value: row.provider,
|
|
3090
|
-
disabled: true
|
|
3091
|
-
}, state.catalogStatus === "ready" ? t("unavailableOption", { value: row.provider }) : row.provider));
|
|
3092
|
-
}
|
|
3093
|
-
|
|
3094
|
-
var models = modelsByProvider[row.provider] || [];
|
|
3095
|
-
var modelControl;
|
|
3096
|
-
if (row.provider === "") {
|
|
3097
|
-
modelControl = React.createElement("select", { className: "cohub-select", value: "", disabled: true },
|
|
3098
|
-
React.createElement("option", { value: "" }, t("selectProviderFirst")));
|
|
3099
|
-
} else if (state.catalogStatus === "loading") {
|
|
3100
|
-
modelControl = React.createElement("select", { className: "cohub-select", value: "", disabled: true },
|
|
3101
|
-
React.createElement("option", { value: "" }, t("loading")));
|
|
3102
|
-
} else if (models.length > 0) {
|
|
3103
|
-
// 未保存 model 时必须插入 value="" 的占位项。否则 <select value=""> 会被浏览器
|
|
3104
|
-
// 渲染成列表第一项,用户以为已选、实际存的仍是空 → 子代理拿不到模型(UNKNOWN_MODEL)。
|
|
3105
|
-
var modelOptions = [React.createElement("option", { key: "__inherit", value: "" }, t("modelInherit"))];
|
|
3106
|
-
var modelIds = [];
|
|
3107
|
-
for (var m = 0; m < models.length; m += 1) {
|
|
3108
|
-
modelIds.push(models[m].id);
|
|
3109
|
-
modelOptions.push(React.createElement("option", { key: models[m].id, value: models[m].id }, models[m].label));
|
|
3110
|
-
}
|
|
3111
|
-
if (row.model !== "" && modelIds.indexOf(row.model) < 0) {
|
|
3112
|
-
modelOptions.push(React.createElement("option", {
|
|
3113
|
-
key: "__missing-model",
|
|
3114
|
-
value: row.model,
|
|
3115
|
-
disabled: true
|
|
3116
|
-
}, t("unavailableOption", { value: row.model })));
|
|
3117
|
-
}
|
|
3118
|
-
modelControl = React.createElement("select", {
|
|
3119
|
-
className: "cohub-select",
|
|
3120
|
-
value: row.model === "" ? "" : row.model,
|
|
3121
|
-
disabled: locked,
|
|
3122
|
-
"aria-label": label + " · " + t("model"),
|
|
3123
|
-
onChange: function (event) {
|
|
3124
|
-
props.editRow(row.name, "model", event.target.value);
|
|
3125
|
-
}
|
|
3126
|
-
}, modelOptions);
|
|
3127
|
-
} else {
|
|
3128
|
-
// 该供应商没有可用模型目录(或目录加载失败)→ 降级为手填 model id。
|
|
3129
|
-
modelControl = React.createElement("input", {
|
|
3130
|
-
className: "cohub-input",
|
|
3131
|
-
type: "text",
|
|
3132
|
-
value: row.model,
|
|
3133
|
-
disabled: locked,
|
|
3134
|
-
"aria-label": label + " · " + t("model"),
|
|
3135
|
-
placeholder: state.catalogStatus === "ready" ? t("emptyModel") + " / " + t("customModel") : t("customModel"),
|
|
3136
|
-
onChange: function (event) {
|
|
3137
|
-
props.editRow(row.name, "model", event.target.value);
|
|
3138
|
-
}
|
|
3139
|
-
});
|
|
3140
|
-
}
|
|
3141
|
-
|
|
3142
|
-
var configured = row.provider !== "" || row.model !== "" || effortOf(row) !== "";
|
|
3143
|
-
|
|
3144
|
-
// 第三个下拉:推理强度。档位来自模型目录(models[].reasoning.efforts),
|
|
3145
|
-
// 按「供应商 + 模型」这一对查表;不支持的模型整个 reasoning 字段缺失 → 禁用并提示。
|
|
3146
|
-
var currentEffort = effortOf(row);
|
|
3147
|
-
var efforts = [];
|
|
3148
|
-
if (row.provider !== "" && row.model !== "") {
|
|
3149
|
-
var byModel = state.effortsByModel && state.effortsByModel[row.provider];
|
|
3150
|
-
var list = byModel ? byModel[row.model] : undefined;
|
|
3151
|
-
if (Array.isArray(list)) efforts = list;
|
|
3152
|
-
}
|
|
3153
|
-
var effortControl;
|
|
3154
|
-
if (row.provider === "") {
|
|
3155
|
-
effortControl = React.createElement("select", { className: "cohub-select", value: "", disabled: true },
|
|
3156
|
-
React.createElement("option", { value: "" }, t("selectProviderFirst")));
|
|
3157
|
-
} else if (state.catalogStatus === "loading") {
|
|
3158
|
-
effortControl = React.createElement("select", { className: "cohub-select", value: "", disabled: true },
|
|
3159
|
-
React.createElement("option", { value: "" }, t("loading")));
|
|
3160
|
-
} else if (row.model === "") {
|
|
3161
|
-
effortControl = React.createElement("select", { className: "cohub-select", value: "", disabled: true },
|
|
3162
|
-
React.createElement("option", { value: "" }, t("effortSelectModelFirst")));
|
|
3163
|
-
} else if (efforts.length === 0) {
|
|
3164
|
-
// 模型目录里没有该模型的 reasoning 信息(或手填了不在目录里的 model id)→ 不支持。
|
|
3165
|
-
effortControl = React.createElement("select", { className: "cohub-select", value: "", disabled: true },
|
|
3166
|
-
React.createElement("option", { value: "" }, t("effortUnsupported")));
|
|
3167
|
-
} else {
|
|
3168
|
-
// 与模型下拉同理:value="" 的继承占位项必须在首位,否则浏览器把第一档显示成已选,
|
|
3169
|
-
// 而实际存的是空串(用户以为配了 high,其实继承父会话)。
|
|
3170
|
-
var effortOptions = [React.createElement("option", { key: "__inherit", value: "" }, t("effortInherit"))];
|
|
3171
|
-
var effortIds = [];
|
|
3172
|
-
for (var e = 0; e < efforts.length; e += 1) {
|
|
3173
|
-
effortIds.push(efforts[e].id);
|
|
3174
|
-
effortOptions.push(React.createElement("option", { key: efforts[e].id, value: efforts[e].id }, efforts[e].label));
|
|
3175
|
-
}
|
|
3176
|
-
if (currentEffort !== "" && effortIds.indexOf(currentEffort) < 0) {
|
|
3177
|
-
// 已配强度不在当前模型档位里(手改过 YAML / 换过模型)→ 给不可选回显项,别静默改成第一档。
|
|
3178
|
-
effortOptions.push(React.createElement("option", {
|
|
3179
|
-
key: "__missing-effort",
|
|
3180
|
-
value: currentEffort,
|
|
3181
|
-
disabled: true
|
|
3182
|
-
}, t("effortUnsupportedOption", { value: currentEffort })));
|
|
3183
|
-
}
|
|
3184
|
-
effortControl = React.createElement("select", {
|
|
3185
|
-
className: "cohub-select",
|
|
3186
|
-
value: currentEffort,
|
|
3187
|
-
disabled: locked,
|
|
3188
|
-
"aria-label": label + " · " + t("reasoningEffort"),
|
|
3189
|
-
onChange: function (event) {
|
|
3190
|
-
props.editRow(row.name, "reasoningEffort", event.target.value);
|
|
3191
|
-
}
|
|
3192
|
-
}, effortOptions);
|
|
3193
|
-
}
|
|
3194
|
-
|
|
3195
|
-
return React.createElement("li", { key: row.name, className: "cohub-row" },
|
|
3196
|
-
React.createElement("div", { className: "cohub-row-head" },
|
|
3197
|
-
React.createElement("span", { className: "cohub-row-name" }, label),
|
|
3198
|
-
React.createElement("span", { className: "cohub-row-id" }, row.name),
|
|
3199
|
-
React.createElement("span", {
|
|
3200
|
-
className: configured ? "cohub-badge cohub-badge-explicit" : "cohub-badge"
|
|
3201
|
-
}, configured ? t("configured") : t("inherited"))
|
|
3202
|
-
),
|
|
3203
|
-
React.createElement("div", { className: "cohub-fields" },
|
|
3204
|
-
React.createElement("div", { className: "cohub-field" },
|
|
3205
|
-
React.createElement("label", { className: "cohub-label" }, t("provider")),
|
|
3206
|
-
React.createElement("select", {
|
|
3207
|
-
className: "cohub-select",
|
|
3208
|
-
value: row.provider,
|
|
3209
|
-
disabled: locked,
|
|
3210
|
-
"aria-label": label + " · " + t("provider"),
|
|
3211
|
-
onChange: function (event) {
|
|
3212
|
-
props.editRow(row.name, "provider", event.target.value);
|
|
3213
|
-
}
|
|
3214
|
-
}, providerOptions)
|
|
3215
|
-
),
|
|
3216
|
-
React.createElement("div", { className: "cohub-field" },
|
|
3217
|
-
React.createElement("label", { className: "cohub-label" }, t("model")),
|
|
3218
|
-
modelControl
|
|
3219
|
-
),
|
|
3220
|
-
React.createElement("div", { className: "cohub-field" },
|
|
3221
|
-
React.createElement("label", { className: "cohub-label" }, t("reasoningEffort")),
|
|
3222
|
-
effortControl
|
|
3223
|
-
),
|
|
3224
|
-
React.createElement("button", {
|
|
3225
|
-
type: "button",
|
|
3226
|
-
className: "cohub-row-reset",
|
|
3227
|
-
disabled: locked || !configured,
|
|
3228
|
-
onClick: function () {
|
|
3229
|
-
props.resetRow(row.name);
|
|
3230
|
-
}
|
|
3231
|
-
}, t("reset"))
|
|
3232
|
-
)
|
|
3233
|
-
);
|
|
3234
|
-
}
|
|
3235
|
-
|
|
3236
3039
|
/* ── 自定义团队:增删改 Config.customRoles ─────────────────── */
|
|
3237
3040
|
|
|
3238
3041
|
var roles = state.roles || [];
|
|
@@ -4242,9 +4045,6 @@ window.__ModuleLoader__.load({
|
|
|
4242
4045
|
)
|
|
4243
4046
|
);
|
|
4244
4047
|
|
|
4245
|
-
var items = [];
|
|
4246
|
-
for (var i = 0; i < rows.length; i += 1) items.push(renderRow(rows[i]));
|
|
4247
|
-
|
|
4248
4048
|
var status = null;
|
|
4249
4049
|
var statusClass = "cohub-status";
|
|
4250
4050
|
if (state.conflicted) {
|
|
@@ -4280,7 +4080,10 @@ window.__ModuleLoader__.load({
|
|
|
4280
4080
|
state.conflicted
|
|
4281
4081
|
? React.createElement("p", { className: "cohub-notice cohub-notice-warn" }, t("conflicted"))
|
|
4282
4082
|
: null,
|
|
4283
|
-
|
|
4083
|
+
teamsBlock,
|
|
4084
|
+
rolesBlock,
|
|
4085
|
+
// 角色库 / 角色编辑里的模型区写的是 Config.skills,统一由这条动作条落盘。
|
|
4086
|
+
// 顶部「每个代理一行」的模型区块已移除,这里只剩保存 / 放弃与状态提示。
|
|
4284
4087
|
React.createElement("div", { className: "cohub-actions" },
|
|
4285
4088
|
status !== null ? React.createElement("p", { className: statusClass }, status) : null,
|
|
4286
4089
|
React.createElement("button", {
|
|
@@ -4299,9 +4102,7 @@ window.__ModuleLoader__.load({
|
|
|
4299
4102
|
props.save();
|
|
4300
4103
|
}
|
|
4301
4104
|
}, t(state.saving ? "saving" : "save"))
|
|
4302
|
-
)
|
|
4303
|
-
teamsBlock,
|
|
4304
|
-
rolesBlock
|
|
4105
|
+
)
|
|
4305
4106
|
);
|
|
4306
4107
|
}
|
|
4307
4108
|
|
package/lib/index.js
CHANGED
|
@@ -6100,6 +6100,28 @@ function normalizeArguments(args) {
|
|
|
6100
6100
|
}
|
|
6101
6101
|
return raw.replace(/\s+/g, " ").trim().slice(0, 200);
|
|
6102
6102
|
}
|
|
6103
|
+
function describeFailureDetail(value) {
|
|
6104
|
+
const seen = new Set;
|
|
6105
|
+
let cur = value;
|
|
6106
|
+
let text;
|
|
6107
|
+
while (cur !== null && cur !== undefined && typeof cur === "object" && !seen.has(cur)) {
|
|
6108
|
+
seen.add(cur);
|
|
6109
|
+
const next = cur.error ?? cur.errorMessage ?? cur.failure ?? cur.message ?? cur.cause;
|
|
6110
|
+
if (next === cur || next === null || next === undefined)
|
|
6111
|
+
break;
|
|
6112
|
+
cur = next;
|
|
6113
|
+
}
|
|
6114
|
+
if (typeof cur === "string")
|
|
6115
|
+
text = cur;
|
|
6116
|
+
else if (cur !== null && cur !== undefined && typeof cur !== "object")
|
|
6117
|
+
text = String(cur);
|
|
6118
|
+
if (text === undefined)
|
|
6119
|
+
return;
|
|
6120
|
+
const oneLine = text.replace(/\s+/g, " ").trim();
|
|
6121
|
+
if (oneLine.length === 0)
|
|
6122
|
+
return;
|
|
6123
|
+
return oneLine.length > 200 ? oneLine.slice(0, 200) + "…" : oneLine;
|
|
6124
|
+
}
|
|
6103
6125
|
|
|
6104
6126
|
class StallWatchdog {
|
|
6105
6127
|
cfg;
|
|
@@ -6749,6 +6771,7 @@ function createDelegateTool(ctx, getRoutes, config = {}, getSettings) {
|
|
|
6749
6771
|
const runAttempts = async (outerSignal) => {
|
|
6750
6772
|
let lastReason = "unknown";
|
|
6751
6773
|
let lastDiagnostic;
|
|
6774
|
+
let lastRunError;
|
|
6752
6775
|
let lastPartial = "";
|
|
6753
6776
|
let lastPartialBudget = "";
|
|
6754
6777
|
const stallState = { last: null };
|
|
@@ -6862,6 +6885,7 @@ function createDelegateTool(ctx, getRoutes, config = {}, getSettings) {
|
|
|
6862
6885
|
await new Promise((r) => setTimeout(r, retry.retryDelayMs));
|
|
6863
6886
|
continue;
|
|
6864
6887
|
}
|
|
6888
|
+
lastRunError = describeFailureDetail(error) ?? lastRunError;
|
|
6865
6889
|
reportAttempt("", "failed", String(error?.message ?? error));
|
|
6866
6890
|
throw error;
|
|
6867
6891
|
}
|
|
@@ -6898,6 +6922,7 @@ function createDelegateTool(ctx, getRoutes, config = {}, getSettings) {
|
|
|
6898
6922
|
await safeDispose();
|
|
6899
6923
|
outcome = { stopReason: "aborted", output: [], diagnostic: "raced abort(result 未结算)" };
|
|
6900
6924
|
} else {
|
|
6925
|
+
lastRunError = describeFailureDetail(error) ?? lastRunError;
|
|
6901
6926
|
reportAttempt(String(run?.id ?? ""), "failed", "error");
|
|
6902
6927
|
throw error;
|
|
6903
6928
|
}
|
|
@@ -6947,7 +6972,9 @@ function createDelegateTool(ctx, getRoutes, config = {}, getSettings) {
|
|
|
6947
6972
|
return budgeted + formatDegradeNotes(degradeNotes) + contractMark;
|
|
6948
6973
|
}
|
|
6949
6974
|
lastReason = String(outcome?.stopReason ?? "unknown");
|
|
6950
|
-
|
|
6975
|
+
const outcomeDiag = typeof outcome?.diagnostic === "string" && outcome.diagnostic.length > 0 ? outcome.diagnostic : undefined;
|
|
6976
|
+
const residualDetail = describeFailureDetail(outcome);
|
|
6977
|
+
lastDiagnostic = outcomeDiag ?? (residualDetail !== undefined ? "subagent error: " + residualDetail : lastRunError === undefined ? undefined : "run error: " + lastRunError);
|
|
6951
6978
|
const partialRaw = contentText(outcome?.output ?? []);
|
|
6952
6979
|
lastPartial = partialRaw.slice(0, 500);
|
|
6953
6980
|
lastPartialBudget = budget.enabled && partialRaw.length > budget.partialMaxChars ? applyResultBudget(partialRaw, {
|
|
@@ -7663,6 +7690,12 @@ function createDelegateBatchTool(ctx, getRoutes, config = {}, getSettings) {
|
|
|
7663
7690
|
degradeNotes: taskNotes
|
|
7664
7691
|
});
|
|
7665
7692
|
const run = await spawnAgain(promptText, ac.signal);
|
|
7693
|
+
const timing = {};
|
|
7694
|
+
const markSettled = () => {
|
|
7695
|
+
if (timing.endedAt === undefined)
|
|
7696
|
+
timing.endedAt = Date.now();
|
|
7697
|
+
};
|
|
7698
|
+
run.result.then(markSettled, markSettled);
|
|
7666
7699
|
return {
|
|
7667
7700
|
taskId,
|
|
7668
7701
|
skillName: skill.name,
|
|
@@ -7673,6 +7706,7 @@ function createDelegateBatchTool(ctx, getRoutes, config = {}, getSettings) {
|
|
|
7673
7706
|
ac,
|
|
7674
7707
|
onExecAbort,
|
|
7675
7708
|
startedAt,
|
|
7709
|
+
timing,
|
|
7676
7710
|
startError: undefined,
|
|
7677
7711
|
skillError: undefined,
|
|
7678
7712
|
outputContract,
|
|
@@ -7789,7 +7823,7 @@ ${attribution}`,
|
|
|
7789
7823
|
}, val.startedAt, startErrAt));
|
|
7790
7824
|
continue;
|
|
7791
7825
|
}
|
|
7792
|
-
const { run, taskId, skillName, skillTag, taskNotes, ac, onExecAbort, startedAt, outputContract, buildPrompt, spawnAgain } = val;
|
|
7826
|
+
const { run, taskId, skillName, skillTag, taskNotes, ac, onExecAbort, startedAt, timing, outputContract, buildPrompt, spawnAgain } = val;
|
|
7793
7827
|
const taskEvents = batchEvents[index] ?? [];
|
|
7794
7828
|
let disposed = false;
|
|
7795
7829
|
const safeDispose = () => {
|
|
@@ -7798,11 +7832,11 @@ ${attribution}`,
|
|
|
7798
7832
|
disposed = true;
|
|
7799
7833
|
Promise.resolve().then(() => run.dispose()).catch(() => {});
|
|
7800
7834
|
};
|
|
7801
|
-
runs.push({ run, safeDispose, taskId, skillName, skillTag, taskNotes, ac, onExecAbort, startedAt, taskEvents, outputContract, buildPrompt, spawnAgain });
|
|
7835
|
+
runs.push({ run, safeDispose, taskId, skillName, skillTag, taskNotes, ac, onExecAbort, startedAt, timing, taskEvents, outputContract, buildPrompt, spawnAgain });
|
|
7802
7836
|
perTaskNotes.push({ taskId, notes: taskNotes });
|
|
7803
7837
|
run.result.catch(() => {});
|
|
7804
7838
|
}
|
|
7805
|
-
for (const { run, safeDispose, taskId, skillName, skillTag, taskNotes, ac, startedAt, taskEvents, outputContract, buildPrompt, spawnAgain } of runs) {
|
|
7839
|
+
for (const { run, safeDispose, taskId, skillName, skillTag, taskNotes, ac, startedAt, timing, taskEvents, outputContract, buildPrompt, spawnAgain } of runs) {
|
|
7806
7840
|
let outcome;
|
|
7807
7841
|
let timer = null;
|
|
7808
7842
|
const runId = typeof run?.id === "string" && run.id.length > 0 ? run.id : undefined;
|
|
@@ -7924,7 +7958,7 @@ ${attribution}`,
|
|
|
7924
7958
|
ctx.logger?.warn?.("[cohub contract] " + taskId + " 输出未满足契约(" + outputContract.level + "):" + check.errors.join(";"));
|
|
7925
7959
|
}
|
|
7926
7960
|
}
|
|
7927
|
-
const endedAt = Date.now();
|
|
7961
|
+
const endedAt = timing.endedAt ?? Date.now();
|
|
7928
7962
|
pushBatchEvent(taskEvents, {
|
|
7929
7963
|
taskId,
|
|
7930
7964
|
phase: "completed",
|
|
@@ -7948,8 +7982,9 @@ ${attribution}`,
|
|
|
7948
7982
|
...contractViolated ? { contractViolated: true } : {}
|
|
7949
7983
|
}, startedAt, endedAt, runId));
|
|
7950
7984
|
} else {
|
|
7951
|
-
const endedAt = Date.now();
|
|
7952
|
-
const
|
|
7985
|
+
const endedAt = timing.endedAt ?? Date.now();
|
|
7986
|
+
const residual = describeFailureDetail(outcome);
|
|
7987
|
+
const diag = typeof outcome?.diagnostic === "string" && outcome.diagnostic.length > 0 ? outcome.diagnostic : residual === undefined ? undefined : "subagent error: " + residual;
|
|
7953
7988
|
pushBatchEvent(taskEvents, {
|
|
7954
7989
|
taskId,
|
|
7955
7990
|
phase: "failed",
|
|
@@ -7968,8 +8003,9 @@ ${attribution}`,
|
|
|
7968
8003
|
}, startedAt, endedAt, runId));
|
|
7969
8004
|
}
|
|
7970
8005
|
} catch (e) {
|
|
7971
|
-
const endedAt = Date.now();
|
|
7972
|
-
const
|
|
8006
|
+
const endedAt = timing.endedAt ?? Date.now();
|
|
8007
|
+
const rawMessage = e instanceof Error ? e.message : String(e);
|
|
8008
|
+
const message = describeFailureDetail(rawMessage) ?? rawMessage;
|
|
7973
8009
|
pushBatchEvent(taskEvents, {
|
|
7974
8010
|
taskId,
|
|
7975
8011
|
phase: message.startsWith("超时") ? "timeout" : "failed",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-cohub",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.9",
|
|
4
4
|
"description": "DeepSeek Harness 版 CoHub:中文智能体编排——用户可选 2 种工作模式(co-orchestrator 纯调度 / cohub-cordis 创造模式)+ 13 个专职代理技能 + 多模型共识;另由 cohub-subagent-readonly / cohub-subagent-write 两个支撑 preset 实现子代理读写硬隔离(共 4 个 preset)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|