@olane/o-node 0.7.12-alpha.55 → 0.7.12-alpha.56
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/src/connection/o-node-connection.d.ts.map +1 -1
- package/dist/src/connection/o-node-connection.js +2 -1
- package/dist/src/connection/o-node-connection.manager.d.ts.map +1 -1
- package/dist/src/connection/o-node-connection.manager.js +1 -0
- package/dist/src/connection/stream-handler.d.ts +3 -1
- package/dist/src/connection/stream-handler.d.ts.map +1 -1
- package/dist/src/connection/stream-handler.js +15 -3
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"o-node-connection.d.ts","sourceRoot":"","sources":["../../../src/connection/o-node-connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAEL,WAAW,EAGX,QAAQ,EACR,SAAS,EACV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,qBAAa,eAAgB,SAAQ,WAAW;IAIlC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,qBAAqB;IAHrD,aAAa,EAAE,UAAU,CAAC;IACjC,SAAS,CAAC,aAAa,EAAE,aAAa,CAAC;gBAER,MAAM,EAAE,qBAAqB;IAO5D,wBAAwB;IAYxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM;IAmBlB,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC;IAkBpC,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"o-node-connection.d.ts","sourceRoot":"","sources":["../../../src/connection/o-node-connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAEL,WAAW,EAGX,QAAQ,EACR,SAAS,EACV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,qBAAa,eAAgB,SAAQ,WAAW;IAIlC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,qBAAqB;IAHrD,aAAa,EAAE,UAAU,CAAC;IACjC,SAAS,CAAC,aAAa,EAAE,aAAa,CAAC;gBAER,MAAM,EAAE,qBAAqB;IAO5D,wBAAwB;IAYxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM;IAmBlB,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC;IAkBpC,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC;IAwC/C,YAAY,CAAC,MAAM,EAAE,MAAM;IAQ3B,KAAK,CAAC,KAAK,EAAE,KAAK;IAMlB,KAAK;CAKZ"}
|
|
@@ -55,7 +55,8 @@ export class oNodeConnection extends oConnection {
|
|
|
55
55
|
const data = new TextEncoder().encode(request.toString());
|
|
56
56
|
await this.streamHandler.send(stream, data, streamConfig);
|
|
57
57
|
// Handle response using StreamHandler
|
|
58
|
-
|
|
58
|
+
// Pass request handler if configured to enable bidirectional stream processing
|
|
59
|
+
const response = await this.streamHandler.handleOutgoingStream(stream, this.emitter, streamConfig, this.config.requestHandler);
|
|
59
60
|
// Handle cleanup of the stream
|
|
60
61
|
await this.postTransmit(stream);
|
|
61
62
|
return response;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"o-node-connection.manager.d.ts","sourceRoot":"","sources":["../../../src/connection/o-node-connection.manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAU,UAAU,EAAU,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,4BAA4B,EAAE,MAAM,kDAAkD,CAAC;AAEhG,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"o-node-connection.manager.d.ts","sourceRoot":"","sources":["../../../src/connection/o-node-connection.manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAU,UAAU,EAAU,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,4BAA4B,EAAE,MAAM,kDAAkD,CAAC;AAEhG,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGzD,qBAAa,sBAAuB,SAAQ,kBAAkB;IAKhD,QAAQ,CAAC,MAAM,EAAE,4BAA4B;IAJzD,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,oBAAoB,CAAC,CAAS;IACtC,OAAO,CAAC,qBAAqB,CAAC,CAAS;gBAElB,MAAM,EAAE,4BAA4B;IAOnD,qBAAqB,CACzB,cAAc,EAAE,QAAQ,EACxB,OAAO,EAAE,QAAQ,GAChB,OAAO,CAAC,UAAU,CAAC;IA4BtB;;;;OAIG;IACG,OAAO,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,CAAC;IA8BlE;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO;IA4BpC;;;;OAIG;IACH,yBAAyB,CAAC,OAAO,EAAE,QAAQ,GAAG,UAAU,GAAG,IAAI;CA0BhE"}
|
|
@@ -42,6 +42,7 @@ export class oNodeConnectionManager extends oConnectionManager {
|
|
|
42
42
|
isStream: config.isStream ?? false,
|
|
43
43
|
abortSignal: config.abortSignal,
|
|
44
44
|
runOnLimitedConnection: this.config.runOnLimitedConnection ?? false,
|
|
45
|
+
requestHandler: config.requestHandler ?? undefined,
|
|
45
46
|
});
|
|
46
47
|
return connection;
|
|
47
48
|
}
|
|
@@ -75,13 +75,15 @@ export declare class StreamHandler {
|
|
|
75
75
|
/**
|
|
76
76
|
* Handles an outgoing stream on the client side
|
|
77
77
|
* Listens for response messages and emits them via the event emitter
|
|
78
|
+
* If requestHandler is provided, also processes incoming router requests
|
|
78
79
|
*
|
|
79
80
|
* @param stream - The outgoing stream
|
|
80
81
|
* @param emitter - Event emitter for chunk events
|
|
81
82
|
* @param config - Configuration including abort signal
|
|
83
|
+
* @param requestHandler - Optional handler for processing router requests received on this stream
|
|
82
84
|
* @returns Promise that resolves with the final response
|
|
83
85
|
*/
|
|
84
|
-
handleOutgoingStream(stream: Stream, emitter: EventEmitter, config?: StreamHandlerConfig): Promise<oResponse>;
|
|
86
|
+
handleOutgoingStream(stream: Stream, emitter: EventEmitter, config?: StreamHandlerConfig, requestHandler?: (request: oRequest, stream: Stream) => Promise<RunResult>): Promise<oResponse>;
|
|
85
87
|
/**
|
|
86
88
|
* Forwards a request to the next hop and relays response chunks back
|
|
87
89
|
* This implements the middleware/proxy pattern for intermediate nodes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream-handler.d.ts","sourceRoot":"","sources":["../../../src/connection/stream-handler.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EACL,QAAQ,EACR,SAAS,EAIT,MAAM,EAEP,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAGtE;;;;;;;GAOG;AACH,qBAAa,aAAa;IACxB,OAA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AAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,SAAS,CAAC,GACzE,OAAO,CAAC,SAAS,CAAC;IAsGrB;;;;;;;OAOG;IACG,cAAc,CAClB,OAAO,EAAE,cAAc,EACvB,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,GAChD,OAAO,CAAC,IAAI,CAAC;CAyBjB"}
|
|
@@ -54,7 +54,7 @@ export class StreamHandler {
|
|
|
54
54
|
this.logger.debug('Stream re-use option:', stream.protocol, stream.status, stream.direction, stream.remoteWriteStatus, stream.writeStatus, stream.remoteReadStatus, stream.readStatus);
|
|
55
55
|
});
|
|
56
56
|
const existingStream = connection.streams.find((stream) => stream.status === 'open' &&
|
|
57
|
-
stream.protocol
|
|
57
|
+
stream.protocol === protocol &&
|
|
58
58
|
stream.writeStatus === 'writable' &&
|
|
59
59
|
stream.remoteReadStatus === 'readable');
|
|
60
60
|
if (existingStream) {
|
|
@@ -171,11 +171,14 @@ export class StreamHandler {
|
|
|
171
171
|
const request = new oRequest(message);
|
|
172
172
|
const responseBuilder = ResponseBuilder.create();
|
|
173
173
|
try {
|
|
174
|
+
this.logger.debug(`Processing request on stream: method=${request.method}, id=${request.id}`);
|
|
174
175
|
const result = await toolExecutor(request, stream);
|
|
175
176
|
const response = await responseBuilder.build(request, result, null);
|
|
176
177
|
await CoreUtils.sendResponse(response, stream);
|
|
178
|
+
this.logger.debug(`Successfully processed request: method=${request.method}, id=${request.id}`);
|
|
177
179
|
}
|
|
178
180
|
catch (error) {
|
|
181
|
+
this.logger.error(`Error processing request: method=${request.method}, id=${request.id}`, error);
|
|
179
182
|
const errorResponse = await responseBuilder.buildError(request, error);
|
|
180
183
|
await CoreUtils.sendResponse(errorResponse, stream);
|
|
181
184
|
}
|
|
@@ -183,13 +186,15 @@ export class StreamHandler {
|
|
|
183
186
|
/**
|
|
184
187
|
* Handles an outgoing stream on the client side
|
|
185
188
|
* Listens for response messages and emits them via the event emitter
|
|
189
|
+
* If requestHandler is provided, also processes incoming router requests
|
|
186
190
|
*
|
|
187
191
|
* @param stream - The outgoing stream
|
|
188
192
|
* @param emitter - Event emitter for chunk events
|
|
189
193
|
* @param config - Configuration including abort signal
|
|
194
|
+
* @param requestHandler - Optional handler for processing router requests received on this stream
|
|
190
195
|
* @returns Promise that resolves with the final response
|
|
191
196
|
*/
|
|
192
|
-
async handleOutgoingStream(stream, emitter, config = {}) {
|
|
197
|
+
async handleOutgoingStream(stream, emitter, config = {}, requestHandler) {
|
|
193
198
|
return new Promise((resolve, reject) => {
|
|
194
199
|
let lastResponse;
|
|
195
200
|
const messageHandler = async (event) => {
|
|
@@ -218,7 +223,14 @@ export class StreamHandler {
|
|
|
218
223
|
}
|
|
219
224
|
}
|
|
220
225
|
else if (this.isRequest(message)) {
|
|
221
|
-
|
|
226
|
+
// Process incoming router requests if handler is provided
|
|
227
|
+
if (requestHandler) {
|
|
228
|
+
this.logger.debug('Received router request on client-side stream, processing...', message);
|
|
229
|
+
await this.handleRequestMessage(message, stream, requestHandler);
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
this.logger.warn('Received request message on client-side stream, ignoring (no handler)', message);
|
|
233
|
+
}
|
|
222
234
|
}
|
|
223
235
|
else {
|
|
224
236
|
this.logger.warn('Received unknown message type', message);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olane/o-node",
|
|
3
|
-
"version": "0.7.12-alpha.
|
|
3
|
+
"version": "0.7.12-alpha.56",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -54,12 +54,12 @@
|
|
|
54
54
|
"typescript": "5.4.5"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@olane/o-config": "0.7.12-alpha.
|
|
58
|
-
"@olane/o-core": "0.7.12-alpha.
|
|
59
|
-
"@olane/o-protocol": "0.7.12-alpha.
|
|
60
|
-
"@olane/o-tool": "0.7.12-alpha.
|
|
57
|
+
"@olane/o-config": "0.7.12-alpha.56",
|
|
58
|
+
"@olane/o-core": "0.7.12-alpha.56",
|
|
59
|
+
"@olane/o-protocol": "0.7.12-alpha.56",
|
|
60
|
+
"@olane/o-tool": "0.7.12-alpha.56",
|
|
61
61
|
"debug": "^4.4.1",
|
|
62
62
|
"dotenv": "^16.5.0"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "e59edf30cd442f528f9b4981ca69572b3777aa4e"
|
|
65
65
|
}
|