ragent-cli 1.5.0 → 1.5.1
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 +55 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -31,7 +31,7 @@ var require_package = __commonJS({
|
|
|
31
31
|
"package.json"(exports2, module2) {
|
|
32
32
|
module2.exports = {
|
|
33
33
|
name: "ragent-cli",
|
|
34
|
-
version: "1.5.
|
|
34
|
+
version: "1.5.1",
|
|
35
35
|
description: "CLI agent for rAgent Live \u2014 browser-first terminal control plane for AI coding agents",
|
|
36
36
|
main: "dist/index.js",
|
|
37
37
|
bin: {
|
|
@@ -2720,6 +2720,8 @@ var os6 = __toESM(require("os"));
|
|
|
2720
2720
|
var import_child_process5 = require("child_process");
|
|
2721
2721
|
var ClaudeCodeParser = class {
|
|
2722
2722
|
name = "claude-code";
|
|
2723
|
+
/** Maps tool_use id → tool name for matching results back to tools. */
|
|
2724
|
+
pendingTools = /* @__PURE__ */ new Map();
|
|
2723
2725
|
parseLine(line) {
|
|
2724
2726
|
let obj;
|
|
2725
2727
|
try {
|
|
@@ -2727,7 +2729,16 @@ var ClaudeCodeParser = class {
|
|
|
2727
2729
|
} catch {
|
|
2728
2730
|
return null;
|
|
2729
2731
|
}
|
|
2730
|
-
if (
|
|
2732
|
+
if (!obj.message?.content) return null;
|
|
2733
|
+
if (obj.type === "assistant") {
|
|
2734
|
+
return this.parseAssistant(obj);
|
|
2735
|
+
}
|
|
2736
|
+
if (obj.type === "user") {
|
|
2737
|
+
return this.parseUserToolResults(obj);
|
|
2738
|
+
}
|
|
2739
|
+
return null;
|
|
2740
|
+
}
|
|
2741
|
+
parseAssistant(obj) {
|
|
2731
2742
|
const content = obj.message.content;
|
|
2732
2743
|
const textBlocks = [];
|
|
2733
2744
|
const tools = [];
|
|
@@ -2735,6 +2746,9 @@ var ClaudeCodeParser = class {
|
|
|
2735
2746
|
if (block.type === "text" && typeof block.text === "string") {
|
|
2736
2747
|
textBlocks.push(block.text);
|
|
2737
2748
|
} else if (block.type === "tool_use" && block.name) {
|
|
2749
|
+
if (block.id) {
|
|
2750
|
+
this.pendingTools.set(block.id, block.name);
|
|
2751
|
+
}
|
|
2738
2752
|
tools.push({
|
|
2739
2753
|
name: block.name,
|
|
2740
2754
|
input: block.input,
|
|
@@ -2742,6 +2756,12 @@ var ClaudeCodeParser = class {
|
|
|
2742
2756
|
});
|
|
2743
2757
|
}
|
|
2744
2758
|
}
|
|
2759
|
+
if (this.pendingTools.size > 500) {
|
|
2760
|
+
const keys = [...this.pendingTools.keys()];
|
|
2761
|
+
for (let i = 0; i < 250; i++) {
|
|
2762
|
+
this.pendingTools.delete(keys[i]);
|
|
2763
|
+
}
|
|
2764
|
+
}
|
|
2745
2765
|
const text = textBlocks.join("\n").trim();
|
|
2746
2766
|
if (!text && tools.length === 0) return null;
|
|
2747
2767
|
return {
|
|
@@ -2752,6 +2772,39 @@ var ClaudeCodeParser = class {
|
|
|
2752
2772
|
timestamp: obj.timestamp ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
2753
2773
|
};
|
|
2754
2774
|
}
|
|
2775
|
+
parseUserToolResults(obj) {
|
|
2776
|
+
const content = obj.message.content;
|
|
2777
|
+
const tools = [];
|
|
2778
|
+
for (const block of content) {
|
|
2779
|
+
if (block.type !== "tool_result") continue;
|
|
2780
|
+
const toolName = (block.tool_use_id && this.pendingTools.get(block.tool_use_id)) ?? "Tool";
|
|
2781
|
+
const resultText = this.extractToolResultText(block);
|
|
2782
|
+
if (block.tool_use_id) {
|
|
2783
|
+
this.pendingTools.delete(block.tool_use_id);
|
|
2784
|
+
}
|
|
2785
|
+
tools.push({
|
|
2786
|
+
name: toolName,
|
|
2787
|
+
status: block.is_error ? "error" : "completed",
|
|
2788
|
+
result: resultText || void 0
|
|
2789
|
+
});
|
|
2790
|
+
}
|
|
2791
|
+
if (tools.length === 0) return null;
|
|
2792
|
+
return {
|
|
2793
|
+
turnId: obj.uuid ?? `result-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
|
|
2794
|
+
role: "user",
|
|
2795
|
+
content: "",
|
|
2796
|
+
tools,
|
|
2797
|
+
timestamp: obj.timestamp ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
2798
|
+
};
|
|
2799
|
+
}
|
|
2800
|
+
extractToolResultText(block) {
|
|
2801
|
+
const rc = block.content;
|
|
2802
|
+
if (typeof rc === "string") return rc;
|
|
2803
|
+
if (Array.isArray(rc)) {
|
|
2804
|
+
return rc.filter((item) => item.type === "text" && typeof item.text === "string").map((item) => item.text).join("\n");
|
|
2805
|
+
}
|
|
2806
|
+
return "";
|
|
2807
|
+
}
|
|
2755
2808
|
};
|
|
2756
2809
|
var CodexCliParser = class {
|
|
2757
2810
|
name = "codex-cli";
|