@comake/skl-js-engine
Version:
Standard Knowledge Language Javascript Engine
46 lines • 2.24 kB
JavaScript
;
// /* eslint-disable func-style */
// /* eslint-disable no-console */
// import path from 'node:path';
// import { JsonRpcServer } from '../../transport/JsonRpcServer';
// import { StdioTransport } from '../../transport/StdioTransport';
// const server = new JsonRpcServer();
// // Register methods that the child process can call
// server.registerMethod('getTime', async(): Promise<{ result: string }> => {
// console.log('📅 Child requested current time');
// return {
// result: new Date().toISOString()
// };
// });
// // Handle notifications from child
// server.registerMethod('childNotification', async(params: { message: string; timestamp: string }): Promise<void> => {
// console.log('📨 Received notification from child:', params);
// // Notifications don't return responses
// });
// const stdioTransport = new StdioTransport(path.resolve(__dirname, './process.ts'), server);
// stdioTransport.setName('basic-example-parent');
// const main = async(): Promise<void> => {
// console.log('🚀 Starting parent process');
// await stdioTransport.initialize();
// console.log('✅ Child process initialized');
// // Example: Make some calls to the child process using the new ergonomic API
// try {
// // Test basic ping
// // const pingResult = await stdioTransport.request('ping');
// // console.log('🏓 Ping result:', pingResult);
// // // Test child calling back to parent
// const callParentResult = await stdioTransport.request('callParent');
// console.log('🔄 Child callback result:', callParentResult);
// // // Test child sending notification
// // const notifyResult = await stdioTransport.request('sendNotification');
// // console.log('📤 Notification test result:', notifyResult);
// // // Test execute code method
// // const executeResult = await stdioTransport.request('executeCode', 'console.log("Hello from executed code!")');
// // console.log('⚡ Execute result:', executeResult);
// await stdioTransport.close();
// } catch (error: unknown) {
// console.error('❌ Error testing child methods:', (error as Error).message);
// }
// };
// main().catch(console.error);
//# sourceMappingURL=index.js.map