paseo-dsh-direct 0.2.6 → 0.2.7
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/package.json +1 -1
- package/server/bridge-client.ts +24 -5
package/package.json
CHANGED
package/server/bridge-client.ts
CHANGED
|
@@ -379,6 +379,24 @@ export async function launchDshBridge(options: LaunchBridgeOptions): Promise<Dsh
|
|
|
379
379
|
}
|
|
380
380
|
}
|
|
381
381
|
|
|
382
|
+
/**
|
|
383
|
+
* Parse one stdout line from the bridge process. `undefined` means the line is
|
|
384
|
+
* not a protocol message: dsh also writes its own logs to stdout (for example
|
|
385
|
+
* the model-catalog line the deepseek-account provider emits), and such a line
|
|
386
|
+
* must not fail the bridge.
|
|
387
|
+
*/
|
|
388
|
+
export function parseBridgeLine(line: string): RpcResponse | RpcNotification | undefined {
|
|
389
|
+
let value: unknown;
|
|
390
|
+
try {
|
|
391
|
+
value = JSON.parse(line);
|
|
392
|
+
} catch {
|
|
393
|
+
return undefined;
|
|
394
|
+
}
|
|
395
|
+
return typeof value === "object" && value !== null && !Array.isArray(value)
|
|
396
|
+
? (value as RpcResponse | RpcNotification)
|
|
397
|
+
: undefined;
|
|
398
|
+
}
|
|
399
|
+
|
|
382
400
|
class JsonlBridgeClient implements DshBridge {
|
|
383
401
|
initialized!: BridgeInitializeResult;
|
|
384
402
|
readonly executable: string;
|
|
@@ -517,11 +535,12 @@ class JsonlBridgeClient implements DshBridge {
|
|
|
517
535
|
|
|
518
536
|
private acceptLine(line: string): void {
|
|
519
537
|
if (!line.trim()) return;
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
538
|
+
const message = parseBridgeLine(line);
|
|
539
|
+
if (message === undefined) {
|
|
540
|
+
// stdout carries the protocol, but dsh writes its own logs there too.
|
|
541
|
+
// Forward the line to stderr and keep the bridge alive instead of
|
|
542
|
+
// failing every provider snapshot on one log line.
|
|
543
|
+
process.stderr.write(`[paseo-dsh-direct] ignored dsh stdout: ${line.slice(0, 2000)}\n`);
|
|
525
544
|
return;
|
|
526
545
|
}
|
|
527
546
|
if ("id" in message) {
|