@manturhub/cli 0.9.10-dev.20260810.7 → 0.9.10-dev.20260810.8
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/lib/skill-install.js +10 -6
- package/package.json +1 -1
package/lib/skill-install.js
CHANGED
|
@@ -53,9 +53,6 @@ async function fetchSkillDetail(slug) {
|
|
|
53
53
|
}
|
|
54
54
|
if (!response.ok) throw new Error(`Skill 信息获取失败(HTTP ${response.status})`);
|
|
55
55
|
const detail = unwrapGatewayData(response.json) || {};
|
|
56
|
-
if (!detail?.version) {
|
|
57
|
-
throw new Error(`线上 Skill「${slug}」缺少 version,平台需先修正后才能安装`);
|
|
58
|
-
}
|
|
59
56
|
return { ...detail, slug: detail.code };
|
|
60
57
|
}
|
|
61
58
|
|
|
@@ -234,6 +231,7 @@ export async function skillAdd(
|
|
|
234
231
|
const tempDir = mkdtempSync(join(tmpdir(), "manturhub-skill-"));
|
|
235
232
|
const bundle = join(tempDir, `${slug}.zip`);
|
|
236
233
|
const staged = join(tempDir, "staged");
|
|
234
|
+
let installedVersion;
|
|
237
235
|
let installError = null;
|
|
238
236
|
try {
|
|
239
237
|
await downloadSkillBundle(slug, bundle);
|
|
@@ -244,11 +242,17 @@ export async function skillAdd(
|
|
|
244
242
|
`安装包 name 与请求不一致(请求 ${slug},安装包 ${bundleMetadata.name || "缺失"})`
|
|
245
243
|
);
|
|
246
244
|
}
|
|
247
|
-
|
|
245
|
+
// 兼容公开详情未返回版本的旧网关,以实际安装包版本记录安装状态。
|
|
246
|
+
// 接口已返回版本时仍严格比对,避免安装过程中发布切换造成版本错配。
|
|
247
|
+
if (detail.version && bundleMetadata.version !== detail.version) {
|
|
248
248
|
throw new Error(
|
|
249
249
|
`安装包 version 与线上元数据不一致(线上 ${detail.version},安装包 ${bundleMetadata.version || "缺失"})`
|
|
250
250
|
);
|
|
251
251
|
}
|
|
252
|
+
if (!bundleMetadata.version) {
|
|
253
|
+
throw new Error(`Skill「${slug}」的接口和安装包均缺少 version,无法记录安装版本`);
|
|
254
|
+
}
|
|
255
|
+
installedVersion = bundleMetadata.version;
|
|
252
256
|
const contentSha256 = hashSkillDirectory(staged);
|
|
253
257
|
const bundleSha256 = createHash("sha256").update(readFileSync(bundle)).digest("hex");
|
|
254
258
|
const installedAt = new Date().toISOString();
|
|
@@ -259,7 +263,7 @@ export async function skillAdd(
|
|
|
259
263
|
setSkillRecord(state, {
|
|
260
264
|
slug,
|
|
261
265
|
client: destination.client,
|
|
262
|
-
version:
|
|
266
|
+
version: installedVersion,
|
|
263
267
|
base_url: baseUrl,
|
|
264
268
|
bundle_sha256: bundleSha256,
|
|
265
269
|
content_sha256: contentSha256,
|
|
@@ -283,7 +287,7 @@ export async function skillAdd(
|
|
|
283
287
|
}
|
|
284
288
|
|
|
285
289
|
for (const destination of destinations) {
|
|
286
|
-
console.log(`✓ 已${action === "update" ? "更新" : "安装"} Skill「${slug}」v${
|
|
290
|
+
console.log(`✓ 已${action === "update" ? "更新" : "安装"} Skill「${slug}」v${installedVersion} → ${destination.path}`);
|
|
287
291
|
}
|
|
288
292
|
console.log(" 重启对应 Agent 后,用自然语言描述任务即可使用。");
|
|
289
293
|
}
|