aisoulhub 1.1.2 → 1.1.4
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/package.json +1 -1
- package/src/index.js +70 -19
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import path from 'node:path';
|
|
|
10
10
|
import { pipeline } from 'node:stream/promises';
|
|
11
11
|
import unzipper from 'unzipper';
|
|
12
12
|
|
|
13
|
-
export const DEFAULT_BASE_URL = 'https://
|
|
13
|
+
export const DEFAULT_BASE_URL = 'https://aisoulhub.com';
|
|
14
14
|
const CLAWHUB_REGISTRY = 'https://cn.clawhub-mirror.com';
|
|
15
15
|
|
|
16
16
|
export class UserFacingError extends Error {
|
|
@@ -319,6 +319,27 @@ async function runCommand(command, args) {
|
|
|
319
319
|
});
|
|
320
320
|
}
|
|
321
321
|
|
|
322
|
+
export function summarizeErrorMessage(error) {
|
|
323
|
+
const lines = String(error?.message || error || '')
|
|
324
|
+
.split('\n')
|
|
325
|
+
.map(line => line.trim())
|
|
326
|
+
.filter(Boolean);
|
|
327
|
+
|
|
328
|
+
if (lines.length === 0) {
|
|
329
|
+
return '未知错误';
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
for (const line of lines) {
|
|
333
|
+
const match = line.match(/"Message"\s*:\s*"([^"]+)"/);
|
|
334
|
+
if (match?.[1]) {
|
|
335
|
+
return match[1];
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
const detailLine = lines.find(line => !line.startsWith('命令执行失败:'));
|
|
340
|
+
return detailLine || lines[0];
|
|
341
|
+
}
|
|
342
|
+
|
|
322
343
|
async function listAgents() {
|
|
323
344
|
const { stdout } = await runCommand('openclaw', ['agents', 'list', '--json']);
|
|
324
345
|
|
|
@@ -359,10 +380,14 @@ async function resolveVersion(baseUrl, slug, user) {
|
|
|
359
380
|
|
|
360
381
|
async function installSkills(skills, workspacePath) {
|
|
361
382
|
if (!Array.isArray(skills) || skills.length === 0) {
|
|
362
|
-
return
|
|
383
|
+
return {
|
|
384
|
+
installedSkills: [],
|
|
385
|
+
skippedSkills: [],
|
|
386
|
+
};
|
|
363
387
|
}
|
|
364
388
|
|
|
365
389
|
const installedSkills = [];
|
|
390
|
+
const skippedSkills = [];
|
|
366
391
|
|
|
367
392
|
for (const skill of skills) {
|
|
368
393
|
const skillName = normalizeSkillName(skill);
|
|
@@ -370,23 +395,36 @@ async function installSkills(skills, workspacePath) {
|
|
|
370
395
|
continue;
|
|
371
396
|
}
|
|
372
397
|
|
|
373
|
-
|
|
374
|
-
'
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
398
|
+
try {
|
|
399
|
+
await runCommand('npx', [
|
|
400
|
+
'clawhub',
|
|
401
|
+
'install',
|
|
402
|
+
skillName,
|
|
403
|
+
'--workdir',
|
|
404
|
+
workspacePath,
|
|
405
|
+
'--registry',
|
|
406
|
+
CLAWHUB_REGISTRY,
|
|
407
|
+
]);
|
|
408
|
+
|
|
409
|
+
installedSkills.push({
|
|
410
|
+
requested: String(skill),
|
|
411
|
+
installed: skillName,
|
|
412
|
+
});
|
|
413
|
+
} catch (error) {
|
|
414
|
+
const reason = summarizeErrorMessage(error);
|
|
415
|
+
skippedSkills.push({
|
|
416
|
+
requested: String(skill),
|
|
417
|
+
installed: skillName,
|
|
418
|
+
reason,
|
|
419
|
+
});
|
|
420
|
+
console.warn(`- 跳过 skill: ${skillName}${reason ? ` (${reason})` : ''}`);
|
|
421
|
+
}
|
|
387
422
|
}
|
|
388
423
|
|
|
389
|
-
return
|
|
424
|
+
return {
|
|
425
|
+
installedSkills,
|
|
426
|
+
skippedSkills,
|
|
427
|
+
};
|
|
390
428
|
}
|
|
391
429
|
|
|
392
430
|
function printSummary(summary) {
|
|
@@ -406,6 +444,15 @@ function printSummary(summary) {
|
|
|
406
444
|
: 'none'
|
|
407
445
|
}`
|
|
408
446
|
);
|
|
447
|
+
console.log(
|
|
448
|
+
`- skipped_skills: ${
|
|
449
|
+
summary.skippedSkills.length > 0
|
|
450
|
+
? summary.skippedSkills
|
|
451
|
+
.map(item => `${item.installed}${item.reason ? ` (${item.reason})` : ''}`)
|
|
452
|
+
.join(', ')
|
|
453
|
+
: 'none'
|
|
454
|
+
}`
|
|
455
|
+
);
|
|
409
456
|
}
|
|
410
457
|
|
|
411
458
|
export async function installSoul({ soulSpecifier, user, baseUrl }) {
|
|
@@ -490,14 +537,17 @@ export async function installSoul({ soulSpecifier, user, baseUrl }) {
|
|
|
490
537
|
await fs.mkdir(workspacePath, { recursive: true });
|
|
491
538
|
await copyPackageContent(packageRoot, workspacePath);
|
|
492
539
|
const agentsAppended = await appendAgentsFile(packageRoot, workspacePath);
|
|
493
|
-
const installedSkills = await installSkills(
|
|
540
|
+
const { installedSkills, skippedSkills } = await installSkills(
|
|
541
|
+
metadata.skills,
|
|
542
|
+
workspacePath
|
|
543
|
+
);
|
|
494
544
|
|
|
495
545
|
await runCommand('openclaw', [
|
|
496
546
|
'agent',
|
|
497
547
|
'--agent',
|
|
498
548
|
agentName,
|
|
499
549
|
'--message',
|
|
500
|
-
|
|
550
|
+
`Hi,你的名字是 ${displayName}`,
|
|
501
551
|
]);
|
|
502
552
|
|
|
503
553
|
printSummary({
|
|
@@ -510,6 +560,7 @@ export async function installSoul({ soulSpecifier, user, baseUrl }) {
|
|
|
510
560
|
baseUrl: effectiveBaseUrl,
|
|
511
561
|
agentsAppended,
|
|
512
562
|
installedSkills,
|
|
563
|
+
skippedSkills,
|
|
513
564
|
});
|
|
514
565
|
} finally {
|
|
515
566
|
await fs.rm(tempRoot, { recursive: true, force: true });
|