validatePackages

View as MarkdownOpen in Claude

Attempt to import() every package listed in the skill class’s REQUIRED_PACKAGES static array. Returns the list of packages that failed to import (empty array means everything is available). Python parity: validate_packages() at core/skill_base.py:112-124.

Logs an error listing every missing package when the result is non-empty.

For a boolean check, use hasAllPackages(). Because the TS version uses dynamic import(), this method is async.

Returns

Promise<string[]> — array of package names that failed to import. Empty when all packages are available.

Example

1import { SkillBase } from '@signalwire/sdk';
2
3export class ScraperSkill extends SkillBase {
4 static SKILL_NAME = 'scraper';
5 static SKILL_DESCRIPTION = 'Scrapes web pages.';
6 static REQUIRED_PACKAGES = ['cheerio'];
7
8 async setup(): Promise<boolean> {
9 const missing = await this.validatePackages();
10 if (missing.length > 0) {
11 this.logger.error(`Install: npm install ${missing.join(' ')}`);
12 return false;
13 }
14 return true;
15 }
16}