/* eslint-disable @typescript-eslint/naming-convention */ /* eslint-disable no-console */ import type { NodeObject } from 'jsonld'; import type { SKLEngine } from '../index'; import { customCapabilities } from '../index'; import type { JSONObject } from '../util/Types'; // Example 1: Simple custom capability customCapabilities.register('greetUser', async(args: JSONObject): Promise => ({ '@type': 'GreetingResult', '@value': `Hello, ${args.name as string}! Welcome to SKL Engine.` })); // Example 2: Custom capability that uses SKL Engine instance customCapabilities.register( 'countEntitiesWithProcessing', async(args: JSONObject, sklEngine: SKLEngine): Promise => { try { // Use the SKL engine to count entities const count = await sklEngine.count(args); // Add some processing const processedCount = count * 2; return { '@type': 'ProcessedCountResult', '@value': { originalCount: count, processedCount, timestamp: new Date().toISOString() } }; } catch (error: unknown) { return { '@type': 'ErrorResult', '@value': { error: error instanceof Error ? error.message : 'Unknown error', timestamp: new Date().toISOString() } }; } } ); // Example 3: Custom capability that returns multiple results customCapabilities.register( 'generateMultipleGreetings', async(args: JSONObject): Promise => { const names = args.names as string[] || []; return names.map((name, index) => ({ '@type': 'IndexedGreeting', '@value': { index, message: `Hello, ${name}!`, timestamp: new Date().toISOString() } })); } ); // Usage example: console.log('Custom capabilities registered:'); console.log('- greetUser'); console.log('- countEntitiesWithProcessing'); console.log('- generateMultipleGreetings'); console.log('\nAll registered capabilities:', customCapabilities.getAll()); // Check if capabilities exist console.log('\nCapability checks:'); console.log('greetUser exists:', customCapabilities.has('greetUser')); console.log('nonExistent exists:', customCapabilities.has('nonExistent')); export { };