open-agents-ai 0.185.92 → 0.185.94
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 +41 -50
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -68141,48 +68141,42 @@ Respond conversationally. Call task_complete with your final response.`;
|
|
|
68141
68141
|
child.stderr?.on("data", () => {
|
|
68142
68142
|
});
|
|
68143
68143
|
child.on("close", () => {
|
|
68144
|
-
if (rawBuffer.trim()) {
|
|
68145
|
-
for (const line of rawBuffer.split("\n")) {
|
|
68146
|
-
if (!line.trim())
|
|
68147
|
-
continue;
|
|
68148
|
-
try {
|
|
68149
|
-
const evt = JSON.parse(line);
|
|
68150
|
-
if (evt.type === "text" && evt.content && !fullContent.includes(evt.content)) {
|
|
68151
|
-
fullContent += evt.content + "\n";
|
|
68152
|
-
res.write("data: " + JSON.stringify({
|
|
68153
|
-
id: `chatcmpl-${session.id.slice(0, 8)}`,
|
|
68154
|
-
object: "chat.completion.chunk",
|
|
68155
|
-
choices: [{ index: 0, delta: { content: evt.content + "\n" }, finish_reason: null }]
|
|
68156
|
-
}) + "\n\n");
|
|
68157
|
-
}
|
|
68158
|
-
} catch {
|
|
68159
|
-
}
|
|
68160
|
-
}
|
|
68161
|
-
}
|
|
68162
68144
|
if (!fullContent) {
|
|
68145
|
+
const allOutput = rawBuffer.trim();
|
|
68163
68146
|
try {
|
|
68164
|
-
const result = JSON.parse(
|
|
68165
|
-
const summary = result.summary ||
|
|
68166
|
-
const
|
|
68167
|
-
|
|
68168
|
-
if (
|
|
68169
|
-
|
|
68147
|
+
const result = JSON.parse(allOutput);
|
|
68148
|
+
const summary = result.summary || "";
|
|
68149
|
+
const summaryMatch = summary.match(/Tokens:\s*[\d,]+\s+([\s\S]*)/);
|
|
68150
|
+
let content = summaryMatch ? summaryMatch[1].trim() : "";
|
|
68151
|
+
if (content.length < 20 && result.text) {
|
|
68152
|
+
const textMatch = result.text.match(/Tokens:[\s\S]*?\n\s*([\s\S]+?)$/);
|
|
68153
|
+
if (textMatch)
|
|
68154
|
+
content = textMatch[1].trim();
|
|
68155
|
+
}
|
|
68156
|
+
if (!content)
|
|
68157
|
+
content = summary;
|
|
68158
|
+
fullContent = content;
|
|
68159
|
+
res.write("data: " + JSON.stringify({
|
|
68160
|
+
id: `chatcmpl-${session.id.slice(0, 8)}`,
|
|
68161
|
+
object: "chat.completion.chunk",
|
|
68162
|
+
choices: [{ index: 0, delta: { content }, finish_reason: null }]
|
|
68163
|
+
}) + "\n\n");
|
|
68164
|
+
res.write("data: " + JSON.stringify({
|
|
68165
|
+
type: "complete",
|
|
68166
|
+
turns: summary.match(/(\d+) turns/)?.[1],
|
|
68167
|
+
tokens: summary.match(/Tokens:\s*([\d,]+)/)?.[1],
|
|
68168
|
+
toolCalls: parseInt(summary.match(/(\d+) tool calls/)?.[1] || "0", 10),
|
|
68169
|
+
duration: result.durationMs
|
|
68170
|
+
}) + "\n\n");
|
|
68171
|
+
} catch {
|
|
68172
|
+
if (allOutput) {
|
|
68173
|
+
fullContent = allOutput.slice(0, 500);
|
|
68170
68174
|
res.write("data: " + JSON.stringify({
|
|
68171
68175
|
id: `chatcmpl-${session.id.slice(0, 8)}`,
|
|
68172
68176
|
object: "chat.completion.chunk",
|
|
68173
|
-
choices: [{ index: 0, delta: { content:
|
|
68174
|
-
}) + "\n\n");
|
|
68175
|
-
const turns = summary.match(/(\d+) turns/)?.[1];
|
|
68176
|
-
const tokens = summary.match(/Tokens:\s*([\d,]+)/)?.[1];
|
|
68177
|
-
res.write("data: " + JSON.stringify({
|
|
68178
|
-
type: "complete",
|
|
68179
|
-
turns,
|
|
68180
|
-
tokens,
|
|
68181
|
-
duration: result.durationMs,
|
|
68182
|
-
toolCalls: parseInt(summary.match(/(\d+) tool calls/)?.[1] || "0", 10)
|
|
68177
|
+
choices: [{ index: 0, delta: { content: fullContent }, finish_reason: null }]
|
|
68183
68178
|
}) + "\n\n");
|
|
68184
68179
|
}
|
|
68185
|
-
} catch {
|
|
68186
68180
|
}
|
|
68187
68181
|
}
|
|
68188
68182
|
addAssistantMessage(session, fullContent);
|
|
@@ -68201,22 +68195,19 @@ Respond conversationally. Call task_complete with your final response.`;
|
|
|
68201
68195
|
try {
|
|
68202
68196
|
const result = JSON.parse(output.trim());
|
|
68203
68197
|
const summary = result.summary || "";
|
|
68204
|
-
const
|
|
68205
|
-
|
|
68206
|
-
|
|
68207
|
-
|
|
68208
|
-
|
|
68209
|
-
|
|
68210
|
-
|
|
68211
|
-
|
|
68212
|
-
if (evt.status === "completed") {
|
|
68213
|
-
const summary = evt.summary || "";
|
|
68214
|
-
const match = summary.match(/Tokens:\s*[\d,]+\s+([\s\S]*)/);
|
|
68215
|
-
content = match ? match[1].trim() : summary;
|
|
68216
|
-
}
|
|
68217
|
-
} catch {
|
|
68218
|
-
}
|
|
68198
|
+
const summaryMatch = summary.match(/Tokens:\s*[\d,]+\s+([\s\S]*)/);
|
|
68199
|
+
if (summaryMatch && summaryMatch[1]?.trim()) {
|
|
68200
|
+
content = summaryMatch[1].trim();
|
|
68201
|
+
}
|
|
68202
|
+
if (content.length < 20 && result.text) {
|
|
68203
|
+
const textMatch = result.text.match(/Tokens:[\s\S]*?\n\s*([\s\S]+?)$/);
|
|
68204
|
+
if (textMatch && textMatch[1]?.trim())
|
|
68205
|
+
content = textMatch[1].trim();
|
|
68219
68206
|
}
|
|
68207
|
+
if (!content)
|
|
68208
|
+
content = summary;
|
|
68209
|
+
} catch {
|
|
68210
|
+
content = output.trim().slice(0, 500);
|
|
68220
68211
|
}
|
|
68221
68212
|
addAssistantMessage(session, content.trim());
|
|
68222
68213
|
jsonResponse(res, 200, {
|
package/package.json
CHANGED