workflow-ai 1.0.6 → 1.0.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/src/runner.mjs +25 -2
package/package.json
CHANGED
package/src/runner.mjs
CHANGED
|
@@ -783,9 +783,19 @@ class StageExecutor {
|
|
|
783
783
|
if (!line.trim()) continue;
|
|
784
784
|
try {
|
|
785
785
|
const obj = JSON.parse(line);
|
|
786
|
+
// Claude: content_block_delta с delta.text
|
|
786
787
|
if (obj.type === 'content_block_delta' && obj.delta?.text) {
|
|
787
788
|
process.stdout.write(obj.delta.text);
|
|
788
789
|
}
|
|
790
|
+
// Qwen/Claude: assistant message с content text
|
|
791
|
+
else if (obj.type === 'assistant' && obj.message?.content) {
|
|
792
|
+
for (const block of obj.message.content) {
|
|
793
|
+
if (block.type === 'text' && block.text) {
|
|
794
|
+
process.stdout.write(block.text);
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
// result содержит финальный текст (дублирует assistant) — пропускаем
|
|
789
799
|
} catch {
|
|
790
800
|
// не JSON — выводим как есть
|
|
791
801
|
process.stdout.write(line + '\n');
|
|
@@ -800,6 +810,18 @@ class StageExecutor {
|
|
|
800
810
|
|
|
801
811
|
child.on('close', (code) => {
|
|
802
812
|
clearTimeout(timeoutId);
|
|
813
|
+
// Обрабатываем остаток буфера стриминга
|
|
814
|
+
if (stdoutBuffer.trim()) {
|
|
815
|
+
try {
|
|
816
|
+
const obj = JSON.parse(stdoutBuffer);
|
|
817
|
+
if (obj.type === 'content_block_delta' && obj.delta?.text) {
|
|
818
|
+
process.stdout.write(obj.delta.text);
|
|
819
|
+
}
|
|
820
|
+
} catch {
|
|
821
|
+
process.stdout.write(stdoutBuffer + '\n');
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
process.stdout.write('\n');
|
|
803
825
|
|
|
804
826
|
if (timedOut) return;
|
|
805
827
|
|
|
@@ -1101,7 +1123,8 @@ class PipelineRunner {
|
|
|
1101
1123
|
return {
|
|
1102
1124
|
steps: this.stepCount,
|
|
1103
1125
|
tasksExecuted: this.tasksExecuted,
|
|
1104
|
-
context: this.context
|
|
1126
|
+
context: this.context,
|
|
1127
|
+
failed: !this.running && this.stepCount < maxSteps
|
|
1105
1128
|
};
|
|
1106
1129
|
}
|
|
1107
1130
|
|
|
@@ -1437,7 +1460,7 @@ async function runPipeline(argv = process.argv.slice(2)) {
|
|
|
1437
1460
|
console.log(`Steps executed: ${result.steps}`);
|
|
1438
1461
|
console.log(`Tasks completed: ${result.tasksExecuted}`);
|
|
1439
1462
|
|
|
1440
|
-
return { exitCode: 0, result };
|
|
1463
|
+
return { exitCode: result.failed ? 1 : 0, result };
|
|
1441
1464
|
|
|
1442
1465
|
} catch (err) {
|
|
1443
1466
|
console.error(`\nError: ${err.message}`);
|