open-agents-ai 0.185.95 → 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 +53 -31
- 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) => {
|
|
@@ -68060,7 +68067,7 @@ ${historyLines}
|
|
|
68060
68067
|
|
|
68061
68068
|
Respond conversationally. Call task_complete with your final response.`;
|
|
68062
68069
|
const oaBin = process.argv[1] || "oa";
|
|
68063
|
-
const args = [taskPrompt, "--json"
|
|
68070
|
+
const args = [taskPrompt, "--json"];
|
|
68064
68071
|
if (model)
|
|
68065
68072
|
args.push("--model", model.replace(/^local\//, ""));
|
|
68066
68073
|
const streamMode = chatBody.stream !== false;
|
|
@@ -68073,10 +68080,8 @@ Respond conversationally. Call task_complete with your final response.`;
|
|
|
68073
68080
|
const child = spawn21("oa", args, {
|
|
68074
68081
|
cwd: cwdPath,
|
|
68075
68082
|
env: runEnv,
|
|
68076
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
68077
|
-
detached: true
|
|
68083
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
68078
68084
|
});
|
|
68079
|
-
child.unref();
|
|
68080
68085
|
if (streamMode) {
|
|
68081
68086
|
res.writeHead(200, {
|
|
68082
68087
|
"Content-Type": "text/event-stream",
|
|
@@ -68145,27 +68150,24 @@ Respond conversationally. Call task_complete with your final response.`;
|
|
|
68145
68150
|
const allOutput = rawBuffer.trim();
|
|
68146
68151
|
try {
|
|
68147
68152
|
const result = JSON.parse(allOutput);
|
|
68148
|
-
|
|
68149
|
-
|
|
68150
|
-
|
|
68151
|
-
|
|
68152
|
-
|
|
68153
|
-
if (textMatch)
|
|
68154
|
-
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;
|
|
68155
68158
|
}
|
|
68156
|
-
if (!content)
|
|
68157
|
-
content = summary;
|
|
68158
68159
|
fullContent = content;
|
|
68159
68160
|
res.write("data: " + JSON.stringify({
|
|
68160
68161
|
id: `chatcmpl-${session.id.slice(0, 8)}`,
|
|
68161
68162
|
object: "chat.completion.chunk",
|
|
68162
68163
|
choices: [{ index: 0, delta: { content }, finish_reason: null }]
|
|
68163
68164
|
}) + "\n\n");
|
|
68165
|
+
const meta = result.summary || "";
|
|
68164
68166
|
res.write("data: " + JSON.stringify({
|
|
68165
68167
|
type: "complete",
|
|
68166
|
-
turns:
|
|
68167
|
-
tokens:
|
|
68168
|
-
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),
|
|
68169
68171
|
duration: result.durationMs
|
|
68170
68172
|
}) + "\n\n");
|
|
68171
68173
|
} catch {
|
|
@@ -68194,18 +68196,14 @@ Respond conversationally. Call task_complete with your final response.`;
|
|
|
68194
68196
|
let content = "";
|
|
68195
68197
|
try {
|
|
68196
68198
|
const result = JSON.parse(output.trim());
|
|
68197
|
-
|
|
68198
|
-
|
|
68199
|
-
|
|
68200
|
-
|
|
68201
|
-
|
|
68202
|
-
|
|
68203
|
-
|
|
68204
|
-
|
|
68205
|
-
content = textMatch[1].trim();
|
|
68206
|
-
}
|
|
68207
|
-
if (!content)
|
|
68208
|
-
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
|
+
}
|
|
68209
68207
|
} catch {
|
|
68210
68208
|
content = output.trim().slice(0, 500);
|
|
68211
68209
|
}
|
|
@@ -69651,6 +69649,8 @@ ${entry.fullContent}`
|
|
|
69651
69649
|
emotionEngine?.appraise(event);
|
|
69652
69650
|
switch (event.type) {
|
|
69653
69651
|
case "tool_call":
|
|
69652
|
+
if (_apiCallbacks?.onToolCall)
|
|
69653
|
+
_apiCallbacks.onToolCall(event.toolName ?? "unknown", event.toolArgs);
|
|
69654
69654
|
toolSequence.push({
|
|
69655
69655
|
tool: event.toolName ?? "unknown",
|
|
69656
69656
|
argKeys: Object.keys(event.toolArgs ?? {})
|
|
@@ -69859,6 +69859,11 @@ ${entry.fullContent}`
|
|
|
69859
69859
|
if (sudoCallback)
|
|
69860
69860
|
sudoCallback(event.content ?? "");
|
|
69861
69861
|
break;
|
|
69862
|
+
case "assistant_text":
|
|
69863
|
+
if (_apiCallbacks?.onAssistantText && event.content) {
|
|
69864
|
+
_apiCallbacks.onAssistantText(event.content, event.turn ?? 0);
|
|
69865
|
+
}
|
|
69866
|
+
break;
|
|
69862
69867
|
case "complete":
|
|
69863
69868
|
break;
|
|
69864
69869
|
}
|
|
@@ -73292,7 +73297,7 @@ ${c2.dim("(Use /quit to exit)")}
|
|
|
73292
73297
|
showPrompt();
|
|
73293
73298
|
};
|
|
73294
73299
|
}
|
|
73295
|
-
async function runWithTUI(task, config, repoPath) {
|
|
73300
|
+
async function runWithTUI(task, config, repoPath, callbacks) {
|
|
73296
73301
|
const repoRoot = resolve32(repoPath ?? cwd());
|
|
73297
73302
|
const needsSetup = isFirstRun() || !await isModelAvailable(config);
|
|
73298
73303
|
if (needsSetup && config.backendType === "ollama") {
|
|
@@ -73332,6 +73337,7 @@ async function runWithTUI(task, config, repoPath) {
|
|
|
73332
73337
|
renderInfo("The agent will retry when you submit a task. Use /endpoint to reconfigure.");
|
|
73333
73338
|
}
|
|
73334
73339
|
}
|
|
73340
|
+
_apiCallbacks = callbacks ?? null;
|
|
73335
73341
|
renderCompactHeader(config.model);
|
|
73336
73342
|
renderUserMessage(task);
|
|
73337
73343
|
setTerminalTitle(task.slice(0, 60), getVersion4());
|
|
@@ -73602,7 +73608,7 @@ Rules:
|
|
|
73602
73608
|
process.exit(1);
|
|
73603
73609
|
}
|
|
73604
73610
|
}
|
|
73605
|
-
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;
|
|
73606
73612
|
var init_interactive = __esm({
|
|
73607
73613
|
"packages/cli/dist/tui/interactive.js"() {
|
|
73608
73614
|
"use strict";
|
|
@@ -73643,6 +73649,7 @@ var init_interactive = __esm({
|
|
|
73643
73649
|
init_overlay_lock();
|
|
73644
73650
|
init_neovim_mode();
|
|
73645
73651
|
taskManager = new BackgroundTaskManager();
|
|
73652
|
+
_apiCallbacks = null;
|
|
73646
73653
|
_shellToolRef = null;
|
|
73647
73654
|
_replToolRef = null;
|
|
73648
73655
|
_fullSubAgentToolRef = null;
|
|
@@ -73706,8 +73713,17 @@ async function runJson(task, config, repoPath) {
|
|
|
73706
73713
|
});
|
|
73707
73714
|
process.stderr.write = (() => true);
|
|
73708
73715
|
let result;
|
|
73716
|
+
const assistantTexts = [];
|
|
73717
|
+
const toolCallLog = [];
|
|
73709
73718
|
try {
|
|
73710
|
-
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
|
+
});
|
|
73711
73727
|
result = {
|
|
73712
73728
|
status: "completed",
|
|
73713
73729
|
summary: extractSummary(captured),
|
|
@@ -73727,6 +73743,12 @@ async function runJson(task, config, repoPath) {
|
|
|
73727
73743
|
const allCaptured = captured.join("");
|
|
73728
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, "");
|
|
73729
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
|
+
}
|
|
73730
73752
|
process.stdout.write(JSON.stringify(result, null, 2) + "\n");
|
|
73731
73753
|
if (result.exitCode !== 0)
|
|
73732
73754
|
process.exit(1);
|
package/package.json
CHANGED