open-agents-ai 0.185.96 → 0.185.97
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 +51 -27
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -26914,6 +26914,10 @@ Take a DIFFERENT action now.`
|
|
|
26914
26914
|
turn,
|
|
26915
26915
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
26916
26916
|
});
|
|
26917
|
+
const cleanNonStream = content.replace(/<think>[\s\S]*?<\/think>/g, "").trim();
|
|
26918
|
+
if (cleanNonStream) {
|
|
26919
|
+
this.emit({ type: "assistant_text", content: cleanNonStream, turn, timestamp: (/* @__PURE__ */ new Date()).toISOString() });
|
|
26920
|
+
}
|
|
26917
26921
|
if (/task.?complete|all tests pass/i.test(content)) {
|
|
26918
26922
|
completed = true;
|
|
26919
26923
|
summary = content;
|
|
@@ -28825,6 +28829,9 @@ ${description}`
|
|
|
28825
28829
|
}
|
|
28826
28830
|
this.emit({ type: "stream_end", content, turn, timestamp: (/* @__PURE__ */ new Date()).toISOString() });
|
|
28827
28831
|
const cleanContent = content.replace(/<think>[\s\S]*?<\/think>/g, "").trim();
|
|
28832
|
+
if (cleanContent) {
|
|
28833
|
+
this.emit({ type: "assistant_text", content: cleanContent, turn, timestamp: (/* @__PURE__ */ new Date()).toISOString() });
|
|
28834
|
+
}
|
|
28828
28835
|
const hadThinking = content.includes("<think>") && content.includes("</think>");
|
|
28829
28836
|
const thinkOnlyResponse = hadThinking && !cleanContent;
|
|
28830
28837
|
const toolCalls = toolCallAccumulators.size > 0 ? Array.from(toolCallAccumulators.values()).map((tc) => {
|
|
@@ -68143,27 +68150,24 @@ Respond conversationally. Call task_complete with your final response.`;
|
|
|
68143
68150
|
const allOutput = rawBuffer.trim();
|
|
68144
68151
|
try {
|
|
68145
68152
|
const result = JSON.parse(allOutput);
|
|
68146
|
-
|
|
68147
|
-
|
|
68148
|
-
|
|
68149
|
-
|
|
68150
|
-
|
|
68151
|
-
if (textMatch)
|
|
68152
|
-
content = textMatch[1].trim();
|
|
68153
|
+
let content = result.assistant_text || "";
|
|
68154
|
+
if (!content) {
|
|
68155
|
+
const summary = result.summary || "";
|
|
68156
|
+
const summaryMatch = summary.match(/Tokens:\s*[\d,]+\s+([\s\S]*)/);
|
|
68157
|
+
content = summaryMatch ? summaryMatch[1].trim() : summary;
|
|
68153
68158
|
}
|
|
68154
|
-
if (!content)
|
|
68155
|
-
content = summary;
|
|
68156
68159
|
fullContent = content;
|
|
68157
68160
|
res.write("data: " + JSON.stringify({
|
|
68158
68161
|
id: `chatcmpl-${session.id.slice(0, 8)}`,
|
|
68159
68162
|
object: "chat.completion.chunk",
|
|
68160
68163
|
choices: [{ index: 0, delta: { content }, finish_reason: null }]
|
|
68161
68164
|
}) + "\n\n");
|
|
68165
|
+
const meta = result.summary || "";
|
|
68162
68166
|
res.write("data: " + JSON.stringify({
|
|
68163
68167
|
type: "complete",
|
|
68164
|
-
turns:
|
|
68165
|
-
tokens:
|
|
68166
|
-
toolCalls: parseInt(
|
|
68168
|
+
turns: meta.match(/(\d+) turns/)?.[1],
|
|
68169
|
+
tokens: meta.match(/Tokens:\s*([\d,]+)/)?.[1],
|
|
68170
|
+
toolCalls: parseInt(meta.match(/(\d+) tool calls/)?.[1] || "0", 10),
|
|
68167
68171
|
duration: result.durationMs
|
|
68168
68172
|
}) + "\n\n");
|
|
68169
68173
|
} catch {
|
|
@@ -68192,18 +68196,14 @@ Respond conversationally. Call task_complete with your final response.`;
|
|
|
68192
68196
|
let content = "";
|
|
68193
68197
|
try {
|
|
68194
68198
|
const result = JSON.parse(output.trim());
|
|
68195
|
-
|
|
68196
|
-
|
|
68197
|
-
|
|
68198
|
-
|
|
68199
|
-
|
|
68200
|
-
|
|
68201
|
-
|
|
68202
|
-
|
|
68203
|
-
content = textMatch[1].trim();
|
|
68204
|
-
}
|
|
68205
|
-
if (!content)
|
|
68206
|
-
content = summary;
|
|
68199
|
+
if (result.assistant_text) {
|
|
68200
|
+
content = result.assistant_text;
|
|
68201
|
+
}
|
|
68202
|
+
if (!content) {
|
|
68203
|
+
const summary = result.summary || "";
|
|
68204
|
+
const summaryMatch = summary.match(/Tokens:\s*[\d,]+\s+([\s\S]*)/);
|
|
68205
|
+
content = summaryMatch ? summaryMatch[1].trim() : summary;
|
|
68206
|
+
}
|
|
68207
68207
|
} catch {
|
|
68208
68208
|
content = output.trim().slice(0, 500);
|
|
68209
68209
|
}
|
|
@@ -69649,6 +69649,8 @@ ${entry.fullContent}`
|
|
|
69649
69649
|
emotionEngine?.appraise(event);
|
|
69650
69650
|
switch (event.type) {
|
|
69651
69651
|
case "tool_call":
|
|
69652
|
+
if (_apiCallbacks?.onToolCall)
|
|
69653
|
+
_apiCallbacks.onToolCall(event.toolName ?? "unknown", event.toolArgs);
|
|
69652
69654
|
toolSequence.push({
|
|
69653
69655
|
tool: event.toolName ?? "unknown",
|
|
69654
69656
|
argKeys: Object.keys(event.toolArgs ?? {})
|
|
@@ -69857,6 +69859,11 @@ ${entry.fullContent}`
|
|
|
69857
69859
|
if (sudoCallback)
|
|
69858
69860
|
sudoCallback(event.content ?? "");
|
|
69859
69861
|
break;
|
|
69862
|
+
case "assistant_text":
|
|
69863
|
+
if (_apiCallbacks?.onAssistantText && event.content) {
|
|
69864
|
+
_apiCallbacks.onAssistantText(event.content, event.turn ?? 0);
|
|
69865
|
+
}
|
|
69866
|
+
break;
|
|
69860
69867
|
case "complete":
|
|
69861
69868
|
break;
|
|
69862
69869
|
}
|
|
@@ -73290,7 +73297,7 @@ ${c2.dim("(Use /quit to exit)")}
|
|
|
73290
73297
|
showPrompt();
|
|
73291
73298
|
};
|
|
73292
73299
|
}
|
|
73293
|
-
async function runWithTUI(task, config, repoPath) {
|
|
73300
|
+
async function runWithTUI(task, config, repoPath, callbacks) {
|
|
73294
73301
|
const repoRoot = resolve32(repoPath ?? cwd());
|
|
73295
73302
|
const needsSetup = isFirstRun() || !await isModelAvailable(config);
|
|
73296
73303
|
if (needsSetup && config.backendType === "ollama") {
|
|
@@ -73330,6 +73337,7 @@ async function runWithTUI(task, config, repoPath) {
|
|
|
73330
73337
|
renderInfo("The agent will retry when you submit a task. Use /endpoint to reconfigure.");
|
|
73331
73338
|
}
|
|
73332
73339
|
}
|
|
73340
|
+
_apiCallbacks = callbacks ?? null;
|
|
73333
73341
|
renderCompactHeader(config.model);
|
|
73334
73342
|
renderUserMessage(task);
|
|
73335
73343
|
setTerminalTitle(task.slice(0, 60), getVersion4());
|
|
@@ -73600,7 +73608,7 @@ Rules:
|
|
|
73600
73608
|
process.exit(1);
|
|
73601
73609
|
}
|
|
73602
73610
|
}
|
|
73603
|
-
var taskManager, _shellToolRef, _replToolRef, _fullSubAgentToolRef, _activeRunnerRef, _wireSubAgentCallbacks, _autoUpdatedThisSession, SELF_IMPROVE_INTERVAL, _tasksSinceImprove;
|
|
73611
|
+
var taskManager, _apiCallbacks, _shellToolRef, _replToolRef, _fullSubAgentToolRef, _activeRunnerRef, _wireSubAgentCallbacks, _autoUpdatedThisSession, SELF_IMPROVE_INTERVAL, _tasksSinceImprove;
|
|
73604
73612
|
var init_interactive = __esm({
|
|
73605
73613
|
"packages/cli/dist/tui/interactive.js"() {
|
|
73606
73614
|
"use strict";
|
|
@@ -73641,6 +73649,7 @@ var init_interactive = __esm({
|
|
|
73641
73649
|
init_overlay_lock();
|
|
73642
73650
|
init_neovim_mode();
|
|
73643
73651
|
taskManager = new BackgroundTaskManager();
|
|
73652
|
+
_apiCallbacks = null;
|
|
73644
73653
|
_shellToolRef = null;
|
|
73645
73654
|
_replToolRef = null;
|
|
73646
73655
|
_fullSubAgentToolRef = null;
|
|
@@ -73704,8 +73713,17 @@ async function runJson(task, config, repoPath) {
|
|
|
73704
73713
|
});
|
|
73705
73714
|
process.stderr.write = (() => true);
|
|
73706
73715
|
let result;
|
|
73716
|
+
const assistantTexts = [];
|
|
73717
|
+
const toolCallLog = [];
|
|
73707
73718
|
try {
|
|
73708
|
-
await runWithTUI(task, config, repoPath
|
|
73719
|
+
await runWithTUI(task, config, repoPath, {
|
|
73720
|
+
onAssistantText: (text) => {
|
|
73721
|
+
assistantTexts.push(text);
|
|
73722
|
+
},
|
|
73723
|
+
onToolCall: (tool, args) => {
|
|
73724
|
+
toolCallLog.push({ tool, args });
|
|
73725
|
+
}
|
|
73726
|
+
});
|
|
73709
73727
|
result = {
|
|
73710
73728
|
status: "completed",
|
|
73711
73729
|
summary: extractSummary(captured),
|
|
@@ -73725,6 +73743,12 @@ async function runJson(task, config, repoPath) {
|
|
|
73725
73743
|
const allCaptured = captured.join("");
|
|
73726
73744
|
const cleanText = allCaptured.replace(/\x1B\[[0-9;]*[A-Za-z]/g, "").replace(/\x1B\].*?\x07/g, "").replace(/\x1B[78]/g, "").replace(/\x1B\[\?[0-9;]*[hl]/g, "");
|
|
73727
73745
|
result.text = cleanText;
|
|
73746
|
+
if (assistantTexts.length > 0) {
|
|
73747
|
+
result.assistant_text = assistantTexts.join("\n\n");
|
|
73748
|
+
}
|
|
73749
|
+
if (toolCallLog.length > 0) {
|
|
73750
|
+
result.tool_calls = toolCallLog;
|
|
73751
|
+
}
|
|
73728
73752
|
process.stdout.write(JSON.stringify(result, null, 2) + "\n");
|
|
73729
73753
|
if (result.exitCode !== 0)
|
|
73730
73754
|
process.exit(1);
|
package/package.json
CHANGED