Overview
Concrete initialization method for the SkillManager singleton that sets up storage, executor, built-in skills, and the skill registry with event notification.
Description
The SkillManager.initialize method orchestrates the entire skill system startup. It initializes `skillStorage` (IndexedDB + ZenFS), `skillExecutor` (QuickJS VM), loads built-in skills (skill-creator-browser, ux-audit-walkthrough, wcag22-a11y-audit) from bundled `?raw` imports, reloads skills from storage, and initializes `skillRegistry` with all skill metadata. The manager is a singleton with an event system (`subscribe`/`_emit`) for skill_loaded, skill_unloaded, skill_enabled, and skill_disabled events. Configuration includes `autoLoadEnabledSkills` (default true), `maxConcurrentExecutions` (default 5), and `scriptTimeout` (default 30000ms).
Usage
- Initialize skill system: `await skillManager.initialize()` (call once on extension startup)
- Subscribe to events: `skillManager.subscribe("skill_loaded", (data) => { ... })`
- Configuration: pass `SkillManagerConfig` to the constructor.
Code Reference
Source Location
- Repository: AIPex
- File: packages/browser-runtime/src/skill/lib/services/skill-manager.ts
- Lines: L32-120 (class, initialize, event system), L770 (singleton export)
Signature
export class SkillManager {
constructor(config?: SkillManagerConfig)
async initialize(): Promise<void>
subscribe(event: SkillEventType, callback: SkillSubscriber): () => void
unsubscribe(event: SkillEventType, callback: SkillSubscriber): void
}
interface SkillManagerConfig {
autoLoadEnabledSkills?: boolean;
maxConcurrentExecutions?: number;
scriptTimeout?: number;
}
type SkillEventType = "skill_loaded" | "skill_unloaded" | "skill_enabled" | "skill_disabled";
// Singleton: export const skillManager = new SkillManager();
Import
import { skillManager } from "@aipexstudio/browser-runtime";
I/O Contract
Inputs
| Name |
Type |
Required |
Description
|
| config |
SkillManagerConfig |
No |
Configuration (defaults: autoLoad=true, maxConcurrent=5, timeout=30000)
|
Outputs
| Name |
Type |
Description
|
| returns |
Promise<void> |
Resolves when all components initialized
|
Usage Examples
Initialize on Extension Startup
import { skillManager } from "@aipexstudio/browser-runtime";
// Subscribe to skill events
skillManager.subscribe("skill_loaded", (skill) => {
console.log("Skill loaded:", skill.name);
});
// Initialize on extension startup
await skillManager.initialize();
console.log("Skill system ready");
Custom Configuration
import { SkillManager } from "@aipexstudio/browser-runtime";
const customManager = new SkillManager({
autoLoadEnabledSkills: false,
maxConcurrentExecutions: 3,
scriptTimeout: 10000,
});
await customManager.initialize();
Related Pages
Implements Principle
Requires Environment
Page Connections
Double-click a node to navigate. Hold to expand connections.