@comake/skl-js-engine
Version:
Standard Knowledge Language Javascript Engine
81 lines (80 loc) • 2.69 kB
TypeScript
import type { ClientTransport } from '../../jsonRpc/JsonRpcClient';
import type { JsonRpcServer } from '../../jsonRpc/JsonRpcServer';
import type { ExecutionOptions } from '../../types';
import { BaseTransport } from '../base/BaseTransport';
import { ProcessManager } from '../process/ProcessManager';
import type { TransportConfig } from '../Transport';
/**
* Client transport implementation for stdio communication
*/
export declare class StdioClientTransport implements ClientTransport {
private readonly processManager;
private messageHandler?;
private name?;
private readonly logger;
constructor(processManager: ProcessManager);
setName(name: string): void;
send(message: string): Promise<void>;
onMessage(handler: (message: string) => void): void;
close(): Promise<void>;
}
/**
* StdioTransport implementation for parent process communication with child
* This is the parent-side transport that manages a child process
*/
export declare class ParentStdioTransport extends BaseTransport {
private readonly processManager;
private readonly server;
private readonly client;
private readonly clientTransport;
private readonly executorScriptPath;
private readonly messageBuffer;
constructor(executorScriptPath: string, server: JsonRpcServer);
/**
* Initialize the transport connection
*/
initialize(config?: TransportConfig, executionOptions?: ExecutionOptions): Promise<void>;
/**
* Send a message through the transport
*/
send<TRequest, TResponse>(message: TRequest): Promise<TResponse>;
/**
* Make a direct RPC request to the child process
*/
request<TParams = any, TResult = any>(method: string, params?: TParams, options?: {
timeout?: number;
retries?: number;
}): Promise<TResult>;
/**
* Send a notification to the child process (no response expected)
*/
notify<TParams = any>(method: string, params?: TParams): Promise<void>;
/**
* Close the transport connection
*/
close(): Promise<void>;
/**
* Check if the transport is ready for communication
*/
isReady(): boolean;
/**
* Set up server methods for handling incoming requests from Deno process
*/
private setupServerMethods;
/**
* Set up event handlers
*/
private setupEventHandlers;
/**
* Set up process communication handlers
*/
private setupProcessCommunication;
/**
* Handle incoming message from Deno process with bidirectional routing
*/
private handleIncomingMessage;
/**
* Wait for the process to be ready
*/
private waitForReady;
}