@comake/skl-js-engine 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/JsExecutor/jsExecutor.d.ts +1 -1
- package/dist/JsExecutor/jsExecutor.js +3 -1
- package/dist/JsExecutor/jsExecutor.js.map +1 -1
- package/dist/JsExecutor/transport/StdioTransport.d.ts +0 -226
- package/dist/JsExecutor/transport/StdioTransport.js +639 -632
- package/dist/JsExecutor/transport/StdioTransport.js.map +1 -1
- package/dist/JsExecutor/transport/Transport.d.ts +2 -0
- package/dist/JsExecutor/transport/process/ProcessManager.js +28 -23
- package/dist/JsExecutor/transport/process/ProcessManager.js.map +1 -1
- package/dist/JsExecutor/transport/stdio/ChildStdioTransport.js +6 -2
- package/dist/JsExecutor/transport/stdio/ChildStdioTransport.js.map +1 -1
- package/dist/JsExecutor/transport/stdio/ParentStdioTransport.js +19 -22
- package/dist/JsExecutor/transport/stdio/ParentStdioTransport.js.map +1 -1
- package/dist/JsExecutor/transport/utils/PollingUtils.d.ts +52 -0
- package/dist/JsExecutor/transport/utils/PollingUtils.js +92 -0
- package/dist/JsExecutor/transport/utils/PollingUtils.js.map +1 -0
- package/dist/SklEngine.d.ts +8 -9
- package/dist/SklEngine.js +35 -36
- package/dist/SklEngine.js.map +1 -1
- package/dist/logger.d.ts +24 -1
- package/dist/logger.js +86 -7
- package/dist/logger.js.map +1 -1
- package/dist/util/safeJsonStringify.d.ts +0 -5
- package/dist/util/safeJsonStringify.js +17 -17
- package/dist/util/safeJsonStringify.js.map +1 -1
- package/package.json +1 -1
|
@@ -38,7 +38,7 @@ export declare class JSExecutor {
|
|
|
38
38
|
private readonly abortController;
|
|
39
39
|
private static readonly globalAbortController;
|
|
40
40
|
private shutdownTimeout?;
|
|
41
|
-
constructor(executorScriptPath: string, callbacks:
|
|
41
|
+
constructor(executorScriptPath: string, callbacks: Record<string, (...args: any[]) => any>);
|
|
42
42
|
/**
|
|
43
43
|
* Static method to check if any JSExecutor instance is being shut down
|
|
44
44
|
* Callbacks can use this to check if they should abort their operations
|
|
@@ -60,7 +60,9 @@ class JSExecutor {
|
|
|
60
60
|
if (this.isInitialized) {
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
63
|
-
this.server = new transport_1.JsonRpcServer(
|
|
63
|
+
this.server = new transport_1.JsonRpcServer({
|
|
64
|
+
requestTimeout: 2 * 60 * 1000
|
|
65
|
+
});
|
|
64
66
|
// Register callbacks with the server
|
|
65
67
|
Object.entries(this.callbacks).forEach(([methodName, callback]) => {
|
|
66
68
|
this.server.registerMethod(methodName, this.wrapCallbackWithAbort(callback));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsExecutor.js","sourceRoot":"","sources":["../../src/JsExecutor/jsExecutor.ts"],"names":[],"mappings":";AAAA,yDAAyD;AACzD,oCAAoC;AACpC,qEAAqE;AACrE,+BAA+B;;;AAE/B,qCAA+C;AAE/C,
|
|
1
|
+
{"version":3,"file":"jsExecutor.js","sourceRoot":"","sources":["../../src/JsExecutor/jsExecutor.ts"],"names":[],"mappings":";AAAA,yDAAyD;AACzD,oCAAoC;AACpC,qEAAqE;AACrE,+BAA+B;;;AAE/B,qCAA+C;AAE/C,2CAAoF;AAKpF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAa,UAAU;IAQrB,YACmB,kBAA0B,EAC1B,SAAkD;QADlD,uBAAkB,GAAlB,kBAAkB,CAAQ;QAC1B,cAAS,GAAT,SAAS,CAAyC;QAT7D,kBAAa,GAAG,KAAK,CAAC;QAGb,oBAAe,GAAG,IAAI,eAAe,EAAE,CAAC;IAOtD,CAAC;IAEJ;;;OAGG;IACI,MAAM,CAAC,cAAc;QAC1B,OAAO,UAAU,CAAC,qBAAqB,CAAC,MAAM,CAAC,OAAO,CAAC;IACzD,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,oBAAoB;QAChC,OAAO,UAAU,CAAC,qBAAqB,CAAC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C,UAAU,EAAE,IAAI,CAAC,CAAC;IAClD,CAAC;;AAvJH,gCAwJC;AAnJyB,gCAAqB,GAAG,IAAI,eAAe,EAAE,CAAC"}
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import { EventEmitter } from 'node:events';
|
|
4
|
-
import type { Readable, Writable } from 'stream';
|
|
5
|
-
import type { ClientTransport } from '../jsonRpc/JsonRpcClient';
|
|
6
|
-
import { JsonRpcServer } from '../jsonRpc/JsonRpcServer';
|
|
7
|
-
import type { ExecutionOptions } from '../types';
|
|
8
|
-
import type { MessageHandler, Transport, TransportConfig, TransportEvents } from './Transport';
|
|
9
|
-
import { TransportStatus } from './Transport';
|
|
10
|
-
/**
|
|
11
|
-
* StdioTransport implementation using stdin/stdout for JSON-RPC communication
|
|
12
|
-
* This is the parent-side transport that manages a child process
|
|
13
|
-
*/
|
|
14
|
-
export declare class StdioTransport extends EventEmitter implements Transport {
|
|
15
|
-
private _status;
|
|
16
|
-
private childProcess?;
|
|
17
|
-
private readonly server;
|
|
18
|
-
private readonly client;
|
|
19
|
-
private readonly clientTransport;
|
|
20
|
-
private readonly executorScriptPath;
|
|
21
|
-
private messageHandler?;
|
|
22
|
-
private name?;
|
|
23
|
-
private readonly logger;
|
|
24
|
-
constructor(executorScriptPath: string, server: JsonRpcServer);
|
|
25
|
-
setName(name: string): void;
|
|
26
|
-
get status(): TransportStatus;
|
|
27
|
-
/**
|
|
28
|
-
* Initialize the transport connection
|
|
29
|
-
*/
|
|
30
|
-
initialize(config?: TransportConfig, executionOptions?: ExecutionOptions): Promise<void>;
|
|
31
|
-
/**
|
|
32
|
-
* Normalizes execution options with defaults
|
|
33
|
-
* @param options - Raw execution options
|
|
34
|
-
* @returns Normalized options with all required fields
|
|
35
|
-
*/
|
|
36
|
-
private normalizeOptions;
|
|
37
|
-
/**
|
|
38
|
-
* Extracts permission configuration from execution options
|
|
39
|
-
* @param options - Normalized execution options
|
|
40
|
-
* @returns Permission configuration object
|
|
41
|
-
*/
|
|
42
|
-
private extractPermissionConfig;
|
|
43
|
-
/**
|
|
44
|
-
* Send a message through the transport
|
|
45
|
-
*/
|
|
46
|
-
send<TRequest, TResponse>(message: TRequest): Promise<TResponse>;
|
|
47
|
-
/**
|
|
48
|
-
* Make a direct RPC request to the child process
|
|
49
|
-
*/
|
|
50
|
-
request<TParams = any, TResult = any>(method: string, params?: TParams, options?: {
|
|
51
|
-
timeout?: number;
|
|
52
|
-
retries?: number;
|
|
53
|
-
}): Promise<TResult>;
|
|
54
|
-
/**
|
|
55
|
-
* Send a notification to the child process (no response expected)
|
|
56
|
-
*/
|
|
57
|
-
notify<TParams = any>(method: string, params?: TParams): Promise<void>;
|
|
58
|
-
/**
|
|
59
|
-
* Register a message handler for incoming messages
|
|
60
|
-
*/
|
|
61
|
-
onMessage<T>(handler: MessageHandler<T>): void;
|
|
62
|
-
/**
|
|
63
|
-
* Register an event listener
|
|
64
|
-
*/
|
|
65
|
-
on<TKey extends keyof TransportEvents>(event: TKey, handler: TransportEvents[TKey]): this;
|
|
66
|
-
/**
|
|
67
|
-
* Remove an event listener
|
|
68
|
-
*/
|
|
69
|
-
off<TKey extends keyof TransportEvents>(event: TKey, handler: TransportEvents[TKey]): this;
|
|
70
|
-
/**
|
|
71
|
-
* Close the transport connection
|
|
72
|
-
*/
|
|
73
|
-
close(): Promise<void>;
|
|
74
|
-
/**
|
|
75
|
-
* Check if the transport is ready for communication
|
|
76
|
-
*/
|
|
77
|
-
isReady(): boolean;
|
|
78
|
-
/**
|
|
79
|
-
* Set up server methods for handling incoming requests from Deno process
|
|
80
|
-
*/
|
|
81
|
-
private setupServerMethods;
|
|
82
|
-
/**
|
|
83
|
-
* Set up event handlers
|
|
84
|
-
*/
|
|
85
|
-
private setupEventHandlers;
|
|
86
|
-
/**
|
|
87
|
-
* Set up process communication handlers
|
|
88
|
-
*/
|
|
89
|
-
private setupProcessCommunication;
|
|
90
|
-
/**
|
|
91
|
-
* Handle incoming message from Deno process with bidirectional routing
|
|
92
|
-
*/
|
|
93
|
-
private handleIncomingMessage;
|
|
94
|
-
private safeParse;
|
|
95
|
-
/**
|
|
96
|
-
* Check if a message is a JSON-RPC response
|
|
97
|
-
*/
|
|
98
|
-
private isResponse;
|
|
99
|
-
/**
|
|
100
|
-
* Wait for the process to be ready
|
|
101
|
-
*/
|
|
102
|
-
private waitForReady;
|
|
103
|
-
/**
|
|
104
|
-
* Set transport status and emit event
|
|
105
|
-
*/
|
|
106
|
-
private setStatus;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Client transport implementation for stdio communication
|
|
110
|
-
*/
|
|
111
|
-
export declare class StdioClientTransport implements ClientTransport {
|
|
112
|
-
private stdout?;
|
|
113
|
-
private stdin?;
|
|
114
|
-
private messageHandler?;
|
|
115
|
-
private name?;
|
|
116
|
-
private readonly logger;
|
|
117
|
-
setProcess(stdout: Readable, stdin: Writable): void;
|
|
118
|
-
setName(name: string): void;
|
|
119
|
-
send(message: string): Promise<void>;
|
|
120
|
-
onMessage(handler: (message: string) => void): void;
|
|
121
|
-
close(): Promise<void>;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Bidirectional StdioTransport for child processes
|
|
125
|
-
* This class handles both server (receiving requests) and client (sending requests) functionality
|
|
126
|
-
* over a single stdio channel with proper message routing.
|
|
127
|
-
*
|
|
128
|
-
* Usage in child process:
|
|
129
|
-
* ```typescript
|
|
130
|
-
* const transport = new BidirectionalStdioTransport();
|
|
131
|
-
*
|
|
132
|
-
* // Register methods that parent can call
|
|
133
|
-
* transport.registerMethod('ping', async () => 'pong');
|
|
134
|
-
*
|
|
135
|
-
* // Make requests to parent
|
|
136
|
-
* const result = await transport.request('getTime');
|
|
137
|
-
* ```
|
|
138
|
-
*/
|
|
139
|
-
export declare class BidirectionalStdioTransport extends EventEmitter {
|
|
140
|
-
private readonly server;
|
|
141
|
-
private readonly client;
|
|
142
|
-
private readonly logger;
|
|
143
|
-
private buffer;
|
|
144
|
-
private name?;
|
|
145
|
-
private initialized;
|
|
146
|
-
constructor();
|
|
147
|
-
/**
|
|
148
|
-
* Set a name for this transport (used in logging)
|
|
149
|
-
*/
|
|
150
|
-
setName(name: string): void;
|
|
151
|
-
/**
|
|
152
|
-
* Initialize the bidirectional transport
|
|
153
|
-
* This should be called once after setting up all methods
|
|
154
|
-
*/
|
|
155
|
-
initialize(): Promise<void>;
|
|
156
|
-
/**
|
|
157
|
-
* Register a method that the parent can call
|
|
158
|
-
* @param method - Method name
|
|
159
|
-
* @param handler - Method handler function
|
|
160
|
-
*/
|
|
161
|
-
registerMethod<TParams = any, TResult = any>(method: string, handler: (params: TParams) => Promise<TResult> | TResult): void;
|
|
162
|
-
/**
|
|
163
|
-
* Send a request to the parent process
|
|
164
|
-
* @param method - Method name
|
|
165
|
-
* @param params - Method parameters
|
|
166
|
-
* @param options - Request options
|
|
167
|
-
* @returns Promise resolving to the response
|
|
168
|
-
*/
|
|
169
|
-
request<TParams = any, TResult = any>(method: string, params?: TParams, options?: {
|
|
170
|
-
timeout?: number;
|
|
171
|
-
}): Promise<TResult>;
|
|
172
|
-
/**
|
|
173
|
-
* Send a notification to the parent process (no response expected)
|
|
174
|
-
* @param method - Method name
|
|
175
|
-
* @param params - Method parameters
|
|
176
|
-
*/
|
|
177
|
-
notify<TParams = any>(method: string, params?: TParams): Promise<void>;
|
|
178
|
-
/**
|
|
179
|
-
* Get transport statistics
|
|
180
|
-
*/
|
|
181
|
-
getStats(): {
|
|
182
|
-
serverMethods: number;
|
|
183
|
-
pendingRequests: number;
|
|
184
|
-
initialized: boolean;
|
|
185
|
-
};
|
|
186
|
-
/**
|
|
187
|
-
* Close the transport and cleanup resources
|
|
188
|
-
*/
|
|
189
|
-
close(): Promise<void>;
|
|
190
|
-
/**
|
|
191
|
-
* Set up stdio communication handlers
|
|
192
|
-
*/
|
|
193
|
-
private setupStdioCommunication;
|
|
194
|
-
/**
|
|
195
|
-
* Handle incoming message and route to appropriate handler
|
|
196
|
-
*/
|
|
197
|
-
private handleIncomingMessage;
|
|
198
|
-
private safeParse;
|
|
199
|
-
/**
|
|
200
|
-
* Check if a message is a JSON-RPC response
|
|
201
|
-
*/
|
|
202
|
-
private isResponse;
|
|
203
|
-
/**
|
|
204
|
-
* Send a message to the parent process
|
|
205
|
-
*/
|
|
206
|
-
private sendMessage;
|
|
207
|
-
/**
|
|
208
|
-
* Set up event handlers
|
|
209
|
-
*/
|
|
210
|
-
private setupEventHandlers;
|
|
211
|
-
}
|
|
212
|
-
export declare class StdioServerTransport implements Transport {
|
|
213
|
-
private readonly stdio;
|
|
214
|
-
private readonly stdout;
|
|
215
|
-
private readonly server;
|
|
216
|
-
private name?;
|
|
217
|
-
private readonly logger;
|
|
218
|
-
constructor(stdio: Readable, stdout: Writable, server: JsonRpcServer);
|
|
219
|
-
setName(name: string): void;
|
|
220
|
-
get status(): TransportStatus;
|
|
221
|
-
isReady(): boolean;
|
|
222
|
-
initialize(): Promise<void>;
|
|
223
|
-
send<TRequest, TResponse>(message: TRequest): Promise<TResponse>;
|
|
224
|
-
onMessage<T>(): void;
|
|
225
|
-
close(): Promise<void>;
|
|
226
|
-
}
|