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

import { SkillBase } from '@signalwire/sdk';
export class ScraperSkill extends SkillBase {
static SKILL_NAME = 'scraper';
static SKILL_DESCRIPTION = 'Scrapes web pages.';
static REQUIRED_PACKAGES = ['cheerio'];
async setup(): Promise<boolean> {
const missing = await this.validatePackages();
if (missing.length > 0) {
this.logger.error(`Install: npm install ${missing.join(' ')}`);
return false;
}
return true;
}
}