open-agents-ai 0.185.84 → 0.185.85
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/index.js +57 -20
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -68073,12 +68073,30 @@ Respond conversationally. Call task_complete with your final response.`;
|
|
|
68073
68073
|
child.stderr?.on("data", () => {
|
|
68074
68074
|
});
|
|
68075
68075
|
child.on("close", () => {
|
|
68076
|
-
if (
|
|
68076
|
+
if (rawBuffer.trim()) {
|
|
68077
|
+
for (const line of rawBuffer.split("\n")) {
|
|
68078
|
+
if (!line.trim())
|
|
68079
|
+
continue;
|
|
68080
|
+
try {
|
|
68081
|
+
const evt = JSON.parse(line);
|
|
68082
|
+
if (evt.type === "text" && evt.content && !fullContent.includes(evt.content)) {
|
|
68083
|
+
fullContent += evt.content + "\n";
|
|
68084
|
+
res.write("data: " + JSON.stringify({
|
|
68085
|
+
id: `chatcmpl-${session.id.slice(0, 8)}`,
|
|
68086
|
+
object: "chat.completion.chunk",
|
|
68087
|
+
choices: [{ index: 0, delta: { content: evt.content + "\n" }, finish_reason: null }]
|
|
68088
|
+
}) + "\n\n");
|
|
68089
|
+
}
|
|
68090
|
+
} catch {
|
|
68091
|
+
}
|
|
68092
|
+
}
|
|
68093
|
+
}
|
|
68094
|
+
if (!fullContent) {
|
|
68077
68095
|
try {
|
|
68078
|
-
const result = JSON.parse(rawBuffer.trim());
|
|
68079
|
-
const summary = result.summary || "";
|
|
68080
|
-
const match = summary.match(/Tokens:\s*[\d,]+\s+([\s\S]*)/);
|
|
68081
|
-
const cleanContent = match ? match[1].trim() : summary;
|
|
68096
|
+
const result = JSON.parse(rawBuffer.trim().split("\n").pop() || "{}");
|
|
68097
|
+
const summary = result.summary || result.text || "";
|
|
68098
|
+
const match = summary.match ? summary.match(/Tokens:\s*[\d,]+\s+([\s\S]*)/) : null;
|
|
68099
|
+
const cleanContent = match ? match[1].trim() : result.text || summary;
|
|
68082
68100
|
if (cleanContent) {
|
|
68083
68101
|
fullContent = cleanContent;
|
|
68084
68102
|
res.write("data: " + JSON.stringify({
|
|
@@ -68112,26 +68130,28 @@ Respond conversationally. Call task_complete with your final response.`;
|
|
|
68112
68130
|
});
|
|
68113
68131
|
await new Promise((resolve36) => child.on("close", resolve36));
|
|
68114
68132
|
let content = "";
|
|
68115
|
-
|
|
68116
|
-
|
|
68117
|
-
|
|
68118
|
-
|
|
68119
|
-
|
|
68120
|
-
|
|
68121
|
-
|
|
68122
|
-
|
|
68123
|
-
|
|
68124
|
-
|
|
68125
|
-
|
|
68126
|
-
if (
|
|
68133
|
+
let summaryContent = "";
|
|
68134
|
+
for (const line of output.split("\n")) {
|
|
68135
|
+
if (!line.trim())
|
|
68136
|
+
continue;
|
|
68137
|
+
try {
|
|
68138
|
+
const evt = JSON.parse(line);
|
|
68139
|
+
if (evt.type === "text" && evt.content) {
|
|
68140
|
+
content += evt.content + "\n";
|
|
68141
|
+
} else if (evt.status === "completed" || evt.status === "failed") {
|
|
68142
|
+
if (evt.text)
|
|
68143
|
+
content = evt.text;
|
|
68144
|
+
if (!content.trim()) {
|
|
68127
68145
|
const summary = evt.summary || "";
|
|
68128
68146
|
const match = summary.match(/Tokens:\s*[\d,]+\s+([\s\S]*)/);
|
|
68129
|
-
|
|
68147
|
+
summaryContent = match ? match[1].trim() : summary;
|
|
68130
68148
|
}
|
|
68131
|
-
} catch {
|
|
68132
68149
|
}
|
|
68150
|
+
} catch {
|
|
68133
68151
|
}
|
|
68134
68152
|
}
|
|
68153
|
+
if (!content.trim())
|
|
68154
|
+
content = summaryContent;
|
|
68135
68155
|
addAssistantMessage(session, content.trim());
|
|
68136
68156
|
jsonResponse(res, 200, {
|
|
68137
68157
|
session_id: session.id,
|
|
@@ -73618,12 +73638,25 @@ async function runCommand(opts, config) {
|
|
|
73618
73638
|
async function runJson(task, config, repoPath) {
|
|
73619
73639
|
const startTime = Date.now();
|
|
73620
73640
|
const origWrite = process.stdout.write.bind(process.stdout);
|
|
73641
|
+
const origStderr = process.stderr.write.bind(process.stderr);
|
|
73621
73642
|
const captured = [];
|
|
73643
|
+
let assistantText = "";
|
|
73644
|
+
let textBuffer = "";
|
|
73622
73645
|
process.stdout.write = ((chunk, ...args) => {
|
|
73623
|
-
if (typeof chunk === "string")
|
|
73646
|
+
if (typeof chunk === "string") {
|
|
73624
73647
|
captured.push(chunk);
|
|
73648
|
+
const clean = chunk.replace(/\x1B\[[0-9;]*[A-Za-z]/g, "").replace(/\x1B\].*?\x07/g, "").replace(/\x1B[78]/g, "");
|
|
73649
|
+
if (clean.trim()) {
|
|
73650
|
+
const stripped = clean.replace(/[▸▹⎿]/g, "").trim();
|
|
73651
|
+
if (stripped.length > 0 && !stripped.startsWith("\x1B") && stripped.length < 5e3) {
|
|
73652
|
+
textBuffer += stripped + "\n";
|
|
73653
|
+
origWrite(JSON.stringify({ type: "text", content: stripped }) + "\n");
|
|
73654
|
+
}
|
|
73655
|
+
}
|
|
73656
|
+
}
|
|
73625
73657
|
return true;
|
|
73626
73658
|
});
|
|
73659
|
+
process.stderr.write = (() => true);
|
|
73627
73660
|
let result;
|
|
73628
73661
|
try {
|
|
73629
73662
|
await runWithTUI(task, config, repoPath);
|
|
@@ -73642,6 +73675,10 @@ async function runJson(task, config, repoPath) {
|
|
|
73642
73675
|
};
|
|
73643
73676
|
}
|
|
73644
73677
|
process.stdout.write = origWrite;
|
|
73678
|
+
process.stderr.write = origStderr;
|
|
73679
|
+
if (textBuffer.trim()) {
|
|
73680
|
+
result.text = textBuffer.trim();
|
|
73681
|
+
}
|
|
73645
73682
|
process.stdout.write(JSON.stringify(result, null, 2) + "\n");
|
|
73646
73683
|
if (result.exitCode !== 0)
|
|
73647
73684
|
process.exit(1);
|
package/package.json
CHANGED