workflow-ai 1.0.5 → 1.0.6
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/src/runner.mjs +19 -2
package/package.json
CHANGED
package/src/runner.mjs
CHANGED
|
@@ -771,9 +771,26 @@ class StageExecutor {
|
|
|
771
771
|
reject(new Error(`Stage "${stageId}" timed out after ${timeout}s`));
|
|
772
772
|
}, timeout * 1000);
|
|
773
773
|
|
|
774
|
+
let stdoutBuffer = '';
|
|
774
775
|
child.stdout.on('data', (data) => {
|
|
775
|
-
|
|
776
|
-
|
|
776
|
+
const chunk = data.toString();
|
|
777
|
+
stdout += chunk;
|
|
778
|
+
// Парсим stream-json и выводим только текст дельт
|
|
779
|
+
stdoutBuffer += chunk;
|
|
780
|
+
const lines = stdoutBuffer.split('\n');
|
|
781
|
+
stdoutBuffer = lines.pop(); // незавершённая строка остаётся в буфере
|
|
782
|
+
for (const line of lines) {
|
|
783
|
+
if (!line.trim()) continue;
|
|
784
|
+
try {
|
|
785
|
+
const obj = JSON.parse(line);
|
|
786
|
+
if (obj.type === 'content_block_delta' && obj.delta?.text) {
|
|
787
|
+
process.stdout.write(obj.delta.text);
|
|
788
|
+
}
|
|
789
|
+
} catch {
|
|
790
|
+
// не JSON — выводим как есть
|
|
791
|
+
process.stdout.write(line + '\n');
|
|
792
|
+
}
|
|
793
|
+
}
|
|
777
794
|
});
|
|
778
795
|
|
|
779
796
|
child.stderr.on('data', (data) => {
|