@olane/o-node 0.7.12-alpha.59 → 0.7.12-alpha.60
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.
|
@@ -30,7 +30,7 @@ export declare class StreamHandler {
|
|
|
30
30
|
/**
|
|
31
31
|
* Decodes a stream message event into a JSON object
|
|
32
32
|
*/
|
|
33
|
-
decodeMessage(event: any): Promise<any>;
|
|
33
|
+
decodeMessage(event: any): Promise<any[]>;
|
|
34
34
|
/**
|
|
35
35
|
* Gets an existing open stream or creates a new one based on reuse policy
|
|
36
36
|
*
|
|
@@ -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;
|
|
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,O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AE,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,SAAS,CAAC,GACzE,OAAO,CAAC,SAAS,CAAC;IAoGrB;;;;;;;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"}
|
|
@@ -64,11 +64,12 @@ export class StreamHandler {
|
|
|
64
64
|
}
|
|
65
65
|
// Create new stream
|
|
66
66
|
this.logger.debug('Creating new stream');
|
|
67
|
-
|
|
67
|
+
const stream = await connection.newStream(protocol, {
|
|
68
68
|
signal: config.signal,
|
|
69
69
|
maxOutboundStreams: config.maxOutboundStreams ?? 1000,
|
|
70
70
|
runOnLimitedConnection: config.runOnLimitedConnection ?? false,
|
|
71
71
|
});
|
|
72
|
+
return stream;
|
|
72
73
|
}
|
|
73
74
|
/**
|
|
74
75
|
* Sends data through a stream with backpressure handling
|
|
@@ -130,23 +131,18 @@ export class StreamHandler {
|
|
|
130
131
|
if (!event.data) {
|
|
131
132
|
return;
|
|
132
133
|
}
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
this.logger.warn('Received response message on server-side stream, ignoring', message);
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
this.logger.warn('Received unknown message type', message);
|
|
149
|
-
}
|
|
134
|
+
const messages = await this.decodeMessage(event);
|
|
135
|
+
await Promise.all(messages.map(async (message) => {
|
|
136
|
+
if (this.isRequest(message)) {
|
|
137
|
+
await this.handleRequestMessage(message, stream, toolExecutor);
|
|
138
|
+
}
|
|
139
|
+
else if (this.isResponse(message)) {
|
|
140
|
+
this.logger.warn('Received response message on server-side stream, ignoring', message);
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
this.logger.warn('Received unknown message type', message);
|
|
144
|
+
}
|
|
145
|
+
}));
|
|
150
146
|
}
|
|
151
147
|
catch (error) {
|
|
152
148
|
this.logger.error('Error handling stream message:', error);
|
|
@@ -204,38 +200,32 @@ export class StreamHandler {
|
|
|
204
200
|
return;
|
|
205
201
|
}
|
|
206
202
|
try {
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
emitter.emit('chunk', response);
|
|
219
|
-
// Check if this is the last chunk
|
|
220
|
-
if (response.result._last || !response.result._isStreaming) {
|
|
221
|
-
lastResponse = response;
|
|
222
|
-
cleanup();
|
|
223
|
-
resolve(response);
|
|
203
|
+
const messages = await this.decodeMessage(event);
|
|
204
|
+
await Promise.all(messages.map(async (message) => {
|
|
205
|
+
if (this.isResponse(message)) {
|
|
206
|
+
// Emit chunk for streaming responses
|
|
207
|
+
emitter.emit('chunk', message);
|
|
208
|
+
// Check if this is the last chunk
|
|
209
|
+
if (message.result._last || !message.result._isStreaming) {
|
|
210
|
+
lastResponse = message;
|
|
211
|
+
cleanup();
|
|
212
|
+
resolve(message);
|
|
213
|
+
}
|
|
224
214
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
215
|
+
else if (this.isRequest(message)) {
|
|
216
|
+
// Process incoming router requests if handler is provided
|
|
217
|
+
if (requestHandler) {
|
|
218
|
+
this.logger.debug('Received router request on client-side stream, processing...', message);
|
|
219
|
+
await this.handleRequestMessage(message, stream, requestHandler);
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
this.logger.warn('Received request message on client-side stream, ignoring (no handler)', message);
|
|
223
|
+
}
|
|
231
224
|
}
|
|
232
225
|
else {
|
|
233
|
-
this.logger.warn('Received
|
|
226
|
+
this.logger.warn('Received unknown message type', message);
|
|
234
227
|
}
|
|
235
|
-
}
|
|
236
|
-
else {
|
|
237
|
-
this.logger.warn('Received unknown message type', message);
|
|
238
|
-
}
|
|
228
|
+
}));
|
|
239
229
|
}
|
|
240
230
|
catch (error) {
|
|
241
231
|
this.logger.error('Error handling response message:', error);
|
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.60",
|
|
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.60",
|
|
58
|
+
"@olane/o-core": "0.7.12-alpha.60",
|
|
59
|
+
"@olane/o-protocol": "0.7.12-alpha.60",
|
|
60
|
+
"@olane/o-tool": "0.7.12-alpha.60",
|
|
61
61
|
"debug": "^4.4.1",
|
|
62
62
|
"dotenv": "^16.5.0"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "4419813eec431b7030c230069d08984f25bbaed2"
|
|
65
65
|
}
|