UNPKG

@comake/skl-js-engine

Version:

Standard Knowledge Language Javascript Engine

34 lines 1.69 kB
"use strict"; // /* eslint-disable @typescript-eslint/ban-ts-comment */ // // @ts-nocheck // import { BidirectionalStdioTransport } from '../../transport/StdioTransport.ts'; // // Create a single transport that handles both server and client functionality // const transport = new BidirectionalStdioTransport(); // transport.setName('basic-example-process'); // // Register methods that the parent can call (server functionality) // transport.registerMethod('executeCode', async(message: string): Promise<{ result: string }> => ({ // result: 'Hello from the process' // })); // transport.registerMethod('ping', async(): Promise<string> => 'pong'); // // Register a method that demonstrates calling back to the parent (client functionality) // transport.registerMethod('callParent', async(): Promise<{ result: string }> => { // try { // // Call the parent's getTime method // const result = await transport.request('getTime'); // return { result: `Parent getTime returned: ${JSON.stringify(result)}` }; // } catch (error: unknown) { // return { result: `Error calling parent: ${(error as Error).message}` }; // } // }); // // Register a method that sends notifications to parent // transport.registerMethod('sendNotification', async(): Promise<{ result: string }> => { // // Send a notification (no response expected) // await transport.notify('childNotification', { // message: 'Hello from child process', // timestamp: new Date().toISOString() // }); // return { result: 'Notification sent to parent' }; // }); // // Initialize the transport (this sets up stdio communication) // await transport.initialize(); //# sourceMappingURL=process.js.map