@mobcode/openclaw-plugin 0.1.22 → 0.1.24
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/package.json +1 -1
- package/src/plugin-definition.js +47 -6
package/package.json
CHANGED
package/src/plugin-definition.js
CHANGED
|
@@ -90,17 +90,58 @@ export function createMobcodePluginDefinition() {
|
|
|
90
90
|
);
|
|
91
91
|
});
|
|
92
92
|
api.on("tool_result_persist", (event, ctx) => {
|
|
93
|
+
const toolCallId =
|
|
94
|
+
String(event?.message?.toolCallId ?? "").trim() ||
|
|
95
|
+
String(event?.toolCallId ?? "").trim() ||
|
|
96
|
+
String(ctx?.toolCallId ?? "").trim() ||
|
|
97
|
+
undefined;
|
|
98
|
+
const toolName =
|
|
99
|
+
String(event?.message?.toolName ?? "").trim() ||
|
|
100
|
+
String(event?.toolName ?? "").trim() ||
|
|
101
|
+
String(ctx?.toolName ?? "").trim() ||
|
|
102
|
+
undefined;
|
|
103
|
+
const messageId =
|
|
104
|
+
typeof event?.message?.id === "string" && event.message.id.trim()
|
|
105
|
+
? event.message.id.trim()
|
|
106
|
+
: toolCallId;
|
|
107
|
+
const persistedMessage = {
|
|
108
|
+
...(event?.message ?? {}),
|
|
109
|
+
role: event?.message?.role ?? "toolResult",
|
|
110
|
+
...(toolCallId ? { toolCallId } : {}),
|
|
111
|
+
...(toolName ? { toolName } : {}),
|
|
112
|
+
...(messageId ? { id: messageId } : {}),
|
|
113
|
+
};
|
|
114
|
+
console.warn(
|
|
115
|
+
"[mobcode-direct-debug] tool_result_persist enter",
|
|
116
|
+
"sessionKey=",
|
|
117
|
+
String(ctx?.sessionKey ?? "").trim() || "-",
|
|
118
|
+
"toolCallId=",
|
|
119
|
+
toolCallId ?? "-",
|
|
120
|
+
"toolName=",
|
|
121
|
+
toolName ?? "-",
|
|
122
|
+
"messageId=",
|
|
123
|
+
messageId ?? "-",
|
|
124
|
+
"role=",
|
|
125
|
+
String(persistedMessage.role ?? "").trim() || "-",
|
|
126
|
+
);
|
|
93
127
|
log.warn(
|
|
94
|
-
`[mobcode-debug] tool_result_persist sessionKey=${String(ctx?.sessionKey ?? "").trim() || "-"} toolCallId=${
|
|
128
|
+
`[mobcode-debug] tool_result_persist sessionKey=${String(ctx?.sessionKey ?? "").trim() || "-"} toolCallId=${toolCallId ?? "-"} toolName=${toolName ?? "-"} messageId=${messageId ?? "-"}`,
|
|
129
|
+
);
|
|
130
|
+
console.warn(
|
|
131
|
+
"[mobcode-direct-debug] before appendMessageSync",
|
|
132
|
+
"sessionKey=",
|
|
133
|
+
String(ctx?.sessionKey ?? "").trim() || "-",
|
|
134
|
+
"toolCallId=",
|
|
135
|
+
toolCallId ?? "-",
|
|
136
|
+
"toolName=",
|
|
137
|
+
toolName ?? "-",
|
|
95
138
|
);
|
|
96
139
|
store.appendMessageSync({
|
|
97
140
|
sessionKey: ctx?.sessionKey,
|
|
98
|
-
message:
|
|
99
|
-
messageId
|
|
100
|
-
typeof event?.message?.id === "string" && event.message.id.trim()
|
|
101
|
-
? event.message.id.trim()
|
|
102
|
-
: undefined,
|
|
141
|
+
message: persistedMessage,
|
|
142
|
+
messageId,
|
|
103
143
|
});
|
|
144
|
+
console.warn("[mobcode-direct-debug] after appendMessageSync");
|
|
104
145
|
});
|
|
105
146
|
},
|
|
106
147
|
};
|